1 def configured_pidgin_accounts
3 xml = REXML::Document.new(@vm.file_content('$HOME/.purple/accounts.xml',
5 xml.elements.each("account/account") do |e|
6 account = e.elements["name"].text
7 account_name, network = account.split("@")
8 protocol = e.elements["protocol"].text
9 port = e.elements["settings/setting[@name='port']"].text
10 nickname = e.elements["settings/setting[@name='username']"].text
11 real_name = e.elements["settings/setting[@name='realname']"].text
13 'name' => account_name,
15 'protocol' => protocol,
17 'nickname' => nickname,
18 'real_name' => real_name,
25 def chan_image (account, channel, image)
29 'roaster' => 'PidginTailsChannelEntry',
30 'conversation_tab' => 'PidginTailsConversationTab',
31 'welcome' => 'PidginTailsChannelWelcome',
35 return images[account][channel][image] + ".png"
38 def default_chan (account)
40 'irc.oftc.net' => '#tails',
46 return @vm.file_content('$HOME/.purple/otr.private_key', $live_user)
49 Given /^Pidgin has the expected accounts configured with random nicknames$/ do
50 next if @skip_steps_while_restoring_background
52 ["irc.oftc.net", "prpl-irc", "6697"],
53 ["127.0.0.1", "prpl-irc", "6668"],
55 configured_pidgin_accounts.each() do |account|
56 assert(account['nickname'] != "XXX_NICK_XXX", "Nickname was no randomised")
57 assert_equal(account['nickname'], account['real_name'],
58 "Nickname and real name are not identical: " +
59 account['nickname'] + " vs. " + account['real_name'])
60 assert_equal(account['name'], account['nickname'],
61 "Account name and nickname are not identical: " +
62 account['name'] + " vs. " + account['nickname'])
63 candidate = [account['network'], account['protocol'], account['port']]
64 assert(expected.include?(candidate), "Unexpected account: #{candidate}")
65 expected.delete(candidate)
67 assert(expected.empty?, "These Pidgin accounts are not configured: " +
71 When /^I start Pidgin through the GNOME menu$/ do
72 next if @skip_steps_while_restoring_background
73 step 'I start "Pidgin" via the GNOME "Internet" applications menu'
76 When /^I open Pidgin's account manager window$/ do
77 next if @skip_steps_while_restoring_background
78 @screen.type("a", Sikuli::KeyModifier.CTRL) # shortcut for "manage accounts"
79 step "I see Pidgin's account manager window"
82 When /^I see Pidgin's account manager window$/ do
83 next if @skip_steps_while_restoring_background
84 @screen.wait("PidginAccountWindow.png", 20)
87 When /^I close Pidgin's account manager window$/ do
88 next if @skip_steps_while_restoring_background
89 @screen.wait_and_click("PidginAccountManagerCloseButton.png", 10)
92 When /^I activate the "([^"]+)" Pidgin account$/ do |account|
93 next if @skip_steps_while_restoring_background
94 @screen.click("PidginAccount_#{account}.png")
95 @screen.type(Sikuli::Key.LEFT + Sikuli::Key.SPACE)
96 # wait for the Pidgin to be connecting, otherwise sometimes the step
97 # that closes the account management dialog happens before the account
99 @screen.wait("PidginConnecting.png", 5)
102 def focus_pidgin_buddy_list
103 @vm.execute_successfully(
104 "xdotool search --name 'Buddy List' windowactivate --sync", $live_user
108 Then /^Pidgin successfully connects to the "([^"]+)" account$/ do |account|
109 next if @skip_steps_while_restoring_background
110 expected_channel_entry = chan_image(account, default_chan(account), 'roaster')
111 # Sometimes the OFTC welcome notice window pops up over the buddy list one...
112 focus_pidgin_buddy_list
113 @screen.wait(expected_channel_entry, 60)
116 Then /^I can join the "([^"]+)" channel on "([^"]+)"$/ do |channel, account|
117 next if @skip_steps_while_restoring_background
118 @screen.doubleClick( chan_image(account, channel, 'roaster'))
119 @screen.wait_and_click(chan_image(account, channel, 'conversation_tab'), 10)
120 @screen.wait( chan_image(account, channel, 'welcome'), 10)
123 Then /^I take note of the configured Pidgin accounts$/ do
124 next if @skip_steps_while_restoring_background
125 @persistent_pidgin_accounts = configured_pidgin_accounts
128 Then /^I take note of the OTR key for Pidgin's "([^"]+)" account$/ do |account_name|
129 next if @skip_steps_while_restoring_background
130 @persistent_pidgin_otr_keys = pidgin_otr_keys
133 Then /^Pidgin has the expected persistent accounts configured$/ do
134 next if @skip_steps_while_restoring_background
135 current_accounts = configured_pidgin_accounts
136 assert(current_accounts <=> @persistent_pidgin_accounts,
137 "Currently configured Pidgin accounts do not match the persistent ones:\n" +
138 "Current:\n#{current_accounts}\n" +
139 "Persistent:\n#{@persistent_pidgin_accounts}"
143 Then /^Pidgin has the expected persistent OTR keys$/ do
144 next if @skip_steps_while_restoring_background
145 assert_equal(pidgin_otr_keys, @persistent_pidgin_otr_keys)
148 def pidgin_add_certificate_from (cert_file)
149 # Here, we need a certificate that is not already in the NSS database
150 step "I copy \"/usr/share/ca-certificates/spi-inc.org/spi-cacert-2008.crt\" to \"#{cert_file}\" as user \"amnesia\""
152 @screen.wait_and_click('PidginToolsMenu.png', 10)
153 @screen.wait_and_click('PidginCertificatesMenuItem.png', 10)
154 @screen.wait('PidginCertificateManagerDialog.png', 10)
155 @screen.wait_and_click('PidginCertificateAddButton.png', 10)
157 @screen.wait_and_click('GtkFileChooserDesktopButton.png', 10)
159 # The first time we're run, the file chooser opens in the Recent
160 # view, so we have to browse a directory before we can use the
161 # "Type file name" button. But on subsequent runs, the file
162 # chooser is already in the Desktop directory, so we don't need to
163 # do anything. Hence, this noop exception handler.
165 @screen.wait_and_click('GtkFileTypeFileNameButton.png', 10)
166 @screen.type("l", Sikuli::KeyModifier.ALT) # "Location" field
167 @screen.type(cert_file + Sikuli::Key.ENTER)
170 Then /^I can add a certificate from the "([^"]+)" directory to Pidgin$/ do |cert_dir|
171 next if @skip_steps_while_restoring_background
172 pidgin_add_certificate_from("#{cert_dir}/test.crt")
173 @screen.wait('PidginCertificateAddHostnameDialog.png', 10)
174 @screen.type("XXX test XXX" + Sikuli::Key.ENTER)
175 @screen.wait('PidginCertificateTestItem.png', 10)
178 Then /^I cannot add a certificate from the "([^"]+)" directory to Pidgin$/ do |cert_dir|
179 next if @skip_steps_while_restoring_background
180 pidgin_add_certificate_from("#{cert_dir}/test.crt")
181 @screen.wait('PidginCertificateImportFailed.png', 10)
184 When /^I close Pidgin's certificate manager$/ do
185 @screen.type(Sikuli::Key.ESC)
186 # @screen.wait_and_click('PidginCertificateManagerClose.png', 10)
187 @screen.waitVanish('PidginCertificateManagerDialog.png', 10)
190 When /^I close Pidgin's certificate import failure dialog$/ do
191 @screen.type(Sikuli::Key.ESC)
192 # @screen.wait_and_click('PidginCertificateManagerClose.png', 10)
193 @screen.waitVanish('PidginCertificateImportFailed.png', 10)