mirror of
https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git
synced 2024-12-02 18:13:10 +00:00
178 lines
6.7 KiB
Perl
178 lines
6.7 KiB
Perl
package desktoptools;
|
|
|
|
use strict;
|
|
|
|
use base 'Exporter';
|
|
use Exporter;
|
|
|
|
use testapi;
|
|
use utils;
|
|
|
|
our @EXPORT = qw/find_application install_application check_application_information start_application_via_packagemanager check_app_installed remove_application restart_application/;
|
|
|
|
# This subroutine searches for the application using the package manager's
|
|
# search method. Currently, the routine is only available for Gnome Software.
|
|
sub find_application {
|
|
my $application = shift;
|
|
assert_and_click("gnome_search_button");
|
|
wait_still_screen(2);
|
|
type_safely($application);
|
|
# Confirm that the application has been found and shown
|
|
# in the overview, click on it to enter the installation
|
|
# tab and confirm it has opened.
|
|
assert_and_click("software_$application-found");
|
|
wait_still_screen(2);
|
|
assert_screen("software_$application-install_pane");
|
|
}
|
|
|
|
# This subroutine checks that the application shows appropriate
|
|
# information.
|
|
sub check_application_information {
|
|
my $application = shift;
|
|
# The logo, the screenshot, and the description should be visible
|
|
# without any intervention needed.
|
|
assert_screen("software_logo_$application");
|
|
assert_screen("software_screenshot_$application");
|
|
assert_screen("software_description_$application");
|
|
|
|
# Other elements are placed below the visible area
|
|
# so we need to move there, if we want to see it.
|
|
# The safest option is to hit the tab key until
|
|
# we reach that element.
|
|
send_key_until_needlematch("software_download_size_$application", "tab");
|
|
# Now, other metadata should be visible two, so let's check them
|
|
assert_screen("software_safestatus_$application");
|
|
assert_screen("software_usage_$application");
|
|
assert_screen("software_rating_$application");
|
|
|
|
# Again, let's move a bit down
|
|
send_key_until_needlematch("software_website_$application", "tab");
|
|
# Let's click on the link to open the website
|
|
click_lastmatch();
|
|
|
|
# Check, that the webpage has opened with correct information.
|
|
assert_screen("software_weblink_$application");
|
|
assert_screen("software_webcontent_$application");
|
|
|
|
# Close the browser
|
|
send_key("alt-f4");
|
|
wait_still_screen(2);
|
|
}
|
|
|
|
# This subroutine installs an application via the
|
|
# GUI application, such as Gnome Software, or Discover.
|
|
# Currently, only Gnome Software is supported.
|
|
# The $application takes the name of the application, while
|
|
# $source takes the installation source, rpm or flatpak.
|
|
# The subroutine does not start the application itself,
|
|
# you need to start it before running this.
|
|
sub install_application {
|
|
my ($application, $source) = @_;
|
|
# For some applications, there are more installation sources
|
|
# available. Pick the desired one.
|
|
if (check_screen("software_sources_available", timeout => 5)) {
|
|
click_lastmatch();
|
|
wait_still_screen(2);
|
|
assert_and_click("software_source_fedora_$source");
|
|
wait_still_screen(2);
|
|
# Confirm that the source is indeed correctly selected.
|
|
assert_screen("software_sources_available_$source");
|
|
}
|
|
# Click the Install button to start the installation.
|
|
assert_and_click("gnome_install_button");
|
|
# When the installation is finished, the Open button
|
|
# will be shown. We are going to wait for this for
|
|
# a certain time. In case of Flatpak, this should be longer.
|
|
my $wait_time = 180;
|
|
if ($source eq "flatpak") {
|
|
$wait_time = 1200;
|
|
}
|
|
assert_screen("gnome_button_open", timeout => $wait_time);
|
|
# After the installation, return to the previous page.
|
|
if (check_screen("software_back_button")) {
|
|
click_lastmatch();
|
|
}
|
|
}
|
|
|
|
# This subroutine opens the $application using Gnome Software.
|
|
# It is useful to check that the installed application can
|
|
# be run immediately from withing the application.
|
|
sub start_application_via_packagemanager {
|
|
my $application = shift;
|
|
# We do not have to be on the application tab, so let's
|
|
# start over and navigate there from scratch if needed -
|
|
# if no Open button is visible.
|
|
unless (check_screen("gnome_button_open")) {
|
|
assert_and_click("gnome_search_button");
|
|
wait_still_screen(2);
|
|
type_safely($application);
|
|
assert_and_click("software_$application-found");
|
|
wait_still_screen(2);
|
|
assert_screen("software_$application-install_pane");
|
|
}
|
|
# An Open button must be visible now, if the application
|
|
# has been installed, otherwise the command will fail.
|
|
assert_and_click("gnome_button_open");
|
|
wait_still_screen(3);
|
|
assert_screen("apps_run_$application");
|
|
}
|
|
|
|
# This subroutine checks that the $application has been found
|
|
# in the list of installed applications.
|
|
# It will send a key and circle through the GUI list until the
|
|
# application has been found (or it will fail).
|
|
sub check_app_installed {
|
|
my $application = shift;
|
|
# Look for the application and confirm that it is listed as installed
|
|
# in the application overview.
|
|
assert_and_click("gnome_search_button");
|
|
type_safely($application);
|
|
send_key("ret");
|
|
assert_screen("software_$application-found_installed");
|
|
|
|
# Enter the Installed application view and circle through the items
|
|
# until the desired application has been found.
|
|
assert_and_click("software_installed_button");
|
|
send_key_until_needlematch("software_$application-listed", "tab", 70);
|
|
}
|
|
|
|
# This subroutine removes the application using a default package manager.
|
|
# This will not start the package manager application, you need to start
|
|
# it manualy or using a different subroutine.
|
|
# Currently only works for Software.
|
|
sub remove_application {
|
|
my $application = shift;
|
|
|
|
# Find the application.
|
|
assert_and_click("gnome_search_button");
|
|
wait_still_screen(2);
|
|
type_safely($application);
|
|
|
|
assert_and_click("software_$application-found_installed");
|
|
wait_still_screen(2);
|
|
assert_screen("software_$application-install_pane");
|
|
|
|
# Click the Delete button to delete the application.
|
|
assert_and_click("software_remove_button");
|
|
|
|
# Confirm to progress with the removal
|
|
assert_and_click("gnome_uninstall_button");
|
|
|
|
# Wait until the Open button changes to Install to indicate
|
|
# that the application has been removed.
|
|
assert_screen("gnome_install_button", timeout => 180);
|
|
}
|
|
|
|
# This routine records a soft failure and starts the application.
|
|
# We have identified tests where the tested application crashes
|
|
# after the VM has been rolled back, probably due to changes
|
|
# to the underlying system, such as in Software.
|
|
sub restart_application {
|
|
my $application = shift;
|
|
|
|
record_soft_failure("$application crashed and had to be restarted to continue the tests.");
|
|
menu_launch_type($application);
|
|
wait_still_screen(2);
|
|
assert_screen("apps_run_$application");
|
|
}
|