1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2025-07-16 10:21:37 +00:00
os-autoinst-distri-fedora/tests/applications/navigation/play_game.pm
Lukáš Růžička 0190f38677 Use the new features of menu_launch_type in code.
We have enhanced the menu_launch_type to allow for
start checking and maximizing applications.
This PR uses the new functions wherever it seems
logical.
If special logic was used for certain cases,
we have not touched these to preserve the
exact behaviour.

The crash workaround for the Fonts flatpak is dropped because it
no longer seems to be needed with the latest version of the
flatpak, and dropping it simplifies this migration.

Fixes: https://pagure.io/fedora-qa/os-autoinst-distri-fedora/issue/358
2025-04-25 14:40:54 -07:00

112 lines
2.7 KiB
Perl

use base "installedtest";
use strict;
use testapi;
use utils;
# This will test that
# - a game can be played both full screen or normal
sub send_tab_to_select {
my $times = shift;
foreach (1 .. $times) {
send_key("tab");
sleep(1);
}
send_key("ret");
sleep(2);
}
sub go_tux {
my $time = shift // 20;
while ($time > 0) {
hold_key("up");
sleep(1);
release_key("up");
sleep(3);
$time -= 1;
}
}
sub run {
my $self = shift;
# Open the game
menu_launch_type("tux_racer", checkstart => 1);
# Check that it has started in the fullscreen mode.
if (check_screen("panel_controls")) {
record_soft_failure("The game should have started in full screen mode.");
}
# Select new game. The background changes like hell,
# and the mouse does not work particularly well
# without 3d acceleration, so we need to rely
# on keyboard.
# Take what is offered.
send_tab_to_select(2);
assert_screen('tuxracer_menu');
# Navigate to start the practice
send_tab_to_select(1);
assert_screen('tuxracer_bunnyhill');
# Navigate to start the race.
send_tab_to_select(6);
# Wait a little bit to start the race
sleep(5);
# Try to play the game.
# This is sending a forward key intermittently
# to slide to slope towards the finish. As it is difficult
# to make sure Tux finishes in the right place and because
# the game graphics changes a lot, we need to check whether
# the screen changes and when it stops changing for some
# time, we could assume that we have finished the game.
assert_screen_change(sub { go_tux(30) }, timeout => 10);
# Then hit to come back to the Race settings.
send_key('esc');
assert_screen('tuxracer_bunnyhill');
sleep(2);
# One more escape to come to the menu.
send_key('esc');
assert_screen('tuxracer_menu');
# Navigate to Configuration and switch off full screen.
send_tab_to_select(2);
# Hit space to switch off full screen.
send_key('spc');
sleep(1);
# Go and press OK.
send_tab_to_select(7);
# Now the application should be in non-fs mode,
# so we should be able to see the Gnome panel
assert_screen("panel_controls");
# Start the game again.
send_tab_to_select(1);
assert_screen('tuxracer_bunnyhill');
send_tab_to_select(6);
sleep(5);
# Play it as before.
assert_screen_change(sub { go_tux(30) }, timeout => 10);
# Send Esc
send_key('esc');
assert_screen('tuxracer_bunnyhill');
send_key('esc');
assert_screen('tuxracer_menu');
# Quit game
send_tab_to_select(6);
}
sub test_flags {
return {always_rollback => 1};
}
1;
# vim: set sw=4 et: