~ubuntu-branches/ubuntu/oneiric/pyside/oneiric

« back to all changes in this revision

Viewing changes to tests/QtTest/eventfilter_test.py

  • Committer: Bazaar Package Importer
  • Author(s): Didier Raboud
  • Date: 2010-09-27 21:01:06 UTC
  • mfrom: (1.2.1 upstream) (6.1.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20100927210106-m1nrq8vmd3exqb9o
Tags: 0.4.1-0ubuntu1
* New 0.4.1 upstream release. (LP: #648612)
  - Add some 0.4.1 symbols.

* Patches:
  - u_c130273_fix_py25_QtScript_property.patch
    Remove, was from upstream.
  - u_20e226b_fix_missing_qcoreapplication_arguments_method.patch
    Remove, was from upstream.
  - u_268bf77_fixed_signal_signature_parser.patch
    Remove, was from upstream.
  + libPythonVersionPostfix.patch: Refresh
  + usePySpecificShiboken.patch: Refresh
  + lessBuildVerbosity.patch: Refresh

* Bump the B-D chain versions.
* Make sure the private.py is installed in QtCore module.
* Build against Qt 4.7.
  - Add libqtwebkit-dev
  - Drop QtMultimedia module.
  - Add the QtDeclarative package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
'''Tests for QKeyEvent'''
 
3
 
 
4
import unittest
 
5
 
 
6
from PySide.QtCore import *
 
7
from PySide.QtGui import *
 
8
from PySide.QtTest import QTest
 
9
 
 
10
from helper import UsesQApplication
 
11
 
 
12
 
 
13
class KeyEventFilter(QObject):
 
14
 
 
15
    def __init__(self, widget, eventType, key):
 
16
        QObject.__init__(self)
 
17
 
 
18
        self.widget = widget
 
19
        self.eventType = eventType
 
20
        self.key = key
 
21
 
 
22
        self.processed = False
 
23
 
 
24
    def eventFilter(self, obj, event):
 
25
        if self.widget == obj and event.type() == self.eventType and \
 
26
               isinstance(event, QKeyEvent) and event.key() == self.key:
 
27
            self.processed = True
 
28
            return True
 
29
 
 
30
        return False
 
31
 
 
32
class EventFilterTest(UsesQApplication):
 
33
 
 
34
    def testKeyEvent(self):
 
35
        widget = QLineEdit()
 
36
        key = Qt.Key_A
 
37
        eventFilter = KeyEventFilter(widget, QEvent.KeyPress, key)
 
38
        widget.installEventFilter(eventFilter)
 
39
 
 
40
        QTest.keyClick(widget, key)
 
41
 
 
42
        self.assert_(eventFilter.processed)
 
43
 
 
44
 
 
45
 
 
46
if __name__ == '__main__':
 
47
    unittest.main()