[gnome-build-meta/abderrahim/gtk-gi: 3/4] openqa: Add an example test for Settings




commit 080465dad2b44ed4947266963a48606c4edd39f6
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     | 30 ++++++++++++++++++++++++++++++
 openqa/main.pm               |  2 ++
 openqa/tests/app_settings.pm | 16 ++++++++++++++++
 3 files changed, 48 insertions(+)
---
diff --git a/openqa/lib/gnomeutils.pm b/openqa/lib/gnomeutils.pm
new file mode 100644
index 000000000..75fd7b2ef
--- /dev/null
+++ b/openqa/lib/gnomeutils.pm
@@ -0,0 +1,30 @@
+# 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 run_command {
+    my $command = $_[0];
+    my $desktop_runner_hotkey = 'alt-f2';
+    my $desktop_runner_timeout = 2;
+
+    # Exit activities view if it's open.
+    send_key('esc');
+    wait_still_screen(2);
+
+    send_key($desktop_runner_hotkey, wait_screen_change => true);
+
+    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]