diff options
| author | Bastien Nocera <hadess@hadess.net> | 2013-01-23 17:44:12 (GMT) |
|---|---|---|
| committer | Bastien Nocera <hadess@hadess.net> | 2013-01-23 18:21:20 (GMT) |
| commit | 09c87dbaae882ee7225fcc9052ebcd6a07c695a1 (patch) | |
| tree | 4e1a5422464bf2baffacbbc77c3237411964c42a | |
| parent | de5b13d6afa2db9db974b3ccdb280cfc2c89febc (diff) | |
| download | gnome-settings-daemon-09c87dbaae882ee7225fcc9052ebcd6a07c695a1.zip gnome-settings-daemon-09c87dbaae882ee7225fcc9052ebcd6a07c695a1.tar.xz | |
power: Add tests for blanking on lid close
For details see bug 692282
| -rwxr-xr-x | plugins/power/test.py | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/plugins/power/test.py b/plugins/power/test.py index a09e75d..9ad59f8 100755 --- a/plugins/power/test.py +++ b/plugins/power/test.py @@ -334,6 +334,73 @@ class PowerPluginTest(gsdtestcase.GSDTestCase): self.obj_session_mgr.Uninhibit(dbus.UInt32(inhibit_id)) + def test_lock_on_lid_close(self): + '''Check that we do lock on lid closing, if the machine will not suspend''' + + self.settings_screensaver['lock-enabled'] = True + + # create inhibitor + inhibit_id = self.obj_session_mgr.Inhibit( + 'testsuite', dbus.UInt32(0), 'for testing', + dbus.UInt32(gsdpowerenums.GSM_INHIBITOR_FLAG_SUSPEND)) + + # Close the lid + self.obj_upower.Set('org.freedesktop.UPower', 'LidIsClosed', True) + self.obj_upower.EmitSignal('', 'Changed', '', [], dbus_interface='org.freedesktop.DBus.Mock') + + # Check that we've blanked + time.sleep(2) + self.assertTrue(self.obj_screensaver.GetActive(), 'screensaver not turned on') + self.check_blank(2) + + # Drop the inhibit and see whether we suspend + self.obj_session_mgr.Uninhibit(dbus.UInt32(inhibit_id)) + self.check_for_suspend(5) + + def test_blank_on_lid_close(self): + '''Check that we do blank on lid closing, if the machine will not suspend''' + + # create inhibitor + inhibit_id = self.obj_session_mgr.Inhibit( + 'testsuite', dbus.UInt32(0), 'for testing', + dbus.UInt32(gsdpowerenums.GSM_INHIBITOR_FLAG_SUSPEND)) + + # Close the lid + self.obj_upower.Set('org.freedesktop.UPower', 'LidIsClosed', True) + self.obj_upower.EmitSignal('', 'Changed', '', [], dbus_interface='org.freedesktop.DBus.Mock') + + # Check that we've blanked + self.check_blank(4) + + # Drop the inhibit and see whether we suspend + self.obj_session_mgr.Uninhibit(dbus.UInt32(inhibit_id)) + self.check_for_suspend(5) + + def test_unblank_on_lid_open(self): + '''Check that we do unblank on lid opening, if the machine will not suspend''' + + # create inhibitor + inhibit_id = self.obj_session_mgr.Inhibit( + 'testsuite', dbus.UInt32(0), 'for testing', + dbus.UInt32(gsdpowerenums.GSM_INHIBITOR_FLAG_SUSPEND)) + + # Close the lid + self.obj_upower.Set('org.freedesktop.UPower', 'LidIsClosed', True) + self.obj_upower.EmitSignal('', 'Changed', '', [], dbus_interface='org.freedesktop.DBus.Mock') + + # Check that we've blanked + self.check_blank(2) + + # Reopen the lid + self.obj_upower.Set('org.freedesktop.UPower', 'LidIsClosed', False) + self.obj_upower.EmitSignal('', 'Changed', '', [], dbus_interface='org.freedesktop.DBus.Mock') + + # Check for unblanking + self.check_unblank(2) + + # Drop the inhibit + self.obj_session_mgr.Uninhibit(dbus.UInt32(inhibit_id)) + def test_dim(self): '''Check that we do go to dim''' |
