Update changelog for 0.20.
[tails-test.git] / features / support / helpers / sikuli_helper.rb
blob30ec504ab9395575322b7e95d018d14bc0f8144e
1 require 'sikuli'
3 # Add missing stuff
4 module Sikuli
5   KEY_F1 = Key::F1
6   KEY_F2 = Key::F2
7   KEY_F3 = Key::F3
8   KEY_F4 = Key::F4
9   KEY_F5 = Key::F5
10   KEY_F6 = Key::F6
11   KEY_F7 = Key::F7
12   KEY_F8 = Key::F8
13   KEY_F9 = Key::F9
14   KEY_F10 = Key::F10
15   KEY_F11 = Key::F11
16   KEY_F12 = Key::F12
17   KEY_ESC = Key::ESC
18 end
20 module Sikuli::Clickable
21   def hover(x, y)
22     @java_obj.hover(org.sikuli.script::Location.new(x, y).offset(x(), y()))
23   end
24 end
26 class Sikuli::Region
27   def wait_and_click(pic, time)
28     # It's undocumented, but wait() returns the matched region, so we
29     # compute the middle of it and click() there instead of letting
30     # click() scan for the picture again.
31     r = self.wait(pic, time)
32     x = r.x + r.width/2
33     y = r.y + r.height/2
34     self.click(x, y)
35   end
36 end
38 class Sikuli::Screen
39   def hide_cursor()
40     hover(self.width, self.height/2)
41   end
42 end
44 # Configure sikuli
45 Sikuli::Config.run do |config|
46   config.image_path = "#{Dir.pwd}/features/images/"
47   config.logging = false
48   config.highlight_on_find = false
49 end