1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
|
#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-
#
require 'efl/evas'
#
describe Efl::Evas do
#
before(:all) { Evas = Efl::Evas }
#
it "should init" do
Evas.init.should == 1
Evas.init.should == 2
Evas.init.should == 3
end
#
it "should shutdown" do
Evas.shutdown.should == 2
Evas.shutdown.should == 1
Evas.shutdown.should == 0
end
#
it "evas alloc error enum is ok" do
Efl::Evas.enum_value(:evas_alloc_error_none).should == 0
Efl::Evas.enum_value(:evas_alloc_error_fatal).should == 1
Efl::Evas.enum_value(:evas_alloc_error_recovered).should == 2
Efl::Evas.enum_type(:evas_alloc_error)[0].should == :evas_alloc_error_none
Efl::Evas.enum_type(:evas_alloc_error)[1].should == :evas_alloc_error_fatal
Efl::Evas.enum_type(:evas_alloc_error)[2].should == :evas_alloc_error_recovered
Efl::Evas.enum_type(:evas_alloc_error)[:evas_alloc_error_none].should == 0
Efl::Evas.enum_type(:evas_alloc_error)[:evas_alloc_error_fatal].should == 1
Efl::Evas.enum_type(:evas_alloc_error)[:evas_alloc_error_recovered].should == 2
end
#
it "should have no memory allocation error occured" do
Evas.init
Evas.alloc_error.should == :evas_alloc_error_none
Evas.shutdown
end
#
it "should process async events" do
cb = Proc.new do |target,type,evt|
target.read_string.should == "target"
type.should == :evas_callback_show
evt.read_string.should == "work"
end
Evas.init
target = FFI::MemoryPointer.from_string("target")
work = FFI::MemoryPointer.from_string("work")
Evas.async_events_put target, :evas_callback_show, work, cb
Evas.async_events_process.should == 1
Evas.async_events_process.should == 0
Evas.shutdown
end
#
describe Efl::Evas::REvas do
before(:all) do
Evas.init
@width = 800
@height = 600
@pixels = FFI::MemoryPointer.new :int, @width*@height
@e = Evas::REvas.new
@e.output_method_set Evas::render_method_lookup("buffer")
@e.output_viewport_set 0, 0, @width, @height
@e.output_size_set @width, @height
einfo = Efl::Evas::EngineInfoBufferStruct.new @e.engine_info_get
einfo[:info][:depth_type] = Efl::Evas::EVAS_ENGINE_BUFFER_DEPTH_ARGB32
einfo[:info][:dest_buffer] = @pixels
einfo[:info][:dest_buffer_row_bytes] = @width * FFI::type_size(:int);
einfo[:info][:use_color_key] = 0;
einfo[:info][:alpha_threshold] = 0;
einfo[:info][:func][:new_update_region] = nil #FFI::Pointer::NULL;
einfo[:info][:func][:free_update_region] = nil #FFI::Pointer::NULL;
@e.engine_info_set einfo
end
after(:all) do
@e.free
@pixels.free
Evas.shutdown
end
it "should be able to create and destroy evas" do
e1 = Evas::REvas.new
e1.address.should_not == 0
e2 = Evas::REvas.new e1.to_ptr
e1.address.should == e2.address
(e1==e2).should be_false
(e1===e2).should be_true
e1.free
e1.free
e1.to_ptr.should be_nil
e2.free
e2.free
e4 = Evas::REvas.new Evas.evas_new
e4.address.should_not == 0
e5 = e4.dup
e4.address.should == e5.address
e6 = e4.clone
e4.address.should == e6.address
e4.free
e4.to_ptr.should be_nil
end
#
it "focus should work" do
Efl::Evas.evas_focus_in @e.to_ptr
Efl::Evas.evas_focus_state_get(@e.to_ptr).should be_true
Efl::Evas.evas_focus_out @e.to_ptr
Efl::Evas.evas_focus_state_get(@e.to_ptr).should be_false
Efl::Evas.focus_in @e.to_ptr
Efl::Evas.focus_state_get(@e.to_ptr).should be_true
Efl::Evas.focus_out @e.to_ptr
Efl::Evas.focus_state_get(@e.to_ptr).should be_false
@e.focus_in { |r| r.should be_nil }
@e.focus_state_get.should be_true
@e.focus_state_get { |r| r.should be_true }
@e.focus_out.should be_nil
@e.focus_state_get.should be_false
@e.focus_state_get { |r| r.should be_false }
end
#
it "nochange should work" do
@e.nochange_push
@e.nochange_pop
end
#
it "attach data should work" do
data = FFI::MemoryPointer.from_string "my data"
@e.data_attach_set data
@e.data_attach_get.read_string.should == "my data"
end
#
it "should not crash" do
@e.damage_rectangle_add 1, 2, 3, 4
@e.obscured_rectangle_add 1, 2, 3, 4
@e.obscured_clear
list = @e.render_updates
Evas.render_updates_free list
@e.render
@e.norender
@e.render_idle_flush
@e.render_dump
end
it "output method should work" do
@e.output_method_get.should == Evas::render_method_lookup("buffer")
# output_method_set tested in before(:all)
l = Efl::Evas::render_method_list
Evas::render_method_list_free l
end
#
it "engine info should work" do
# engine_info_get and engine_info_set tested in before(:all)
true.should be_true
end
#
it "output size should work" do
@e.output_size_set 69, 666
@e.output_size_get.should == [69,666]
end
it "output viewport should work" do
@e.output_viewport_set 0, 0, 666, 69
@e.output_viewport_get.should == [0,0,666,69]
end
#
it "coordinates evas<=>world should work" do
@e.output_viewport_set 0, 0, 800, 600
x = @e.coord_screen_x_to_world 666
r = @e.coord_world_x_to_screen x
r.should <= 668
r.should >= 664
y = @e.coord_screen_y_to_world 69
r = @e.coord_world_y_to_screen y
r.should <= 71
r.should >= 67
end
#
it "freeze and thaw should work" do
@e.event_freeze_get.should == 0
@e.event_freeze
@e.event_freeze_get.should == 1
@e.event_thaw
@e.event_freeze_get.should == 0
end
#
it "up/down mouse event should work" do
@e.event_feed_mouse_down 2, :evas_button_double_click, Time.now.to_i, FFI::Pointer::NULL
@e.pointer_button_down_mask_get.should == 2
@e.event_feed_mouse_up 2, :evas_button_double_click, Time.now.to_i, FFI::Pointer::NULL
@e.pointer_button_down_mask_get.should == 0
end
#
it "move mouse event should work" do
@e.pointer_output_xy_get.should == [0,0]
@e.pointer_canvas_xy_get.should == [0,0]
@e.event_feed_mouse_move 6, 6, Time.now.to_i, FFI::Pointer::NULL
@e.pointer_output_xy_get.should == [6,6]
@e.pointer_canvas_xy_get.should == [6,6]
end
#
it "in/out mouse event should work" do
@e.pointer_inside_get.should be_false
@e.event_feed_mouse_in Time.now.to_i, FFI::Pointer::NULL
@e.pointer_inside_get.should be_true
@e.event_feed_mouse_out Time.now.to_i, FFI::Pointer::NULL
@e.pointer_inside_get.should be_false
end
#
# TODO
# evas_event_feed_multi_down
# evas_event_feed_multi_up
# evas_event_feed_multi_move
# evas_event_feed_mouse_cancel
# evas_event_feed_mouse_wheel
# evas_event_feed_key_down
# evas_event_feed_key_up
# evas_event_feed_hold
#
it "add/del event callback should work" do
@cb = false
kd_cb = Proc.new do |data, e, obj, event_info|
data.read_string.should eq "mouse_in"
e.address.should == @e.address
obj.address.should == @bg.address
@db=true
true
end
kd_d = FFI::MemoryPointer.from_string "mouse_in"
@bg = Evas::REvasObject.new @e.object_rectangle_add
@bg.move 0, 0
@bg.resize 20, 20
@bg.show
@bg.event_callback_add :evas_callback_mouse_in, kd_cb, kd_d
@e.event_feed_mouse_in Time.now.to_i, FFI::Pointer::NULL
@bg.event_callback_del(:evas_callback_mouse_in, kd_cb).address.should == kd_d.address
@db.should be_true
end
#
it "image cache functions should work" do
@e.image_cache_flush
@e.image_cache_reload
@e.image_cache_set 666
@e.image_cache_get.should == 666
end
#
it "font functions should work" do
@e.font_hinting_set :evas_font_hinting_bytecode
@e.font_hinting_get.should == :evas_font_hinting_bytecode
@e.font_hinting_can_hint(:evas_font_hinting_none).should be_true
@e.font_cache_flush
@e.font_cache_set 666
@e.font_cache_get.should == 666
l = @e.font_available_list
@e.font_available_list_free l
@e.font_path_clear
a = ['/tmp1','/tmp2']
@e.font_path_append a[1]
@e.font_path_prepend a[0]
require 'efl/eina_list'
Efl::EinaList::REinaList.new(@e.font_path_list).each_with_index do |p,i|
p.read_string.should == a[i]
end
end
end
describe Efl::Evas::REvasObject do
#
before(:all) do
Evas.init
@pixels = FFI::MemoryPointer.new :int, 100*100
@e = Evas::REvas.new
@e.output_method_set Evas::render_method_lookup("buffer")
@e.output_viewport_set 0, 0, 100, 100
@e.output_size_set 100, 100
einfo = Efl::Evas::EngineInfoBufferStruct.new @e.engine_info_get
einfo[:info][:depth_type] = Efl::Evas::EVAS_ENGINE_BUFFER_DEPTH_ARGB32
einfo[:info][:dest_buffer] = @pixels
einfo[:info][:dest_buffer_row_bytes] = 100 * FFI::type_size(:int);
einfo[:info][:use_color_key] = 0;
einfo[:info][:alpha_threshold] = 0;
einfo[:info][:func][:new_update_region] = nil #FFI::Pointer::NULL;
einfo[:info][:func][:free_update_region] = nil #FFI::Pointer::NULL;
@e.engine_info_set einfo
@o = @e.object_add :rectangle
@o.color = 200,200,200,200
@o.move 0, 0
@o.resize 100, 100
@o.show
end
after(:all) do
@e.free
@o.free
@pixels.free
Evas.shutdown
end
#
it "clipper should work" do
clipper = @e.object_add :rectangle
clipper.color = 255,255,255,255
clipper.move 25, 25
clipper.resize 50, 50
@o.clip = clipper.to_ptr
clipper.show
@o.clip_get.address.should == clipper.address
require 'efl/eina_list'
Efl::EinaList::REinaList.new(clipper.clipees_get).to_ary[0].address.should == @o.address
@o.clip_unset
@o.clip_get.address.should == 0
end
#
it "focus functions should work" do
@o.focus_get.should be_false
@o.focus_set true
@o.focus_get.should be_true
@o.focus = false
@o.focus_get.should be_false
end
#
it "layer functions should work" do
@o.layer_get.should == 0
@o.layer_set 2
@o.layer_get.should == 2
@o.layer = 0
@o.layer_get.should == 0
end
#
it "name functions should work" do
@o.name_set "My name"
@o.name_get.should == "My name"
end
#
it "geometry functions should work" do
# FIXME
# @o.geometry_get.should == [0,0,100,100]
# @o.resize 50,50
# @o.geometry_get.should == [0,0,50,50]
# @o.move 10, 10
# @o.geometry_get.should == [10,10,50,50]
end
#
it "show hide visible should work" do
@o.show
@o.visible?.should be_true
@o.hide
@o.visible_get.should be_false
@o.show
@o.visible?.should be_true
end
end
#
end
|