Commit 77a2172d authored by intrigeri's avatar intrigeri
Browse files

WIP: update test suite for new Persistent Wizard UI (refs: #6485, #15259, #15314).

The tails-persistence-setup UI has changed in a number of ways:

 - some setting lines now have a "Configure" button
 - custom widgets were replaced with standard GNOME ones
 - a "preset" can now map to N lines in persistence.conf
parent cde36bcc
# Returns a hash that for each preset the running Tails is aware of
# Returns a hash that for each persistence preset the running Tails is aware of,
# for each of the corresponding configuration lines,
# maps the source to the destination.
def get_persistence_presets(skip_links = false)
# Perl script that prints all persistence presets (one per line) on
# the form: <mount_point>:<comma-separated-list-of-options>
def get_persistence_presets_config(skip_links = false)
# Perl script that prints all persistence configuration lines (one per line)
# in the form: <mount_point>:<comma-separated-list-of-options>
script = <<-EOF
use strict;
use warnings FATAL => "all";
......@@ -14,11 +15,13 @@ EOF
# VMCommand:s cannot handle newlines, and they're irrelevant in the
# above perl script any way
script.delete!("\n")
presets = $vm.execute_successfully("perl -E '#{script}'").stdout.chomp.split("\n")
assert presets.size >= 10, "Got #{presets.size} persistence presets, " +
"which is too few"
presets_configs = $vm.execute_successfully("perl -E '#{script}'")
.stdout.chomp.split("\n")
assert presets_configs.size >= 10,
"Got #{presets_configs.size} persistence preset configuration lines, " +
"which is too few"
persistence_mapping = Hash.new
for line in presets
for line in presets_configs
destination, options_str = line.split(":")
options = options_str.split(",")
is_link = options.include? "link"
......@@ -37,17 +40,59 @@ EOF
end
def persistent_dirs
get_persistence_presets
get_persistence_presets_config
end
def persistent_mounts
get_persistence_presets(true)
get_persistence_presets_config(true)
end
def persistent_volumes_mountpoints
$vm.execute("ls -1 -d /live/persistence/*_unlocked/").stdout.chomp.split
end
# Returns an array that for each persistence preset the running Tails is aware of,
# contains a hash with the following keys: id, enabled, has_configuration_button.
def persistent_presets_ui_settings
# Perl script that prints all persistence presets
# in the form: <id>:<enabled>:<has_configuration_button>
script = <<-EOF
use strict;
use warnings FATAL => "all";
use Tails::Persistence::Configuration::Presets;
foreach my $preset (Tails::Persistence::Configuration::Presets->new()->all) {
say(sprintf(
"%s:%s:%s",
$preset->{id},
($preset->{enabled} ? 1 : 0),
(exists($preset->{configuration_cb}) && defined($preset->{configuration_cb})
? 1
: 0
),
));
}
EOF
# VMCommand:s cannot handle newlines, and they're irrelevant in the
# above perl script any way
script.delete!("\n")
presets = $vm.execute_successfully("perl -E '#{script}'")
.stdout.chomp.split("\n")
assert presets.size >= 10,
"Got #{presets.size} persistence presets, " +
"which is too few"
presets_ui_settings = Array.new
for line in presets
id, enabled, has_configuration_button = line.split(":")
presets_ui_settings += [{
'id' => id,
'enabled' => (enabled == '1'),
'has_configuration_button' => (has_configuration_button == '1'),
}]
end
return presets_ui_settings
end
def recover_from_upgrader_failure
$vm.execute('killall tails-upgrade-frontend tails-upgrade-frontend-wrapper zenity')
# Remove unnecessary sleep for retry
......@@ -170,14 +215,29 @@ end
Given /^I enable all persistence presets$/ do
@screen.wait('PersistenceWizardPresets.png', 20)
# Select the "Persistent" folder preset, which is checked by default.
@screen.type(Sikuli::Key.TAB)
# Check all non-default persistence presets, i.e. all *after* the
# "Persistent" folder, which are unchecked by default.
(persistent_dirs.size - 1).times do
@screen.type(Sikuli::Key.TAB + Sikuli::Key.SPACE)
presets = persistent_presets_ui_settings
presets[0]['is_first'] = true
debug_log("presets: #{presets}")
for setting in presets
debug_log("on preset: #{setting}")
tabs_to_select_switch = 3 # previous switch -> separator -> row -> switch
tabs_to_select_switch -= 1 if setting['is_first']
tabs_to_select_switch += 1 if setting['has_configuration_button']
# Select the switch
debug_log("typing TAB #{tabs_to_select_switch} times to select the switch")
tabs_to_select_switch.times do
debug_log("typing TAB")
@screen.type(Sikuli::Key.TAB)
end
# Activate the switch
if ! setting['enabled']
debug_log("pressing space")
@screen.type(Sikuli::Key.SPACE)
else
debug_log("setting already enabled, skipping")
end
end
@screen.wait_and_click('PersistenceWizardSave.png', 10)
@screen.type(Sikuli::Key.ENTER) # Press the Save button
@screen.wait('PersistenceWizardDone.png', 60)
@screen.type(Sikuli::Key.F4, Sikuli::KeyModifier.ALT)
end
......@@ -185,8 +245,9 @@ end
When /^I disable the first persistence preset$/ do
step 'I start "Configure persistent volume" via GNOME Activities Overview'
@screen.wait('PersistenceWizardPresets.png', 300)
@screen.type(Sikuli::Key.TAB)
@screen.type(Sikuli::Key.SPACE)
@screen.wait_and_click('PersistenceWizardSave.png', 10)
@screen.type(Sikuli::Key.ENTER)
@screen.wait('PersistenceWizardDone.png', 30)
@screen.type(Sikuli::Key.F4, Sikuli::KeyModifier.ALT)
end
......
Markdown is supported
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