1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-11-24 23:03:08 +00:00

Make changes to the Desktop Printing test.

This commit is contained in:
Lukáš Růžička 2022-01-21 11:05:07 +01:00 committed by adamwill
parent ec83223ed1
commit 980ba5f411
7 changed files with 94 additions and 46 deletions

View File

@ -0,0 +1,15 @@
{
"area": [
{
"height": 18,
"xpos": 183,
"ypos": 88,
"type": "match",
"width": 327
}
],
"properties": [],
"tags": [
"printing_check_sentence"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -1,15 +1,15 @@
{
"area": [
{
"height": 19,
"ypos": 55,
"xpos": 599,
"type": "match",
"width": 40
}
],
"properties": [],
"tags": [
"printing_print"
],
"area": [
{
"xpos": 790,
"ypos": 134,
"width": 40,
"height": 19,
"type": "match"
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 438 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"width": 99,
"height": 19,
"ypos": 209,
"xpos": 48,
"type": "match"
}
],
"properties": [],
"tags": [
"printing_select_pdfprinter"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 KiB

View File

@ -5,44 +5,63 @@ use utils;
sub run {
my $self = shift;
# Prepare the environment:
# Prepare the environment for the test.
#
# Become root
# Some actions need a root account, so become root.
$self->root_console(tty=>3);
# Create a text file with content to print
# Create a text file, put content to it to prepare it for later printing.
script_run "cd /home/test/";
assert_script_run "echo 'A quick brown fox jumps over a lazy dog.' > testfile.txt";
# Make the file readable and for everybody.
script_run "chmod 666 testfile.txt";
# Install the Cups-PDF package to use the Cups-PDF printer
assert_script_run "dnf -y install cups-pdf", 180;
# FIXME: log version of cups-pdf and check it for output location
# this is only necessary as long as the test may run on cups-pdf
# 3.0.1-11 or lower, as soon as that's not true we can cut it
my $cpdfver = script_output 'rpm -q cups-pdf --queryformat "%{VERSION}-%{RELEASE}\n"';
assert_script_run "dnf -y install rpmdevtools", 180;
my $cpdfvercmp = script_run "rpmdev-vercmp $cpdfver 3.0.1-11.5";
# Leave the root terminal and switch back to desktop.
# 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.
script_run("rm /home/test/Desktop/*");
# Verification commands need serial console to be writable and readable for
# normal users, let's make it writable then.
script_run("chmod 666 /dev/ttyS0");
# Leave the root terminal and switch back to desktop for the rest of the test.
desktop_vt();
my $desktop = get_var("DESKTOP");
# some simple variances between desktops. defaults are for GNOME
my $editor = "gedit";
# Set up some variables to make the test compatible with different desktops.
# Defaults are for the Gnome desktop.
my $version = get_var("VERSION");
# FIXME: When we entirely move to version 36 with all the tests
# we will get rid of gedit (which ceased to exist on 36).
my $editor = "gnome-text-editor";
if ($version <= 35 and $version ne "Rawhide") {
$editor = "gedit";
}
my $viewer = "evince";
my $maximize = "super-up";
my $term = "gnome-terminal";
if ($desktop eq "kde") {
$editor = "kwrite";
$viewer = "okular";
$maximize = "super-pgup";
$term = "konsole";
}
# 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);
wait_still_screen(2);
# Open the text editor and print the file.
wait_screen_change { send_key "alt-f2"; };
wait_still_screen(stilltime=>5, similarity_level=>45);
type_very_safely "$editor /home/test/testfile.txt\n";
wait_still_screen(stilltime=>5, similarity_level=>44);
type_very_safely "$editor /home/test/testfile.txt &\n";
wait_still_screen(stilltime=>3, similarity_level=>45);
# Print the file using the Cups-PDF printer
send_key "ctrl-p";
wait_still_screen(stilltime=>5, similarity_level=>45);
wait_still_screen(stilltime=>3, similarity_level=>45);
# In Gnome, we need to select the Cups-PDF printer first
if ($desktop eq 'gnome') {
assert_and_click "printing_select_pdfprinter";
}
@ -52,29 +71,28 @@ sub run {
# We only check that it is correct.
assert_screen "printing_pdfprinter_ready";
}
wait_still_screen(stilltime=>2, similarity_level=>45);
assert_and_click "printing_print";
# Exit the application
send_key "alt-f4";
wait_still_screen(stilltime=>3, similarity_level=>45);
# 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");
# Open the pdf file and check the print
send_key "alt-f2";
wait_still_screen(stilltime=>5, similarity_level=>45);
# output location is different for cups-pdf 3.0.1-12 or later (we
# checked this above)
if ($cpdfvercmp eq "12") {
# older cups-pdf
type_safely "$viewer /home/test/Desktop/testfile.pdf\n";
}
else {
type_safely "$viewer /home/test/Desktop/testfile-job_1.pdf\n";
}
wait_still_screen(stilltime=>5, similarity_level=>45);
# Get the name of the printed file. Both Gnome and KDE place
# that file in the /home/$user/Desktop directory.
my $filename = script_output("ls /home/test/Desktop/");
# Echo that filename to the terminal for troubleshooting purposes
diag("The filename of the printed out file is: $filename");
# Open the pdf file in a Document readier and check that it is correctly printed.
type_safely("$viewer /home/test/Desktop/$filename &\n");
wait_still_screen(stilltime=>3, similarity_level=>45);
# Resize the window, so that the size of the document fits the bigger space
# and gets more readable.
send_key $maximize;
wait_still_screen(stilltime=>2, similarity_level=>45);
# make sure we're at the start of the document
# in KDE, make sure we're at the start of the document
send_key "ctrl-home" if ($desktop eq "kde");
# Check the printed pdf.
assert_screen "printing_check_sentence";