Sha256: b079bf02493c06d5c482d3e0fc40a3bcc3283e2784a68ad7ba0244fce4796a6e

Contents?: true

Size: 1.96 KB

Versions: 28

Compression:

Stored size: 1.96 KB

Contents

=begin
Copyright 2010, Roger Pack 
This file is part of Sensible Cinema.

    Sensible Cinema is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Sensible Cinema is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Sensible Cinema.  If not, see <http://www.gnu.org/licenses/>.
=end
require File.expand_path(File.dirname(__FILE__) + '/common')
require_relative '../lib/mouse'

p 'dont move the mouse!'

describe Mouse do

  it "should move it a couple times" do
    old = Mouse.total_movements
    begin
    Timeout::timeout(2) {
      Mouse::jitter_forever_in_own_thread.join
    }
    rescue Timeout::Error
    end
    Mouse.total_movements.should be > old
  end
  
  it "should not move it if the user does" do
    old = Mouse.total_movements
    begin
    Timeout::timeout(2) {
      Mouse::jitter_forever_in_own_thread
      x = 1
      loop {java.awt.Robot.new.mouse_move(500 + (x+=1),500); sleep 0.1; }
    }
    rescue Timeout::Error
    end
    Mouse.total_movements.should == old + 1
  end
  
  it "should be able to left mouse click" do
    Mouse.left_mouse_button_state.should be :up
    Mouse.left_mouse_down!
    Mouse.left_mouse_button_state.should be :down
    Mouse.left_mouse_up!
    Mouse.left_mouse_button_state.should be :up
  end
  
  it "should be able to click" do
    Mouse.left_mouse_button_state.should be :up
    Mouse.single_click_left_mouse_button
    Mouse.left_mouse_up!
    Mouse.left_mouse_up!
    Mouse.left_mouse_button_state.should be :up
  end

end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
sensible-cinema-0.26.1 spec/mouse.spec.rb
sensible-cinema-0.26.0 spec/mouse.spec.rb
sensible-cinema-0.25.4 spec/mouse.spec.rb
sensible-cinema-0.25.3 spec/mouse.spec.rb
sensible-cinema-0.25.2 spec/mouse.spec.rb
sensible-cinema-0.25.1 spec/mouse.spec.rb
sensible-cinema-0.25.0 spec/mouse.spec.rb
sensible-cinema-0.24.9 spec/mouse.spec.rb
sensible-cinema-0.24.8 spec/mouse.spec.rb
sensible-cinema-0.24.7 spec/mouse.spec.rb
sensible-cinema-0.24.6 spec/mouse.spec.rb
sensible-cinema-0.24.5 spec/mouse.spec.rb
sensible-cinema-0.24.4 spec/mouse.spec.rb
sensible-cinema-0.24.3 spec/mouse.spec.rb
sensible-cinema-0.24.2 spec/mouse.spec.rb
sensible-cinema-0.24.1 spec/mouse.spec.rb
sensible-cinema-0.24.0 spec/mouse.spec.rb
sensible-cinema-0.23.6 spec/mouse.spec.rb
sensible-cinema-0.23.5 spec/mouse.spec.rb
sensible-cinema-0.23.4 spec/mouse.spec.rb