From ec34439004a3cb2ac0ea03092508cfdaa09bc1cf Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 8 Oct 2024 09:16:41 -0700 Subject: [PATCH] Tweak desktop_printing launch/maximize a bit to make more robust We seem to be having quite a few failures lately because the viewer window in KDE never got maximized. This makes us a bit more conservative at startup and puts the maximization / sentence check in a send_key_until_needlematch loop to give it more chances. Signed-off-by: Adam Williamson --- tests/desktop_printing.pm | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/desktop_printing.pm b/tests/desktop_printing.pm index e4f4bbed..dd28a5a4 100644 --- a/tests/desktop_printing.pm +++ b/tests/desktop_printing.pm @@ -144,15 +144,23 @@ sub run { # Enter key will dismiss them and return the CLI to the ready status. send_key("ret"); # Open the pdf file in a Document reader and check that it is correctly printed. - type_safely("$viewer $filepath &\n"); + wait_screen_change { 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. - send_key $maximize if (defined($maximize)); - wait_still_screen(stilltime => 2, similarity_level => 45); - send_key "ctrl-home" if ($desktop eq "kde"); - # Check the printed pdf. - assert_screen "printing_check_sentence"; + # 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); }