File: test_kb.rb

package info (click to toggle)
ruby-eventmachine 1.0.3-6%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,000 kB
  • ctags: 3,178
  • sloc: ruby: 8,641; cpp: 5,217; java: 827; makefile: 5
file content (34 lines) | stat: -rw-r--r-- 1,031 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'em_test_helper'

class TestKeyboardEvents < Test::Unit::TestCase

  if !jruby?
    module KbHandler
      include EM::Protocols::LineText2
      def receive_line d
        EM::stop if d == "STOP"
      end
    end

    # This test doesn't actually do anything useful but is here to
    # illustrate the usage. If you removed the timer and ran this test
    # by itself on a console, and then typed into the console, it would
    # work.
    # I don't know how to get the test harness to simulate actual keystrokes.
    # When someone figures that out, then we can make this a real test.
    #
    def test_kb
      EM.run {
        EM.open_keyboard KbHandler
        EM::Timer.new(1) { EM.stop }
      } if $stdout.tty? # don't run the test unless it stands a chance of validity.
    end
  else
    warn "EM.open_keyboard not implemented, skipping tests in #{__FILE__}"

    # Because some rubies will complain if a TestCase class has no tests
    def test_em_open_keyboard_unsupported
      assert true
    end
  end
end