limelight 0.0.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. data/bin/icons/icon.ico +0 -0
  2. data/bin/icons/icon_48.gif +0 -0
  3. data/bin/icons/limelight.icns +0 -0
  4. data/bin/icons/splash.png +0 -0
  5. data/bin/limelight +6 -0
  6. data/bin/ll +10 -0
  7. data/bin/ll.bat +5 -0
  8. data/lib/init.rb +11 -0
  9. data/lib/limelight/build_exception.rb +45 -0
  10. data/lib/limelight/button_group_cache.rb +11 -0
  11. data/lib/limelight/casting_director.rb +72 -0
  12. data/lib/limelight/commands.rb +66 -0
  13. data/lib/limelight/file_chooser.rb +55 -0
  14. data/lib/limelight/file_filter.rb +26 -0
  15. data/lib/limelight/java_util.rb +29 -0
  16. data/lib/limelight/limelight_exception.rb +9 -0
  17. data/lib/limelight/loaders/file_scene_loader.rb +48 -0
  18. data/lib/limelight/menu_bar.rb +49 -0
  19. data/lib/limelight/paint_action.rb +25 -0
  20. data/lib/limelight/pen.rb +53 -0
  21. data/lib/limelight/players/button.rb +29 -0
  22. data/lib/limelight/players/check_box.rb +38 -0
  23. data/lib/limelight/players/combo_box.rb +44 -0
  24. data/lib/limelight/players/radio_button.rb +47 -0
  25. data/lib/limelight/players/text_area.rb +25 -0
  26. data/lib/limelight/players/text_box.rb +25 -0
  27. data/lib/limelight/players.rb +9 -0
  28. data/lib/limelight/producer.rb +141 -0
  29. data/lib/limelight/production.rb +64 -0
  30. data/lib/limelight/production_builder.rb +49 -0
  31. data/lib/limelight/prop.rb +241 -0
  32. data/lib/limelight/prop_builder.rb +60 -0
  33. data/lib/limelight/scene.rb +75 -0
  34. data/lib/limelight/stage.rb +93 -0
  35. data/lib/limelight/stage_builder.rb +62 -0
  36. data/lib/limelight/styles.rb +37 -0
  37. data/lib/limelight/styles_builder.rb +61 -0
  38. data/lib/limelight/theater.rb +42 -0
  39. data/lib/limelight/util.rb +26 -0
  40. data/lib/limelight/version.rb +20 -0
  41. data/lib/limelight.jar +0 -0
  42. data/productions/examples/8thlight.com/about/about.txt +24 -0
  43. data/productions/examples/8thlight.com/about/props.rb +11 -0
  44. data/productions/examples/8thlight.com/about/styles.rb +2 -0
  45. data/productions/examples/8thlight.com/footer.rb +6 -0
  46. data/productions/examples/8thlight.com/home/props.rb +28 -0
  47. data/productions/examples/8thlight.com/home/styles.rb +2 -0
  48. data/productions/examples/8thlight.com/images/anvil.jpg +0 -0
  49. data/productions/examples/8thlight.com/images/bg.jpg +0 -0
  50. data/productions/examples/8thlight.com/images/botticelli.jpg +0 -0
  51. data/productions/examples/8thlight.com/images/button_bg.jpg +0 -0
  52. data/productions/examples/8thlight.com/images/canvas_bg.jpg +0 -0
  53. data/productions/examples/8thlight.com/images/footer_bg.jpg +0 -0
  54. data/productions/examples/8thlight.com/images/header.jpg +0 -0
  55. data/productions/examples/8thlight.com/images/moses.jpg +0 -0
  56. data/productions/examples/8thlight.com/images/statemachine_thumbnail.png +0 -0
  57. data/productions/examples/8thlight.com/images/thumbnail_book.jpg +0 -0
  58. data/productions/examples/8thlight.com/menu.rb +11 -0
  59. data/productions/examples/8thlight.com/services/props.rb +11 -0
  60. data/productions/examples/8thlight.com/services/services.txt +8 -0
  61. data/productions/examples/8thlight.com/services/styles.rb +2 -0
  62. data/productions/examples/8thlight.com/stages.rb +8 -0
  63. data/productions/examples/8thlight.com/styles.rb +205 -0
  64. data/productions/examples/calculator/players/button.rb +24 -0
  65. data/productions/examples/calculator/players/calculator.rb +15 -0
  66. data/productions/examples/calculator/players/calculator_model.rb +13 -0
  67. data/productions/examples/calculator/props.rb +23 -0
  68. data/productions/examples/calculator/styles.rb +38 -0
  69. data/productions/examples/langstons_ant/html_javascript/ant.css +39 -0
  70. data/productions/examples/langstons_ant/html_javascript/ant.html +22 -0
  71. data/productions/examples/langstons_ant/html_javascript/ant.js +23 -0
  72. data/productions/examples/langstons_ant/players/ant.rb +103 -0
  73. data/productions/examples/langstons_ant/players/log.rb +29 -0
  74. data/productions/examples/langstons_ant/players/start_stop_button.rb +37 -0
  75. data/productions/examples/langstons_ant/players/world.rb +61 -0
  76. data/productions/examples/langstons_ant/props.rb +22 -0
  77. data/productions/examples/langstons_ant/styles.rb +105 -0
  78. data/productions/examples/sandbox/click_me/players/chromaton.rb +47 -0
  79. data/productions/examples/sandbox/click_me/props.rb +8 -0
  80. data/productions/examples/sandbox/click_me/styles.rb +12 -0
  81. data/productions/examples/sandbox/floaters/players/floater.rb +92 -0
  82. data/productions/examples/sandbox/floaters/players/surface.rb +17 -0
  83. data/productions/examples/sandbox/floaters/props.rb +10 -0
  84. data/productions/examples/sandbox/floaters/styles.rb +25 -0
  85. data/productions/examples/sandbox/gradients/players/spinner.rb +23 -0
  86. data/productions/examples/sandbox/gradients/players/teaser.rb +26 -0
  87. data/productions/examples/sandbox/gradients/players/wave.rb +26 -0
  88. data/productions/examples/sandbox/gradients/players/waves.rb +26 -0
  89. data/productions/examples/sandbox/gradients/props.rb +13 -0
  90. data/productions/examples/sandbox/gradients/styles.rb +47 -0
  91. data/productions/examples/sandbox/header.rb +15 -0
  92. data/productions/examples/sandbox/homer/players/homer.rb +20 -0
  93. data/productions/examples/sandbox/homer/props.rb +10 -0
  94. data/productions/examples/sandbox/homer/styles.rb +17 -0
  95. data/productions/examples/sandbox/images/arch.jpg +0 -0
  96. data/productions/examples/sandbox/images/beach.jpg +0 -0
  97. data/productions/examples/sandbox/images/homer.jpg +0 -0
  98. data/productions/examples/sandbox/images/limelight_spotlight.jpg +0 -0
  99. data/productions/examples/sandbox/images/marilyn.jpg +0 -0
  100. data/productions/examples/sandbox/inputs/players/button_input.rb +48 -0
  101. data/productions/examples/sandbox/inputs/players/check_box_input.rb +40 -0
  102. data/productions/examples/sandbox/inputs/players/combo_box_input.rb +41 -0
  103. data/productions/examples/sandbox/inputs/players/radio_button_input.rb +43 -0
  104. data/productions/examples/sandbox/inputs/players/text_area_input.rb +36 -0
  105. data/productions/examples/sandbox/inputs/players/text_box_input.rb +36 -0
  106. data/productions/examples/sandbox/inputs/props.rb +40 -0
  107. data/productions/examples/sandbox/inputs/styles.rb +39 -0
  108. data/productions/examples/sandbox/players/sandbox.rb +11 -0
  109. data/productions/examples/sandbox/rounded_corners/players/box.rb +11 -0
  110. data/productions/examples/sandbox/rounded_corners/props.rb +22 -0
  111. data/productions/examples/sandbox/rounded_corners/styles.rb +18 -0
  112. data/productions/examples/sandbox/scrolling/players/cell.rb +16 -0
  113. data/productions/examples/sandbox/scrolling/props.rb +40 -0
  114. data/productions/examples/sandbox/scrolling/styles.rb +25 -0
  115. data/productions/examples/sandbox/sketching/players/sketchpad.rb +46 -0
  116. data/productions/examples/sandbox/sketching/props.rb +25 -0
  117. data/productions/examples/sandbox/sketching/styles.rb +36 -0
  118. data/productions/examples/sandbox/stages.rb +6 -0
  119. data/productions/examples/sandbox/styles.rb +37 -0
  120. data/productions/examples/sandbox/teaser/players/fader.rb +58 -0
  121. data/productions/examples/sandbox/teaser/props.rb +14 -0
  122. data/productions/examples/sandbox/teaser/styles.rb +22 -0
  123. data/productions/examples/tutorials/tutorial_1/players/sample.rb +11 -0
  124. data/productions/examples/tutorials/tutorial_1/props.rb +9 -0
  125. data/productions/examples/tutorials/tutorial_1/styles.rb +27 -0
  126. data/productions/stage_composer/init.rb +10 -0
  127. data/productions/stage_composer/inspector/players/inspector.rb +80 -0
  128. data/productions/stage_composer/inspector/players/prop_row.rb +12 -0
  129. data/productions/stage_composer/inspector/players/prop_tree.rb +33 -0
  130. data/productions/stage_composer/inspector/players/style_table.rb +12 -0
  131. data/productions/stage_composer/inspector/players/style_value.rb +16 -0
  132. data/productions/stage_composer/inspector/props.rb +19 -0
  133. data/productions/stage_composer/inspector/styles.rb +71 -0
  134. data/productions/stage_composer/lib/init.rb +5 -0
  135. data/productions/stage_composer/lib/limelight/composer/controller.rb +51 -0
  136. data/productions/stage_composer/lib/limelight/composer/lethargy.rb +24 -0
  137. data/productions/stage_composer/production.rb +6 -0
  138. data/productions/stage_composer/stages.rb +15 -0
  139. data/productions/startup/props.rb +5 -0
  140. data/spec/casting_director_spec.rb +94 -0
  141. data/spec/commands_spec.rb +33 -0
  142. data/spec/file_chooser_spec.rb +64 -0
  143. data/spec/file_filter_spec.rb +29 -0
  144. data/spec/java_util_spec.rb +53 -0
  145. data/spec/loaders/file_loader_spec.rb +28 -0
  146. data/spec/paint_action_spec.rb +30 -0
  147. data/spec/pen_spec.rb +62 -0
  148. data/spec/players/button_spec.rb +31 -0
  149. data/spec/players/check_box_spec.rb +40 -0
  150. data/spec/players/combo_box_spec.rb +39 -0
  151. data/spec/players/radio_button_spec.rb +75 -0
  152. data/spec/players/text_area_spec.rb +37 -0
  153. data/spec/players/text_box_spec.rb +37 -0
  154. data/spec/producer_spec.rb +157 -0
  155. data/spec/production_builder_spec.rb +48 -0
  156. data/spec/production_spec.rb +75 -0
  157. data/spec/prop_builder_spec.rb +178 -0
  158. data/spec/prop_spec.rb +216 -0
  159. data/spec/scene_spec.rb +34 -0
  160. data/spec/spec_helper.rb +18 -0
  161. data/spec/stage_builder_spec.rb +90 -0
  162. data/spec/stage_spec.rb +57 -0
  163. data/spec/styles_builder_spec.rb +123 -0
  164. data/spec/theater_spec.rb +66 -0
  165. metadata +275 -0
@@ -0,0 +1,178 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
+ require 'limelight/prop_builder'
6
+
7
+ describe Limelight::SceneBuilder do
8
+
9
+ before(:each) do
10
+ @caster = make_mock("caster", :fill_cast => nil)
11
+ @options = { :name => "root", :casting_director => @caster}
12
+ end
13
+
14
+ it "should build root" do
15
+ root = Limelight.build_scene(@options)
16
+
17
+ root.class.should == Limelight::Scene
18
+ root.name.should == "root"
19
+ root.panel.should_not == nil
20
+ root.children.size.should == 0
21
+ end
22
+
23
+ it "should build one child prop" do
24
+ root = Limelight::build_scene(@options) do
25
+ child
26
+ end
27
+
28
+ root.children.size.should == 1
29
+ child = root.children[0]
30
+ child.class.should == Limelight::Prop
31
+ child.name.should == "child"
32
+ child.panel.should_not == nil
33
+ child.children.size.should == 0
34
+ end
35
+
36
+ it "should allow multiple children" do
37
+ root = Limelight::build_scene(@options) do
38
+ child1
39
+ child2
40
+ end
41
+
42
+ root.children.size.should == 2
43
+ root.children[0].name.should == "child1"
44
+ root.children[1].name.should == "child2"
45
+ end
46
+
47
+ it "should allow nested children" do
48
+ root = Limelight::build_scene(@options) do
49
+ child do
50
+ grandchild
51
+ end
52
+ end
53
+
54
+ root.children.size.should == 1
55
+ root.children[0].name.should == "child"
56
+ root.children[0].children.size.should == 1
57
+ root.children[0].children[0].name.should == "grandchild"
58
+ end
59
+
60
+ it "should be able to set the id" do
61
+ root = Limelight::build_scene(@options) do
62
+ child :id => "child_1", :players => "x, y, z"
63
+ end
64
+
65
+ child = root.children[0]
66
+ child.id.should == "child_1"
67
+ child.players.should == "x, y, z"
68
+ end
69
+
70
+ it "should allow setting styles" do
71
+ root = Limelight::build_scene(@options) do
72
+ child :width => "100", :font_size => "10", :top_border_color => "blue"
73
+ end
74
+
75
+ child = root.children[0]
76
+ child.style.width.should == "100"
77
+ child.style.font_size.should == "10"
78
+ child.style.top_border_color.should == "blue"
79
+ end
80
+
81
+ it "should allow defining events through constructor" do
82
+ root = Limelight::build_scene(@options) do
83
+ child :on_mouse_entered => "return [self, event]"
84
+ end
85
+
86
+ child = root.children[0]
87
+ child.mouse_entered("blah").should == [child, "blah"]
88
+ end
89
+
90
+ it "should allow scene configuration" do
91
+ root = Limelight::build_scene(@options) do
92
+ __ :name => "root", :id => "123"
93
+ end
94
+
95
+ root.children.size.should == 0
96
+ root.name.should == "root"
97
+ root.id.should == "123"
98
+ end
99
+
100
+ it "should give every prop their scene" do
101
+ root = Limelight::build_scene(@options) do
102
+ child do
103
+ grandchild
104
+ end
105
+ end
106
+
107
+ root.scene.should == root
108
+ root.children[0].scene.should == root
109
+ root.children[0].children[0].scene.should == root
110
+ end
111
+
112
+ it "should install external props" do
113
+ loader = make_mock("loader", :exists? => true)
114
+ loader.should_receive(:load).with("external.rb").and_return("child :id => 123")
115
+
116
+ root = Limelight::build_scene(:id => 321, :build_loader => loader, :casting_director => @caster) do
117
+ __install "external.rb"
118
+ end
119
+
120
+ root.id.should == 321
121
+ root.children.size.should == 1
122
+ child = root.children[0]
123
+ child.name.should == "child"
124
+ child.id.should == 123
125
+ end
126
+
127
+ it "should fail if no loader is provided" do
128
+ begin
129
+ root = Limelight::build_scene(@options.merge(:id => 321, :build_loader => nil)) do
130
+ __install "external.rb"
131
+ end
132
+ root.should == nil # should never get here
133
+ rescue Exception => e
134
+ e.message.should == "Cannot install external props because no loader was provided"
135
+ end
136
+ end
137
+
138
+ it "should fail when the external file doesn't exist" do
139
+ loader = make_mock("loader")
140
+ loader.should_receive(:exists?).with("external.rb").and_return(false)
141
+
142
+ begin
143
+ root = Limelight::build_scene(@options.merge(:id => 321, :build_loader => loader)) do
144
+ __install "external.rb"
145
+ end
146
+ rescue Exception => e
147
+ e.message.should == "External prop file: 'external.rb' doesn't exist"
148
+ end
149
+ end
150
+
151
+ it "should fail with PropException when there's problem in the external file" do
152
+ loader = make_mock("loader", :exists? => true)
153
+ loader.should_receive(:load).with("external.rb").and_return("+")
154
+
155
+ begin
156
+ root = Limelight::build_scene(@options.merge(:id => 321, :build_loader => loader)) do
157
+ __install "external.rb"
158
+ end
159
+ rescue Limelight::BuildException => e
160
+ e.message.should include("external.rb:1: (eval):1: , unexpected end-of-file")
161
+ end
162
+ end
163
+
164
+ it "should build onto an existing block" do
165
+ prop = Limelight::Prop.new
166
+ prop.set_scene(Limelight::Scene.new(:casting_director => make_mock(:casting_director, :fill_cast => nil)))
167
+ builder = Limelight::PropBuilder.new(prop)
168
+ block = Proc.new { one; two { three } }
169
+ builder.instance_eval(&block)
170
+
171
+ prop.children.length.should == 2
172
+ prop.children[0].name.should == "one"
173
+ prop.children[1].name.should == "two"
174
+ prop.children[1].children.length.should == 1
175
+ prop.children[1].children[0].name.should == "three"
176
+ end
177
+
178
+ end
data/spec/prop_spec.rb ADDED
@@ -0,0 +1,216 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
+ require 'limelight/prop'
6
+ require 'limelight/styles_builder'
7
+ require 'limelight/scene'
8
+
9
+ describe Limelight::Prop do
10
+
11
+ before(:each) do
12
+ @casting_director = make_mock("casting_director", :fill_cast => nil)
13
+ @scene = Limelight::Scene.new(:casting_director => @casting_director)
14
+ @prop = Limelight::Prop.new(:id => "root", :name => "root_class")
15
+ @scene << @prop
16
+ end
17
+
18
+ it "should extend added controllers and invoke the extended hook" do
19
+ module TestController
20
+ class << self
21
+ attr_reader :extended_prop
22
+ def extended(prop)
23
+ @extended_prop = (prop)
24
+ end
25
+ end
26
+
27
+ def test_method
28
+ end
29
+ end
30
+
31
+ @prop.add_controller(TestController)
32
+
33
+ TestController.extended_prop.should == @prop
34
+ @prop.respond_to?(:test_method).should == true
35
+ end
36
+
37
+ it "should have an id" do
38
+ @prop.id.should == "root"
39
+ end
40
+
41
+ def build_prop_tree
42
+ @child1 = Limelight::Prop.new(:id => "child1", :name => "child_class")
43
+ @child2 = Limelight::Prop.new(:id => "child2", :name => "child_class")
44
+ @grand_child1 = Limelight::Prop.new(:id => "grand_child1", :name => "grand_child_class")
45
+ @grand_child2 = Limelight::Prop.new(:id => "grand_child2", :name => "grand_child_class")
46
+ @grand_child3 = Limelight::Prop.new(:id => "grand_child3", :name => "grand_child_class")
47
+ @grand_child4 = Limelight::Prop.new(:id => "grand_child4", :name => "grand_child_class")
48
+
49
+ @prop << @child1 << @child2
50
+ @child1 << @grand_child1 << @grand_child2
51
+ @child2 << @grand_child3 << @grand_child4
52
+ end
53
+
54
+ it "should find children by id" do
55
+ build_prop_tree
56
+ @prop.find("blah").should == nil
57
+ @prop.find("root").should be(@prop)
58
+ @prop.find("child1").should be(@child1)
59
+ @prop.find("child2").should be(@child2)
60
+ @prop.find("grand_child1").should be(@grand_child1)
61
+ @prop.find("grand_child2").should be(@grand_child2)
62
+ @prop.find("grand_child3").should be(@grand_child3)
63
+ @prop.find("grand_child4").should be(@grand_child4)
64
+ end
65
+
66
+ it "should find children by name" do
67
+ build_prop_tree
68
+ @prop.find_by_name("root_class").should == [@prop]
69
+ @prop.find_by_name("child_class").should == [@child1, @child2]
70
+ @prop.find_by_name("grand_child_class").should == [@grand_child1, @grand_child2, @grand_child3, @grand_child4]
71
+ end
72
+
73
+ it "should get and set text" do
74
+ @prop.text = "blah"
75
+ @prop.text.should == "blah"
76
+ end
77
+
78
+ it "should have controllers" do
79
+ prop = Limelight::Prop.new(:players => "abc, xyz")
80
+ @scene << prop
81
+ prop.players.should == "abc, xyz"
82
+ end
83
+
84
+ it "should get populated through constructor" do
85
+ prop = Limelight::Prop.new(:name => "my_name", :id => "123", :players => "a, b, c")
86
+ @scene << prop
87
+
88
+ prop.name.should == "my_name"
89
+ prop.id.should == "123"
90
+ end
91
+
92
+ it "should populate styles through constructor" do
93
+ prop = Limelight::Prop.new(:width => "100", :text_color => "white", :background_image => "apple.jpg")
94
+ @scene << prop
95
+
96
+ prop.style.width.should == "100"
97
+ prop.style.text_color.should == "white"
98
+ prop.style.background_image.should == "apple.jpg"
99
+ end
100
+
101
+ it "should define event through constructor using a string" do
102
+ prop = Limelight::Prop.new(:on_mouse_entered => "return event")
103
+ @scene << prop
104
+
105
+ value = prop.mouse_entered("my event")
106
+
107
+ value.should == "my event"
108
+ end
109
+
110
+ it "should pass scene on to children" do
111
+ child = Limelight::Prop.new(:name => "child")
112
+
113
+ @prop.parent.should == @scene
114
+ @prop.scene.should == @scene
115
+
116
+ @prop << child
117
+ child.parent.should == @prop
118
+ child.scene.should == @scene
119
+ end
120
+
121
+ it "should set styles upon adding to parent" do
122
+ styles = Limelight::build_styles { child { width 123 } }
123
+ scene = Limelight::Scene.new(:casting_director => @casting_director, :styles => styles)
124
+ prop = Limelight::Prop.new(:name => "child")
125
+
126
+ scene << prop
127
+
128
+ prop.style.width.should == "123"
129
+ end
130
+
131
+ it "should set styles upon adding to parent" do
132
+ prop = Limelight::Prop.new(:name => "child")
133
+
134
+ @casting_director.should_receive(:fill_cast).with(prop)
135
+
136
+ @scene << prop
137
+ end
138
+
139
+ it "should use populate data included by players" do
140
+ prop = Limelight::Prop.new(:name => "child", :foo => "bar")
141
+ @casting_director.should_receive(:fill_cast).with(prop) do
142
+ prop.instance_eval "def foo=(value); @foo = value; end; def foo; return @foo; end;"
143
+ end
144
+
145
+ @scene << prop
146
+
147
+ prop.foo.should == "bar"
148
+ end
149
+
150
+ it "should be able to remove children" do
151
+ child1 = Limelight::Prop.new()
152
+ child2 = Limelight::Prop.new()
153
+ child3 = Limelight::Prop.new()
154
+ @prop << child1 << child2 << child3
155
+
156
+ @prop.remove(child2)
157
+
158
+ @prop.children.length.should == 2
159
+ @prop.children.should_not include(child2)
160
+ @prop.panel.components.length.should == 2
161
+ @prop.panel.components.should_not include(child2.panel)
162
+ end
163
+
164
+ it "should make dimensions accessible" do
165
+ @prop.panel.should_receive(:get_rectangle).and_return("whole area")
166
+ @prop.panel.should_receive(:get_rectangle_inside_borders).and_return("area inside borders")
167
+
168
+ @prop.area.should == "whole area"
169
+ @prop.bordered_area.should == "area inside borders"
170
+ end
171
+
172
+ it "should give you a pen" do
173
+ graphics = make_mock("graphics", :setColor => nil, :setStroke => nil, :setRenderingHint => nil)
174
+ @prop.panel.should_receive(:getGraphics).and_return(graphics)
175
+
176
+ pen = @prop.pen
177
+
178
+ pen.context.should be(graphics)
179
+ end
180
+
181
+ it "should set after paint action" do
182
+ block = Proc.new { |pen| }
183
+
184
+ @prop.after_painting &block
185
+
186
+ action = @prop.panel.after_paint_action
187
+ action.should_not == nil
188
+ action.class.should == Limelight::PaintAction
189
+ action.block.should == block
190
+ end
191
+
192
+ it "should clear after paint action" do
193
+ @prop.after_painting { |pen| puts "blah" }
194
+
195
+ @prop.after_painting nil
196
+
197
+ @prop.panel.after_paint_action.should == nil
198
+ end
199
+
200
+ it "should build children" do
201
+ @prop.build do
202
+ one
203
+ two do
204
+ three
205
+ end
206
+ end
207
+
208
+ @prop.children.length.should == 2
209
+ @prop.children[0].name.should == "one"
210
+ @prop.children[1].name.should == "two"
211
+ @prop.children[1].children.length.should == 1
212
+ @prop.children[1].children[0].name.should == "three"
213
+ end
214
+
215
+ end
216
+
@@ -0,0 +1,34 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
+ require 'limelight/scene'
6
+
7
+ describe Limelight::Scene do
8
+
9
+ before(:each) do
10
+ @casting_director = make_mock("casting_director", :fill_cast => nil)
11
+ @scene = Limelight::Scene.new(:casting_director => @casting_director)
12
+ end
13
+
14
+ it "should have a styles hash" do
15
+ @scene.styles.should_not == nil
16
+ @scene.styles.size.should == 0
17
+ end
18
+
19
+ it "should have a button group cache" do
20
+ @scene.button_groups.should_not == nil
21
+ @scene.button_groups.class.should == Java::limelight.ui.ButtonGroupCache
22
+ end
23
+
24
+ it "should pullout sytles and casting_director from options" do
25
+ scene = Limelight::Scene.new(:styles => "styles", :casting_director => @casting_director)
26
+
27
+ scene.styles.should == "styles"
28
+ scene.casting_director.should == @casting_director
29
+ end
30
+
31
+ it "should have opened event" do
32
+ @scene.should respond_to(:scene_opened)
33
+ end
34
+ end
@@ -0,0 +1,18 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/init")
5
+
6
+ require 'spec'
7
+
8
+ def make_mock(name, stubs = {})
9
+ the_mock = mock(name)
10
+ the_mock.stubs!(stubs)
11
+ return the_mock
12
+ end
13
+
14
+ class Object
15
+ def stubs!(stubs = {})
16
+ stubs.each_pair { |key, value| self.stub!(key).and_return(value) }
17
+ end
18
+ end
@@ -0,0 +1,90 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
+ require 'limelight/stage_builder'
6
+ require 'limelight/theater'
7
+
8
+ describe Limelight::StageBuilder do
9
+
10
+ before(:each) do
11
+ @theater = Limelight::Theater.new
12
+ end
13
+
14
+ it "should give no stages if empty" do
15
+ stages = Limelight::build_stages(@theater)
16
+
17
+ stages.should == []
18
+ end
19
+
20
+ it "should build one stage" do
21
+ stages = Limelight::build_stages(@theater) do
22
+ stage "George"
23
+ end
24
+
25
+ stages.length.should == 1
26
+ stages[0].name.should == "George"
27
+ end
28
+
29
+ it "should build multiple stages" do
30
+ stages = Limelight::build_stages(@theater) do
31
+ stage "George"
32
+ stage "Bill"
33
+ stage "Amy"
34
+ end
35
+
36
+ stages.length.should == 3
37
+ stages[0].name.should == "George"
38
+ stages[1].name.should == "Bill"
39
+ stages[2].name.should == "Amy"
40
+ end
41
+
42
+ it "should allow the setting of stage properties" do
43
+ stages = Limelight::build_stages(@theater) do
44
+ stage "George" do
45
+ title "The Curious"
46
+ end
47
+ end
48
+
49
+ stages.length.should == 1
50
+ stages[0].title.should == "The Curious"
51
+ end
52
+
53
+ it "should raise an exception when setting an invalid property" do
54
+ lambda do
55
+ Limelight::build_stages(@theater) do
56
+ stage "George" do
57
+ blah "blah"
58
+ end
59
+ end
60
+ end.should raise_error(Limelight::StageBuilderException, "'blah' is not a valid stage property")
61
+ end
62
+
63
+ it "should add stages to the theater" do
64
+ stages = Limelight::build_stages(@theater) do
65
+ stage "George" do
66
+ title "The Curious"
67
+ end
68
+ end
69
+
70
+ @theater["George"].should == stages[0]
71
+ end
72
+
73
+ it "should add stages to the theater" do
74
+ stages = Limelight::build_stages(@theater) do
75
+ stage "George" do
76
+ title "The Curious"
77
+ end
78
+ end
79
+ stages = Limelight::build_stages(@theater) do
80
+ stage "George" do
81
+ title "The Monkey"
82
+ end
83
+ end
84
+
85
+ @theater.stages.length.should == 1
86
+ @theater["George"].title.should == "The Monkey"
87
+ end
88
+
89
+ end
90
+
@@ -0,0 +1,57 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
+ require 'limelight/stage'
6
+
7
+ describe Limelight::Stage do
8
+
9
+ before(:each) do
10
+ @theater = make_mock("theater")
11
+ @stage = Limelight::Stage.new(@theater, "George")
12
+ end
13
+
14
+ it "should have a name" do
15
+ stage = Limelight::Stage.new(@theater, "Jose")
16
+ stage.theater.should be(@theater)
17
+ stage.name.should == "Jose"
18
+ end
19
+
20
+ it "should have a title which default to it's name" do
21
+ @stage.title.should == "George"
22
+
23
+ @stage.title = "Once Upon a Test"
24
+
25
+ @stage.title.should == "Once Upon a Test"
26
+ end
27
+
28
+ it "should have size" do
29
+ @stage.size.should == [800, 800]
30
+
31
+ @stage.size = 123, 456
32
+
33
+ @stage.size.should == [123, 456]
34
+ end
35
+
36
+ it "should have size" do
37
+ @stage.location.should == [200, 25]
38
+
39
+ @stage.location = 123, 456
40
+
41
+ @stage.location.should == [123, 456]
42
+ end
43
+
44
+ it "should not allow name changes" do
45
+ lambda { @stage.name = "new name" }.should raise_error
46
+ end
47
+
48
+ it "should call scene.scene_opened at the end of opening a scene" do
49
+ scene = make_mock("scene", :visible= => nil)
50
+ scene.should_receive(:scene_opened)
51
+
52
+ @stage.frame.stub!(:open)
53
+ @stage.stub!(:load_scene)
54
+ @stage.open(scene)
55
+ end
56
+
57
+ end