Sha256: a950d5d4ab8ff36aafce77398faee079d6f385b81774aca59ebf32e2e265922d

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require 'test_helper'

describe Gtk do
  describe '::init' do
    before do
      module DummyGtk
        def self.init(_arr)
          %w(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 %w(foo bar)
      DummyGtk.init
      assert_equal %w(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

1 entries across 1 versions & 1 rubygems

Version Path
gir_ffi-gtk-0.15.0 test/gir_ffi-gtk/base_test.rb