Sha256: cb74d31190d3ed730d45ebf7b684ec94ff674253801ce5f24e398b0276314e6d

Contents?: true

Size: 794 Bytes

Versions: 4

Compression:

Stored size: 794 Bytes

Contents

require_relative 'em_test_helper'

class TestKeyboardEvents < Test::Unit::TestCase

  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
    omit_if(jruby?)
    omit_if(!$stdout.tty?) # don't run the test unless it stands a chance of validity.
    EM.run do
      EM.open_keyboard KbHandler
      EM::Timer.new(1) { EM.stop }
    end
  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
eventmachine-mkroman-1.3.0.dev.1 tests/test_kb.rb
wj_eventmachine-1.3.2 tests/test_kb.rb
wj_eventmachine-1.3.1 tests/test_kb.rb
wj_eventmachine-1.3.0.dev.1 tests/test_kb.rb