[openqa-tests/sam/app-tests] openqa: Add tests for 5 more apps




commit 6e198492edeccc07d906d975a5b4361b768050fc
Author: Sam Thursfield <sam thursfield codethink co uk>
Date:   Mon Oct 10 11:16:23 2022 +0200

    openqa: Add tests for 5 more apps
    
    App tests are not fatal, ensuring we test all apps even if one or
    more tests don't pass.
    
    Part of https://gitlab.gnome.org/GNOME/openqa-tests/-/issues/4

 lib/app_test.pm            | 16 ++++++++++++++++
 lib/gnomeutils.pm          | 26 +++++++++++++++++++++++---
 main.pm                    | 15 +++++++++++----
 tests/app_cheese.pm        | 13 +++++++++++++
 tests/app_epiphany.pm      | 13 +++++++++++++
 tests/app_gnome_weather.pm | 13 +++++++++++++
 tests/app_nautilus.pm      | 17 +++++++++++++++++
 tests/app_settings.pm      |  7 ++++---
 tests/app_simple_scan.pm   | 17 +++++++++++++++++
 9 files changed, 127 insertions(+), 10 deletions(-)
---
diff --git a/lib/app_test.pm b/lib/app_test.pm
new file mode 100644
index 0000000..695ad02
--- /dev/null
+++ b/lib/app_test.pm
@@ -0,0 +1,16 @@
+package app_test;
+use base "basetest";
+
+use strict;
+use warnings;
+use testapi;
+use gnomeutils;
+
+sub post_fail_hook {
+    # We don't know what state the app is in, but make sure it's closed
+    # to avoid breaking the next test.
+    send_key('alt-f4');
+    assert_screen('desktop_empty') unless match_has_tag('generic-desktop');
+}
+
+1;
diff --git a/lib/gnomeutils.pm b/lib/gnomeutils.pm
index 0eb396c..b92caa7 100644
--- a/lib/gnomeutils.pm
+++ b/lib/gnomeutils.pm
@@ -2,6 +2,22 @@
 # `x11_start_program` function found here:
 # https://github.com/os-autoinst/os-autoinst-distri-opensuse/blob/master/lib/susedistribution.pm
 
+package gnomeutils;
+
+use base Exporter;
+use Exporter;
+
+use strict;
+use warnings;
+
+use testapi;
+
+our @EXPORT = qw(
+    run_command
+    start_app
+    close_app
+);
+
 sub run_command {
     my $command = $_[0];
     my $desktop_runner_hotkey = 'alt-f2';
@@ -11,12 +27,12 @@ sub run_command {
     send_key('esc');
     wait_still_screen(2);
 
-    send_key($desktop_runner_hotkey, wait_screen_change => 1);
+    send_key($desktop_runner_hotkey, wait_screen_change => 'true');
 
     assert_screen('desktop_runner', $desktop_runner_timeout);
 
     type_string($command);
-    send_key 'ret';
+    send_key('ret');
 }
 
 sub start_app {
@@ -24,7 +40,11 @@ sub start_app {
     run_command($command);
 
     wait_still_screen(2);
-    save_screenshot;
+}
+
+sub close_app {
+    wait_screen_change { send_key('alt-f4') };
+    assert_screen('desktop_empty')  unless match_has_tag('generic-desktop');
 }
 
 1;
diff --git a/main.pm b/main.pm
index ce045d9..39811df 100644
--- a/main.pm
+++ b/main.pm
@@ -1,11 +1,18 @@
 use strict;
+use warnings;
 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";
+autotest::loadtest("tests/gnome_install.pm");
+autotest::loadtest("tests/gnome_welcome.pm");
+autotest::loadtest("tests/gnome_desktop.pm");
+autotest::loadtest("tests/app_cheese.pm");
+autotest::loadtest("tests/app_epiphany.pm");
+autotest::loadtest("tests/app_gnome_weather.pm");
+autotest::loadtest("tests/app_nautilus.pm");
+autotest::loadtest("tests/app_settings.pm");
+autotest::loadtest("tests/app_simple_scan.pm");
+
 1;
diff --git a/tests/app_cheese.pm b/tests/app_cheese.pm
new file mode 100644
index 0000000..b89475d
--- /dev/null
+++ b/tests/app_cheese.pm
@@ -0,0 +1,13 @@
+use base 'app_test';
+use strict;
+use warnings;
+use testapi;
+use gnomeutils;
+
+sub run {
+    start_app('cheese');
+    assert_screen('app_cheese_home', 10);
+    close_app;
+}
+
+1;
diff --git a/tests/app_epiphany.pm b/tests/app_epiphany.pm
new file mode 100644
index 0000000..90ce24f
--- /dev/null
+++ b/tests/app_epiphany.pm
@@ -0,0 +1,13 @@
+use base 'app_test';
+use strict;
+use warnings;
+use testapi;
+use gnomeutils;
+
+sub run {
+    start_app('epiphany');
+    assert_screen('app_epiphany_home', 10);
+    close_app;
+}
+
+1;
diff --git a/tests/app_gnome_weather.pm b/tests/app_gnome_weather.pm
new file mode 100644
index 0000000..33c3b29
--- /dev/null
+++ b/tests/app_gnome_weather.pm
@@ -0,0 +1,13 @@
+use base 'app_test';
+use strict;
+use warnings;
+use testapi;
+use gnomeutils;
+
+sub run {
+    start_app('gnome-weather');
+    assert_screen('app_gnome_weather_home', 10);
+    close_app;
+}
+
+1;
diff --git a/tests/app_nautilus.pm b/tests/app_nautilus.pm
new file mode 100644
index 0000000..1737d86
--- /dev/null
+++ b/tests/app_nautilus.pm
@@ -0,0 +1,17 @@
+use base 'app_test';
+use strict;
+use warnings;
+use testapi;
+use gnomeutils;
+
+sub run {
+    start_app('nautilus');
+    assert_screen('app_nautilus_home', 10);
+    close_app;
+}
+
+sub test_flags {
+    return { fatal => 0 };
+}
+
+1;
diff --git a/tests/app_settings.pm b/tests/app_settings.pm
index 96986e3..b6f79cd 100644
--- a/tests/app_settings.pm
+++ b/tests/app_settings.pm
@@ -1,16 +1,17 @@
-use base 'basetest';
+use base 'app_test';
 use strict;
+use warnings;
 use testapi;
 use gnomeutils;
 
 sub run {
     start_app('gnome-control-center');
     assert_screen('app_settings_startup', 10);
-    send_key('alt-f4');
+    close_app;
 }
 
 sub test_flags {
-    return { fatal => 1 };
+    return { fatal => 0 };
 }
 
 1;
diff --git a/tests/app_simple_scan.pm b/tests/app_simple_scan.pm
new file mode 100644
index 0000000..42427f4
--- /dev/null
+++ b/tests/app_simple_scan.pm
@@ -0,0 +1,17 @@
+use base 'app_test';
+use strict;
+use warnings;
+use testapi;
+use gnomeutils;
+
+sub run {
+    start_app('simple-scan');
+    assert_screen('app_simple_scan_home', 10);
+    close_app;
+}
+
+sub test_flags {
+    return { fatal => 0 };
+}
+
+1;


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