From 943c4193d3669d7df32bbe0ec2a82f24730b3dec Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 11 Jun 2024 16:21:00 -0700 Subject: [PATCH] Factor out the KDE launcher double-typing workaround, use it more There's a couple of places where we do menu_launch_type in KDE without doing this workaround first, and they do run into the bug sometimes. Let's factor it out from the few places it's already repeated, and add it to the places it is missing. Signed-off-by: Adam Williamson --- lib/utils.pm | 16 +++++++++++++++- tests/applications/keyring/keyring_password.pm | 2 ++ .../applications/keyring/keyring_passwordless.pm | 2 ++ tests/apps_startstop/kde/aasetting.pm | 9 +-------- tests/desktop_printing.pm | 4 ++++ tests/desktop_update_graphical.pm | 9 ++------- tests/graphical_upgrade_run.pm | 9 ++------- 7 files changed, 28 insertions(+), 23 deletions(-) diff --git a/lib/utils.pm b/lib/utils.pm index 784d1fd8..fdab662c 100644 --- a/lib/utils.pm +++ b/lib/utils.pm @@ -7,7 +7,7 @@ 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 download_modularity_tests quit_firefox advisory_get_installed_packages 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/; +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 download_modularity_tests quit_firefox advisory_get_installed_packages 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/; # We introduce this global variable to hold the list of applications that have @@ -1764,4 +1764,18 @@ sub start_applications { 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 { + wait_screen_change { send_key 'super'; }; + wait_still_screen 3; + send_key "k"; + wait_still_screen 5; + send_key "esc"; +} + 1; diff --git a/tests/applications/keyring/keyring_password.pm b/tests/applications/keyring/keyring_password.pm index 52f435d7..bfde6409 100644 --- a/tests/applications/keyring/keyring_password.pm +++ b/tests/applications/keyring/keyring_password.pm @@ -63,6 +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"); # Export the environmental variables, this is needed for the process diff --git a/tests/applications/keyring/keyring_passwordless.pm b/tests/applications/keyring/keyring_passwordless.pm index 9662b2a2..88641c9c 100644 --- a/tests/applications/keyring/keyring_passwordless.pm +++ b/tests/applications/keyring/keyring_passwordless.pm @@ -34,6 +34,8 @@ sub connect_localhost { 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(); diff --git a/tests/apps_startstop/kde/aasetting.pm b/tests/apps_startstop/kde/aasetting.pm index b600838e..96257dda 100644 --- a/tests/apps_startstop/kde/aasetting.pm +++ b/tests/apps_startstop/kde/aasetting.pm @@ -9,14 +9,7 @@ use utils; sub run { my $self = shift; solidify_wallpaper; - # to try and avoid problems with kde grinding a lot on first - # attempt to do a menu_launch_type, let's do a throwaway one - # here before we snapshot - wait_screen_change { send_key 'super'; }; - wait_still_screen 3; - send_key "k"; - wait_still_screen 5; - send_key "esc"; + kde_doublek_workaround; } sub test_flags { diff --git a/tests/desktop_printing.pm b/tests/desktop_printing.pm index 59f71233..cd9b241e 100644 --- a/tests/desktop_printing.pm +++ b/tests/desktop_printing.pm @@ -52,6 +52,10 @@ sub run { # give the desktop a few seconds to settle, we seem to be getting # a lot of mis-types in KDE if we do not, as of 2024-02 wait_still_screen(3); + # On KDE, try and avoid double-typing issues + if ($desktop eq "kde") { + kde_doublek_workaround; + } # 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. menu_launch_type($term); diff --git a/tests/desktop_update_graphical.pm b/tests/desktop_update_graphical.pm index f49a8dc1..be52159d 100644 --- a/tests/desktop_update_graphical.pm +++ b/tests/desktop_update_graphical.pm @@ -23,13 +23,8 @@ sub run { # run the updater if ($desktop eq 'kde') { - # try and avoid double-typing issues, same way we do - # for apps_startstop test - wait_screen_change { send_key 'super'; }; - wait_still_screen 3; - send_key "k"; - wait_still_screen 5; - send_key "esc"; + # try and avoid double-typing issues + kde_doublek_workaround; menu_launch_type('discover'); # Wait for it to run and maximize it to make sure we see the # Updates entry diff --git a/tests/graphical_upgrade_run.pm b/tests/graphical_upgrade_run.pm index 262a8fee..947b6689 100644 --- a/tests/graphical_upgrade_run.pm +++ b/tests/graphical_upgrade_run.pm @@ -41,14 +41,9 @@ sub run { } # Let's check, that the desktop is shown. check_desktop(); - # On KDE, try and avoid double-typing issues, same way we do - # for apps_startstop test + # On KDE, try and avoid double-typing issues if ($desktop eq "kde") { - wait_screen_change { send_key 'super'; }; - wait_still_screen 3; - send_key "k"; - wait_still_screen 5; - send_key "esc"; + kde_doublek_workaround; } # Start the package manager application depending