~timo-jyrinki/ubuntu/trusty/pitivi/backport_utopic_fixes

« back to all changes in this revision

Viewing changes to tests/test_system_gnome.py

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2014-03-29 15:22:50 UTC
  • mto: (3.1.23 experimental)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: package-import@ubuntu.com-20140329152250-flg9onx416bqf3e3
Tags: upstream-0.93
Import upstream version 0.93

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from unittest import TestCase
2
 
from pitivi.utils.system import getSystem, GnomeSystem, \
3
 
    INHIBIT_LOGOUT, INHIBIT_SUSPEND, INHIBIT_SESSION_IDLE, \
4
 
    INHIBIT_USER_SWITCHING
5
 
 
6
 
 
7
 
class TestGnomeSystem(TestCase):
8
 
    def setUp(self):
9
 
        self.system = getSystem()
10
 
 
11
 
    def testPowerInhibition(self):
12
 
        if not isinstance(self.system, GnomeSystem):
13
 
            # We can only test this on a Gnome system.
14
 
            return
15
 
 
16
 
        #check that no other programs are inhibiting, otherwise the
17
 
        #test is compromised
18
 
        self.assertTrue(not self.system.session_iface.IsInhibited(
19
 
            INHIBIT_LOGOUT | INHIBIT_USER_SWITCHING | INHIBIT_SUSPEND |
20
 
            INHIBIT_SESSION_IDLE))
21
 
 
22
 
        self.system.inhibitScreensaver('1')
23
 
        self.assertTrue(self.system.session_iface.IsInhibited(
24
 
            INHIBIT_SESSION_IDLE))
25
 
 
26
 
        self.system.inhibitSleep('2')
27
 
        #screensaver should be able to turn off, but
28
 
        self.assertTrue(not self.system.session_iface.IsInhibited(
29
 
            INHIBIT_SESSION_IDLE))
30
 
        #suspend (sleep, suspend, shutdown), logout should be inhibited
31
 
        #IsInhibited will return true if just one is inhibited, so we
32
 
        #check both separately.
33
 
        self.assertTrue(self.system.session_iface.IsInhibited(
34
 
            INHIBIT_SUSPEND))
35
 
        self.assertTrue(self.system.session_iface.IsInhibited(
36
 
            INHIBIT_LOGOUT))
37
 
 
38
 
        self.system.uninhibitSleep('2')
39
 
        #screensaver should now be blocked
40
 
        self.assertTrue(self.system.session_iface.IsInhibited(
41
 
            INHIBIT_SESSION_IDLE))
42
 
        #suspend and logout should be unblocked
43
 
        self.assertTrue(not self.system.session_iface.IsInhibited(
44
 
            INHIBIT_SUSPEND))
45
 
        self.assertTrue(not self.system.session_iface.IsInhibited(
46
 
            INHIBIT_LOGOUT))
47
 
 
48
 
        self.system.uninhibitScreensaver('1')
49
 
        #now everything should be unblocked
50
 
        self.assertTrue(not self.system.session_iface.IsInhibited(
51
 
            INHIBIT_LOGOUT | INHIBIT_USER_SWITCHING | INHIBIT_SUSPEND |
52
 
            INHIBIT_SESSION_IDLE))