gir_ffi 0.0.14 → 0.1.0
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.
- data/History.txt +6 -0
- data/README.rdoc +36 -12
- data/examples/01_empty_window.rb +1 -3
- data/examples/02_hello_world.rb +1 -3
- data/examples/03_upgraded_hello_world.rb +1 -3
- data/examples/04_webkit.rb +2 -2
- data/examples/05_notification.rb +1 -2
- data/examples/print_class.rb +6 -4
- data/lib/ffi-glib.rb +107 -0
- data/lib/ffi-glib/array.rb +14 -0
- data/lib/ffi-glib/byte_array.rb +10 -0
- data/lib/ffi-glib/hash_table.rb +55 -0
- data/lib/ffi-glib/list.rb +9 -0
- data/lib/ffi-glib/list_methods.rb +31 -0
- data/lib/ffi-glib/s_list.rb +9 -0
- data/lib/ffi-gobject.rb +94 -0
- data/lib/ffi-gobject/closure.rb +12 -0
- data/lib/ffi-gobject/helper.rb +119 -0
- data/lib/ffi-gobject/initially_unowned.rb +10 -0
- data/lib/ffi-gobject/ruby_closure.rb +47 -0
- data/lib/ffi-gobject/value.rb +65 -0
- data/lib/ffi-gobject_introspection.rb +3 -0
- data/lib/{gir_ffi → ffi-gobject_introspection}/g_error.rb +1 -1
- data/lib/ffi-gobject_introspection/gobject_lib.rb +7 -0
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_arg_info.rb +2 -2
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_base_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_callable_info.rb +4 -4
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_callback_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_constant_info.rb +2 -3
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_enum_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_field_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_flags_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_function_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_interface_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_object_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_property_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_registered_type_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_repository.rb +37 -23
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_signal_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_struct_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_type_info.rb +2 -2
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_union_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_value_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/i_vfunc_info.rb +1 -1
- data/lib/{gir_ffi → ffi-gobject_introspection}/lib.rb +1 -1
- data/lib/ffi-gtk/base.rb +17 -0
- data/lib/ffi-gtk2.rb +5 -0
- data/lib/ffi-gtk3.rb +5 -0
- data/lib/gir_ffi.rb +11 -4
- data/lib/gir_ffi/arg_helper.rb +5 -4
- data/lib/gir_ffi/builder.rb +3 -25
- data/lib/gir_ffi/builder/argument.rb +0 -2
- data/lib/gir_ffi/builder/argument/hash_table_base.rb +1 -1
- data/lib/gir_ffi/builder/argument/list_base.rb +1 -1
- data/lib/gir_ffi/builder/module.rb +1 -6
- data/lib/gir_ffi/builder/type/unintrospectable.rb +1 -1
- data/lib/gir_ffi/callback_helper.rb +14 -7
- data/lib/gir_ffi/in_out_pointer.rb +1 -1
- data/lib/gir_ffi/in_pointer.rb +1 -1
- data/lib/gir_ffi/module_base.rb +4 -0
- data/lib/gir_ffi/type_map.rb +29 -0
- data/lib/gir_ffi/version.rb +1 -1
- data/tasks/test.rake +20 -1
- data/test/arg_helper_test.rb +10 -13
- data/test/builder_test.rb +2 -2
- data/test/class_base_test.rb +1 -1
- data/test/{glib_overrides_test.rb → ffi-glib/glib_overrides_test.rb} +3 -5
- data/test/{g_object_overrides_test.rb → ffi-gobject/g_object_overrides_test.rb} +7 -37
- data/test/ffi-gobject/gobject_test.rb +22 -0
- data/test/ffi-gobject/value_test.rb +34 -0
- data/test/{unit → ffi-gobject_introspection}/i_base_info_test.rb +2 -2
- data/test/{unit → ffi-gobject_introspection}/i_constant_info_test.rb +1 -1
- data/test/ffi-gobject_introspection/i_object_info_test.rb +20 -0
- data/test/{unit → ffi-gobject_introspection}/i_repository_test.rb +11 -11
- data/test/function_definition_builder_test.rb +1 -1
- data/test/gir_ffi_test_helper.rb +114 -0
- data/test/girffi_test.rb +2 -2
- data/test/gtk_overrides_test.rb +15 -12
- data/test/integration/generated_gimarshallingtests_test.rb +10 -5
- data/test/integration/generated_gio_test.rb +1 -1
- data/test/integration/generated_gobject_test.rb +1 -1
- data/test/integration/generated_gtk_test.rb +3 -3
- data/test/integration/generated_regress_test.rb +11 -3
- data/test/interface_type_builder_test.rb +1 -1
- data/test/module_builder_test.rb +1 -1
- data/test/test_helper.rb +2 -111
- data/test/type_builder_test.rb +2 -2
- data/test/unintrospectable_type_builder_test.rb +1 -1
- data/test/unit/builder_test.rb +1 -1
- data/test/unit/callback_helper_test.rb +13 -10
- data/test/unit/constant_builder_test.rb +1 -1
- data/test/unit/in_out_pointer_test.rb +1 -1
- data/test/unit/in_pointer_test.rb +1 -1
- data/test/unit/object_type_builder_test.rb +1 -1
- metadata +62 -43
- data/lib/gir_ffi/g_object.rb +0 -38
- data/lib/gir_ffi/overrides/glib.rb +0 -225
- data/lib/gir_ffi/overrides/gobject.rb +0 -330
- data/lib/gir_ffi/overrides/gtk.rb +0 -29
- data/test/g_object_test.rb +0 -21
- data/test/i_object_info_test.rb +0 -20
data/test/builder_test.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
2
2
|
|
3
3
|
class BuilderTest < MiniTest::Spec
|
4
4
|
context "The GirFFI::Builder module" do
|
5
5
|
setup do
|
6
|
-
@gir =
|
6
|
+
@gir = GObjectIntrospection::IRepository.default
|
7
7
|
end
|
8
8
|
|
9
9
|
context "building GObject::Object" do
|
data/test/class_base_test.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
2
2
|
|
3
|
-
|
4
|
-
before do
|
5
|
-
GirFFI.setup :GLib
|
6
|
-
end
|
3
|
+
require 'ffi-glib'
|
7
4
|
|
5
|
+
describe "With the GLib overrides" do
|
8
6
|
describe "a HashTable provided by the system" do
|
9
7
|
before do
|
10
8
|
GirFFI.setup :Regress
|
@@ -1,4 +1,6 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'ffi-gobject'
|
2
4
|
|
3
5
|
class GObjectOverridesTest < MiniTest::Spec
|
4
6
|
context "In the GObject module with overridden functions" do
|
@@ -6,36 +8,6 @@ class GObjectOverridesTest < MiniTest::Spec
|
|
6
8
|
GirFFI.setup :Regress
|
7
9
|
end
|
8
10
|
|
9
|
-
context "the Value class" do
|
10
|
-
context "the wrap_ruby_value class method" do
|
11
|
-
should "wrap a boolean false" do
|
12
|
-
gv = GObject::Value.wrap_ruby_value false
|
13
|
-
assert_instance_of GObject::Value, gv
|
14
|
-
assert_equal false, gv.get_boolean
|
15
|
-
end
|
16
|
-
|
17
|
-
should "wrap a boolean true" do
|
18
|
-
gv = GObject::Value.wrap_ruby_value true
|
19
|
-
assert_instance_of GObject::Value, gv
|
20
|
-
assert_equal true, gv.get_boolean
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "the ruby_value method" do
|
25
|
-
should "unwrap a boolean false" do
|
26
|
-
gv = GObject::Value.wrap_ruby_value false
|
27
|
-
result = gv.ruby_value
|
28
|
-
assert_equal false, result
|
29
|
-
end
|
30
|
-
|
31
|
-
should "unwrap a boolean true" do
|
32
|
-
gv = GObject::Value.wrap_ruby_value true
|
33
|
-
result = gv.ruby_value
|
34
|
-
assert_equal true, result
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
11
|
context "the signal_emit function" do
|
40
12
|
should "emit a signal" do
|
41
13
|
a = 1
|
@@ -158,7 +130,7 @@ class GObjectOverridesTest < MiniTest::Spec
|
|
158
130
|
b = Regress::TestSimpleBoxedA.new
|
159
131
|
|
160
132
|
@gva =
|
161
|
-
|
133
|
+
GObject::Helper.signal_arguments_to_gvalue_array(
|
162
134
|
"test-with-static-scope-arg", o, b)
|
163
135
|
end
|
164
136
|
|
@@ -185,7 +157,7 @@ class GObjectOverridesTest < MiniTest::Spec
|
|
185
157
|
stub(arg_t = Object.new).tag { :utf8 }
|
186
158
|
stub(info = Object.new).argument_type { arg_t }
|
187
159
|
val =
|
188
|
-
|
160
|
+
GObject::Helper.signal_argument_to_gvalue(
|
189
161
|
info, "foo")
|
190
162
|
assert_instance_of GObject::Value, val
|
191
163
|
assert_equal "foo", val.get_string
|
@@ -202,7 +174,7 @@ class GObjectOverridesTest < MiniTest::Spec
|
|
202
174
|
sig = o.class._find_signal sig_name
|
203
175
|
|
204
176
|
@gva =
|
205
|
-
|
177
|
+
GObject::Helper.cast_back_signal_arguments(
|
206
178
|
sig, o.class, o.to_ptr, b.to_ptr, ud)
|
207
179
|
end
|
208
180
|
|
@@ -240,7 +212,7 @@ class GObjectOverridesTest < MiniTest::Spec
|
|
240
212
|
end
|
241
213
|
|
242
214
|
it "casts an integer to its enum symbol" do
|
243
|
-
res =
|
215
|
+
res = GObject::Helper.cast_signal_argument @info, 7
|
244
216
|
assert_equal :july, res
|
245
217
|
end
|
246
218
|
end
|
@@ -301,5 +273,3 @@ class GObjectOverridesTest < MiniTest::Spec
|
|
301
273
|
end
|
302
274
|
end
|
303
275
|
end
|
304
|
-
|
305
|
-
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'ffi-gobject'
|
4
|
+
|
5
|
+
describe GObject do
|
6
|
+
it "has type_init as a public method" do
|
7
|
+
assert GObject.respond_to?('type_init')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "does not have g_type_init as a public method" do
|
11
|
+
assert GObject.respond_to?('g_type_init') == false
|
12
|
+
end
|
13
|
+
|
14
|
+
context "::type_init" do
|
15
|
+
it "does not raise an error" do
|
16
|
+
assert_nothing_raised do
|
17
|
+
GObject.type_init
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'ffi-gobject'
|
4
|
+
|
5
|
+
describe GObject::Value do
|
6
|
+
describe "::wrap_ruby_value class" do
|
7
|
+
it "wraps a boolean false" do
|
8
|
+
gv = GObject::Value.wrap_ruby_value false
|
9
|
+
assert_instance_of GObject::Value, gv
|
10
|
+
assert_equal false, gv.get_boolean
|
11
|
+
end
|
12
|
+
|
13
|
+
it "wraps a boolean true" do
|
14
|
+
gv = GObject::Value.wrap_ruby_value true
|
15
|
+
assert_instance_of GObject::Value, gv
|
16
|
+
assert_equal true, gv.get_boolean
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#ruby_value" do
|
21
|
+
it "unwraps a boolean false" do
|
22
|
+
gv = GObject::Value.wrap_ruby_value false
|
23
|
+
result = gv.ruby_value
|
24
|
+
assert_equal false, result
|
25
|
+
end
|
26
|
+
|
27
|
+
it "unwraps a boolean true" do
|
28
|
+
gv = GObject::Value.wrap_ruby_value true
|
29
|
+
result = gv.ruby_value
|
30
|
+
assert_equal true, result
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe GObjectIntrospection::IBaseInfo do
|
4
4
|
describe "#safe_name" do
|
5
5
|
it "makes names starting with an underscore safe" do
|
6
6
|
stub(ptr = Object.new).null? { false }
|
7
7
|
|
8
|
-
info =
|
8
|
+
info = GObjectIntrospection::IBaseInfo.wrap ptr
|
9
9
|
|
10
10
|
stub(info).name { "_foo" }
|
11
11
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe GObjectIntrospection::IConstantInfo do
|
4
4
|
describe "for GLib::ALLOCATOR_LIST, a constant of type :gint32" do
|
5
5
|
before do
|
6
6
|
@info = get_introspection_data 'GLib', 'ALLOCATOR_LIST'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
module GirFFI
|
4
|
+
class IObjectInfoTest < MiniTest::Spec
|
5
|
+
context "An IObjectInfo object" do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
gir = GObjectIntrospection::IRepository.default
|
9
|
+
gir.require 'GObject', nil
|
10
|
+
@info = gir.find_by_name 'GObject', 'Object'
|
11
|
+
end
|
12
|
+
|
13
|
+
should "find a vfunc by name" do
|
14
|
+
assert_not_nil @info.find_vfunc("finalize")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -1,21 +1,21 @@
|
|
1
1
|
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe GObjectIntrospection::IRepository do
|
4
4
|
describe "an instance" do
|
5
5
|
should "not be created by calling new()" do
|
6
6
|
assert_raises NoMethodError do
|
7
|
-
|
7
|
+
GObjectIntrospection::IRepository.new
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
should "be created by calling default()" do
|
12
|
-
gir =
|
13
|
-
assert_kind_of
|
12
|
+
gir = GObjectIntrospection::IRepository.default
|
13
|
+
assert_kind_of GObjectIntrospection::IRepository, gir
|
14
14
|
end
|
15
15
|
|
16
16
|
should "be a singleton" do
|
17
|
-
gir =
|
18
|
-
gir2 =
|
17
|
+
gir = GObjectIntrospection::IRepository.default
|
18
|
+
gir2 = GObjectIntrospection::IRepository.default
|
19
19
|
assert_equal gir, gir2
|
20
20
|
end
|
21
21
|
end
|
@@ -23,26 +23,26 @@ describe GirFFI::IRepository do
|
|
23
23
|
describe "#namespace" do
|
24
24
|
should "raise an error if the namespace doesn't exist" do
|
25
25
|
assert_raises RuntimeError do
|
26
|
-
|
26
|
+
GObjectIntrospection::IRepository.default.require 'VeryUnlikelyGObjectNamespaceName', nil
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
should "allow version to be nil" do
|
31
31
|
assert_nothing_raised do
|
32
|
-
|
32
|
+
GObjectIntrospection::IRepository.default.require 'GObject', nil
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
should "allow version to be left out" do
|
37
37
|
assert_nothing_raised do
|
38
|
-
|
38
|
+
GObjectIntrospection::IRepository.default.require 'GObject'
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe "enumerating the infos for Gtk" do
|
44
44
|
setup do
|
45
|
-
@gir =
|
45
|
+
@gir = GObjectIntrospection::IRepository.default
|
46
46
|
@gir.require 'Gtk', "2.0"
|
47
47
|
end
|
48
48
|
|
@@ -51,7 +51,7 @@ describe GirFFI::IRepository do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
should "yield IBaseInfo objects" do
|
54
|
-
assert_kind_of
|
54
|
+
assert_kind_of GObjectIntrospection::IBaseInfo, @gir.info('Gtk', 0)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require File.expand_path('test_helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'gir_ffi'
|
4
|
+
|
5
|
+
GObjectIntrospection::IRepository.prepend_search_path File.join(File.dirname(__FILE__), 'lib')
|
6
|
+
module GObjectIntrospection
|
7
|
+
class IRepository
|
8
|
+
def shared_library_with_regress namespace
|
9
|
+
case namespace
|
10
|
+
when "Regress"
|
11
|
+
return File.join(File.dirname(__FILE__), 'lib', 'libregress.so')
|
12
|
+
when "GIMarshallingTests"
|
13
|
+
return File.join(File.dirname(__FILE__), 'lib', 'libgimarshallingtests.so')
|
14
|
+
else
|
15
|
+
return shared_library_without_regress namespace
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
alias shared_library_without_regress shared_library
|
20
|
+
alias shared_library shared_library_with_regress
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Preload data for Gtk+ version 2.0.
|
25
|
+
gir = GObjectIntrospection::IRepository.default
|
26
|
+
gir.require "Gtk", "2.0"
|
27
|
+
|
28
|
+
# Need a dummy module for some tests.
|
29
|
+
module Lib
|
30
|
+
end
|
31
|
+
|
32
|
+
class MiniTest::Unit::TestCase
|
33
|
+
def cws code
|
34
|
+
code.gsub(/(^\s*|\s*$)/, "")
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_method_introspection_data namespace, klass, name
|
38
|
+
get_introspection_data(namespace, klass).find_method name
|
39
|
+
end
|
40
|
+
|
41
|
+
SAVED_MODULES = {}
|
42
|
+
|
43
|
+
def save_module name
|
44
|
+
if Object.const_defined? name
|
45
|
+
puts "Saving #{name} over existing" if SAVED_MODULES.has_key? name
|
46
|
+
SAVED_MODULES[name] = Object.const_get name
|
47
|
+
Object.send(:remove_const, name)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def restore_module name
|
52
|
+
if Object.const_defined? name
|
53
|
+
Object.send(:remove_const, name)
|
54
|
+
end
|
55
|
+
if SAVED_MODULES.has_key? name
|
56
|
+
Object.const_set name, SAVED_MODULES[name]
|
57
|
+
SAVED_MODULES.delete name
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def ref_count object
|
62
|
+
GObject::Object::Struct.new(object.to_ptr)[:ref_count]
|
63
|
+
end
|
64
|
+
|
65
|
+
def is_floating? object
|
66
|
+
(GObject::Object::Struct.new(object.to_ptr)[:qdata].address & 2) == 2
|
67
|
+
end
|
68
|
+
|
69
|
+
def max_for_unsigned_type type
|
70
|
+
( 1 << (FFI.type_size(type) * 8) ) - 1
|
71
|
+
end
|
72
|
+
|
73
|
+
def max_for_type type
|
74
|
+
( 1 << (FFI.type_size(type) * 8 - 1) ) - 1
|
75
|
+
end
|
76
|
+
|
77
|
+
def min_for_type type
|
78
|
+
~max_for_type(type)
|
79
|
+
end
|
80
|
+
|
81
|
+
def max_long
|
82
|
+
max_for_type :long
|
83
|
+
end
|
84
|
+
|
85
|
+
def min_long
|
86
|
+
min_for_type :long
|
87
|
+
end
|
88
|
+
|
89
|
+
def max_size_t
|
90
|
+
max_for_unsigned_type :size_t
|
91
|
+
end
|
92
|
+
|
93
|
+
def max_ssize_t
|
94
|
+
# FFI has no :ssize_t, but it's the same number of bits as :size_t
|
95
|
+
max_for_type :size_t
|
96
|
+
end
|
97
|
+
|
98
|
+
def min_ssize_t
|
99
|
+
min_for_type :size_t
|
100
|
+
end
|
101
|
+
|
102
|
+
def max_ushort
|
103
|
+
max_for_unsigned_type :ushort
|
104
|
+
end
|
105
|
+
|
106
|
+
def max_uint
|
107
|
+
max_for_unsigned_type :uint
|
108
|
+
end
|
109
|
+
|
110
|
+
def max_ulong
|
111
|
+
max_for_unsigned_type :ulong
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
data/test/girffi_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
2
2
|
|
3
3
|
class GirFFITest < MiniTest::Spec
|
4
4
|
context "GirFFI" do
|
@@ -8,7 +8,7 @@ class GirFFITest < MiniTest::Spec
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it "sets up xlib, which has no shared library" do
|
11
|
-
gir =
|
11
|
+
gir = GObjectIntrospection::IRepository.default
|
12
12
|
gir.require 'xlib'
|
13
13
|
assert_nil gir.shared_library('xlib'), "Precondition for test failed"
|
14
14
|
GirFFI.setup :xlib
|
data/test/gtk_overrides_test.rb
CHANGED
@@ -1,32 +1,35 @@
|
|
1
|
-
require File.expand_path('
|
2
|
-
require 'gir_ffi/overrides/gtk'
|
1
|
+
require File.expand_path('gir_ffi_test_helper.rb', File.dirname(__FILE__))
|
3
2
|
|
4
|
-
describe
|
3
|
+
describe "Gtk's overrides" do
|
5
4
|
before do
|
6
|
-
|
5
|
+
save_module :Gtk
|
6
|
+
::Object.const_set :Gtk, Module.new
|
7
|
+
Gtk.class_eval do
|
7
8
|
def self.init arr
|
8
9
|
["baz", "qux", "zonk"]
|
9
10
|
end
|
10
11
|
end
|
11
|
-
stub(
|
12
|
+
stub(Gtk)._setup_method { }
|
12
13
|
|
13
|
-
|
14
|
-
include GirFFI::Overrides::Gtk
|
15
|
-
end
|
14
|
+
load 'ffi-gtk/base.rb'
|
16
15
|
end
|
17
16
|
|
18
17
|
context "The .init function" do
|
19
18
|
should "not take any arguments" do
|
20
|
-
assert_raises(ArgumentError) {
|
21
|
-
assert_raises(ArgumentError) {
|
22
|
-
assert_nothing_raised {
|
19
|
+
assert_raises(ArgumentError) { Gtk.init 1, ["foo"] }
|
20
|
+
assert_raises(ArgumentError) { Gtk.init ["foo"] }
|
21
|
+
assert_nothing_raised { Gtk.init }
|
23
22
|
end
|
24
23
|
|
25
24
|
should "replace ARGV with the tail of the result of the original init function" do
|
26
25
|
ARGV.replace ["foo", "bar"]
|
27
|
-
|
26
|
+
Gtk.init
|
28
27
|
assert_equal ["qux", "zonk"], ARGV.to_a
|
29
28
|
end
|
30
29
|
end
|
30
|
+
|
31
|
+
after do
|
32
|
+
restore_module :Gtk
|
33
|
+
end
|
31
34
|
end
|
32
35
|
|