Sha256: ffb1be3c11b74d37ce6f92bfe96e456d4bba97d06e002dcc34184b677a353a97

Contents?: true

Size: 1.38 KB

Versions: 21

Compression:

Stored size: 1.38 KB

Contents

require 'test/unit'
require 'fox16'
require 'testcase'
require 'socket'

class TC_FXApp < Test::Unit::TestCase
  include Fox

  def test_exception_for_second_app
    app = FXApp.new
    mainWindow = FXMainWindow.new(app, "")
    app.create
    assert_raise RuntimeError do
      app2 = FXApp.new
    end
  end
end

class TC_FXApp2 < Fox::TestCase
  include Fox

  def setup
    super(self.class.name)
  end

  def test_nil_window_raises_argument_error
    assert_raise(ArgumentError){ app.runPopup(nil) }
  end

  def check_events(pipe_rd, pipe_wr)
    app.addInput(pipe_wr, INPUT_WRITE, app, FXApp::ID_QUIT)
    app.run
    app.removeInput(pipe_wr, INPUT_WRITE)

    app.addInput(pipe_rd, INPUT_READ, app, FXApp::ID_QUIT)
    data_sent = false
    app.addTimeout(1) do
      data_sent = true
      pipe_wr.write " "
    end
    app.run
    assert data_sent, "the read input event shouldn't fire before some data is available"

    app.removeInput(pipe_rd, INPUT_READ)
    pipe_wr.close
    pipe_rd.close unless pipe_rd.closed?
  end

  def test_addInput_on_pipe
    check_events *IO.pipe
  end

  def test_addInput_on_socket
    s = TCPServer.open 'localhost', 0
    pipe_wr = TCPSocket.open 'localhost', s.addr[1]
    pipe_rd = s.accept
    s.close

    check_events pipe_rd, pipe_wr
  end

  def test_addInput_on_popen
    pipe_rdwr = IO.popen("cat", "r+")
    check_events pipe_rdwr, pipe_rdwr
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
fxruby-1.6.29-x86-mingw32 test/TC_FXApp.rb
fxruby-1.6.29-x64-mingw32 test/TC_FXApp.rb
fxruby-1.6.29 test/TC_FXApp.rb
fxruby-1.6.28-x86-mingw32 test/TC_FXApp.rb
fxruby-1.6.28-x64-mingw32 test/TC_FXApp.rb
fxruby-1.6.28 test/TC_FXApp.rb
fxruby-1.6.27-x86-mingw32 test/TC_FXApp.rb
fxruby-1.6.27-x64-mingw32 test/TC_FXApp.rb
fxruby-1.6.27 test/TC_FXApp.rb
fxruby-1.6.26-x86-mingw32 test/TC_FXApp.rb
fxruby-1.6.26 test/TC_FXApp.rb
fxruby-1.6.26.pre1-x86-mingw32 test/TC_FXApp.rb
fxruby-1.6.26.pre1 test/TC_FXApp.rb
fxruby-1.6.25-x86-mingw32 test/TC_FXApp.rb
fxruby-1.6.25 test/TC_FXApp.rb
fxruby-1.6.25.pre2-x86-mingw32 test/TC_FXApp.rb
fxruby-1.6.25.pre2 test/TC_FXApp.rb
fxruby-1.6.25.pre1-x86-mingw32 test/TC_FXApp.rb
fxruby-1.6.25.pre1 test/TC_FXApp.rb
fxruby-1.6.24-x86-mingw32 test/TC_FXApp.rb