gir_ffi 0.15.1 → 0.15.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +42 -0
  3. data/README.md +10 -10
  4. data/TODO.md +14 -35
  5. data/docs/Documentation.md +6 -0
  6. data/docs/Subclassing.md +38 -0
  7. data/lib/ffi-glib.rb +8 -3
  8. data/lib/ffi-glib/byte_array.rb +2 -1
  9. data/lib/ffi-glib/container_class_methods.rb +1 -3
  10. data/lib/ffi-glib/destroy_notify.rb +2 -2
  11. data/lib/ffi-glib/hash_table.rb +1 -2
  12. data/lib/ffi-glib/list.rb +11 -5
  13. data/lib/ffi-glib/list_methods.rb +12 -0
  14. data/lib/ffi-glib/s_list.rb +10 -4
  15. data/lib/ffi-gobject.rb +2 -5
  16. data/lib/ffi-gobject/object.rb +102 -92
  17. data/lib/ffi-gobject/object_class.rb +1 -1
  18. data/lib/ffi-gobject/ruby_closure.rb +1 -1
  19. data/lib/ffi-gobject/value.rb +108 -117
  20. data/lib/ffi-gobject_introspection/i_base_info.rb +35 -27
  21. data/lib/ffi-gobject_introspection/lib.rb +1 -1
  22. data/lib/gir_ffi-base/gobject/lib.rb +4 -0
  23. data/lib/gir_ffi/array_element_convertor.rb +2 -3
  24. data/lib/gir_ffi/boxed_base.rb +13 -11
  25. data/lib/gir_ffi/builder.rb +3 -4
  26. data/lib/gir_ffi/builder_helper.rb +10 -2
  27. data/lib/gir_ffi/builders/base_argument_builder.rb +2 -2
  28. data/lib/gir_ffi/builders/base_method_builder.rb +1 -1
  29. data/lib/gir_ffi/builders/base_type_builder.rb +1 -1
  30. data/lib/gir_ffi/builders/callback_argument_builder.rb +2 -0
  31. data/lib/gir_ffi/builders/callback_builder.rb +25 -11
  32. data/lib/gir_ffi/builders/callback_return_value_builder.rb +4 -6
  33. data/lib/gir_ffi/builders/enum_builder.rb +9 -5
  34. data/lib/gir_ffi/builders/field_builder.rb +2 -1
  35. data/lib/gir_ffi/builders/function_builder.rb +1 -1
  36. data/lib/gir_ffi/builders/interface_builder.rb +3 -1
  37. data/lib/gir_ffi/builders/mapping_method_builder.rb +1 -1
  38. data/lib/gir_ffi/builders/marshalling_method_builder.rb +5 -2
  39. data/lib/gir_ffi/builders/method_template.rb +4 -4
  40. data/lib/gir_ffi/builders/module_builder.rb +4 -2
  41. data/lib/gir_ffi/builders/null_argument_builder.rb +0 -2
  42. data/lib/gir_ffi/builders/null_return_value_builder.rb +0 -2
  43. data/lib/gir_ffi/builders/object_builder.rb +18 -6
  44. data/lib/gir_ffi/builders/property_builder.rb +1 -2
  45. data/lib/gir_ffi/builders/signal_closure_builder.rb +3 -5
  46. data/lib/gir_ffi/builders/struct_builder.rb +34 -7
  47. data/lib/gir_ffi/builders/user_defined_builder.rb +8 -1
  48. data/lib/gir_ffi/builders/vfunc_argument_builder.rb +1 -1
  49. data/lib/gir_ffi/callback_base.rb +7 -8
  50. data/lib/gir_ffi/class_base.rb +1 -0
  51. data/lib/gir_ffi/core.rb +17 -2
  52. data/lib/gir_ffi/glib_error.rb +1 -2
  53. data/lib/gir_ffi/in_pointer.rb +7 -0
  54. data/lib/gir_ffi/object_base.rb +27 -0
  55. data/lib/gir_ffi/return_value_info.rb +1 -2
  56. data/lib/gir_ffi/struct_base.rb +1 -9
  57. data/lib/gir_ffi/struct_like_base.rb +9 -5
  58. data/lib/gir_ffi/type_map.rb +1 -0
  59. data/lib/gir_ffi/unintrospectable_type_info.rb +1 -1
  60. data/lib/gir_ffi/union_base.rb +1 -9
  61. data/lib/gir_ffi/user_defined_object_info.rb +3 -2
  62. data/lib/gir_ffi/version.rb +1 -1
  63. data/lib/gir_ffi/vfunc_implementation.rb +1 -0
  64. metadata +106 -143
  65. data/Gemfile +0 -14
  66. data/Rakefile +0 -9
  67. data/tasks/test.rake +0 -204
  68. data/test/base_test_helper.rb +0 -70
  69. data/test/ffi-glib/array_test.rb +0 -203
  70. data/test/ffi-glib/byte_array_test.rb +0 -28
  71. data/test/ffi-glib/bytes_test.rb +0 -61
  72. data/test/ffi-glib/closure_test.rb +0 -38
  73. data/test/ffi-glib/destroy_notify_test.rb +0 -18
  74. data/test/ffi-glib/hash_table_test.rb +0 -68
  75. data/test/ffi-glib/list_test.rb +0 -86
  76. data/test/ffi-glib/main_loop_test.rb +0 -53
  77. data/test/ffi-glib/ptr_array_test.rb +0 -112
  78. data/test/ffi-glib/ruby_closure_test.rb +0 -62
  79. data/test/ffi-glib/s_list_test.rb +0 -76
  80. data/test/ffi-glib/strv_test.rb +0 -60
  81. data/test/ffi-glib/variant_test.rb +0 -12
  82. data/test/ffi-gobject/gobject_test.rb +0 -76
  83. data/test/ffi-gobject/object_class_test.rb +0 -31
  84. data/test/ffi-gobject/object_test.rb +0 -122
  85. data/test/ffi-gobject/param_spec_test.rb +0 -32
  86. data/test/ffi-gobject/value_test.rb +0 -390
  87. data/test/ffi-gobject_introspection/gobject_type_init_test.rb +0 -26
  88. data/test/ffi-gobject_introspection/i_base_info_test.rb +0 -52
  89. data/test/ffi-gobject_introspection/i_constant_info_test.rb +0 -29
  90. data/test/ffi-gobject_introspection/i_enum_info_test.rb +0 -18
  91. data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -6
  92. data/test/ffi-gobject_introspection/i_interface_info_test.rb +0 -23
  93. data/test/ffi-gobject_introspection/i_object_info_test.rb +0 -49
  94. data/test/ffi-gobject_introspection/i_property_info_test.rb +0 -47
  95. data/test/ffi-gobject_introspection/i_registered_type_info_test.rb +0 -27
  96. data/test/ffi-gobject_introspection/i_repository_test.rb +0 -81
  97. data/test/ffi-gobject_introspection/i_struct_info_test.rb +0 -23
  98. data/test/ffi-gobject_introspection/i_type_info_test.rb +0 -30
  99. data/test/ffi-gobject_introspection/i_union_info_test.rb +0 -17
  100. data/test/ffi-gobject_introspection/i_vfunc_info_test.rb +0 -41
  101. data/test/ffi-gobject_introspection/lib_test.rb +0 -13
  102. data/test/ffi-gobject_introspection/strv_test.rb +0 -46
  103. data/test/ffi-gobject_test.rb +0 -151
  104. data/test/gir_ffi/allocation_helper_test.rb +0 -36
  105. data/test/gir_ffi/arg_helper_test.rb +0 -139
  106. data/test/gir_ffi/boolean_test.rb +0 -43
  107. data/test/gir_ffi/boxed_base_test.rb +0 -65
  108. data/test/gir_ffi/builder_test.rb +0 -322
  109. data/test/gir_ffi/builders/argument_builder_test.rb +0 -651
  110. data/test/gir_ffi/builders/base_argument_builder_test.rb +0 -6
  111. data/test/gir_ffi/builders/callback_argument_builder_test.rb +0 -126
  112. data/test/gir_ffi/builders/callback_builder_test.rb +0 -117
  113. data/test/gir_ffi/builders/callback_return_value_builder_test.rb +0 -81
  114. data/test/gir_ffi/builders/constant_builder_test.rb +0 -6
  115. data/test/gir_ffi/builders/constructor_builder_test.rb +0 -37
  116. data/test/gir_ffi/builders/enum_builder_test.rb +0 -23
  117. data/test/gir_ffi/builders/field_builder_test.rb +0 -134
  118. data/test/gir_ffi/builders/function_builder_test.rb +0 -550
  119. data/test/gir_ffi/builders/initializer_builder_test.rb +0 -54
  120. data/test/gir_ffi/builders/interface_builder_test.rb +0 -32
  121. data/test/gir_ffi/builders/module_builder_test.rb +0 -43
  122. data/test/gir_ffi/builders/object_builder_test.rb +0 -98
  123. data/test/gir_ffi/builders/property_builder_test.rb +0 -158
  124. data/test/gir_ffi/builders/registered_type_builder_test.rb +0 -54
  125. data/test/gir_ffi/builders/return_value_builder_test.rb +0 -433
  126. data/test/gir_ffi/builders/signal_closure_builder_test.rb +0 -197
  127. data/test/gir_ffi/builders/struct_builder_test.rb +0 -93
  128. data/test/gir_ffi/builders/unintrospectable_boxed_builder_test.rb +0 -29
  129. data/test/gir_ffi/builders/unintrospectable_builder_test.rb +0 -84
  130. data/test/gir_ffi/builders/union_builder_test.rb +0 -28
  131. data/test/gir_ffi/builders/user_defined_builder_test.rb +0 -524
  132. data/test/gir_ffi/builders/vfunc_argument_builder_test.rb +0 -101
  133. data/test/gir_ffi/builders/vfunc_builder_test.rb +0 -241
  134. data/test/gir_ffi/callback_base_test.rb +0 -22
  135. data/test/gir_ffi/class_base_test.rb +0 -166
  136. data/test/gir_ffi/core_test.rb +0 -98
  137. data/test/gir_ffi/enum_base_test.rb +0 -43
  138. data/test/gir_ffi/error_type_info_test.rb +0 -50
  139. data/test/gir_ffi/ffi_ext/pointer_test.rb +0 -20
  140. data/test/gir_ffi/g_type_test.rb +0 -31
  141. data/test/gir_ffi/in_pointer_test.rb +0 -203
  142. data/test/gir_ffi/info_ext/i_callable_info_test.rb +0 -26
  143. data/test/gir_ffi/info_ext/i_callback_info_test.rb +0 -21
  144. data/test/gir_ffi/info_ext/i_field_info_test.rb +0 -37
  145. data/test/gir_ffi/info_ext/i_function_info_test.rb +0 -74
  146. data/test/gir_ffi/info_ext/i_signal_info_test.rb +0 -32
  147. data/test/gir_ffi/info_ext/i_type_info_test.rb +0 -711
  148. data/test/gir_ffi/info_ext/i_unresolved_info_test.rb +0 -19
  149. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +0 -26
  150. data/test/gir_ffi/info_ext/safe_function_name_test.rb +0 -26
  151. data/test/gir_ffi/interface_base_test.rb +0 -20
  152. data/test/gir_ffi/method_stubber_test.rb +0 -65
  153. data/test/gir_ffi/object_base_test.rb +0 -64
  154. data/test/gir_ffi/object_store_test.rb +0 -41
  155. data/test/gir_ffi/receiver_argument_info_test.rb +0 -33
  156. data/test/gir_ffi/sized_array_test.rb +0 -206
  157. data/test/gir_ffi/struct_base_test.rb +0 -23
  158. data/test/gir_ffi/struct_like_base_test.rb +0 -167
  159. data/test/gir_ffi/type_map_test.rb +0 -17
  160. data/test/gir_ffi/unintrospectable_type_info_test.rb +0 -121
  161. data/test/gir_ffi/union_base_test.rb +0 -23
  162. data/test/gir_ffi/user_defined_object_info_test.rb +0 -119
  163. data/test/gir_ffi/user_defined_property_info_test.rb +0 -39
  164. data/test/gir_ffi/variable_name_generator_test.rb +0 -18
  165. data/test/gir_ffi/version_test.rb +0 -9
  166. data/test/gir_ffi/zero_terminated_test.rb +0 -108
  167. data/test/gir_ffi_test_helper.rb +0 -84
  168. data/test/integration/callback_exceptions_test.rb +0 -59
  169. data/test/integration/derived_classes_test.rb +0 -53
  170. data/test/integration/generated_everything_test.rb +0 -452
  171. data/test/integration/generated_gimarshallingtests_test.rb +0 -3096
  172. data/test/integration/generated_gio_test.rb +0 -116
  173. data/test/integration/generated_glib_test.rb +0 -10
  174. data/test/integration/generated_gobject_test.rb +0 -124
  175. data/test/integration/generated_gst_test.rb +0 -38
  176. data/test/integration/generated_gtk_source_test.rb +0 -32
  177. data/test/integration/generated_gtop_test.rb +0 -22
  178. data/test/integration/generated_pango_ft2_test.rb +0 -17
  179. data/test/integration/generated_pango_test.rb +0 -24
  180. data/test/integration/generated_regress_test.rb +0 -4038
  181. data/test/integration/generated_secret_test.rb +0 -14
  182. data/test/integration/generated_utility_test.rb +0 -174
  183. data/test/integration/generated_warnlib_test.rb +0 -43
  184. data/test/integration/method_lookup_test.rb +0 -34
  185. data/test/introspection_test_helper.rb +0 -93
  186. data/test/lib/Makefile.am +0 -110
  187. data/test/lib/autogen.sh +0 -4
  188. data/test/lib/configure.ac +0 -34
  189. data/test/lib/m4/jhflags.m4 +0 -21
  190. data/test/minitest/stats_plugin.rb +0 -30
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- describe GObject::RubyClosure do
6
- describe ".new" do
7
- it "takes a mandatory block argument" do
8
- assert_raises ArgumentError do
9
- GObject::RubyClosure.new
10
- end
11
- end
12
-
13
- it "returns a kind of Closure" do
14
- c = GObject::RubyClosure.new {}
15
- assert_kind_of GObject::Closure, c
16
- end
17
- end
18
-
19
- describe ".wrap" do
20
- it "returns a fully functional object that can invoke the original block" do
21
- a = 0
22
- c = GObject::RubyClosure.new { a = 2 }
23
- c2 = GObject::RubyClosure.wrap(c.to_ptr)
24
- c2.invoke_block
25
- assert_equal 2, a
26
- end
27
- end
28
-
29
- describe ".marshaller" do
30
- it "invokes its closure argument's block" do
31
- a = 0
32
- c = GObject::RubyClosure.new { a = 2 }
33
- GObject::RubyClosure.marshaller(c, nil, nil, nil, nil)
34
- assert_equal 2, a
35
- end
36
-
37
- it "works when its closure argument is a GObject::Closure" do
38
- a = 0
39
- c = GObject::RubyClosure.new { a = 2 }
40
- c2 = GObject::Closure.wrap(c.to_ptr)
41
- GObject::RubyClosure.marshaller(c2, nil, nil, nil, nil)
42
- assert_equal 2, a
43
- end
44
-
45
- it "stores the closure's return value in the proper gvalue" do
46
- c = GObject::RubyClosure.new { 2 }
47
- gv = GObject::Value.new.init GObject::TYPE_INT
48
- GObject::RubyClosure.marshaller(c, gv, nil, nil, nil)
49
- assert_equal 2, gv.get_value
50
- end
51
- end
52
-
53
- describe "#invoke" do
54
- it "invokes the ruby block" do
55
- a = 0
56
- c = GObject::RubyClosure.new { a = 2 }
57
- c2 = GObject::Closure.wrap(c.to_ptr)
58
- c2.invoke nil, []
59
- assert_equal 2, a
60
- end
61
- end
62
- end
@@ -1,76 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- describe GLib::SList do
6
- it "knows its element type" do
7
- arr = GLib::SList.new :gint32
8
- assert_equal :gint32, arr.element_type
9
- end
10
-
11
- describe "#prepend" do
12
- it "prepends integer values" do
13
- lst = GLib::SList.new :gint32
14
- res = lst.prepend 1
15
- assert_equal 1, res.data
16
- end
17
-
18
- it "prepends string values" do
19
- lst = GLib::SList.new :utf8
20
- res = lst.prepend "bla"
21
- assert_equal "bla", res.data
22
- end
23
-
24
- it "prepends multiple values into a single list" do
25
- lst = GLib::SList.new :gint32
26
-
27
- res = lst.prepend 1
28
- res2 = res.prepend 2
29
-
30
- assert_equal 2, res2.data
31
- assert_equal 1, res.data
32
- assert_equal res.to_ptr, res2.next.to_ptr
33
- end
34
- end
35
-
36
- describe "::from" do
37
- it "creates a GSList from a Ruby array" do
38
- lst = GLib::SList.from :gint32, [3, 2, 1]
39
- assert_equal [3, 2, 1], lst.to_a
40
- end
41
-
42
- it "return its argument if given a GSList" do
43
- lst = GLib::SList.from :gint32, [3, 2, 1]
44
- lst2 = GLib::SList.from :gint32, lst
45
- assert_equal lst, lst2
46
- end
47
- end
48
-
49
- describe "#==" do
50
- it "returns true when comparing to an array with the same elements" do
51
- list = GLib::SList.from :gint32, [1, 2, 3]
52
-
53
- _(list).must_be :==, [1, 2, 3]
54
- end
55
-
56
- it "returns false when comparing to an array with different elements" do
57
- list = GLib::SList.from :gint32, [1, 2, 3]
58
-
59
- _(list).wont_be :==, [1, 2]
60
- end
61
-
62
- it "returns true when comparing to a list with the same elements" do
63
- list = GLib::SList.from :gint32, [1, 2, 3]
64
- other = GLib::SList.from :gint32, [1, 2, 3]
65
-
66
- _(list).must_be :==, other
67
- end
68
-
69
- it "returns false when comparing to a list with different elements" do
70
- list = GLib::SList.from :gint32, [1, 2, 3]
71
- other = GLib::SList.from :gint32, [1, 2]
72
-
73
- _(list).wont_be :==, other
74
- end
75
- end
76
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "base_test_helper"
4
-
5
- describe GLib::Strv do
6
- describe "::from" do
7
- it "creates a Strv from a Ruby array" do
8
- strv = GLib::Strv.from %w(1 2 3)
9
- _(strv).must_be_instance_of GLib::Strv
10
- _(strv.to_a).must_equal %w(1 2 3)
11
- end
12
-
13
- it "return its argument if given a Strv" do
14
- strv = GLib::Strv.from %w(1 2 3)
15
- strv2 = GLib::Strv.from strv
16
- assert strv2.equal? strv
17
- end
18
-
19
- it "wraps its argument if given a pointer" do
20
- strv = GLib::Strv.from %w(1 2 3)
21
-
22
- pointer = strv.to_ptr
23
- _(pointer).must_be_kind_of FFI::Pointer
24
-
25
- strv2 = GLib::Strv.from pointer
26
-
27
- _(strv2).must_be_kind_of GLib::Strv
28
- refute strv2.equal? strv
29
- _(strv2.to_a).must_equal strv.to_a
30
- end
31
- end
32
-
33
- describe "#==" do
34
- it "returns true when comparing to an array with the same elements" do
35
- strv = GLib::Strv.from %w(1 2 3)
36
-
37
- _(strv).must_be :==, %w(1 2 3)
38
- end
39
-
40
- it "returns false when comparing to an array with different elements" do
41
- strv = GLib::Strv.from %w(1 2 3)
42
-
43
- _(strv).wont_be :==, %w(1 2)
44
- end
45
-
46
- it "returns true when comparing to a strv with the same elements" do
47
- strv = GLib::Strv.from %w(1 2 3)
48
- other = GLib::Strv.from %w(1 2 3)
49
-
50
- _(strv).must_be :==, other
51
- end
52
-
53
- it "returns false when comparing to a strv with different elements" do
54
- strv = GLib::Strv.from %w(1 2 3)
55
- other = GLib::Strv.from %w(1 2)
56
-
57
- _(strv).wont_be :==, other
58
- end
59
- end
60
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- describe GLib::Variant do
6
- describe "#get_string" do
7
- it "returns just the contained string" do
8
- var = GLib::Variant.new_string("Foo")
9
- _(var.get_string).must_equal "Foo"
10
- end
11
- end
12
- end
@@ -1,76 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- require "ffi-gobject"
6
-
7
- GirFFI.setup :GIMarshallingTests
8
-
9
- describe GObject do
10
- describe ".type_init" do
11
- it "does not raise an error" do
12
- GObject.type_init
13
- pass
14
- end
15
- end
16
-
17
- it "has constants for the fundamental GTypes" do
18
- _(GObject::TYPE_INVALID).must_equal GObject.type_from_name("invalid")
19
- _(GObject.type_name(GObject::TYPE_INVALID)).must_be_nil
20
-
21
- _(GObject.type_name(GObject::TYPE_NONE)).must_equal "void"
22
- _(GObject.type_name(GObject::TYPE_INTERFACE)).must_equal "GInterface"
23
- _(GObject.type_name(GObject::TYPE_CHAR)).must_equal "gchar"
24
- _(GObject.type_name(GObject::TYPE_UCHAR)).must_equal "guchar"
25
- _(GObject.type_name(GObject::TYPE_BOOLEAN)).must_equal "gboolean"
26
- _(GObject.type_name(GObject::TYPE_INT)).must_equal "gint"
27
- _(GObject.type_name(GObject::TYPE_UINT)).must_equal "guint"
28
- _(GObject.type_name(GObject::TYPE_LONG)).must_equal "glong"
29
- _(GObject.type_name(GObject::TYPE_ULONG)).must_equal "gulong"
30
- _(GObject.type_name(GObject::TYPE_INT64)).must_equal "gint64"
31
- _(GObject.type_name(GObject::TYPE_UINT64)).must_equal "guint64"
32
- _(GObject.type_name(GObject::TYPE_ENUM)).must_equal "GEnum"
33
- _(GObject.type_name(GObject::TYPE_FLAGS)).must_equal "GFlags"
34
- _(GObject.type_name(GObject::TYPE_FLOAT)).must_equal "gfloat"
35
- _(GObject.type_name(GObject::TYPE_DOUBLE)).must_equal "gdouble"
36
- _(GObject.type_name(GObject::TYPE_STRING)).must_equal "gchararray"
37
- _(GObject.type_name(GObject::TYPE_POINTER)).must_equal "gpointer"
38
- _(GObject.type_name(GObject::TYPE_BOXED)).must_equal "GBoxed"
39
- _(GObject.type_name(GObject::TYPE_PARAM)).must_equal "GParam"
40
- _(GObject.type_name(GObject::TYPE_OBJECT)).must_equal "GObject"
41
- _(GObject.type_name(GObject::TYPE_GTYPE)).must_equal "GType"
42
- _(GObject.type_name(GObject::TYPE_VARIANT)).must_equal "GVariant"
43
-
44
- _(GObject.type_name(GObject::TYPE_ARRAY)).must_equal "GArray"
45
- _(GObject.type_name(GObject::TYPE_BYTE_ARRAY)).must_equal "GByteArray"
46
- _(GObject.type_name(GObject::TYPE_ERROR)).must_equal "GError"
47
- _(GObject.type_name(GObject::TYPE_HASH_TABLE)).must_equal "GHashTable"
48
- _(GObject.type_name(GObject::TYPE_STRV)).must_equal "GStrv"
49
- end
50
-
51
- describe "::object_class_from_instance" do
52
- it "returns a GObject::ObjectClass with the correct GType" do
53
- obj = GIMarshallingTests::OverridesObject.new
54
- object_class = GObject.object_class_from_instance obj
55
- gtype = object_class.g_type_class.g_type
56
-
57
- _(object_class).must_be_instance_of GObject::ObjectClass
58
- _(gtype).must_equal GIMarshallingTests::OverridesObject.gtype
59
- end
60
- end
61
-
62
- describe "creating ParamSpecs" do
63
- describe "#param_spec_int" do
64
- it "creates a GObject::ParamSpecInt" do
65
- spec = GObject.param_spec_int("foo", "foo bar",
66
- "The Foo Bar Property",
67
- 10, 20, 15,
68
- 3)
69
- _(spec).must_be_instance_of GObject::ParamSpecInt
70
- _(spec.struct[:minimum]).must_equal 10
71
- _(spec.struct[:maximum]).must_equal 20
72
- _(spec.get_default_value).must_equal 15
73
- end
74
- end
75
- end
76
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- require "ffi-gobject"
6
-
7
- describe GObject::ObjectClass do
8
- describe "#list_properties" do
9
- it "returns GIMarshallingTests::OverridesObject's properties" do
10
- obj = GIMarshallingTests::OverridesObject.new
11
- object_class = GObject.object_class_from_instance obj
12
-
13
- info = get_introspection_data "GIMarshallingTests", "OverridesObject"
14
- expected_props = info.properties.map(&:name)
15
- expected_props += info.parent.properties.map(&:name)
16
-
17
- props = object_class.list_properties
18
- prop_names = props.map(&:get_name)
19
-
20
- _(prop_names.sort).must_equal expected_props.sort
21
- end
22
- end
23
-
24
- describe "#gtype" do
25
- it "returns the correct GType" do
26
- obj = GIMarshallingTests::OverridesObject.new
27
- object_class = GObject.object_class_from_instance obj
28
- _(object_class.gtype).must_equal GIMarshallingTests::OverridesObject.gtype
29
- end
30
- end
31
- end
@@ -1,122 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- require "ffi-gobject"
6
- GirFFI.setup :GIMarshallingTests
7
-
8
- describe GObject::Object do
9
- describe ".new" do
10
- it "is overridden to take only one argument" do
11
- _(GObject::Object.new({})).must_be_instance_of GObject::Object
12
- end
13
-
14
- it "can be used to create objects with properties" do
15
- obj = GIMarshallingTests::SubObject.new(int: 13)
16
- _(obj.int).must_equal 13
17
- end
18
-
19
- it "allows omission of the first argument" do
20
- _(GObject::Object.new).must_be_instance_of GObject::Object
21
- end
22
-
23
- it "raises an error for properties that do not exist" do
24
- _(proc { GObject::Object.new(dog: "bark") }).must_raise GirFFI::PropertyNotFoundError
25
- end
26
- end
27
-
28
- describe "#get_property" do
29
- it "is overridden to have arity 1" do
30
- _(GObject::Object.instance_method("get_property").arity).must_equal 1
31
- end
32
-
33
- it "raises an error for a property that does not exist" do
34
- instance = GObject::Object.new
35
- _(proc { instance.get_property "foo-bar" }).must_raise GirFFI::PropertyNotFoundError
36
- end
37
-
38
- it "raises an error for a property that does not exist" do
39
- instance = GObject::Object.new
40
- _(proc { instance.get_property "foo-bar" })
41
- .must_raise GirFFI::PropertyNotFoundError
42
- end
43
- end
44
-
45
- describe "#get_property_extended" do
46
- it "raises an error for a property that does not exist" do
47
- instance = GObject::Object.new
48
- _(proc { instance.get_property_extended "foo-bar" })
49
- .must_raise GirFFI::PropertyNotFoundError
50
- end
51
- end
52
-
53
- describe "#set_property" do
54
- it "raises an error for a property that does not exist" do
55
- instance = GObject::Object.new
56
- _(proc { instance.set_property "foo-bar", 123 }).must_raise GirFFI::PropertyNotFoundError
57
- end
58
- end
59
-
60
- describe "#set_property_extended" do
61
- it "raises an error for a property that does not exist" do
62
- instance = GObject::Object.new
63
- _(proc { instance.set_property_extended "foo-bar", 123 })
64
- .must_raise GirFFI::PropertyNotFoundError
65
- end
66
- end
67
-
68
- describe "#signal_connect" do
69
- subject { GObject::Object.new }
70
-
71
- it "delegates to GObject" do
72
- expect(GObject).to receive(:signal_connect).with(subject, "some-event", nil)
73
- subject.signal_connect("some-event") do
74
- nothing
75
- end
76
- end
77
-
78
- it "delegates to GObject if an optional data argument is passed" do
79
- expect(GObject).to receive(:signal_connect).with(subject, "some-event", "data")
80
- subject.signal_connect("some-event", "data") do
81
- nothing
82
- end
83
- end
84
- end
85
-
86
- describe "#signal_connect_after" do
87
- subject { GObject::Object.new }
88
-
89
- it "delegates to GObject" do
90
- expect(GObject).to receive(:signal_connect_after).with(subject, "some-event", nil)
91
- subject.signal_connect_after("some-event") do
92
- nothing
93
- end
94
- end
95
-
96
- it "delegates to GObject if an optional data argument is passed" do
97
- expect(GObject).to receive(:signal_connect_after).with(subject, "some-event", "data")
98
- subject.signal_connect_after("some-event", "data") do
99
- nothing
100
- end
101
- end
102
- end
103
-
104
- describe "upon garbage collection" do
105
- it "lowers the reference count" do
106
- skip "cannot be reliably tested on JRuby and Rubinius" if jruby? || rubinius?
107
-
108
- ptr = GObject::Object.new.to_ptr
109
- _(object_ref_count(ptr)).must_equal 1
110
-
111
- GC.start
112
- # Creating a new object is sometimes needed to trigger enough garbage collection.
113
- GObject::Object.new
114
- sleep 1
115
-
116
- GC.start
117
- GC.start
118
-
119
- _(object_ref_count(ptr)).must_equal 0
120
- end
121
- end
122
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "gir_ffi_test_helper"
4
-
5
- require "ffi-gobject"
6
- describe GObject::ParamSpec do
7
- let(:pspec) do
8
- GObject.param_spec_int("foo-bar", "foo bar",
9
- "Foo Bar",
10
- 1, 3, 2,
11
- readable: true, writable: true)
12
- end
13
- let(:pspec_struct) { GObject::ParamSpec::Struct.new(pspec.to_ptr) }
14
-
15
- describe "#ref" do
16
- it "increases the ref count" do
17
- old = pspec_struct[:ref_count]
18
- pspec.ref
19
- _(pspec_struct[:ref_count]).must_equal old + 1
20
- end
21
- end
22
-
23
- describe "#accessor_name" do
24
- it "returns a safe ruby method name" do
25
- _(pspec.accessor_name).must_equal "foo_bar"
26
- end
27
- end
28
-
29
- it "cannot be instantiated directly" do
30
- _(proc { GObject::ParamSpec.new }).must_raise NoMethodError
31
- end
32
- end