diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-04 03:59:01 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-04 03:59:01 (GMT) |
commit | e4c49c5344058aaa033a9928e96205c767b8e07d (patch) | |
tree | b14f2bf71ee4bd58dc4e3ab547944e84358f4668 /tests | |
parent | ffa103af9620998f47c632f4118e789bf7f1cde7 (diff) | |
parent | 3d745d7ded2ed8d52a8c6d9f7113bd6a61e13647 (diff) | |
download | Qt-e4c49c5344058aaa033a9928e96205c767b8e07d.zip Qt-e4c49c5344058aaa033a9928e96205c767b8e07d.tar.gz Qt-e4c49c5344058aaa033a9928e96205c767b8e07d.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1:
add static QChar::is(High|Low)Surrogate methods
Increase tooltip margin for cleanlooks+gtk
Fixes a crash in QGestureManager when unregistering recognizers.
Propagate LocaleChange event from application to widgets.
Support updating system locale data on Symbian
QMap: make sure we never access forward and backward through typed Node structs
Don't quote $COMPILER because it may contain flags
Unix configure: fix sed pattern extracting C and C++ flags from mkspec
qdoc: Added more API topics. Are these important?
Prevent accelerators from firing on X11 and QWS during a drag
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gestures/tst_gestures.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index f8ecca3..dfadf48 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -50,6 +50,7 @@ #include <qgesturerecognizer.h> #include <qgraphicsitem.h> #include <qgraphicsview.h> +#include <qmainwindow.h> #include <qdebug.h> @@ -355,6 +356,7 @@ private slots: void deleteGestureTargetItem(); void viewportCoordinates(); void partialGesturePropagation(); + void testQGestureRecognizerCleanup(); }; tst_Gestures::tst_Gestures() @@ -1949,5 +1951,74 @@ void tst_Gestures::partialGesturePropagation() QCOMPARE(item4->gestureEventsReceived, 0); } +class WinNativePan : public QPanGesture { +public: + WinNativePan() {} +}; + +class Pan : public QPanGesture { +public: + Pan() {} +}; + +class CustomPan : public QPanGesture { +public: + CustomPan() {} +}; + +// Recognizer for active gesture triggers on mouse press +class PanRecognizer : public QGestureRecognizer { +public: + enum PanType { Platform, Default, Custom }; + + PanRecognizer(int id) : m_id(id) {} + QGesture *create(QObject *) { + switch(m_id) { + case Platform: return new WinNativePan(); + case Default: return new Pan(); + default: return new CustomPan(); + } + } + + Result recognize(QGesture *, QObject *, QEvent *) { return QGestureRecognizer::Ignore; } + + const int m_id; +}; + +void tst_Gestures::testQGestureRecognizerCleanup() +{ + // Clean first the current recognizers in QGManager + QGestureRecognizer::unregisterRecognizer(Qt::PanGesture); + + // v-- Qt singleton QGManager initialization + + // Mimic QGestureManager: register both default and "platform" recognizers + // (this is done in windows when QT_NO_NATIVE_GESTURES is not defined) + PanRecognizer *def = new PanRecognizer(PanRecognizer::Default); + QGestureRecognizer::registerRecognizer(def); + PanRecognizer *plt = new PanRecognizer(PanRecognizer::Platform); + QGestureRecognizer::registerRecognizer(plt); + qDebug () << "register: default =" << def << "; platform =" << plt; + + // ^-- Qt singleton QGManager initialization + + // Here, application code would start + + // Create QGV (has a QAScrollArea, which uses Qt::PanGesture) + QMainWindow *w = new QMainWindow; + QGraphicsView *v = new QGraphicsView(); + w->setCentralWidget(v); + + // Unregister Qt recognizers + QGestureRecognizer::unregisterRecognizer(Qt::PanGesture); + + // Register a custom Pan recognizer + //QGestureRecognizer::registerRecognizer(new PanRecognizer(PanRecognizer::Custom)); + + w->show(); + QTest::qWaitForWindowShown(w); + delete w; +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" |