diff --git a/lib/utils.pm b/lib/utils.pm index 150ea757..2edbc8b0 100644 --- a/lib/utils.pm +++ b/lib/utils.pm @@ -6,7 +6,7 @@ use base 'Exporter'; use Exporter; use lockapi; use testapi qw(is_serial_terminal :DEFAULT); -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 setup_repos repo_setup get_workarounds disable_updates_repos cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup anaconda_create_user check_desktop quit_firefox advisory_get_installed_packages acnp_handle_output advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log 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 desktop_launch_terminal/; +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 setup_repos repo_setup get_workarounds disable_updates_repos cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup anaconda_create_user check_desktop quit_firefox advisory_get_installed_packages acnp_handle_output advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log repos_mirrorlist register_application get_registered_applications desktop_launch_terminal 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 @@ -1609,6 +1609,22 @@ sub register_application { print("APPLICATION REGISTERED: $application \n"); } +# launch a terminal from a desktop, using the most efficient/reliable +# approach (not appropriate if we really need to test launching it a +# specific way) +sub desktop_launch_terminal { + my $desktop = get_var("DESKTOP"); + if ($desktop eq "i3") { + send_key "alt-ret"; + } + elsif ($desktop eq "kde") { + send_key "ctrl-alt-t"; + } + else { + menu_launch_type "terminal"; + } +} + # The KDE desktop tests are very difficult to maintain, because the transparency # of the menu requires a lot of different needles to cover the elements. # Therefore it is useful to change the background to a solid colour. @@ -1652,7 +1668,8 @@ sub solidify_wallpaper { } elsif ($desktop eq "gnome") { # Start the terminal to set up backgrounds. - menu_launch_type("terminal"); + desktop_launch_terminal; + assert_screen "apps_run_terminal"; # wait to be sure it's fully open wait_still_screen(stilltime => 5, similarity_level => 38); # When the application opens, run command in it to set the background to black @@ -1760,7 +1777,8 @@ sub set_update_notification_timestamp { sub start_applications { my @applications = @_; # Open the terminal - menu_launch_type("terminal"); + desktop_launch_terminal; + assert_screen("apps_run_terminal"); wait_still_screen(2); # Iterate over the application list # and start each application from it. @@ -1822,20 +1840,4 @@ sub dm_perform_login { send_key "ret"; } -# launch a terminal from a desktop, using the most efficient/reliable -# approach (not appropriate if we really need to test launching it a -# specific way) -sub desktop_launch_terminal { - my $desktop = get_var("DESKTOP"); - if ($desktop eq "i3") { - send_key "alt-ret"; - } - elsif ($desktop eq "kde") { - send_key "ctrl-alt-t"; - } - else { - menu_launch_type "terminal"; - } -} - 1; diff --git a/tests/_vncconnect_client_setup.pm b/tests/_vncconnect_client_setup.pm index 176bfe40..2bba5742 100644 --- a/tests/_vncconnect_client_setup.pm +++ b/tests/_vncconnect_client_setup.pm @@ -6,7 +6,8 @@ use utils; sub run { my $self = shift; - menu_launch_type 'terminal'; + desktop_launch_terminal; + assert_screen "apps_run_terminal"; wait_still_screen 5; type_very_safely "vncviewer -FullScreen -listen\n"; mutex_create 'vncconnect_client_ready'; diff --git a/tests/applications/gnome-panel/volumebar.pm b/tests/applications/gnome-panel/volumebar.pm index 7917b925..8fb72620 100644 --- a/tests/applications/gnome-panel/volumebar.pm +++ b/tests/applications/gnome-panel/volumebar.pm @@ -24,7 +24,7 @@ sub run { my $self = shift; # Open the terminal to enable us to set the # volume level. - menu_launch_type("terminal"); + desktop_launch_terminal; assert_screen("apps_run_terminal"); # Set the volume to 0% type_safely('amixer -D pipewire sset Master 0%'); diff --git a/tests/applications/keyring/keyring_password.pm b/tests/applications/keyring/keyring_password.pm index fe2086bc..9dbce531 100644 --- a/tests/applications/keyring/keyring_password.pm +++ b/tests/applications/keyring/keyring_password.pm @@ -63,10 +63,8 @@ sub connect_localhost { # Therefore, we will use a different approach - we will enable # CLI keyring integration and perform an SFTP connection # in Konsole. - # try and avoid double-typing issues - kde_doublek_workaround; - menu_launch_type("konsole"); - assert_screen("konsole_runs"); + desktop_launch_terminal; + assert_screen("apps_run_terminal"); # Export the environmental variables, this is needed for the process # to work correctly. export_kde_vars(); diff --git a/tests/applications/keyring/keyring_passwordless.pm b/tests/applications/keyring/keyring_passwordless.pm index f09f9ab5..0234e510 100644 --- a/tests/applications/keyring/keyring_passwordless.pm +++ b/tests/applications/keyring/keyring_passwordless.pm @@ -28,18 +28,11 @@ sub export_kde_vars { sub connect_localhost { my $type = shift; - # Start the terminal application. On KDE also export the variables. - if (get_var("DESKTOP") eq "gnome") { - menu_launch_type("terminal"); - assert_screen("apps_run_terminal"); - } - else { - # try and avoid double-typing issues - kde_doublek_workaround; - menu_launch_type("konsole"); - assert_screen("konsole_runs"); - export_kde_vars(); - } + # Start the terminal application + desktop_launch_terminal; + assert_screen("apps_run_terminal"); + # On KDE also export the variables + export_kde_vars() if (get_var("DESKTOP") eq "kde"); # Establish the SFTP connection to the localhost. # A dialogue should appear to collect credentials to open diff --git a/tests/apps_startstop/kde/konsole.pm b/tests/apps_startstop/kde/konsole.pm index 0ed45e60..e7c667d8 100644 --- a/tests/apps_startstop/kde/konsole.pm +++ b/tests/apps_startstop/kde/konsole.pm @@ -9,6 +9,8 @@ sub run { my $self = shift; # Start the application + # we don't use desktop_launch_terminal here as we specifically + # want to run 'konsole' from the kicker menu in this test menu_launch_type 'konsole'; # Check that it is started assert_screen 'konsole_runs', timeout => 60; diff --git a/tests/check_default_fonts.pm b/tests/check_default_fonts.pm index 9e1480db..bbc89712 100644 --- a/tests/check_default_fonts.pm +++ b/tests/check_default_fonts.pm @@ -27,12 +27,12 @@ sub run { desktop_switch_layout 'ascii'; wait_still_screen(2); - menu_launch_type("terminal"); + desktop_launch_terminal; # Similarly to _graphical_input.pm, repeat running the command # if it fails the first time (it often does). unless (check_screen "apps_run_terminal", 30) { check_desktop; - menu_launch_type("terminal"); + desktop_launch_terminal; } assert_screen("apps_run_terminal"); wait_still_screen(stilltime => 5, similarity_level => 42); diff --git a/tests/desktop_notifications.pm b/tests/desktop_notifications.pm index b5f597d2..ca2501b7 100644 --- a/tests/desktop_notifications.pm +++ b/tests/desktop_notifications.pm @@ -146,7 +146,7 @@ sub run { # we launch a terminal so that the top of the screen is filled with # something that we know and can check that it is not covered by a # notification popup from dunst - send_key('alt-ret'); + desktop_launch_terminal; assert_screen("apps_run_terminal"); assert_script_run('notify-send -t 10000 "foo"'); assert_screen("i3_dunst_foo_notification", timeout => 5); diff --git a/tests/desktop_printing.pm b/tests/desktop_printing.pm index dd28a5a4..6fa79569 100644 --- a/tests/desktop_printing.pm +++ b/tests/desktop_printing.pm @@ -71,17 +71,11 @@ sub run { } # Let's open the terminal. We will use it to start the applications # as well as to check for the name of the printed file. - if ($desktop eq "i3") { - send_key('alt-ret'); - assert_screen("apps_run_terminal"); - # switch to tabbed mode - send_key("alt-w"); - } - else { - menu_launch_type($term); - wait_still_screen(5); - } - + desktop_launch_terminal; + assert_screen("apps_run_terminal"); + wait_still_screen 3; + # switch to tabbed mode + send_key("alt-w") if ($desktop eq "i3"); # Open the text editor and maximize it. wait_screen_change { type_very_safely "$editor /home/$user/testfile.txt &\n"; }; wait_still_screen(stilltime => 2, similarity_level => 45); diff --git a/tests/desktop_terminal.pm b/tests/desktop_terminal.pm index b7468737..74a87b93 100644 --- a/tests/desktop_terminal.pm +++ b/tests/desktop_terminal.pm @@ -10,12 +10,7 @@ sub run { check_desktop; # try and avoid double-typing issues kde_doublek_workaround(key => 't') if ($desktop eq "kde"); - if ($desktop eq "i3") { - send_key("alt-ret"); - } - else { - menu_launch_type('terminal'); - } + desktop_launch_terminal; assert_screen "apps_run_terminal"; wait_still_screen(stilltime => 5, similarity_level => 42); # need to be root diff --git a/tests/i3_tiling.pm b/tests/i3_tiling.pm index f854d92f..ab96158d 100644 --- a/tests/i3_tiling.pm +++ b/tests/i3_tiling.pm @@ -7,7 +7,7 @@ sub run { my $password = get_var('USER_PASSWORD', 'weakpassword'); # launch a terminal first - send_key("alt-ret"); + desktop_launch_terminal; assert_screen("apps_run_terminal"); # start blivet_gui, mousepad and check that they are split on the screen