glimmer 0.1.5.470 → 0.1.8.470

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +2 -0
  5. data/README.markdown +7 -2
  6. data/Rakefile +7 -8
  7. data/TODO.md +1 -1
  8. data/VERSION +1 -1
  9. data/bin/girb +3 -0
  10. data/bin/girb_runner.rb +5 -0
  11. data/glimmer.gemspec +29 -19
  12. data/lib/glimmer_application.rb +1 -2
  13. data/lib/shine.rb +23 -21
  14. data/lib/xml_command_handlers/models/node.rb +11 -11
  15. data/lib/xml_command_handlers/models/xml_visitor.rb +12 -12
  16. data/samples/tictactoe/tic_tac_toe.rb +11 -11
  17. data/spec/lib/command_handlers/models/observable_model_spec.rb +22 -0
  18. data/spec/lib/command_handlers/models/r_widget_spec.rb +52 -0
  19. data/{test/glimmer_combo_data_binding_test.rb → spec/lib/glimmer__combo_data_binding__spec.rb} +48 -49
  20. data/spec/lib/glimmer__constant__spec.rb +30 -0
  21. data/{test/glimmer_data_binding_test.rb → spec/lib/glimmer__data_binding__spec.rb} +95 -94
  22. data/spec/lib/glimmer__list_data_binding__spec.rb +224 -0
  23. data/{test/glimmer_listeners_test.rb → spec/lib/glimmer__listeners__spec.rb} +18 -19
  24. data/spec/lib/glimmer__shine_data_binding__spec.rb +89 -0
  25. data/spec/lib/glimmer__tab_item__spec.rb +55 -0
  26. data/spec/lib/glimmer__table_data_binding__spec.rb +121 -0
  27. data/spec/lib/glimmer_spec.rb +251 -0
  28. data/spec/lib/xml/glimmer_xml_spec.rb +154 -0
  29. data/spec/samples/contactmanager/contact_manager_presenter_spec.rb +81 -0
  30. data/spec/samples/tictactoe/tic_tac_toe_spec.rb +263 -0
  31. data/spec/spec_helper.rb +123 -0
  32. metadata +50 -17
  33. data/test/glimmer_constant_test.rb +0 -30
  34. data/test/glimmer_list_data_binding_test.rb +0 -223
  35. data/test/glimmer_shine_data_binding_test.rb +0 -89
  36. data/test/glimmer_tab_item_test.rb +0 -61
  37. data/test/glimmer_table_data_binding_test.rb +0 -122
  38. data/test/glimmer_test.rb +0 -237
  39. data/test/helper.rb +0 -24
  40. data/test/observable_model_test.rb +0 -25
  41. data/test/r_widget_test.rb +0 -52
  42. data/test/samples/contactmanager/contact_manager_presenter_test.rb +0 -81
  43. data/test/samples/tictactoe/tic_tac_toe_test.rb +0 -262
  44. data/test/xml/glimmer_xml_test.rb +0 -163
@@ -1,30 +0,0 @@
1
- require_relative "helper"
2
-
3
- class GlimmerTest < Test::Unit::TestCase
4
- include Glimmer
5
-
6
- include_package 'org.eclipse.swt'
7
- include_package 'org.eclipse.swt.widgets'
8
- include_package 'org.eclipse.swt.layout'
9
-
10
- def setup
11
- dsl :swt
12
- end
13
-
14
- def teardown
15
- @target.display.dispose if @target.display
16
- end
17
-
18
- def test_shell_with_default_layout_and_composite
19
- @target = shell {
20
- composite(:border, :no_focus) {
21
- }
22
- }
23
-
24
- assert_equal 1, @target.widget.children.size
25
- assert_instance_of Composite, @target.widget.children[0]
26
- composite_widget = @target.widget.children[0]
27
- assert_has_style :no_focus, composite_widget
28
- assert_has_style :border, composite_widget
29
- end
30
- end
@@ -1,223 +0,0 @@
1
- require_relative "helper"
2
-
3
- class GlimmerListDataBindingTest < Test::Unit::TestCase
4
- include Glimmer
5
-
6
- include_package 'org.eclipse.swt'
7
- include_package 'org.eclipse.swt.widgets'
8
- include_package 'org.eclipse.swt.layout'
9
-
10
- def setup
11
- dsl :swt
12
- end
13
-
14
- def teardown
15
- @target.display.dispose if @target.display
16
- end
17
-
18
- class Person
19
- attr_accessor :country, :country_options
20
- attr_accessor :provinces, :provinces_options
21
-
22
- def initialize
23
- self.country_options=[
24
- "",
25
- "Canada",
26
- "US",
27
- "Mexico"
28
- ]
29
- self.provinces_options=[
30
- "",
31
- "Quebec",
32
- "Ontario",
33
- "Manitoba",
34
- "Saskatchewan",
35
- "Alberta",
36
- "British Columbia",
37
- "Nova Skotia",
38
- "Newfoundland"
39
- ]
40
- end
41
- end
42
-
43
- def test_single_selection_property
44
- person = Person.new
45
-
46
- @target = shell {
47
- @list = list {
48
- selection bind(person, :country)
49
- }
50
- }
51
-
52
- assert_equal 4, @list.widget.item_count
53
- assert_equal -1, @list.widget.selection_index
54
- assert_equal [], @list.widget.selection.to_a
55
-
56
- @list.widget.select(1)
57
- @list.widget.notifyListeners(SWT::Selection, nil)
58
- assert_equal "Canada", person.country
59
-
60
- person.country_options << "France"
61
-
62
- assert_equal 5, @list.widget.item_count
63
-
64
- person.country_options=["", "Canada", "US", "Mexico", "Russia", "France"]
65
-
66
- assert_equal 6, @list.widget.item_count
67
-
68
- person.country_options << "Italy"
69
- person.country_options << "Germany"
70
- person.country_options << "Australia"
71
-
72
- assert_equal 9, @list.widget.item_count
73
-
74
- person.country = "Canada"
75
-
76
- assert_equal 1, @list.widget.selection_index
77
- assert_equal ["Canada"], @list.widget.selection.to_a
78
-
79
- person.country = "Russia"
80
-
81
- assert_equal 4, @list.widget.selection_index
82
- assert_equal ["Russia"], @list.widget.selection.to_a
83
-
84
- person.country = ""
85
-
86
- assert_equal 0, @list.widget.selection_index
87
- assert_equal [""], @list.widget.selection.to_a
88
-
89
- person.country = "Japan"
90
-
91
- assert_equal 0, @list.widget.selection_index
92
- assert_equal [""], @list.widget.selection.to_a
93
-
94
- @list.widget.select(2)
95
- @list.widget.notifyListeners(SWT::Selection, nil)
96
- assert_equal "US", person.country
97
- end
98
-
99
- def test_single_selection_property_with_model_preinitialized
100
- person = Person.new
101
- person.country = "Canada"
102
-
103
- @target = shell {
104
- @list = list {
105
- selection bind(person, :country)
106
- }
107
- }
108
-
109
- assert_equal 4, @list.widget.item_count
110
- assert_equal 1, @list.widget.selection_index
111
- assert_equal ["Canada"], @list.widget.selection.to_a
112
-
113
- @list.widget.select(2)
114
- @list.widget.notifyListeners(SWT::Selection, nil)
115
- assert_equal "US", person.country
116
-
117
- person.country_options << "France"
118
-
119
- assert_equal 5, @list.widget.item_count
120
-
121
- person.country_options=["", "Canada", "US", "Mexico", "Russia", "France"]
122
-
123
- assert_equal 6, @list.widget.item_count
124
-
125
- person.country_options << "Italy"
126
- person.country_options << "Germany"
127
- person.country_options << "Australia"
128
-
129
- assert_equal 9, @list.widget.item_count
130
-
131
- person.country = "Canada"
132
-
133
- assert_equal 1, @list.widget.selection_index
134
- assert_equal ["Canada"], @list.widget.selection.to_a
135
-
136
- person.country = "Russia"
137
-
138
- assert_equal 4, @list.widget.selection_index
139
- assert_equal ["Russia"], @list.widget.selection.to_a
140
-
141
- person.country = ""
142
-
143
- assert_equal 0, @list.widget.selection_index
144
- assert_equal [""], @list.widget.selection.to_a
145
-
146
- person.country = "Japan"
147
-
148
- assert_equal 0, @list.widget.selection_index
149
- assert_equal [""], @list.widget.selection.to_a
150
- end
151
-
152
- def test_multi_selection_property
153
- person = Person.new
154
-
155
- @target = shell {
156
- @list = list(:multi) {
157
- selection bind(person, :provinces)
158
- }
159
- }
160
-
161
- assert_equal 0, @list.widget.selection_count.to_i
162
- assert_equal [], @list.widget.selection.to_a
163
-
164
- @list.widget.select(1)
165
- @list.widget.notifyListeners(SWT::Selection, nil)
166
- assert_equal ["Quebec"], person.provinces
167
-
168
- @list.widget.select(2)
169
- @list.widget.notifyListeners(SWT::Selection, nil)
170
- assert_equal ["Quebec", "Ontario"], person.provinces
171
-
172
- person.provinces=["Ontario", "Manitoba", "Alberta"]
173
-
174
- assert_equal 3, @list.widget.selection_count.to_i
175
- assert_equal [2, 3, 5], @list.widget.selection_indices.to_a
176
- assert_equal ["Ontario", "Manitoba", "Alberta"], @list.widget.selection.to_a
177
-
178
- person.provinces << "Quebec"
179
- person.provinces << "Saskatchewan"
180
- person.provinces << "British Columbia"
181
-
182
- assert_equal 6, @list.widget.selection_count.to_i
183
- assert_equal [1, 2, 3, 4, 5, 6], @list.widget.selection_indices.to_a
184
- assert_equal ["Quebec", "Ontario", "Manitoba", "Saskatchewan", "Alberta", "British Columbia"], @list.widget.selection.to_a
185
- end
186
-
187
- def test_multi_selection_property_with_model_preinitialized
188
- person = Person.new
189
- person.provinces = []
190
-
191
- @target = shell {
192
- @list = list(:multi) {
193
- selection bind(person, :provinces)
194
- }
195
- }
196
-
197
- assert_equal 0, @list.widget.selection_count.to_i
198
- assert_equal [], @list.widget.selection.to_a
199
-
200
- @list.widget.select(1)
201
- @list.widget.notifyListeners(SWT::Selection, nil)
202
- assert_equal ["Quebec"], person.provinces
203
-
204
- @list.widget.select(2)
205
- @list.widget.notifyListeners(SWT::Selection, nil)
206
- assert_equal ["Quebec", "Ontario"], person.provinces
207
-
208
- person.provinces=["Ontario", "Manitoba", "Alberta"]
209
-
210
- assert_equal 3, @list.widget.selection_count.to_i
211
- assert_equal [2, 3, 5], @list.widget.selection_indices.to_a
212
- assert_equal ["Ontario", "Manitoba", "Alberta"], @list.widget.selection.to_a
213
-
214
- person.provinces << "Quebec"
215
- person.provinces << "Saskatchewan"
216
- person.provinces << "British Columbia"
217
-
218
- assert_equal 6, @list.widget.selection_count.to_i
219
- assert_equal [1, 2, 3, 4, 5, 6], @list.widget.selection_indices.to_a
220
- assert_equal ["Quebec", "Ontario", "Manitoba", "Saskatchewan", "Alberta", "British Columbia"], @list.widget.selection.to_a
221
- end
222
- end
223
-
@@ -1,89 +0,0 @@
1
- require_relative "helper"
2
-
3
- require_relative "../lib/shine"
4
-
5
- class GlimmerDataBindingTest < Test::Unit::TestCase
6
- include Glimmer
7
-
8
- include_package 'org.eclipse.swt'
9
- include_package 'org.eclipse.swt.widgets'
10
- include_package 'org.eclipse.swt.layout'
11
-
12
- def setup
13
- dsl :swt
14
- end
15
-
16
- def teardown
17
- @target.display.dispose if @target.display
18
- end
19
-
20
- class Person
21
- attr_accessor :name, :age, :adult
22
- end
23
-
24
- def test_text_widget_data_binding_string_property_spaceship
25
- person = Person.new
26
- person.name = "Bruce Ting"
27
-
28
- @target = shell {
29
- composite {
30
- @text = text {
31
- }
32
- }
33
- }
34
-
35
- [@text, :text] <=> [person, :name]
36
-
37
- assert_equal "Bruce Ting", @text.widget.getText
38
-
39
- person.name = "Lady Butterfly"
40
- assert_equal "Lady Butterfly", @text.widget.getText
41
-
42
- @text.widget.setText("Allen Cork")
43
- assert_equal "Allen Cork", person.name
44
-
45
- comparison = ["he"] <=> ["he"]
46
- assert_equal(0, comparison)
47
- end
48
-
49
- def test_multiple_widget_data_bindings_to_different_model_properties_spaceship
50
- person = Person.new
51
- person.name = "Nancy"
52
- person.age = 15
53
- person.adult = true
54
-
55
- @target = shell {
56
- composite {
57
- @label = label {}
58
- @text = text {}
59
- @check_box = button(:check) {}
60
- }
61
- }
62
-
63
- [@label, :text] <=> [person, :name]
64
- [@text, :text] <=> [person, :age, :fixnum]
65
- [@check_box, :selection] <=> [person, :adult]
66
-
67
- assert_equal "Nancy", @label.widget.getText
68
- assert_equal "15", @text.widget.getText
69
- assert_equal true, @check_box.widget.getSelection
70
-
71
- person.name = "Drew"
72
- assert_equal "Drew", @label.widget.getText
73
-
74
- person.age = 27
75
- assert_equal "27", @text.widget.getText
76
-
77
- person.adult = false
78
- assert_equal false, @check_box.widget.getSelection
79
-
80
- @text.widget.setText("30")
81
- assert_equal 30, person.age
82
-
83
- @check_box.widget.setSelection(true)
84
- @check_box.widget.notifyListeners(SWT::Selection, nil)
85
- assert_equal true, person.adult
86
- end
87
-
88
- end
89
-
@@ -1,61 +0,0 @@
1
- require_relative "helper"
2
-
3
- class GlimmerTest < Test::Unit::TestCase
4
- include Glimmer
5
-
6
- include_package 'org.eclipse.swt'
7
- include_package 'org.eclipse.swt.widgets'
8
- include_package 'org.eclipse.swt.layout'
9
- include_package 'org.eclipse.swt.graphics'
10
-
11
- def setup
12
- dsl :swt
13
- end
14
-
15
- def teardown
16
- @target.display.dispose if @target.display
17
- end
18
-
19
- def test_tab_item_composite_with_default_layout
20
- @target = shell {
21
- @tab_folder = tab_folder {
22
- @tab_item_composite = tab_item {
23
- text "Tab 1"
24
- label {text "Hello"}
25
- }
26
- }
27
- }
28
-
29
- assert_not_nil @target
30
- assert_not_nil @target.widget
31
- assert_equal 1, @tab_folder.widget.items.size
32
- assert_instance_of Composite, @tab_item_composite.widget
33
- assert_equal @tab_item_composite.widget, @tab_folder.widget.items[0].control
34
- assert_equal "Tab 1", @tab_item_composite.tab_item.widget.text
35
- assert_not_nil @tab_item_composite.widget.getLayout
36
- assert_instance_of GridLayout, @tab_item_composite.widget.getLayout
37
- end
38
-
39
- def test_tab_item_composite_with_fill_layout
40
- @target = shell {
41
- @tab_folder = tab_folder {
42
- @tab_item_composite = tab_item {
43
- text "Tab 2"
44
- layout FillLayout.new
45
- label {text "Hello"}
46
- }
47
- }
48
- }
49
-
50
- assert_not_nil @target
51
- assert_not_nil @target.widget
52
- assert_equal 1, @tab_folder.widget.items.size
53
- assert_instance_of Composite, @tab_item_composite.widget
54
- assert_equal @tab_item_composite.widget, @tab_folder.widget.items[0].control
55
- assert_equal "Tab 2", @tab_item_composite.tab_item.widget.text
56
- assert_not_nil @tab_item_composite.widget.getLayout
57
- assert_instance_of FillLayout, @tab_item_composite.widget.getLayout
58
- end
59
-
60
- end
61
-
@@ -1,122 +0,0 @@
1
- require_relative "helper"
2
-
3
- class GlimmerTableDataBindingTest < Test::Unit::TestCase
4
- include Glimmer
5
-
6
- include_package 'org.eclipse.swt'
7
- include_package 'org.eclipse.swt.widgets'
8
- include_package 'org.eclipse.swt.layout'
9
-
10
- def setup
11
- dsl :swt
12
- end
13
-
14
- def teardown
15
- @target.display.dispose if @target.display
16
- end
17
-
18
- class Group
19
- def initialize
20
- @people = []
21
- end
22
-
23
- attr_accessor :people
24
- end
25
-
26
- class Person
27
- attr_accessor :name, :age, :adult
28
- end
29
-
30
- def test_text_widget_data_binding_string_property
31
- person1 = Person.new
32
- person1.name = "Bruce Ting"
33
- person1.age = 45
34
- person1.adult = true
35
-
36
- person2 = Person.new
37
- person2.name = "Julia Fang"
38
- person2.age = 17
39
- person2.adult = false
40
-
41
- group = Group.new
42
- group.people << person1
43
- group.people << person2
44
-
45
- @target = shell {
46
- @table = table {
47
- table_column {
48
- text "Name"
49
- width 120
50
- }
51
- table_column {
52
- text "Age"
53
- width 120
54
- }
55
- table_column {
56
- text "Adult"
57
- width 120
58
- }
59
- items bind(group, :people), column_properties(:name, :age, :adult)
60
- }
61
- }
62
-
63
- assert_equal 3, @table.widget.getColumnCount
64
- assert_equal 2, @table.widget.getItems.size
65
-
66
- assert_equal "Bruce Ting", @table.widget.getItems[0].getText(0)
67
- assert_equal "45", @table.widget.getItems[0].getText(1)
68
- assert_equal "true", @table.widget.getItems[0].getText(2)
69
-
70
- assert_equal "Julia Fang", @table.widget.getItems[1].getText(0)
71
- assert_equal "17", @table.widget.getItems[1].getText(1)
72
- assert_equal "false", @table.widget.getItems[1].getText(2)
73
-
74
- person3 = Person.new
75
- person3.name = "Andrea Shingle"
76
- person3.age = 23
77
- person3.adult = true
78
-
79
- group.people << person3
80
-
81
- assert_equal 3, @table.widget.getItems.size
82
- assert_equal "Andrea Shingle", @table.widget.getItems[2].getText(0)
83
- assert_equal "23", @table.widget.getItems[2].getText(1)
84
- assert_equal "true", @table.widget.getItems[2].getText(2)
85
-
86
- group.people.delete person2
87
-
88
- assert_equal 2, @table.widget.getItems.size
89
- assert_equal "Andrea Shingle", @table.widget.getItems[1].getText(0)
90
- assert_equal "23", @table.widget.getItems[1].getText(1)
91
- assert_equal "true", @table.widget.getItems[1].getText(2)
92
-
93
- group.people.delete_at(0)
94
-
95
- assert_equal 1, @table.widget.getItems.size
96
- assert_equal "Andrea Shingle", @table.widget.getItems[0].getText(0)
97
- assert_equal "23", @table.widget.getItems[0].getText(1)
98
- assert_equal "true", @table.widget.getItems[0].getText(2)
99
-
100
- group.people.clear
101
-
102
- assert_equal 0, @table.widget.getItems.size
103
-
104
- group.people = [person2, person1]
105
-
106
- assert_equal 2, @table.widget.getItems.size
107
-
108
- assert_equal "Julia Fang", @table.widget.getItems[0].getText(0)
109
- assert_equal "17", @table.widget.getItems[0].getText(1)
110
- assert_equal "false", @table.widget.getItems[0].getText(2)
111
-
112
- assert_equal "Bruce Ting", @table.widget.getItems[1].getText(0)
113
- assert_equal "45", @table.widget.getItems[1].getText(1)
114
- assert_equal "true", @table.widget.getItems[1].getText(2)
115
-
116
- person1.name = "Bruce Flee"
117
-
118
- assert_equal "Bruce Flee", @table.widget.getItems[1].getText(0)
119
- end
120
-
121
- end
122
-