Commit 5c4f31c9 authored by Tails developers's avatar Tails developers
Browse files

Add some useful step definitions.

parent 6872e3e7
......@@ -7,6 +7,7 @@ Feature: Keyserver interaction with GnuPG
Given I restore the background snapshot if it exists
And a freshly started Tails
And I log in to a new session
And GNOME has started
And I have a network connection
And Tor has built a circuit
And Iceweasel has autostarted and is not loading a web page
......
......@@ -7,6 +7,7 @@ Feature: Browsing the web using Iceweasel
Given I restore the background snapshot if it exists
And a freshly started Tails
And I log in to a new session
And GNOME has started
And I have a network connection
And Tor has built a circuit
And Iceweasel has autostarted and is not loading a web page
......
......@@ -42,11 +42,35 @@ Given /^a freshly started Tails$/ do
@screen.wait('TailsGreeter.png', 120)
end
Given /^a freshly started Tails with boot options "([^"]+)"$/ do |options|
next if @skip_steps_while_restoring_background
@vm.start
@screen.wait('TailsBootSplash.png', 30)
# Start the VM remote shell
@screen.type("\t autotest_never_use_this_option " + options +
Sikuli::KEY_RETURN)
@screen.wait('TailsGreeter.png', 120)
end
Given /^I log in to a new session$/ do
next if @skip_steps_while_restoring_background
@screen.click('TailsGreeterLoginButton.png')
end
Given /^I log in to a new session with sudo password "([^"]*)"$/ do |password|
@password = password
next if @skip_steps_while_restoring_background
@screen.type(" " + Sikuli::KEY_RETURN)
@screen.wait("TailsGreeterAdminPassword.png", 30)
@screen.type(password + "\t" + @password)
@screen.click('TailsGreeterLoginButton.png')
end
Given /^GNOME has started$/ do
next if @skip_steps_while_restoring_background
@screen.wait('GnomeStarted.png', 60)
end
Given /^I have a network connection$/ do
next if @skip_steps_while_restoring_background
# Wait until the VM's remote shell is available, which implies
......@@ -149,3 +173,27 @@ When /^I run "([^"]*)"$/ do |program|
step "I open the GNOME run dialog"
@screen.type(program + Sikuli::KEY_RETURN)
end
Given /^I enter the sudo password in the PolicyKit prompt$/ do
next if @skip_steps_while_restoring_background
@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)
waitVanish('PolicyKitAuthPrompt.png', 10)
end
Given /^process "([^"]+)" is running$/ do |process|
next if @skip_steps_while_restoring_background
assert guest_has_process?(process)
end
Given /^I shutdown Tails$/ do
next if @skip_steps_while_restoring_background
assert @vm.execute("halt", "root").success?
end
Given /^package "([^"]+)" is installed$/ do |package|
next if @skip_steps_while_restoring_background
assert @vm.execute("dpkg -s #{package}").success?
end
......@@ -37,3 +37,20 @@ def wait_until_tor_is_working
'tor_control_getinfo status/circuit-established',
'root').stdout == "1\n" }
end
# Ruby's sikuli bindings doesn't implement this...
def waitVanish(image, time = 2)
SystemTimer.timeout(time) do
loop do
begin
@screen.find(image)
rescue
return
end
end
end
end
def guest_has_process?(process)
return @vm.execute("pidof " + process).success?
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment