Modify Desktop Printing test to use two different methods.

The PR introduces an improved logic to the desktop_printing.pm
that allows to use the USE_CUPS variable in templates to trigger
the installation of cups-pdf prior to the actual test.
The cups-pdf is then used as an alternative PDF printer
instead the built-in Save As PDF method.
This commit is contained in:
Lukáš Růžička 2022-02-08 09:57:27 +01:00
parent 4282048819
commit 9a56adcfd0
31 changed files with 170 additions and 105 deletions

View File

@ -86,6 +86,7 @@ it also means that `B` conflicts `A` even if not shown in the table).
| `BUGZILLA_LOGIN` | string | not set | used with `_SECRET_BUGZILLA_PASSWORD` | This is used to store a login string which does not get exposed in log files. |
| `_SECRET_BUGZILLA_PASSWORD` | string | not set | used with `BUGZILLA_LOGIN` | This is used to store a password string which does not get exposed in log files. |
| `_SECRET_BUGZILLA_APIKEY` | string | not set | used with other secrets | This is used to store an API key which does not get exposed in log files. |
| `USE_CUPS` | boolean | `false`/not set | if set, the desktop printing test will use cups-pdf instead of the generic method |
Run variables
-------------

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 49,
"ypos": 175,
"width": 107,
"height": 20,
"type": "match"
}
],
"properties": [],
"tags": [
"printing_use_saveas_pdf"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 KiB

View File

@ -2,14 +2,14 @@
"area": [
{
"type": "match",
"xpos": 161,
"width": 328,
"height": 19,
"width": 99,
"ypos": 270,
"xpos": 184
"ypos": 141
}
],
"properties": [],
"tags": [
"printing_select_pdfprinter"
"printing_check_sentence"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 438,
"ypos": 405,
"width": 85,
"height": 17,
"type": "match"
}
],
"properties": [],
"tags": [
"printing_kde_location_line"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 440,
"ypos": 319,
"width": 129,
"height": 15,
"type": "match"
}
],
"properties": [],
"tags": [
"printing_kde_select_printer"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"ypos": 318,
"width": 129,
"height": 15,
"xpos": 394,
"type": "match"
}
],
"properties": [],
"tags": [
"printing_kde_select_printer"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@ -1,15 +0,0 @@
{
"area": [
{
"type": "match",
"ypos": 212,
"width": 60,
"height": 16,
"xpos": 203
}
],
"properties": [],
"tags": [
"printing_pdfprinter_ready"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 756 KiB

View File

@ -1,22 +0,0 @@
{
"area": [
{
"height": 18,
"xpos": 198,
"width": 69,
"type": "match",
"ypos": 212
},
{
"type": "match",
"height": 17,
"xpos": 198,
"width": 67,
"ypos": 211
}
],
"properties": [],
"tags": [
"printing_pdfprinter_ready"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 620 KiB

View File

@ -1,20 +0,0 @@
{
"area": [
{
"xpos": 194,
"height": 20,
"ypos": 183,
"width": 61,
"type": "match"
}
],
"properties": [
{
"name": "workaround",
"value": "if this needle matches, styling in KDE is wrong somehow"
}
],
"tags": [
"printing_pdfprinter_ready"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 630 KiB

View File

@ -1,22 +0,0 @@
{
"properties": [],
"tags": [
"printing_pdfprinter_ready"
],
"area": [
{
"xpos": 377,
"ypos": 98,
"width": 69,
"height": 18,
"type": "match"
},
{
"xpos": 377,
"ypos": 97,
"width": 69,
"height": 20,
"type": "match"
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 433 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"ypos": 347,
"width": 103,
"height": 16,
"xpos": 392,
"type": "match"
}
],
"properties": [],
"tags": [
"printing_use_cups_printer"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 440,
"ypos": 347,
"width": 126,
"height": 16,
"type": "match"
}
],
"properties": [],
"tags": [
"printing_use_saveas_pdf"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

View File

@ -987,7 +987,24 @@
"START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%"
}
},
"desktop_printing": {
"desktop_printing_cups": {
"profiles": {
"fedora-KDE-live-iso-x86_64-*-64bit": 20,
"fedora-Workstation-live-iso-ppc64le-*-ppc64le": 20,
"fedora-Workstation-live-iso-x86_64-*-64bit": 20,
"fedora-Workstation-upgrade-x86_64-*-64bit": 40,
"fedora-Workstation-upgrade-aarch64-*-aarch64": 40,
"fedora-Workstation-raw_xz-raw.xz-aarch64-*-aarch64": 22
},
"settings": {
"BOOTFROM": "c",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"USE_CUPS":"1",
"POSTINSTALL": "desktop_printing",
"START_AFTER_TEST": "%DEPLOY_UPLOAD_TEST%"
}
},
"desktop_printing_built": {
"profiles": {
"fedora-KDE-live-iso-x86_64-*-64bit": 20,
"fedora-Workstation-live-iso-ppc64le-*-ppc64le": 20,

View File

@ -5,6 +5,7 @@ use utils;
sub run {
my $self = shift;
my $usecups = get_var("USE_CUPS");
# Prepare the environment for the test.
#
# Some actions need a root account, so become root.
@ -15,8 +16,12 @@ sub run {
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;
# If the test should be running with CUPS-PDF, we need to install it first.
if ($usecups) {
# Install the Cups-PDF package to use the Cups-PDF printer
assert_script_run "dnf -y install cups-pdf", 180;
}
# 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:
@ -55,21 +60,30 @@ sub run {
menu_launch_type($term);
wait_still_screen(2);
# Open the text editor and print the file.
# Open the text editor and maximize it.
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($maximize);
# Print the file using one of the available methods
send_key "ctrl-p";
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";
# 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";
}
else {
# It seems that on newly installed KDE systems with no
# printer, the Cups-PDF printer is already pre-selected.
# We only check that it is correct.
assert_screen "printing_pdfprinter_ready";
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");
type_safely("/home/test/Documents/output.pdf");
}
}
assert_and_click "printing_print";
# Exit the application
@ -79,14 +93,21 @@ sub run {
# Enter key will dismiss them and return the CLI to the ready status.
send_key("ret");
# 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/");
# Get the name of the printed file. The path location depends
# on the selected method.
# For the built-in printing method.
my $filepath = "/home/test/Documents/output.pdf";
# If we use cups-pdf, the file will be placed elsewhere.
if ($usecups) {
my $filename = script_output("ls /home/test/Desktop/");
$filepath = "/home/test/Desktop/$filename";
}
# Echo that filename to the terminal for troubleshooting purposes
diag("The filename of the printed out file is: $filename");
diag("The file of the printed out file is located in $filepath");
# Open the pdf file in a Document readier and check that it is correctly printed.
type_safely("$viewer /home/test/Desktop/$filename &\n");
# Open the pdf file in a Document reader and check that it is correctly printed.
type_safely("$viewer $filepath &\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.