[gnome-build-meta/sam/settings-test: 24/24] openqa: Add an example test for Settings




commit 2151cb0541b5afa5d44effaacc9d163e60f233e4
Author: Sam Thursfield <sam thursfield codethink co uk>
Date:   Fri Sep 24 10:39:18 2021 +0100

    openqa: Add an example test for Settings
    
    This shows how to launch Settings, save a screenshot and assert
    that the expected app shows up on startup.

 openqa/lib/gnomeutils.pm     | 35 +++++++++++++++++++++++++++++++++++
 openqa/main.pm               |  2 ++
 openqa/tests/app_settings.pm | 16 ++++++++++++++++
 3 files changed, 53 insertions(+)
---
diff --git a/openqa/lib/gnomeutils.pm b/openqa/lib/gnomeutils.pm
new file mode 100644
index 000000000..edd565ad6
--- /dev/null
+++ b/openqa/lib/gnomeutils.pm
@@ -0,0 +1,35 @@
+# Some of this code is based on the OpenSuSE tests, particularly
+# `x11_start_program` function found here:
+# https://github.com/os-autoinst/os-autoinst-distri-opensuse/blob/master/lib/susedistribution.pm
+
+sub exit_activities_view {
+    send_key('esc');
+    wait_still_screen(2);
+}
+
+sub run_command {
+    my $command = $_[0];
+    my $desktop_runner_hotkey = 'alt-f2';
+    my $desktop_runner_timeout = 2;
+
+    exit_activities_view
+
+    wait_screen_change(sub {
+        send_key($desktop_runner_hotkey);
+    }, $desktop_runner_timeout);
+
+    assert_screen('desktop_runner', $desktop_runner_timeout);
+
+    type_string($command);
+    send_key 'ret';
+}
+
+sub start_app {
+    my $command = $_[0];
+    run_command($command);
+
+    wait_still_screen(2);
+    save_screenshot;
+}
+
+1;
diff --git a/openqa/main.pm b/openqa/main.pm
index b6fbf2556..ce045d958 100644
--- a/openqa/main.pm
+++ b/openqa/main.pm
@@ -2,8 +2,10 @@ use strict;
 use testapi;
 use autotest;
 use needle;
+use File::Basename;
 
 autotest::loadtest "tests/gnome_install.pm";
 autotest::loadtest "tests/gnome_welcome.pm";
 autotest::loadtest "tests/gnome_desktop.pm";
+autotest::loadtest "tests/app_settings.pm";
 1;
diff --git a/openqa/tests/app_settings.pm b/openqa/tests/app_settings.pm
new file mode 100644
index 000000000..96986e335
--- /dev/null
+++ b/openqa/tests/app_settings.pm
@@ -0,0 +1,16 @@
+use base 'basetest';
+use strict;
+use testapi;
+use gnomeutils;
+
+sub run {
+    start_app('gnome-control-center');
+    assert_screen('app_settings_startup', 10);
+    send_key('alt-f4');
+}
+
+sub test_flags {
+    return { fatal => 1 };
+}
+
+1;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]