Sha256: 83becdcaf7c72308b937ed7a2c87a95b17985c54e5d73a91225a58d9fcf9ba7f

Contents?: true

Size: 1.87 KB

Versions: 3

Compression:

Stored size: 1.87 KB

Contents

# frozen_string_literal: true
require 'gir_ffi_test_helper'

GirFFI.setup :Gio
GirFFI.setup :Gst
Gst.init []

describe GirFFI::Builders::UnintrospectableBuilder do
  describe 'building the GLocalFile type' do
    before do
      Gio.file_new_for_path '/'

      @gtype = GObject.type_from_name 'GLocalFile'
      @info = GirFFI::UnintrospectableTypeInfo.new(@gtype)
      @bldr = GirFFI::Builders::UnintrospectableBuilder.new(@info)
      @klass = @bldr.build_class
    end

    it 'builds a class' do
      assert_instance_of Class, @klass
    end

    it 'builds a class derived from GObject::Object' do
      assert_includes @klass.ancestors, GObject::Object
    end

    it 'builds a class derived from Gio::File' do
      assert_includes @klass.ancestors, Gio::File
    end

    it 'returns the same class when built again' do
      other_bldr = GirFFI::Builders::UnintrospectableBuilder.new(@info)
      other_klass = other_bldr.build_class

      assert_equal @klass, other_klass
    end

    describe 'its #find_signal method' do
      it "returns nil for a signal that doesn't exist" do
        @bldr.find_signal('foo').must_be_nil
      end

      it 'finds signals in ancestor classes' do
        signal = @bldr.find_signal 'notify'
        signal.name.must_equal 'notify'
      end
    end

    describe '#object_class_struct' do
      it 'returns the parent class struct' do
        @bldr.object_class_struct.must_equal GObject::ObjectClass
      end
    end
  end

  describe 'building the GstFakeSink type' do
    let(:instance) { Gst::ElementFactory.make('fakesink', 'sink') }
    let(:klass) { instance.class }
    let(:builder) { klass.gir_ffi_builder }

    describe 'its #find_signal method' do
      it 'finds signals that are not defined in the GIR' do
        signal = builder.find_signal 'handoff'
        signal.wont_be_nil
        signal.name.must_equal 'handoff'
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-0.9.5 test/gir_ffi/builders/unintrospectable_builder_test.rb
gir_ffi-0.9.4 test/gir_ffi/builders/unintrospectable_builder_test.rb
gir_ffi-0.9.3 test/gir_ffi/builders/unintrospectable_builder_test.rb