gir_ffi 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +11 -0
- data/README.md +8 -6
- data/TODO.md +3 -0
- data/lib/ffi-glib.rb +2 -1
- data/lib/ffi-gobject.rb +2 -1
- data/lib/ffi-gobject/object.rb +19 -9
- data/lib/ffi-gobject/value.rb +15 -3
- data/lib/gir_ffi-base.rb +9 -4
- data/lib/gir_ffi-base/glib.rb +8 -0
- data/lib/gir_ffi-base/glib/boolean.rb +1 -0
- data/lib/gir_ffi-base/glib/strv.rb +1 -0
- data/lib/gir_ffi-base/gobject.rb +5 -1
- data/lib/gir_ffi/boxed_base.rb +12 -0
- data/lib/gir_ffi/builder.rb +10 -1
- data/lib/gir_ffi/builders/argument_builder.rb +8 -4
- data/lib/gir_ffi/builders/base_return_value_builder.rb +38 -0
- data/lib/gir_ffi/builders/callback_return_value_builder.rb +2 -30
- data/lib/gir_ffi/builders/initializer_return_value_builder.rb +2 -6
- data/lib/gir_ffi/builders/module_builder.rb +2 -3
- data/lib/gir_ffi/builders/property_argument_builder.rb +23 -0
- data/lib/gir_ffi/builders/property_builder.rb +65 -46
- data/lib/gir_ffi/builders/property_return_value_builder.rb +14 -0
- data/lib/gir_ffi/builders/return_value_builder.rb +9 -33
- data/lib/gir_ffi/callback_base.rb +5 -0
- data/lib/gir_ffi/core.rb +3 -3
- data/lib/gir_ffi/in_pointer.rb +1 -1
- data/lib/gir_ffi/info_ext/i_signal_info.rb +2 -3
- data/lib/gir_ffi/info_ext/i_type_info.rb +22 -14
- data/lib/gir_ffi/interface_base.rb +12 -0
- data/lib/gir_ffi/user_defined_type_info.rb +8 -0
- data/lib/gir_ffi/version.rb +1 -1
- data/test/gir_ffi/builders/function_builder_test.rb +19 -0
- data/test/gir_ffi/builders/object_builder_test.rb +5 -11
- data/test/gir_ffi/builders/property_builder_test.rb +37 -5
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +21 -0
- data/test/gir_ffi/builders/vfunc_builder_test.rb +20 -0
- data/test/gir_ffi/info_ext/i_type_info_test.rb +18 -0
- data/test/gir_ffi/user_defined_type_info_test.rb +25 -0
- data/test/gir_ffi_test_helper.rb +2 -6
- data/test/integration/generated_gimarshallingtests_test.rb +5 -5
- data/test/integration/generated_gio_test.rb +2 -3
- data/test/integration/generated_gst_test.rb +1 -0
- data/test/integration/generated_regress_test.rb +630 -189
- data/test/integration/generated_utility_test.rb +173 -0
- data/test/lib/Makefile.am +3 -5
- metadata +7 -2
@@ -162,5 +162,26 @@ describe GirFFI::Builders::SignalClosureBuilder do
|
|
162
162
|
builder.marshaller_definition.must_equal expected
|
163
163
|
end
|
164
164
|
end
|
165
|
+
|
166
|
+
describe 'for a signal with GList argument' do
|
167
|
+
let(:signal_info) do
|
168
|
+
get_signal_introspection_data 'Regress', 'AnnotationObject', 'list-signal'
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'returns a valid mapping method' do
|
172
|
+
skip unless signal_info
|
173
|
+
|
174
|
+
expected = <<-CODE.reset_indentation
|
175
|
+
def self.marshaller(closure, return_value, param_values, _invocation_hint, _marshal_data)
|
176
|
+
_instance, list = param_values.map(&:get_value_plain)
|
177
|
+
_v1 = _instance
|
178
|
+
_v2 = GLib::List.wrap(:utf8, list)
|
179
|
+
wrap(closure.to_ptr).invoke_block(_v1, _v2)
|
180
|
+
end
|
181
|
+
CODE
|
182
|
+
|
183
|
+
builder.marshaller_definition.must_equal expected
|
184
|
+
end
|
185
|
+
end
|
165
186
|
end
|
166
187
|
end
|
@@ -109,6 +109,26 @@ describe GirFFI::Builders::VFuncBuilder do
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
+
describe 'for a vfunc with a GObject::Value out argument allocated by them, the caller' do
|
113
|
+
let(:vfunc_info) do
|
114
|
+
get_vfunc_introspection_data('GIMarshallingTests', 'Object',
|
115
|
+
'vfunc_caller_allocated_out_parameter')
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'returns a valid mapping method including receiver' do
|
119
|
+
expected = <<-CODE.reset_indentation
|
120
|
+
def self.call_with_argument_mapping(_proc, _instance, a)
|
121
|
+
_v1 = GIMarshallingTests::Object.wrap(_instance)
|
122
|
+
_v2 = GirFFI::InOutPointer.new(GObject::Value, a)
|
123
|
+
_v3 = _proc.call(_v1)
|
124
|
+
_v2.set_value GObject::Value.from(_v3)
|
125
|
+
end
|
126
|
+
CODE
|
127
|
+
|
128
|
+
result.must_equal expected
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
112
132
|
describe 'for a vfunc with an error argument' do
|
113
133
|
let(:vfunc_info) do
|
114
134
|
get_vfunc_introspection_data('GIMarshallingTests', 'Object',
|
@@ -585,6 +585,15 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
585
585
|
end
|
586
586
|
end
|
587
587
|
|
588
|
+
describe 'for :void pointer' do
|
589
|
+
let(:tag) { :void }
|
590
|
+
let(:pointer?) { true }
|
591
|
+
|
592
|
+
it 'equals the none type' do
|
593
|
+
GObject.type_name(type_info.gtype).must_equal 'gpointer'
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
588
597
|
describe 'for :gboolean' do
|
589
598
|
let(:tag) { :gboolean }
|
590
599
|
let(:pointer?) { false }
|
@@ -639,6 +648,15 @@ describe GirFFI::InfoExt::ITypeInfo do
|
|
639
648
|
end
|
640
649
|
end
|
641
650
|
|
651
|
+
describe 'for pointer to :glist' do
|
652
|
+
let(:tag) { :glist }
|
653
|
+
let(:pointer?) { true }
|
654
|
+
|
655
|
+
it 'equals the pointer type' do
|
656
|
+
GObject.type_name(type_info.gtype).must_equal 'gpointer'
|
657
|
+
end
|
658
|
+
end
|
659
|
+
|
642
660
|
describe 'for arrays' do
|
643
661
|
let(:tag) { :array }
|
644
662
|
let(:pointer?) { true }
|
@@ -2,6 +2,8 @@
|
|
2
2
|
require 'gir_ffi_test_helper'
|
3
3
|
require 'gir_ffi/user_defined_type_info'
|
4
4
|
|
5
|
+
GirFFI.setup :GIMarshallingTests
|
6
|
+
|
5
7
|
describe GirFFI::UserDefinedTypeInfo do
|
6
8
|
describe '#described_class' do
|
7
9
|
let(:info) { GirFFI::UserDefinedTypeInfo.new :some_class }
|
@@ -86,4 +88,27 @@ describe GirFFI::UserDefinedTypeInfo do
|
|
86
88
|
info.find_method('foo').must_equal nil
|
87
89
|
end
|
88
90
|
end
|
91
|
+
|
92
|
+
describe '#find_signal' do
|
93
|
+
let(:klass) { Object.new }
|
94
|
+
let(:info) { GirFFI::UserDefinedTypeInfo.new klass }
|
95
|
+
|
96
|
+
it 'finds no signals' do
|
97
|
+
info.find_signal('foo').must_equal nil
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '#interfaces' do
|
102
|
+
let(:modul) { GIMarshallingTests::Interface }
|
103
|
+
let(:klass) { Class.new GIMarshallingTests::Object }
|
104
|
+
let(:info) { GirFFI::UserDefinedTypeInfo.new klass }
|
105
|
+
|
106
|
+
before do
|
107
|
+
klass.send :include, modul
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'returns the interface infos for the include modules' do
|
111
|
+
info.interfaces.must_equal [modul.gir_info]
|
112
|
+
end
|
113
|
+
end
|
89
114
|
end
|
data/test/gir_ffi_test_helper.rb
CHANGED
@@ -30,12 +30,8 @@ module GirFFITestExtensions
|
|
30
30
|
SAVED_MODULES.delete name
|
31
31
|
end
|
32
32
|
|
33
|
-
def ref_count(
|
34
|
-
GObject::Object::Struct.new(
|
35
|
-
end
|
36
|
-
|
37
|
-
def ref(object)
|
38
|
-
object.ref
|
33
|
+
def ref_count(ptr)
|
34
|
+
GObject::Object::Struct.new(ptr)[:ref_count]
|
39
35
|
end
|
40
36
|
|
41
37
|
def max_for_unsigned_type(type)
|
@@ -298,12 +298,12 @@ describe GIMarshallingTests do
|
|
298
298
|
|
299
299
|
it 'has a working function #full_inout' do
|
300
300
|
ob = GIMarshallingTests::Object.new 42
|
301
|
-
|
301
|
+
ob.ref_count.must_equal 1
|
302
302
|
|
303
303
|
res = GIMarshallingTests::Object.full_inout ob
|
304
304
|
|
305
|
-
|
306
|
-
|
305
|
+
ob.ref_count.must_be :>, 0
|
306
|
+
res.ref_count.must_equal 1
|
307
307
|
|
308
308
|
res.must_be_instance_of GIMarshallingTests::Object
|
309
309
|
res.int.must_equal 0
|
@@ -400,7 +400,7 @@ describe GIMarshallingTests do
|
|
400
400
|
end
|
401
401
|
result = derived_instance.
|
402
402
|
get_ref_info_for_vfunc_in_object_transfer_none GIMarshallingTests::Object.gtype
|
403
|
-
|
403
|
+
obj.ref_count.must_be :>, 0
|
404
404
|
result.must_equal [2, false]
|
405
405
|
obj.must_be_instance_of GIMarshallingTests::Object
|
406
406
|
end
|
@@ -415,7 +415,7 @@ describe GIMarshallingTests do
|
|
415
415
|
}
|
416
416
|
end
|
417
417
|
result = derived_instance.get_ref_info_for_vfunc_out_object_transfer_full
|
418
|
-
|
418
|
+
obj.ref_count.must_be :>, 0
|
419
419
|
# TODO: Check desired result
|
420
420
|
result.must_equal [2, false]
|
421
421
|
end
|
@@ -5,10 +5,9 @@ GirFFI.setup :Gio
|
|
5
5
|
|
6
6
|
# Tests generated methods and functions in the Gio namespace.
|
7
7
|
describe 'The generated Gio module' do
|
8
|
-
#
|
9
|
-
describe '#file_new_for_path, a method returning an interface,' do
|
8
|
+
describe 'File#new_for_path, a method returning an interface,' do
|
10
9
|
it 'returns an object of a more specific class' do
|
11
|
-
file = Gio.
|
10
|
+
file = Gio::File.new_for_path('/')
|
12
11
|
refute_instance_of Gio::File, file
|
13
12
|
assert_includes file.class.ancestors, Gio::File
|
14
13
|
end
|
@@ -25,6 +25,7 @@ describe 'the generated Gst module' do
|
|
25
25
|
let(:instance) { Gst::ElementFactory.make('autoaudiosink', 'audiosink') }
|
26
26
|
|
27
27
|
it 'correctly fetches the name' do
|
28
|
+
skip 'Audio sink was not created' unless instance
|
28
29
|
instance.get_name.must_equal 'audiosink'
|
29
30
|
instance.name.must_equal 'audiosink'
|
30
31
|
end
|
@@ -65,11 +65,11 @@ describe Regress do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'has a writable field a' do
|
68
|
-
skip '
|
68
|
+
skip 'Anonymous union fields are not exposed in the GIR data'
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'has a writable field padding' do
|
72
|
-
skip '
|
72
|
+
skip 'Anonymous union fields are not exposed in the GIR data'
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -113,153 +113,287 @@ describe Regress do
|
|
113
113
|
end
|
114
114
|
|
115
115
|
describe 'Regress::AnnotationObject' do
|
116
|
+
let(:instance) { Regress::AnnotationObject.new }
|
117
|
+
|
118
|
+
it 'has an attribute org.example.Test' do
|
119
|
+
info = get_introspection_data('Regress', 'AnnotationObject')
|
120
|
+
info.attribute('org.example.Test').must_equal 'cows'
|
121
|
+
end
|
122
|
+
|
116
123
|
it 'has a working method #allow_none' do
|
117
|
-
|
124
|
+
instance.allow_none('hello!').must_be_nil
|
125
|
+
instance.allow_none(nil).must_be_nil
|
126
|
+
instance.allow_none.must_be_nil
|
118
127
|
end
|
128
|
+
|
119
129
|
it 'has a working method #calleeowns' do
|
120
|
-
|
130
|
+
result, object = instance.calleeowns
|
131
|
+
result.must_equal 1
|
132
|
+
object.must_be_nil
|
121
133
|
end
|
134
|
+
|
122
135
|
it 'has a working method #calleesowns' do
|
123
|
-
|
136
|
+
result, toown1, toown2 = instance.calleesowns
|
137
|
+
result.must_equal 1
|
138
|
+
toown1.must_be_nil
|
139
|
+
toown2.must_be_nil
|
124
140
|
end
|
141
|
+
|
125
142
|
it 'has a working method #compute_sum' do
|
126
|
-
|
143
|
+
instance.compute_sum [1, 2, 3]
|
144
|
+
pass
|
127
145
|
end
|
146
|
+
|
128
147
|
it 'has a working method #compute_sum_n' do
|
129
|
-
|
148
|
+
instance.compute_sum_n [1, 2, 3]
|
149
|
+
pass
|
130
150
|
end
|
151
|
+
|
131
152
|
it 'has a working method #compute_sum_nz' do
|
132
|
-
|
153
|
+
instance.compute_sum_nz [1, 2, 3]
|
154
|
+
pass
|
133
155
|
end
|
156
|
+
|
134
157
|
it 'has a working method #create_object' do
|
135
|
-
|
158
|
+
result = instance.create_object
|
159
|
+
result.must_equal instance
|
136
160
|
end
|
161
|
+
|
137
162
|
it 'has a working method #do_not_use' do
|
138
|
-
|
163
|
+
# TODO: Handle deprecation
|
164
|
+
instance.do_not_use.must_be_nil
|
139
165
|
end
|
166
|
+
|
140
167
|
it 'has a working method #extra_annos' do
|
141
|
-
|
168
|
+
info = get_method_introspection_data('Regress', 'AnnotationObject', 'extra_annos')
|
169
|
+
info.attribute('org.foobar').must_equal 'testvalue'
|
170
|
+
|
171
|
+
instance.extra_annos.must_be_nil
|
142
172
|
end
|
173
|
+
|
143
174
|
it 'has a working method #foreach' do
|
144
|
-
|
175
|
+
a = 1
|
176
|
+
instance.foreach { a += 1 }
|
177
|
+
a.must_equal 1
|
145
178
|
end
|
179
|
+
|
146
180
|
it 'has a working method #get_hash' do
|
147
|
-
|
181
|
+
result = instance.get_hash
|
182
|
+
hash = result.to_hash
|
183
|
+
hash['one'].must_equal instance
|
184
|
+
hash['two'].must_equal instance
|
148
185
|
end
|
186
|
+
|
149
187
|
it 'has a working method #get_objects' do
|
150
|
-
|
188
|
+
list = instance.get_objects
|
189
|
+
list.to_a.must_equal [instance]
|
151
190
|
end
|
191
|
+
|
152
192
|
it 'has a working method #get_strings' do
|
153
|
-
|
193
|
+
list = instance.get_strings
|
194
|
+
list.to_a.must_equal %w(bar regress_annotation)
|
154
195
|
end
|
196
|
+
|
155
197
|
it 'has a working method #hidden_self' do
|
156
|
-
|
198
|
+
instance.hidden_self.must_be_nil
|
157
199
|
end
|
200
|
+
|
158
201
|
it 'has a working method #in' do
|
159
|
-
|
202
|
+
# TODO: Automatically convert to pointer argument
|
203
|
+
ptr = FFI::MemoryPointer.new(:int, 1)
|
204
|
+
ptr.put_int 0, 2342
|
205
|
+
instance.in(ptr).must_equal 2342
|
160
206
|
end
|
207
|
+
|
161
208
|
it 'has a working method #inout' do
|
162
|
-
|
209
|
+
instance.inout(2342).must_equal [2343, 2343]
|
163
210
|
end
|
211
|
+
|
164
212
|
it 'has a working method #inout2' do
|
165
|
-
|
213
|
+
instance.inout2(2342).must_equal [2343, 2343]
|
166
214
|
end
|
215
|
+
|
167
216
|
it 'has a working method #inout3' do
|
168
|
-
|
217
|
+
instance.inout3(2342).must_equal [2343, 2342]
|
169
218
|
end
|
219
|
+
|
170
220
|
it 'has a working method #method' do
|
171
|
-
|
221
|
+
instance.method.must_equal 1
|
172
222
|
end
|
223
|
+
|
173
224
|
it 'has a working method #notrans' do
|
174
|
-
|
225
|
+
instance.notrans.must_be_nil
|
175
226
|
end
|
227
|
+
|
176
228
|
it 'has a working method #out' do
|
177
|
-
|
229
|
+
instance.out.must_equal [1, 2]
|
178
230
|
end
|
231
|
+
|
179
232
|
it 'has a working method #parse_args' do
|
180
|
-
|
233
|
+
instance.parse_args(%w(one two)).to_a.must_equal %w(one two)
|
181
234
|
end
|
235
|
+
|
182
236
|
it 'has a working method #set_data' do
|
183
|
-
|
237
|
+
# TODO: Explicitely allow or deny passing a string here.
|
238
|
+
instance.set_data([1, 2, 3]).must_be_nil
|
184
239
|
end
|
240
|
+
|
185
241
|
it 'has a working method #set_data2' do
|
186
|
-
|
242
|
+
instance.set_data2([1, -2, 3]).must_be_nil
|
187
243
|
end
|
244
|
+
|
188
245
|
it 'has a working method #set_data3' do
|
189
|
-
|
246
|
+
instance.set_data3([1, 2, 3]).must_be_nil
|
190
247
|
end
|
248
|
+
|
191
249
|
it 'has a working method #string_out' do
|
192
|
-
|
250
|
+
instance.string_out.must_equal [false, nil]
|
193
251
|
end
|
252
|
+
|
194
253
|
it 'has a working method #use_buffer' do
|
195
|
-
skip '
|
254
|
+
skip 'Ingoing pointer argument conversion is not implemented yet'
|
255
|
+
instance.use_buffer(FFI::MemoryPointer.new(:void, 1)).must_be_nil
|
196
256
|
end
|
257
|
+
|
197
258
|
it 'has a working method #watch_full' do
|
198
|
-
|
259
|
+
instance.watch {}
|
199
260
|
end
|
261
|
+
|
200
262
|
it 'has a working method #with_voidp' do
|
201
|
-
|
263
|
+
# NOTE: Anything implementing #to_ptr could be passed in here
|
264
|
+
obj = Regress::AnnotationObject.new
|
265
|
+
instance.with_voidp(obj).must_be_nil
|
202
266
|
end
|
267
|
+
|
203
268
|
describe "its 'function-property' property" do
|
204
|
-
it 'can be retrieved with #
|
205
|
-
|
269
|
+
it 'can be retrieved with #get_property_extended' do
|
270
|
+
instance.get_property_extended('function-property').must_be_nil
|
206
271
|
end
|
272
|
+
|
207
273
|
it 'can be retrieved with #function_property' do
|
208
|
-
|
274
|
+
instance.function_property.must_be_nil
|
209
275
|
end
|
210
|
-
|
211
|
-
|
276
|
+
|
277
|
+
it 'can be set with #set_property_extended' do
|
278
|
+
instance.set_property_extended('function-property', proc {})
|
279
|
+
# AnnotationObject doesn't actually store stuff
|
280
|
+
instance.function_property.must_be_nil
|
212
281
|
end
|
282
|
+
|
213
283
|
it 'can be set with #function_property=' do
|
214
|
-
|
284
|
+
instance.function_property = proc {}
|
285
|
+
# AnnotationObject doesn't actually store stuff
|
286
|
+
instance.get_property_extended('function-property').must_be_nil
|
215
287
|
end
|
216
288
|
end
|
289
|
+
|
217
290
|
describe "its 'string-property' property" do
|
218
291
|
it 'can be retrieved with #get_property' do
|
219
|
-
|
292
|
+
instance.get_property('string-property').must_be_nil
|
220
293
|
end
|
294
|
+
|
221
295
|
it 'can be retrieved with #string_property' do
|
222
|
-
|
296
|
+
instance.string_property.must_be_nil
|
223
297
|
end
|
298
|
+
|
224
299
|
it 'can be set with #set_property' do
|
225
|
-
|
300
|
+
instance.set_property('string-property', 'hello 42')
|
301
|
+
# AnnotationObject doesn't actually store stuff
|
302
|
+
instance.string_property.must_be_nil
|
226
303
|
end
|
304
|
+
|
227
305
|
it 'can be set with #string_property=' do
|
228
|
-
|
306
|
+
instance.string_property = 'hello 42'
|
307
|
+
# AnnotationObject doesn't actually store stuff
|
308
|
+
instance.get_property('string-property').must_be_nil
|
229
309
|
end
|
230
310
|
end
|
311
|
+
|
231
312
|
describe "its 'tab-property' property" do
|
232
313
|
it 'can be retrieved with #get_property' do
|
233
|
-
|
314
|
+
instance.get_property('tab-property').must_be_nil
|
234
315
|
end
|
316
|
+
|
235
317
|
it 'can be retrieved with #tab_property' do
|
236
|
-
|
318
|
+
instance.tab_property.must_be_nil
|
237
319
|
end
|
320
|
+
|
238
321
|
it 'can be set with #set_property' do
|
239
|
-
|
322
|
+
instance.set_property('tab-property', 'hello 42')
|
323
|
+
# AnnotationObject doesn't actually store stuff
|
324
|
+
instance.tab_property.must_be_nil
|
240
325
|
end
|
326
|
+
|
241
327
|
it 'can be set with #tab_property=' do
|
242
|
-
|
328
|
+
instance.tab_property = 'hello 42'
|
329
|
+
# AnnotationObject doesn't actually store stuff
|
330
|
+
instance.get_property('tab-property').must_be_nil
|
243
331
|
end
|
244
332
|
end
|
333
|
+
|
245
334
|
it "handles the 'attribute-signal' signal" do
|
246
|
-
|
335
|
+
signal_info = get_signal_introspection_data('Regress',
|
336
|
+
'AnnotationObject',
|
337
|
+
'attribute-signal')
|
338
|
+
argument_infos = signal_info.args
|
339
|
+
argument_infos.first.attribute('some.annotation.foo1').must_equal 'val1'
|
340
|
+
argument_infos.last.attribute('some.annotation.foo2').must_equal 'val2'
|
341
|
+
|
342
|
+
result = nil
|
343
|
+
instance.signal_connect 'attribute-signal' do |_obj, _arg1, _arg2, _user_data|
|
344
|
+
# This signal uses a null marshaller, so the return value is never passed on.
|
345
|
+
result = 'hello'
|
346
|
+
end
|
347
|
+
|
348
|
+
GObject.signal_emit instance, 'attribute-signal', 'foo', 'bar'
|
349
|
+
result.must_equal 'hello'
|
247
350
|
end
|
351
|
+
|
248
352
|
it "handles the 'doc-empty-arg-parsing' signal" do
|
249
|
-
|
353
|
+
test = nil
|
354
|
+
instance.signal_connect 'doc-empty-arg-parsing' do |_obj, arg1, _user_data|
|
355
|
+
test = arg1
|
356
|
+
end
|
357
|
+
|
358
|
+
result = GObject.signal_emit instance, 'doc-empty-arg-parsing', FFI::Pointer.new(123)
|
359
|
+
result.must_be_nil
|
360
|
+
test.address.must_equal 123
|
250
361
|
end
|
362
|
+
|
251
363
|
it "handles the 'list-signal' signal" do
|
252
|
-
|
364
|
+
result = nil
|
365
|
+
instance.signal_connect 'list-signal' do |_obj, list, _user_data|
|
366
|
+
result = list
|
367
|
+
end
|
368
|
+
|
369
|
+
# TODO: Automatically convert to GLib::List
|
370
|
+
GObject.signal_emit instance, 'list-signal', GLib::List.from(:utf8, %w(foo bar))
|
371
|
+
result.to_a.must_equal %w(foo bar)
|
253
372
|
end
|
373
|
+
|
254
374
|
it "handles the 'string-signal' signal" do
|
255
|
-
|
375
|
+
result = nil
|
376
|
+
instance.signal_connect 'string-signal' do |_obj, string, _user_data|
|
377
|
+
result = string
|
378
|
+
end
|
379
|
+
|
380
|
+
GObject.signal_emit instance, 'string-signal', 'foo'
|
381
|
+
result.must_equal 'foo'
|
256
382
|
end
|
257
383
|
end
|
384
|
+
|
258
385
|
describe 'Regress::AnnotationStruct' do
|
386
|
+
let(:instance) { Regress::AnnotationStruct.new }
|
387
|
+
|
259
388
|
it 'has a writable field objects' do
|
260
|
-
|
389
|
+
instance.objects.to_a.must_equal [nil] * 10
|
390
|
+
|
391
|
+
obj = Regress::AnnotationObject.new
|
392
|
+
instance.objects = [nil] * 5 + [obj] + [nil] * 4
|
393
|
+
instance.objects.to_a[5].must_equal obj
|
261
394
|
end
|
262
395
|
end
|
396
|
+
|
263
397
|
it 'has the constant BOOL_CONSTANT' do
|
264
398
|
skip unless get_introspection_data 'Regress', 'BOOL_CONSTANT'
|
265
399
|
Regress::BOOL_CONSTANT.must_equal true
|
@@ -270,355 +404,615 @@ describe Regress do
|
|
270
404
|
end
|
271
405
|
|
272
406
|
it 'has the constant FOO_DEFINE_SHOULD_BE_EXPOSED' do
|
273
|
-
|
407
|
+
Regress::FOO_DEFINE_SHOULD_BE_EXPOSED.must_equal 'should be exposed'
|
274
408
|
end
|
409
|
+
|
275
410
|
it 'has the constant FOO_PIE_IS_TASTY' do
|
276
|
-
|
411
|
+
Regress::FOO_PIE_IS_TASTY.must_equal 3.141590
|
277
412
|
end
|
413
|
+
|
278
414
|
it 'has the constant FOO_SUCCESS_INT' do
|
279
|
-
|
415
|
+
Regress::FOO_SUCCESS_INT.must_equal 4408
|
280
416
|
end
|
417
|
+
|
281
418
|
describe 'Regress::FooASingle' do
|
282
419
|
it 'has the member :foo_some_single_enum' do
|
283
|
-
|
420
|
+
Regress::FooASingle[:foo_some_single_enum].must_equal 0
|
284
421
|
end
|
285
422
|
end
|
423
|
+
|
286
424
|
describe 'Regress::FooAddressType' do
|
287
425
|
it 'has the member :invalid' do
|
288
|
-
|
426
|
+
Regress::FooAddressType[:invalid].must_equal 0
|
289
427
|
end
|
428
|
+
|
290
429
|
it 'has the member :ipv4' do
|
291
|
-
|
430
|
+
Regress::FooAddressType[:ipv4].must_equal 1
|
292
431
|
end
|
432
|
+
|
293
433
|
it 'has the member :ipv6' do
|
294
|
-
|
434
|
+
Regress::FooAddressType[:ipv6].must_equal 2
|
295
435
|
end
|
296
436
|
end
|
437
|
+
|
297
438
|
describe 'Regress::FooBRect' do
|
439
|
+
let(:instance) { Regress::FooBRect.wrap(Regress::FooBRect::Struct.new.to_ptr) }
|
440
|
+
|
298
441
|
it 'has a writable field x' do
|
299
|
-
|
442
|
+
instance.x.must_equal 0.0
|
443
|
+
instance.x = 23.42
|
444
|
+
instance.x.must_equal 23.42
|
300
445
|
end
|
446
|
+
|
301
447
|
it 'has a writable field y' do
|
302
|
-
|
448
|
+
instance.y.must_equal 0.0
|
449
|
+
instance.y = 23.42
|
450
|
+
instance.y.must_equal 23.42
|
303
451
|
end
|
452
|
+
|
304
453
|
it 'creates an instance using #new' do
|
305
|
-
skip '
|
454
|
+
skip 'This function is defined in the header but not implemented'
|
306
455
|
end
|
456
|
+
|
307
457
|
it 'has a working method #add' do
|
308
|
-
skip '
|
458
|
+
skip 'This function is defined in the header but not implemented'
|
309
459
|
end
|
310
460
|
end
|
461
|
+
|
311
462
|
describe 'Regress::FooBUnion' do
|
463
|
+
let(:instance) { Regress::FooBUnion.wrap(Regress::FooBUnion::Struct.new.to_ptr) }
|
464
|
+
|
312
465
|
it 'has a writable field type' do
|
313
|
-
|
466
|
+
instance.type.must_equal 0
|
467
|
+
instance.type = 42
|
468
|
+
instance.type.must_equal 42
|
314
469
|
end
|
470
|
+
|
315
471
|
it 'has a writable field v' do
|
316
|
-
|
472
|
+
instance.v.must_equal 0.0
|
473
|
+
instance.v = 23.42
|
474
|
+
instance.v.must_equal 23.42
|
317
475
|
end
|
476
|
+
|
318
477
|
it 'has a writable field rect' do
|
319
|
-
|
478
|
+
instance.rect.must_be_nil
|
479
|
+
rect = Regress::FooBRect.wrap(Regress::FooBRect::Struct.new.to_ptr)
|
480
|
+
rect.x = 42
|
481
|
+
rect.y = 23
|
482
|
+
instance.rect = rect
|
483
|
+
instance.rect.x.must_equal 42.0
|
484
|
+
instance.rect.y.must_equal 23.0
|
320
485
|
end
|
486
|
+
|
321
487
|
it 'creates an instance using #new' do
|
322
|
-
skip '
|
488
|
+
skip 'This function is defined in the header but not implemented'
|
323
489
|
end
|
490
|
+
|
324
491
|
it 'has a working method #get_contained_type' do
|
325
|
-
skip '
|
492
|
+
skip 'This function is defined in the header but not implemented'
|
326
493
|
end
|
327
494
|
end
|
495
|
+
|
328
496
|
describe 'Regress::FooBoxed' do
|
497
|
+
let(:instance) { Regress::FooBoxed.new }
|
498
|
+
|
329
499
|
it 'creates an instance using #new' do
|
330
|
-
|
500
|
+
instance.must_be_instance_of Regress::FooBoxed
|
331
501
|
end
|
502
|
+
|
332
503
|
it 'has a working method #method' do
|
333
|
-
|
504
|
+
instance.method.must_be_nil
|
334
505
|
end
|
335
506
|
end
|
507
|
+
|
336
508
|
describe 'Regress::FooBuffer' do
|
509
|
+
let(:instance) { Regress::FooBuffer.new }
|
510
|
+
|
511
|
+
it 'creates an instance using #new' do
|
512
|
+
instance.must_be_instance_of Regress::FooBuffer
|
513
|
+
end
|
514
|
+
|
337
515
|
it 'has a working method #some_method' do
|
338
|
-
|
516
|
+
instance.some_method.must_be_nil
|
339
517
|
end
|
340
518
|
end
|
519
|
+
|
341
520
|
describe 'Regress::FooDBusData' do
|
521
|
+
let(:instance) { Regress::FooDBusData.new }
|
522
|
+
|
523
|
+
it 'creates an instance using #new' do
|
524
|
+
instance.must_be_instance_of Regress::FooDBusData
|
525
|
+
end
|
526
|
+
|
342
527
|
it 'has a working method #method' do
|
343
|
-
skip '
|
528
|
+
skip 'This function is defined in the header but not implemented'
|
344
529
|
end
|
345
530
|
end
|
531
|
+
|
346
532
|
describe 'Regress::FooEnumFullname' do
|
347
533
|
it 'has the member :one' do
|
348
|
-
|
534
|
+
Regress::FooEnumFullname[:one].must_equal 1
|
349
535
|
end
|
536
|
+
|
350
537
|
it 'has the member :two' do
|
351
|
-
|
538
|
+
Regress::FooEnumFullname[:two].must_equal 2
|
352
539
|
end
|
540
|
+
|
353
541
|
it 'has the member :three' do
|
354
|
-
|
542
|
+
Regress::FooEnumFullname[:three].must_equal 3
|
355
543
|
end
|
356
544
|
end
|
545
|
+
|
357
546
|
describe 'Regress::FooEnumNoType' do
|
358
547
|
it 'has the member :un' do
|
359
|
-
|
548
|
+
Regress::FooEnumNoType[:un].must_equal 1
|
360
549
|
end
|
550
|
+
|
361
551
|
it 'has the member :deux' do
|
362
|
-
|
552
|
+
Regress::FooEnumNoType[:deux].must_equal 2
|
363
553
|
end
|
554
|
+
|
364
555
|
it 'has the member :trois' do
|
365
|
-
|
556
|
+
Regress::FooEnumNoType[:trois].must_equal 3
|
366
557
|
end
|
558
|
+
|
367
559
|
it 'has the member :neuf' do
|
368
|
-
|
560
|
+
Regress::FooEnumNoType[:neuf].must_equal 9
|
369
561
|
end
|
370
562
|
end
|
563
|
+
|
371
564
|
describe 'Regress::FooEnumType' do
|
372
565
|
it 'has the member :alpha' do
|
373
|
-
|
566
|
+
Regress::FooEnumType[:alpha].must_equal 0
|
374
567
|
end
|
568
|
+
|
375
569
|
it 'has the member :beta' do
|
376
|
-
|
570
|
+
Regress::FooEnumType[:beta].must_equal 1
|
377
571
|
end
|
572
|
+
|
378
573
|
it 'has the member :delta' do
|
379
|
-
|
574
|
+
Regress::FooEnumType[:delta].must_equal 2
|
380
575
|
end
|
576
|
+
|
381
577
|
it 'has a working function #method' do
|
382
|
-
skip '
|
578
|
+
skip 'This function is defined in the header but not implemented'
|
383
579
|
end
|
580
|
+
|
384
581
|
it 'has a working function #returnv' do
|
385
|
-
skip '
|
582
|
+
skip 'This function is defined in the header but not implemented'
|
386
583
|
end
|
387
584
|
end
|
585
|
+
|
388
586
|
describe 'Regress::FooError' do
|
389
587
|
it 'has the member :good' do
|
390
|
-
|
588
|
+
Regress::FooError[:good].must_equal 0
|
391
589
|
end
|
590
|
+
|
392
591
|
it 'has the member :bad' do
|
393
|
-
|
592
|
+
Regress::FooError[:bad].must_equal 1
|
394
593
|
end
|
594
|
+
|
395
595
|
it 'has the member :ugly' do
|
396
|
-
|
596
|
+
Regress::FooError[:ugly].must_equal 2
|
397
597
|
end
|
598
|
+
|
398
599
|
it 'has a working function #quark' do
|
399
|
-
|
600
|
+
quark = Regress::FooError.quark
|
601
|
+
GLib.quark_to_string(quark).must_equal 'regress_foo-error-quark'
|
400
602
|
end
|
401
603
|
end
|
604
|
+
|
402
605
|
describe 'Regress::FooEvent' do
|
606
|
+
let(:instance) { Regress::FooEvent.new }
|
607
|
+
|
403
608
|
it 'has a writable field type' do
|
404
|
-
|
609
|
+
instance.type.must_equal 0
|
610
|
+
instance.type = 23
|
611
|
+
instance.type.must_equal 23
|
405
612
|
end
|
613
|
+
|
406
614
|
it 'has a writable field any' do
|
407
|
-
|
615
|
+
instance.any.send_event.must_equal 0
|
616
|
+
any = Regress::FooEventAny.new
|
617
|
+
any.send_event = 42
|
618
|
+
instance.any = any
|
619
|
+
instance.any.send_event.must_equal 42
|
408
620
|
end
|
621
|
+
|
409
622
|
it 'has a writable field expose' do
|
410
|
-
|
623
|
+
instance.expose.send_event.must_equal 0
|
624
|
+
instance.expose.count.must_equal 0
|
625
|
+
expose = Regress::FooEventExpose.new
|
626
|
+
expose.send_event = 23
|
627
|
+
expose.count = 14
|
628
|
+
instance.expose = expose
|
629
|
+
instance.expose.send_event.must_equal 23
|
630
|
+
instance.expose.count.must_equal 14
|
411
631
|
end
|
412
632
|
end
|
633
|
+
|
413
634
|
describe 'Regress::FooEventAny' do
|
635
|
+
let(:instance) { Regress::FooEventAny.new }
|
636
|
+
|
414
637
|
it 'has a writable field send_event' do
|
415
|
-
|
638
|
+
instance.send_event.must_equal 0
|
639
|
+
instance.send_event = 23
|
640
|
+
instance.send_event.must_equal 23
|
416
641
|
end
|
417
642
|
end
|
643
|
+
|
418
644
|
describe 'Regress::FooEventExpose' do
|
645
|
+
let(:instance) { Regress::FooEventExpose.new }
|
646
|
+
|
419
647
|
it 'has a writable field send_event' do
|
420
|
-
|
648
|
+
instance.send_event.must_equal 0
|
649
|
+
instance.send_event = 23
|
650
|
+
instance.send_event.must_equal 23
|
421
651
|
end
|
652
|
+
|
422
653
|
it 'has a writable field count' do
|
423
|
-
|
654
|
+
instance.count.must_equal 0
|
655
|
+
instance.count = 42
|
656
|
+
instance.count.must_equal 42
|
424
657
|
end
|
425
658
|
end
|
659
|
+
|
426
660
|
describe 'Regress::FooFlagsNoType' do
|
427
661
|
it 'has the member :ett' do
|
428
|
-
|
662
|
+
Regress::FooFlagsNoType[:ett].must_equal 1
|
429
663
|
end
|
664
|
+
|
430
665
|
it 'has the member :tva' do
|
431
|
-
|
666
|
+
Regress::FooFlagsNoType[:tva].must_equal 2
|
432
667
|
end
|
668
|
+
|
433
669
|
it 'has the member :fyra' do
|
434
|
-
|
670
|
+
Regress::FooFlagsNoType[:fyra].must_equal 4
|
435
671
|
end
|
436
672
|
end
|
673
|
+
|
437
674
|
describe 'Regress::FooFlagsType' do
|
438
675
|
it 'has the member :first' do
|
439
|
-
|
676
|
+
Regress::FooFlagsType[:first].must_equal 1
|
440
677
|
end
|
678
|
+
|
441
679
|
it 'has the member :second' do
|
442
|
-
|
680
|
+
Regress::FooFlagsType[:second].must_equal 2
|
443
681
|
end
|
682
|
+
|
444
683
|
it 'has the member :third' do
|
445
|
-
|
684
|
+
Regress::FooFlagsType[:third].must_equal 4
|
446
685
|
end
|
447
686
|
end
|
687
|
+
|
448
688
|
describe 'Regress::FooForeignStruct' do
|
689
|
+
let(:instance) { Regress::FooForeignStruct.new }
|
690
|
+
|
449
691
|
it 'has a writable field regress_foo' do
|
450
|
-
|
692
|
+
instance.regress_foo.must_equal 0
|
693
|
+
instance.regress_foo = 143
|
694
|
+
instance.regress_foo.must_equal 143
|
451
695
|
end
|
696
|
+
|
452
697
|
it 'creates an instance using #new' do
|
453
|
-
|
698
|
+
instance.must_be_instance_of Regress::FooForeignStruct
|
454
699
|
end
|
700
|
+
|
455
701
|
it 'has a working method #copy' do
|
456
|
-
|
702
|
+
instance.regress_foo = 585
|
703
|
+
result = instance.copy
|
704
|
+
instance.regress_foo = 0
|
705
|
+
result.regress_foo.must_equal 585
|
457
706
|
end
|
458
707
|
end
|
708
|
+
|
459
709
|
describe 'Regress::FooInterface' do
|
460
710
|
it 'has a working function #static_method' do
|
461
|
-
|
711
|
+
Regress::FooInterface.static_method(42).must_be_nil
|
462
712
|
end
|
713
|
+
|
463
714
|
it 'has a working method #do_regress_foo' do
|
464
|
-
|
715
|
+
instance = Regress::FooObject.new
|
716
|
+
instance.must_be_kind_of Regress::FooInterface
|
717
|
+
instance.do_regress_foo(42).must_be_nil
|
465
718
|
end
|
466
719
|
end
|
720
|
+
|
467
721
|
describe 'Regress::FooObject' do
|
722
|
+
let(:instance) { Regress::FooObject.new }
|
723
|
+
|
468
724
|
it 'creates an instance using #new' do
|
469
|
-
|
725
|
+
instance.must_be_instance_of Regress::FooObject
|
470
726
|
end
|
727
|
+
|
471
728
|
it 'creates an instance using #new_as_super' do
|
472
|
-
|
729
|
+
other_instance = Regress::FooObject.new_as_super
|
730
|
+
other_instance.must_be_instance_of Regress::FooObject
|
473
731
|
end
|
732
|
+
|
474
733
|
it 'has a working function #a_global_method' do
|
475
|
-
skip '
|
734
|
+
skip 'This function is defined in the header but not implemented'
|
476
735
|
end
|
736
|
+
|
477
737
|
it 'has a working function #get_default' do
|
478
|
-
|
738
|
+
Regress::FooObject.get_default.must_be_nil
|
479
739
|
end
|
740
|
+
|
480
741
|
it 'has a working function #static_meth' do
|
481
|
-
skip '
|
742
|
+
skip 'This function is defined in the header but not implemented'
|
482
743
|
end
|
744
|
+
|
483
745
|
it 'has a working method #append_new_stack_layer' do
|
484
|
-
|
746
|
+
instance.append_new_stack_layer(42).must_be_nil
|
485
747
|
end
|
748
|
+
|
486
749
|
it 'has a working method #dup_name' do
|
487
|
-
|
750
|
+
instance.dup_name.must_equal 'regress_foo'
|
488
751
|
end
|
752
|
+
|
489
753
|
it 'has a working method #external_type' do
|
490
|
-
|
754
|
+
result = instance.external_type
|
755
|
+
result.must_be_nil
|
491
756
|
end
|
757
|
+
|
492
758
|
it 'has a working method #get_name' do
|
493
|
-
|
759
|
+
instance.get_name.must_equal 'regress_foo'
|
494
760
|
end
|
761
|
+
|
495
762
|
it 'has a working method #handle_glyph' do
|
496
|
-
skip '
|
763
|
+
skip 'This function is defined in the header but not implemented'
|
497
764
|
end
|
765
|
+
|
498
766
|
it 'has a working method #is_it_time_yet' do
|
499
|
-
|
767
|
+
instance.is_it_time_yet(Time.now.to_i).must_be_nil
|
500
768
|
end
|
769
|
+
|
501
770
|
it 'has a working method #read' do
|
502
|
-
|
771
|
+
instance.read(12, 13).must_be_nil
|
503
772
|
end
|
773
|
+
|
504
774
|
it 'has a working method #various' do
|
505
|
-
skip '
|
775
|
+
skip 'This function is defined in the header but not implemented'
|
506
776
|
end
|
777
|
+
|
507
778
|
it 'has a working method #virtual_method' do
|
508
|
-
skip '
|
779
|
+
skip 'This function is defined in the header but not implemented'
|
509
780
|
end
|
781
|
+
|
510
782
|
describe "its 'string' property" do
|
511
783
|
it 'can be retrieved with #get_property' do
|
512
|
-
|
784
|
+
instance.get_property('string').must_equal nil
|
513
785
|
end
|
786
|
+
|
514
787
|
it 'can be retrieved with #string' do
|
515
|
-
|
788
|
+
instance.string.must_equal nil
|
516
789
|
end
|
790
|
+
|
517
791
|
it 'can be set with #set_property' do
|
518
|
-
|
792
|
+
instance.set_property 'string', 'hello 42'
|
793
|
+
# FooObject doesn't actually store stuff
|
794
|
+
instance.string.must_be_nil
|
795
|
+
instance.get_property('string').must_be_nil
|
519
796
|
end
|
797
|
+
|
520
798
|
it 'can be set with #string=' do
|
521
|
-
|
799
|
+
instance.string = 'hello 42'
|
800
|
+
# FooObject doesn't actually store stuff
|
801
|
+
instance.string.must_be_nil
|
802
|
+
instance.get_property('string').must_be_nil
|
522
803
|
end
|
523
804
|
end
|
805
|
+
|
524
806
|
it "handles the 'signal' signal" do
|
807
|
+
instance.signal_connect 'signal' do
|
808
|
+
'hello'
|
809
|
+
end
|
810
|
+
|
811
|
+
result = GObject.signal_emit instance, 'signal'
|
812
|
+
result.must_equal 'hello'
|
525
813
|
end
|
526
814
|
end
|
815
|
+
|
527
816
|
describe 'Regress::FooOtherObject' do
|
817
|
+
it 'is derived from GObject::Object' do
|
818
|
+
Regress::FooOtherObject.superclass.must_equal GObject::Object
|
819
|
+
end
|
528
820
|
end
|
821
|
+
|
529
822
|
describe 'Regress::FooRectangle' do
|
823
|
+
let(:instance) { Regress::FooRectangle.new }
|
824
|
+
|
530
825
|
it 'has a writable field x' do
|
531
|
-
|
826
|
+
instance.x.must_equal 0
|
827
|
+
instance.x = 23
|
828
|
+
instance.x.must_equal 23
|
532
829
|
end
|
830
|
+
|
533
831
|
it 'has a writable field y' do
|
534
|
-
|
832
|
+
instance.y.must_equal 0
|
833
|
+
instance.y = 23
|
834
|
+
instance.y.must_equal 23
|
535
835
|
end
|
836
|
+
|
536
837
|
it 'has a writable field width' do
|
537
|
-
|
838
|
+
instance.width.must_equal 0
|
839
|
+
instance.width = 23
|
840
|
+
instance.width.must_equal 23
|
538
841
|
end
|
842
|
+
|
539
843
|
it 'has a writable field height' do
|
540
|
-
|
844
|
+
instance.height.must_equal 0
|
845
|
+
instance.height = 23
|
846
|
+
instance.height.must_equal 23
|
541
847
|
end
|
848
|
+
|
542
849
|
it 'has a working method #add' do
|
543
|
-
skip '
|
850
|
+
skip 'Not implemented yet'
|
851
|
+
other_instance = Regress::FooRectangle.new
|
852
|
+
instance.add other_instance
|
544
853
|
end
|
545
854
|
end
|
855
|
+
|
546
856
|
describe 'Regress::FooStackLayer' do
|
547
857
|
it 'has the member :desktop' do
|
548
|
-
|
858
|
+
Regress::FooStackLayer[:desktop].must_equal 0
|
549
859
|
end
|
860
|
+
|
550
861
|
it 'has the member :bottom' do
|
551
|
-
|
862
|
+
Regress::FooStackLayer[:bottom].must_equal 1
|
552
863
|
end
|
864
|
+
|
553
865
|
it 'has the member :normal' do
|
554
|
-
|
866
|
+
Regress::FooStackLayer[:normal].must_equal 2
|
555
867
|
end
|
868
|
+
|
556
869
|
it 'has the member :top' do
|
557
|
-
|
870
|
+
Regress::FooStackLayer[:top].must_equal 4
|
558
871
|
end
|
872
|
+
|
559
873
|
it 'has the member :dock' do
|
560
|
-
|
874
|
+
Regress::FooStackLayer[:dock].must_equal 4
|
561
875
|
end
|
876
|
+
|
562
877
|
it 'has the member :fullscreen' do
|
563
|
-
|
878
|
+
Regress::FooStackLayer[:fullscreen].must_equal 5
|
564
879
|
end
|
880
|
+
|
565
881
|
it 'has the member :focused_window' do
|
566
|
-
|
882
|
+
Regress::FooStackLayer[:focused_window].must_equal 6
|
567
883
|
end
|
884
|
+
|
568
885
|
it 'has the member :override_redirect' do
|
569
|
-
|
886
|
+
Regress::FooStackLayer[:override_redirect].must_equal 7
|
570
887
|
end
|
888
|
+
|
571
889
|
it 'has the member :last' do
|
572
|
-
|
890
|
+
Regress::FooStackLayer[:last].must_equal 8
|
573
891
|
end
|
574
892
|
end
|
893
|
+
|
575
894
|
describe 'Regress::FooStruct' do
|
895
|
+
let(:instance) { Regress::FooStruct.new }
|
896
|
+
|
576
897
|
it 'has a writable field priv' do
|
577
|
-
|
898
|
+
instance.priv.must_be_nil
|
899
|
+
struct = Regress::FooStructPrivate.new
|
900
|
+
instance.priv = struct
|
901
|
+
instance.priv.must_equal struct
|
578
902
|
end
|
903
|
+
|
579
904
|
it 'has a writable field member' do
|
580
|
-
|
905
|
+
instance.member.must_equal 0
|
906
|
+
instance.member = 23
|
907
|
+
instance.member.must_equal 23
|
581
908
|
end
|
582
909
|
end
|
910
|
+
|
583
911
|
describe 'Regress::FooSubInterface' do
|
912
|
+
let(:derived_klass) do
|
913
|
+
Object.const_set("DerivedClass#{Sequence.next}",
|
914
|
+
Class.new(Regress::FooObject))
|
915
|
+
end
|
916
|
+
|
917
|
+
def make_derived_instance
|
918
|
+
derived_klass.send :include, Regress::FooSubInterface
|
919
|
+
GirFFI.define_type derived_klass do |info|
|
920
|
+
yield info if block_given?
|
921
|
+
end
|
922
|
+
derived_klass.new
|
923
|
+
end
|
924
|
+
|
584
925
|
it 'has a working method #do_bar' do
|
585
|
-
|
926
|
+
result = nil
|
927
|
+
instance = make_derived_instance do |info|
|
928
|
+
info.install_vfunc_implementation :do_bar, proc { |obj| result = obj.get_name }
|
929
|
+
end
|
930
|
+
instance.do_bar
|
931
|
+
result.must_equal 'regress_foo'
|
586
932
|
end
|
933
|
+
|
587
934
|
it 'has a working method #do_baz' do
|
588
|
-
|
935
|
+
a = nil
|
936
|
+
instance = make_derived_instance do |info|
|
937
|
+
# TODO: Do not pass callback again in user_data if destroy notifier is absent
|
938
|
+
info.install_vfunc_implementation :do_baz,
|
939
|
+
proc { |obj, callback, _user_data| callback.call; a = obj.get_name }
|
940
|
+
end
|
941
|
+
b = nil
|
942
|
+
instance.do_baz { b = 'hello' }
|
943
|
+
a.must_equal 'regress_foo'
|
944
|
+
b.must_equal 'hello'
|
589
945
|
end
|
946
|
+
|
590
947
|
it "handles the 'destroy-event' signal" do
|
948
|
+
a = nil
|
949
|
+
instance = make_derived_instance
|
950
|
+
instance.signal_connect 'destroy-event' do
|
951
|
+
a = 'hello'
|
952
|
+
end
|
953
|
+
GObject.signal_emit instance, 'destroy-event'
|
954
|
+
a.must_equal 'hello'
|
591
955
|
end
|
592
956
|
end
|
957
|
+
|
593
958
|
describe 'Regress::FooSubobject' do
|
594
959
|
it 'creates an instance using #new' do
|
595
|
-
|
960
|
+
# TODO: Guard against instantiating abstract classes
|
961
|
+
skip 'This function is defined in the header but not implemented'
|
596
962
|
end
|
597
963
|
end
|
964
|
+
|
598
965
|
describe 'Regress::FooThingWithArray' do
|
966
|
+
let(:instance) { Regress::FooThingWithArray.new }
|
967
|
+
|
599
968
|
it 'has a writable field x' do
|
600
|
-
|
969
|
+
instance.x.must_equal 0
|
970
|
+
instance.x = 23
|
971
|
+
instance.x.must_equal 23
|
601
972
|
end
|
973
|
+
|
602
974
|
it 'has a writable field y' do
|
603
|
-
|
975
|
+
instance.y.must_equal 0
|
976
|
+
instance.y = 23
|
977
|
+
instance.y.must_equal 23
|
604
978
|
end
|
979
|
+
|
605
980
|
it 'has a writable field lines' do
|
606
|
-
|
981
|
+
instance.lines.must_be :==, [0] * 80
|
982
|
+
instance.lines = (1..80).to_a
|
983
|
+
instance.lines.must_be :==, (1..80).to_a
|
607
984
|
end
|
985
|
+
|
608
986
|
it 'has a writable field data' do
|
609
|
-
|
987
|
+
instance.data.must_equal FFI::Pointer::NULL
|
988
|
+
instance.data = FFI::Pointer.new(23)
|
989
|
+
instance.data.must_equal FFI::Pointer.new(23)
|
610
990
|
end
|
611
991
|
end
|
992
|
+
|
612
993
|
describe 'Regress::FooUnion' do
|
994
|
+
let(:instance) { Regress::FooUnion.new }
|
995
|
+
|
613
996
|
it 'has a writable field regress_foo' do
|
614
|
-
|
997
|
+
instance.regress_foo.must_equal 0
|
998
|
+
instance.regress_foo = 23
|
999
|
+
instance.regress_foo.must_equal 23
|
615
1000
|
end
|
616
1001
|
end
|
1002
|
+
|
617
1003
|
describe 'Regress::FooUtilityStruct' do
|
1004
|
+
let(:instance) { Regress::FooUtilityStruct.new }
|
1005
|
+
|
618
1006
|
it 'has a writable field bar' do
|
619
|
-
|
1007
|
+
struct = Utility::Struct.new
|
1008
|
+
struct.field = 23
|
1009
|
+
|
1010
|
+
instance.bar.field.must_equal 0
|
1011
|
+
instance.bar = struct
|
1012
|
+
instance.bar.field.must_equal 23
|
620
1013
|
end
|
621
1014
|
end
|
1015
|
+
|
622
1016
|
it 'has the constant GI_SCANNER_ELSE' do
|
623
1017
|
skip unless get_introspection_data 'Regress', 'GI_SCANNER_ELSE'
|
624
1018
|
Regress::GI_SCANNER_ELSE.must_equal 3
|
@@ -1030,7 +1424,7 @@ describe Regress do
|
|
1030
1424
|
end
|
1031
1425
|
|
1032
1426
|
it 'has a reference count of 1' do
|
1033
|
-
assert_equal 1,
|
1427
|
+
assert_equal 1, @o.ref_count
|
1034
1428
|
end
|
1035
1429
|
|
1036
1430
|
it 'has been sunk' do
|
@@ -1190,7 +1584,7 @@ describe Regress do
|
|
1190
1584
|
end
|
1191
1585
|
|
1192
1586
|
it 'has a reference count of 1' do
|
1193
|
-
assert_equal 1, ref_count
|
1587
|
+
assert_equal 1, instance.ref_count
|
1194
1588
|
end
|
1195
1589
|
|
1196
1590
|
it 'does not float' do
|
@@ -1261,9 +1655,9 @@ describe Regress do
|
|
1261
1655
|
|
1262
1656
|
it 'has a working method #instance_method_full' do
|
1263
1657
|
skip unless get_method_introspection_data('Regress', 'TestObj', 'instance_method_full')
|
1264
|
-
|
1658
|
+
instance.ref_count.must_equal 1
|
1265
1659
|
instance.instance_method_full
|
1266
|
-
|
1660
|
+
instance.ref_count.must_equal 1
|
1267
1661
|
end
|
1268
1662
|
|
1269
1663
|
it 'has a working method #set_bare' do
|
@@ -2314,53 +2708,81 @@ describe Regress do
|
|
2314
2708
|
end
|
2315
2709
|
|
2316
2710
|
it 'has a working function #annotation_attribute_func' do
|
2317
|
-
|
2711
|
+
info = get_introspection_data('Regress', 'annotation_attribute_func')
|
2712
|
+
param = info.args.last
|
2713
|
+
param.attribute('some.annotation').must_equal 'value'
|
2714
|
+
param.attribute('another.annotation').must_equal 'blahvalue'
|
2715
|
+
|
2716
|
+
obj = Regress::AnnotationObject.new
|
2717
|
+
Regress.annotation_attribute_func(obj, 'hello').must_equal 42
|
2318
2718
|
end
|
2719
|
+
|
2319
2720
|
it 'has a working function #annotation_custom_destroy' do
|
2320
|
-
|
2721
|
+
result = Regress.annotation_custom_destroy {}
|
2722
|
+
result.must_be_nil
|
2321
2723
|
end
|
2724
|
+
|
2322
2725
|
it 'has a working function #annotation_get_source_file' do
|
2323
|
-
|
2726
|
+
Regress.annotation_get_source_file.must_be_nil
|
2324
2727
|
end
|
2728
|
+
|
2325
2729
|
it 'has a working function #annotation_init' do
|
2326
|
-
|
2730
|
+
result = Regress.annotation_init %w(foo bar)
|
2731
|
+
result.to_a.must_equal %w(foo bar)
|
2327
2732
|
end
|
2733
|
+
|
2328
2734
|
it 'has a working function #annotation_invalid_regress_annotation' do
|
2329
|
-
|
2735
|
+
Regress.annotation_invalid_regress_annotation(42).must_be_nil
|
2330
2736
|
end
|
2737
|
+
|
2331
2738
|
it 'has a working function #annotation_ptr_array' do
|
2332
|
-
|
2739
|
+
# TODO: Automatically convert array elements to correct type
|
2740
|
+
val1 = GObject::Value.from 1
|
2741
|
+
val2 = GObject::Value.from 'a'
|
2742
|
+
Regress.annotation_ptr_array([val1, val2]).must_be_nil
|
2333
2743
|
end
|
2744
|
+
|
2334
2745
|
it 'has a working function #annotation_return_array' do
|
2335
|
-
|
2746
|
+
Regress.annotation_return_array.must_be_nil
|
2336
2747
|
end
|
2748
|
+
|
2337
2749
|
it 'has a working function #annotation_return_filename' do
|
2338
|
-
|
2750
|
+
Regress.annotation_return_filename.must_equal 'a utf-8 filename'
|
2339
2751
|
end
|
2752
|
+
|
2340
2753
|
it 'has a working function #annotation_set_source_file' do
|
2341
|
-
|
2754
|
+
Regress.annotation_set_source_file('a filename').must_be_nil
|
2342
2755
|
end
|
2756
|
+
|
2343
2757
|
it 'has a working function #annotation_space_after_comment_bug631690' do
|
2344
|
-
|
2758
|
+
Regress.annotation_space_after_comment_bug631690.must_be_nil
|
2345
2759
|
end
|
2760
|
+
|
2346
2761
|
it 'has a working function #annotation_string_array_length' do
|
2347
|
-
|
2762
|
+
Regress.annotation_string_array_length(%w(foo bar)).must_be_nil
|
2348
2763
|
end
|
2764
|
+
|
2349
2765
|
it 'has a working function #annotation_string_zero_terminated' do
|
2350
|
-
|
2766
|
+
Regress.annotation_string_zero_terminated.to_a.must_equal []
|
2351
2767
|
end
|
2768
|
+
|
2352
2769
|
it 'has a working function #annotation_string_zero_terminated_out' do
|
2353
|
-
|
2770
|
+
Regress.annotation_string_zero_terminated_out(%w(foo bar)).to_a.
|
2771
|
+
must_equal %w(foo bar)
|
2354
2772
|
end
|
2773
|
+
|
2355
2774
|
it 'has a working function #annotation_test_parsing_bug630862' do
|
2356
|
-
|
2775
|
+
Regress.annotation_test_parsing_bug630862.must_be_nil
|
2357
2776
|
end
|
2777
|
+
|
2358
2778
|
it 'has a working function #annotation_transfer_floating' do
|
2359
|
-
|
2779
|
+
Regress.annotation_transfer_floating.must_be_nil
|
2360
2780
|
end
|
2781
|
+
|
2361
2782
|
it 'has a working function #annotation_versioned' do
|
2362
|
-
|
2783
|
+
Regress.annotation_versioned.must_be_nil
|
2363
2784
|
end
|
2785
|
+
|
2364
2786
|
it 'has a working function #atest_error_quark' do
|
2365
2787
|
skip unless get_introspection_data 'Regress', 'atest_error_quark'
|
2366
2788
|
result = Regress.atest_error_quark
|
@@ -2368,59 +2790,78 @@ describe Regress do
|
|
2368
2790
|
end
|
2369
2791
|
|
2370
2792
|
it 'has a working function #foo_async_ready_callback' do
|
2371
|
-
skip '
|
2793
|
+
skip 'This function is defined in the header but not implemented'
|
2372
2794
|
end
|
2795
|
+
|
2373
2796
|
it 'has a working function #foo_destroy_notify_callback' do
|
2374
|
-
skip '
|
2797
|
+
skip 'This function is defined in the header but not implemented'
|
2375
2798
|
end
|
2799
|
+
|
2376
2800
|
it 'has a working function #foo_enum_type_method' do
|
2377
|
-
skip '
|
2801
|
+
skip 'This function is defined in the header but not implemented'
|
2378
2802
|
end
|
2803
|
+
|
2379
2804
|
it 'has a working function #foo_enum_type_returnv' do
|
2380
|
-
skip '
|
2805
|
+
skip 'This function is defined in the header but not implemented'
|
2381
2806
|
end
|
2807
|
+
|
2382
2808
|
it 'has a working function #foo_error_quark' do
|
2383
|
-
|
2809
|
+
result = Regress.foo_error_quark
|
2810
|
+
GLib.quark_to_string(result).must_equal('regress_foo-error-quark')
|
2384
2811
|
end
|
2812
|
+
|
2385
2813
|
it 'has a working function #foo_init' do
|
2386
|
-
|
2814
|
+
Regress.foo_init.must_equal 0x1138
|
2387
2815
|
end
|
2816
|
+
|
2388
2817
|
it 'has a working function #foo_interface_static_method' do
|
2389
|
-
|
2818
|
+
Regress.foo_interface_static_method(42).must_be_nil
|
2390
2819
|
end
|
2820
|
+
|
2391
2821
|
it 'has a working function #foo_method_external_references' do
|
2392
|
-
skip '
|
2822
|
+
skip 'This function is defined in the header but not implemented'
|
2393
2823
|
end
|
2824
|
+
|
2394
2825
|
it 'has a working function #foo_not_a_constructor_new' do
|
2395
|
-
|
2826
|
+
Regress.foo_not_a_constructor_new.must_be_nil
|
2396
2827
|
end
|
2828
|
+
|
2397
2829
|
it 'has a working function #foo_test_array' do
|
2398
|
-
|
2830
|
+
Regress.foo_test_array.must_be_nil
|
2399
2831
|
end
|
2832
|
+
|
2400
2833
|
it 'has a working function #foo_test_const_char_param' do
|
2401
|
-
skip '
|
2834
|
+
skip 'This function is defined in the header but not implemented'
|
2402
2835
|
end
|
2836
|
+
|
2403
2837
|
it 'has a working function #foo_test_const_char_retval' do
|
2404
|
-
skip '
|
2838
|
+
skip 'This function is defined in the header but not implemented'
|
2405
2839
|
end
|
2840
|
+
|
2406
2841
|
it 'has a working function #foo_test_const_struct_param' do
|
2407
|
-
skip '
|
2842
|
+
skip 'This function is defined in the header but not implemented'
|
2408
2843
|
end
|
2844
|
+
|
2409
2845
|
it 'has a working function #foo_test_const_struct_retval' do
|
2410
|
-
skip '
|
2846
|
+
skip 'This function is defined in the header but not implemented'
|
2411
2847
|
end
|
2848
|
+
|
2412
2849
|
it 'has a working function #foo_test_string_array' do
|
2413
|
-
|
2850
|
+
Regress.foo_test_string_array(%w(foo bar)).must_be_nil
|
2414
2851
|
end
|
2852
|
+
|
2415
2853
|
it 'has a working function #foo_test_string_array_with_g' do
|
2416
|
-
|
2854
|
+
Regress.foo_test_string_array_with_g(%w(foo bar)).must_be_nil
|
2417
2855
|
end
|
2856
|
+
|
2418
2857
|
it 'has a working function #foo_test_unsigned_qualifier' do
|
2419
|
-
skip '
|
2858
|
+
skip 'This function is defined in the header but not implemented'
|
2420
2859
|
end
|
2860
|
+
|
2421
2861
|
it 'has a working function #foo_test_unsigned_type' do
|
2422
|
-
skip '
|
2862
|
+
skip 'This function is defined in the header but not implemented'
|
2423
2863
|
end
|
2864
|
+
|
2424
2865
|
it 'has a working function #func_obj_null_in' do
|
2425
2866
|
Regress.func_obj_null_in nil
|
2426
2867
|
Regress.func_obj_null_in Regress::TestObj.constructor
|
@@ -2700,7 +3141,7 @@ describe Regress do
|
|
2700
3141
|
skip unless get_introspection_data 'Regress', 'test_callback_return_full'
|
2701
3142
|
obj = Regress::TestObj.constructor
|
2702
3143
|
Regress.test_callback_return_full { obj }
|
2703
|
-
|
3144
|
+
obj.ref_count.must_equal 1
|
2704
3145
|
end
|
2705
3146
|
|
2706
3147
|
it 'has a working function #test_callback_thaw_async' do
|
@@ -2937,8 +3378,8 @@ describe Regress do
|
|
2937
3378
|
end
|
2938
3379
|
|
2939
3380
|
it 'has a working function #test_glist_gtype_container_in' do
|
2940
|
-
skip
|
2941
|
-
Regress.test_glist_gtype_container_in
|
3381
|
+
skip unless get_introspection_data 'Regress', 'test_glist_gtype_container_in'
|
3382
|
+
Regress.test_glist_gtype_container_in [Regress::TestObj.gtype, Regress::TestSubObj.gtype]
|
2942
3383
|
pass
|
2943
3384
|
end
|
2944
3385
|
|
@@ -3025,8 +3466,8 @@ describe Regress do
|
|
3025
3466
|
it 'has a working function #test_gvariant_asv' do
|
3026
3467
|
result = Regress.test_gvariant_asv
|
3027
3468
|
result.n_children.must_equal 2
|
3028
|
-
result.lookup_value('name'
|
3029
|
-
result.lookup_value('timeout'
|
3469
|
+
result.lookup_value('name').get_string.must_equal 'foo'
|
3470
|
+
result.lookup_value('timeout').get_int32.must_equal 10
|
3030
3471
|
end
|
3031
3472
|
|
3032
3473
|
it 'has a working function #test_gvariant_i' do
|