~ubuntu-branches/ubuntu/natty/pyside/natty

« back to all changes in this revision

Viewing changes to tests/QtGui/bug_416.py

  • Committer: Bazaar Package Importer
  • Author(s): Didier Raboud
  • Date: 2011-02-18 18:01:00 UTC
  • mfrom: (1.1.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20110218180100-y8aqmcdbcbd6gpeh
Tags: upstream-1.0.0~rc1
ImportĀ upstreamĀ versionĀ 1.0.0~rc1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import unittest
 
4
from helper import TimedQApplication
 
5
from PySide.QtCore import QSignalTransition, QState, Qt, QStateMachine
 
6
from PySide.QtGui import QCheckBox
 
7
 
 
8
class CheckedTransition(QSignalTransition):
 
9
    def __init__(self, check):
 
10
        QSignalTransition.__init__(self, check.stateChanged[int])
 
11
        self.eventTested = False
 
12
 
 
13
    def eventTest(self, event):
 
14
        self.eventTested = True
 
15
        if not QSignalTransition.eventTest(self, event):
 
16
            return False
 
17
        return event.arguments()[0] == Qt.Checked
 
18
 
 
19
class TestBug(TimedQApplication):
 
20
    def testCase(self):
 
21
        check = QCheckBox()
 
22
        check.setTristate(True)
 
23
 
 
24
        s1 = QState()
 
25
        s2 = QState()
 
26
 
 
27
        t1 = CheckedTransition(check)
 
28
        t1.setTargetState(s2)
 
29
        s1.addTransition(t1)
 
30
 
 
31
        machine = QStateMachine()
 
32
        machine.addState(s1)
 
33
        machine.addState(s2)
 
34
        machine.setInitialState(s1)
 
35
        machine.start()
 
36
 
 
37
        check.stateChanged[int].emit(1)
 
38
        check.show()
 
39
        self.app.exec_()
 
40
        self.assert_(t1.eventTested)
 
41
 
 
42
if __name__ == '__main__':
 
43
    unittest.main()