From da080c472fc415b0ce918f4dd4a1ab143bb1bca4 Mon Sep 17 00:00:00 2001 From: Philip Hands Date: Mon, 14 Mar 2016 15:36:16 +0100 Subject: rough attempt to grab the good cucumber bits from recent tails --- features/step_definitions/apt.rb | 68 +++++++++++++--------------------------- 1 file changed, 22 insertions(+), 46 deletions(-) (limited to 'features/step_definitions/apt.rb') diff --git a/features/step_definitions/apt.rb b/features/step_definitions/apt.rb index fa351c88..c69d2598 100644 --- a/features/step_definitions/apt.rb +++ b/features/step_definitions/apt.rb @@ -1,9 +1,8 @@ require 'uri' Given /^the only hosts in APT sources are "([^"]*)"$/ do |hosts_str| - next if @skip_steps_while_restoring_background hosts = hosts_str.split(',') - @vm.file_content("/etc/apt/sources.list /etc/apt/sources.list.d/*").chomp.each_line { |line| + $vm.file_content("/etc/apt/sources.list /etc/apt/sources.list.d/*").chomp.each_line { |line| next if ! line.start_with? "deb" source_host = URI(line.split[1]).host if !hosts.include?(source_host) @@ -12,69 +11,46 @@ Given /^the only hosts in APT sources are "([^"]*)"$/ do |hosts_str| } end -When /^I update APT using apt-get$/ do - next if @skip_steps_while_restoring_background - Timeout::timeout(10*60) do - cmd = @vm.execute("echo #{@sudo_password} | " + - "sudo -S apt-get update", $live_user) - if !cmd.success? - STDERR.puts cmd.stderr - end +When /^I update APT using apt$/ do + Timeout::timeout(30*60) do + $vm.execute_successfully("echo #{@sudo_password} | " + + "sudo -S apt update", :user => LIVE_USER) end end -Then /^I should be able to install a package using apt-get$/ do - next if @skip_steps_while_restoring_background +Then /^I should be able to install a package using apt$/ do package = "cowsay" Timeout::timeout(120) do - cmd = @vm.execute("echo #{@sudo_password} | " + - "sudo -S apt-get install #{package}", $live_user) - if !cmd.success? - STDERR.puts cmd.stderr - end + $vm.execute_successfully("echo #{@sudo_password} | " + + "sudo -S apt install #{package}", + :user => LIVE_USER) end step "package \"#{package}\" is installed" end When /^I update APT using Synaptic$/ do - next if @skip_steps_while_restoring_background - # Upon start the interface will be frozen while Synaptic loads the - # package list. Since the frozen GUI is so similar to the unfrozen - # 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::KeyModifier.CTRL) - @screen.find('SynapticReloadPrompt.png') - } + @screen.click('SynapticReloadButton.png') + @screen.wait('SynapticReloadPrompt.png', 20) @screen.waitVanish('SynapticReloadPrompt.png', 30*60) end Then /^I should be able to install a package using Synaptic$/ do - next if @skip_steps_while_restoring_background package = "cowsay" - # 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::KeyModifier.CTRL) # Find key - @screen.find('SynapticSearch.png') - } + try_for(60) do + @screen.wait_and_click('SynapticSearchButton.png', 10) + @screen.wait_and_click('SynapticSearchWindow.png', 10) + end @screen.type(package + Sikuli::Key.ENTER) - @screen.wait_and_click('SynapticCowsaySearchResult.png', 20) - sleep 5 - @screen.type("i", Sikuli::KeyModifier.CTRL) # Mark for installation - sleep 5 - @screen.type("p", Sikuli::KeyModifier.CTRL) # Apply + @screen.wait_and_double_click('SynapticCowsaySearchResult.png', 20) + @screen.wait_and_click('SynapticApplyButton.png', 10) @screen.wait('SynapticApplyPrompt.png', 60) - @screen.type("a", Sikuli::KeyModifier.ALT) # Verify apply - @screen.wait('SynapticChangesAppliedPrompt.png', 120) + @screen.type(Sikuli::Key.ENTER) + @screen.wait('SynapticChangesAppliedPrompt.png', 240) step "package \"#{package}\" is installed" end When /^I start Synaptic$/ do - next if @skip_steps_while_restoring_background - @screen.wait_and_click("GnomeApplicationsMenu.png", 10) - @screen.wait_and_click("GnomeApplicationsSystem.png", 10) - @screen.wait_and_click("GnomeApplicationsAdministration.png", 10) - @screen.wait_and_click("GnomeApplicationsSynaptic.png", 20) - deal_with_polkit_prompt('SynapticPolicyKitAuthPrompt.png', @sudo_password) + step 'I start "Synaptic" via the GNOME "System" applications menu' + deal_with_polkit_prompt('PolicyKitAuthPrompt.png', @sudo_password) + @screen.wait('SynapticReloadButton.png', 30) end -- cgit v1.2.3-70-g09d2