Sha256: 1c79eba443679128cdc6b63911405ca35f7b0e871728d87ab95df7812312a08a
Contents?: true
Size: 1.81 KB
Versions: 3
Compression:
Stored size: 1.81 KB
Contents
require 'gir_ffi_test_helper' require "gir_ffi/callback_helper" describe GirFFI::CallbackHelper do describe "::map_single_callback_arg" do it "maps a :struct type by building the type and wrapping the argument in it" do cinfo = get_introspection_data 'GObject', 'ClosureMarshal' ainfo = cinfo.args[0] ifinfo = ainfo.argument_type.interface assert_equal :struct, ifinfo.info_type struct_class = Class.new mock(GirFFI::Builder).build_class(ifinfo) { struct_class } mock(struct_class).wrap("dummy") { "good-result" } r = GirFFI::CallbackHelper.map_single_callback_arg "dummy", ainfo.argument_type assert_equal "good-result", r end it "maps an :interface type by calling #to_object on the argument" do cinfo = get_introspection_data 'Gtk', 'CellLayoutDataFunc' ainfo = cinfo.args[0] ifinfo = ainfo.argument_type.interface assert_equal :interface, ifinfo.info_type mock(ptr = Object.new).to_object { "good-result" } r = GirFFI::CallbackHelper.map_single_callback_arg ptr, ainfo.argument_type assert_equal "good-result", r end it "maps an :object type by calling #to_object on the argument" do cinfo = get_introspection_data 'Gtk', 'CellLayoutDataFunc' ainfo = cinfo.args[1] ifinfo = ainfo.argument_type.interface assert_equal :object, ifinfo.info_type mock(ptr = Object.new).to_object { "good-result" } r = GirFFI::CallbackHelper.map_single_callback_arg ptr, ainfo.argument_type assert_equal "good-result", r end end describe ".store_callback" do it "stores the passed in proc in GirFFI::CallbackHelper::CALLBACKS" do GirFFI::CallbackHelper.store_callback "some-callback" GirFFI::CallbackHelper::CALLBACKS.last.must_equal "some-callback" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gir_ffi-0.5.2 | test/gir_ffi/callback_helper_test.rb |
gir_ffi-0.5.1 | test/gir_ffi/callback_helper_test.rb |
gir_ffi-0.5.0 | test/gir_ffi/callback_helper_test.rb |