summaryrefslogtreecommitdiffstats
path: root/spec/ecore_evas_spec.rb
blob: 07243d9bb55e9be813b6236e5988c801b53a9368 (plain)
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
#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-
#
require 'efl/eina_list'
require 'efl/ecore'
require 'efl/ecore_evas'
require './spec/helper'
#
describe 'Efl::EcoreEvas' do
    #
    before(:all) do
        EcoreEvas = Efl::EcoreEvas
        EcoreEvas.init.should==1
    end
    after(:all) do
        EcoreEvas.shutdown.should==0
    end
    #
    it "should init" do
        EcoreEvas.init.should == 2
        EcoreEvas.init.should == 3
    end
    #
    it "should shutdown" do
        EcoreEvas.shutdown.should == 2
        EcoreEvas.shutdown.should == 1
    end
    #
    it "engines get/list/free" do
        EcoreEvas.engines_free EcoreEvas.engines_get
        l = EcoreEvas.engines_list
        r = l.inject("\t") do |s,e| s+=e.read_string+' ' end
        EcoreEvas.engines_free l
    end
    #
    it "ecore_evas_list" do
        el = EcoreEvas.ecore_evas_list
        el.to_ary.length.should == 0
        el.free
        r=[]
        0.upto(3) do
            r << EcoreEvas::REcoreEvas.new
        end
        el = EcoreEvas.ecore_evas_list
        el.to_ary.length.should == 4
        el.free
        r.each do |e| e.free end
    end
    #
    describe Efl::EcoreEvas::REcoreEvas do
        before(:all) do
            EcoreEvas.init.should == 2
        end
        before(:each) do
            @e = EcoreEvas::REcoreEvas.new :engine_name=>"software_x11", :x=>10, :y=>10, :w=>100, :h=>120
            @canvas = @e.evas
            @bg = @canvas.object_rectangle_add { |o|
                o.color = 100, 100, 255, 255
                o.size = @e.size
            }
            @bg.show
            @e.object_associate @bg, :ecore_evas_object_associate_base
            @e.move 10, 10
            @e.show
        end
        after(:each) do
            @e.free
        end
        after(:all) do
            EcoreEvas.shutdown.should == 1
        end
        #
        it "engine_name_get " do
            @e.engine_name_get.should == "software_x11"
        end
        #
        it "data get/set " do
            @e.data_set 'key', '666'
            @e.data_get('key').read_string.should == '666'
        end
        #
        it "move, resize move_resize and geometry_get  (and check association)" do
            @e.geometry_get.should == [10,10,100,120]
            @bg.geometry_get.should == [0,0,100,120]
            @e.move 50, 50
            ecore_loop 3
            g = @e.geometry_get
            g[0].should >=50
            g[0].should <=60
            g[1].should >=60
            g[1].should <=80
            g.delete_at 0
            g.delete_at 0
            g.should == [100,120]
            @bg.geometry_get.should == [0,0,100,120]
            @e.resize 200,150
            ecore_loop 3
            g = @e.geometry_get
            g.delete_at 0
            g.delete_at 0
            g.should == [200,150]
            @bg.geometry_get.should == [0,0,200,150]
            @e.move_resize 10, 0, 130, 100
            ecore_loop 3
            g = @e.geometry_get
            g[0].should >=10
            g[0].should <=20
            g[1].should >=20
            g[1].should <=30
            g.delete_at 0
            g.delete_at 0
            g.should == [130,100]
            @bg.geometry_get.should == [0,0,130,100]
            g = @e.geometry_get
        end
        #
        it "rotation " do
            @e.rotation_set 25
            @e.rotation_get.should == 25
            @e.rotation = 50
            @e.rotation_get.should == 50
            @e.rotation_with_resize_set 0
            @e.rotation_get.should == 0
        end
        #
        it "shaped get/set " do
            bool_check @e, 'shaped'
        end
        #
        it "alpha get/set " do
            bool_check @e, 'alpha'
        end
        #
        it "transparent get/set " do
            bool_check @e, 'transparent'
        end
        #
        it "show hide visibility " do
            ecore_loop 3
            @e.visibility?.should == 1
            @e.hide
            ecore_loop 3
            @e.visibility_get.should == 0
            @e.show
            ecore_loop 3
            @e.visibility?.should == 1
        end
        #
        it "raise lower activate " do
            @e.raise
            @e.lower
            @e.activate
        end
        #
        it "title set/get " do
            @e.title_set "title"
            @e.title_get.should == "title"
            @e.title = "other"
            @e.title_get.should == "other"
        end
        #
        #
        it "name_class set/get " do
            @e.name_class_set "name", "class"
            @e.name_class_get.should == ['name','class']
            @e.name_class = "name1", "class1"
            @e.name_class_get.should == ['name1','class1']
        end
        #
        it "size_min set/get " do
            @e.size_min_set 20, 30
            @e.size_min_get.should == [20, 30]
        end
        #
        it "size_max set/get " do
            @e.size_max_set 20, 30
            @e.size_max_get.should == [20, 30]
        end
        #
        it "size_base set/get " do
            @e.size_base_set 20, 30
            @e.size_base_get.should == [20, 30]
        end
        #
        it "size_step set/get " do
            @e.size_step_set 20, 30
            @e.size_step_get.should == [20, 30]
        end
        #
        it "layer set/get " do
            @e.layer_set 2
            @e.layer_get.should == 2
            @e.layer = 1
            @e.layer?.should == 1
        end
        #
        it "focus set/get " do
            @e.focus?.should be_false
            @e.focus_set true
            ecore_loop 3
            @e.focus_get.should be_true
            @e.focus?.should be_true
        end
        #
        it "iconified set/get " do
            bool_check @e, 'iconified'
        end
        #
        it "borderless set/get " do
            bool_check @e, 'borderless'
        end
        #
        it "override set/get " do
            bool_check @e, 'override'
        end
        #
        it "maximized set/get " do
            bool_check @e, 'maximized', 5
        end
        #
        it "fullscreen set/get " do
            bool_check @e, 'fullscreen', 5
        end
        #
        it "avoid_damage set/get " do
            @e.avoid_damage_set :ecore_evas_avoid_damage_expose
            ecore_loop 3
            @e.avoid_damage_get.should == :ecore_evas_avoid_damage_expose
            @e.avoid_damage = :ecore_evas_avoid_damage_built_in
            ecore_loop 3
            @e.avoid_damage?.should == :ecore_evas_avoid_damage_built_in
        end
        #
        it "withdrawn set/get " do
            bool_check @e, 'withdrawn'
        end
        #
        it "sticky set/get " do
            bool_check @e, 'sticky', 3
        end
        #
        it "ignore_events set/get " do
            bool_check @e, 'ignore_events'
        end
        #
        it "manual_render set/get " do
            @e.manual_render_set true
            @e.manual_render_get.should be_true
            @e.manual_render = false
            @e.manual_render?.should be_false
            @e.manual_render.should be_nil
        end
        #
        it "comp_sync set/get " do
            bool_check @e, 'comp_sync'
        end
        #
        it "ecore_evas_callback_resize " do
            cpt = 0
            cb = Proc.new do |ecore_evas|
                cpt+=1
            end
            @e.callback_resize_set cb
            @e.resize 60,90
            ecore_loop 3
            cpt.should >0
        end
        #
        it "ecore_evas_callback_move " do
            cpt = 0
            cb = Proc.new do |ecore_evas|
                cpt+=1
            end
            @e.callback_move_set cb
            @e.move 60,90
            ecore_loop 3
            cpt.should >0
        end
        #
        it "ecore_evas_callback_show " do
            cpt = 0
            cb = Proc.new do |ecore_evas|
                cpt+=1
            end
            @e.callback_show_set cb
            @e.show
            ecore_loop 3
            cpt.should >0
        end
        #
        it "ecore_evas_callback_hide " do
            cpt = 0
            cb = Proc.new do |ecore_evas|
                cpt+=1
            end
            @e.show
            ecore_loop 3
            @e.callback_hide_set cb
            @e.hide
            ecore_loop 3
            cpt.should >0
        end
        #
    end
end