Skip to content

Commit

Permalink
Add a couple of tests for the dark theme
Browse files Browse the repository at this point in the history
  • Loading branch information
shashi committed Oct 6, 2016
1 parent 5879695 commit 8dda492
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/density_dark.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Base.Test
using Gadfly, DataArrays, RDatasets, Distributions

global density_dark_tested

p = Gadfly.with_theme(:dark) do
plot(dataset("ggplot2", "diamonds"), x="Price", color="Cut", Geom.density)
end

# prevent these tests from running more than once
if !isdefined(:density_dark_tested)
svg_str_dark = stringmime(MIME("image/svg+xml"), p)
@test contains(svg_str_dark, hex(Gadfly.dark_theme.default_color))
@test contains(svg_str_dark, hex(Gadfly.dark_theme.background_color))
@test contains(svg_str_dark, hex(Gadfly.dark_theme.panel_fill))

# Test reset.
p2 = plot(dataset("ggplot2", "diamonds"), x="Price", color="Cut", Geom.density)
svg_str_light = stringmime(MIME("image/svg+xml"), p2)
@test !contains(svg_str_light, hex(Gadfly.dark_theme.default_color))
@test !contains(svg_str_light, hex(Gadfly.dark_theme.background_color))
@test !contains(svg_str_light, hex(Gadfly.dark_theme.panel_fill))

density_dark_tested=true
end

p
8 changes: 8 additions & 0 deletions test/hexbin_dark.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

using Gadfly, Distributions

vals = rand(MultivariateNormal([0.0, 0.0], [1.0 0.5; 0.5 1.0]), 10000)
Gadfly.with_theme(:dark) do
plot(x=vals[1,:], y=vals[2,:], Geom.hexbin)
end

2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ tests = [
("histogram2d", 6inch, 3inch),
("rectbin", 6inch, 3inch),
("density", 6inch, 3inch),
("density_dark", 6inch, 3inch),
("colorful_density", 6inch, 3inch),
("explicit_colorkey_title", 6inch, 3inch),
("explicit_subplot_titles", 6inch, 3inch),
Expand Down Expand Up @@ -70,6 +71,7 @@ tests = [
("ordered_line", 6inch, 3inch),
("nan_skipping", 6inch, 3inch),
("hexbin", 6inch, 3inch),
("hexbin_dark", 6inch, 3inch),
("spy", 6inch, 3inch),
("issue177", 6inch, 3inch),
("ribbon", 6inch, 3inch),
Expand Down

0 comments on commit 8dda492

Please sign in to comment.