OSDN Git Service

Replaced mongrel with thin
[redminele/redminele.git] / ruby / lib / ruby / gems / 1.8 / gems / eventmachine-0.12.10-x86-mswin32-60 / tests / test_kb.rb
1 # $Id$\r
2 #\r
3 # Author:: Francis Cianfrocca (gmail: blackhedd)\r
4 # Homepage::  http://rubyeventmachine.com\r
5 # Date:: 8 April 2006\r
6\r
7 # See EventMachine and EventMachine::Connection for documentation and\r
8 # usage examples.\r
9 #\r
10 #----------------------------------------------------------------------------\r
11 #\r
12 # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.\r
13 # Gmail: blackhedd\r
14\r
15 # This program is free software; you can redistribute it and/or modify\r
16 # it under the terms of either: 1) the GNU General Public License\r
17 # as published by the Free Software Foundation; either version 2 of the\r
18 # License, or (at your option) any later version; or 2) Ruby's License.\r
19\r
20 # See the file COPYING for complete licensing information.\r
21 #\r
22 #---------------------------------------------------------------------------\r
23 #\r
24 #\r
25 #\r
26 \r
27 $:.unshift "../lib"\r
28 require 'eventmachine'\r
29 require 'test/unit'\r
30 \r
31 class TestKeyboardEvents < Test::Unit::TestCase\r
32 \r
33   def setup\r
34   end\r
35 \r
36   def teardown\r
37   end\r
38 \r
39   module KbHandler\r
40     include EM::Protocols::LineText2\r
41     def receive_line d\r
42       EM::stop if d == "STOP"\r
43     end\r
44   end\r
45 \r
46   # This test doesn't actually do anything useful but is here to\r
47   # illustrate the usage. If you removed the timer and ran this test\r
48   # by itself on a console, and then typed into the console, it would\r
49   # work.\r
50   # I don't know how to get the test harness to simulate actual keystrokes.\r
51   # When someone figures that out, then we can make this a real test.\r
52   #\r
53   def test_kb\r
54     EM.run {\r
55       EM.open_keyboard KbHandler\r
56       EM::Timer.new(1) { EM.stop }\r
57     } if $stdout.tty? # don't run the test unless it stands a chance of validity.\r
58   end\r
59 \r
60 end\r