3 require File.dirname(__FILE__) + "/gruff_test_case"
6 class LayerStub < Gruff::Layer; attr_reader :base_dir, :filenames, :selected_filename; end
8 class TestGruffScene < GruffTestCase
14 g.time = Time.mktime(2006, 7, 4, 4, 35)
15 g.write "test/output/scene_hazy_night.png"
21 g.time = Time.mktime(2006, 7, 4, 0, 0)
22 g.write "test/output/scene_stormy_night.png"
30 g.time = Time.mktime(2006, 7, 4, 6, 00)
31 g.write "test/output/scene_not_hazy_day.png"
34 def test_partly_cloudy
36 g.weather = "partly cloudy"
38 g.time = Time.mktime(2006, 7, 4, 13, 00)
39 g.write "test/output/scene_partly_cloudy_day.png"
47 g.time = Time.mktime(2006, 7, 4, 8, 00)
48 g.write "test/output/scene_stormy_day.png"
53 l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "clouds")
54 assert_equal %w(cloudy.png partly_cloudy.png stormy.png), l.filenames
56 l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "grass")
57 assert_equal 'default.png', l.selected_filename
59 l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "sky")
60 l.update Time.mktime(2006, 7, 4, 12, 35) # 12:35, July 4, 2006
61 assert_equal '1200.png', l.selected_filename
63 l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "sky")
64 l.update Time.mktime(2006, 7, 4, 0, 0) # 00:00, July 4, 2006
65 assert_equal '0000.png', l.selected_filename
67 l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "sky")
68 l.update Time.mktime(2006, 7, 4, 23, 35) # 23:35, July 4, 2006
69 assert_equal '2000.png', l.selected_filename
71 l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "sky")
72 l.update Time.mktime(2006, 7, 4, 0, 1) # 00:01, July 4, 2006
73 assert_equal '0000.png', l.selected_filename
75 l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "sky")
76 l.update Time.mktime(2006, 7, 4, 2, 0) # 02:00, July 4, 2006
77 assert_equal '0200.png', l.selected_filename
79 l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "sky")
80 l.update Time.mktime(2006, 7, 4, 4, 00) # 04:00, July 4, 2006
81 assert_equal '0400.png', l.selected_filename
83 # TODO Need number_sample folder
84 # l = LayerStub.new(File.expand_path("../assets/city_scene", File.dirname(__FILE__)), "number_sample")
85 # assert_equal %w(1.png 2.png default.png), l.filenames
87 # assert_equal 'default.png', l.selected_filename
93 g = Gruff::Scene.new("500x100", File.expand_path("../assets/city_scene", File.dirname(__FILE__)) )
94 g.layers = %w(background haze sky clouds)
95 g.weather_group = %w(clouds)
96 g.time_group = %w(background sky)