Sha256: 6b0f91ca94f62f24b7ae2e93438bad993a9a7cca09957fabb08586e84d2c4773

Contents?: true

Size: 1023 Bytes

Versions: 5

Compression:

Stored size: 1023 Bytes

Contents

require 'test_helper'

describe Gtk do
  describe "::init" do
    before do
      module DummyGtk
        def self.init arr
          ["baz", "qux", "zonk"]
        end

        include GirFFIGtk::AutoArgv
      end
    end

    it "does not take any arguments" do
      assert_raises(ArgumentError) { DummyGtk.init 1, ["foo"] }
      assert_raises(ArgumentError) { DummyGtk.init ["foo"] }
      assert_nothing_raised { DummyGtk.init }
    end

    it "replaces ARGV with the tail of the result of the original init function" do
      ARGV.replace ["foo", "bar"]
      DummyGtk.init
      assert_equal ["qux", "zonk"], ARGV.to_a
    end
  end

  describe "::main" do
    it "allows other threads to run" do
      a = []
      GLib.timeout_add(GLib::PRIORITY_DEFAULT, 150) { Gtk.main_quit }

      slow_thread = Thread.new do
        sleep 0.005
        a << "During run"
      end

      a << "Before run"
      Gtk.main
      a << "After run"

      slow_thread.join

      a.last.must_equal "After run"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gir_ffi-gtk-0.12.1 test/gir_ffi-gtk/base_test.rb
gir_ffi-gtk-0.12.0 test/gir_ffi-gtk/base_test.rb
gir_ffi-gtk-0.11.0 test/gir_ffi-gtk/base_test.rb
gir_ffi-gtk-0.10.0 test/gir_ffi-gtk/base_test.rb
gir_ffi-gtk-0.9.0 test/gir_ffi-gtk/base_test.rb