Sha256: 07c700c658683a6ac4ac18049de79e8ab81a160956b2b75e9c612a18a30a3428

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

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,
                       proc { Gtk.main_quit },
                       nil, nil)

      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

2 entries across 2 versions & 1 rubygems

Version Path
gir_ffi-gtk-0.8.1 test/gir_ffi-gtk/base_test.rb
gir_ffi-gtk-0.8.0 test/gir_ffi-gtk/base_test.rb