Sha256: 6ee1c40e5a586ae5ad3481870e7e7623bfd2d54a5a946a5df39abc1831f5ac5a

Contents?: true

Size: 1.71 KB

Versions: 1

Compression:

Stored size: 1.71 KB

Contents

# $Id$
#
# Author:: Francis Cianfrocca (gmail: blackhedd)
# Homepage::  http://rubyeventmachine.com
# Date:: 8 April 2006
# 
# See EventMachine and EventMachine::Connection for documentation and
# usage examples.
#
#----------------------------------------------------------------------------
#
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
# Gmail: blackhedd
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of either: 1) the GNU General Public License
# as published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version; or 2) Ruby's License.
# 
# See the file COPYING for complete licensing information.
#
#---------------------------------------------------------------------------
#
#
#

$:.unshift "../lib"
require 'eventmachine'
require 'test/unit'

class TestKeyboardEvents < Test::Unit::TestCase

  def setup
  end

  def teardown
  end

  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
      if $stdout.tty? # don't run the test unless it stands a chance of validity.
  	    EM.run {
  		    EM.open_keyboard KbHandler
  		    EM::Timer.new(1) { EM.stop }
  	    }
      else # but at least do something to keep Test::Unit happy
        assert true
      end
    end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
careo-eventmachine-0.12.5.1 tests/test_kb.rb