summaryrefslogtreecommitdiffstats
path: root/features
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2018-03-04 15:56:38 +0000
committerintrigeri <intrigeri@boum.org>2018-03-04 18:02:44 +0000
commit77a2172d2cb997b456c50a1fb98ed99c80edb4cb (patch)
treeca702219dfdc108e0e30a9ac768538c241990b3d /features
parentcde36bcc129471b0253dfad8ce1243082947e918 (diff)
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
Diffstat (limited to 'features')
-rw-r--r--features/images/PersistenceWizardSave.pngbin982 -> 0 bytes
-rw-r--r--features/step_definitions/usb.rb97
2 files changed, 79 insertions, 18 deletions
diff --git a/features/images/PersistenceWizardSave.png b/features/images/PersistenceWizardSave.png
deleted file mode 100644
index c0b8dcd..0000000
--- a/features/images/PersistenceWizardSave.png
+++ /dev/null
Binary files differ
diff --git a/features/step_definitions/usb.rb b/features/step_definitions/usb.rb
index e40c577..8859bd1 100644
--- a/features/step_definitions/usb.rb
+++ b/features/step_definitions/usb.rb
@@ -1,8 +1,9 @@
-# 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