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

Compare commits

...

1 Commits

Author SHA1 Message Date
Adam Williamson
aa5e905b70 abstract desktop terminal launch, refactor user switch, enable for KDE
Signed-off-by: Adam Williamson <awilliam@redhat.com>
2024-10-09 13:41:58 -07:00
22 changed files with 46 additions and 192 deletions

View File

@ -6,7 +6,7 @@ use base 'Exporter';
use Exporter; use Exporter;
use lockapi; use lockapi;
use testapi qw(is_serial_terminal :DEFAULT); use testapi qw(is_serial_terminal :DEFAULT);
our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us do_bootloader boot_decrypt check_release menu_launch_type setup_repos repo_setup get_workarounds disable_updates_repos cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup anaconda_create_user check_desktop quit_firefox advisory_get_installed_packages acnp_handle_output advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log repos_mirrorlist register_application get_registered_applications solidify_wallpaper check_and_install_git download_testdata make_serial_writable set_update_notification_timestamp kde_doublek_workaround dm_perform_login/; our @EXPORT = qw/run_with_error_check type_safely type_very_safely desktop_vt boot_to_login_screen console_login console_switch_layout desktop_switch_layout console_loadkeys_us do_bootloader boot_decrypt check_release menu_launch_type setup_repos repo_setup get_workarounds disable_updates_repos cleanup_workaround_repo console_initial_setup handle_welcome_screen gnome_initial_setup anaconda_create_user check_desktop quit_firefox advisory_get_installed_packages acnp_handle_output advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log repos_mirrorlist register_application get_registered_applications solidify_wallpaper check_and_install_git download_testdata make_serial_writable set_update_notification_timestamp kde_doublek_workaround dm_perform_login desktop_launch_terminal/;
# We introduce this global variable to hold the list of applications that have # We introduce this global variable to hold the list of applications that have
@ -1822,4 +1822,20 @@ sub dm_perform_login {
send_key "ret"; send_key "ret";
} }
# launch a terminal from a desktop, using the most efficient/reliable
# approach (not appropriate if we really need to test launching it a
# specific way)
sub desktop_launch_terminal {
my $desktop = get_var("DESKTOP");
if ($desktop eq "i3") {
send_key "alt-ret";
}
elif ($desktop eq "kde") {
send_key "ctrl-alt-t";
}
else {
menu_launch_type "terminal";
}
}
1; 1;

View File

@ -1,15 +0,0 @@
{
"area": [
{
"width": 41,
"type": "match",
"ypos": 173,
"xpos": 191,
"height": 21
}
],
"properties": [],
"tags": [
"user_confirm_jack"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

View File

@ -1,15 +0,0 @@
{
"area": [
{
"height": 21,
"width": 39,
"ypos": 165,
"type": "match",
"xpos": 185
}
],
"properties": [],
"tags": [
"user_confirm_jack"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

View File

@ -1,15 +0,0 @@
{
"area": [
{
"width": 39,
"height": 21,
"type": "match",
"xpos": 185,
"ypos": 165
}
],
"properties": [],
"tags": [
"user_confirm_jack"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

View File

@ -1,15 +0,0 @@
{
"area": [
{
"height": 15,
"type": "match",
"ypos": 176,
"xpos": 193,
"width": 31
}
],
"properties": [],
"tags": [
"user_confirm_jim"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,15 +0,0 @@
{
"area": [
{
"height": 15,
"width": 31,
"ypos": 168,
"xpos": 185,
"type": "match"
}
],
"properties": [],
"tags": [
"user_confirm_jim"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

View File

@ -1,15 +0,0 @@
{
"area": [
{
"height": 15,
"width": 31,
"xpos": 185,
"ypos": 168,
"type": "match"
}
],
"properties": [],
"tags": [
"user_confirm_jim"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

View File

@ -1,15 +0,0 @@
{
"area": [
{
"height": 15,
"xpos": 40,
"ypos": 217,
"type": "match",
"width": 31
}
],
"properties": [],
"tags": [
"user_confirm_jack"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

View File

@ -1,15 +0,0 @@
{
"area": [
{
"height": 16,
"type": "match",
"ypos": 200,
"width": 31,
"xpos": 44
}
],
"properties": [],
"tags": [
"user_confirm_jack"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

View File

@ -1,15 +0,0 @@
{
"area": [
{
"ypos": 215,
"type": "match",
"width": 26,
"xpos": 39,
"height": 17
}
],
"properties": [],
"tags": [
"user_confirm_jim"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

View File

@ -1,15 +0,0 @@
{
"area": [
{
"width": 26,
"xpos": 43,
"ypos": 199,
"type": "match",
"height": 17
}
],
"properties": [],
"tags": [
"user_confirm_jim"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 101 KiB

View File

@ -115,32 +115,21 @@ sub login_user {
sub check_user_logged_in { sub check_user_logged_in {
# Performs a check that a correct user has been locked in. # Performs a check that a correct user has been locked in.
my $user = shift; my %args = @_;
my $exitkey; $args{termopen} //= 0;
# In Gnome, the name of the user was accessible through menu $args{keepterm} //= 0;
# in the upper right corner, but apparently it has been removed. my $user = $args{user};
# Reading the login name from the terminal prompt seems to be # In Gnome and i3, the current user's name is not easily visible,
# the most reliable thing to do. # so reading the login name from the terminal prompt seems to be
if ($desktop eq "gnome") { # the most reliable thing to do. In KDE we could see it on the
menu_launch_type("terminal"); # launcher menu, but it keeps things clean if we use the same
wait_still_screen 2; # approach for all desktops.
$exitkey = "alt-f4"; my $exitkey = "alt-f4";
} $exitkey = "shift-ctrl-q" if ($desktop eq "i3");
elsif ($desktop eq "i3") { desktop_launch_terminal unless ($args{termopen});
send_key("alt-ret"); assert_screen("apps_run_terminal");
assert_screen("apps_run_terminal"); assert_script_run('[ $(whoami) = "' . "$user\" ]");
assert_script_run('[ $(whoami) = "' . "$user\" ]"); send_key $exitkey unless ($args{keepterm});
wait_screen_change { send_key("alt-shift-q"); };
return;
}
# With KDE, the user is shown in the main menu, so let us just
# open this and see.
else {
assert_and_click "system_menu_button";
$exitkey = "esc";
}
assert_screen "user_confirm_$user";
send_key $exitkey;
wait_still_screen 5; wait_still_screen 5;
} }
@ -276,7 +265,7 @@ sub run {
# Log in with the first user account. # Log in with the first user account.
login_user(user => "jack", password => $jackpass); login_user(user => "jack", password => $jackpass);
check_user_logged_in("jack"); check_user_logged_in(user => "jack");
# Log out the user. # Log out the user.
logout_user(); logout_user();
@ -289,7 +278,7 @@ sub run {
# If not, we are in KDE and we will log in normally. # If not, we are in KDE and we will log in normally.
login_user(user => "jim", password => $jimpass); login_user(user => "jim", password => $jimpass);
} }
check_user_logged_in("jim"); check_user_logged_in(user => "jim");
# And this time reboot the system using the menu. # And this time reboot the system using the menu.
reboot_system(); reboot_system();
@ -307,7 +296,7 @@ sub run {
# only work if we were correctly denied login with the wrong password, # only work if we were correctly denied login with the wrong password,
# if we were let in with the wrong password it'll fail # if we were let in with the wrong password it'll fail
login_user(user => "jim", password => $jimpass); login_user(user => "jim", password => $jimpass);
check_user_logged_in("jim"); check_user_logged_in(user => "jim");
# Lock the screen and unlock again. # Lock the screen and unlock again.
lock_screen(); lock_screen();
@ -315,32 +304,29 @@ sub run {
login_user(user => "jim", password => $jimpass, method => "unlock"); login_user(user => "jim", password => $jimpass, method => "unlock");
# Switch user tests # Switch user tests
if ($desktop eq "gnome") { unless ($desktop eq "i3") {
# Because KDE at the moment (20200403) is very unreliable concerning switching the users inside
# the virtual machine, we will skip this part, until situation is better. Switching users will
# be only tested in Gnome.
# Start a terminal session to monitor on which sessions we are, when we start switching users. # Start a terminal session to monitor on which sessions we are, when we start switching users.
# This time, we will open the terminal window manually because we want to leave it open later. # This time, we will open the terminal window manually because we want to leave it open later.
menu_launch_type "terminal"; desktop_launch_terminal;
wait_still_screen 2; wait_still_screen 2;
# Initiate switch user # Initiate switch user
switch_user(); switch_user();
# Now, we get a new login screen, so let's do the login into the new session. # Now, we get a new login screen, so let's do the login into the new session.
login_user(user => "jack", password => $jackpass); login_user(user => "jack", password => $jackpass);
# Check that it is a new session, the terminal window should not be visible. # Check that it is a new session, the terminal window should not be visible.
if (check_screen "user_confirm_jim") { if (check_screen "apps_run_terminal") {
die "The session was not switched!"; die "The session was not switched!";
} }
else { else {
check_user_logged_in("jack"); # keep the terminal open so we can check later
check_user_logged_in(user => "jack", keepterm => 1);
} }
# Log out the user. # Switch again.
logout_user(); switch_user();
# Now, let us log into the original session, this time, the terminal window # Now, let us log into the original session, this time, the terminal window
# should still be visible. # should still be visible.
login_user(user => "jim", password => $jimpass); login_user(user => "jim", password => $jimpass);
assert_screen "user_confirm_jim"; check_user_logged_in(user => "jim", termopen => 1);
# We will also test another alternative - switching the user from # We will also test another alternative - switching the user from
# a locked screen. # a locked screen.
@ -348,7 +334,9 @@ sub run {
send_key "ret"; send_key "ret";
switch_user(); switch_user();
login_user(user => "jack", password => $jackpass); login_user(user => "jack", password => $jackpass);
check_user_logged_in("jack"); # we should be back in the previous 'jack' session so the terminal
# we kept open should be there
check_user_logged_in(user => "jack", termopen => 1);
} }
# Power off the machine # Power off the machine
power_off(); power_off();