Sha256: bd38bad9d0419df9a563b7be8bdf535cf34b86a06b3279f40236dae9905ea1c5

Contents?: true

Size: 1.79 KB

Versions: 2

Compression:

Stored size: 1.79 KB

Contents

require 'gir_ffi_test_helper'

describe GirFFI::InfoExt::ISignalInfo do
  let(:klass) { Class.new do
    include GirFFI::InfoExt::ISignalInfo
  end }
  let(:signal_info) { klass.new }

  describe "#cast_back_signal_arguments" do
    # TODO: Move to integration tests
    it "correctly casts back pointers for the test-with-static-scope-arg signal" do
      o = Regress::TestSubObj.new
      b = Regress::TestSimpleBoxedA.new
      ud = GirFFI::ArgHelper.object_to_inptr "Hello!"

      assert_equal "Hello!", GirFFI::ArgHelper::OBJECT_STORE[ud.address]

      sig = o.class.find_signal "test-with-static-scope-arg"

      gva = sig.cast_back_signal_arguments(o.to_ptr, b.to_ptr, ud)

      klasses = gva.map {|it| it.class}
      klasses.must_equal [ Regress::TestSubObj,
                           Regress::TestSimpleBoxedA,
                           String ]
      gva[2].must_equal "Hello!"
    end
  end

  describe "#signal_arguments_to_gvalue_array" do
    # TODO: Move to integration tests
    describe "the result of wrapping test-with-static-scope-arg" do
      setup do
        o = Regress::TestSubObj.new
        b = Regress::TestSimpleBoxedA.new
        sig = o.class.find_signal "test-with-static-scope-arg"

        @gva = sig.signal_arguments_to_gvalue_array(o, b)
      end

      should "be a GObject::ValueArray" do
        assert_instance_of GObject::ValueArray, @gva
      end

      should "contain two values" do
        assert_equal 2, @gva.n_values
      end

      should "have a first value with GType for TestSubObj" do
        assert_equal Regress::TestSubObj.get_gtype, (@gva.get_nth 0).current_gtype
      end

      should "have a second value with GType for TestSimpleBoxedA" do
        assert_equal Regress::TestSimpleBoxedA.get_gtype, (@gva.get_nth 1).current_gtype
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gir_ffi-0.6.5 test/gir_ffi/info_ext/i_signal_info_test.rb
gir_ffi-0.6.4 test/gir_ffi/info_ext/i_signal_info_test.rb