Sha256: c1ae08de07c36703404a750b1206d2c5e356bd966ed3e322ae4a7189c2ca6a05
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') include Mac::EventMonitor describe Monitor do before do @monitor = Monitor.new end it 'should monitor mouse down events' do result = 0 robot = Mac::Robot.new @monitor.add_listener(:mouse_down) do |event| result += 1 end result.should be_zero EM.run do [1, 1.5].each do |t| EM.add_timer(t) do robot.mouse_press end end EM.add_timer(2) do EM.stop end EM.add_periodic_timer(0.1) do @monitor.run(0.1) end end result.should be >= 2 end it 'should monitor key down events' do result = 0 robot = Mac::Robot.new @monitor.add_listener(:key_down) do |event| result += 1 end result.should be_zero EM.run do [1, 1.5].each do |t| EM.add_timer(t) do robot.key_press(0x04) end end EM.add_timer(2) do EM.stop end EM.add_periodic_timer(0.1) do @monitor.run(0.1) end end result.should be >= 2 end it 'should monitor all' do result = 0 robot = Mac::Robot.new @monitor.add_listener do |event| result += 1 end result.should be_zero EM.run do [1, 1.5].each do |t| EM.add_timer(t) do robot.mouse_press end end [2, 2.5].each do |t| EM.add_timer(t) do robot.key_press(0x04) end end EM.add_timer(3) do EM.stop end EM.add_periodic_timer(0.1) do @monitor.run(0.1) end end result.should be >= 4 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mac-event-monitor-0.2.1 | spec/mac-event-monitor/monitor_spec.rb |
mac-event-monitor-0.2.0 | spec/mac-event-monitor/monitor_spec.rb |