[gnome-settings-daemon] power: Add simple test for lid close with no external monitor



commit 8f440ab8fe342e6912cd0ba949251d48ef98bed1
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Jan 22 16:03:58 2013 +0100

    power: Add simple test for lid close with no external monitor
    
    And unplugging that monitor.

 plugins/power/test.py |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/plugins/power/test.py b/plugins/power/test.py
index ca1df5c..a6c6cff 100755
--- a/plugins/power/test.py
+++ b/plugins/power/test.py
@@ -116,6 +116,16 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
     def get_status(self):
         return self.obj_session_presence_props.Get('org.gnome.SessionManager.Presence', 'status')
 
+    def set_has_external_monitor(self, external):
+        f = open('GSD_MOCK_EXTERNAL_MONITOR', 'w')
+        if external:
+            f.write('1')
+        else:
+            f.write('0')
+        f.close ()
+
+        os.kill(self.daemon.pid, signal.SIGUSR2)
+
     def check_for_suspend(self, timeout):
         '''Check that Suspend() or Hibernate() is requested.
 
@@ -335,6 +345,26 @@ class PowerPluginTest(gsdtestcase.GSDTestCase):
 
         self.assertEqual(self.get_status(), gsdpowerenums.GSM_PRESENCE_STATUS_AVAILABLE)
 
+    def test_no_suspend_lid_close(self):
+        '''Check that we don't suspend on lid close with an external monitor'''
+
+        # Add an external monitor
+        self.set_has_external_monitor(True)
+        time.sleep (1)
+
+        # Close the lid
+        self.obj_upower.Set('org.freedesktop.UPower', 'LidIsClosed', True)
+        self.obj_upower.EmitSignal('', 'Changed', '', [], dbus_interface='org.freedesktop.DBus.Mock')
+
+        # Check for suspend
+        self.check_no_suspend (10)
+
+        # Unplug the external monitor
+        self.set_has_external_monitor(False)
+        self.check_for_suspend (10)
+
+        os.unlink('GSD_MOCK_EXTERNAL_MONITOR')
+
     def test_action_critical_battery(self):
         '''action on critical battery'''
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]