Newer
Older
require 'testcase'
require 'socket'
class TC_FXApp < Test::Unit::TestCase
def test_exception_for_second_app
app = FXApp.new
mainWindow = FXMainWindow.new(app, "")
app.create
assert_raise RuntimeError do
app2 = FXApp.new
end
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class TC_FXApp2 < TestCase
def setup
super(self.class.name)
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
app.removeInput(pipe_rd, INPUT_READ)
pipe_wr.close
pipe_rd.close
assert data_sent, "the read input event shouldn't fire before some data is available"
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
end