1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2025-05-06 01:21:33 +00:00

Enhance the menu_launch_type subroutine.

The previous version of menu_launch_type took the name of the
application as an argument and it started the application.
To maximize the application or to check that it has started indeed
we had to do it manually.

Now, the application also takes "maximize => 1" or "checkstart => 1"
to maximize the application or check that it has started as optional
arguments to avoid doing it manually, while it still accepts just
the name of the application and behaves like it did before.

Note that if you decide to use the checkstart argument, you
also need to update the check-needles.py script to whitelist
the application needle tag, see the example test scripts
attached to this PR.

Fixes: https://pagure.io/fedora-qa/os-autoinst-distri-fedora/issue/329
This commit is contained in:
Lukáš Růžička 2025-02-10 13:48:47 +01:00 committed by adamwill
parent 891868e77a
commit 653fb2938f
11 changed files with 45 additions and 33 deletions

View File

@ -240,6 +240,10 @@ testtags.extend(f"anaconda_main_hub_{fsys}" for fsys in ('language_support', 'se
'time_date', 'create_user','keyboard_layout'))
for selection in ("hide", "maximize", "restore"):
testtags.append(f"calculator_context_{selection}")
# After the change to menu_launch_type, applications should be whitelisted here
# to prevent the unused needles warning in case of apps_run_<application>.
for app in ("focuswriter", "gvim"):
testtags.append(f"apps_run_{app}")
# retcode tracker
ret = 0

View File

@ -1370,27 +1370,43 @@ sub menu_launch_type {
# Launch an application in a graphical environment, by opening a
# launcher, typing the specified string and hitting enter. Pass
# the string to be typed to launch whatever it is you want.
my ($app, $maximize) = @_;
# Use maximize => 1 to maximize the application after it
# is started.
# Use checkstart => 1 to check that the application has started
my ($application, %args) = @_;
my $desktop = get_var("DESKTOP");
# The standard combo key is the "super" key, just in I3
# it is different.
my $key = 'super';
$key = 'alt-d' if ($desktop eq "i3");
# In KDE, we have been experiencing BZ2097208.
# To overcome this let's move the mouse out of the way
# and give the launcher some time to take the correct focus.
if ($desktop eq "kde") {
# To overcome BZ2097208, let's move the mouse out of the way
# and give the launcher some time to take the correct focus.
diag("Moving the mouse away from the launcher.");
mouse_set(1, 1);
}
# Open the launching mode
wait_screen_change { send_key $key; };
# srsly KDE y u so slo
# Give enough wait time for the everything to settle,
# especially KDE is quite slow in responses.
wait_still_screen 3;
type_very_safely $app;
# Wait for KDE to place focus correctly.
type_very_safely($application);
# Wait to place focus correctly.
wait_still_screen 2;
send_key 'ret';
wait_still_screen 3;
diag("Launcher: The application $app should have been launched.");
# If we should maximize the application
if ($maximize) {
# If check that app is running was requested
# with checkstart => 1
if ($args{checkstart}) {
assert_screen("apps_run_$application");
}
# If maximizing the application was requested
# with maximize => 1
if ($args{maximize}) {
if ($desktop eq "kde") {
send_key('super-pgup');
}
@ -1398,10 +1414,9 @@ sub menu_launch_type {
send_key('super-up');
}
else {
diag('Maximizing in this desktop is not supported at the moment!');
record_soft_failure('Maximizing in this desktop is not supported at the moment!');
}
wait_still_screen 3;
diag("Maximizer: The application should have been maximized.");
}
}
@ -1618,6 +1633,7 @@ sub register_application {
# 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)
# Check, that the application has started.
sub desktop_launch_terminal {
my $desktop = get_var("DESKTOP");
if ($desktop eq "i3") {
@ -1627,7 +1643,7 @@ sub desktop_launch_terminal {
send_key "ctrl-alt-t";
}
else {
menu_launch_type "terminal";
menu_launch_type("terminal", checkstart => 1);
}
}

View File

@ -22,12 +22,7 @@ sub run {
set_update_notification_timestamp();
# Start the application
menu_launch_type("nautilus");
# Check it has started
assert_screen 'apps_run_files';
# Fullsize the window.
wait_screen_change { send_key("super-up"); };
wait_still_screen 3;
menu_launch_type("nautilus", checkstart => 1, maximize => 1);
# Open the Documents directory
assert_and_click("gnome_open_location_documents");

View File

@ -12,7 +12,7 @@ sub run {
sleep(5);
# The full screen is not supported by any application, but it
# is supported by several, such as Terminal.
menu_launch_type("terminal", "maximize");
menu_launch_type("terminal", maximize => 1);
# If we see prompt, everything is ok.
assert_screen("terminal_prompt");

View File

@ -11,9 +11,9 @@ sub run {
# Let us wait here for a couple of seconds to give the VM time to settle.
# Starting right over might result in erroneous behavior.
sleep(5);
menu_launch_type("text editor", "maximize");
menu_launch_type("text editor", maximize => 1);
assert_screen("apps_run_texteditor");
menu_launch_type("files", "maximize");
menu_launch_type("files", maximize => 1);
assert_screen("apps_run_files");
# If we are at Nautilus switch to editor

View File

@ -72,16 +72,16 @@ sub run {
### Switch between more applications
# Start more applications.
menu_launch_type("clocks", "maximize");
menu_launch_type("clocks", maximize => 1);
# Sometime, Clocks start with an access request,
# deny it.
if (check_screen('grant_access', 5)) {
send_key('ret');
}
assert_screen('apps_run_clocks');
menu_launch_type("calculator", "maximize");
menu_launch_type("calculator", maximize => 1);
assert_screen('apps_run_calculator');
menu_launch_type("terminal", "maximize");
menu_launch_type("terminal", maximize => 1);
assert_screen('apps_run_terminal');
## Going forwards

View File

@ -27,9 +27,9 @@ sub run {
# Let us wait here for a couple of seconds to give the VM time to settle.
# Starting right over might result in erroneous behavior.
sleep(5);
menu_launch_type("files", "maximize");
menu_launch_type("files", maximize => 1);
assert_screen('apps_run_files');
menu_launch_type("text editor", "maximize");
menu_launch_type("text editor", maximize => 1);
assert_screen('apps_run_texteditor');
# The focused application should be the Editor, so let's check it is

View File

@ -31,8 +31,7 @@ sub run {
# Now, we will switch into the Desktop and we will try to run the application
desktop_vt();
wait_still_screen(3);
menu_launch_type("gvim");
assert_screen("apps_run_gvim");
menu_launch_type("gvim", checkstart => 1);
# Switch off the application
type_very_safely(":qa\n");

View File

@ -37,9 +37,7 @@ sub run {
# Switch to desktop and try to run the application.
desktop_vt();
wait_still_screen(3);
menu_launch_type("focuswriter");
# Check that it started
assert_screen("apps_run_focuswriter");
menu_launch_type("focuswriter", checkstart => 1);
# Stop the application
send_key("alt-f4");

View File

@ -45,7 +45,7 @@ sub run {
# According to the ticket, the 'fedora.json' file
# which lists the available versions will be created
# after the Software starts. Let's start it then on Gnome.
menu_launch_type("software");
menu_launch_type("software", checkstart => 1);
# When Software is started for the first time, it asks whether
# a user wants to use Third Party software. We want to Ignore
# this and proceed, so if we see that we click on Ignore.

View File

@ -50,7 +50,7 @@ sub run {
# on which DE we are on.
my $pkgmgr = "software";
$pkgmgr = "discover" if ($desktop eq "kde");
menu_launch_type($pkgmgr);
menu_launch_type($pkgmgr, checkstart => 1);
# On Gnome, the upgrade is safely visible when
# we visit the Update page by clicking on the