summaryrefslogtreecommitdiffstats
path: root/features/step_definitions/pidgin.rb
diff options
context:
space:
mode:
Diffstat (limited to 'features/step_definitions/pidgin.rb')
-rw-r--r--features/step_definitions/pidgin.rb45
1 files changed, 22 insertions, 23 deletions
diff --git a/features/step_definitions/pidgin.rb b/features/step_definitions/pidgin.rb
index cbfbea1..7e29bfc 100644
--- a/features/step_definitions/pidgin.rb
+++ b/features/step_definitions/pidgin.rb
@@ -18,19 +18,20 @@ EOF
return account
end
+def wait_and_focus(img, time = 10, window)
+ begin
+ @screen.wait(img, time)
+ rescue FindFailed
+ @vm.focus_window(window)
+ @screen.wait(img, time)
+ end
+end
+
def focus_pidgin_irc_conversation_window(account)
account = account.sub(/^irc\./, '')
@vm.focus_window(".*#{Regexp.escape(account)}$")
end
-def close_pidgin_conversation_window(account)
- focus_pidgin_irc_conversation_window(account)
- @screen.type(Sikuli::Key.F4, Sikuli::KeyModifier.ALT)
- if @screen.exists('PidginConfirmationIcon.png')
- @screen.click('GnomeCloseButton.png')
- end
-end
-
When /^I create my XMPP account$/ do
next if @skip_steps_while_restoring_background
account = xmpp_account("Tails_account")
@@ -296,9 +297,11 @@ end
Then /^Pidgin successfully connects to the "([^"]+)" account$/ do |account|
next if @skip_steps_while_restoring_background
expected_channel_entry = chan_image(account, default_chan(account), 'roster')
- @new_circuit_tries = 0
- until @new_circuit_tries == $config["MAX_NEW_TOR_CIRCUIT_RETRIES"] do
- # Sometimes the OFTC welcome notice window pops up over the buddy list one...
+ reconnect_button = 'PidginReconnect.png'
+ recovery_on_failure = Proc.new do
+ @screen.wait_and_click(reconnect_button, 20)
+ end
+ retry_tor(recovery_on_failure) do
begin
@vm.focus_window('Buddy List')
rescue ExecutionFailedInVM
@@ -307,17 +310,11 @@ Then /^Pidgin successfully connects to the "([^"]+)" account$/ do |account|
# conversation window. At worst, the test will still fail...
close_pidgin_conversation_window(account)
end
-
- # FIXME This should be modified to use waitAny once #9633 is addressed
- begin
- @screen.wait(expected_channel_entry, 60)
- break
- rescue FindFailed
- force_new_tor_circuit
- @screen.wait_and_click('PidginReconnect.png', 20)
+ on_screen, _ = @screen.waitAny([expected_channel_entry, reconnect_button], 60)
+ unless on_screen == expected_channel_entry
+ raise "Connecting to account #{account} failed."
end
end
- @screen.wait(expected_channel_entry, 10)
end
Then /^the "([^"]*)" account only responds to PING and VERSION CTCP requests$/ do |irc_server|
@@ -385,6 +382,7 @@ def pidgin_add_certificate_from (cert_file)
# Here, we need a certificate that is not already in the NSS database
step "I copy \"/usr/share/ca-certificates/spi-inc.org/spi-cacert-2008.crt\" to \"#{cert_file}\" as user \"amnesia\""
+ @vm.focus_window('Buddy List')
@screen.wait_and_click('PidginToolsMenu.png', 10)
@screen.wait_and_click('PidginCertificatesMenuItem.png', 10)
@screen.wait('PidginCertificateManagerDialog.png', 10)
@@ -406,18 +404,19 @@ end
Then /^I can add a certificate from the "([^"]+)" directory to Pidgin$/ do |cert_dir|
next if @skip_steps_while_restoring_background
pidgin_add_certificate_from("#{cert_dir}/test.crt")
- @screen.wait('PidginCertificateAddHostnameDialog.png', 10)
+ wait_and_focus('PidginCertificateAddHostnameDialog.png', 10, 'Certificate Import')
@screen.type("XXX test XXX" + Sikuli::Key.ENTER)
- @screen.wait('PidginCertificateTestItem.png', 10)
+ wait_and_focus('PidginCertificateTestItem.png', 10, 'Certificate Manager')
end
Then /^I cannot add a certificate from the "([^"]+)" directory to Pidgin$/ do |cert_dir|
next if @skip_steps_while_restoring_background
pidgin_add_certificate_from("#{cert_dir}/test.crt")
- @screen.wait('PidginCertificateImportFailed.png', 10)
+ wait_and_focus('PidginCertificateImportFailed.png', 10, 'Import Error')
end
When /^I close Pidgin's certificate manager$/ do
+ wait_and_focus('PidginCertificateManagerDialog.png', 10, 'Certificate Manager')
@screen.type(Sikuli::Key.ESC)
# @screen.wait_and_click('PidginCertificateManagerClose.png', 10)
@screen.waitVanish('PidginCertificateManagerDialog.png', 10)