diff options
Diffstat (limited to 'tests/auto/widgets')
-rw-r--r-- | tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp | 89 | ||||
-rw-r--r-- | tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 48 |
2 files changed, 89 insertions, 48 deletions
diff --git a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp index 6528c24c1a..e6a0c5e86b 100644 --- a/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp +++ b/tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp @@ -50,7 +50,7 @@ QT_FORWARD_DECLARE_CLASS(QDialog) class DummyDialog : public QDialog { public: - DummyDialog(): QDialog(0, Qt::X11BypassWindowManagerHint) {} + DummyDialog(): QDialog() {} using QDialog::showExtension; }; @@ -60,10 +60,8 @@ class tst_QDialog : public QObject public: tst_QDialog(); -public slots: - void initTestCase(); - void cleanupTestCase(); private slots: + void cleanup(); void getSetCheck(); void showExtension_data(); void showExtension(); @@ -86,9 +84,6 @@ private slots: void transientParent_data(); void transientParent(); void dialogInGraphicsView(); - -private: - DummyDialog *testWidget; }; // Testing get/set functions @@ -144,25 +139,12 @@ private: }; tst_QDialog::tst_QDialog() - { } -void tst_QDialog::initTestCase() +void tst_QDialog::cleanup() { - // Create the test class - testWidget = new DummyDialog; - testWidget->resize(200,200); - testWidget->show(); - qApp->setActiveWindow(testWidget); -} - -void tst_QDialog::cleanupTestCase() -{ - if (testWidget) { - delete testWidget; - testWidget = 0; - } + QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void tst_QDialog::showExtension_data() @@ -185,44 +167,52 @@ void tst_QDialog::showExtension() QFETCH( QSize, extSize ); QFETCH( bool, horizontal ); - // set geometry of main dialog and extension widget - testWidget->setFixedSize( dlgSize ); - QWidget *ext = new QWidget( testWidget ); + DummyDialog testWidget; + testWidget.resize(200, 200); + testWidget.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1Char(':') + + QLatin1String(QTest::currentDataTag())); + testWidget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&testWidget)); + + testWidget.setFixedSize( dlgSize ); + QWidget *ext = new QWidget( &testWidget ); ext->setFixedSize( extSize ); - testWidget->setExtension( ext ); - testWidget->setOrientation( horizontal ? Qt::Horizontal : Qt::Vertical ); + testWidget.setExtension( ext ); + testWidget.setOrientation( horizontal ? Qt::Horizontal : Qt::Vertical ); - QCOMPARE( testWidget->size(), dlgSize ); - QPoint oldPosition = testWidget->pos(); + QCOMPARE( testWidget.size(), dlgSize ); + QPoint oldPosition = testWidget.pos(); // show - testWidget->showExtension( true ); + testWidget.showExtension( true ); // while ( testWidget->size() == dlgSize ) // qApp->processEvents(); - QTEST( testWidget->size(), "result" ); + QTEST( testWidget.size(), "result" ); - QCOMPARE(testWidget->pos(), oldPosition); + QCOMPARE(testWidget.pos(), oldPosition); // hide extension. back to old size ? - testWidget->showExtension( false ); - QCOMPARE( testWidget->size(), dlgSize ); + testWidget.showExtension( false ); + QCOMPARE( testWidget.size(), dlgSize ); - testWidget->setExtension( 0 ); + testWidget.setExtension( 0 ); } void tst_QDialog::defaultButtons() { - QLineEdit *lineEdit = new QLineEdit(testWidget); - QPushButton *push = new QPushButton("Button 1", testWidget); - QPushButton *pushTwo = new QPushButton("Button 2", testWidget); - QPushButton *pushThree = new QPushButton("Button 3", testWidget); + DummyDialog testWidget; + testWidget.resize(200, 200); + testWidget.setWindowTitle(QTest::currentTestFunction()); + QLineEdit *lineEdit = new QLineEdit(&testWidget); + QPushButton *push = new QPushButton("Button 1", &testWidget); + QPushButton *pushTwo = new QPushButton("Button 2", &testWidget); + QPushButton *pushThree = new QPushButton("Button 3", &testWidget); pushThree->setAutoDefault(false); - //we need to show the buttons. Otherwise they won't get the focus - push->show(); - pushTwo->show(); - pushThree->show(); + testWidget.show(); + QApplication::setActiveWindow(&testWidget); + QVERIFY(QTest::qWaitForWindowActive(&testWidget)); push->setDefault(true); QVERIFY(push->isDefault()); @@ -375,11 +365,15 @@ void tst_QDialog::showAsTool() #if defined(Q_OS_UNIX) QSKIP("Qt/X11: Skipped since activeWindow() is not respected by all window managers"); #endif - ToolDialog dialog(testWidget); - testWidget->activateWindow(); + DummyDialog testWidget; + testWidget.resize(200, 200); + testWidget.setWindowTitle(QTest::currentTestFunction()); + ToolDialog dialog(&testWidget); + testWidget.show(); + testWidget.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&testWidget)); dialog.exec(); - QTest::qWait(100); - if (testWidget->style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, testWidget)) { + if (testWidget.style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, &testWidget)) { QCOMPARE(dialog.wasActive(), true); } else { QCOMPARE(dialog.wasActive(), false); @@ -602,7 +596,6 @@ void tst_QDialog::transientParent_data() void tst_QDialog::transientParent() { QFETCH(bool, nativewidgets); - testWidget->hide(); QWidget topLevel; topLevel.resize(200, 200); topLevel.move(QGuiApplication::primaryScreen()->availableGeometry().center() - QPoint(100, 100)); diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 515ddf480f..ae48445363 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -442,6 +442,7 @@ private slots: void touchEventSynthesizedMouseEvent(); void touchUpdateOnNewTouch(); + void touchEventsForGesturePendingWidgets(); void styleSheetPropagation(); @@ -9783,6 +9784,7 @@ public: m_touchUpdateCount(0), m_touchEndCount(0), m_touchEventCount(0), + m_gestureEventCount(0), m_acceptTouch(false), m_mouseEventCount(0), m_acceptMouse(true) @@ -9820,6 +9822,9 @@ protected: else e->ignore(); return true; + case QEvent::Gesture: + ++m_gestureEventCount; + return true; case QEvent::MouseButtonPress: case QEvent::MouseMove: @@ -9842,6 +9847,7 @@ public: int m_touchUpdateCount; int m_touchEndCount; int m_touchEventCount; + int m_gestureEventCount; bool m_acceptTouch; int m_mouseEventCount; bool m_acceptMouse; @@ -9997,6 +10003,48 @@ void tst_QWidget::touchUpdateOnNewTouch() QCOMPARE(widget.m_touchEndCount, 1); } +void tst_QWidget::touchEventsForGesturePendingWidgets() +{ + QTouchDevice *device = new QTouchDevice; + device->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(device); + + TouchMouseWidget parent; + TouchMouseWidget child(&parent); + parent.grabGesture(Qt::TapAndHoldGesture); + parent.show(); + + QWindow* window = parent.windowHandle(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + QTest::qWait(500); // needed for QApplication::topLevelAt(), which is used by QGestureManager + QCOMPARE(child.m_touchEventCount, 0); + QCOMPARE(child.m_gestureEventCount, 0); + QCOMPARE(parent.m_touchEventCount, 0); + QCOMPARE(parent.m_gestureEventCount, 0); + QTest::touchEvent(window, device).press(0, QPoint(20, 20), window); + QCOMPARE(child.m_touchEventCount, 0); + QCOMPARE(child.m_gestureEventCount, 0); + QCOMPARE(parent.m_touchBeginCount, 1); // QTapAndHoldGestureRecognizer::create() sets Qt::WA_AcceptTouchEvents + QCOMPARE(parent.m_touchUpdateCount, 0); + QCOMPARE(parent.m_touchEndCount, 0); + QCOMPARE(parent.m_gestureEventCount, 0); + QTest::touchEvent(window, device).move(0, QPoint(25, 25), window); + QCOMPARE(child.m_touchEventCount, 0); + QCOMPARE(child.m_gestureEventCount, 0); + QCOMPARE(parent.m_touchBeginCount, 1); + QCOMPARE(parent.m_touchUpdateCount, 0); + QCOMPARE(parent.m_touchEndCount, 0); + QCOMPARE(parent.m_gestureEventCount, 0); + QTest::qWait(1000); + QTest::touchEvent(window, device).release(0, QPoint(25, 25), window); + QCOMPARE(child.m_touchEventCount, 0); + QCOMPARE(child.m_gestureEventCount, 0); + QCOMPARE(parent.m_touchBeginCount, 1); + QCOMPARE(parent.m_touchUpdateCount, 0); + QCOMPARE(parent.m_touchEndCount, 0); + QVERIFY(parent.m_gestureEventCount > 0); +} + void tst_QWidget::styleSheetPropagation() { QTableView tw; |