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
@@ -0,0 +1,251 @@
1
+ require "spec_helper"
2
+
3
+ describe Glimmer do
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
+ Shell = org.eclipse.swt.widgets.Shell unless Object.const_defined?(:Shell)
12
+ Composite = org.eclipse.swt.widgets.Composite unless Object.const_defined?(:Composite)
13
+ Text = org.eclipse.swt.widgets.Text unless Object.const_defined?(:Text)
14
+ Spinner = org.eclipse.swt.widgets.Spinner unless Object.const_defined?(:Spinner)
15
+ List = org.eclipse.swt.widgets.List unless Object.const_defined?(:List)
16
+ Button = org.eclipse.swt.widgets.Button unless Object.const_defined?(:Button)
17
+ Group = org.eclipse.swt.widgets.Group unless Object.const_defined?(:Group)
18
+
19
+ GridLayout = org.eclipse.swt.layout.GridLayout unless Object.const_defined?(:GridLayout)
20
+ FillLayout = org.eclipse.swt.layout.FillLayout unless Object.const_defined?(:FillLayout)
21
+ RowLayout = org.eclipse.swt.layout.RowLayout unless Object.const_defined?(:RowLayout)
22
+
23
+ Rectangle = org.eclipse.swt.graphics.Rectangle unless Object.const_defined?(:Rectangle)
24
+ Point = org.eclipse.swt.graphics.Point unless Object.const_defined?(:Point)
25
+
26
+ before do
27
+ @target = nil
28
+ dsl :swt
29
+ end
30
+
31
+ after do
32
+ @target.display.dispose if @target.display
33
+ end
34
+
35
+ it "tests shell_with_default_layout" do
36
+ @target = shell
37
+
38
+ expect(@target).to_not be_nil
39
+ expect(@target.widget).to_not be_nil
40
+ expect(@target.widget).to be_instance_of(Shell)
41
+ expect(@target.widget.getLayout).to_not be_nil
42
+ expect(@target.widget.getLayout).to be_instance_of(FillLayout)
43
+ end
44
+
45
+ it "tests shell_with_title_and_layout" do
46
+ shell_layout = GridLayout.new
47
+ @target = shell {
48
+ text "Title"
49
+ layout shell_layout
50
+ }
51
+
52
+ expect(@target.widget.getText).to eq( "Title")
53
+ expect(@target.widget.getLayout).to eq( shell_layout)
54
+ end
55
+
56
+ it "tests shell_with_bounds" do
57
+ @target = shell {
58
+ bounds 50, 75, 800, 600
59
+ }
60
+
61
+ expect(@target.widget.getBounds).to eq( Rectangle.new(50, 75, 800, 600) )
62
+ end
63
+
64
+ it "tests shell_with_size" do
65
+ @target = shell {
66
+ size 800, 600
67
+ }
68
+
69
+ expect(@target.widget.getSize).to eq( Point.new(800, 600) )
70
+ end
71
+
72
+ it "tests shell_and_composite_with_default_style_and_layout" do
73
+ @target = shell {
74
+ composite
75
+ }
76
+
77
+ expect(@target.widget.children.size).to eq( 1)
78
+ expect(@target.widget.children[0]).to be_instance_of(Composite)
79
+ composite_widget = @target.widget.children[0]
80
+ expect(composite_widget).to have_style(:none)
81
+ expect(composite_widget.getLayout).to be_instance_of(GridLayout)
82
+ grid_layout = composite_widget.getLayout
83
+ expect(grid_layout.numColumns).to eq( 1)
84
+ expect(grid_layout.makeColumnsEqualWidth).to eq( false)
85
+ end
86
+
87
+ it "tests shell_and_group_with_default_style_and_layout" do
88
+ @target = shell {
89
+ group {
90
+ text "Title"
91
+ }
92
+ }
93
+
94
+ expect(@target.widget.children.size).to eq( 1)
95
+ expect(@target.widget.children[0]).to be_instance_of(Java::OrgEclipseSwtWidgets::Group)
96
+ group_widget = @target.widget.children[0]
97
+ expect(group_widget).to have_style(:none)
98
+ expect(group_widget.getLayout).to be_instance_of(GridLayout)
99
+ grid_layout = group_widget.getLayout
100
+ expect(grid_layout.numColumns).to eq( 1)
101
+ expect(grid_layout.makeColumnsEqualWidth).to eq( false)
102
+ expect(group_widget.getText).to eq( "Title")
103
+ end
104
+
105
+ it "tests shell_and_composite_with_style_and_layout" do
106
+ composite_layout = RowLayout.new
107
+ @target = shell {
108
+ composite(:no_focus) {
109
+ layout composite_layout
110
+ }
111
+ }
112
+
113
+ expect(@target.widget.children.size).to eq( 1)
114
+ expect(@target.widget.children[0]).to be_instance_of(Composite)
115
+ composite_widget = @target.widget.children[0]
116
+ expect(composite_widget).to have_style(:no_focus)
117
+ expect(composite_widget.getLayout).to eq( composite_layout)
118
+ end
119
+
120
+ it "tests shell_and_composite_and_text_with_default_style" do
121
+ @target = shell {
122
+ composite {
123
+ text
124
+ }
125
+ }
126
+
127
+ composite_widget = @target.widget.children[0]
128
+ expect(composite_widget.children.size).to eq( 1)
129
+ expect(composite_widget.children[0]).to be_instance_of(Text)
130
+ text_widget = composite_widget.children[0]
131
+ expect(text_widget).to have_style(:border)
132
+ end
133
+
134
+ it "tests shell_and_composite_with_custom_layout_and_text_with_default_style" do
135
+ composite_layout = RowLayout.new
136
+ @target = shell {
137
+ composite {
138
+ text
139
+ layout composite_layout
140
+ }
141
+ }
142
+
143
+ composite_widget = @target.widget.children[0]
144
+ expect(composite_widget.getLayout).to eq( composite_layout)
145
+ expect(composite_widget.children.size).to eq( 1)
146
+ expect(composite_widget.children[0]).to be_instance_of(Text)
147
+ text_widget = composite_widget.children[0]
148
+ expect(text_widget).to have_style(:border)
149
+ end
150
+
151
+ it "tests shell_and_composite_and_text_with_style_and_text" do
152
+ @target = shell {
153
+ composite {
154
+ text(:password) {
155
+ text "Hello"
156
+ }
157
+ }
158
+ }
159
+
160
+ composite_widget = @target.widget.children[0]
161
+ expect(composite_widget.children.size).to eq( 1)
162
+ expect(composite_widget.children[0]).to be_instance_of(Text)
163
+ text_widget = composite_widget.children[0]
164
+ expect(text_widget).to have_style(:password)
165
+ expect(text_widget.getText).to eq( "Hello")
166
+ end
167
+
168
+ it "tests shell_and_spinner_default" do
169
+ @target = shell {
170
+ @spinner = spinner {
171
+ selection 55
172
+ }
173
+ }
174
+
175
+ expect(@spinner.widget).to be_instance_of(Spinner)
176
+ expect(@spinner.widget).to have_style(:border)
177
+ expect(@spinner.widget.getSelection).to eq( 55)
178
+ end
179
+
180
+ it "tests shell_and_list_default" do
181
+ @target = shell {
182
+ @list = list {
183
+ }
184
+ }
185
+
186
+ expect(@list.widget).to be_instance_of(List)
187
+ expect(@list.widget).to have_style(:border)
188
+ expect(@list.widget).to have_style(:single)
189
+ expect(@list.widget).to have_style(:v_scroll)
190
+ end
191
+
192
+ it "tests shell_and_button_default" do
193
+ @target = shell {
194
+ @button = button {
195
+ text "Push Me"
196
+ }
197
+ }
198
+
199
+ expect(@button.widget).to be_instance_of(Button)
200
+ expect(@button.widget).to have_style(:push)
201
+ expect(@button.widget.text).to eq( "Push Me")
202
+ end
203
+
204
+ it "tests shell_and_table_and_table_column_defaults" do
205
+ @target = shell {
206
+ @table = table {
207
+ @table_column = table_column
208
+ }
209
+ }
210
+
211
+ expect(@table.widget).to have_style(:border)
212
+ assert @table.widget.getHeaderVisible
213
+ assert @table.widget.getLinesVisible
214
+ expect(@table_column.widget.getWidth).to eq( 80)
215
+ end
216
+
217
+ it "tests shell_containing_undefined_command" do
218
+ @target = shell {
219
+ undefined_command(:undefined_parameter) {
220
+ }
221
+ }
222
+
223
+ expect(@target).to_not be_nil
224
+ expect(@target.widget).to_not be_nil
225
+ expect(@target.widget).to be_instance_of(Shell)
226
+ expect(@target.widget.getLayout).to_not be_nil
227
+ expect(@target.widget.getLayout).to be_instance_of(FillLayout)
228
+ end
229
+
230
+
231
+ it "tests add_contents" do
232
+ @target = shell {
233
+ }
234
+
235
+ add_contents(@target) {
236
+ composite {
237
+ text(:password) {
238
+ text "Hello"
239
+ }
240
+ }
241
+ }
242
+
243
+ composite_widget = @target.widget.children[0]
244
+ expect(composite_widget.children.size).to eq( 1)
245
+ expect(composite_widget.children[0]).to be_instance_of(Text)
246
+ text_widget = composite_widget.children[0]
247
+ expect(text_widget).to have_style(:password)
248
+ expect(text_widget.getText).to eq( "Hello")
249
+ end
250
+
251
+ end
@@ -0,0 +1,154 @@
1
+ require "spec_helper"
2
+ # require_relative "../../lib/parent"
3
+
4
+ describe "Glimmer Xml" do
5
+ include Glimmer
6
+
7
+ before do
8
+ dsl :xml
9
+ end
10
+
11
+ it "tests single html tag" do
12
+ @target = html
13
+
14
+ assert_not_nil @target
15
+ expect(@target.to_xml).to eq("<html/>")
16
+ end
17
+
18
+ it "tests single document tag upper case" do
19
+ @target = tag(:_name => "DOCUMENT")
20
+
21
+ assert_not_nil @target
22
+ expect(@target.to_xml).to eq("<DOCUMENT/>")
23
+ end
24
+
25
+ it "tests open and closed html tag" do
26
+ @target = html {}
27
+
28
+ assert_not_nil @target
29
+ expect(@target.to_xml).to eq("<html></html>")
30
+ end
31
+
32
+ it "tests open and closed html tag with contents" do
33
+ @target = html { "This is an HTML Document" }
34
+
35
+ assert_not_nil @target
36
+ expect(@target.to_xml).to eq("<html>This is an HTML Document</html>")
37
+ end
38
+
39
+ it "tests open and closed html tag with attributes" do
40
+ @target = html(:id => "thesis", :class => "document") {
41
+ }
42
+
43
+ assert_not_nil @target
44
+ expect(@target.to_xml).to eq('<html id="thesis" class="document"></html>')
45
+ end
46
+
47
+ it "tests open and closed html tag with attributes and nested body with attributes" do
48
+ @target = html(:id => "thesis", :class => "document") {
49
+ body(:id => "main") {
50
+ }
51
+ }
52
+
53
+ assert_not_nil @target
54
+ expect(@target.to_xml).to eq('<html id="thesis" class="document"><body id="main"></body></html>')
55
+ end
56
+
57
+ it "tests tag with contents before and after nested tag" do
58
+ @target = html(:id => "thesis", :class => "document") {
59
+ text "Before body"
60
+ body(:id => "main") {
61
+ }
62
+ text "When a string is the last part of the tag contents, text prefix is optional"
63
+ }
64
+
65
+ assert_not_nil @target
66
+ expect(@target.to_xml).to eq('<html id="thesis" class="document">Before body<body id="main"></body>When a string is the last part of the tag contents, text prefix is optional</html>')
67
+ end
68
+
69
+ it "tests different name spaced tags" do
70
+ @target = w3c.html(:id => "thesis", :class => "document") {
71
+ document.body(:id => "main") {
72
+ }
73
+ }
74
+
75
+ assert_not_nil @target
76
+ expect(@target.to_xml).to eq('<w3c:html id="thesis" class="document"><document:body id="main"></document:body></w3c:html>')
77
+ end
78
+
79
+ it "tests different name spaced attributes and tags" do
80
+ @target = w3c.html(w3c.id => "thesis", :class => "document") {
81
+ document.body(document.id => "main") {
82
+ }
83
+ }
84
+
85
+ assert_not_nil @target
86
+ expect(@target.to_xml).to eq('<w3c:html w3c:id="thesis" class="document"><document:body document:id="main"></document:body></w3c:html>')
87
+ end
88
+
89
+ it "tests name space context" do
90
+ @target = name_space(:w3c) {
91
+ html(:id => "thesis", :class => "document") {
92
+ body(:id => "main") {
93
+ }
94
+ }
95
+ }
96
+
97
+ assert_not_nil @target
98
+ expect(@target.to_xml).to eq('<w3c:html id="thesis" class="document"><w3c:body id="main"></w3c:body></w3c:html>')
99
+ end
100
+
101
+ it "tests two name space contexts" do
102
+ @target = name_space(:w3c) {
103
+ html(:id => "thesis", :class => "document") {
104
+ name_space(:document) {
105
+ sectionDivider(:id => "main") {
106
+ }
107
+ }
108
+ }
109
+ }
110
+
111
+ assert_not_nil @target
112
+ expect(@target.to_xml).to eq('<w3c:html id="thesis" class="document"><document:sectionDivider id="main"></document:sectionDivider></w3c:html>')
113
+ end
114
+
115
+ it "tests two name space contexts including contents" do
116
+ @target = name_space(:w3c) {
117
+ html(:id => "thesis", :class => "document") {
118
+ text "before section divider"
119
+ name_space(:document) {
120
+ sectionDivider(:id => "main") {
121
+ "section divider"
122
+ }
123
+ }
124
+ text "after section divider"
125
+ }
126
+ }
127
+
128
+ assert_not_nil @target
129
+ expect(@target.to_xml).to eq('<w3c:html id="thesis" class="document">before section divider<document:sectionDivider id="main">section divider</document:sectionDivider>after section divider</w3c:html>')
130
+ end
131
+
132
+ it "tests mixed contents custom syntax" do
133
+ @target = html{"before section divider#strong{section divider}after section divider"}
134
+
135
+ assert_not_nil @target
136
+ expect(@target.to_xml).to eq('<html>before section divider<strong>section divider</strong>after section divider</html>')
137
+ end
138
+
139
+ #TODO handle special characters such as #, {, }, and .
140
+ #TODO CDATA support
141
+ #TODO encode special characters
142
+
143
+ it "tests html alternative syntax for id and class attributes" do
144
+ @target = html_thesis_document {
145
+ body_main {
146
+ h1__title
147
+ }
148
+ }
149
+
150
+ assert_not_nil @target
151
+ expect(@target.to_xml).to eq('<html id="thesis" class="document"><body id="main"><h1 class="title" /></body></html>')
152
+ end
153
+
154
+ end
@@ -0,0 +1,81 @@
1
+ require "spec_helper"
2
+ require_relative "../../../samples/contactmanager/contact_manager_presenter"
3
+
4
+ describe ContactManagerPresenter do
5
+
6
+ it "tests find_specify_all_fields_for_one_result" do
7
+ contact_manager_presenter = ContactManagerPresenter.new
8
+ contact_manager_presenter.first_name = "Frank"
9
+ contact_manager_presenter.last_name = "Deelio"
10
+ contact_manager_presenter.email = "frank@deelio.com"
11
+ contact_manager_presenter.find
12
+ contacts = contact_manager_presenter.results
13
+ expect(contacts).to_not be_nil
14
+ expect(contacts.size).to eq( 1)
15
+ contact = contacts[0]
16
+ expect(contact.is_a?(Contact)).to be_true
17
+ expect(contact.first_name).to eq( "Frank")
18
+ expect(contact.last_name).to eq( "Deelio")
19
+ expect(contact.email).to eq( "frank@deelio.com")
20
+ end
21
+
22
+ it "tests find_specify_one_field_for_two_results" do
23
+ contact_manager_presenter = ContactManagerPresenter.new
24
+ contact_manager_presenter.first_name = "Frank"
25
+ contact_manager_presenter.find
26
+ contacts = contact_manager_presenter.results
27
+ expect(contacts).to_not be_nil
28
+ expect(contacts.size).to eq( 2)
29
+ contact1 = contacts[0]
30
+ contact2 = contacts[1]
31
+ expect(contact1.first_name).to eq( "Frank")
32
+ expect(contact1.last_name).to eq( "Deelio")
33
+ expect(contact1.email).to eq( "frank@deelio.com")
34
+ expect(contact2.first_name).to eq( "franky")
35
+ expect(contact2.last_name).to eq( "miller")
36
+ expect(contact2.email).to eq( "frank@miller.com")
37
+ end
38
+
39
+ it "tests find_specify_all_fields_for_no_results" do
40
+ contact_manager_presenter = ContactManagerPresenter.new
41
+ contact_manager_presenter.first_name = "Julia"
42
+ contact_manager_presenter.last_name = "Big"
43
+ contact_manager_presenter.email = "julia@big.com"
44
+ contact_manager_presenter.find
45
+ contacts = contact_manager_presenter.results
46
+ expect(contacts).to_not be_nil
47
+ expect(contacts.size).to eq( 0)
48
+ end
49
+
50
+ it "tests find_specify_no_fields_for_all_results" do
51
+ contact_manager_presenter = ContactManagerPresenter.new
52
+ contact_manager_presenter.find
53
+ contacts = contact_manager_presenter.results
54
+ expect(contacts).to_not be_nil
55
+ expect(contacts.size).to eq( 4)
56
+ expect(contacts[0].first_name).to eq( "Anne")
57
+ expect(contacts[1].first_name).to eq( "Beatrice")
58
+ expect(contacts[2].first_name).to eq( "Frank")
59
+ expect(contacts[3].first_name).to eq( "franky")
60
+ end
61
+
62
+ it "tests list_all_results" do
63
+ contact_manager_presenter = ContactManagerPresenter.new
64
+ contact_manager_presenter.list
65
+ contacts = contact_manager_presenter.results
66
+ expect(contacts).to_not be_nil
67
+ expect(contacts.size).to eq( 4)
68
+ expect(contacts[0].first_name).to eq( "Anne")
69
+ expect(contacts[1].first_name).to eq( "Beatrice")
70
+ expect(contacts[2].first_name).to eq( "Frank")
71
+ expect(contacts[3].first_name).to eq( "franky")
72
+ end
73
+
74
+ it "tests initial_results" do
75
+ contact_manager_presenter = ContactManagerPresenter.new
76
+ contacts = contact_manager_presenter.results
77
+ expect(contacts).to_not be_nil
78
+ expect(contacts.size).to eq( 0)
79
+ end
80
+
81
+ end