Skip to content
Snippets Groups Projects
Commit 42b5d260 authored by Lars Kanis's avatar Lars Kanis
Browse files

Add a test case for FXApp#addInput for socket accept()

parent 58b4ec65
No related branches found
No related tags found
No related merge requests found
......@@ -33,14 +33,16 @@ class TC_FXApp2 < Fox::TestCase
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 " "
2.times do
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"
assert " ", pipe_rd.read(1)
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?
......@@ -50,6 +52,22 @@ class TC_FXApp2 < Fox::TestCase
check_events *IO.pipe
end
def test_addInput_on_socket_accept
s = TCPServer.open 'localhost', 0
app.addInput(s, INPUT_READ, app, FXApp::ID_QUIT)
2.times do
pipe_wr = nil
app.addTimeout(1) do
pipe_wr = TCPSocket.open 'localhost', s.addr[1]
end
app.run
assert pipe_wr, "the read input event shouldn't fire before client connection happens"
s.accept.close
end
app.removeInput(s, INPUT_READ)
s.close
end
def test_addInput_on_socket
s = TCPServer.open 'localhost', 0
pipe_wr = TCPSocket.open 'localhost', s.addr[1]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment