From 10b10e7085833d35b43ca5f5d4b196e9244fff7f Mon Sep 17 00:00:00 2001 From: Trevor Cooper Date: Mon, 30 Sep 2024 20:20:42 -0700 Subject: [PATCH 1/5] restore various application test suites --- templates.fif.json | 209 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 209 insertions(+) diff --git a/templates.fif.json b/templates.fif.json index dcd6bb61..27789f7b 100644 --- a/templates.fif.json +++ b/templates.fif.json @@ -470,6 +470,17 @@ } }, "TestSuites": { + "apps_startstop": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "STARTSTOP": "true", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, "anaconda_help": { "profiles": { "rocky-dvd-iso-s390x-*-s390x": 20, @@ -658,6 +669,204 @@ "START_AFTER_TEST": "install_lvm_ext4" } }, + "archiver": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/archiver", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "calculator": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/calculator", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "characters": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/characters", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "clocks": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/clocks", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "contacts": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/contacts", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "disks": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/disks", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "evince": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/evince", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "fonts": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/fonts", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "gnome-panel": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/gnome-panel", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "gnome_text_editor": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/gnome-text-editor", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "help_viewer": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/help", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "loupe": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/loupe", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "maps": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/maps", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "nautilus": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/nautilus", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "navigation": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/navigation", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "sysmon": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/sysmon", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "tour": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/tour", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, + "weather": { + "profiles": { + "rocky-dvd-iso-x86_64-*-uefi": 50 + }, + "settings": { + "BOOTFROM": "c", + "HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2", + "POSTINSTALL_PATH": "tests/applications/weather", + "START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%" + } + }, "install_anaconda_text": { "profiles": { "rocky-universal-s390x-*-s390x": 20, From f6b823d5c6c4ca7f44dab64b543fecf50afab316 Mon Sep 17 00:00:00 2001 From: AlanMarshall Date: Sat, 9 Nov 2024 19:13:57 +0000 Subject: [PATCH 2/5] Restore functions for applications tests. From upstream: support functions added to lib/utils.pm clocks functions directory added in tests/applications/ minor correction in ...evince/aaa_setup.pm --- lib/utils.pm | 157 ++++++++++++++++++++++++- tests/applications/clocks/aaa_setup.pm | 47 ++++++++ tests/applications/clocks/about.pm | 29 +++++ tests/applications/clocks/alarm.pm | 68 +++++++++++ tests/applications/clocks/help.pm | 24 ++++ tests/applications/clocks/shortcuts.pm | 24 ++++ tests/applications/clocks/stopwatch.pm | 52 ++++++++ tests/applications/clocks/timer.pm | 41 +++++++ tests/applications/clocks/world.pm | 60 ++++++++++ tests/applications/evince/aaa_setup.pm | 2 +- 10 files changed, 502 insertions(+), 2 deletions(-) create mode 100644 tests/applications/clocks/aaa_setup.pm create mode 100644 tests/applications/clocks/about.pm create mode 100644 tests/applications/clocks/alarm.pm create mode 100644 tests/applications/clocks/help.pm create mode 100644 tests/applications/clocks/shortcuts.pm create mode 100644 tests/applications/clocks/stopwatch.pm create mode 100644 tests/applications/clocks/timer.pm create mode 100644 tests/applications/clocks/world.pm diff --git a/lib/utils.pm b/lib/utils.pm index cd7cae9e..3d866f5b 100644 --- a/lib/utils.pm +++ b/lib/utils.pm @@ -8,7 +8,7 @@ use Exporter; use feature "switch"; use lockapi; use testapi; -our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us do_bootloader boot_decrypt check_release menu_launch_type repo_setup cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup anaconda_create_user check_desktop download_modularity_tests quit_firefox advisory_get_installed_packages advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut lo_dismiss_tip disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile get_release_number get_version_major get_code_name check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log click_unwanted_notifications repos_mirrorlist register_application get_registered_applications solidify_wallpaper/; +our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us do_bootloader boot_decrypt check_release menu_launch_type repo_setup cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup anaconda_create_user check_desktop download_modularity_tests quit_firefox advisory_get_installed_packages advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut lo_dismiss_tip disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile get_release_number get_version_major get_code_name check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log click_unwanted_notifications repos_mirrorlist register_application get_registered_applications solidify_wallpaper check_and_install_git download_testdata make_serial_writable set_update_notification_timestamp kde_doublek_workaround dm_perform_login/; # We introduce this global variable to hold the list of applications that have # registered during the apps_startstop_test when they have sucessfully run. @@ -1381,4 +1381,159 @@ sub solidify_wallpaper { } } +# This routine is used in Desktop test suites, such as Evince or Gedit. +# It checks if git is installed and installs it, if necessary. +sub check_and_install_git { + unless (get_var("CANNED")) { + if (script_run("rpm -q git")) { + assert_script_run("dnf install -y git"); + } + } +} + +# This routine is used in Desktop test suites. It downloads the test data from +# the repository and populates the directory structure. +# The data repository is located at https://pagure.io/fedora-qa/openqa_testdata. + +sub download_testdata { + # We can select which Data to copy over. + my $data = shift; + $data = 'structure' unless ($data); + # Navigate to the user's home directory + my $user = get_var("USER_LOGIN") // "test"; + assert_script_run("cd /home/$user/"); + # Create a temporary directory to unpack the zipped file. + assert_script_run("mkdir temp"); + assert_script_run("cd temp"); + # Download the compressed file with the repository content. + assert_script_run("curl --retry-delay 10 --max-time 120 --retry 5 -o repository.tar.gz https://pagure.io/fedora-qa/openqa_testdata/blob/thetree/f/repository.tar.gz", timeout => 600); + # Untar it. + assert_script_run("tar -zxvf repository.tar.gz"); + # Copy out the files into the VMs directory structure. + if ($data eq "structure") { + assert_script_run("cp music/* /home/$user/Music"); + assert_script_run("cp documents/* /home/$user/Documents"); + assert_script_run("cp pictures/* /home/$user/Pictures"); + assert_script_run("cp video/* /home/$user/Videos"); + assert_script_run("cp reference/* /home/$user/"); + } + else { + assert_script_run("mkdir /home/$user/$data"); + assert_script_run("cp $data/* /home/$user/$data/"); + } + # Delete the temporary directory and the downloaded file. + assert_script_run("cd"); + assert_script_run("rm -rf /home/$user/temp"); + # Change ownership + assert_script_run("chown -R test:test /home/$user/"); +} + +# On Fedora, the serial console is not writable for regular users which lames +# some of the openQA commands that send messages to the serial console to check +# that a command has finished, for example assert_script_run, etc. +# This routine changes the rights on the serial console file and makes it +# writable for everyone, so that those commands work. This is actually very useful +# for testing commands from users' perspective. The routine also handles becoming the root. +# We agree that this is not the "correct" way, to enable users to type onto serial console +# and that it correctly should be done via groups (dialout) but that would require rebooting +# the virtual machine. Therefore we do it this way, which has immediate effect. +sub make_serial_writable { + become_root(); + sleep 2; + # Make serial console writable for everyone. + enter_cmd("chmod 666 /dev/${serialdev}"); + sleep 2; + # Exit the root account + enter_cmd("exit"); + sleep 2; +} + +# Sometimes, especially in between freezes, there are Software Updates available +# that trigger a notification pop-up which covers some part of the screen +# and possibly steals focus from the applications, thus making tests to fail. +# This will set the update notification timestamp to the current time (-30 seconds), +# forcing the notification mechanism to think it already had notified. +# Note, that this has to be run under the user under which the tests run, +# not root. +sub set_update_notification_timestamp { + # Get the current time + my $ep_time = time(); + # Subtract 30 seconds from the number. + $ep_time -= 30; + # Run a command using the command dialogue + send_key('alt-f2'); + wait_still_screen(2); + # Set the new timestamp using the gsettings command. + type_very_safely("gsettings set org.gnome.software update-notification-timestamp $ep_time\n"); +} + +# This routine takes a list of applications. It will then use the terminal +# to start all these applications in the background and then it will exit the +# terminal. This is useful when we want to start multiple applications quickly. +sub start_applications { + my @applications = @_; + # Open the terminal + desktop_launch_terminal(); + assert_screen("apps_run_terminal"); + wait_still_screen(2); + # Iterate over the application list + # and start each application from it. + foreach (@applications) { + assert_script_run("$_ &"); + # Take some time for things to settle. + wait_still_screen(1); + } + # Exit the terminal. + enter_cmd("exit"); +} + +# this is a workaround for an annoying KDE bug where the first character +# typed into the launcher is often repeated. I think it's due to KDE +# working hard to cache all the launchers, or something, so we try to +# work around it by doing a 'throwaway' open, type a 'k', wait a bit, +# close operation before we do anything 'real'. this is repeated in +# several tests so we share it here +sub kde_doublek_workaround { + my %args = @_; + $args{key} //= 'k'; + wait_screen_change { send_key 'super'; }; + wait_still_screen 3; + send_key $args{key}; + wait_still_screen 5; + send_key 'esc'; + wait_still_screen 3; +} + +# handle login at a graphical DM once we have reached the initial +# DM screen. Factored out of _graphical_wait_login for reuse by +# tests that reboot and need to login afterwards +sub dm_perform_login { + my ($desktop, $password) = @_; + # GDM 3.24.1 dumps a cursor in the middle of the screen here... + mouse_hide; + if ($desktop eq 'gnome') { + # we have to hit enter to get the password dialog, and it + # doesn't always work for some reason so just try it three + # times + send_key_until_needlematch("graphical_login_input", "ret", 3, 5); + } + assert_screen "graphical_login_input"; + # seems like we often double-type on aarch64 if we start right + # away + wait_still_screen(stilltime => 5, similarity_level => 38); + if (get_var("SWITCHED_LAYOUT")) { + # see _do_install_and_reboot; when layout is switched + # user password is doubled to contain both US and native + # chars + desktop_switch_layout 'ascii'; + type_very_safely $password; + desktop_switch_layout 'native'; + type_very_safely $password; + } + else { + type_very_safely $password; + } + send_key "ret"; +} + 1; diff --git a/tests/applications/clocks/aaa_setup.pm b/tests/applications/clocks/aaa_setup.pm new file mode 100644 index 00000000..6ea1d232 --- /dev/null +++ b/tests/applications/clocks/aaa_setup.pm @@ -0,0 +1,47 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +# This script will start the Gnome Clocks application and save the status +# for any subsequent tests. + +sub run { + my $self = shift; + + # At first, we need to set time and time zones manually. + $self->root_console(tty => 3); + # Switch off automatic time. + assert_script_run("timedatectl set-ntp 0"); + # Set the time zone + assert_script_run("timedatectl set-timezone Europe/Prague"); + # Set the time and date + assert_script_run("timedatectl set-time '2022-09-09 09:00:00'"); + # Return back + desktop_vt(); + + # Set the update notification timestamp + set_update_notification_timestamp(); + + # Start the Application + menu_launch_type("clocks"); + assert_screen ["apps_run_clocks", "grant_access"]; + # give access rights if asked + if (match_has_tag 'grant_access') { + click_lastmatch; + assert_screen 'apps_run_clocks'; + } + + # Make it fill the entire window. + send_key("super-up"); + wait_still_screen(2); +} + +sub test_flags { + # If this test fails, there is no need to continue. + return {fatal => 1, milestone => 1}; +} + +1; + +# vim: set sw=4 et: diff --git a/tests/applications/clocks/about.pm b/tests/applications/clocks/about.pm new file mode 100644 index 00000000..4bda6811 --- /dev/null +++ b/tests/applications/clocks/about.pm @@ -0,0 +1,29 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +# I as a user want to be able use the menu to enter further functions. + +sub run { + my $self = shift; + + # Click on the burger menu. + assert_and_click("gnome_burger_menu"); + + # Click on About Clocks to see the About info. + assert_and_click("clocks_menu_about"); + assert_screen("clocks_about_displayed"); + assert_and_click("gnome_button_credits"); + assert_screen("clocks_credits_shown"); + +} + +sub test_flags { + # Rollback after test is over. + return {always_rollback => 1}; +} + +1; + +# vim: set sw=4 et: diff --git a/tests/applications/clocks/alarm.pm b/tests/applications/clocks/alarm.pm new file mode 100644 index 00000000..8d2ef5b5 --- /dev/null +++ b/tests/applications/clocks/alarm.pm @@ -0,0 +1,68 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +# I as a user want to be able to add, edit and remove alarms. + +sub run { + my $self = shift; + + # Click on the Alarm button. + assert_and_click("clocks_button_alarm"); + + # Add a new alarm using the Add Alarm button + assert_and_click("clocks_button_add_alarm"); + assert_and_click("clocks_alarm_hour"); + wait_still_screen 2; + send_key("ctrl-a"); + wait_still_screen(2); + type_very_safely("09"); + send_key("tab"); + type_very_safely("04"); + assert_and_click("clocks_set_snooze"); + assert_and_click("clocks_set_snooze_time"); + assert_and_click("gnome_add_button"); + assert_screen("clocks_alarm_active"); + + # Wait until the alarm goes on, two buttons will be shown. This should not take + # more than three minutes. + # A snooze button should become visible, click it. + assert_and_click("clocks_button_alarm_snooze", timeout => 240); + assert_screen("clocks_alarm_snooze_confirmed"); + # After another minute or so, the alarm should ring again. + # This time we will use the stop button to stop it. + assert_and_click("clocks_button_alarm_stop", timeout => 120); + # Up to 46.0, the alarm would stay active after being stopped; from + # 46.0 onwards it goes inactive. FIXME this can be simplified to + # assume it starts at 'inactive' once we are no longer testing + # < 46.0 anywhere + assert_screen(["clocks_alarm_active", "clocks_alarm_inactive"]); + my $wasactive = match_has_tag("clocks_alarm_active"); + # Now toggle the switch to change its state + assert_and_click("gnome_button_toggle"); + # whichever state it was in, check it's now in the other + if ($wasactive) { + assert_screen("clocks_alarm_inactive"); + } + else { + assert_screen("clocks_alarm_active"); + } + # Delete alarm using the delete button. + assert_and_click("gnome_button_cross_remove"); + sleep 2; + if (check_screen(["clocks_alarm_active", "clocks_alarm_inactive"])) { + die("The alarm should have been deleted but it is still visible in the GUI"); + } + + +} + +sub test_flags { + # Rollback after test is over. + return {always_rollback => 1}; +} + +1; + +# vim: set sw=4 et: diff --git a/tests/applications/clocks/help.pm b/tests/applications/clocks/help.pm new file mode 100644 index 00000000..8f29e35a --- /dev/null +++ b/tests/applications/clocks/help.pm @@ -0,0 +1,24 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +# I as a user want to be able use the menu to enter further functions. + +sub run { + my $self = shift; + + # Click on the burger menu and display Help. + assert_and_click("gnome_burger_menu"); + assert_and_click("clocks_menu_help"); + assert_screen("clocks_help_shown"); +} + +sub test_flags { + # Rollback after test is over. + return {always_rollback => 1}; +} + +1; + +# vim: set sw=4 et: diff --git a/tests/applications/clocks/shortcuts.pm b/tests/applications/clocks/shortcuts.pm new file mode 100644 index 00000000..29124cf5 --- /dev/null +++ b/tests/applications/clocks/shortcuts.pm @@ -0,0 +1,24 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +# I as a user want to be able use the menu to enter further functions. + +sub run { + my $self = shift; + + # Use the menu to see the shortcuts + assert_and_click("gnome_burger_menu"); + assert_and_click("clocks_menu_shortcuts"); + assert_screen("clocks_shortcuts_shown"); +} + +sub test_flags { + # Rollback after test is over. + return {always_rollback => 1}; +} + +1; + +# vim: set sw=4 et: diff --git a/tests/applications/clocks/stopwatch.pm b/tests/applications/clocks/stopwatch.pm new file mode 100644 index 00000000..289ac161 --- /dev/null +++ b/tests/applications/clocks/stopwatch.pm @@ -0,0 +1,52 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +# I as a user want to be able to measure time using stopwatch. + +sub run { + my $self = shift; + + # Click on the Stopwatch button. + assert_and_click("clocks_button_stopwatch"); + + # Start the stopwatch, pause it, resume, and clear. + assert_and_click("clocks_stopwatch_button_start"); + # Wait some time and pause the stopwatch, read the + # time. + sleep(20); + assert_and_click("clocks_stopwatch_button_pause", timeout => 2); + assert_screen("clocks_stopwatch_time_reached"); + # Resume the measurement. + assert_and_click("clocks_stopwatch_button_resume"); + sleep(10); + # Press pause and read the time. + assert_and_click("clocks_stopwatch_button_pause", timeout => 2); + assert_screen("clocks_stopwatch_secondtime_reached"); + # Clear the stopwatch and check you can start it again. + assert_and_click("clocks_stopwatch_button_clear"); + assert_screen("clocks_stopwatch_button_start"); + + # Start the stopwatch, count several laps and assert. + assert_and_click("clocks_stopwatch_button_start"); + sleep(10); + assert_and_click("clocks_stopwatch_button_lap"); + sleep(10); + assert_and_click("clocks_stopwatch_button_lap"); + sleep(10); + assert_and_click("clocks_stopwatch_button_lap"); + assert_and_click("clocks_stopwatch_button_pause"); + assert_screen("clocks_stopwatch_laps_count"); + assert_screen("clocks_stopwatch_laps_times"); + assert_screen("clocks_stopwatch_laps_deltas"); +} + +sub test_flags { + # Rollback when tests are over. + return {always_rollback => 1}; +} + +1; + +# vim: set sw=4 et: diff --git a/tests/applications/clocks/timer.pm b/tests/applications/clocks/timer.pm new file mode 100644 index 00000000..867441f9 --- /dev/null +++ b/tests/applications/clocks/timer.pm @@ -0,0 +1,41 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +# I as a user want to be able to add, edit and remove timers. + +sub run { + my $self = shift; + + # Click on the Timer button. + assert_and_click("clocks_button_timer"); + + # Add a new alarm using the one minute button + assert_screen("clocks_timer_page"); + assert_and_click("clocks_button_timer_minute"); + # since GNOME 46, that was a 'quickstart', on older GNOME we + # have to hit start; remove this when no more F39 testing + if (check_screen("clocks_button_timer_start", 5)) { + wait_still_screen(2); + click_lastmatch; + } + sleep(10); + assert_and_click("clocks_button_timer_pause"); + assert_screen("clocks_timer_paused"); + assert_and_click("clocks_button_timer_start"); + # Wait a minute if the timer goes off. + assert_screen("clocks_timer_finished", timeout => 60); + # Delete the timeout + assert_and_click("gnome_button_delete"); + assert_screen("clocks_timer_page"); +} + +sub test_flags { + # Rollback after test is over. + return {always_rollback => 1}; +} + +1; + +# vim: set sw=4 et: diff --git a/tests/applications/clocks/world.pm b/tests/applications/clocks/world.pm new file mode 100644 index 00000000..3e229fb0 --- /dev/null +++ b/tests/applications/clocks/world.pm @@ -0,0 +1,60 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +# I as a user want to be able to add a new city in the World clock. + +sub run { + my $self = shift; + + # Click on the World button. + assert_and_click("clocks_button_world"); + + # Add a new location using the addition icon + assert_and_click("gnome_add_button_plus"); + wait_still_screen(2); + type_very_safely("Bratislava"); + assert_and_click("gnome_city_button_bratislava"); + assert_and_click("gnome_add_button"); + wait_still_screen(2); + diag("CLOCKS: Added the new city."); + # View city details + assert_and_click("clocks_city_added_bratislava"); + assert_screen("clocks_city_details"); + diag("CLOCKS: Details shown."); + + # Return back to overview + assert_and_click("clocks_button_back"); + assert_screen("clocks_city_added_bratislava"); + + # Add a new location using the keyboard shortcut + send_key("ctrl-n"); + wait_still_screen(2); + type_very_safely("Reykjav"); + assert_and_click("gnome_city_button_reykjavik"); + assert_and_click("gnome_add_button_blue"); + assert_screen("clocks_city_added_reykjavik"); + + # Click onto the Delete button to remove the listed cities. + # While there are cities to be removed, remove them. + while (check_screen("gnome_button_cross_remove", 3)) { + click_lastmatch(); + mouse_hide; + } + # If the cities are still visible, then die. + if (check_screen("clocks_city_added_bratislava")) { + die("The city Bratislava should have been removed, but it is still visible on the screen."); + } + if (check_screen("clocks_city_added_reykjavik")) { + die("The city Reykjavik should have been removed, but it is still visible on the screen."); + } +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + +# vim: set sw=4 et: diff --git a/tests/applications/evince/aaa_setup.pm b/tests/applications/evince/aaa_setup.pm index a0055366..703b8023 100644 --- a/tests/applications/evince/aaa_setup.pm +++ b/tests/applications/evince/aaa_setup.pm @@ -25,7 +25,7 @@ sub download_testdata { # Change ownership and attributes assert_script_run("chown -R test:test openqa_testdata"); # Move the test file into a correct location. - assert_script_run("cp openqa_testdata/evince/evince.pdf Documents"); + assert_script_run("cp openqa_testdata/documents/evince.pdf Documents"); } sub run { From 4cc86d7c38948a1bb619c441b6a61ecdaa67bdff Mon Sep 17 00:00:00 2001 From: AlanMarshall Date: Tue, 12 Nov 2024 15:44:37 +0000 Subject: [PATCH 3/5] Handle differences for Rocky --- lib/utils.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/utils.pm b/lib/utils.pm index 3d866f5b..fe16400f 100644 --- a/lib/utils.pm +++ b/lib/utils.pm @@ -118,6 +118,13 @@ sub desktop_vt { type_very_safely "weakpassword\n"; } } + else { + type_very_safely "\t"; + type_very_safely "\n"; + type_very_safely "weakpassword\n"; + wait_still_screen 3; + send_key 'alt-f1'; + } } # Wait for login screen to appear. Handle the annoying GPU buffer From 2bd20eed7c7a9f2f47e21c969975e5c22bb971aa Mon Sep 17 00:00:00 2001 From: AlanMarshall Date: Tue, 12 Nov 2024 16:01:20 +0000 Subject: [PATCH 4/5] Calculator tests added --- tests/applications/calculator/aaa_setup.pm | 26 +++++ tests/applications/calculator/about.pm | 36 +++++++ tests/applications/calculator/calculator.pm | 108 ++++++++++++++++++++ tests/applications/calculator/help.pm | 33 ++++++ 4 files changed, 203 insertions(+) create mode 100644 tests/applications/calculator/aaa_setup.pm create mode 100644 tests/applications/calculator/about.pm create mode 100644 tests/applications/calculator/calculator.pm create mode 100644 tests/applications/calculator/help.pm diff --git a/tests/applications/calculator/aaa_setup.pm b/tests/applications/calculator/aaa_setup.pm new file mode 100644 index 00000000..bd8aff9b --- /dev/null +++ b/tests/applications/calculator/aaa_setup.pm @@ -0,0 +1,26 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +# This script starts the Calculator and stores an image. + +sub run { + my $self = shift; + # Set update notification timestamp + set_update_notification_timestamp(); + # Run the application + menu_launch_type("Calculator"); + assert_screen("apps_run_calculator"); + # wait for system to settle before snapshotting + sleep 10; +} + +sub test_flags { + return {fatal => 1, milestone => 1}; +} + +1; + +# vim: set sw=4 et: + diff --git a/tests/applications/calculator/about.pm b/tests/applications/calculator/about.pm new file mode 100644 index 00000000..95fe6574 --- /dev/null +++ b/tests/applications/calculator/about.pm @@ -0,0 +1,36 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +# This script checks that Gnome Calculator shows About. + +sub run { + my $self = shift; + # Let's wait until everything settles down properly + # before we start testing. + sleep 5; + # Open the menu and click on the About item. + assert_and_click("gnome_burger_menu"); + wait_still_screen(2); + assert_and_click("calc_menu_about"); + # Check that it is shown. + assert_screen("calc_about_shown"); + # Click on the Credits button and check that it shows. + unless (check_screen("gnome_button_credits", 30)) { + send_key("pgdn"); + assert_screen("gnome_button_credits", 15); + record_soft_failure("https://gitlab.gnome.org/GNOME/gnome-calculator/-/issues/419"); + } + click_lastmatch; + assert_screen("calc_credits_shown"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + +# vim: set sw=4 et: + diff --git a/tests/applications/calculator/calculator.pm b/tests/applications/calculator/calculator.pm new file mode 100644 index 00000000..dbc6aadf --- /dev/null +++ b/tests/applications/calculator/calculator.pm @@ -0,0 +1,108 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +# This script checks that Gnome Calculator works in Basic mode. + +# This subroutine rewrites the number into a word. +sub rewrite { + my $number = shift; + my %numbers = ( + 0 => 'zero', + 1 => 'one', + 2 => 'two', + 3 => 'three', + 4 => 'four', + 5 => 'five', + 6 => 'six', + 7 => 'seven', + 8 => 'eight', + 9 => 'nine', + "." => 'divider', + "%" => 'percent', + "p" => 'pi', + "r" => 'root', + "s" => 'square' + ); + my $rewritten = $numbers{$number}; + return $rewritten; +} + +# This subroutine performs the clicking of simple operations +# in the Calculator. +sub calculate { + my ($a, $b, $operation) = @_; + # Create lists of the numbers. + my @first = split('', $a); + my @second = split('', $b); + + # For each digit of the first number, click on + # the corresponding button. + foreach (@first) { + my $word = rewrite($_); + assert_and_click("calc_button_$word"); + } + # Click the operation button. + assert_and_click("calc_button_$operation"); + # For each digit of the second number, click on + # the corresponding button. + foreach (@second) { + my $word = rewrite($_); + assert_and_click("calc_button_$word"); + } + # Click on the Equals button + assert_and_click("calc_button_equals"); + # Assert the result has appeared on the screen. + my $identifier = hashed_string("$a-$operation-$b"); + assert_screen("calc_result_$identifier"); + # Clear the display. + send_key("esc"); +} + +sub run { + my $self = shift; + # Wait until everything settles. + sleep 5; + # Check that two numbers can be added. + calculate("10", "23", "add"); + # Check that two numbers can be subtracted. + calculate("67", "45", "sub"); + # Check that two numbers can be multiplied. + calculate("9", "0.8", "multi"); + # Check that two numbers can be divided. + calculate("77", "7", "div"); + # Check that two numbers can be divided using modulo. + calculate("28", "5", "mod"); + # Check that you can count with Pi + calculate("p", "10", "multi"); + # Check that you can use a root + calculate("r144", "10", "add"); + # Check that you can use square + calculate("12s", "44", "sub"); + # Check that you can use percents + calculate("33%", "90", "multi"); + + # Check that you can use brackets + assert_and_click("calc_button_three"); + assert_and_click("calc_button_multi"); + assert_and_click("calc_button_bopen"); + assert_and_click("calc_button_two"); + assert_and_click("calc_button_add"); + assert_and_click("calc_button_three"); + assert_and_click("calc_button_bclose"); + assert_and_click("calc_button_equals"); + my $identifier = hashed_string("3*(3+2)"); + assert_screen("calc_result_$identifier"); + send_key("esc"); + +} + +sub test_flags { + return {fatal => 1}; +} + +1; + +# vim: set sw=4 et: + diff --git a/tests/applications/calculator/help.pm b/tests/applications/calculator/help.pm new file mode 100644 index 00000000..b4e670e5 --- /dev/null +++ b/tests/applications/calculator/help.pm @@ -0,0 +1,33 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +# This script checks that Gnome Calculator shows help. + +sub run { + my $self = shift; + # Wait until everything settles. + sleep 5; + # Open Help + send_key("f1"); + wait_still_screen(2); + + # Browse through a couple of links and + # check they are not empty. + assert_and_click("calc_help_using_keyboard"); + assert_screen("calc_help_keyboard"); + assert_and_click("calc_help_main_view"); + assert_and_click("calc_help_using_factorial"); + assert_screen("calc_help_factorial"); + assert_and_click("calc_help_main_view"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + +# vim: set sw=4 et: + From 529eff1e846d8b88dda1627eff5f2cb6bcc0d805 Mon Sep 17 00:00:00 2001 From: AlanMarshall Date: Tue, 12 Nov 2024 19:27:36 +0000 Subject: [PATCH 5/5] Disk tests added --- tests/applications/disks/aaa_setup.pm | 65 +++++++++++++++++++ tests/applications/disks/about.pm | 33 ++++++++++ tests/applications/disks/delete_partition.pm | 22 +++++++ tests/applications/disks/edit_filesystem.pm | 21 ++++++ tests/applications/disks/edit_partition.pm | 21 ++++++ tests/applications/disks/format_partition.pm | 23 +++++++ tests/applications/disks/mount_partitions.pm | 38 +++++++++++ tests/applications/disks/resize_partition.pm | 28 ++++++++ .../disks/standard_partitioning.pm | 38 +++++++++++ 9 files changed, 289 insertions(+) create mode 100644 tests/applications/disks/aaa_setup.pm create mode 100644 tests/applications/disks/about.pm create mode 100644 tests/applications/disks/delete_partition.pm create mode 100644 tests/applications/disks/edit_filesystem.pm create mode 100644 tests/applications/disks/edit_partition.pm create mode 100644 tests/applications/disks/format_partition.pm create mode 100644 tests/applications/disks/mount_partitions.pm create mode 100644 tests/applications/disks/resize_partition.pm create mode 100644 tests/applications/disks/standard_partitioning.pm diff --git a/tests/applications/disks/aaa_setup.pm b/tests/applications/disks/aaa_setup.pm new file mode 100644 index 00000000..3dcf78cf --- /dev/null +++ b/tests/applications/disks/aaa_setup.pm @@ -0,0 +1,65 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will prepare a disk image with the size of +# 1 GB and will add two partitions to it. This will serve as +# a milestone for other follow-up tests. +# + +# This script will test if Disks can create new partitions +# in an empty disk. + +sub run { + my $self = shift; + + # Switch to the console and perform some pre-settings. + # Switch to the console + $self->root_console(tty => 3); + # Create a disk image in the home folder. We have decided + # to use truncate to be able to create bigger partitions + # that would not require as much space on the disk when + # empty. + script_run("truncate -s 1G /root/disk.img"); + # Connect the created partition to the system as a loop device + # using losetup which will make it accessible to the Disks application + # later. + script_run("losetup -P -f --show /root/disk.img"); + + # Go back to graphics. + desktop_vt(); + # Set the update notification_timestamp + set_update_notification_timestamp(); + + menu_launch_type("disks"); + wait_still_screen(3); + + # Make it fill the entire window. + send_key("super-up"); + wait_still_screen(2); + assert_screen("apps_run_disks"); + + # Click on the listed icon of the new loop device. + assert_and_click("disks_diskloop_listed"); + # Check that the file has been correctly attached. + assert_screen("disks_diskloop_status"); + + # Format the entire disk with a GPT. + wipe_disk(); + + # Add partitions. + add_partitions(); +} + +sub test_flags { + # If this test fails, there is no need to continue. + return {fatal => 1, milestone => 1}; +} + +1; + +# vim: set sw=4 et: + + diff --git a/tests/applications/disks/about.pm b/tests/applications/disks/about.pm new file mode 100644 index 00000000..29bd0ac6 --- /dev/null +++ b/tests/applications/disks/about.pm @@ -0,0 +1,33 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; + +# This script will open the About dialogue and check +# that it works. + +sub run { + # Open the menu + assert_and_click("gnome_burger_menu"); + + # Click on the About item + assert_and_click("gnome_menu_about"); + + # Check that the dialogue is shown. + assert_screen("disks_about_shown"); + + # Click on the Credits button. + assert_and_click("gnome_button_credits"); + + # Check that Credits are shown. + assert_screen("disks_credits_shown"); + + # Dismiss the About window using the Esc key. + send_key("esc"); +} + +sub test_flags { + return {fatal => 0}; +} + +1; diff --git a/tests/applications/disks/delete_partition.pm b/tests/applications/disks/delete_partition.pm new file mode 100644 index 00000000..cb393ee9 --- /dev/null +++ b/tests/applications/disks/delete_partition.pm @@ -0,0 +1,22 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will test if Disks can delete a partition +# and add a new partition instead. + +sub run { + # Select the test disk. + assert_and_click("disks_loopdisk_listed"); + # Delete the second partition. + delete_partition("two"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + diff --git a/tests/applications/disks/edit_filesystem.pm b/tests/applications/disks/edit_filesystem.pm new file mode 100644 index 00000000..bd618565 --- /dev/null +++ b/tests/applications/disks/edit_filesystem.pm @@ -0,0 +1,21 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will test if Disks can edit the filesystem name. + +sub run { + # Click on the test disk to select it. + assert_and_click("disks_loopdisk_listed"); + # Edit the filesystem name. + edit_filesystem("one", "renamed"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + diff --git a/tests/applications/disks/edit_partition.pm b/tests/applications/disks/edit_partition.pm new file mode 100644 index 00000000..ca5772ec --- /dev/null +++ b/tests/applications/disks/edit_partition.pm @@ -0,0 +1,21 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will test if Disks can edit the partition name. + +sub run { + # Open the menu + assert_and_click("disks_loopdisk_listed"); + # Change the type of the partition. + edit_partition("one", "linuxroot", "partroot"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + diff --git a/tests/applications/disks/format_partition.pm b/tests/applications/disks/format_partition.pm new file mode 100644 index 00000000..1b613638 --- /dev/null +++ b/tests/applications/disks/format_partition.pm @@ -0,0 +1,23 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will test if Disks can format an empty +# partition. + +sub run { + # Select the test loop disk. + assert_and_click("disks_loopdisk_listed"); + + # Format partition + format_partition("one", "swap", "backup"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + diff --git a/tests/applications/disks/mount_partitions.pm b/tests/applications/disks/mount_partitions.pm new file mode 100644 index 00000000..46c21452 --- /dev/null +++ b/tests/applications/disks/mount_partitions.pm @@ -0,0 +1,38 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will test if current partitions can be mounted +# via the Disks application. + + +sub run { + my $self = shift; + + # Wipe the entire disk, recreate partitions + wipe_disk(); + add_partitions(); + + + # Mount the first partition. + mount_partition("one"); + + # Mount the second partition. + mount_partition("two"); + + # Check in the system that the partitions have been mounted. + $self->root_console(tty => 3); + # First partition + assert_script_run("findmnt /dev/loop0p1"); + # Second partition + assert_script_run("findmnt /dev/loop0p2"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + diff --git a/tests/applications/disks/resize_partition.pm b/tests/applications/disks/resize_partition.pm new file mode 100644 index 00000000..845b8d83 --- /dev/null +++ b/tests/applications/disks/resize_partition.pm @@ -0,0 +1,28 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will test if Disks can resize a partition and +# put a new partition after the resized one. + +sub run { + # Select the test loop disk. + assert_and_click("disks_loopdisk_listed"); + # Resize the second partition + resize_partition("two", "320"); + + # Add a new partition to the remainaing space + assert_and_click("disks_free_space"); + + # Create another partition in the remaining space. + create_partition("terciavolta", "full"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; + diff --git a/tests/applications/disks/standard_partitioning.pm b/tests/applications/disks/standard_partitioning.pm new file mode 100644 index 00000000..3026b2c3 --- /dev/null +++ b/tests/applications/disks/standard_partitioning.pm @@ -0,0 +1,38 @@ +use base "installedtest"; +use strict; +use testapi; +use utils; +use disks; + +# This script will test if Disks can delete all partitions and +# create three partitions for Standard partitioning, a small boot +# partition, a bigger root partition, and a home partition that +# takes the rest of the space. All partitions will be formatted +# as ext4. + +sub run { + # Select the test loop disk. + assert_and_click("disks_loopdisk_listed"); + + # Remove partitions + wipe_disk(); + + # Create the partitions (they are formatted as ext4) + create_partition("boot", "200"); + assert_and_click("disks_free_space"); + create_partition("root", "300"); + assert_and_click("disks_free_space"); + create_partition("home", "full"); + + # Mount the partitions + mount_partition("one"); + mount_partition("two"); + mount_partition("three"); +} + +sub test_flags { + return {always_rollback => 1}; +} + +1; +