Commit 1fe59247 authored by Tails developers's avatar Tails developers
Browse files

Make test suite use native ruby + rjb instead of JRuby etc.

parent 4a2503f1
#!/usr/bin/env bash
# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
# Only full ruby name is supported here, for short names use:
# echo "rvm use jruby" > .rvmrc
environment_id="jruby-1.6.8"
# Uncomment the following lines if you want to verify rvm version per project
# rvmrc_rvm_version="1.14.1 ()" # 1.10.1 seams as a safe start
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
# return 1
# }
# Uncomment following line if you want options to be set only for given project.
PROJECT_JRUBY_OPTS=( --1.9 )
# The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
# chmod +x ${rvm_path}/hooks/after_use_jruby_opts
# First we attempt to load the desired environment directly from the environment
# file. This is very fast and efficient compared to running through the entire
# CLI and selector. If you want feedback on which environment was used then
# insert the word 'use' after --create as this triggers verbose mode.
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
then
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
if [[ $- == *i* ]] # check for interactive shells
then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
else echo "Using: $GEM_HOME" # don't use colors in non-interactive shells
fi
else
# If the environment file has not yet been created, use the RVM CLI to select.
rvm --create use "$environment_id" || {
echo "Failed to create RVM environment '${environment_id}'."
return 1
}
fi
......@@ -43,7 +43,7 @@ When /^I update APT using Synaptic$/ do
# one there's no easy way to reliably wait for the latter. Hence we
# spam reload until it's performed, which is easier to detect.
try_for(60, :msg => "Failed to reload the package list in Synaptic") {
@screen.type("r", Sikuli::KEY_CTRL)
@screen.type("r", Sikuli::KeyModifier.CTRL)
@screen.find('SynapticReloadPrompt.png')
}
@screen.waitVanish('SynapticReloadPrompt.png', 30*60)
......@@ -55,17 +55,17 @@ Then /^I should be able to install a package using Synaptic$/ do
# We do this after a Reload, so the interface will be frozen until
# the package list has been loaded
try_for(60, :msg => "Failed to open the Synaptic 'Find' window") {
@screen.type("f", Sikuli::KEY_CTRL) # Find key
@screen.type("f", Sikuli::KeyModifier.CTRL) # Find key
@screen.find('SynapticSearch.png')
}
@screen.type(package + Sikuli::KEY_RETURN)
@screen.type(package + Sikuli::Key.ENTER)
@screen.wait_and_click('SynapticCowsaySearchResult.png', 20)
sleep 5
@screen.type("i", Sikuli::KEY_CTRL) # Mark for installation
@screen.type("i", Sikuli::KeyModifier.CTRL) # Mark for installation
sleep 5
@screen.type("p", Sikuli::KEY_CTRL) # Apply
@screen.type("p", Sikuli::KeyModifier.CTRL) # Apply
@screen.wait('SynapticApplyPrompt.png', 60)
@screen.type("a", Sikuli::KEY_ALT) # Verify apply
@screen.type("a", Sikuli::KeyModifier.ALT) # Verify apply
@screen.wait('SynapticChangesAppliedPrompt.png', 120)
step "package \"#{package}\" is installed"
end
......@@ -5,7 +5,7 @@ def post_vm_start_hook
# focus to virt-viewer or similar) so we do that now rather than
# having an important click lost. The point we click should be
# somewhere where no clickable elements generally reside.
@screen.click(@screen.width, @screen.height/2)
@screen.click_point(@screen.w, @screen.h/2)
end
def activate_filesystem_shares
......@@ -153,10 +153,10 @@ Given /^the computer boots Tails$/ do
next if @skip_steps_while_restoring_background
@screen.wait('TailsBootSplash.png', 30)
@screen.wait('TailsBootSplashTabMsg.png', 10)
@screen.type("\t")
@screen.type(Sikuli::Key.TAB)
@screen.waitVanish('TailsBootSplashTabMsg.png', 1)
@screen.type(" autotest_never_use_this_option #{@boot_options}" +
Sikuli::KEY_RETURN)
Sikuli::Key.ENTER)
@screen.wait('TailsGreeter.png', 15*60)
@vm.wait_until_remote_shell_is_up
activate_filesystem_shares
......@@ -170,11 +170,7 @@ end
Given /^I enable more Tails Greeter options$/ do
next if @skip_steps_while_restoring_background
match = @screen.find('TailsGreeterMoreOptions.png')
pos_x = match.x + match.width/2
# height*2 may seem odd, but we want to click the button below the
# match. This may even work accross different screen resolutions.
pos_y = match.y + match.height*2
@screen.click(pos_x, pos_y)
@screen.click(match.getCenter.offset(match.w/2, match.h*2))
@screen.wait_and_click('TailsGreeterForward.png', 10)
@screen.wait('TailsGreeterLoginButton.png', 20)
end
......@@ -184,12 +180,8 @@ Given /^I set sudo password "([^"]*)"$/ do |password|
next if @skip_steps_while_restoring_background
@screen.wait("TailsGreeterAdminPassword.png", 20)
match = @screen.find('TailsGreeterPassword.png')
# width*3 may seem odd, but we want to click the field right of the
# match. This may even work accross different screen resolutions.
pos_x = match.x + match.width*3
pos_y = match.y + match.height/2
@screen.click(pos_x, pos_y)
@screen.type(@sudo_password + "\t" + @sudo_password)
@screen.click(match.getCenter.offset(match.w*3, match.h/2))
@screen.type(@sudo_password + Sikuli::Key.TAB + @sudo_password)
end
Given /^Tails Greeter has dealt with the sudo password$/ do
......@@ -247,8 +239,8 @@ Given /^Iceweasel has autostarted and is not loading a web page$/ do
# from getting confused in case we save and restore a snapshot in
# the middle of loading a page.
@screen.wait_and_click(iceweasel_picture, 120)
@screen.type("l", Sikuli::KEY_CTRL)
@screen.type("about:blank" + Sikuli::KEY_RETURN)
@screen.type("l", Sikuli::KeyModifier.CTRL)
@screen.type("about:blank" + Sikuli::Key.ENTER)
end
Given /^I have closed all annoying notifications$/ do
......@@ -272,9 +264,9 @@ Given /^I have closed all annoying notifications$/ do
# have the positions from before we start closing notificatios,
# but closing them will change the positions.
while match = @screen.find(notification_picture)
@screen.click(match.x + match.width/2, match.y + match.height/2)
@screen.click(match)
end
rescue Sikuli::ImageNotFound
rescue FindFailed
# noop
end
end
......@@ -340,7 +332,7 @@ end
When /^I open the GNOME run dialog$/ do
next if @skip_steps_while_restoring_background
@screen.type(Sikuli::KEY_F2, Sikuli::KEY_ALT)
@screen.type(Sikuli::Key.F2, Sikuli::KeyModifier.ALT)
case @theme
when "winxp"
run_dialog_picture = 'WinXPRunDialog.png'
......@@ -353,7 +345,7 @@ end
When /^I run "([^"]*)"$/ do |program|
next if @skip_steps_while_restoring_background
step "I open the GNOME run dialog"
@screen.type(program + Sikuli::KEY_RETURN)
@screen.type(program + Sikuli::Key.ENTER)
end
Given /^I enter the sudo password in the gksu prompt$/ do
......@@ -361,7 +353,7 @@ Given /^I enter the sudo password in the gksu prompt$/ do
@screen.wait('GksuAuthPrompt.png', 60)
sleep 1 # wait for weird fade-in to unblock the "Ok" button
@screen.type(@sudo_password)
@screen.type(Sikuli::KEY_RETURN)
@screen.type(Sikuli::Key.ENTER)
@screen.waitVanish('GksuAuthPrompt.png', 10)
end
......@@ -375,7 +367,7 @@ Given /^I enter the "([^"]*)" password in the PolicyKit prompt$/ do |password|
@screen.wait('PolicyKitAuthPrompt.png', 60)
sleep 1 # wait for weird fade-in to unblock the "Ok" button
@screen.type(password)
@screen.type(Sikuli::KEY_RETURN)
@screen.type(Sikuli::Key.ENTER)
@screen.waitVanish('PolicyKitAuthPrompt.png', 10)
end
......
......@@ -32,8 +32,8 @@ end
def maybe_deal_with_pinentry
begin
@screen.wait("PinEntryPrompt.png", 3)
@screen.type(@passphrase + Sikuli::KEY_RETURN)
rescue Sikuli::ImageNotFound
@screen.type(@passphrase + Sikuli::Key.ENTER)
rescue FindFailed
# The passphrase was cached or we wasn't prompted at all (e.g. when
# only encrypting to a public key)
end
......@@ -41,7 +41,7 @@ end
def encrypt_sign_helper
@screen.wait_and_click("GeditWindow.png", 10)
@screen.type("a", Sikuli::KEY_CTRL)
@screen.type("a", Sikuli::KeyModifier.CTRL)
sleep 0.5
@screen.click("GpgAppletIconNormal.png")
sleep 2
......@@ -52,14 +52,14 @@ def encrypt_sign_helper
maybe_deal_with_pinentry
@screen.wait_and_click("GeditWindow.png", 10)
sleep 0.5
@screen.type("n", Sikuli::KEY_CTRL)
@screen.type("n", Sikuli::KeyModifier.CTRL)
sleep 0.5
@screen.type("v", Sikuli::KEY_CTRL)
@screen.type("v", Sikuli::KeyModifier.CTRL)
end
def decrypt_verify_helper(icon)
@screen.wait_and_click("GeditWindow.png", 10)
@screen.type("a", Sikuli::KEY_CTRL)
@screen.type("a", Sikuli::KeyModifier.CTRL)
sleep 0.5
@screen.click(icon)
sleep 2
......@@ -72,7 +72,7 @@ end
When /^I encrypt the message using my OpenPGP key$/ do
next if @skip_steps_while_restoring_background
encrypt_sign_helper do
@screen.type(@key_name + Sikuli::KEY_RETURN + Sikuli::KEY_RETURN)
@screen.type(@key_name + Sikuli::Key.ENTER + Sikuli::Key.ENTER)
end
end
......@@ -85,9 +85,9 @@ end
When /^I sign the message using my OpenPGP key$/ do
next if @skip_steps_while_restoring_background
encrypt_sign_helper do
@screen.type("\t" + Sikuli::DOWN_ARROW + Sikuli::KEY_RETURN)
@screen.type(Sikuli::Key.TAB + Sikuli::Key.DOWN + Sikuli::Key.ENTER)
@screen.wait("PinEntryPrompt.png", 10)
@screen.type(@passphrase + Sikuli::KEY_RETURN)
@screen.type(@passphrase + Sikuli::Key.ENTER)
end
end
......@@ -100,10 +100,10 @@ end
When /^I both encrypt and sign the message using my OpenPGP key$/ do
next if @skip_steps_while_restoring_background
encrypt_sign_helper do
@screen.type(@key_name + Sikuli::KEY_RETURN)
@screen.type("\t" + Sikuli::DOWN_ARROW + Sikuli::KEY_RETURN)
@screen.type(@key_name + Sikuli::Key.ENTER)
@screen.type(Sikuli::Key.TAB + Sikuli::Key.DOWN + Sikuli::Key.ENTER)
@screen.wait("PinEntryPrompt.png", 10)
@screen.type(@passphrase + Sikuli::KEY_RETURN)
@screen.type(@passphrase + Sikuli::Key.ENTER)
end
end
......@@ -118,19 +118,19 @@ When /^I symmetrically encrypt the message with password "([^"]+)"$/ do |pwd|
@passphrase = pwd
next if @skip_steps_while_restoring_background
@screen.wait_and_click("GeditWindow.png", 10)
@screen.type("a", Sikuli::KEY_CTRL)
@screen.type("a", Sikuli::KeyModifier.CTRL)
sleep 0.5
@screen.click("GpgAppletIconNormal.png")
sleep 2
@screen.type("p")
@screen.wait("PinEntryPrompt.png", 10)
@screen.type(@passphrase + Sikuli::KEY_RETURN)
@screen.type(@passphrase + Sikuli::Key.ENTER)
sleep 1
@screen.wait("PinEntryPrompt.png", 10)
@screen.type(@passphrase + Sikuli::KEY_RETURN)
@screen.type(@passphrase + Sikuli::Key.ENTER)
@screen.wait_and_click("GeditWindow.png", 10)
sleep 0.5
@screen.type("n", Sikuli::KEY_CTRL)
@screen.type("n", Sikuli::KeyModifier.CTRL)
sleep 0.5
@screen.type("v", Sikuli::KEY_CTRL)
@screen.type("v", Sikuli::KeyModifier.CTRL)
end
......@@ -28,7 +28,7 @@ Then /^I should be able to run a command as root with pkexec$/ do
next if @skip_steps_while_restoring_background
step 'I run "gnome-terminal"'
@screen.wait_and_click('GnomeTerminalWindow.png', 20)
@screen.type('pkexec touch /root/pkexec-test' + Sikuli::KEY_RETURN)
@screen.type('pkexec touch /root/pkexec-test' + Sikuli::Key.ENTER)
step 'I enter the sudo password in the PolicyKit prompt'
try_for(10, :msg => 'The /root/pkexec-test file was not created.') {
@vm.execute('ls /root/pkexec-test').success?
......@@ -39,7 +39,7 @@ Then /^I should not be able to run a command as root with pkexec and the standar
next if @skip_steps_while_restoring_background
step 'I run "gnome-terminal"'
@screen.wait_and_click('GnomeTerminalWindow.png', 20)
@screen.type('pkexec touch /root/pkexec-test' + Sikuli::KEY_RETURN)
@screen.type('pkexec touch /root/pkexec-test' + Sikuli::Key.ENTER)
['', 'live'].each do |password|
step "I enter the \"#{password}\" password in the PolicyKit prompt"
@screen.wait('PolicyKitAuthFailure.png', 20)
......
When /^I open a new tab in Iceweasel$/ do
next if @skip_steps_while_restoring_background
@screen.wait_and_click("IceweaselRunning.png", 10)
@screen.type("t", Sikuli::KEY_CTRL)
@screen.type("t", Sikuli::KeyModifier.CTRL)
end
When /^I open the address "([^"]*)" in Iceweasel$/ do |address|
next if @skip_steps_while_restoring_background
step "I open a new tab in Iceweasel"
@screen.type("l", Sikuli::KEY_CTRL)
@screen.type("l", Sikuli::KeyModifier.CTRL)
sleep 0.5
@screen.type(address + Sikuli::KEY_RETURN)
@screen.type(address + Sikuli::Key.ENTER)
end
......@@ -34,13 +34,13 @@ When /^I fetch the "([^"]*)" OpenPGP key using Seahorse$/ do |keyid|
next if @skip_steps_while_restoring_background
step "I run \"seahorse\""
@screen.wait("SeahorseWindow.png", 10)
@screen.type("r", Sikuli::KEY_ALT) # Menu: "Remote" ->
@screen.type("r", Sikuli::KeyModifier.ALT) # Menu: "Remote" ->
@screen.type("f") # "Find Remote Keys...".
@screen.wait("SeahorseFindKeysWindow.png", 10)
# Seahorse doesn't seem to support searching for fingerprints
@screen.type(keyid + Sikuli::KEY_RETURN)
@screen.type(keyid + Sikuli::Key.ENTER)
@screen.wait("SeahorseFoundKeyResult.png", 5*60)
@screen.type(Sikuli::DOWN_ARROW) # Select first item in result menu
@screen.type("f", Sikuli::KEY_ALT) # Menu: "File" ->
@screen.type(Sikuli::Key.DOWN) # Select first item in result menu
@screen.type("f", Sikuli::KeyModifier.ALT) # Menu: "File" ->
@screen.type("i") # "Import"
end
When /^I see and accept the Unsafe Browser start verification$/ do
next if @skip_steps_while_restoring_background
@screen.wait("UnsafeBrowserStartVerification.png", 30)
@screen.type("l", Sikuli::KEY_ALT)
@screen.type("l", Sikuli::KeyModifier.ALT)
end
Then /^I see and close the Unsafe Browser start notification$/ do
......@@ -49,7 +49,7 @@ end
When /^I close the Unsafe Browser$/ do
next if @skip_steps_while_restoring_background
@screen.type("q", Sikuli::KEY_CTRL)
@screen.type("q", Sikuli::KeyModifier.CTRL)
end
Then /^I see the Unsafe Browser stop notification$/ do
......@@ -66,15 +66,15 @@ end
When /^I open a new tab in the Unsafe Browser$/ do
next if @skip_steps_while_restoring_background
@screen.wait_and_click("UnsafeBrowserWindow.png", 10)
@screen.type("t", Sikuli::KEY_CTRL)
@screen.type("t", Sikuli::KeyModifier.CTRL)
end
When /^I open the address "([^"]*)" in the Unsafe Browser$/ do |address|
next if @skip_steps_while_restoring_background
step "I open a new tab in the Unsafe Browser"
@screen.type("l", Sikuli::KEY_CTRL)
@screen.type("l", Sikuli::KeyModifier.CTRL)
sleep 0.5
@screen.type(address + Sikuli::KEY_RETURN)
@screen.type(address + Sikuli::Key.ENTER)
end
Then /^I cannot configure the Unsafe Browser to use any local proxies$/ do
......@@ -83,13 +83,13 @@ Then /^I cannot configure the Unsafe Browser to use any local proxies$/ do
sleep 0.5
# First we open the proxy settings page to prepare it with the
# correct open tabs for the loop below.
@screen.type("e", Sikuli::KEY_ALT)
@screen.type("e", Sikuli::KeyModifier.ALT)
@screen.type("n")
@screen.wait('UnsafeBrowserPreferences.png', 10)
@screen.wait_and_click('UnsafeBrowserAdvancedSettings.png', 10)
@screen.wait_and_click('UnsafeBrowserNetworkTab.png', 10)
sleep 0.5
@screen.type(Sikuli::KEY_ESC)
@screen.type(Sikuli::Key.ESC)
# @screen.waitVanish('UnsafeBrowserPreferences.png', 10)
sleep 0.5
......@@ -112,24 +112,24 @@ Then /^I cannot configure the Unsafe Browser to use any local proxies$/ do
proxy_port = proxy[1]
# Open proxy settings and select manual proxy configuration
@screen.type("e", Sikuli::KEY_ALT)
@screen.type("e", Sikuli::KeyModifier.ALT)
@screen.type("n")
@screen.wait('UnsafeBrowserPreferences.png', 10)
@screen.type("e", Sikuli::KEY_ALT)
@screen.type("e", Sikuli::KeyModifier.ALT)
@screen.wait('UnsafeBrowserProxySettings.png', 10)
@screen.type("m", Sikuli::KEY_ALT)
@screen.type("m", Sikuli::KeyModifier.ALT)
# Configure the proxy
@screen.type(proxy_type, Sikuli::KEY_ALT) # Select correct proxy type
@screen.type("127.0.0.1\t#{proxy_port}") if proxy_type != no_proxy
@screen.type(proxy_type, Sikuli::KeyModifier.ALT) # Select correct proxy type
@screen.type("127.0.0.1" + Sikuli::Key.TAB + "#{proxy_port}") if proxy_type != no_proxy
# For http proxy we set "Use this proxy server for all protocols"
@screen.type("s", Sikuli::KEY_ALT) if proxy_type == http_proxy
@screen.type("s", Sikuli::KeyModifier.ALT) if proxy_type == http_proxy
# Close settings
@screen.type(Sikuli::KEY_RETURN)
@screen.type(Sikuli::Key.ENTER)
# @screen.waitVanish('UnsafeBrowserProxySettings.png', 10)
sleep 0.5
@screen.type(Sikuli::KEY_ESC)
@screen.type(Sikuli::Key.ESC)
# @screen.waitVanish('UnsafeBrowserPreferences.png', 10)
sleep 0.5
......
......@@ -44,9 +44,9 @@ def usb_install_helper(name)
# @screen.wait('USBTargetDevice.png', 10)
# match = @screen.find('USBTargetDevice.png')
# region_x = match.x
# region_y = match.y + match.height
# region_w = match.width*3
# region_h = match.height*2
# region_y = match.y + match.h
# region_w = match.w*3
# region_h = match.h*2
# ocr = Sikuli::Region.new(region_x, region_y, region_w, region_h).text
# STDERR.puts ocr
# # Unfortunately this results in almost garbage, like "|]dev/sdm"
......@@ -57,15 +57,15 @@ def usb_install_helper(name)
if @screen.find("USBSuggestsInstall.png")
raise ISOHybridUpgradeNotSupported
end
rescue Sikuli::ImageNotFound
rescue FindFailed
# we didn't get the warning, so we can proceed with the install
end
# @screen.hide_cursor
@screen.wait_and_click('USBCreateLiveUSBNext.png', 10)
# @screen.hide_cursor
@screen.wait('USBInstallationComplete.png', 60*60)
@screen.type(Sikuli::KEY_RETURN)
@screen.type(Sikuli::KEY_F4, Sikuli::KEY_ALT)
@screen.type(Sikuli::Key.ENTER)
@screen.type(Sikuli::Key.F4, Sikuli::KeyModifier.ALT)
end
When /^I "Clone & Install" Tails to USB drive "([^"]+)"$/ do |name|
......@@ -113,13 +113,11 @@ When /^I do a "Upgrade from ISO" on USB drive "([^"]+)"$/ do |name|
@screen.wait_and_click('USBUpgradeFromISO.png', 10)
@screen.wait('USBUseLiveSystemISO.png', 10)
match = @screen.find('USBUseLiveSystemISO.png')
pos_x = match.x + match.width/2
pos_y = match.y + match.height*2
@screen.click(pos_x, pos_y)
@screen.click(match.getCenter.offset(match.w/2, match.h*2))
@screen.wait('USBSelectISO.png', 10)
@screen.wait_and_click('GnomeFileDiagTypeFilename.png', 10)
iso = "#{shared_iso_dir_on_guest}/#{File.basename($tails_iso)}"
@screen.type(iso + Sikuli::KEY_RETURN)
@screen.type(iso + Sikuli::Key.ENTER)
usb_install_helper(name)
end
......@@ -127,19 +125,19 @@ Given /^I enable all persistence presets$/ do
next if @skip_steps_while_restoring_background
@screen.wait('PersistenceWizardPresets.png', 20)
# Mark first non-default persistence preset
@screen.type("\t\t")
@screen.type(Sikuli::Key.TAB*2)
# Check all non-default persistence presets
10.times do
@screen.type(" \t")
@screen.type(Sikuli::Key.SPACE + Sikuli::Key.TAB)
end
# Now we'll have the custom persistence field selected
@screen.type("/home/#{$live_user}/custom_persistence")
@screen.type('a', Sikuli::KEY_ALT)
@screen.type('a', Sikuli::KeyModifier.ALT)
@screen.type('/etc/ssh')
@screen.type('a', Sikuli::KEY_ALT)
@screen.type('a', Sikuli::KeyModifier.ALT)
@screen.wait_and_click('PersistenceWizardSave.png', 10)
@screen.wait('PersistenceWizardDone.png', 20)
@screen.type(Sikuli::KEY_F4, Sikuli::KEY_ALT)
@screen.type(Sikuli::Key.F4, Sikuli::KeyModifier.ALT)
end
Given /^I create a persistent partition with password "([^"]+)"$/ do |pwd|
......@@ -147,7 +145,7 @@ Given /^I create a persistent partition with password "([^"]+)"$/ do |pwd|
step "I run \"tails-persistence-setup\""
@screen.wait('PersistenceWizardWindow.png', 20)
@screen.wait('PersistenceWizardStart.png', 20)
@screen.type(pwd + "\t" + pwd + Sikuli::KEY_RETURN)
@screen.type(pwd + "\t" + pwd + Sikuli::Key.ENTER)
@screen.wait('PersistenceWizardPresets.png', 300)
step "I enable all persistence presets"
end
......@@ -248,16 +246,10 @@ end
Given /^I enable persistence with password "([^"]+)"$/ do |pwd|
next if @skip_steps_while_restoring_background
match = @screen.find('TailsGreeterPersistence.png')
pos_x = match.x + match.width/2
# height*2 may seem odd, but we want to click the button below the
# match. This may even work accross different screen resolutions.
pos_y = match.y + match.height*2
@screen.click(pos_x, pos_y)
@screen.click(match.getCenter.offset(match.w/2, match.h*2))
@screen.wait('TailsGreeterPersistencePassphrase.png', 10)
match = @screen.find('TailsGreeterPersistencePassphrase.png')
pos_x = match.x + match.width*2
pos_y = match.y + match.height/2
@screen.click(pos_x, pos_y)
@screen.click(match.getCenter.offset(match.w*2, match.h/2))
@screen.type(pwd)
end
......
require 'java'
require 'rubygems'
require "#{Dir.pwd}/features/support/extra_hooks.rb"
require 'time'
......
require 'sikuli'
# Add missing stuff
module Sikuli
KEY_F1 = Key::F1
KEY_F2 = Key::F2
KEY_F3 = Key::F3
KEY_F4 = Key::F4
KEY_F5 = Key::F5
KEY_F6 = Key::F6
KEY_F7 = Key::F7
KEY_F8 = Key::F8
KEY_F9 = Key::F9
KEY_F10 = Key::F10
KEY_F11 = Key::F11
KEY_F12 = Key::F12
KEY_ESC = Key::ESC
end
require 'rjb'
require 'rjbextension'
$LOAD_PATH << ENV['SIKULI_HOME']
require 'sikuli-script.jar'
Rjb::load
package_members = [
"org.sikuli.script.Finder",
"org.sikuli.script.Key",
"org.sikuli.script.KeyModifier",
"org.sikuli.script.Location",
"org.sikuli.script.Match",
"org.sikuli.script.Pattern",
"org.sikuli.script.Region",
"org.sikuli.script.Screen",
"org.sikuli.script.Settings",
]
module Sikuli::Clickable
def hover(x, y)
@java_obj.hover(org.sikuli.script::Location.new(x, y).offset(x(), y()))
translations = Hash[
"org.sikuli.script", "Sikuli",
]
for p in package_members
imported_class = Rjb::import(p)
package, ignore, class_name = p.rpartition(".")
next if ! translations.include? package
mod_name = translations[package]
mod = mod_name.split("::").inject(Object) do |parent_obj, child_name|
if parent_obj.const_defined?(child_name, false)
parent_obj.const_get(child_name, false)
else
child_obj = Module.new
parent_obj.const_set(child_name, child_obj)
end
end
mod.const_set(class_name, imported_class)
end
class Sikuli::Region
def wait_and_click(pic, time)
# It's undocumented, but wait() returns the matched region, so we
# compute the middle of it and click() there instead of letting
# click() scan for the picture again.
r = self.wait(pic, time)
x = r.x + r.width/2
y = r.y + r.height/2
self.click(x, y)
# Since rjb imports Java classes without creating a corresponding
# Ruby class (it's just an instance of Rjb_JavaProxy) we can't
# monkey patch any class, so additional methods must be added
# to each Screen object.
# Also, due to limitations in Ruby's syntax we can't do:
# def Sikuli::Screen.new