ffi-efl 0.0.3 → 0.0.4
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.
- data/Changelog +12 -0
- data/Rakefile +1 -1
- data/lib/efl/ecore.rb +17 -6
- data/lib/efl/ecore_evas.rb +78 -24
- data/lib/efl/ecore_getopt.rb +27 -23
- data/lib/efl/ecore_input.rb +1 -1
- data/lib/efl/edje.rb +11 -11
- data/lib/efl/eet.rb +20 -14
- data/lib/efl/eina.rb +1 -1
- data/lib/efl/eina_hash.rb +17 -30
- data/lib/efl/eina_list.rb +16 -25
- data/lib/efl/elementary.rb +8 -19
- data/lib/efl/evas.rb +167 -38
- data/lib/efl/ffi.rb +28 -17
- data/lib/efl/{ffi → native}/ecore.rb +9 -5
- data/lib/efl/{ffi → native}/ecore_evas.rb +27 -20
- data/lib/efl/{ffi → native}/ecore_getopt.rb +9 -5
- data/lib/efl/{ffi → native}/ecore_input.rb +9 -5
- data/lib/efl/{ffi → native}/edje.rb +14 -10
- data/lib/efl/{ffi → native}/eet.rb +9 -5
- data/lib/efl/{ffi → native}/eina.rb +9 -5
- data/lib/efl/{ffi → native}/eina_hash.rb +9 -5
- data/lib/efl/{ffi → native}/eina_list.rb +9 -5
- data/lib/efl/{ffi → native}/eina_types.rb +9 -5
- data/lib/efl/{ffi → native}/elementary.rb +70 -66
- data/lib/efl/{ffi → native}/evas.rb +11 -7
- data/lib/efl/native.rb +16 -0
- data/lib/efl.rb +1 -1
- data/spec/ecore_evas_spec.rb +325 -6
- data/spec/ecore_getopt_spec.rb +70 -104
- data/spec/ecore_input_spec.rb +6 -6
- data/spec/ecore_spec.rb +63 -60
- data/spec/edje_spec.rb +6 -6
- data/spec/eet_spec.rb +23 -22
- data/spec/eina_hash_spec.rb +53 -58
- data/spec/eina_list_spec.rb +28 -18
- data/spec/eina_spec.rb +6 -6
- data/spec/evas_spec.rb +371 -119
- data/tasks/constants.rb +4 -0
- data/test/test_edje.rb +1 -1
- data/test/test_elm_win-native.rb +38 -0
- data/test/test_evas.rb +4 -4
- metadata +32 -20
- data/test/test_elm_win.rb +0 -35
data/spec/ecore_evas_spec.rb
CHANGED
@@ -1,24 +1,343 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
# -*- coding: UTF-8 -*-
|
3
3
|
#
|
4
|
+
require 'efl/eina_list'
|
5
|
+
require 'efl/evas'
|
6
|
+
require 'efl/ecore'
|
4
7
|
require 'efl/ecore_evas'
|
5
8
|
#
|
9
|
+
def ecore_loop n
|
10
|
+
n.downto(0) do
|
11
|
+
sleep 0.1
|
12
|
+
Efl::Ecore.main_loop_iterate
|
13
|
+
end
|
14
|
+
end
|
15
|
+
#
|
6
16
|
describe Efl::EcoreEvas do
|
7
17
|
#
|
8
18
|
before(:all) do
|
9
19
|
EcoreEvas = Efl::EcoreEvas
|
20
|
+
EcoreEvas.init
|
21
|
+
end
|
22
|
+
after(:all) do
|
23
|
+
EcoreEvas.shutdown
|
10
24
|
end
|
11
25
|
#
|
12
26
|
it "should init" do
|
13
|
-
EcoreEvas.init.should
|
14
|
-
EcoreEvas.init.should
|
15
|
-
EcoreEvas.init.should eql 3
|
27
|
+
EcoreEvas.init.should == 2
|
28
|
+
EcoreEvas.init.should == 3
|
16
29
|
end
|
17
30
|
#
|
18
31
|
it "should shutdown" do
|
19
|
-
EcoreEvas.shutdown.should
|
20
|
-
EcoreEvas.shutdown.should
|
21
|
-
EcoreEvas.shutdown.should eql 0
|
32
|
+
EcoreEvas.shutdown.should == 2
|
33
|
+
EcoreEvas.shutdown.should == 1
|
22
34
|
end
|
23
35
|
#
|
36
|
+
it "should work" do
|
37
|
+
EcoreEvas.engines_free EcoreEvas.engines_get
|
38
|
+
l = EcoreEvas.engines_list
|
39
|
+
r = l.inject("\t") do |s,e| s+=e.read_string+' ' end
|
40
|
+
puts r
|
41
|
+
EcoreEvas.engines_free l
|
42
|
+
end
|
43
|
+
#
|
44
|
+
it "ecore_evas_list should work" do
|
45
|
+
el = EcoreEvas.ecore_evas_list
|
46
|
+
el.to_ary.length.should == 0
|
47
|
+
el.free
|
48
|
+
r=[]
|
49
|
+
0.upto(3) do
|
50
|
+
r << EcoreEvas::REcoreEvas.new
|
51
|
+
end
|
52
|
+
el = EcoreEvas.ecore_evas_list
|
53
|
+
el.to_ary.length.should == 4
|
54
|
+
el.free
|
55
|
+
r.each do |e| e.free end
|
56
|
+
end
|
57
|
+
#
|
58
|
+
describe Efl::EcoreEvas::REcoreEvas do
|
59
|
+
before(:all) {
|
60
|
+
EcoreEvas.init
|
61
|
+
}
|
62
|
+
before(:each) do
|
63
|
+
@e = EcoreEvas::REcoreEvas.new :engine_name=>"software_x11", :x=>10, :y=>10, :w=>100, :h=>120
|
64
|
+
@canvas = @e.evas
|
65
|
+
@bg = @canvas.object_add(:rectangle) { |o|
|
66
|
+
o.color = 100, 100, 255, 255
|
67
|
+
o.size = @e.size
|
68
|
+
}
|
69
|
+
@bg.show
|
70
|
+
@e.object_associate @bg, :ecore_evas_object_associate_base
|
71
|
+
@e.move 10, 10
|
72
|
+
@e.show
|
73
|
+
end
|
74
|
+
after(:each) do
|
75
|
+
@e.free
|
76
|
+
end
|
77
|
+
after(:all) do
|
78
|
+
EcoreEvas.shutdown
|
79
|
+
end
|
80
|
+
#
|
81
|
+
it "engine_name_get should work" do
|
82
|
+
@e.engine_name_get.should == "software_x11"
|
83
|
+
end
|
84
|
+
#
|
85
|
+
it "data get/set should work" do
|
86
|
+
@e.data_set 'key', '666'
|
87
|
+
@e.data_get('key').read_string.should == '666'
|
88
|
+
end
|
89
|
+
#
|
90
|
+
it "move, resize move_resize and geometry_get should work (and check association)" do
|
91
|
+
@e.geometry_get.should == [10,10,100,120]
|
92
|
+
@bg.geometry_get.should == [0,0,100,120]
|
93
|
+
@e.move 20, 17 # w+23 window bar height
|
94
|
+
ecore_loop 3
|
95
|
+
@e.geometry_get.should == [20,40,100,120]
|
96
|
+
@bg.geometry_get.should == [0,0,100,120]
|
97
|
+
@e.resize 200,150
|
98
|
+
ecore_loop 3
|
99
|
+
@e.geometry_get.should == [20,40,200,150]
|
100
|
+
@bg.geometry_get.should == [0,0,200,150]
|
101
|
+
@e.move_resize 10, 0, 130, 100
|
102
|
+
ecore_loop 3
|
103
|
+
@e.geometry_get.should == [10,23,130,100]
|
104
|
+
@bg.geometry_get.should == [0,0,130,100]
|
105
|
+
g = @e.geometry_get
|
106
|
+
end
|
107
|
+
#
|
108
|
+
it "rotation should work" do
|
109
|
+
@e.rotation_set 25
|
110
|
+
@e.rotation_get.should == 25
|
111
|
+
@e.rotation = 50
|
112
|
+
@e.rotation_get.should == 50
|
113
|
+
@e.rotation_with_resize_set 0
|
114
|
+
@e.rotation_get.should == 0
|
115
|
+
end
|
116
|
+
#
|
117
|
+
it "shaped get/set should work" do
|
118
|
+
@e.shaped?.should be_false
|
119
|
+
@e.shaped_set true
|
120
|
+
@e.shaped_get.should be_true
|
121
|
+
@e.shaped = false
|
122
|
+
@e.shaped?.should be_false
|
123
|
+
end
|
124
|
+
#
|
125
|
+
it "alpha get/set should work" do
|
126
|
+
@e.alpha?.should be_false
|
127
|
+
@e.alpha_set true
|
128
|
+
@e.alpha_get.should be_true
|
129
|
+
@e.alpha = false
|
130
|
+
@e.alpha?.should be_false
|
131
|
+
end
|
132
|
+
#
|
133
|
+
it "transparent get/set should work" do
|
134
|
+
@e.transparent?.should be_false
|
135
|
+
@e.transparent_set true
|
136
|
+
@e.transparent_get.should be_true
|
137
|
+
@e.transparent = false
|
138
|
+
@e.transparent?.should be_false
|
139
|
+
end
|
140
|
+
#
|
141
|
+
it "show hide visibility should work" do
|
142
|
+
ecore_loop 3
|
143
|
+
@e.visibility?.should == 1
|
144
|
+
@e.hide
|
145
|
+
ecore_loop 3
|
146
|
+
@e.visibility_get.should == 0
|
147
|
+
@e.show
|
148
|
+
ecore_loop 3
|
149
|
+
@e.visibility?.should == 1
|
150
|
+
end
|
151
|
+
#
|
152
|
+
it "raise lower activate should work" do
|
153
|
+
@e.raise
|
154
|
+
@e.lower
|
155
|
+
@e.activate
|
156
|
+
end
|
157
|
+
#
|
158
|
+
it "title set/get should work" do
|
159
|
+
@e.title_set "title"
|
160
|
+
@e.title_get.should == "title"
|
161
|
+
@e.title = "other"
|
162
|
+
@e.title_get.should == "other"
|
163
|
+
end
|
164
|
+
#
|
165
|
+
#
|
166
|
+
it "name_class set/get should work" do
|
167
|
+
@e.name_class_set "name", "class"
|
168
|
+
@e.name_class_get.should == ['name','class']
|
169
|
+
@e.name_class = "name1", "class1"
|
170
|
+
@e.name_class_get.should == ['name1','class1']
|
171
|
+
end
|
172
|
+
#
|
173
|
+
it "size_min set/get should work" do
|
174
|
+
@e.size_min_set 20, 30
|
175
|
+
@e.size_min_get.should == [20, 30]
|
176
|
+
end
|
177
|
+
#
|
178
|
+
it "size_max set/get should work" do
|
179
|
+
@e.size_max_set 20, 30
|
180
|
+
@e.size_max_get.should == [20, 30]
|
181
|
+
end
|
182
|
+
#
|
183
|
+
it "size_base set/get should work" do
|
184
|
+
@e.size_base_set 20, 30
|
185
|
+
@e.size_base_get.should == [20, 30]
|
186
|
+
end
|
187
|
+
#
|
188
|
+
it "size_step set/get should work" do
|
189
|
+
@e.size_step_set 20, 30
|
190
|
+
@e.size_step_get.should == [20, 30]
|
191
|
+
end
|
192
|
+
#
|
193
|
+
it "layer set/get should work" do
|
194
|
+
@e.layer_set 2
|
195
|
+
@e.layer_get.should == 2
|
196
|
+
@e.layer = 1
|
197
|
+
@e.layer?.should == 1
|
198
|
+
end
|
199
|
+
#
|
200
|
+
it "focus set/get should work" do
|
201
|
+
@e.focus?.should be_false
|
202
|
+
@e.focus_set true
|
203
|
+
ecore_loop 3
|
204
|
+
@e.focus_get.should be_true
|
205
|
+
@e.focus?.should be_true
|
206
|
+
end
|
207
|
+
#
|
208
|
+
it "iconified set/get should work" do
|
209
|
+
@e.iconified_set true
|
210
|
+
@e.iconified_get.should be_true
|
211
|
+
@e.iconified = false
|
212
|
+
@e.iconified?.should be_false
|
213
|
+
end
|
214
|
+
#
|
215
|
+
it "borderless set/get should work" do
|
216
|
+
@e.borderless_set true
|
217
|
+
@e.borderless_get.should be_true
|
218
|
+
@e.borderless = false
|
219
|
+
@e.borderless?.should be_false
|
220
|
+
end
|
221
|
+
#
|
222
|
+
it "override set/get should work" do
|
223
|
+
@e.override_set true
|
224
|
+
@e.override_get.should be_true
|
225
|
+
@e.override = false
|
226
|
+
@e.override?.should be_false
|
227
|
+
end
|
228
|
+
#
|
229
|
+
# FIXME maximized
|
230
|
+
# ecore/src/lib/ecore_evas/ecore_evas.c => ecore_evas_maximized_set => IFC => return
|
231
|
+
# it "maximized set/get should work" do
|
232
|
+
# @e.maximized?.should be_false
|
233
|
+
# @e.maximized_set true
|
234
|
+
# ecore_loop 10
|
235
|
+
# @e.maximized_get.should be_true
|
236
|
+
# @e.maximized = false
|
237
|
+
# ecore_loop 3
|
238
|
+
# @e.maximized?.should be_false
|
239
|
+
# end
|
240
|
+
#
|
241
|
+
it "fullscreen set/get should work" do
|
242
|
+
@e.fullscreen_set true
|
243
|
+
ecore_loop 3
|
244
|
+
@e.fullscreen_get.should be_true
|
245
|
+
@e.fullscreen = false
|
246
|
+
ecore_loop 3
|
247
|
+
@e.fullscreen?.should be_false
|
248
|
+
end
|
249
|
+
#
|
250
|
+
it "avoid_damage set/get should work" do
|
251
|
+
@e.avoid_damage_set :ecore_evas_avoid_damage_expose
|
252
|
+
ecore_loop 3
|
253
|
+
@e.avoid_damage_get.should == :ecore_evas_avoid_damage_expose
|
254
|
+
@e.avoid_damage = :ecore_evas_avoid_damage_built_in
|
255
|
+
ecore_loop 3
|
256
|
+
@e.avoid_damage?.should == :ecore_evas_avoid_damage_built_in
|
257
|
+
end
|
258
|
+
#
|
259
|
+
it "withdrawn set/get should work" do
|
260
|
+
@e.withdrawn_set true
|
261
|
+
@e.withdrawn_get.should be_true
|
262
|
+
@e.withdrawn = false
|
263
|
+
@e.withdrawn?.should be_false
|
264
|
+
end
|
265
|
+
#
|
266
|
+
it "sticky set/get should work" do
|
267
|
+
@e.sticky_set true
|
268
|
+
ecore_loop 3
|
269
|
+
@e.sticky_get.should be_true
|
270
|
+
@e.sticky = false
|
271
|
+
ecore_loop 3
|
272
|
+
@e.sticky?.should be_false
|
273
|
+
end
|
274
|
+
#
|
275
|
+
it "ignore_events set/get should work" do
|
276
|
+
@e.ignore_events_set true
|
277
|
+
@e.ignore_events_get.should be_true
|
278
|
+
@e.ignore_events = false
|
279
|
+
@e.ignore_events?.should be_false
|
280
|
+
end
|
281
|
+
#
|
282
|
+
it "manual_render set/get should work" do
|
283
|
+
@e.manual_render_set true
|
284
|
+
@e.manual_render_get.should be_true
|
285
|
+
@e.manual_render = false
|
286
|
+
@e.manual_render?.should be_false
|
287
|
+
end
|
288
|
+
#
|
289
|
+
it "comp_sync set/get should work" do
|
290
|
+
@e.comp_sync_set true
|
291
|
+
@e.comp_sync_get.should be_true
|
292
|
+
@e.comp_sync = false
|
293
|
+
@e.comp_sync?.should be_false
|
294
|
+
end
|
295
|
+
#
|
296
|
+
it "ecore_evas_callback_resize should work" do
|
297
|
+
cpt = 0
|
298
|
+
cb = Proc.new do |ecore_evas|
|
299
|
+
cpt+=1
|
300
|
+
end
|
301
|
+
@e.callback_resize_set cb
|
302
|
+
@e.resize 60,90
|
303
|
+
ecore_loop 3
|
304
|
+
cpt.should >0
|
305
|
+
end
|
306
|
+
#
|
307
|
+
it "ecore_evas_callback_move should work" do
|
308
|
+
cpt = 0
|
309
|
+
cb = Proc.new do |ecore_evas|
|
310
|
+
cpt+=1
|
311
|
+
end
|
312
|
+
@e.callback_move_set cb
|
313
|
+
@e.move 60,90
|
314
|
+
ecore_loop 3
|
315
|
+
cpt.should >0
|
316
|
+
end
|
317
|
+
#
|
318
|
+
it "ecore_evas_callback_show should work" do
|
319
|
+
cpt = 0
|
320
|
+
cb = Proc.new do |ecore_evas|
|
321
|
+
cpt+=1
|
322
|
+
end
|
323
|
+
@e.callback_show_set cb
|
324
|
+
@e.show
|
325
|
+
ecore_loop 3
|
326
|
+
cpt.should >0
|
327
|
+
end
|
328
|
+
#
|
329
|
+
it "ecore_evas_callback_hide should work" do
|
330
|
+
cpt = 0
|
331
|
+
cb = Proc.new do |ecore_evas|
|
332
|
+
cpt+=1
|
333
|
+
end
|
334
|
+
@e.show
|
335
|
+
ecore_loop 3
|
336
|
+
@e.callback_hide_set cb
|
337
|
+
@e.hide
|
338
|
+
ecore_loop 3
|
339
|
+
cpt.should >0
|
340
|
+
end
|
341
|
+
#
|
342
|
+
end
|
24
343
|
end
|
data/spec/ecore_getopt_spec.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
# -*- coding: UTF-8 -*-
|
3
3
|
#
|
4
|
+
require 'efl/ecore'
|
5
|
+
require 'efl/ecore_evas'
|
4
6
|
require 'efl/ecore_getopt'
|
5
7
|
#
|
6
8
|
describe Efl::EcoreGetopt do
|
@@ -10,10 +12,10 @@ describe Efl::EcoreGetopt do
|
|
10
12
|
#
|
11
13
|
@p = Efl::EcoreGetopt::REcoreGetopt.new :prog =>"Prog", :usage => "Usage", :version => "0.0.0", :copyright => "less", :license => "MIT", :description => "description", :strict => 1
|
12
14
|
@callback = Proc.new do |parser, desc, string, data, value|
|
13
|
-
parser.address.should
|
14
|
-
string.should
|
15
|
-
data.read_string.should
|
16
|
-
value.read_pointer.read_int.should
|
15
|
+
parser.address.should == @p.to_ptr.address
|
16
|
+
string.should == "my_data"
|
17
|
+
data.read_string.should == "cb_data"
|
18
|
+
value.read_pointer.read_int.should == 99
|
17
19
|
true
|
18
20
|
end
|
19
21
|
#
|
@@ -22,6 +24,7 @@ describe Efl::EcoreGetopt do
|
|
22
24
|
:copyright => FFI::MemoryPointer.new(:uchar),
|
23
25
|
:version => FFI::MemoryPointer.new(:uchar),
|
24
26
|
:help => FFI::MemoryPointer.new(:uchar),
|
27
|
+
:engines => FFI::MemoryPointer.new(:uchar),
|
25
28
|
:int => FFI::MemoryPointer.new(:int),
|
26
29
|
:double => FFI::MemoryPointer.new(:double),
|
27
30
|
:short => FFI::MemoryPointer.new(:short),
|
@@ -45,6 +48,9 @@ describe Efl::EcoreGetopt do
|
|
45
48
|
@p.value :boolp, @values[:version]
|
46
49
|
@p.help 'H', 'help'
|
47
50
|
@p.value :boolp, @values[:help]
|
51
|
+
# FIXME debug callback : ecore_getopt_callback_ecore_evas_list_engines
|
52
|
+
@p.callback_noargs 'E', 'list-engines', 'list ecore-evas available engines', Efl::Native.method(:ecore_getopt_callback_ecore_evas_list_engines), FFI::Pointer::NULL
|
53
|
+
@p.value :boolp, @values[:engines]
|
48
54
|
@p.store_type :int, 'i', 'int', 'store an integer'
|
49
55
|
@p.value :intp, @values[:int]
|
50
56
|
@p.store_meta_type :double, 'd', 'double', 'store an double+meta', @meta1
|
@@ -65,14 +71,14 @@ describe Efl::EcoreGetopt do
|
|
65
71
|
# @p.append 'a', 'append', 'store append', :ecore_getopt_type_int
|
66
72
|
@p.count 'k', 'count', 'store count'
|
67
73
|
@p.value :intp, @values[:count]
|
68
|
-
@p.callback_args 'b', 'callback', 'callback full', @
|
74
|
+
@p.callback_args 'b', 'callback', 'callback full', @meta1, @callback, @cb_data
|
69
75
|
@p.value :intp, @values[:callback]
|
70
76
|
@p.create
|
71
77
|
# puts @p.debug
|
72
78
|
#
|
73
79
|
end
|
74
80
|
before(:each) do
|
75
|
-
[ :license, :copyright, :version, :help ].each do |sym|
|
81
|
+
[ :license, :copyright, :version, :help, :engines ].each do |sym|
|
76
82
|
@values[sym].write_char 0
|
77
83
|
end
|
78
84
|
@values[:int].write_int 0
|
@@ -92,131 +98,91 @@ describe Efl::EcoreGetopt do
|
|
92
98
|
#
|
93
99
|
describe "license copyright version help" do
|
94
100
|
it "should handle -L" do
|
95
|
-
[ :license, :copyright, :version, :help ].each do |sym|
|
96
|
-
@values[sym].read_char.should eql 0
|
97
|
-
end
|
98
101
|
args = @p.parse ["My lovely prog name","-L"]
|
99
|
-
@values[:license].read_char.should
|
100
|
-
[ :copyright, :version, :help ].each do |sym|
|
101
|
-
@values[sym].read_char.should eql 0
|
102
|
-
end
|
102
|
+
@values[:license].read_char.should == 1
|
103
103
|
end
|
104
104
|
it "should handle --license" do
|
105
|
-
[ :license, :copyright, :version, :help ].each do |sym|
|
106
|
-
@values[sym].read_char.should eql 0
|
107
|
-
end
|
108
105
|
args = @p.parse ["My lovely prog name","--license"]
|
109
|
-
@values[:license].read_char.should
|
110
|
-
[ :copyright, :version, :help ].each do |sym|
|
111
|
-
@values[sym].read_char.should eql 0
|
112
|
-
end
|
106
|
+
@values[:license].read_char.should == 1
|
113
107
|
end
|
114
108
|
it "should handle -C" do
|
115
|
-
[ :license, :copyright, :version, :help ].each do |sym|
|
116
|
-
@values[sym].read_char.should eql 0
|
117
|
-
end
|
118
109
|
args = @p.parse ["progname","-C"]
|
119
|
-
@values[:copyright].read_char.should
|
120
|
-
[ :license, :version, :help ].each do |sym|
|
121
|
-
@values[sym].read_char.should eql 0
|
122
|
-
end
|
110
|
+
@values[:copyright].read_char.should == 1
|
123
111
|
end
|
124
112
|
it "should handle --copyright" do
|
125
|
-
[ :license, :copyright, :version, :help ].each do |sym|
|
126
|
-
@values[sym].read_char.should eql 0
|
127
|
-
end
|
128
113
|
args = @p.parse ["My lovely prog name","--copyright"]
|
129
|
-
@values[:copyright].read_char.should
|
130
|
-
[ :license, :version, :help ].each do |sym|
|
131
|
-
@values[sym].read_char.should eql 0
|
132
|
-
end
|
114
|
+
@values[:copyright].read_char.should == 1
|
133
115
|
end
|
134
116
|
it "should handle -V" do
|
135
|
-
[ :license, :copyright, :version, :help ].each do |sym|
|
136
|
-
@values[sym].read_char.should eql 0
|
137
|
-
end
|
138
117
|
args = @p.parse ["My lovely prog name","-V"]
|
139
|
-
@values[:version].read_char.should
|
140
|
-
[ :license, :copyright, :help ].each do |sym|
|
141
|
-
@values[sym].read_char.should eql 0
|
142
|
-
end
|
118
|
+
@values[:version].read_char.should == 1
|
143
119
|
end
|
144
120
|
it "should handle --version" do
|
145
|
-
[ :license, :copyright, :version, :help ].each do |sym|
|
146
|
-
@values[sym].read_char.should eql 0
|
147
|
-
end
|
148
121
|
args = @p.parse ["progname","--version"]
|
149
|
-
@values[:version].read_char.should
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
[
|
166
|
-
@values[sym].read_char.should eql 0
|
167
|
-
end
|
168
|
-
args = @p.parse ["progname","--help"]
|
169
|
-
@values[:help].read_char.should eql 1
|
170
|
-
[ :license, :copyright, :version ].each do |sym|
|
171
|
-
@values[sym].read_char.should eql 0
|
172
|
-
end
|
122
|
+
@values[:version].read_char.should == 1
|
123
|
+
end
|
124
|
+
# it "should handle -H" do
|
125
|
+
# args = @p.parse ["My lovely prog name","-H"]
|
126
|
+
# @values[:help].read_char.should == 1
|
127
|
+
# end
|
128
|
+
# it "should handle --help" do
|
129
|
+
# args = @p.parse ["progname","--help"]
|
130
|
+
# @values[:help].read_char.should == 1
|
131
|
+
# end
|
132
|
+
it "should handle -E" do
|
133
|
+
args = @p.parse ["My lovely prog name","-E"]
|
134
|
+
@values[:engines].read_char.should == 1
|
135
|
+
end
|
136
|
+
it "should handle --list-engines" do
|
137
|
+
args = @p.parse ["My lovely prog name","--list-engines"]
|
138
|
+
@values[:engines].read_char.should == 1
|
173
139
|
end
|
174
140
|
end
|
175
141
|
describe "simple short options" do
|
176
142
|
it "should handle -i" do
|
177
|
-
@values[:int].read_int.should
|
143
|
+
@values[:int].read_int.should == 0
|
178
144
|
args = @p.parse ["progname","-i 666"]
|
179
|
-
@values[:int].read_int.should
|
145
|
+
@values[:int].read_int.should == 666
|
180
146
|
end
|
181
147
|
it "should handle -d" do
|
182
|
-
@values[:double].read_double.should
|
148
|
+
@values[:double].read_double.should == 3.1415926
|
183
149
|
args = @p.parse ["progname","-d 6.66"]
|
184
|
-
@values[:double].read_double.should
|
150
|
+
@values[:double].read_double.should == 6.66
|
185
151
|
end
|
186
152
|
it "should handle -s" do
|
187
|
-
@values[:short].read_short.should
|
153
|
+
@values[:short].read_short.should == 9
|
188
154
|
args = @p.parse ["progname","-s 125"]
|
189
|
-
@values[:short].read_short.should
|
155
|
+
@values[:short].read_short.should == 125
|
190
156
|
end
|
191
157
|
it "should handle -l" do
|
192
|
-
@values[:long].read_long.should
|
158
|
+
@values[:long].read_long.should == 666
|
193
159
|
args = @p.parse ["progname","-l 69"]
|
194
|
-
@values[:long].read_long.should
|
160
|
+
@values[:long].read_long.should == 69
|
195
161
|
end
|
196
162
|
it "should handle -c" do
|
197
|
-
@values[:const].read_int.should
|
163
|
+
@values[:const].read_int.should == -666
|
198
164
|
args = @p.parse ["progname","-c"]
|
199
|
-
@values[:const].read_int.should
|
165
|
+
@values[:const].read_int.should == 123456
|
200
166
|
end
|
201
167
|
it "should handle -t" do
|
202
|
-
@values[:false].read_uchar.should
|
168
|
+
@values[:false].read_uchar.should == 0
|
203
169
|
args = @p.parse ["progname","-t"]
|
204
|
-
@values[:false].read_uchar.should
|
170
|
+
@values[:false].read_uchar.should == 1
|
205
171
|
end
|
206
172
|
it "should handle -f" do
|
207
|
-
@values[:true].read_uchar.should
|
173
|
+
@values[:true].read_uchar.should == 1
|
208
174
|
args = @p.parse ["progname","-f"]
|
209
|
-
@values[:true].read_uchar.should
|
175
|
+
@values[:true].read_uchar.should == 0
|
210
176
|
end
|
211
177
|
it "should handle -m" do
|
212
|
-
@values[:choice].read_pointer.should
|
178
|
+
@values[:choice].read_pointer.should == FFI::Pointer::NULL
|
213
179
|
args = @p.parse ["progname","-mch2"]
|
214
|
-
@values[:choice].read_pointer.read_string.should
|
180
|
+
@values[:choice].read_pointer.read_string.should == "ch2"
|
215
181
|
end
|
216
182
|
it "should handle -k" do
|
217
|
-
@values[:count].read_int.should
|
183
|
+
@values[:count].read_int.should == 664
|
218
184
|
args = @p.parse ["progname","-kk"]
|
219
|
-
@values[:count].read_int.should
|
185
|
+
@values[:count].read_int.should == 666
|
220
186
|
end
|
221
187
|
it "should handle -b" do
|
222
188
|
args = @p.parse ["progname","-bmy_data"]
|
@@ -224,49 +190,49 @@ describe Efl::EcoreGetopt do
|
|
224
190
|
end
|
225
191
|
describe "simple long options" do
|
226
192
|
it "should handle --int" do
|
227
|
-
@values[:int].read_int.should
|
193
|
+
@values[:int].read_int.should == 0
|
228
194
|
args = @p.parse ["progname","--int=666"]
|
229
|
-
@values[:int].read_int.should
|
195
|
+
@values[:int].read_int.should == 666
|
230
196
|
end
|
231
197
|
it "should handle --double" do
|
232
|
-
@values[:double].read_double.should
|
198
|
+
@values[:double].read_double.should == 3.1415926
|
233
199
|
args = @p.parse ["progname","--double=6.66"]
|
234
|
-
@values[:double].read_double.should
|
200
|
+
@values[:double].read_double.should == 6.66
|
235
201
|
end
|
236
202
|
it "should handle --short" do
|
237
|
-
@values[:short].read_short.should
|
203
|
+
@values[:short].read_short.should == 9
|
238
204
|
args = @p.parse ["progname","--short=125"]
|
239
|
-
@values[:short].read_short.should
|
205
|
+
@values[:short].read_short.should == 125
|
240
206
|
end
|
241
207
|
it "should handle --long" do
|
242
|
-
@values[:long].read_long.should
|
208
|
+
@values[:long].read_long.should == 666
|
243
209
|
args = @p.parse ["progname","--long=69"]
|
244
|
-
@values[:long].read_long.should
|
210
|
+
@values[:long].read_long.should == 69
|
245
211
|
end
|
246
212
|
it "should handle --const" do
|
247
|
-
@values[:const].read_int.should
|
213
|
+
@values[:const].read_int.should == -666
|
248
214
|
args = @p.parse ["progname","--const"]
|
249
|
-
@values[:const].read_int.should
|
215
|
+
@values[:const].read_int.should == 123456
|
250
216
|
end
|
251
217
|
it "should handle --true" do
|
252
|
-
@values[:false].read_uchar.should
|
218
|
+
@values[:false].read_uchar.should == 0
|
253
219
|
args = @p.parse ["progname","--true"]
|
254
|
-
@values[:false].read_uchar.should
|
220
|
+
@values[:false].read_uchar.should == 1
|
255
221
|
end
|
256
222
|
it "should handle --false" do
|
257
|
-
@values[:true].read_uchar.should
|
223
|
+
@values[:true].read_uchar.should == 1
|
258
224
|
args = @p.parse ["progname","--false"]
|
259
|
-
@values[:true].read_uchar.should
|
225
|
+
@values[:true].read_uchar.should == 0
|
260
226
|
end
|
261
227
|
it "should handle --many" do
|
262
|
-
@values[:choice].read_pointer.should
|
228
|
+
@values[:choice].read_pointer.should == FFI::Pointer::NULL
|
263
229
|
args = @p.parse ["progname","--many=ch3"]
|
264
|
-
@values[:choice].read_pointer.read_string.should
|
230
|
+
@values[:choice].read_pointer.read_string.should == "ch3"
|
265
231
|
end
|
266
232
|
it "should handle --count" do
|
267
|
-
@values[:count].read_int.should
|
233
|
+
@values[:count].read_int.should == 664
|
268
234
|
args = @p.parse ["progname","--count","--count"]
|
269
|
-
@values[:count].read_int.should
|
235
|
+
@values[:count].read_int.should == 666
|
270
236
|
end
|
271
237
|
it "should handle --callback" do
|
272
238
|
args = @p.parse ["progname","--callback=my_data"]
|
data/spec/ecore_input_spec.rb
CHANGED
@@ -10,15 +10,15 @@ describe Efl::EcoreInput do
|
|
10
10
|
end
|
11
11
|
#
|
12
12
|
it "should init" do
|
13
|
-
EcoreInput.init.should
|
14
|
-
EcoreInput.init.should
|
15
|
-
EcoreInput.init.should
|
13
|
+
EcoreInput.init.should == 1
|
14
|
+
EcoreInput.init.should == 2
|
15
|
+
EcoreInput.init.should == 3
|
16
16
|
end
|
17
17
|
#
|
18
18
|
it "should shutdown" do
|
19
|
-
EcoreInput.shutdown.should
|
20
|
-
EcoreInput.shutdown.should
|
21
|
-
EcoreInput.shutdown.should
|
19
|
+
EcoreInput.shutdown.should == 2
|
20
|
+
EcoreInput.shutdown.should == 1
|
21
|
+
EcoreInput.shutdown.should == 0
|
22
22
|
end
|
23
23
|
#
|
24
24
|
end
|