[pitivi/ges: 136/287] tests/test_system.py: test that adding and removing keys occurs properly tests/test_system_gnome.py:
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/ges: 136/287] tests/test_system.py: test that adding and removing keys occurs properly tests/test_system_gnome.py:
- Date: Thu, 15 Mar 2012 16:37:16 +0000 (UTC)
commit 8e2b19af25376a673c1d06bf76d6e34712ca9a2f
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date: Sun Jan 1 20:11:43 2012 -0500
tests/test_system.py: test that adding and removing keys occurs properly
tests/test_system_gnome.py: test powersaving works on GNOME
tests/test_system.py | 50 ++++++++++++++++++++++++++++++++++++++++++++
tests/test_system_gnome.py | 48 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 98 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_system.py b/tests/test_system.py
new file mode 100644
index 0000000..4f913e5
--- /dev/null
+++ b/tests/test_system.py
@@ -0,0 +1,50 @@
+from unittest import TestCase
+from pitivi.system import System
+
+class TestSystem(TestCase):
+ def setUp(self):
+ self.system = System()
+
+ def testScreensaverInhibit(self):
+ #check that we start of uninhibited
+ self.assertTrue(not self.system.screensaverIsInhibited())
+
+ #inhibit and check that we are
+ self.system.inhibitScreensaver("a")
+ self.assertTrue(self.system.screensaverIsInhibited())
+ #uninhibit and check that we are
+ self.system.uninhibitScreensaver("a")
+ self.assertTrue(not self.system.screensaverIsInhibited())
+
+ #check that adding/removing is consistent with multiple keys
+ for c in range(0, 5):
+ self.system.inhibitScreensaver(str(c))
+ self.assertTrue(self.system.screensaverIsInhibited(str(c)))
+
+ for c in range (0, 5):
+ self.system.uninhibitScreensaver(str(c))
+ self.assertTrue(not self.system.screensaverIsInhibited(str(c)))
+
+ self.assertTrue(not self.system.screensaverIsInhibited())
+
+ def testSleepInhibit(self):
+ #check that we start of uninhibited
+ self.assertTrue(not self.system.sleepIsInhibited())
+
+ #inhibit and check that we are
+ self.system.inhibitSleep("a")
+ self.assertTrue(self.system.sleepIsInhibited())
+ #uninhibit and check that we are
+ self.system.uninhibitSleep("a")
+ self.assertTrue(not self.system.sleepIsInhibited())
+
+ #check that adding/removing is consistent with multiple keys
+ for c in range(0, 5):
+ self.system.inhibitSleep(str(c))
+ self.assertTrue(self.system.sleepIsInhibited(str(c)))
+
+ for c in range (0, 5):
+ self.system.uninhibitSleep(str(c))
+ self.assertTrue(not self.system.sleepIsInhibited(str(c)))
+
+ self.assertTrue(not self.system.sleepIsInhibited())
diff --git a/tests/test_system_gnome.py b/tests/test_system_gnome.py
new file mode 100644
index 0000000..c400e63
--- /dev/null
+++ b/tests/test_system_gnome.py
@@ -0,0 +1,48 @@
+from unittest import TestCase
+from pitivi.system import getSystem, GnomeSystem, \
+ INHIBIT_LOGOUT, INHIBIT_SUSPEND, INHIBIT_SESSION_IDLE
+
+
+class TestGnomeSystem(TestCase):
+ def setUp(self):
+ self.system = getSystem()
+
+ def testPowerInhibition(self):
+ self.assertTrue(isinstance(self.system, GnomeSystem))
+ #check that no other programs are inhibiting, otherwise the
+ #test is compromised
+ self.assertTrue(not self.system.session_iface.IsInhibited(
+ INHIBIT_LOGOUT | INHIBIT_USER_SWITCHING | INHIBIT_SUSPEND |
+ INHIBIT_SESSION_IDLE))
+
+ self.system.inhibitScreensaver('1')
+ self.assertTrue(self.system.session_iface.IsInhibited(
+ INHIBIT_SESSION_IDLE))
+
+ self.system.inhibitSleep('2')
+ #screensaver should be able to turn off, but
+ self.assertTrue(not self.system.session_iface.IsInhibited(
+ INHIBIT_SESSION_IDLE))
+ #suspend (sleep, suspend, shutdown), logout should be inhibited
+ #IsInhibited will return true if just one is inhibited, so we
+ #check both separately.
+ self.assertTrue(self.system.session_iface.IsInhibited(
+ INHIBIT_SUSPEND))
+ self.assertTrue(self.system.session_iface.IsInhibited(
+ INHIBIT_LOGOUT))
+
+ self.system.uninhibitSleep('2')
+ #screensaver should now be blocked
+ self.assertTrue(self.system.session_iface.IsInhibited(
+ INHIBIT_SESSION_IDLE))
+ #suspend and logout should be unblocked
+ self.assertTrue(not self.system.session_iface.IsInhibited(
+ INHIBIT_SUSPEND))
+ self.assertTrue(not self.system.session_iface.IsInhibited(
+ INHIBIT_LOGOUT))
+
+ self.system.uninhibitScreensaver('1')
+ #now everything should be unblocked
+ self.assertTrue(not self.system.session_iface.IsInhibited(
+ INHIBIT_LOGOUT | INHIBIT_USER_SWITCHING | INHIBIT_SUSPEND |
+ INHIBIT_SESSION_IDLE))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]