gir_ffi 0.7.7 → 0.7.8
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.
- checksums.yaml +4 -4
- data/Changelog.md +9 -0
- data/lib/ffi-glib/array.rb +1 -1
- data/lib/ffi-glib/error.rb +1 -2
- data/lib/ffi-glib/hash_table.rb +2 -2
- data/lib/ffi-glib/variant.rb +1 -1
- data/lib/ffi-gobject/base.rb +23 -23
- data/lib/ffi-gobject/object.rb +7 -3
- data/lib/ffi-gobject/value.rb +6 -1
- data/lib/ffi-gobject.rb +9 -6
- data/lib/ffi-gobject_introspection/i_base_info.rb +3 -3
- data/lib/ffi-gobject_introspection/i_constant_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_repository.rb +4 -1
- data/lib/ffi-gobject_introspection/i_type_info.rb +1 -1
- data/lib/ffi-gobject_introspection/i_unresolved_info.rb +7 -0
- data/lib/ffi-gobject_introspection/lib.rb +1 -1
- data/lib/gir_ffi/builders/argument_builder.rb +1 -1
- data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +37 -29
- data/lib/gir_ffi/builders/callback_argument_builder.rb +57 -27
- data/lib/gir_ffi/builders/closure_convertor.rb +12 -8
- data/lib/gir_ffi/builders/closure_to_pointer_convertor.rb +12 -8
- data/lib/gir_ffi/builders/constructor_result_convertor.rb +11 -7
- data/lib/gir_ffi/builders/field_builder.rb +1 -1
- data/lib/gir_ffi/builders/function_builder.rb +1 -1
- data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
- data/lib/gir_ffi/builders/marshalling_method_builder.rb +2 -2
- data/lib/gir_ffi/builders/method_template.rb +1 -1
- data/lib/gir_ffi/builders/null_convertor.rb +11 -7
- data/lib/gir_ffi/builders/property_builder.rb +1 -1
- data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +17 -13
- data/lib/gir_ffi/error_argument_info.rb +1 -1
- data/lib/gir_ffi/ffi_ext/pointer.rb +1 -1
- data/lib/gir_ffi/info_ext/i_unresolved_info.rb +12 -0
- data/lib/gir_ffi/info_ext/safe_constant_name.rb +2 -2
- data/lib/gir_ffi/info_ext/safe_function_name.rb +1 -1
- data/lib/gir_ffi/info_ext.rb +1 -0
- data/lib/gir_ffi/module_base.rb +1 -1
- data/lib/gir_ffi/receiver_argument_info.rb +15 -12
- data/lib/gir_ffi/user_data_argument_info.rb +17 -15
- data/lib/gir_ffi/user_data_type_info.rb +14 -12
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi-base/gobject/lib.rb +1 -1
- data/test/base_test_helper.rb +15 -15
- data/test/ffi-glib/array_test.rb +38 -38
- data/test/ffi-glib/byte_array_test.rb +6 -7
- data/test/ffi-glib/bytes_test.rb +9 -9
- data/test/ffi-glib/hash_table_test.rb +26 -23
- data/test/ffi-glib/iconv_test.rb +5 -5
- data/test/ffi-glib/list_test.rb +16 -16
- data/test/ffi-glib/main_loop_test.rb +6 -6
- data/test/ffi-glib/ptr_array_test.rb +45 -45
- data/test/ffi-glib/ruby_closure_test.rb +6 -6
- data/test/ffi-glib/s_list_test.rb +15 -15
- data/test/ffi-glib/strv_test.rb +21 -21
- data/test/ffi-glib/variant_test.rb +4 -4
- data/test/ffi-gobject/gobject_test.rb +35 -35
- data/test/ffi-gobject/object_class_test.rb +1 -1
- data/test/ffi-gobject/object_test.rb +29 -6
- data/test/ffi-gobject/value_test.rb +66 -52
- data/test/ffi-gobject_introspection/i_base_info_test.rb +10 -11
- data/test/ffi-gobject_introspection/i_constant_info_test.rb +6 -6
- data/test/ffi-gobject_introspection/i_enum_info_test.rb +4 -5
- data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -2
- data/test/ffi-gobject_introspection/i_object_info_test.rb +5 -5
- data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +9 -8
- data/test/ffi-gobject_introspection/i_repository_test.rb +16 -16
- data/test/ffi-gobject_introspection/i_type_info_test.rb +16 -2
- data/test/ffi-gobject_introspection/lib_test.rb +2 -2
- data/test/ffi-gobject_test.rb +50 -40
- data/test/gir_ffi/arg_helper_test.rb +5 -5
- data/test/gir_ffi/builder_test.rb +41 -41
- data/test/gir_ffi/builders/argument_builder_test.rb +240 -207
- data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -1
- data/test/gir_ffi/builders/callback_argument_builder_test.rb +81 -15
- data/test/gir_ffi/builders/callback_builder_test.rb +39 -14
- data/test/gir_ffi/builders/callback_return_value_builder_test.rb +41 -33
- data/test/gir_ffi/builders/enum_builder_test.rb +3 -3
- data/test/gir_ffi/builders/field_builder_test.rb +17 -17
- data/test/gir_ffi/builders/function_builder_test.rb +16 -16
- data/test/gir_ffi/builders/interface_builder_test.rb +9 -7
- data/test/gir_ffi/builders/module_builder_test.rb +5 -6
- data/test/gir_ffi/builders/object_builder_test.rb +24 -19
- data/test/gir_ffi/builders/property_builder_test.rb +25 -23
- data/test/gir_ffi/builders/registered_type_builder_test.rb +11 -11
- data/test/gir_ffi/builders/return_value_builder_test.rb +237 -197
- data/test/gir_ffi/builders/signal_closure_builder_test.rb +29 -22
- data/test/gir_ffi/builders/struct_builder_test.rb +10 -10
- data/test/gir_ffi/builders/unintrospectable_builder_test.rb +8 -8
- data/test/gir_ffi/builders/union_builder_test.rb +5 -6
- data/test/gir_ffi/builders/user_defined_builder_test.rb +42 -33
- data/test/gir_ffi/builders/vfunc_builder_test.rb +37 -30
- data/test/gir_ffi/callback_base_test.rb +4 -5
- data/test/gir_ffi/class_base_test.rb +35 -28
- data/test/gir_ffi/error_type_info_test.rb +14 -14
- data/test/gir_ffi/ffi_ext/pointer_test.rb +4 -4
- data/test/gir_ffi/g_type_test.rb +6 -6
- data/test/gir_ffi/in_out_pointer_test.rb +27 -27
- data/test/gir_ffi/in_pointer_test.rb +54 -50
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +8 -7
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +7 -7
- data/test/gir_ffi/info_ext/i_field_info_test.rb +10 -8
- data/test/gir_ffi/info_ext/i_function_info_test.rb +17 -15
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +10 -8
- data/test/gir_ffi/info_ext/i_type_info_test.rb +158 -155
- data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +17 -0
- data/test/gir_ffi/info_ext/safe_constant_name_test.rb +12 -10
- data/test/gir_ffi/info_ext/safe_function_name_test.rb +12 -10
- data/test/gir_ffi/interface_base_test.rb +6 -6
- data/test/gir_ffi/method_stubber_test.rb +16 -13
- data/test/gir_ffi/object_base_test.rb +6 -6
- data/test/gir_ffi/sized_array_test.rb +23 -23
- data/test/gir_ffi/type_map_test.rb +3 -3
- data/test/gir_ffi/unintrospectable_type_info_test.rb +18 -18
- data/test/gir_ffi/user_defined_property_info_test.rb +4 -4
- data/test/gir_ffi/user_defined_type_info_test.rb +16 -16
- data/test/gir_ffi/variable_name_generator_test.rb +6 -6
- data/test/gir_ffi/version_test.rb +1 -1
- data/test/gir_ffi/zero_terminated_test.rb +16 -17
- data/test/gir_ffi-base/glib/boolean_test.rb +13 -13
- data/test/gir_ffi-base/glib/strv_test.rb +11 -11
- data/test/gir_ffi_test.rb +18 -18
- data/test/gir_ffi_test_helper.rb +13 -18
- data/test/integration/derived_classes_test.rb +8 -8
- data/test/integration/generated_gimarshallingtests_test.rb +794 -792
- data/test/integration/generated_gio_test.rb +25 -26
- data/test/integration/generated_glib_test.rb +8 -2
- data/test/integration/generated_gobject_test.rb +16 -9
- data/test/integration/generated_pango_ft2_test.rb +1 -2
- data/test/integration/generated_pango_test.rb +2 -2
- data/test/integration/generated_regress_test.rb +785 -705
- data/test/integration/generated_secret_test.rb +5 -5
- data/test/integration/method_lookup_test.rb +5 -5
- data/test/introspection_test_helper.rb +3 -1
- data/test/minitest/stats_plugin.rb +3 -3
- metadata +6 -3
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'gir_ffi_test_helper'
|
2
2
|
|
3
3
|
describe GLib::Variant do
|
4
|
-
describe
|
5
|
-
it
|
6
|
-
var = GLib::Variant.new_string(
|
7
|
-
var.get_string.must_equal
|
4
|
+
describe '#get_string' do
|
5
|
+
it 'returns just the contained string' do
|
6
|
+
var = GLib::Variant.new_string('Foo')
|
7
|
+
var.get_string.must_equal 'Foo'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -5,45 +5,45 @@ require 'ffi-gobject'
|
|
5
5
|
GirFFI.setup :GIMarshallingTests
|
6
6
|
|
7
7
|
describe GObject do
|
8
|
-
describe
|
9
|
-
it
|
8
|
+
describe '.type_init' do
|
9
|
+
it 'does not raise an error' do
|
10
10
|
GObject.type_init
|
11
11
|
pass
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
16
|
-
assert_equal GObject.type_from_name(
|
15
|
+
it 'has constants for the fundamental GTypes' do
|
16
|
+
assert_equal GObject.type_from_name('invalid'), GObject::TYPE_INVALID
|
17
17
|
assert_equal nil, GObject.type_name(GObject::TYPE_INVALID)
|
18
18
|
|
19
|
-
assert_equal
|
20
|
-
assert_equal
|
21
|
-
assert_equal
|
22
|
-
assert_equal
|
23
|
-
assert_equal
|
24
|
-
assert_equal
|
25
|
-
assert_equal
|
26
|
-
assert_equal
|
27
|
-
assert_equal
|
28
|
-
assert_equal
|
29
|
-
assert_equal
|
30
|
-
assert_equal
|
31
|
-
assert_equal
|
32
|
-
assert_equal
|
33
|
-
assert_equal
|
34
|
-
assert_equal
|
35
|
-
assert_equal
|
36
|
-
assert_equal
|
37
|
-
assert_equal
|
38
|
-
assert_equal
|
39
|
-
assert_equal
|
40
|
-
assert_equal
|
41
|
-
assert_equal
|
42
|
-
assert_equal
|
19
|
+
assert_equal 'void', GObject.type_name(GObject::TYPE_NONE)
|
20
|
+
assert_equal 'GInterface', GObject.type_name(GObject::TYPE_INTERFACE)
|
21
|
+
assert_equal 'gchar', GObject.type_name(GObject::TYPE_CHAR)
|
22
|
+
assert_equal 'guchar', GObject.type_name(GObject::TYPE_UCHAR)
|
23
|
+
assert_equal 'gboolean', GObject.type_name(GObject::TYPE_BOOLEAN)
|
24
|
+
assert_equal 'gint', GObject.type_name(GObject::TYPE_INT)
|
25
|
+
assert_equal 'guint', GObject.type_name(GObject::TYPE_UINT)
|
26
|
+
assert_equal 'glong', GObject.type_name(GObject::TYPE_LONG)
|
27
|
+
assert_equal 'gulong', GObject.type_name(GObject::TYPE_ULONG)
|
28
|
+
assert_equal 'gint64', GObject.type_name(GObject::TYPE_INT64)
|
29
|
+
assert_equal 'guint64', GObject.type_name(GObject::TYPE_UINT64)
|
30
|
+
assert_equal 'GEnum', GObject.type_name(GObject::TYPE_ENUM)
|
31
|
+
assert_equal 'GFlags', GObject.type_name(GObject::TYPE_FLAGS)
|
32
|
+
assert_equal 'gfloat', GObject.type_name(GObject::TYPE_FLOAT)
|
33
|
+
assert_equal 'gdouble', GObject.type_name(GObject::TYPE_DOUBLE)
|
34
|
+
assert_equal 'gchararray', GObject.type_name(GObject::TYPE_STRING)
|
35
|
+
assert_equal 'gpointer', GObject.type_name(GObject::TYPE_POINTER)
|
36
|
+
assert_equal 'GBoxed', GObject.type_name(GObject::TYPE_BOXED)
|
37
|
+
assert_equal 'GParam', GObject.type_name(GObject::TYPE_PARAM)
|
38
|
+
assert_equal 'GObject', GObject.type_name(GObject::TYPE_OBJECT)
|
39
|
+
assert_equal 'GType', GObject.type_name(GObject::TYPE_GTYPE)
|
40
|
+
assert_equal 'GVariant', GObject.type_name(GObject::TYPE_VARIANT)
|
41
|
+
assert_equal 'GStrv', GObject.type_name(GObject::TYPE_STRV)
|
42
|
+
assert_equal 'GHashTable', GObject.type_name(GObject::TYPE_HASH_TABLE)
|
43
43
|
end
|
44
44
|
|
45
|
-
describe
|
46
|
-
it
|
45
|
+
describe '::object_class_from_instance' do
|
46
|
+
it 'returns a GObject::ObjectClass with the correct GType' do
|
47
47
|
obj = GIMarshallingTests::OverridesObject.new
|
48
48
|
object_class = GObject.object_class_from_instance obj
|
49
49
|
gtype = object_class.g_type_class.g_type
|
@@ -53,11 +53,11 @@ describe GObject do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
describe
|
57
|
-
describe
|
58
|
-
it
|
59
|
-
spec = GObject.param_spec_int(
|
60
|
-
|
56
|
+
describe 'creating ParamSpecs' do
|
57
|
+
describe '#param_spec_int' do
|
58
|
+
it 'creates a GObject::ParamSpecInt' do
|
59
|
+
spec = GObject.param_spec_int('foo', 'foo bar',
|
60
|
+
'The Foo Bar Property',
|
61
61
|
10, 20, 15,
|
62
62
|
3)
|
63
63
|
spec.must_be_instance_of GObject::ParamSpecInt
|
@@ -3,7 +3,7 @@ require 'gir_ffi_test_helper'
|
|
3
3
|
require 'ffi-gobject'
|
4
4
|
|
5
5
|
describe GObject::ObjectClass do
|
6
|
-
describe
|
6
|
+
describe '#list_properties' do
|
7
7
|
it "returns GIMarshallingTests::OverridesObject's properties" do
|
8
8
|
obj = GIMarshallingTests::OverridesObject.new
|
9
9
|
object_class = GObject.object_class_from_instance obj
|
@@ -3,19 +3,20 @@ require 'gir_ffi_test_helper'
|
|
3
3
|
require 'ffi-gobject'
|
4
4
|
|
5
5
|
describe GObject::Object do
|
6
|
-
describe
|
7
|
-
it
|
6
|
+
describe '#get_property' do
|
7
|
+
it 'is overridden to have arity 1' do
|
8
8
|
assert_equal 1,
|
9
|
-
GObject::Object.instance_method(
|
9
|
+
GObject::Object.instance_method('get_property').arity
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
describe
|
13
|
+
describe 'automatic accessor methods' do
|
14
14
|
class AccessorTest < GObject::Object
|
15
15
|
def get_x
|
16
16
|
@x
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
|
+
def set_x val
|
19
20
|
@x = val
|
20
21
|
end
|
21
22
|
end
|
@@ -33,7 +34,7 @@ describe GObject::Object do
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
|
-
describe
|
37
|
+
describe '#signal_connect' do
|
37
38
|
subject { GObject::Object.new GObject::TYPE_OBJECT, nil }
|
38
39
|
|
39
40
|
it 'delegates to GObject' do
|
@@ -54,4 +55,26 @@ describe GObject::Object do
|
|
54
55
|
RR.verify
|
55
56
|
end
|
56
57
|
end
|
58
|
+
|
59
|
+
describe '#signal_connect_after' do
|
60
|
+
subject { GObject::Object.new GObject::TYPE_OBJECT, nil }
|
61
|
+
|
62
|
+
it 'delegates to GObject' do
|
63
|
+
mock(GObject).signal_connect_after(subject, 'some-event', nil)
|
64
|
+
subject.signal_connect_after('some-event') do
|
65
|
+
nothing
|
66
|
+
end
|
67
|
+
|
68
|
+
RR.verify
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'delegates to GObject if an optional data argument is passed' do
|
72
|
+
mock(GObject).signal_connect_after(subject, 'some-event', 'data')
|
73
|
+
subject.signal_connect_after('some-event', 'data') do
|
74
|
+
nothing
|
75
|
+
end
|
76
|
+
|
77
|
+
RR.verify
|
78
|
+
end
|
79
|
+
end
|
57
80
|
end
|
@@ -3,104 +3,118 @@ require 'gir_ffi_test_helper'
|
|
3
3
|
GirFFI.setup :Regress
|
4
4
|
|
5
5
|
describe GObject::Value do
|
6
|
-
describe
|
7
|
-
describe
|
6
|
+
describe '::Struct' do
|
7
|
+
describe 'layout' do
|
8
8
|
let(:layout) { GObject::Value::Struct.layout }
|
9
9
|
|
10
|
-
it
|
10
|
+
it 'consists of :g_type and :data' do
|
11
11
|
layout.members.must_equal [:g_type, :data]
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
14
|
+
it 'has an array as its second element' do
|
15
15
|
types = layout.fields.map(&:type)
|
16
16
|
types[1].class.must_equal FFI::Type::Array
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe
|
22
|
-
it
|
21
|
+
describe '::wrap_ruby_value' do
|
22
|
+
it 'wraps a boolean false' do
|
23
23
|
gv = GObject::Value.wrap_ruby_value false
|
24
24
|
assert_instance_of GObject::Value, gv
|
25
25
|
assert_equal false, gv.get_boolean
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it 'wraps a boolean true' do
|
29
29
|
gv = GObject::Value.wrap_ruby_value true
|
30
30
|
assert_instance_of GObject::Value, gv
|
31
31
|
assert_equal true, gv.get_boolean
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
34
|
+
it 'wraps an Integer' do
|
35
35
|
gv = GObject::Value.wrap_ruby_value 42
|
36
36
|
assert_equal 42, gv.get_int
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
40
|
-
gv = GObject::Value.wrap_ruby_value
|
41
|
-
assert_equal
|
39
|
+
it 'wraps a String' do
|
40
|
+
gv = GObject::Value.wrap_ruby_value 'Some Random String'
|
41
|
+
assert_equal 'Some Random String', gv.get_string
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
describe
|
46
|
-
it
|
45
|
+
describe '#set_value' do
|
46
|
+
it 'handles char values' do
|
47
47
|
value = 83
|
48
48
|
gv = GObject::Value.for_g_type GObject::TYPE_CHAR
|
49
49
|
gv.set_value value
|
50
50
|
gv.get_char.must_equal value
|
51
51
|
end
|
52
52
|
|
53
|
-
it
|
53
|
+
it 'handles enum values presented as symbols' do
|
54
|
+
value = :value2
|
55
|
+
gv = GObject::Value.for_g_type Regress::TestEnum.get_gtype
|
56
|
+
gv.set_value value
|
57
|
+
gv.get_value.must_equal value
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'handles enum values presented as numbers' do
|
61
|
+
value = :value2
|
62
|
+
gv = GObject::Value.for_g_type Regress::TestEnum.get_gtype
|
63
|
+
gv.set_value Regress::TestEnum[value]
|
64
|
+
gv.get_value.must_equal value
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'handles GType values' do
|
54
68
|
value = GObject::TYPE_STRING
|
55
69
|
gv = GObject::Value.for_g_type GObject::TYPE_GTYPE
|
56
70
|
gv.set_value value
|
57
71
|
gv.get_gtype.must_equal value
|
58
72
|
end
|
59
73
|
|
60
|
-
it
|
74
|
+
it 'handles int64 values' do
|
61
75
|
value = 0x1234_5678_9012_3456
|
62
76
|
gv = GObject::Value.for_g_type GObject::TYPE_INT64
|
63
77
|
gv.set_value value
|
64
78
|
gv.get_int64.must_equal value
|
65
79
|
end
|
66
80
|
|
67
|
-
it
|
81
|
+
it 'handles long values' do
|
68
82
|
value = FFI.type_size(:long) == 8 ? 0x1234_5678_9012_3456 : 0x1234_5678
|
69
83
|
gv = GObject::Value.for_g_type GObject::TYPE_LONG
|
70
84
|
gv.set_value value
|
71
85
|
gv.get_long.must_equal value
|
72
86
|
end
|
73
87
|
|
74
|
-
it
|
88
|
+
it 'handles uchar values' do
|
75
89
|
value = 83
|
76
90
|
gv = GObject::Value.for_g_type GObject::TYPE_UCHAR
|
77
91
|
gv.set_value value
|
78
92
|
gv.get_uchar.must_equal value
|
79
93
|
end
|
80
94
|
|
81
|
-
it
|
95
|
+
it 'handles uint values' do
|
82
96
|
value = 0x1234_5678
|
83
97
|
gv = GObject::Value.for_g_type GObject::TYPE_UINT
|
84
98
|
gv.set_value value
|
85
99
|
gv.get_uint.must_equal value
|
86
100
|
end
|
87
101
|
|
88
|
-
it
|
102
|
+
it 'handles uint64 values' do
|
89
103
|
value = 0x1234_5678_9012_3456
|
90
104
|
gv = GObject::Value.for_g_type GObject::TYPE_UINT64
|
91
105
|
gv.set_value value
|
92
106
|
gv.get_uint64.must_equal value
|
93
107
|
end
|
94
108
|
|
95
|
-
it
|
109
|
+
it 'handles ulong values' do
|
96
110
|
value = FFI.type_size(:long) == 8 ? 0x1234_5678_9012_3456 : 0x1234_5678
|
97
111
|
gv = GObject::Value.for_g_type GObject::TYPE_ULONG
|
98
112
|
gv.set_value value
|
99
113
|
gv.get_ulong.must_equal value
|
100
114
|
end
|
101
115
|
|
102
|
-
it
|
103
|
-
value = GLib::Variant.new_string(
|
116
|
+
it 'handles variant values' do
|
117
|
+
value = GLib::Variant.new_string('Foo')
|
104
118
|
gv = GObject::Value.for_g_type GObject::TYPE_VARIANT
|
105
119
|
gv.set_value value
|
106
120
|
gv.get_variant.must_equal value
|
@@ -108,108 +122,108 @@ describe GObject::Value do
|
|
108
122
|
|
109
123
|
end
|
110
124
|
|
111
|
-
describe
|
112
|
-
it
|
125
|
+
describe '#get_value' do
|
126
|
+
it 'unwraps a boolean false' do
|
113
127
|
gv = GObject::Value.wrap_ruby_value false
|
114
128
|
result = gv.get_value
|
115
129
|
assert_equal false, result
|
116
130
|
end
|
117
131
|
|
118
|
-
it
|
132
|
+
it 'unwraps a boolean true' do
|
119
133
|
gv = GObject::Value.wrap_ruby_value true
|
120
134
|
result = gv.get_value
|
121
135
|
assert_equal true, result
|
122
136
|
end
|
123
137
|
|
124
|
-
it
|
138
|
+
it 'unwraps a char' do
|
125
139
|
value = 3
|
126
140
|
gv = GObject::Value.for_g_type GObject::TYPE_CHAR
|
127
141
|
gv.set_char value
|
128
142
|
gv.get_value.must_equal value
|
129
143
|
end
|
130
144
|
|
131
|
-
it
|
145
|
+
it 'unwraps an enum value' do
|
132
146
|
value = :value2
|
133
147
|
gv = GObject::Value.for_g_type Regress::TestEnum.get_gtype
|
134
148
|
gv.set_enum Regress::TestEnum[value]
|
135
149
|
gv.get_value.must_equal value
|
136
150
|
end
|
137
151
|
|
138
|
-
it
|
152
|
+
it 'unwraps a flags value' do
|
139
153
|
value = Regress::TestFlags[:flag1] | Regress::TestFlags[:flag3]
|
140
154
|
gv = GObject::Value.for_g_type Regress::TestFlags.get_gtype
|
141
155
|
gv.set_flags value
|
142
156
|
gv.get_value.must_equal value
|
143
157
|
end
|
144
158
|
|
145
|
-
it
|
159
|
+
it 'unwraps a GType' do
|
146
160
|
value = GObject::TYPE_STRING
|
147
161
|
gv = GObject::Value.for_g_type GObject::TYPE_GTYPE
|
148
162
|
gv.set_gtype value
|
149
163
|
gv.get_value.must_equal value
|
150
164
|
end
|
151
165
|
|
152
|
-
it
|
166
|
+
it 'unwraps an int64' do
|
153
167
|
value = 0x1234_5678_9012_3456
|
154
168
|
gv = GObject::Value.for_g_type GObject::TYPE_INT64
|
155
169
|
gv.set_int64 value
|
156
170
|
gv.get_value.must_equal value
|
157
171
|
end
|
158
172
|
|
159
|
-
it
|
173
|
+
it 'unwraps a long' do
|
160
174
|
value = FFI.type_size(:long) == 8 ? 0x1234_5678_9012_3456 : 0x1234_5678
|
161
175
|
gv = GObject::Value.for_g_type GObject::TYPE_LONG
|
162
176
|
gv.set_long value
|
163
177
|
gv.get_value.must_equal value
|
164
178
|
end
|
165
179
|
|
166
|
-
it
|
180
|
+
it 'unwraps an uchar' do
|
167
181
|
value = 3
|
168
182
|
gv = GObject::Value.for_g_type GObject::TYPE_UCHAR
|
169
183
|
gv.set_uchar value
|
170
184
|
gv.get_value.must_equal value
|
171
185
|
end
|
172
186
|
|
173
|
-
it
|
187
|
+
it 'unwraps an uint' do
|
174
188
|
value = 0x1234_5678
|
175
189
|
gv = GObject::Value.for_g_type GObject::TYPE_UINT
|
176
190
|
gv.set_uint value
|
177
191
|
gv.get_value.must_equal value
|
178
192
|
end
|
179
193
|
|
180
|
-
it
|
194
|
+
it 'unwraps an uint64' do
|
181
195
|
value = 0x1234_5678_9012_3456
|
182
196
|
gv = GObject::Value.for_g_type GObject::TYPE_UINT64
|
183
197
|
gv.set_uint64 value
|
184
198
|
gv.get_value.must_equal value
|
185
199
|
end
|
186
200
|
|
187
|
-
it
|
201
|
+
it 'unwraps a ulong' do
|
188
202
|
value = FFI.type_size(:long) == 8 ? 0x1234_5678_9012_3456 : 0x1234_5678
|
189
203
|
gv = GObject::Value.for_g_type GObject::TYPE_ULONG
|
190
204
|
gv.set_ulong value
|
191
205
|
gv.get_value.must_equal value
|
192
206
|
end
|
193
207
|
|
194
|
-
it
|
195
|
-
value = GLib::Variant.new_string(
|
208
|
+
it 'unwraps a variant' do
|
209
|
+
value = GLib::Variant.new_string('Foo')
|
196
210
|
gv = GObject::Value.for_g_type GObject::TYPE_VARIANT
|
197
211
|
gv.set_variant value
|
198
212
|
gv.get_value.must_equal value
|
199
213
|
end
|
200
214
|
|
201
|
-
it
|
202
|
-
ba = GLib::ByteArray.new.append(
|
215
|
+
it 'works with a ByteArray' do
|
216
|
+
ba = GLib::ByteArray.new.append('some bytes')
|
203
217
|
v = GObject::Value.for_g_type GObject::TYPE_BYTE_ARRAY
|
204
218
|
v.set_boxed ba
|
205
219
|
|
206
220
|
result = v.get_value
|
207
221
|
|
208
|
-
result.to_string.must_equal
|
222
|
+
result.to_string.must_equal 'some bytes'
|
209
223
|
result.must_be_kind_of GLib::ByteArray
|
210
224
|
end
|
211
225
|
|
212
|
-
it
|
226
|
+
it 'works with an Array' do
|
213
227
|
arr = GLib::Array.from(:uint, [1, 2, 3])
|
214
228
|
v = GObject::Value.for_g_type GObject::TYPE_ARRAY
|
215
229
|
v.set_boxed arr
|
@@ -221,37 +235,37 @@ describe GObject::Value do
|
|
221
235
|
end
|
222
236
|
end
|
223
237
|
|
224
|
-
describe
|
225
|
-
it
|
238
|
+
describe '::from' do
|
239
|
+
it 'creates a gint GValue from a Ruby Integer' do
|
226
240
|
gv = GObject::Value.from 21
|
227
|
-
gv.current_gtype_name.must_equal
|
241
|
+
gv.current_gtype_name.must_equal 'gint'
|
228
242
|
gv.get_value.must_equal 21
|
229
243
|
end
|
230
244
|
|
231
|
-
it
|
245
|
+
it 'returns its argument if given a GValue' do
|
232
246
|
gv = GObject::Value.from 21
|
233
247
|
gv2 = GObject::Value.from gv
|
234
|
-
gv2.current_gtype_name.must_equal
|
248
|
+
gv2.current_gtype_name.must_equal 'gint'
|
235
249
|
gv2.get_value.must_equal 21
|
236
250
|
end
|
237
251
|
end
|
238
252
|
|
239
|
-
describe
|
253
|
+
describe '#set_value' do
|
240
254
|
before do
|
241
255
|
GirFFI.setup :GIMarshallingTests
|
242
256
|
end
|
243
257
|
|
244
|
-
it
|
258
|
+
it 'raises an error when setting an incompatible object type' do
|
245
259
|
o = GIMarshallingTests::Object.new 1
|
246
260
|
v = GObject::Value.new.init(GIMarshallingTests::OverridesObject.get_gtype)
|
247
261
|
proc { v.set_value o }.must_raise ArgumentError
|
248
262
|
end
|
249
263
|
|
250
|
-
it
|
251
|
-
ba = GLib::ByteArray.new.append(
|
252
|
-
v = GObject::Value.new.init(GObject.type_from_name(
|
264
|
+
it 'works with a ByteArray' do
|
265
|
+
ba = GLib::ByteArray.new.append('some bytes')
|
266
|
+
v = GObject::Value.new.init(GObject.type_from_name('GByteArray'))
|
253
267
|
v.set_value ba
|
254
|
-
v.get_value.to_string.must_equal
|
268
|
+
v.get_value.to_string.must_equal 'some bytes'
|
255
269
|
end
|
256
270
|
end
|
257
271
|
end
|
@@ -2,37 +2,37 @@ require 'introspection_test_helper'
|
|
2
2
|
|
3
3
|
describe GObjectIntrospection::IBaseInfo do
|
4
4
|
let(:described_class) { GObjectIntrospection::IBaseInfo }
|
5
|
-
describe
|
6
|
-
it
|
5
|
+
describe '#initialize' do
|
6
|
+
it 'raises an error if a null pointer is passed' do
|
7
7
|
mock(ptr = Object.new).null? { true }
|
8
8
|
proc { described_class.new ptr }.must_raise ArgumentError
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
11
|
+
it 'raises no error if a non-null pointer is passed' do
|
12
12
|
mock(ptr = Object.new).null? { false }
|
13
13
|
described_class.new ptr
|
14
14
|
pass
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
18
|
+
describe '#deprecated?' do
|
19
19
|
let(:deprecated_info) { get_introspection_data 'Regress', 'test_versioning' }
|
20
20
|
let(:other_info) { get_introspection_data 'Regress', 'test_value_return' }
|
21
21
|
|
22
|
-
it
|
22
|
+
it 'returns true for a deprecated item' do
|
23
23
|
skip unless deprecated_info
|
24
24
|
deprecated_info.must_be :deprecated?
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
27
|
+
it 'returns false for a non-deprecated item' do
|
28
28
|
other_info.wont_be :deprecated?
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
describe
|
33
|
-
it
|
34
|
-
if defined?(RUBY_ENGINE) &&
|
35
|
-
skip
|
32
|
+
describe 'upon garbage collection' do
|
33
|
+
it 'calls g_base_info_unref' do
|
34
|
+
if defined?(RUBY_ENGINE) && %w(jruby rbx).include?(RUBY_ENGINE)
|
35
|
+
skip 'cannot be reliably tested on JRuby and Rubinius'
|
36
36
|
end
|
37
37
|
|
38
38
|
mock(ptr = Object.new).null? { false }
|
@@ -51,4 +51,3 @@ describe GObjectIntrospection::IBaseInfo do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
@@ -1,30 +1,30 @@
|
|
1
1
|
require 'introspection_test_helper'
|
2
2
|
|
3
3
|
describe GObjectIntrospection::IConstantInfo do
|
4
|
-
describe
|
4
|
+
describe 'for GLib::USEC_PER_SEC, a constant of type :gint32' do
|
5
5
|
let(:constant_info) { get_introspection_data 'GLib', 'USEC_PER_SEC' }
|
6
6
|
|
7
|
-
it
|
7
|
+
it 'returns :gint32 as its type' do
|
8
8
|
assert_equal :gint32, constant_info.constant_type.tag
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
11
|
+
it 'returns 1_000_000 as its value' do
|
12
12
|
assert_equal 1_000_000, constant_info.value
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
16
|
+
describe 'for GLib::SOURCE_CONTINUE, a constant of type :gboolean' do
|
17
17
|
let(:constant_info) { get_introspection_data 'GLib', 'SOURCE_CONTINUE' }
|
18
18
|
|
19
19
|
before do
|
20
20
|
skip unless constant_info
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'returns :gboolean as its type' do
|
24
24
|
assert_equal :gboolean, constant_info.constant_type.tag
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
27
|
+
it 'returns true as its value' do
|
28
28
|
assert_equal true, constant_info.value
|
29
29
|
end
|
30
30
|
end
|
@@ -1,17 +1,16 @@
|
|
1
1
|
require 'introspection_test_helper'
|
2
2
|
|
3
3
|
describe GObjectIntrospection::IEnumInfo do
|
4
|
-
describe
|
4
|
+
describe '#find_method' do
|
5
5
|
before do
|
6
6
|
gir = GObjectIntrospection::IRepository.default
|
7
7
|
gir.require 'Regress', nil
|
8
8
|
@info = gir.find_by_name 'Regress', 'TestEnum'
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
12
|
-
result = @info.find_method(
|
13
|
-
result.name.must_equal
|
11
|
+
it 'finds a method by name' do
|
12
|
+
result = @info.find_method('param')
|
13
|
+
result.name.must_equal 'param'
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
@@ -3,14 +3,14 @@ require 'introspection_test_helper'
|
|
3
3
|
describe GObjectIntrospection::IObjectInfo do
|
4
4
|
let(:object_info) { get_introspection_data('GObject', 'Object') }
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
object_info.find_vfunc(
|
6
|
+
describe '#find_vfunc' do
|
7
|
+
it 'finds a vfunc by name' do
|
8
|
+
object_info.find_vfunc('finalize').wont_be_nil
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
13
|
-
it
|
12
|
+
describe '#type_name' do
|
13
|
+
it 'returns the correct name' do
|
14
14
|
object_info.type_name.must_equal 'GObject'
|
15
15
|
end
|
16
16
|
end
|