From 43b990195c7672446b036f70bb2613562a0e8576 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 28 May 2019 09:41:33 -0700 Subject: [PATCH] Add a wrapper around assert_and_click to handle signature change So, turns out new os-autoinst does *not* still accept the old argument style for assert_and_click...and old os-autoinst doesn't accept the new one. This adds a wrapper that handles both, so our tests can work with old and new os-autoinst. We can drop this once both deployments are on newer os-autoinst. Signed-off-by: Adam Williamson --- lib/utils.pm | 24 ++++++++++++++++++++++-- tests/_boot_to_anaconda.pm | 4 ++-- tests/desktop_update_graphical.pm | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/utils.pm b/lib/utils.pm index fee61559..d32a1546 100644 --- a/lib/utils.pm +++ b/lib/utils.pm @@ -7,7 +7,7 @@ use Exporter; 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 start_cockpit repo_setup gnome_initial_setup anaconda_create_user check_desktop_clean 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 bypass_1691487 get_release_number/; +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 start_cockpit repo_setup gnome_initial_setup anaconda_create_user check_desktop_clean 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 bypass_1691487 get_release_number _assert_and_click/; sub run_with_error_check { my ($func, $error_screen) = @_; @@ -570,7 +570,7 @@ sub anaconda_create_user { @_ ); my $user_login = get_var("USER_LOGIN") || "test"; - assert_and_click("anaconda_install_user_creation", timeout=>$args{timeout}); + _assert_and_click("anaconda_install_user_creation", timeout=>$args{timeout}); assert_screen "anaconda_install_user_creation_screen"; # wait out animation wait_still_screen 2; @@ -884,3 +884,23 @@ sub get_release_number { return $rawrel if ($version eq "Rawhide"); return $version } + +sub _assert_and_click { + # this is a wrapper around assert_and_click which handles this: + # https://github.com/os-autoinst/os-autoinst/pull/1075/files + # it changed the signature without any backward compatibility, so + # earlier os-autoinsts require an *array* of args, but later ones + # require a *hash* of args. This works with both. + my $version = $OpenQA::Isotovideo::Interface::version; + my ($mustmatch, %args) = @_; + if ($version > 13) { + return assert_and_click($mustmatch, %args); + } + else { + $args{timeout} //= $bmwqemu::default_timeout; + $args{button} //= 'left'; + $args{dclick} //= 0; + $args{mousehide} //= 0; + return assert_and_click($mustmatch, $args{button}, $args{timeout}, 0, $args{dclick}); + } +} diff --git a/tests/_boot_to_anaconda.pm b/tests/_boot_to_anaconda.pm index cf3d8425..d2c6c582 100644 --- a/tests/_boot_to_anaconda.pm +++ b/tests/_boot_to_anaconda.pm @@ -56,12 +56,12 @@ sub run { } else { # on lives, we have to explicitly launch anaconda if (get_var('LIVE')) { - assert_and_click("live_start_anaconda_icon", timeout=>300); + _assert_and_click("live_start_anaconda_icon", timeout=>300); } my $language = get_var('LANGUAGE') || 'english'; # wait for anaconda to appear; we click to work around # RHBZ #1566066 if it happens - assert_and_click("anaconda_select_install_lang", timeout=>300); + _assert_and_click("anaconda_select_install_lang", timeout=>300); # Select install language wait_screen_change { assert_and_click "anaconda_select_install_lang_input"; }; type_safely $language; diff --git a/tests/desktop_update_graphical.pm b/tests/desktop_update_graphical.pm index ae7d12f9..6c43e3dc 100644 --- a/tests/desktop_update_graphical.pm +++ b/tests/desktop_update_graphical.pm @@ -57,7 +57,7 @@ sub run { # already be visible at this point, we may not need to refresh unless (check_screen ['desktop_package_tool_update_apply', 'desktop_package_tool_update_download'], 5) { # refresh updates - assert_and_click('desktop_package_tool_update_refresh', timeout=>120); + _assert_and_click('desktop_package_tool_update_refresh', timeout=>120); } # wait for refresh, then apply updates, moving the mouse every two # minutes to avoid the idle screen blank kicking in. Depending on