2019-11-19 15:09:25 +00:00
|
|
|
use base "installedtest";
|
|
|
|
use strict;
|
|
|
|
use testapi;
|
|
|
|
use utils;
|
|
|
|
|
|
|
|
sub run {
|
|
|
|
my $self = shift;
|
2022-02-08 08:57:27 +00:00
|
|
|
my $usecups = get_var("USE_CUPS");
|
2024-06-20 13:39:34 +00:00
|
|
|
my $desktop = get_var("DESKTOP");
|
|
|
|
my $user = get_var("USER_LOGIN", "test");
|
|
|
|
my $password = get_var("USER_PASSWORD", "weakpassword");
|
2022-01-21 10:05:07 +00:00
|
|
|
# Prepare the environment for the test.
|
2019-11-19 15:09:25 +00:00
|
|
|
#
|
2022-01-21 10:05:07 +00:00
|
|
|
# Some actions need a root account, so become root.
|
2022-07-28 20:32:57 +00:00
|
|
|
$self->root_console(tty => 3);
|
2019-11-19 15:09:25 +00:00
|
|
|
|
2022-01-21 10:05:07 +00:00
|
|
|
# Create a text file, put content to it to prepare it for later printing.
|
2024-06-20 13:39:34 +00:00
|
|
|
script_run "cd /home/$user/";
|
2022-07-28 20:32:57 +00:00
|
|
|
assert_script_run "echo 'A quick brown fox jumps over a lazy dog.' > testfile.txt";
|
2022-01-21 10:05:07 +00:00
|
|
|
# Make the file readable and for everybody.
|
2019-11-19 15:09:25 +00:00
|
|
|
script_run "chmod 666 testfile.txt";
|
2024-06-20 13:39:34 +00:00
|
|
|
if ($desktop eq "i3") {
|
|
|
|
assert_script_run("dnf -y install mupdf", timeout => 120);
|
|
|
|
}
|
2022-02-08 08:57:27 +00:00
|
|
|
|
|
|
|
# If the test should be running with CUPS-PDF, we need to install it first.
|
|
|
|
if ($usecups) {
|
2020-10-17 22:22:09 +00:00
|
|
|
my $pkgs = "cups-pdf";
|
2022-02-08 08:57:27 +00:00
|
|
|
# Install the Cups-PDF package to use the Cups-PDF printer
|
2024-06-20 13:39:34 +00:00
|
|
|
assert_script_run "dnf -y install $pkgs", 120;
|
|
|
|
assert_script_run "systemctl restart cups", 30;
|
2022-02-08 08:57:27 +00:00
|
|
|
}
|
2022-01-21 10:05:07 +00:00
|
|
|
|
|
|
|
# Here, we were doing a version logic. This is no longer needed, because
|
|
|
|
# we now use a different approach to getting the resulting file name:
|
|
|
|
# We will list the directory where the printed file is put and we will
|
|
|
|
# take the file name that will be returned. To make it work, the directory
|
|
|
|
# must be empty, which it normally is, but to make sure let's delete everything.
|
2024-06-20 13:39:34 +00:00
|
|
|
script_run("rm /home/$user/Desktop/*");
|
2022-01-21 10:05:07 +00:00
|
|
|
# Verification commands need serial console to be writable and readable for
|
|
|
|
# normal users, let's make it writable then.
|
2022-01-23 11:23:12 +00:00
|
|
|
script_run("chmod 666 /dev/${serialdev}");
|
2022-01-21 10:05:07 +00:00
|
|
|
# Leave the root terminal and switch back to desktop for the rest of the test.
|
2019-11-19 15:09:25 +00:00
|
|
|
desktop_vt();
|
2022-01-21 10:05:07 +00:00
|
|
|
|
2019-11-19 15:09:25 +00:00
|
|
|
my $desktop = get_var("DESKTOP");
|
2022-01-21 10:05:07 +00:00
|
|
|
# Set up some variables to make the test compatible with different desktops.
|
|
|
|
# Defaults are for the Gnome desktop.
|
|
|
|
my $editor = "gnome-text-editor";
|
2019-11-19 15:09:25 +00:00
|
|
|
my $viewer = "evince";
|
|
|
|
my $maximize = "super-up";
|
2024-08-13 13:38:24 +00:00
|
|
|
my $term = "terminal";
|
2019-11-19 15:09:25 +00:00
|
|
|
if ($desktop eq "kde") {
|
|
|
|
$editor = "kwrite";
|
|
|
|
$viewer = "okular";
|
|
|
|
$maximize = "super-pgup";
|
2022-01-21 10:05:07 +00:00
|
|
|
$term = "konsole";
|
2019-11-19 15:09:25 +00:00
|
|
|
}
|
2020-10-17 22:22:09 +00:00
|
|
|
elsif ($desktop eq "i3") {
|
|
|
|
$editor = "mousepad";
|
|
|
|
$viewer = "mupdf";
|
|
|
|
$maximize = undef;
|
|
|
|
}
|
2019-11-19 15:09:25 +00:00
|
|
|
|
2024-02-27 18:17:38 +00:00
|
|
|
# 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);
|
2024-06-11 23:21:00 +00:00
|
|
|
# On KDE, try and avoid double-typing issues
|
|
|
|
if ($desktop eq "kde") {
|
|
|
|
kde_doublek_workaround;
|
|
|
|
}
|
2022-07-28 20:32:57 +00:00
|
|
|
# Let's open the terminal. We will use it to start the applications
|
2022-01-21 10:05:07 +00:00
|
|
|
# as well as to check for the name of the printed file.
|
2024-10-10 00:14:55 +00:00
|
|
|
desktop_launch_terminal;
|
|
|
|
assert_screen("apps_run_terminal");
|
|
|
|
wait_still_screen 3;
|
|
|
|
# switch to tabbed mode
|
|
|
|
send_key("alt-w") if ($desktop eq "i3");
|
2022-02-08 08:57:27 +00:00
|
|
|
# Open the text editor and maximize it.
|
2024-06-20 13:39:34 +00:00
|
|
|
wait_screen_change { type_very_safely "$editor /home/$user/testfile.txt &\n"; };
|
2022-07-28 20:32:57 +00:00
|
|
|
wait_still_screen(stilltime => 2, similarity_level => 45);
|
2024-06-20 13:39:34 +00:00
|
|
|
if (defined($maximize)) {
|
2020-10-17 22:22:09 +00:00
|
|
|
wait_screen_change { send_key($maximize); };
|
|
|
|
wait_still_screen(stilltime => 2, similarity_level => 45);
|
|
|
|
}
|
2022-02-08 08:57:27 +00:00
|
|
|
|
|
|
|
# Print the file using one of the available methods
|
2019-11-19 15:09:25 +00:00
|
|
|
send_key "ctrl-p";
|
2020-10-17 22:22:09 +00:00
|
|
|
wait_still_screen(stilltime => 5, similarity_level => 45);
|
2022-02-08 08:57:27 +00:00
|
|
|
# We will select the printing method
|
|
|
|
# In case of KDE, we will need to select the printer first.
|
|
|
|
if ($desktop eq "kde") {
|
|
|
|
assert_and_click "printing_kde_select_printer";
|
|
|
|
}
|
|
|
|
if ($usecups) {
|
|
|
|
assert_and_click "printing_use_cups_printer";
|
2019-11-19 15:09:25 +00:00
|
|
|
}
|
|
|
|
else {
|
2022-02-08 08:57:27 +00:00
|
|
|
assert_and_click "printing_use_saveas_pdf";
|
|
|
|
# For KDE, we need to set the output location.
|
|
|
|
if ($desktop eq "kde") {
|
|
|
|
assert_and_click "printing_kde_location_line";
|
|
|
|
send_key("ctrl-a");
|
2024-06-20 13:39:34 +00:00
|
|
|
type_safely("/home/$user/Documents/output.pdf");
|
2022-02-08 08:57:27 +00:00
|
|
|
}
|
2019-11-19 15:09:25 +00:00
|
|
|
}
|
|
|
|
assert_and_click "printing_print";
|
2023-11-07 06:36:18 +00:00
|
|
|
# In Rawhide from 2023-11-04 onwards, sometimes g-t-e has
|
|
|
|
# already died somehow at this point
|
|
|
|
if (check_screen "apps_run_terminal", 10) {
|
2023-11-13 16:39:43 +00:00
|
|
|
record_soft_failure "gnome-text-editor died!";
|
2023-11-07 06:36:18 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
# Exit the application
|
2024-06-20 13:39:34 +00:00
|
|
|
my $killing_weapon = "alt-f4";
|
|
|
|
if ($desktop eq "i3") {
|
|
|
|
$killing_weapon = "alt-shift-q";
|
|
|
|
}
|
|
|
|
send_key($killing_weapon);
|
2023-11-07 06:36:18 +00:00
|
|
|
}
|
2019-11-19 15:09:25 +00:00
|
|
|
|
2022-02-08 08:57:27 +00:00
|
|
|
# Get the name of the printed file. The path location depends
|
2022-02-24 16:24:36 +00:00
|
|
|
# on the selected method. We do this on a VT because there's
|
|
|
|
# no argument to script_output to make it type slowly, and
|
|
|
|
# it often fails typing fast in a desktop terminal
|
2022-07-28 20:32:57 +00:00
|
|
|
$self->root_console(tty => 3);
|
2024-06-20 13:39:34 +00:00
|
|
|
my $directory = $usecups ? "/home/$user/Desktop" : "/home/$user/Documents";
|
2022-02-17 01:21:36 +00:00
|
|
|
my $filename = script_output("ls $directory");
|
|
|
|
my $filepath = "$directory/$filename";
|
|
|
|
|
2022-01-21 10:05:07 +00:00
|
|
|
# Echo that filename to the terminal for troubleshooting purposes
|
2022-02-08 08:57:27 +00:00
|
|
|
diag("The file of the printed out file is located in $filepath");
|
2022-01-21 10:05:07 +00:00
|
|
|
|
2022-02-24 16:24:36 +00:00
|
|
|
# back to the desktop
|
|
|
|
desktop_vt();
|
2022-07-28 20:32:57 +00:00
|
|
|
wait_still_screen(stilltime => 3, similarity_level => 45);
|
2022-02-24 16:24:36 +00:00
|
|
|
# The CLI might be blocked by some application output. Pressing the
|
|
|
|
# Enter key will dismiss them and return the CLI to the ready status.
|
|
|
|
send_key("ret");
|
2022-02-08 08:57:27 +00:00
|
|
|
# Open the pdf file in a Document reader and check that it is correctly printed.
|
2024-10-08 16:16:41 +00:00
|
|
|
wait_screen_change { type_safely("$viewer $filepath &\n"); };
|
2022-07-28 20:32:57 +00:00
|
|
|
wait_still_screen(stilltime => 3, similarity_level => 45);
|
2024-10-08 16:16:41 +00:00
|
|
|
# Maximize the screen and check the printed pdf, giving it a few
|
|
|
|
# chances to work
|
|
|
|
my $count = 5;
|
|
|
|
while ($count) {
|
|
|
|
$count -= 1;
|
|
|
|
send_key($maximize);
|
|
|
|
wait_still_screen(stilltime => 3, similarity_level => 45);
|
|
|
|
if ($desktop eq "kde") {
|
|
|
|
# ensure we're at the start of the document
|
|
|
|
send_key "ctrl-home";
|
|
|
|
wait_still_screen(stilltime => 2, similarity_level => 45);
|
|
|
|
}
|
|
|
|
last if (check_screen("printing_check_sentence", 3));
|
|
|
|
}
|
|
|
|
assert_screen("printing_check_sentence", 5);
|
2019-11-19 15:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sub test_flags {
|
2022-07-28 20:32:57 +00:00
|
|
|
return {fatal => 1};
|
2019-11-19 15:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
|
|
|
|
# vim: set sw=4 et:
|