glimmer 0.1.5.470 → 0.1.8.470
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.rspec +2 -0
- data/Gemfile +2 -0
- data/README.markdown +7 -2
- data/Rakefile +7 -8
- data/TODO.md +1 -1
- data/VERSION +1 -1
- data/bin/girb +3 -0
- data/bin/girb_runner.rb +5 -0
- data/glimmer.gemspec +29 -19
- data/lib/glimmer_application.rb +1 -2
- data/lib/shine.rb +23 -21
- data/lib/xml_command_handlers/models/node.rb +11 -11
- data/lib/xml_command_handlers/models/xml_visitor.rb +12 -12
- data/samples/tictactoe/tic_tac_toe.rb +11 -11
- data/spec/lib/command_handlers/models/observable_model_spec.rb +22 -0
- data/spec/lib/command_handlers/models/r_widget_spec.rb +52 -0
- data/{test/glimmer_combo_data_binding_test.rb → spec/lib/glimmer__combo_data_binding__spec.rb} +48 -49
- data/spec/lib/glimmer__constant__spec.rb +30 -0
- data/{test/glimmer_data_binding_test.rb → spec/lib/glimmer__data_binding__spec.rb} +95 -94
- data/spec/lib/glimmer__list_data_binding__spec.rb +224 -0
- data/{test/glimmer_listeners_test.rb → spec/lib/glimmer__listeners__spec.rb} +18 -19
- data/spec/lib/glimmer__shine_data_binding__spec.rb +89 -0
- data/spec/lib/glimmer__tab_item__spec.rb +55 -0
- data/spec/lib/glimmer__table_data_binding__spec.rb +121 -0
- data/spec/lib/glimmer_spec.rb +251 -0
- data/spec/lib/xml/glimmer_xml_spec.rb +154 -0
- data/spec/samples/contactmanager/contact_manager_presenter_spec.rb +81 -0
- data/spec/samples/tictactoe/tic_tac_toe_spec.rb +263 -0
- data/spec/spec_helper.rb +123 -0
- metadata +50 -17
- data/test/glimmer_constant_test.rb +0 -30
- data/test/glimmer_list_data_binding_test.rb +0 -223
- data/test/glimmer_shine_data_binding_test.rb +0 -89
- data/test/glimmer_tab_item_test.rb +0 -61
- data/test/glimmer_table_data_binding_test.rb +0 -122
- data/test/glimmer_test.rb +0 -237
- data/test/helper.rb +0 -24
- data/test/observable_model_test.rb +0 -25
- data/test/r_widget_test.rb +0 -52
- data/test/samples/contactmanager/contact_manager_presenter_test.rb +0 -81
- data/test/samples/tictactoe/tic_tac_toe_test.rb +0 -262
- data/test/xml/glimmer_xml_test.rb +0 -163
@@ -0,0 +1,22 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ObservableModel do
|
4
|
+
class Person
|
5
|
+
attr_accessor :name
|
6
|
+
end
|
7
|
+
|
8
|
+
it "observes model" do
|
9
|
+
person = Person.new
|
10
|
+
person.name = "Marty"
|
11
|
+
expect(person.name).to eq("Marty")
|
12
|
+
person.extend ObservableModel
|
13
|
+
person.add_observer(:name, self)
|
14
|
+
person.name = "Julia"
|
15
|
+
expect(@observed_name).to eq("Julia")
|
16
|
+
expect(person.name).to eq("Julia")
|
17
|
+
end
|
18
|
+
|
19
|
+
def update(name)
|
20
|
+
@observed_name = name
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe RWidget do
|
4
|
+
include Glimmer
|
5
|
+
|
6
|
+
before do
|
7
|
+
dsl :swt
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'asyncronously executes' do
|
11
|
+
@target = shell {
|
12
|
+
@text = text {
|
13
|
+
text "text1"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
@target.async_exec do
|
18
|
+
@text.widget.setText("text2")
|
19
|
+
end
|
20
|
+
|
21
|
+
@target.async_exec do
|
22
|
+
expect(@text.widget.getText).to eq("text2")
|
23
|
+
@target.widget.close
|
24
|
+
end
|
25
|
+
|
26
|
+
@target.open
|
27
|
+
end
|
28
|
+
|
29
|
+
it "syncronously executes" do
|
30
|
+
@target = shell {
|
31
|
+
@text = text {
|
32
|
+
text "text1"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
@target.async_exec do
|
37
|
+
expect(@text.widget.getText).to eq("text2")
|
38
|
+
@text.widget.setText("text3")
|
39
|
+
end
|
40
|
+
|
41
|
+
@target.sync_exec do
|
42
|
+
@text.widget.setText("text2")
|
43
|
+
end
|
44
|
+
|
45
|
+
@target.async_exec do
|
46
|
+
@target.widget.close
|
47
|
+
end
|
48
|
+
|
49
|
+
@target.open
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
data/{test/glimmer_combo_data_binding_test.rb → spec/lib/glimmer__combo_data_binding__spec.rb}
RENAMED
@@ -1,83 +1,83 @@
|
|
1
|
-
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
|
3
|
+
describe "Glimmer Combo Data Binding" do
|
4
4
|
include Glimmer
|
5
5
|
|
6
6
|
include_package 'org.eclipse.swt'
|
7
7
|
include_package 'org.eclipse.swt.widgets'
|
8
8
|
include_package 'org.eclipse.swt.layout'
|
9
9
|
|
10
|
-
|
10
|
+
before do
|
11
11
|
dsl :swt
|
12
12
|
end
|
13
|
-
|
14
|
-
|
13
|
+
|
14
|
+
after do
|
15
15
|
@target.display.dispose if @target.display
|
16
16
|
end
|
17
|
-
|
18
|
-
class Person
|
17
|
+
|
18
|
+
class Person
|
19
19
|
attr_accessor :country, :country_options
|
20
|
-
|
20
|
+
|
21
21
|
def initialize
|
22
22
|
self.country_options=["", "Canada", "US", "Mexico"]
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
it "tests data binding selection property" do
|
27
27
|
person = Person.new
|
28
|
-
|
28
|
+
|
29
29
|
@target = shell {
|
30
30
|
@combo = combo {
|
31
31
|
selection bind(person, :country)
|
32
32
|
}
|
33
33
|
}
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
|
35
|
+
expect(@combo.widget.item_count).to eq(4)
|
36
|
+
expect(@combo.widget.selection_index).to eq(-1)
|
37
|
+
expect(@combo.widget.text).to eq("")
|
38
38
|
|
39
39
|
person.country = "Canada"
|
40
40
|
|
41
|
-
|
41
|
+
expect(@combo.widget.text).to eq("Canada")
|
42
42
|
|
43
43
|
person.country_options << "France"
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
|
45
|
+
expect(@combo.widget.item_count).to eq(5)
|
46
|
+
|
47
47
|
person.country_options=["", "Canada", "US", "Mexico", "Russia", "France"]
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
|
49
|
+
expect(@combo.widget.item_count).to eq(6)
|
50
|
+
|
51
51
|
person.country_options << "Italy"
|
52
52
|
person.country_options << "Germany"
|
53
53
|
person.country_options << "Australia"
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
|
55
|
+
expect(@combo.widget.item_count).to eq(9)
|
56
|
+
|
57
|
+
expect(@combo.widget.text).to eq("")
|
58
|
+
|
59
59
|
@combo.widget.select(2)
|
60
60
|
@combo.widget.notifyListeners(SWT::Selection, nil)
|
61
|
-
|
61
|
+
expect(person.country).to eq("US")
|
62
62
|
|
63
63
|
person.country = "Canada"
|
64
64
|
|
65
|
-
|
65
|
+
expect(@combo.widget.text).to eq("Canada")
|
66
66
|
|
67
67
|
person.country = "Russia"
|
68
|
-
|
69
|
-
|
68
|
+
|
69
|
+
expect(@combo.widget.text).to eq("Russia")
|
70
70
|
|
71
71
|
person.country = ""
|
72
|
-
|
73
|
-
|
72
|
+
|
73
|
+
expect(@combo.widget.text).to eq("")
|
74
74
|
|
75
75
|
person.country = "Japan"
|
76
|
-
|
77
|
-
|
76
|
+
|
77
|
+
expect(@combo.widget.text).to eq("Japan")
|
78
78
|
end
|
79
|
-
|
80
|
-
|
79
|
+
|
80
|
+
it "tests read only widget data binding selection property" do
|
81
81
|
person = Person.new
|
82
82
|
person.country = "Canada"
|
83
83
|
|
@@ -87,45 +87,44 @@ class GlimmerComboDataBindingTest < Test::Unit::TestCase
|
|
87
87
|
}
|
88
88
|
}
|
89
89
|
|
90
|
-
|
91
|
-
|
90
|
+
expect(@combo.widget.item_count).to eq(4)
|
91
|
+
expect(@combo.widget.text).to eq("Canada")
|
92
92
|
|
93
93
|
person.country_options << "France"
|
94
94
|
|
95
|
-
|
95
|
+
expect(@combo.widget.item_count).to eq(5)
|
96
96
|
|
97
97
|
person.country_options=["", "Canada", "US", "Mexico", "Russia", "France"]
|
98
98
|
|
99
|
-
|
99
|
+
expect(@combo.widget.item_count).to eq(6)
|
100
100
|
|
101
101
|
person.country_options << "Italy"
|
102
102
|
person.country_options << "Germany"
|
103
103
|
person.country_options << "Australia"
|
104
104
|
|
105
|
-
|
105
|
+
expect(@combo.widget.item_count).to eq(9)
|
106
106
|
|
107
|
-
|
107
|
+
expect(@combo.widget.text).to eq("")
|
108
108
|
|
109
109
|
@combo.widget.select(8)
|
110
110
|
@combo.widget.notifyListeners(SWT::Selection, nil)
|
111
|
-
|
111
|
+
expect(person.country).to eq("Australia")
|
112
112
|
|
113
113
|
person.country = "Canada"
|
114
114
|
|
115
|
-
|
115
|
+
expect(@combo.widget.text).to eq("Canada")
|
116
116
|
|
117
117
|
person.country = "Russia"
|
118
118
|
|
119
|
-
|
119
|
+
expect(@combo.widget.text).to eq("Russia")
|
120
120
|
|
121
121
|
person.country = ""
|
122
122
|
|
123
|
-
|
123
|
+
expect(@combo.widget.text).to eq("")
|
124
124
|
|
125
125
|
person.country = "Japan"
|
126
126
|
|
127
|
-
|
127
|
+
expect(@combo.widget.text).to eq("")
|
128
128
|
end
|
129
|
-
|
130
|
-
end
|
131
129
|
|
130
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "Glimmer Constant" 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
|
+
|
10
|
+
before do
|
11
|
+
dsl :swt
|
12
|
+
end
|
13
|
+
|
14
|
+
after do
|
15
|
+
@target.display.dispose if @target.display
|
16
|
+
end
|
17
|
+
|
18
|
+
it "test shell with default layout and composite" do
|
19
|
+
@target = shell {
|
20
|
+
composite(:border, :no_focus) {
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
expect(@target.widget.children.size).to eq(1)
|
25
|
+
expect(@target.widget.children[0]).to be_instance_of(org.eclipse.swt.widgets.Composite)
|
26
|
+
composite_widget = @target.widget.children[0]
|
27
|
+
expect(composite_widget).to have_style(:no_focus)
|
28
|
+
expect(composite_widget).to have_style(:border)
|
29
|
+
end
|
30
|
+
end
|
@@ -1,28 +1,30 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
describe "Glimmer Data Binding" do
|
4
4
|
include Glimmer
|
5
5
|
|
6
6
|
include_package 'org.eclipse.swt'
|
7
7
|
include_package 'org.eclipse.swt.widgets'
|
8
8
|
include_package 'org.eclipse.swt.layout'
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
SWT = org.eclipse.swt.SWT unless Object.const_defined?(:SWT)
|
11
|
+
|
12
|
+
before do
|
11
13
|
dsl :swt
|
12
14
|
end
|
13
15
|
|
14
|
-
|
16
|
+
after do
|
15
17
|
@target.display.dispose if @target.display
|
16
18
|
end
|
17
|
-
|
18
|
-
class Person
|
19
|
+
|
20
|
+
class Person
|
19
21
|
attr_accessor :name, :age, :adult
|
20
22
|
end
|
21
|
-
|
22
|
-
|
23
|
+
|
24
|
+
it "tests text widget data binding string property" do
|
23
25
|
person = Person.new
|
24
26
|
person.name = "Bruce Ting"
|
25
|
-
|
27
|
+
|
26
28
|
@target = shell {
|
27
29
|
composite {
|
28
30
|
@text = text {
|
@@ -30,20 +32,20 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
|
|
30
32
|
}
|
31
33
|
}
|
32
34
|
}
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
|
36
|
+
expect(@text.widget.getText).to eq("Bruce Ting")
|
37
|
+
|
36
38
|
person.name = "Lady Butterfly"
|
37
|
-
|
38
|
-
|
39
|
+
expect(@text.widget.getText).to eq("Lady Butterfly")
|
40
|
+
|
39
41
|
@text.widget.setText("Allen Cork")
|
40
|
-
|
42
|
+
expect(person.name).to eq("Allen Cork")
|
41
43
|
end
|
42
|
-
|
43
|
-
|
44
|
+
|
45
|
+
it "tests text widget data binding fixnum property" do
|
44
46
|
person = Person.new
|
45
47
|
person.age = 15
|
46
|
-
|
48
|
+
|
47
49
|
@target = shell {
|
48
50
|
composite {
|
49
51
|
@text = text {
|
@@ -51,20 +53,20 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
|
|
51
53
|
}
|
52
54
|
}
|
53
55
|
}
|
54
|
-
|
55
|
-
|
56
|
-
|
56
|
+
|
57
|
+
expect(@text.widget.getText).to eq("15")
|
58
|
+
|
57
59
|
person.age = 27
|
58
|
-
|
59
|
-
|
60
|
+
expect(@text.widget.getText).to eq("27")
|
61
|
+
|
60
62
|
@text.widget.setText("30")
|
61
|
-
|
63
|
+
expect(person.age).to eq(30)
|
62
64
|
end
|
63
|
-
|
64
|
-
|
65
|
+
|
66
|
+
it "tests label widget data binding string property" do
|
65
67
|
person = Person.new
|
66
68
|
person.name = "Bruce Ting"
|
67
|
-
|
69
|
+
|
68
70
|
@target = shell {
|
69
71
|
composite {
|
70
72
|
@label = label {
|
@@ -72,17 +74,17 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
|
|
72
74
|
}
|
73
75
|
}
|
74
76
|
}
|
75
|
-
|
76
|
-
|
77
|
-
|
77
|
+
|
78
|
+
expect(@label.widget.getText).to eq("Bruce Ting")
|
79
|
+
|
78
80
|
person.name = "Lady Butterfly"
|
79
|
-
|
81
|
+
expect(@label.widget.getText).to eq("Lady Butterfly")
|
80
82
|
end
|
81
|
-
|
82
|
-
|
83
|
+
|
84
|
+
it "tests checkbox widget data binding boolean property" do
|
83
85
|
person = Person.new
|
84
86
|
person.adult = true
|
85
|
-
|
87
|
+
|
86
88
|
@target = shell {
|
87
89
|
composite {
|
88
90
|
@check_box = button(:check) {
|
@@ -90,21 +92,21 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
|
|
90
92
|
}
|
91
93
|
}
|
92
94
|
}
|
93
|
-
|
94
|
-
|
95
|
-
|
95
|
+
|
96
|
+
expect(@check_box.widget.getSelection).to eq(true)
|
97
|
+
|
96
98
|
person.adult = false
|
97
|
-
|
98
|
-
|
99
|
+
expect(@check_box.widget.getSelection).to eq(false)
|
100
|
+
|
99
101
|
@check_box.widget.setSelection(true)
|
100
102
|
@check_box.widget.notifyListeners(SWT::Selection, nil)
|
101
|
-
|
103
|
+
expect(person.adult).to eq(true)
|
102
104
|
end
|
103
|
-
|
104
|
-
|
105
|
+
|
106
|
+
it "tests radio widget data binding boolean property" do
|
105
107
|
person = Person.new
|
106
108
|
person.adult = true
|
107
|
-
|
109
|
+
|
108
110
|
@target = shell {
|
109
111
|
composite {
|
110
112
|
@radio = button(:radio) {
|
@@ -112,21 +114,21 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
|
|
112
114
|
}
|
113
115
|
}
|
114
116
|
}
|
115
|
-
|
116
|
-
|
117
|
-
|
117
|
+
|
118
|
+
expect(@radio.widget.getSelection).to eq(true)
|
119
|
+
|
118
120
|
person.adult = false
|
119
|
-
|
120
|
-
|
121
|
+
expect(@radio.widget.getSelection).to eq(false)
|
122
|
+
|
121
123
|
@radio.widget.setSelection(true)
|
122
124
|
@radio.widget.notifyListeners(SWT::Selection, nil)
|
123
|
-
|
125
|
+
expect(person.adult).to eq(true)
|
124
126
|
end
|
125
|
-
|
126
|
-
|
127
|
+
|
128
|
+
it "tests spinner widget data binding fixnum property" do
|
127
129
|
person = Person.new
|
128
130
|
person.age = 17
|
129
|
-
|
131
|
+
|
130
132
|
@target = shell {
|
131
133
|
composite {
|
132
134
|
@spinner = spinner {
|
@@ -134,21 +136,21 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
|
|
134
136
|
}
|
135
137
|
}
|
136
138
|
}
|
137
|
-
|
138
|
-
|
139
|
-
|
139
|
+
|
140
|
+
expect(@spinner.widget.getSelection).to eq(17)
|
141
|
+
|
140
142
|
person.age = 20
|
141
|
-
|
142
|
-
|
143
|
+
expect(@spinner.widget.getSelection).to eq(20)
|
144
|
+
|
143
145
|
@spinner.widget.setSelection(34)
|
144
146
|
@spinner.widget.notifyListeners(SWT::Selection, nil)
|
145
|
-
|
147
|
+
expect(person.age).to eq(34)
|
146
148
|
end
|
147
|
-
|
148
|
-
|
149
|
+
|
150
|
+
it "tests widget data binding enablement" do
|
149
151
|
person = Person.new
|
150
152
|
person.adult = true
|
151
|
-
|
153
|
+
|
152
154
|
@target = shell {
|
153
155
|
composite {
|
154
156
|
@text = text {
|
@@ -156,17 +158,17 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
|
|
156
158
|
}
|
157
159
|
}
|
158
160
|
}
|
159
|
-
|
160
|
-
|
161
|
-
|
161
|
+
|
162
|
+
expect(@text.widget.isEnabled).to eq(true)
|
163
|
+
|
162
164
|
person.adult = false
|
163
|
-
|
165
|
+
expect(@text.widget.isEnabled).to eq(false)
|
164
166
|
end
|
165
|
-
|
166
|
-
|
167
|
+
|
168
|
+
it "tests multiple widget data binding enablement to same model property" do
|
167
169
|
person = Person.new
|
168
170
|
person.adult = true
|
169
|
-
|
171
|
+
|
170
172
|
@target = shell {
|
171
173
|
composite {
|
172
174
|
@text = text {
|
@@ -180,23 +182,23 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
|
|
180
182
|
}
|
181
183
|
}
|
182
184
|
}
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
185
|
+
|
186
|
+
expect(@text.widget.isEnabled).to eq(true)
|
187
|
+
expect(@text2.widget.isEnabled).to eq(true)
|
188
|
+
expect(@text3.widget.isEnabled).to eq(true)
|
189
|
+
|
188
190
|
person.adult = false
|
189
|
-
|
190
|
-
|
191
|
-
|
191
|
+
expect(@text.widget.isEnabled).to eq(false)
|
192
|
+
expect(@text2.widget.isEnabled).to eq(false)
|
193
|
+
expect(@text3.widget.isEnabled).to eq(false)
|
192
194
|
end
|
193
|
-
|
194
|
-
|
195
|
+
|
196
|
+
it "tests multiple widget data bindings to different model properties" do
|
195
197
|
person = Person.new
|
196
198
|
person.name = "Nancy"
|
197
199
|
person.age = 15
|
198
200
|
person.adult = true
|
199
|
-
|
201
|
+
|
200
202
|
@target = shell {
|
201
203
|
composite {
|
202
204
|
@label = label {
|
@@ -210,27 +212,26 @@ class GlimmerDataBindingTest < Test::Unit::TestCase
|
|
210
212
|
}
|
211
213
|
}
|
212
214
|
}
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
215
|
+
|
216
|
+
expect(@label.widget.getText).to eq("Nancy")
|
217
|
+
expect(@text.widget.getText).to eq("15")
|
218
|
+
expect(@check_box.widget.getSelection).to eq(true)
|
219
|
+
|
218
220
|
person.name = "Drew"
|
219
|
-
|
220
|
-
|
221
|
+
expect(@label.widget.getText).to eq("Drew")
|
222
|
+
|
221
223
|
person.age = 27
|
222
|
-
|
224
|
+
expect(@text.widget.getText).to eq("27")
|
223
225
|
|
224
226
|
person.adult = false
|
225
|
-
|
226
|
-
|
227
|
+
expect(@check_box.widget.getSelection).to eq(false)
|
228
|
+
|
227
229
|
@text.widget.setText("30")
|
228
|
-
|
230
|
+
expect(person.age).to eq(30)
|
229
231
|
|
230
232
|
@check_box.widget.setSelection(true)
|
231
233
|
@check_box.widget.notifyListeners(SWT::Selection, nil)
|
232
|
-
|
234
|
+
expect(person.adult).to eq(true)
|
233
235
|
end
|
234
|
-
|
235
|
-
end
|
236
236
|
|
237
|
+
end
|