Add desktop login test, revise and rename check_desktop

This adds a new test that implementsQA:Testcase_desktop_login
on both GNOME and KDE.

While working on this, we realized that the "desktop_clean"
needles were really "app menu" needles, and for KDE, this was
a duplication with the new "system menu" needles, because on KDE
the app menu and the system menu are the same. So I (Adam)
started to de-duplicate that, but also realized that "app menu
button" is a much more accurate name for these needles, so I was
renaming the old desktop_clean needles to app_menu_button. That
led me to the realization that "check_desktop_clean" is itself a
dumb name, because we don't (at least, any more, way back in the
mists of time we may have done) do anything to check that the
desktop is "clean" - we're really just asserting that we're at a
desktop *at all*. While thinking *that* through, I *also* realized
that the whole "open the overview and look for the app grid icon"
workaround it did is no longer necessary, because GNOME doesn't
use a translucent top bar any more. That went away in GNOME 3.32,
which is in Fedora 30, our oldest supported release.

So I threw that away, renamed the function "check_desktop",
cleaned up all the needle naming and tagging, and also added an
app menu needle for GNOME in Japanese because we were missing
one (the Japanese tests have been using the "app grid icon"
workaround the whole time).
This commit is contained in:
Lukáš Růžička 2020-03-20 10:04:43 +01:00 committed by Adam Williamson
parent 49c8d46744
commit f3d6a9574c
92 changed files with 947 additions and 106 deletions

View File

@ -72,6 +72,10 @@ for environment in ("anaconda", "gnome"):
for pkgset in ("kde", "workstation", "minimal"): for pkgset in ("kde", "workstation", "minimal"):
testliterals.append(f"anaconda_{pkgset}_highlighted") testliterals.append(f"anaconda_{pkgset}_highlighted")
testliterals.append(f"anaconda_{pkgset}_selected") testliterals.append(f"anaconda_{pkgset}_selected")
# desktop_login stuff
for user in ("jack", "jim"):
testliterals.append(f"login_{user}")
testliterals.append(f"user_confirm_{user}")
# partitioning stuff, there's a bunch of this, all in anaconda.pm # partitioning stuff, there's a bunch of this, all in anaconda.pm
# multiple things use this # multiple things use this
for part in ("swap", "root"): for part in ("swap", "root"):

View File

@ -7,7 +7,7 @@ use Exporter;
use lockapi; use lockapi;
use testapi; use testapi;
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 repo_setup setup_workaround_repo cleanup_workaround_repo gnome_initial_setup anaconda_create_user check_desktop_clean download_modularity_tests quit_firefox advisory_get_installed_packages advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut lo_dismiss_tip disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile bypass_1691487 get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log click_unwanted_notifications repos_mirrorlist register_application get_registered_applications/; 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 repo_setup setup_workaround_repo cleanup_workaround_repo gnome_initial_setup anaconda_create_user check_desktop download_modularity_tests quit_firefox advisory_get_installed_packages advisory_check_nonmatching_packages start_with_launcher quit_with_shortcut lo_dismiss_tip disable_firefox_studies select_rescue_mode copy_devcdrom_as_isofile bypass_1691487 get_release_number check_left_bar check_top_bar check_prerelease check_version spell_version_number _assert_and_click is_branched rec_log click_unwanted_notifications repos_mirrorlist register_application get_registered_applications solidify_wallpaper_kde/;
# 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
# registered during the apps_startstop_test when they have sucessfully run. # registered during the apps_startstop_test when they have sucessfully run.
@ -727,42 +727,18 @@ sub anaconda_create_user {
} }
} }
sub check_desktop_clean { sub check_desktop {
# Check we're at a 'clean' desktop. This used to be a simple # Check we're at a desktop. We do this by looking for the "apps"
# needle check, but Rawhide's default desktop is now one which # menu button ("Activities" button on GNOME, kicker button on
# changes over time, and the GNOME top bar is now translucent # KDE). This is set up as a helper function because, for a while,
# by default; together these changes mean it's impossible to # GNOME made the top bar translucent by default *and* we had an
# make a reliable needle, so we need something more tricksy to # animated background by default, which made doing this solely
# cover that case. 'tries' is the amount of check cycles to run # with needle matches hard, so we had a workaround of trying to
# before giving up and failing; each cycle should take ~3 secs. # open the overview with the super key and match on the app grid
my %args = ( # icon. But GNOME has gone back to the top bar being a solid color
tries => 10, # by default, so we don't have this problem any more and this is
@_ # back to just being a simple needle match.
); assert_screen "apps_menu_button", 30;
foreach my $i (1..$args{tries}) {
# we still *do* the needle check, for all cases it covers
return if (check_screen "graphical_desktop_clean", 1);
# now do the special GNOME case
if (get_var("DESKTOP") eq "gnome") {
send_key "super";
if (check_screen "overview_app_grid", 2) {
send_key "super";
wait_still_screen 3;
# go back to the desktop, if we're still at the app
# grid (can be a bit fuzzy depending on response lag)
while (check_screen "overview_app_grid", 1) {
send_key "super";
wait_still_screen 3;
}
return;
}
}
else {
# to keep the timing equal
sleep 2;
}
}
die "Clean desktop not reached!";
} }
sub download_modularity_tests { sub download_modularity_tests {
@ -1203,4 +1179,36 @@ sub register_application {
print("APPLICATION REGISTERED: $application \n"); print("APPLICATION REGISTERED: $application \n");
} }
# The KDE desktop tests are very difficult to maintain, because the transparency
# of the menu requires a lot of different needles to cover the elements.
# Therefore it is useful to change the background to a solid colour.
# Since many needles have been already created with a black background
# we will keep it that way. The following code has been taken from the
# KDE startstop tests but it is good to have it here, because it will be
# needed more often now, it seems.
sub solidify_wallpaper_kde {
# Run the Desktop settings
hold_key 'alt';
send_key 'd';
send_key 's';
release_key 'alt';
# Select type of background
assert_and_click "deskset_select_type";
wait_still_screen 2;
# Select plain color type
assert_and_click "deskset_plain_color";
wait_still_screen 2;
# Open colors selection
assert_and_click "deskset_select_color";
wait_still_screen 2;
# Select black
assert_and_click "deskset_select_black";
wait_still_screen 2;
# Confirm
assert_and_click "kde_ok";
wait_still_screen 2;
# Close the application
assert_and_click "kde_ok";
}
1; 1;

View File

@ -20,6 +20,6 @@
"DESKTOP-gnome", "DESKTOP-gnome",
"ENV-DISTRI-fedora", "ENV-DISTRI-fedora",
"LANGUAGE-english", "LANGUAGE-english",
"graphical_desktop_clean" "apps_menu_button"
] ]
} }

View File

Before

Width:  |  Height:  |  Size: 605 KiB

After

Width:  |  Height:  |  Size: 605 KiB

View File

@ -13,6 +13,6 @@
"DESKTOP-gnome", "DESKTOP-gnome",
"ENV-DISTRI-fedora", "ENV-DISTRI-fedora",
"LANGUAGE-arabic", "LANGUAGE-arabic",
"graphical_desktop_clean" "apps_menu_button"
] ]
} }

View File

Before

Width:  |  Height:  |  Size: 723 KiB

After

Width:  |  Height:  |  Size: 723 KiB

View File

@ -18,7 +18,7 @@
"tags": [ "tags": [
"DESKTOP-gnome", "DESKTOP-gnome",
"LANGUAGE-french", "LANGUAGE-french",
"graphical_desktop_clean" "apps_menu_button"
], ],
"properties": [] "properties": []
} }

View File

Before

Width:  |  Height:  |  Size: 396 KiB

After

Width:  |  Height:  |  Size: 396 KiB

View File

@ -0,0 +1,16 @@
{
"area": [
{
"xpos": 15,
"ypos": 8,
"width": 99,
"height": 16,
"type": "match"
}
],
"properties": [],
"tags": [
"LANGUAGE-japanese",
"apps_menu_button"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 741 KiB

View File

@ -0,0 +1,15 @@
{
"properties": [],
"tags": [
"lock_button"
],
"area": [
{
"xpos": 734,
"ypos": 193,
"width": 59,
"height": 21,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 KiB

View File

@ -0,0 +1,15 @@
{
"properties": [],
"tags": [
"locked_screen_switch_user"
],
"area": [
{
"xpos": 963,
"ypos": 708,
"width": 22,
"height": 21,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -0,0 +1,15 @@
{
"properties": [],
"tags": [
"log_out_confirm"
],
"area": [
{
"xpos": 595,
"ypos": 441,
"width": 56,
"height": 22,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

View File

@ -0,0 +1,15 @@
{
"properties": [],
"tags": [
"log_out_entry"
],
"area": [
{
"xpos": 758,
"ypos": 258,
"width": 55,
"height": 20,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"ypos": 356,
"height": 28,
"type": "match",
"xpos": 415,
"width": 40
}
],
"properties": [],
"tags": [
"login_jack"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"width": 36,
"xpos": 420,
"type": "match",
"height": 25,
"ypos": 270
}
],
"properties": [],
"tags": [
"login_jack"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"ypos": 447,
"height": 23,
"type": "match",
"xpos": 415,
"width": 36
}
],
"properties": [],
"tags": [
"login_jim"
]
}

BIN
needles/gnome/login_jim.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1,15 @@
{
"properties": [],
"tags": [
"login_wrong_password"
],
"area": [
{
"xpos": 381,
"ypos": 487,
"width": 264,
"height": 22,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -0,0 +1,15 @@
{
"properties": [],
"tags": [
"power_entry"
],
"area": [
{
"xpos": 734,
"ypos": 226,
"width": 70,
"height": 19,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 KiB

View File

@ -0,0 +1,15 @@
{
"properties": [],
"tags": [
"power_off_confirm"
],
"area": [
{
"xpos": 622,
"ypos": 461,
"width": 76,
"height": 21,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@ -0,0 +1,15 @@
{
"properties": [],
"tags": [
"power_off_entry"
],
"area": [
{
"xpos": 753,
"ypos": 227,
"width": 93,
"height": 19,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -0,0 +1,15 @@
{
"properties": [],
"tags": [
"restart_confirm"
],
"area": [
{
"xpos": 486,
"ypos": 461,
"width": 55,
"height": 20,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@ -20,6 +20,6 @@
"DESKTOP-gnome", "DESKTOP-gnome",
"ENV-DISTRI-fedora", "ENV-DISTRI-fedora",
"LANGUAGE-russian", "LANGUAGE-russian",
"graphical_desktop_clean" "apps_menu_button"
] ]
} }

View File

Before

Width:  |  Height:  |  Size: 724 KiB

After

Width:  |  Height:  |  Size: 724 KiB

View File

@ -0,0 +1,15 @@
{
"properties": [],
"tags": [
"switch_user_entry"
],
"area": [
{
"xpos": 758,
"ypos": 289,
"width": 96,
"height": 19,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 710 KiB

View File

@ -0,0 +1,15 @@
{
"properties": [],
"tags": [
"system_menu_button"
],
"area": [
{
"xpos": 969,
"ypos": 2,
"width": 45,
"height": 25,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"xpos": 969,
"ypos": 2,
"width": 45,
"height": 25,
"type": "match"
}
],
"properties": [],
"tags": [
"system_menu_button"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 KiB

View File

@ -10,6 +10,7 @@
], ],
"properties": [], "properties": [],
"tags": [ "tags": [
"kde_ok" "kde_ok",
"add_button"
] ]
} }

View File

@ -1,7 +1,8 @@
{ {
"properties": [], "properties": [],
"tags": [ "tags": [
"konsole_runs" "konsole_runs",
"apps_run_terminal"
], ],
"area": [ "area": [
{ {

View File

@ -1,16 +0,0 @@
{
"area": [
{
"ypos": 733,
"type": "match",
"width": 36,
"height": 35,
"xpos": 0
}
],
"tags": [
"DESKTOP-kde",
"graphical_desktop_clean"
],
"properties": []
}

View File

@ -0,0 +1,16 @@
{
"properties": [],
"tags": [
"leave_button",
"power_entry"
],
"area": [
{
"xpos": 412,
"ypos": 655,
"width": 32,
"height": 32,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"type": "match",
"xpos": 76,
"height": 20,
"width": 55,
"ypos": 281
}
],
"properties": [],
"tags": [
"log_out_entry"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"ypos": 390,
"xpos": 202,
"width": 109,
"type": "match",
"height": 19
}
],
"properties": [],
"tags": [
"login_jack"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"ypos": 389,
"xpos": 601,
"width": 77,
"type": "match",
"height": 22
}
],
"properties": [],
"tags": [
"login_jim"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"height": 17,
"type": "match",
"width": 76,
"xpos": 472,
"ypos": 393
}
],
"properties": [],
"tags": [
"login_jim"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

View File

@ -0,0 +1,15 @@
{
"properties": [],
"tags": [
"login_wrong_password"
],
"area": [
{
"xpos": 464,
"ypos": 416,
"width": 98,
"height": 20,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

View File

@ -0,0 +1,16 @@
{
"properties": [],
"tags": [
"log_out_confirm",
"power_off_confirm"
],
"area": [
{
"xpos": 435,
"ypos": 575,
"width": 45,
"height": 19,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@ -0,0 +1,17 @@
{
"area": [
{
"height": 24,
"type": "match",
"width": 25,
"xpos": 5,
"ypos": 738
}
],
"properties": [],
"tags": [
"DESKTOP-kde",
"system_menu_button",
"apps_menu_button"
]
}

View File

Before

Width:  |  Height:  |  Size: 748 KiB

After

Width:  |  Height:  |  Size: 748 KiB

View File

@ -13,6 +13,7 @@
], ],
"tags": [ "tags": [
"DESKTOP-kde", "DESKTOP-kde",
"graphical_desktop_clean" "apps_menu_button",
"system_menu_button"
] ]
} }

View File

Before

Width:  |  Height:  |  Size: 499 KiB

After

Width:  |  Height:  |  Size: 499 KiB

View File

@ -0,0 +1,15 @@
{
"properties": [],
"tags": [
"power_off_entry"
],
"area": [
{
"xpos": 76,
"ypos": 514,
"width": 77,
"height": 17,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"height": 26,
"type": "match",
"width": 30,
"xpos": 30,
"ypos": 435
}
],
"properties": [],
"tags": [
"reboot_entry"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"height": 38,
"type": "match",
"width": 39,
"xpos": 449,
"ypos": 610
}
],
"properties": [],
"tags": [
"reboot_icon"
]
}

BIN
needles/kde/reboot_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -0,0 +1,15 @@
{
"properties": [],
"tags": [
"switch_user_entry"
],
"area": [
{
"xpos": 75,
"ypos": 321,
"width": 84,
"height": 17,
"type": "match"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"type": "match",
"ypos": 135,
"width": 35,
"xpos": 91,
"height": 21
}
],
"properties": [],
"tags": [
"user_confirm_jim"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -0,0 +1,15 @@
{
"area": [
{
"width": 32,
"ypos": 66,
"xpos": 9,
"type": "match",
"height": 21
}
],
"properties": [],
"tags": [
"user_confirm_jim"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -609,6 +609,19 @@
"START_AFTER_TEST": "install_default_upload" "START_AFTER_TEST": "install_default_upload"
} }
}, },
"desktop_login": {
"profiles": {
"fedora-KDE-live-iso-x86_64-*-64bit": 30,
"fedora-Workstation-live-iso-x86_64-*-64bit": 30,
"fedora-Workstation-live-iso-ppc64le-*-ppc64le": 30
},
"settings": {
"BOOTFROM": "c",
"HDD_1": "disk_%FLAVOR%_%MACHINE%.qcow2",
"POSTINSTALL": "desktop_login",
"START_AFTER_TEST": "install_default_upload"
}
},
"desktop_browser": { "desktop_browser": {
"profiles": { "profiles": {
"fedora-KDE-live-iso-x86_64-*-64bit": 22, "fedora-KDE-live-iso-x86_64-*-64bit": 22,

View File

@ -29,7 +29,7 @@ sub run {
send_key "esc"; send_key "esc";
send_key "esc"; send_key "esc";
send_key "esc"; send_key "esc";
check_desktop_clean; check_desktop;
} }
} }

View File

@ -91,7 +91,7 @@ sub run {
# Move the mouse somewhere it won't highlight the match areas # Move the mouse somewhere it won't highlight the match areas
mouse_set(300, 800); mouse_set(300, 800);
# KDE can take ages to start up # KDE can take ages to start up
check_desktop_clean(tries=>40); check_desktop(tries=>40);
} }
sub test_flags { sub test_flags {

View File

@ -8,28 +8,7 @@ use utils;
sub run { sub run {
my $self = shift; my $self = shift;
# Run the Desktop settings solidify_wallpaper_kde;
hold_key 'alt';
send_key 'd';
send_key 's';
release_key 'alt';
# Select type of background
assert_and_click "deskset_select_type";
wait_still_screen 2;
# Select plain color type
assert_and_click "deskset_plain_color";
wait_still_screen 2;
# Open colors selection
assert_and_click "deskset_select_color";
wait_still_screen 2;
# Select black
assert_and_click "deskset_select_black";
wait_still_screen 2;
# Confirm
assert_and_click "kde_ok";
wait_still_screen 2;
# Close the application
assert_and_click "kde_ok";
# get rid of unwanted notifications that interfere with tests # get rid of unwanted notifications that interfere with tests
click_unwanted_notifications; click_unwanted_notifications;
} }

View File

@ -4,7 +4,7 @@ use testapi;
use utils; use utils;
sub run { sub run {
check_desktop_clean; check_desktop;
# If we want to check that there is a correct background used, as a part # If we want to check that there is a correct background used, as a part
# of self identification test, we will do it here. For now we don't do # of self identification test, we will do it here. For now we don't do
# this for Rawhide as Rawhide doesn't have its own backgrounds and we # this for Rawhide as Rawhide doesn't have its own backgrounds and we

View File

@ -27,7 +27,7 @@ sub _open_new_tab {
sub run { sub run {
my $self = shift; my $self = shift;
check_desktop_clean; check_desktop;
send_key 'alt-f1'; send_key 'alt-f1';
# wait out animations # wait out animations
wait_still_screen(stilltime=>2, similarity_level=>45); wait_still_screen(stilltime=>2, similarity_level=>45);

335
tests/desktop_login.pm Normal file
View File

@ -0,0 +1,335 @@
use base "installedtest";
use strict;
use testapi;
use utils;
our $desktop = get_var("DESKTOP");
our $syspwd = get_var("USER_PASSWORD") || "weakpassword";
our $term = "gnome-terminal";
if ($desktop eq "kde") {
$term = "konsole";
}
sub type_password {
# Safe typing prolongs the operation terribly.
# Let's just use type_string and wait afterwards.
my $string = shift;
type_string "$string\n";
sleep 3;
}
sub adduser {
# Add user to the system.
my %args = @_;
$args{termstart} //= 1;
$args{termstop} //= 1;
my $name = $args{name};
my $login = $args{login};
my $password = $args{password};
if ($args{termstart}) {
menu_launch_type $term;
wait_still_screen 2;
assert_screen "apps_run_terminal";
type_very_safely "sudo -i\n";
type_password $syspwd;
}
assert_script_run "useradd -c '$name' $login";
if ($password ne "askuser") {
# If we want to create a user with a defined password.
type_very_safely "passwd $login\n";
type_password $password;
type_password $password;
}
else {
# If we want to create a user without a password,
# that forces GDM to create a password upon the
# first login.
assert_script_run "passwd -d $login";
assert_script_run "chage --lastday 0 $login";
}
assert_script_run "grep $login /etc/passwd";
# Disable Gnome initial setup on accounts when testing
# inside Gnome.
if ($desktop eq "gnome") {
assert_script_run "mkdir /home/$login/.config";
assert_script_run "echo 'yes' >> /home/$login/.config/gnome-initial-setup-done";
}
if ($args{termstop}) {
type_very_safely "exit\n";
send_key 'alt-f4';
}
}
sub lock_screen {
# Click on buttons to lock the screen.
#my $desktop = get_var("DESKTOP");
assert_and_click "system_menu_button";
if ($desktop eq "kde") {
assert_and_click "leave_button";
}
assert_and_click "lock_button";
wait_still_screen 10;
}
sub login_user {
# Do steps to unlock a previously locked screen. We use it to handle
# logins as well, because it is practically the same.
my %args = @_;
$args{checklogin} //= 1;
$args{method} //= "";
my $user = $args{user};
my $password = $args{password};
my $method = $args{method};
if (!check_screen "login_$user") {
# Sometimes, especially in SDDM, we do not get the user list
# but rather a "screensaver" screen for the DM. If this is the
# case, hit Enter to bring back the user list.
send_key "ret";
wait_still_screen 5;
}
if ($method ne "unlock") {
# When we do not just want to unlock the screen, we need to select a user.
assert_and_click "login_$user";
wait_still_screen 5;
}
if ($method eq "create") {
# With users that do not have passwords, we need to make an extra round
# of password typing.
type_very_safely $password;
send_key "ret";
}
type_very_safely $password;
send_key "ret";
check_desktop if ($args{checklogin});
wait_still_screen 5;
}
sub check_user_logged_in {
# Performs a check that a correct user has been locked in.
my $user = shift;
# In Gnome, the name of the user was accessible through menu
# in the upper right corner, but apparently it has been removed.
# Reading the login name from the terminal prompt seems to be
# the most reliable thing to do.
if ($desktop eq "gnome") {
menu_launch_type $term;
wait_still_screen 2;
}
# 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";
}
assert_screen "user_confirm_$user";
send_key "alt-f4";
wait_still_screen 5;
}
sub logout_user {
# Do steps to log out the user to reach the GDM screen.
assert_and_click "system_menu_button";
assert_and_click "power_entry";
assert_and_click "log_out_entry";
assert_and_click "log_out_confirm";
wait_still_screen 5;
sleep 10;
}
sub switch_user {
# Switch the user, i.e. leave the current user logged in and
# log in another user simultaneously.
if (check_screen "system_menu_button") {
# The system_menu_button indicates that we are in an active
# and unlocked session, where user switching differs
# from a locked but active session.
assert_and_click "system_menu_button";
assert_and_click "power_entry";
assert_and_click "switch_user_entry";
wait_still_screen 5;
# Add sleep to slow down the process a bit
sleep 10;
}
else {
# When the screen is locked, use the icon.
assert_and_click "locked_screen_switch_user";
}
}
sub reboot_system {
# Reboots the system and handles everything until the next GDM screen.
if (check_screen "system_menu_button") {
# Everywhere in Gnome and inside the KDE, there is a menu through which
# we can access the operationg system switching controls.
assert_and_click "system_menu_button";
assert_and_click "power_entry";
if ($desktop eq "gnome") {
# In Gnome, some of the entries are brought together, while in KDE they are
# split and it does not seem correct to me to assign restarting tags to
# needles powering off the machine. So I split this for KDE and Gnome.
# This holds true for Gnome:
assert_and_click "power_off_entry";
assert_and_click "restart_confirm";
}
else {
# And for KDE:
assert_and_click "reboot_entry";
assert_and_click "log_out_confirm";
}
}
# When we are outside KDE (not logged in), the only way to reboot is to click
# the reboot icon.
else {
assert_and_click "reboot_icon";
}
boot_to_login_screen();
}
sub power_off {
# Powers-off the machine. I am not sure if this is not a useless thing to
# do, because at the moment I do not know about a possibility to assert a
# switched-off VM.
assert_and_click "system_menu_button";
assert_and_click "power_entry";
assert_and_click "power_off_entry";
assert_and_click "power_off_confirm";
}
sub run {
# Do a default installation of the Fedora release you wish to test. Create two user accounts.
my $self = shift;
my $jackpass = "kozapanijezibaby";
my $jimpass = "babajagakozaroza";
our $desktop = get_var("DESKTOP");
# Get rid of the KDE wallpaper and make background black.
if ($desktop eq "kde") {
solidify_wallpaper_kde;
# also get rid of the wallpaper on SDDM screen. This is system
# wide so we only need do it once
menu_launch_type $term;
wait_still_screen 2;
assert_screen "apps_run_terminal";
type_very_safely "sudo -i\n";
type_password $syspwd;
assert_script_run "sed -i -e 's,image,solid,g' /usr/share/sddm/themes/01-breeze-fedora/theme.conf.user";
}
if ($desktop eq "kde") {
# we're already at a terminal! EFFICIENCY!
adduser(name=>"Jack Sparrow", login=>"jack", password=>$jackpass, termstart=>0, termstop=>0);
}
else {
# gotta start the terminal
adduser(name=>"Jack Sparrow", login=>"jack", password=>$jackpass, termstart=>1, termstop=>0);
}
if ($desktop eq "gnome") {
# In Gnome, we can create a passwordless user that can provide his password upon
# the first login. So we can create the second user in this way to test this feature
# later.
adduser(name=>"Jim Eagle", login=>"jim", password=>"askuser", termstart=>0, termstop=>1);
}
else {
# In KDE, we can also create a passwordless user, but we cannot log into the system
# later, so we will create the second user the standard way.
adduser(name=>"Jim Eagle", login=>"jim", password=>$jimpass, termstart=>0, termstop=>1);
}
# Clean boot the system, and note what accounts are listed on the login screen.
# Log out the default user "test" and reboot the system
# before the actual testing starts. There is no need to check specifically
# if the users are listed, because if they are not, the login tests will fail
# later.
logout_user();
reboot_system();
# Log in with the first user account.
login_user(user=>"jack", password=>$jackpass);
if ($desktop eq "kde") {
solidify_wallpaper_kde;
}
check_user_logged_in("jack");
# Log out the user.
logout_user();
# Log in with the second user account. The second account, Jim Eagle,
if ($desktop eq "gnome") {
# If we are in Gnome, we will this time assign a password on first log-in.
login_user(user=>"jim", password=>$jimpass, method=>"create");
}
else {
# If not, we are in KDE and we will log in normally.
login_user(user=>"jim", password=>$jimpass);
solidify_wallpaper_kde;
}
check_user_logged_in("jim");
# And this time reboot the system using the menu.
reboot_system();
# Try to log in with either account, intentionally entering the wrong password.
login_user(user=>"jack", password=>"wrongpassword", checklogin=>0);
if ($desktop eq "gnome") {
# In GDM, a message is shown about an unsuccessful login and it can be
# asserted, so let's do it. In SDDM, there is also a message, but it
# is only displayed for a short moment and the assertion fails here,
# so we will skip the assertion. Not being able to login in with
# a wrong password is enough here.
assert_screen "login_wrong_password";
send_key 'esc';
}
# Now, log into the system again using the correct password.
login_user(user=>"jim", password=>$jimpass);
check_user_logged_in("jim");
# Lock the screen and unlock again.
lock_screen();
# Use the password to unlock the screen.
login_user(user=>"jim", password=>$jimpass, method=>"unlock");
# Switch user tests
if ($desktop eq "gnome") {
# 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.
# This time, we will open the terminal window manually because we want to leave it open later.
menu_launch_type "terminal";
wait_still_screen 2;
# Initiate switch user
switch_user();
# Now, we get a new login screen, so let's do the login into the new session.
login_user(user=>"jack", password=>$jackpass);
# Check that it is a new session, the terminal window should not be visible.
if (check_screen "user_confirm_jim") {
die "The session was not switched!";
}
else {
check_user_logged_in("jack");
}
# Log out the user.
logout_user();
# Now, let us log into the original session, this time, the terminal window
# should still be visible.
login_user(user=>"jim", password=>$jimpass);
assert_screen "user_confirm_jim";
# We will also test another alternative - switching the user from
# a locked screen.
lock_screen();
send_key "ret";
switch_user();
login_user(user=>"jack", password=>$jackpass);
check_user_logged_in("jack");
}
# Power off the machine
power_off();
check_shutdown;
}
sub test_flags {
return { fatal => 1 };
}
1;
# vim: set sw=4 et:

View File

@ -67,7 +67,7 @@ sub run {
type_very_safely get_var("USER_PASSWORD", "weakpassword"); type_very_safely get_var("USER_PASSWORD", "weakpassword");
send_key 'ret'; send_key 'ret';
} }
check_desktop_clean(tries=>30); check_desktop(tries=>30);
# now, WE WAIT. this is just an unconditional wait - rather than # now, WE WAIT. this is just an unconditional wait - rather than
# breaking if we see an update notification appear - so we catch # breaking if we see an update notification appear - so we catch
# things that crash a few minutes after startup, etc. # things that crash a few minutes after startup, etc.

View File

@ -5,7 +5,7 @@ use utils;
sub run { sub run {
my $self=shift; my $self=shift;
check_desktop_clean; check_desktop;
menu_launch_type('terminal'); menu_launch_type('terminal');
wait_still_screen 5; wait_still_screen 5;
# need to be root # need to be root