Skip to content

Commit

Permalink
Add test module to disable screensaver
Browse files Browse the repository at this point in the history
  • Loading branch information
asdil12 committed Sep 23, 2019
1 parent 1223232 commit 41873a7
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/main_common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ sub load_reboot_tests {
# exclude this scenario for autoyast test with switched keyboard layaout
loadtest "installation/first_boot" unless get_var('INSTALL_KEYBOARD_LAYOUT');
loadtest "installation/opensuse_welcome" if opensuse_welcome_applicable();
load_system_prepare_tests();
if (is_aarch64 && !get_var('INSTALLONLY') && !get_var('LIVE_INSTALLATION') && !get_var('LIVE_UPGRADE')) {
loadtest "installation/system_workarounds";
}
Expand Down Expand Up @@ -1077,7 +1078,6 @@ sub load_console_server_tests {
sub load_consoletests {
return unless consolestep_is_applicable();
loadtest 'qa_automation/patch_and_reboot' if is_updates_tests && !get_var('QAM_MINIMAL');
loadtest "console/system_prepare";
loadtest "console/check_network";
loadtest "console/system_state";
loadtest "console/prepare_test_data";
Expand All @@ -1102,13 +1102,11 @@ sub load_consoletests {
loadtest "console/supportutils";
loadtest "console/check_package_version" if check_var('UPGRADE_TARGET_VERSION', '12-SP5');
}
loadtest "console/force_scheduled_tasks" unless is_jeos;
if (get_var("LOCK_PACKAGE")) {
loadtest "console/check_locked_package";
}
loadtest "console/textinfo";
loadtest "console/rmt" if is_rmt;
loadtest "console/hostname" unless is_bridged_networking;
# Add non-oss and debug repos for o3 and remove other by default
replace_opensuse_repos_tests if is_repo_replacement_required;
if (get_var('SYSTEM_ROLE', '') =~ /kvm|xen/) {
Expand Down Expand Up @@ -2436,12 +2434,12 @@ sub load_systemd_patches_tests {

sub load_system_prepare_tests {
loadtest 'ses/install_ses' if check_var_array('ADDONS', 'ses') || check_var_array('SCC_ADDONS', 'ses');
loadtest 'qa_automation/patch_and_reboot' if is_updates_tests;
# temporary adding test modules which applies hacks for missing parts in sle15
loadtest 'console/sle15_workarounds' if is_sle('15+');
loadtest 'console/integration_services' if is_hyperv || is_vmware;
loadtest 'console/hostname' unless is_bridged_networking;
loadtest 'console/system_prepare';
loadtest "x11/disable_screensaver" if any_desktop_is_applicable();
loadtest 'console/force_scheduled_tasks' unless is_jeos;
# Remove repos pointing to download.opensuse.org and add snaphot repo from o3
replace_opensuse_repos_tests if is_repo_replacement_required;
Expand All @@ -2452,7 +2450,7 @@ sub load_system_prepare_tests {
sub load_create_hdd_tests {
return unless get_var('INSTALLONLY');
# install SES packages and deepsea testsuites
load_system_prepare_tests;
loadtest 'qa_automation/patch_and_reboot' if is_updates_tests;
load_shutdown_tests;
if (check_var('BACKEND', 'svirt')) {
if (is_hyperv) {
Expand Down
3 changes: 3 additions & 0 deletions lib/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,9 @@ sub disable_serial_getty {
# Mask if is qemu backend as use serial in remote installations e.g. during reboot
systemctl "mask $service_name", ignore_failure => 1 if check_var('BACKEND', 'qemu');
record_info 'serial-getty', "Serial getty mask for $testapi::serialdev";
# agetty changed the group from "dialout" to "tty". This won't happen again on next boot,
# but we need to manually change it back for now.
assert_script_run "chown :dialout /dev/$testapi::serialdev";
}

=head2 exec_and_insert_password
Expand Down
105 changes: 105 additions & 0 deletions lib/x11utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ our @EXPORT = qw(
turn_off_kde_screensaver
turn_off_gnome_screensaver
turn_off_gnome_suspend
turn_off_xfce_screensaver
turn_off_x11_dpms
turn_off_screensaver
set_screensaver_timeout
);


Expand Down Expand Up @@ -213,6 +217,13 @@ sub turn_off_kde_screensaver {
assert_screen 'screenlock-disabled';
send_key('alt-o');
assert_screen 'generic-desktop';
x11_start_program('kcmshell5 powerdevilprofilesconfig', target_match => [qw(kde-screenpower-enabled kde-screenpower-disabled)]);
if (match_has_tag('kde-screenpower-enabled')) {
assert_and_click('kde-disable-screenpower');
}
assert_screen 'kde-screenpower-disabled';
send_key('alt-o');
assert_screen 'generic-desktop';
}

=head2 turn_off_gnome_screensaver
Expand All @@ -237,4 +248,98 @@ sub turn_off_gnome_suspend {
script_run 'gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type \'nothing\'';
}

=head2 turn_off_xfce_screensaver
turn_off_xfce_screensaver();
Disables screensaver in xfce. To be called from a command prompt, for example an xterm window.
=cut
sub turn_off_xfce_screensaver {
script_run 'xfconf-query -c xfce4-screensaver -p /saver/enabled -n -t bool -s false';
script_run 'xfconf-query -c xfce4-screensaver -p /lock/enabled -n -t bool -s false';
}

=head2 turn_of_x11_dpms
turn_off_x11_dpms();
This will disable the X11 Display Power Management Signaling
eg. blanking the screen and sending the monitor to sleep after some time.
This will disable the setting at runtime and also add a config file for the
XServer to make this change persist reboots.
This function must be called from an xterm - B<not> from a bare tty.
This is because the tty will not have the permissions to run C<xset>.
=cut
sub turn_off_x11_dpms {
script_run 'xset -dpms';
script_run 'xset s off';
become_root;
script_run "echo 'Section \"Extensions\"' > /etc/X11/xorg.conf.d/90-nodpms.conf";
script_run "echo ' Option \"DPMS\" \"Disable\"' >> /etc/X11/xorg.conf.d/90-nodpms.conf";
script_run "echo 'EndSection' >> /etc/X11/xorg.conf.d/90-nodpms.conf";
type_string "exit\n";
}

=head2 turn_off_screensaver
turn_off_screensaver();
This will disable the screensaver for your current desktop.
=cut
sub turn_off_screensaver {
if (check_var 'DESKTOP', 'kde') {
# kde settings will be changed via gui
# so xterm will be started afterwards
turn_off_kde_screensaver;
x11_start_program('xterm');
}
elsif (check_var 'DESKTOP', 'gnome') {
x11_start_program('xterm');
turn_off_gnome_screensaver;
}
elsif (check_var 'DESKTOP', 'xfce') {
x11_start_program('xterm');
turn_off_xfce_screensaver;
}
turn_off_x11_dpms();
sleep 10;
type_string "exit\n";
}

=head2 set_screensaver_timeout
set_screensaver_timeout($timeout);
This will set the screensaver timeout to C<$timeout>.
=cut
sub set_screensaver_timeout {
my ($timeout) = @_;
if (check_var 'DESKTOP', 'kde') {
x11_start_program('kcmshell5 screenlocker', target_match => [qw(kde-screenlock-timeout)]);
assert_and_click('kde-screenlock-timeout');
send_key('ctrl-a');
type_string("$timeout");
assert_screen 'kde-screenlock-enabled';
send_key('alt-o');
assert_screen 'generic-desktop';
return;
}
elsif (check_var 'DESKTOP', 'gnome') {
x11_start_program('xterm');
$timeout = $timeout * 60; # gnome uses seconds
script_run "gsettings set org.gnome.desktop.session idle-delay $timeout";
}
elsif (check_var 'DESKTOP', 'xfce') {
x11_start_program('xterm');
script_run "xfconf-query -c xfce4-screensaver -p /saver/idle-activation/delay -n -t int -s $timeout";
}
type_string "exit\n";
}

1;
1 change: 1 addition & 0 deletions tests/console/system_prepare.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ sub run {
my ($self) = @_;
select_console 'root-console';

disable_serial_getty;
ensure_serialdev_permissions;

# Configure serial consoles for virtio support
Expand Down
41 changes: 41 additions & 0 deletions tests/x11/disable_screensaver.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# SUSE's openQA tests
#
# Copyright © 2019 SUSE LLC
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.

# Summary: Ensure screensaver is working and then disable it
# Maintainer: Dominik Heidler <dheidler@suse.de>

use base "x11test";
use strict;
use warnings;
use testapi;
use x11utils;

sub run {
my ($self) = @_;

select_console 'x11';
ensure_unlocked_desktop;
assert_screen "generic-desktop";

# set screensaver timeout to one minute
set_screensaver_timeout(1);

# wait for screensaver to start
assert_screen [qw(screenlock screenlock-password)], 70;
ensure_unlocked_desktop;
mouse_hide(1);

turn_off_screensaver;

# ensure that the screensaver will not start anymore
sleep 70;
assert_screen "generic-desktop";
}

1;

0 comments on commit 41873a7

Please sign in to comment.