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,28 @@
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/loaders/file_scene_loader'
6
+
7
+ describe Limelight::Loaders::FileSceneLoader do
8
+
9
+ before(:each) do
10
+ @loader = Limelight::Loaders::FileSceneLoader.for_root("/Users/micahmartin/Projects/limelight/example")
11
+ end
12
+
13
+ it "should load path parts" do
14
+ @loader.root.should == "/Users/micahmartin/Projects/limelight/example"
15
+ end
16
+
17
+ it "should calculate relative file paths" do
18
+ @loader.path_to(".").should == "/Users/micahmartin/Projects/limelight/example"
19
+ @loader.path_to("..").should == "/Users/micahmartin/Projects/limelight"
20
+ @loader.path_to("images/blah.gif").should == "/Users/micahmartin/Projects/limelight/example/images/blah.gif"
21
+ end
22
+
23
+ it "should know absolute paths" do
24
+ @loader.path_to("/").should == "/"
25
+ @loader.path_to("/Users").should == "/Users"
26
+ end
27
+
28
+ end
@@ -0,0 +1,30 @@
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/paint_action'
6
+
7
+ describe Limelight::PaintAction do
8
+
9
+ before(:each) do
10
+ end
11
+
12
+ it "should take a block in constructor" do
13
+ block = Proc.new { |pen| }
14
+ action = Limelight::PaintAction.new(&block)
15
+
16
+ action.block.should == block
17
+ end
18
+
19
+ it "should pass pen into the block" do
20
+ local_pen = nil
21
+ action = Limelight::PaintAction.new { |pen| local_pen = pen }
22
+
23
+ graphics = make_mock("graphics", :setColor => nil, :setStroke => nil, :setRenderingHint => nil)
24
+ action.invoke(graphics)
25
+
26
+ local_pen.class.should == Limelight::Pen
27
+ local_pen.context.should == graphics
28
+ end
29
+
30
+ end
data/spec/pen_spec.rb ADDED
@@ -0,0 +1,62 @@
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/pen'
6
+
7
+ describe Limelight::Pen do
8
+
9
+ before(:each) do
10
+ @context = make_mock("context", :setColor => nil, :setStroke => nil, :setRenderingHint => nil)
11
+ @pen = Limelight::Pen.new(@context)
12
+ end
13
+
14
+ it "should default to a think black stroke" do
15
+ @context.should_receive(:setColor).with(java.awt.Color::black)
16
+ @context.should_receive(:setStroke).with(java.awt.BasicStroke.new(1))
17
+ @context.should_receive(:setRenderingHint).with(java.awt.RenderingHints::KEY_ANTIALIASING, java.awt.RenderingHints::VALUE_ANTIALIAS_OFF)
18
+
19
+ @pen = Limelight::Pen.new(@context)
20
+
21
+ @pen.context.should be(@context)
22
+ end
23
+
24
+ it "should allow setting the color" do
25
+ @context.should_receive(:setColor).with(java.awt.Color::blue)
26
+
27
+ @pen.color = "blue"
28
+ end
29
+
30
+ it "should allow setting the width" do
31
+ @context.should_receive(:setStroke).with(java.awt.BasicStroke.new(5))
32
+
33
+ @pen.width = 5
34
+ end
35
+
36
+ it "should allow setting smooth on" do
37
+ @context.should_receive(:setRenderingHint).with(java.awt.RenderingHints::KEY_ANTIALIASING, java.awt.RenderingHints::VALUE_ANTIALIAS_ON)
38
+
39
+ @pen.smooth = true
40
+ end
41
+
42
+ it "should draw a line" do
43
+ @context.should_receive(:drawLine).with(1, 2, 3, 4)
44
+
45
+ @pen.draw_line(1, 2, 3, 4)
46
+ end
47
+
48
+ it "should draw a rectangle" do
49
+ @context.should_receive(:drawRect).with(1, 2, 3, 4)
50
+
51
+ @pen.draw_rectangle(1, 2, 3, 4)
52
+ end
53
+
54
+ it "should fill a rectangle" do
55
+ @pen.color = "blue"
56
+
57
+ @context.should_receive(:fillRect).with(1, 2, 3, 4)
58
+
59
+ @pen.fill_rectangle(1, 2, 3, 4)
60
+ end
61
+
62
+ end
@@ -0,0 +1,31 @@
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
+ require 'limelight/prop'
7
+ require 'limelight/players/button'
8
+
9
+ describe Limelight::Players::Button do
10
+
11
+ before(:each) do
12
+ @scene = Limelight::Scene.new(:casting_director => make_mock("caster", :fill_cast => nil))
13
+ @prop = Limelight::Prop.new
14
+ @prop.include_player(Limelight::Players::Button)
15
+ end
16
+
17
+ it "should get rid of the all painters and add a ButtonPainter" do
18
+ @prop.panel.painters.size.should == 1
19
+ @prop.panel.painters.last.class.should == Java::limelight.ui.painting.ButtonPainter
20
+ end
21
+
22
+ it "should clear event listeners on the panel" do
23
+ @prop.panel.mouse_listeners.length.should == 0
24
+ @prop.panel.key_listeners.length.should == 0
25
+ end
26
+
27
+ it "should have a Button" do
28
+ @prop.panel.components[0].class.should == javax.swing.JButton
29
+ end
30
+
31
+ end
@@ -0,0 +1,40 @@
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/players/check_box'
7
+
8
+ describe Limelight::Players::CheckBox do
9
+
10
+ before(:each) do
11
+ @prop = Limelight::Prop.new
12
+ @prop.add_controller(Limelight::Players::CheckBox)
13
+ end
14
+
15
+ it "should get rid of the all painters and add a CheckBoxPainter" do
16
+ @prop.panel.painters.size.should == 1
17
+ @prop.panel.painters.last.class.should == Java::limelight.ui.painting.CheckBoxPainter
18
+ end
19
+
20
+ it "should clear event listeners on the panel" do
21
+ @prop.panel.mouse_listeners.length.should == 0
22
+ @prop.panel.key_listeners.length.should == 0
23
+ end
24
+
25
+ it "should have a TextField" do
26
+ @prop.panel.components[0].class.should == javax.swing.JCheckBox
27
+ end
28
+
29
+ it "should handled checked state" do
30
+ @prop.checked?.should == false
31
+ @prop.checked.should == false
32
+
33
+ @prop.checked = true
34
+
35
+ @prop.checked?.should == true
36
+ @prop.checked.should == true
37
+ @prop.panel.components[0].is_selected.should == true
38
+ end
39
+
40
+ end
@@ -0,0 +1,39 @@
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
+ require 'limelight/prop'
7
+ require 'limelight/players/combo_box'
8
+
9
+ describe Limelight::Players::ComboBox do
10
+
11
+ before(:each) do
12
+ @scene = Limelight::Scene.new(:casting_director => make_mock("caster", :fill_cast => nil))
13
+ @prop = Limelight::Prop.new(:scene => @scene)
14
+ @prop.include_player(Limelight::Players::ComboBox)
15
+ end
16
+
17
+ it "should get rid of the all painters and add a ComboBoxPainter" do
18
+ @prop.panel.painters.size.should == 1
19
+ @prop.panel.painters.last.class.should == Java::limelight.ui.painting.ComboBoxPainter
20
+ end
21
+
22
+ it "should clear event listeners on the panel" do
23
+ @prop.panel.mouse_listeners.length.should == 0
24
+ @prop.panel.key_listeners.length.should == 0
25
+ end
26
+
27
+ it "should have a ComboBox" do
28
+ @prop.panel.components[0].class.should == javax.swing.JComboBox
29
+ end
30
+
31
+ it "should have settable value" do
32
+ @prop.choices = ["1", "2", "3"]
33
+ @prop.value.should == "1"
34
+
35
+ @prop.value = "3"
36
+ @prop.value.should == "3"
37
+ end
38
+
39
+ end
@@ -0,0 +1,75 @@
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
+ require 'limelight/prop'
7
+ require 'limelight/players/radio_button'
8
+
9
+ describe Limelight::Players::RadioButton do
10
+
11
+ before(:each) do
12
+ @scene = Limelight::Scene.new(:casting_director => make_mock("caster", :fill_cast => nil))
13
+ @prop = Limelight::Prop.new
14
+ @scene << @prop
15
+ @prop.include_player(Limelight::Players::RadioButton)
16
+ end
17
+
18
+ it "should get rid of the all painters and add a RadioButtonPainter" do
19
+ @prop.panel.painters.size.should == 1
20
+ @prop.panel.painters.last.class.should == Java::limelight.ui.painting.RadioButtonPainter
21
+ end
22
+
23
+ it "should clear event listeners on the panel" do
24
+ @prop.panel.mouse_listeners.length.should == 0
25
+ @prop.panel.key_listeners.length.should == 0
26
+ end
27
+
28
+ it "should have a RadioButton" do
29
+ @prop.panel.components[0].class.should == javax.swing.JRadioButton
30
+ end
31
+
32
+ it "should handled checked state" do
33
+ @prop.checked?.should == false
34
+ @prop.checked.should == false
35
+ @prop.selected?.should == false
36
+ @prop.selected.should == false
37
+
38
+ @prop.selected = true
39
+
40
+ @prop.checked?.should == true
41
+ @prop.checked.should == true
42
+ @prop.selected?.should == true
43
+ @prop.selected.should == true
44
+ @prop.panel.components[0].is_selected.should == true
45
+ end
46
+
47
+ it "should belong to a button group" do
48
+ @prop.group = "group 1"
49
+
50
+ prop2 = Limelight::Prop.new
51
+ @scene << prop2
52
+ prop2.add_controller(Limelight::Players::RadioButton)
53
+ prop2.group = "group 1"
54
+
55
+ prop3 = Limelight::Prop.new
56
+ @scene << prop3
57
+ prop3.add_controller(Limelight::Players::RadioButton)
58
+ prop3.group = "group 2"
59
+
60
+ group1 = @scene.button_groups["group 1"]
61
+ group1.elements.should include(@prop.radio_button)
62
+ group1.elements.should include(prop2.radio_button)
63
+ group1.elements.should_not include(prop3.radio_button)
64
+
65
+ group2 = @scene.button_groups["group 2"]
66
+ group2.elements.should_not include(@prop.radio_button)
67
+ group2.elements.should_not include(prop2.radio_button)
68
+ group2.elements.should include(prop3.radio_button)
69
+
70
+ @prop.button_group.should == group1
71
+ prop2.button_group.should == group1
72
+ prop3.button_group.should == group2
73
+ end
74
+
75
+ end
@@ -0,0 +1,37 @@
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/players/text_area'
7
+
8
+ describe Limelight::Players::TextArea do
9
+
10
+ before(:each) do
11
+ @prop = Limelight::Prop.new
12
+ @prop.add_controller(Limelight::Players::TextArea)
13
+ end
14
+
15
+ it "should get rid of the all painters and add a TextAreaPainter" do
16
+ @prop.panel.painters.size.should == 1
17
+ @prop.panel.painters.last.class.should == Java::limelight.ui.painting.TextAreaPainter
18
+ end
19
+
20
+ it "should clear event listeners on the panel" do
21
+ @prop.panel.mouse_listeners.length.should == 0
22
+ @prop.panel.key_listeners.length.should == 0
23
+ end
24
+
25
+ it "should have a JTextArea" do
26
+ @prop.panel.components[0].class.should == javax.swing.JTextArea
27
+ end
28
+
29
+ it "should use the TextArea for the text accessor" do
30
+ @prop.text = "blah"
31
+ @prop.panel.components[0].text.should == "blah"
32
+
33
+ @prop.panel.components[0].text = "harumph"
34
+ @prop.text.should == "harumph"
35
+ end
36
+
37
+ end
@@ -0,0 +1,37 @@
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/players/text_box'
7
+
8
+ describe Limelight::Players::TextBox do
9
+
10
+ before(:each) do
11
+ @prop = Limelight::Prop.new
12
+ @prop.add_controller(Limelight::Players::TextBox)
13
+ end
14
+
15
+ it "should get rid of the all painters and add a TextboxPainter" do
16
+ @prop.panel.painters.size.should == 1
17
+ @prop.panel.painters.last.class.should == Java::limelight.ui.painting.TextBoxPainter
18
+ end
19
+
20
+ it "should clear event listeners on the panel" do
21
+ @prop.panel.mouse_listeners.length.should == 0
22
+ @prop.panel.key_listeners.length.should == 0
23
+ end
24
+
25
+ it "should have a TextField" do
26
+ @prop.panel.components[0].class.should == javax.swing.JTextField
27
+ end
28
+
29
+ it "should use the TextField for the text accessor" do
30
+ @prop.text = "blah"
31
+ @prop.panel.components[0].text.should == "blah"
32
+
33
+ @prop.panel.components[0].text = "harumph"
34
+ @prop.text.should == "harumph"
35
+ end
36
+
37
+ end
@@ -0,0 +1,157 @@
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/producer'
6
+
7
+ describe Limelight::Producer do
8
+
9
+ before(:each) do
10
+ Limelight::Production.clear_index
11
+ @producer = Limelight::Producer.new("/tmp")
12
+ @loader = @producer.loader
13
+ end
14
+
15
+ it "should have loader on creation" do
16
+ @producer.loader.root.should == "/tmp"
17
+ end
18
+
19
+ it "should take an optional theater on creation" do
20
+ theater = make_mock("theater")
21
+ producer = Limelight::Producer.new("/tmp", theater)
22
+
23
+ producer.theater.should == theater
24
+ end
25
+
26
+ it "should build a new theater if none is passing in constructor" do
27
+ @producer.theater.should_not == nil
28
+ @producer.theater.class.should == Limelight::Theater
29
+ end
30
+
31
+ it "should load props" do
32
+ @loader.should_receive(:exists?).with("./props.rb").and_return(true)
33
+ @loader.should_receive(:load).with("./props.rb").and_return("child :id => 321")
34
+
35
+ scene = @producer.load_props(".", :casting_director => make_mock("casting_director", :fill_cast => nil))
36
+ scene.children.size.should == 1
37
+ scene.children[0].name.should == "child"
38
+ scene.children[0].id.should == 321
39
+ end
40
+
41
+ it "should load props even when props.rd doesn't exist." do
42
+ @loader.should_receive(:exists?).with("./props.rb").and_return(false)
43
+
44
+ scene = @producer.load_props(".", :casting_director => make_mock("casting_director", :fill_cast => nil))
45
+ scene.children.size.should == 0
46
+ end
47
+
48
+ it "should load styles" do
49
+ @loader.should_receive(:exists?).with("./styles.rb").and_return(true)
50
+ @loader.should_receive(:load).with("./styles.rb").and_return("alpha { width 100 }")
51
+
52
+ styles = @producer.load_styles(".")
53
+ styles.size.should == 1
54
+ styles["alpha"].width.should == "100"
55
+ end
56
+
57
+ it "should format prop errors well" do
58
+ @loader.should_receive(:exists?).with("./props.rb").and_return(true)
59
+ @loader.should_receive(:load).with("./props.rb").and_return("one\n+\nthree")
60
+
61
+ begin
62
+ result = @producer.load_props(".", :casting_director => make_mock("casting_director", :fill_cast => nil))
63
+ result.should == nil # should never execute
64
+ rescue Limelight::BuildException => e
65
+ e.line_number.should == 3
66
+ e.filename.should == "./props.rb"
67
+ e.message.should include("./props.rb:3: undefined method `+@' for ")
68
+ end
69
+ end
70
+
71
+ it "should format styles errors well" do
72
+ @loader.should_receive(:exists?).with("./styles.rb").and_return(true)
73
+ @loader.should_receive(:load).with("./styles.rb").and_return("one {}\ntwo {}\n-\nthree {}")
74
+
75
+ begin
76
+ result = @producer.load_styles(".")
77
+ result.should == nil # should never execute
78
+ rescue Limelight::BuildException => e
79
+ e.line_number.should == 4
80
+ e.filename.should == "./styles.rb"
81
+ e.message.should include("./styles.rb:4: undefined method `-@' for #<Java::LimelightUi::RichStyle:0x")
82
+ end
83
+ end
84
+
85
+ it "should load a stage when stages.rb exists" do
86
+ @loader.should_receive(:exists?).with("production.rb").and_return(false)
87
+ @loader.should_receive(:exists?).with("init.rb").and_return(false)
88
+ @loader.should_receive(:exists?).with("stages.rb").and_return true
89
+ @producer.should_receive(:load_stages).and_return([make_mock("stage", :default_scene => "abc", :name => "Default")])
90
+ @producer.should_receive(:open_scene).with("abc", anything)
91
+
92
+ @producer.open
93
+ end
94
+
95
+ it "should load a scene when stages.rb doesn't exists" do
96
+ @loader.should_receive(:exists?).with("production.rb").and_return(false)
97
+ @loader.should_receive(:exists?).with("init.rb").and_return(false)
98
+ @loader.should_receive(:exists?).with("stages.rb").and_return false
99
+ @producer.should_not_receive(:open_stages)
100
+ @producer.should_receive(:open_scene).with(".", anything)
101
+
102
+ @producer.open
103
+ end
104
+
105
+ it "should have one default stage when no stages.rb is provided" do
106
+ @loader.should_receive(:exists?).with("production.rb").and_return(false)
107
+ @loader.should_receive(:exists?).with("init.rb").and_return(false)
108
+ @loader.should_receive(:exists?).with("stages.rb").and_return false
109
+ @producer.stub!(:open_scene)
110
+
111
+ @producer.open
112
+
113
+ @producer.theater.stages.size.should == 1
114
+ @producer.theater["Limelight"].should_not == nil
115
+ end
116
+
117
+ it "should open a scene" do
118
+ stage = make_mock("stage")
119
+ scene = make_mock("scene")
120
+ @producer.should_receive(:load_styles).and_return("styles")
121
+ @producer.should_receive(:merge_with_root_styles).with("styles")
122
+ @producer.should_receive(:load_props).with("some path", :styles => "styles", :production => @producer.production, :casting_director => anything, :loader => @loader, :path => "some path").and_return(scene)
123
+ stage.should_receive(:open).with(scene)
124
+
125
+ @producer.open_scene("some path", stage)
126
+ end
127
+
128
+ it "should load empty styles if styles.rb doesn't exist" do
129
+ @loader.should_receive(:exists?).with("./styles.rb").and_return(false)
130
+
131
+ @producer.load_styles(".").should == {}
132
+ end
133
+
134
+ it "should use the ProductionBuilder if production.rb is present" do
135
+ @loader.should_receive(:exists?).with("production.rb").and_return(true)
136
+ @loader.should_receive(:exists?).with("init.rb").and_return(false)
137
+ @loader.should_receive(:load).with("production.rb").and_return("name 'Fido'")
138
+ @loader.should_receive(:exists?).with("stages.rb").and_return(false)
139
+ @producer.stub!(:open_scene)
140
+
141
+ @producer.open
142
+
143
+ @producer.production.name.should == "Fido"
144
+ end
145
+
146
+ it "should load init.rb if it exists" do
147
+ @loader.should_receive(:exists?).with("production.rb").and_return(true)
148
+ @loader.should_receive(:exists?).with("init.rb").and_return(true)
149
+ @loader.should_receive(:load).with("production.rb").and_return("name 'Fido'")
150
+ @loader.should_receive(:exists?).with("stages.rb").and_return(false)
151
+ @producer.stub!(:open_scene)
152
+ Kernel.should_receive(:load).with("/tmp/init.rb")
153
+
154
+ @producer.open
155
+ end
156
+
157
+ end
@@ -0,0 +1,48 @@
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/production_builder'
6
+
7
+ describe Limelight::ProductionBuilder do
8
+
9
+ before(:each) do
10
+ @producer = make_mock("producer")
11
+ @theater = make_mock("theater")
12
+ end
13
+
14
+ it "should build a production" do
15
+ result = Limelight.build_production(@producer, @theater)
16
+
17
+ result.class.should == Limelight::Production
18
+ result.producer.should == @producer
19
+ result.theater.should == @theater
20
+ end
21
+
22
+ it "should build able to set the production's name" do
23
+ result = Limelight.build_production(@producer, @theater) do
24
+ name "My Production"
25
+ end
26
+
27
+ result.name.should == "My Production"
28
+ end
29
+
30
+ it "should build attribute accessors" do
31
+ result = Limelight.build_production(@producer, @theater) do
32
+ name "My Production2"
33
+ attribute :foo
34
+ end
35
+
36
+ result.respond_to?(:foo).should == true
37
+ result.foo = "foo"
38
+ result.foo.should == "foo"
39
+ end
40
+
41
+ it "should raise an exception when setting an invalid property" do
42
+ lambda do
43
+ Limelight::build_production(@producer, @theater) do
44
+ blah "blah"
45
+ end
46
+ end.should raise_error(Limelight::ProductionBuilderException, "'blah' is not a valid production property")
47
+ end
48
+ end
@@ -0,0 +1,75 @@
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/production'
6
+
7
+ describe Limelight::Production, "Instance methods" do
8
+
9
+ before(:each) do
10
+ @producer = make_mock("producer")
11
+ @theater = make_mock("theater")
12
+ @production = Limelight::Production.new(@producer, @theater)
13
+ end
14
+
15
+ it "should know it producder and theater" do
16
+ @production.producer.should == @producer
17
+ @production.theater.should == @theater
18
+ end
19
+
20
+ it "should be indexed" do
21
+ Limelight::Production[@production.name].should == @production
22
+ end
23
+
24
+ it "should raise an error when setting the name to a duplicate name" do
25
+ @production.name = "Bill"
26
+
27
+ production = Limelight::Production.new(@producer, @theater)
28
+ lambda { production.name = "Bill" }.should raise_error(Limelight::LimelightException, "Production name 'Bill' is already taken")
29
+ end
30
+
31
+ end
32
+
33
+ describe Limelight::Production, "Class methods" do
34
+
35
+ class TestProduction
36
+ attr_accessor :name
37
+ end
38
+
39
+ before(:each) do
40
+ Limelight::Production.clear_index
41
+ @production = TestProduction.new
42
+ end
43
+
44
+ it "should add productions to the index" do
45
+ @production.name = "Bob"
46
+
47
+ Limelight::Production.index(@production)
48
+
49
+ Limelight::Production["Bob"].should == @production
50
+ end
51
+
52
+ it "should give a production a name if it doesn't have one" do
53
+ Limelight::Production.index(@production)
54
+
55
+ @production.name.should == "1"
56
+ Limelight::Production["1"].should == @production
57
+
58
+ production2 = TestProduction.new
59
+ Limelight::Production.index(production2)
60
+
61
+ production2.name.should == "2"
62
+ Limelight::Production["2"].should == production2
63
+ end
64
+
65
+ it "should raise an error if adding a duplicate name" do
66
+ production2 = TestProduction.new
67
+
68
+ @production.name = "Bob"
69
+ production2.name = "Bob"
70
+
71
+ Limelight::Production.index(@production)
72
+ lambda { Limelight::Production.index(production2) }.should raise_error(Limelight::LimelightException, "Production name 'Bob' is already taken")
73
+ end
74
+
75
+ end