[pitivi] tests: Move the system module tests to test_system



commit ad723db6879d42058ef855bfa865396170cda305
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Thu Jan 30 21:43:35 2014 +0100

    tests: Move the system module tests to test_system
    
    Also some cleanup in the file headers.

 tests/Makefile.am             |    1 -
 tests/test_common.py          |    4 --
 tests/test_projectsettings.py |    3 +-
 tests/test_signallable.py     |   22 ++++++++++++
 tests/test_system.py          |   75 ++++++++++++++++++++++++++++++++++++++++-
 tests/test_system_gnome.py    |   52 ----------------------------
 6 files changed, 98 insertions(+), 59 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a2ae3ea..87de577 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -13,7 +13,6 @@ tests =       \
        test_project.py \
        test_projectsettings.py \
        test_signallable.py \
-       test_system_gnome.py \
        test_system.py \
        test_timeline_undo.py \
        test_undo.py \
diff --git a/tests/test_common.py b/tests/test_common.py
index 766ad2f..9070a68 100644
--- a/tests/test_common.py
+++ b/tests/test_common.py
@@ -20,7 +20,6 @@
 # Boston, MA 02110-1301, USA.
 
 import common
-from unittest import main
 import pitivi.utils.ui as ui_common
 
 
@@ -45,6 +44,3 @@ class TestColors(common.TestCase):
         self.assertEquals(
             (0x01FF, 0x02FF, 0x04FF, 0x08FF),
             ui_common.unpack_color_64(0x01FF02FF04FF08FF))
-
-if __name__ == "__main__":
-    main()
diff --git a/tests/test_projectsettings.py b/tests/test_projectsettings.py
index 7bb827e..ebff2d5 100644
--- a/tests/test_projectsettings.py
+++ b/tests/test_projectsettings.py
@@ -1,8 +1,9 @@
+# -*- coding: utf-8 -*-
 # Pitivi video editor
 #
 #       tests/test_projectsettings.py
 #
-# Copyright (c) 2011, Alex Balut <alexandru balut gmail com>
+# Copyright (c) 2011, Alex Băluț <alexandru balut gmail com>
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/tests/test_signallable.py b/tests/test_signallable.py
index 9ab6e8f..f664ba1 100644
--- a/tests/test_signallable.py
+++ b/tests/test_signallable.py
@@ -1,3 +1,25 @@
+# -*- coding: utf-8 -*-
+# Pitivi video editor
+#
+#       tests/test_signallable.py
+#
+# Copyright (c) 2008, Edward Hervey <bilboed bilboed com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
 import unittest
 from pitivi.utils.signal import Signallable
 
diff --git a/tests/test_system.py b/tests/test_system.py
index d23cd9e..5abe9c0 100644
--- a/tests/test_system.py
+++ b/tests/test_system.py
@@ -1,5 +1,30 @@
+# -*- coding: utf-8 -*-
+# Pitivi video editor
+#
+#       tests/test_system.py
+#
+# Copyright (c) 2012, Jean-François Fortin Tam <nekohayo gmail com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
 from unittest import TestCase
-from pitivi.utils.system import System
+
+from pitivi.utils.system import System, getSystem, GnomeSystem, \
+    INHIBIT_LOGOUT, INHIBIT_SUSPEND, INHIBIT_SESSION_IDLE, \
+    INHIBIT_USER_SWITCHING
 
 
 class TestSystem(TestCase):
@@ -58,3 +83,51 @@ class TestSystem(TestCase):
             self.assertTrue(not self.system.sleepIsInhibited(str(c)))
 
         self.assertTrue(not self.system.sleepIsInhibited())
+
+
+class TestGnomeSystem(TestCase):
+    def setUp(self):
+        self.system = getSystem()
+
+    def testPowerInhibition(self):
+        if not isinstance(self.system, GnomeSystem):
+            # We can only test this on a Gnome system.
+            return
+
+        #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]