3 Given /^the only hosts in APT sources are "([^"]*)"$/ do |hosts_str|
4 next if @skip_steps_while_restoring_background
5 hosts = hosts_str.split(',')
6 @vm.execute("cat /etc/apt/sources.list /etc/apt/sources.list.d/*").stdout.chomp.each_line { |line|
7 next if ! line.start_with? "deb"
8 source_host = URI(line.split[1]).host
9 if !hosts.include?(source_host)
10 raise "Bad APT source '#{line}'"
15 When /^I update APT using apt-get$/ do
16 next if @skip_steps_while_restoring_background
17 Timeout::timeout(30*60) do
18 cmd = @vm.execute("echo #{@sudo_password} | " +
19 "sudo -S apt-get update", $live_user)
21 STDERR.puts cmd.stderr
26 Then /^I should be able to install a package using apt-get$/ do
27 next if @skip_steps_while_restoring_background
29 Timeout::timeout(120) do
30 cmd = @vm.execute("echo #{@sudo_password} | " +
31 "sudo -S apt-get install #{package}", $live_user)
33 STDERR.puts cmd.stderr
36 step "package \"#{package}\" is installed"
39 When /^I update APT using Synaptic$/ do
40 next if @skip_steps_while_restoring_background
41 # Upon start the interface will be frozen while Synaptic loads the
42 # package list. Since the frozen GUI is so similar to the unfrozen
43 # one there's no easy way to reliably wait for the latter. Hence we
44 # spam reload until it's performed, which is easier to detect.
45 try_for(60, :msg => "Failed to reload the package list in Synaptic") {
46 @screen.type("r", Sikuli::KeyModifier.CTRL)
47 @screen.find('SynapticReloadPrompt.png')
49 @screen.waitVanish('SynapticReloadPrompt.png', 30*60)
52 Then /^I should be able to install a package using Synaptic$/ do
53 next if @skip_steps_while_restoring_background
55 # We do this after a Reload, so the interface will be frozen until
56 # the package list has been loaded
57 try_for(60, :msg => "Failed to open the Synaptic 'Find' window") {
58 @screen.type("f", Sikuli::KeyModifier.CTRL) # Find key
59 @screen.find('SynapticSearch.png')
61 @screen.type(package + Sikuli::Key.ENTER)
62 @screen.wait_and_click('SynapticCowsaySearchResult.png', 20)
64 @screen.type("i", Sikuli::KeyModifier.CTRL) # Mark for installation
66 @screen.type("p", Sikuli::KeyModifier.CTRL) # Apply
67 @screen.wait('SynapticApplyPrompt.png', 60)
68 @screen.type("a", Sikuli::KeyModifier.ALT) # Verify apply
69 @screen.wait('SynapticChangesAppliedPrompt.png', 120)
70 step "package \"#{package}\" is installed"
73 When /^I start Synaptic$/ do
74 next if @skip_steps_while_restoring_background
75 @screen.wait_and_click("GnomeApplicationsMenu.png", 10)
76 @screen.wait_and_click("GnomeApplicationsSystem.png", 10)
77 @screen.wait_and_click("GnomeApplicationsAdministration.png", 10)
78 @screen.wait_and_click("GnomeApplicationsSynaptic.png", 20)
79 deal_with_polkit_prompt('SynapticPolicyKitAuthPrompt.png', @sudo_password)