diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-02-24 13:28:17 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-02-24 13:31:14 +0100 |
commit | 1fadc7292b66d4b3984bf5ef36c70b46b07a1c6b (patch) | |
tree | 7a54f6a2612dc469ddbc5afc2cc0010099b661fe /tests | |
parent | ea711d0f59d6272f14b61cb2fd3dc1ede2cc1eb6 (diff) | |
parent | d8e65d5756c937fc3d9be3e5c30b31914a437393 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
src/plugins/platforms/windows/qwindowsfontengine.cpp
src/plugins/platforms/windows/qwindowsnativeimage.cpp
tests/auto/gui/kernel/qwindow/BLACKLIST
tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
Change-Id: I649b32b260ce0ed2d6a5089021daa0d6a8db85f7
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/kernel/qwindow/BLACKLIST | 2 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 193 | ||||
-rw-r--r-- | tests/auto/widgets/dialogs/qfontdialog/BLACKLIST | 1 | ||||
-rw-r--r-- | tests/auto/widgets/itemviews/qtreeview/BLACKLIST | 2 | ||||
-rw-r--r-- | tests/auto/widgets/itemviews/qtreeview/qtreeview.pro | 2 | ||||
-rw-r--r-- | tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp | 51 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp | 5 | ||||
-rw-r--r-- | tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 109 |
8 files changed, 335 insertions, 30 deletions
diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST index bdd27b4ea6..0622ba30b7 100644 --- a/tests/auto/gui/kernel/qwindow/BLACKLIST +++ b/tests/auto/gui/kernel/qwindow/BLACKLIST @@ -8,3 +8,5 @@ ubuntu-14.04 ubuntu-14.04 [setVisible] ubuntu-14.04 +[modalWindowEnterEventOnHide_QTBUG35109] +ubuntu-14.04 diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 232571bc1c..892dc0899f 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -92,6 +92,9 @@ private slots: void modalWithChildWindow(); void modalWindowModallity(); void modalWindowPosition(); +#ifndef QT_NO_CURSOR + void modalWindowEnterEventOnHide_QTBUG35109(); +#endif void windowsTransientChildren(); void requestUpdate(); void initTestCase(); @@ -868,10 +871,24 @@ public: } } } + bool event(QEvent *e) { + switch (e->type()) { + case QEvent::Enter: + ++enterEventCount; + break; + case QEvent::Leave: + ++leaveEventCount; + break; + default: + break; + } + return QWindow::event(e); + } void resetCounters() { mousePressedCount = mouseReleasedCount = mouseMovedCount = mouseDoubleClickedCount = 0; mouseSequenceSignature = QString(); touchPressedCount = touchReleasedCount = touchMovedCount = 0; + enterEventCount = leaveEventCount = 0; } InputTestWindow() { @@ -889,6 +906,7 @@ public: QPointF mousePressScreenPos, mouseMoveScreenPos, mousePressLocalPos; int touchPressedCount, touchReleasedCount, touchMovedCount; QEvent::Type touchEventType; + int enterEventCount, leaveEventCount; bool ignoreMouse, ignoreTouch; @@ -1884,6 +1902,181 @@ void tst_QWindow::modalWindowPosition() QCOMPARE(window.geometry(), origGeo); } +#ifndef QT_NO_CURSOR +void tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109() +{ + if (QGuiApplication::platformName() == QLatin1String("cocoa")) + QSKIP("This test fails on OS X on CI"); + + const QPoint center = QGuiApplication::primaryScreen()->availableGeometry().center(); + + const int childOffset = 16; + const QPoint rootPos = center - QPoint(m_testWindowSize.width(), + m_testWindowSize.height())/2; + const QPoint modalPos = rootPos + QPoint(childOffset * 5, + childOffset * 5); + const QPoint cursorPos = rootPos - QPoint(80, 80); + + // Test whether tlw can receive the enter event + { + QCursor::setPos(cursorPos); + QCoreApplication::processEvents(); + + InputTestWindow root; + root.setTitle(__FUNCTION__); + root.setGeometry(QRect(rootPos, m_testWindowSize)); + root.show(); + QVERIFY(QTest::qWaitForWindowExposed(&root)); + root.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&root)); + + // Move the mouse over the root window, but not over the modal window. + QCursor::setPos(rootPos + QPoint(childOffset * 5 / 2, + childOffset * 5 / 2)); + + // Wait for the enter event. It must be delivered here, otherwise second + // compare can PASS because of this event even after "resetCounters()". + QTRY_COMPARE(root.enterEventCount, 1); + QTRY_COMPARE(root.leaveEventCount, 0); + + QWindow modal; + modal.setTitle(QLatin1String("Modal - ") + __FUNCTION__); + modal.setTransientParent(&root); + modal.resize(m_testWindowSize/2); + modal.setFramePosition(modalPos); + modal.setModality(Qt::ApplicationModal); + modal.show(); + QVERIFY(QTest::qWaitForWindowExposed(&modal)); + modal.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&modal)); + + QCoreApplication::processEvents(); + QTRY_COMPARE(root.leaveEventCount, 1); + + root.resetCounters(); + modal.close(); + + // Check for the enter event + QTRY_COMPARE(root.enterEventCount, 1); + } + + // Test whether child window can receive the enter event + { + QCursor::setPos(cursorPos); + QCoreApplication::processEvents(); + + QWindow root; + root.setTitle(__FUNCTION__); + root.setGeometry(QRect(rootPos, m_testWindowSize)); + + QWindow childLvl1; + childLvl1.setParent(&root); + childLvl1.setGeometry(childOffset, + childOffset, + m_testWindowSize.width() - childOffset, + m_testWindowSize.height() - childOffset); + + InputTestWindow childLvl2; + childLvl2.setParent(&childLvl1); + childLvl2.setGeometry(childOffset, + childOffset, + childLvl1.width() - childOffset, + childLvl1.height() - childOffset); + + root.show(); + childLvl1.show(); + childLvl2.show(); + + QVERIFY(QTest::qWaitForWindowExposed(&root)); + root.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&root)); + QVERIFY(childLvl1.isVisible()); + QVERIFY(childLvl2.isVisible()); + + // Move the mouse over the child window, but not over the modal window. + // Be sure that the value is almost left-top of second child window for + // checking proper position mapping. + QCursor::setPos(rootPos + QPoint(childOffset * 5 / 2, + childOffset * 5 / 2)); + + // Wait for the enter event. It must be delivered here, otherwise second + // compare can PASS because of this event even after "resetCounters()". + QTRY_COMPARE(childLvl2.enterEventCount, 1); + QTRY_COMPARE(childLvl2.leaveEventCount, 0); + + QWindow modal; + modal.setTitle(QLatin1String("Modal - ") + __FUNCTION__); + modal.setTransientParent(&root); + modal.resize(m_testWindowSize/2); + modal.setFramePosition(modalPos); + modal.setModality(Qt::ApplicationModal); + modal.show(); + QVERIFY(QTest::qWaitForWindowExposed(&modal)); + modal.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&modal)); + + QCoreApplication::processEvents(); + QTRY_COMPARE(childLvl2.leaveEventCount, 1); + + childLvl2.resetCounters(); + modal.close(); + + // Check for the enter event + QTRY_COMPARE(childLvl2.enterEventCount, 1); + } + + // Test whether tlw can receive the enter event if mouse is over the invisible child windnow + { + QCursor::setPos(cursorPos); + QCoreApplication::processEvents(); + + InputTestWindow root; + root.setTitle(__FUNCTION__); + root.setGeometry(QRect(rootPos, m_testWindowSize)); + + QWindow child; + child.setParent(&root); + child.setGeometry(QRect(QPoint(), m_testWindowSize)); + + root.show(); + + QVERIFY(QTest::qWaitForWindowExposed(&root)); + root.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&root)); + QVERIFY(!child.isVisible()); + + // Move the mouse over the child window, but not over the modal window. + QCursor::setPos(rootPos + QPoint(childOffset * 5 / 2, + childOffset * 5 / 2)); + + // Wait for the enter event. It must be delivered here, otherwise second + // compare can PASS because of this event even after "resetCounters()". + QTRY_COMPARE(root.enterEventCount, 1); + QTRY_COMPARE(root.leaveEventCount, 0); + + QWindow modal; + modal.setTitle(QLatin1String("Modal - ") + __FUNCTION__); + modal.setTransientParent(&root); + modal.resize(m_testWindowSize/2); + modal.setFramePosition(modalPos); + modal.setModality(Qt::ApplicationModal); + modal.show(); + QVERIFY(QTest::qWaitForWindowExposed(&modal)); + modal.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&modal)); + + QCoreApplication::processEvents(); + QTRY_COMPARE(root.leaveEventCount, 1); + + root.resetCounters(); + modal.close(); + + // Check for the enter event + QTRY_COMPARE(root.enterEventCount, 1); + } +} +#endif + static bool isNativeWindowVisible(const QWindow *window) { #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) diff --git a/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST b/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST index ae0f7bb868..5fd026537e 100644 --- a/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST +++ b/tests/auto/widgets/dialogs/qfontdialog/BLACKLIST @@ -4,3 +4,4 @@ rhel-7.1 [setFont] ubuntu-14.04 redhatenterpriselinuxworkstation-6.6 +rhel-7.1 diff --git a/tests/auto/widgets/itemviews/qtreeview/BLACKLIST b/tests/auto/widgets/itemviews/qtreeview/BLACKLIST new file mode 100644 index 0000000000..5eb80007c4 --- /dev/null +++ b/tests/auto/widgets/itemviews/qtreeview/BLACKLIST @@ -0,0 +1,2 @@ +[setSortingEnabledChild] +windows diff --git a/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro b/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro index e8406dab7b..3abd58e73d 100644 --- a/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro +++ b/tests/auto/widgets/itemviews/qtreeview/qtreeview.pro @@ -4,5 +4,3 @@ QT += widgets testlib QT += widgets-private gui-private core-private SOURCES += tst_qtreeview.cpp HEADERS += ../../../../shared/fakedirmodel.h - -win32: CONFIG += insignificant_test diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 137f18e23a..938c8a47ac 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -189,7 +189,8 @@ private slots: void hiddenItems(); void spanningItems(); void rowSizeHint(); - void setSortingEnabled(); + void setSortingEnabledTopLevel(); + void setSortingEnabledChild(); void headerHidden(); void indentation(); @@ -2501,33 +2502,31 @@ void tst_QTreeView::rowSizeHint() //From task 155449 (QTreeWidget has a large width for the first section when sorting //is turned on before items are added) -void tst_QTreeView::setSortingEnabled() + +void tst_QTreeView::setSortingEnabledTopLevel() { - //1st the treeview is a top-level - { - QTreeView view; - QStandardItemModel model(1,1); - view.setModel(&model); - const int size = view.header()->sectionSize(0); - view.setSortingEnabled(true); - model.setColumnCount(3); - //we test that changing the column count doesn't change the 1st column size - QCOMPARE(view.header()->sectionSize(0), size); - } + QTreeView view; + QStandardItemModel model(1,1); + view.setModel(&model); + const int size = view.header()->sectionSize(0); + view.setSortingEnabled(true); + model.setColumnCount(3); + //we test that changing the column count doesn't change the 1st column size + QCOMPARE(view.header()->sectionSize(0), size); +} - //then it is no more a top-level - { - QMainWindow win; - QTreeView view; - QStandardItemModel model(1,1); - view.setModel(&model); - win.setCentralWidget(&view); - const int size = view.header()->sectionSize(0); - view.setSortingEnabled(true); - model.setColumnCount(3); - //we test that changing the column count doesn't change the 1st column size - QCOMPARE(view.header()->sectionSize(0), size); - } +void tst_QTreeView::setSortingEnabledChild() +{ + QMainWindow win; + QTreeView view; + QStandardItemModel model(1,1); + view.setModel(&model); + win.setCentralWidget(&view); + const int size = view.header()->sectionSize(0); + view.setSortingEnabled(true); + model.setColumnCount(3); + //we test that changing the column count doesn't change the 1st column size + QCOMPARE(view.header()->sectionSize(0), size); } void tst_QTreeView::headerHidden() diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 69dd45e72f..607fc1625a 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -492,9 +492,10 @@ void tst_QMdiArea::subWindowActivated2() spy.clear(); mdiArea.show(); - QVERIFY(QTest::qWaitForWindowExposed(&mdiArea)); + QVERIFY(QTest::qWaitForWindowActive(&mdiArea)); QTRY_COMPARE(spy.count(), 1); - QCOMPARE(mdiArea.activeSubWindow(), activeSubWindow); + QVERIFY(mdiArea.currentSubWindow()); + QTRY_COMPARE(mdiArea.activeSubWindow(), activeSubWindow); spy.clear(); if (qGuiApp->styleHints()->showIsFullScreen()) diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 8ed781a023..17efc05f59 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -105,6 +105,9 @@ private slots: void QTBUG7411_submenus_activate(); void QTBUG30595_rtl_submenu(); void QTBUG20403_nested_popup_on_shortcut_trigger(); +#ifndef QT_NO_CURSOR + void QTBUG47515_widgetActionEnterLeave(); +#endif void QTBUG_10735_crashWithDialog(); #ifdef Q_OS_MAC void QTBUG_37933_ampersands_data(); @@ -1066,6 +1069,112 @@ void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger() QVERIFY(!subsub1.isVisible()); } +class MyWidget : public QWidget +{ +public: + MyWidget(QWidget *parent) : + QWidget(parent), + move(0), enter(0), leave(0) + { + setMinimumSize(100, 100); + setMouseTracking(true); + } + + bool event(QEvent *e) Q_DECL_OVERRIDE + { + switch (e->type()) { + case QEvent::MouseMove: + ++move; + break; + case QEvent::Enter: + ++enter; + break; + case QEvent::Leave: + ++leave; + break; + default: + break; + } + return QWidget::event(e); + } + + int move, enter, leave; +}; + +#ifndef QT_NO_CURSOR +void tst_QMenu::QTBUG47515_widgetActionEnterLeave() +{ + if (QGuiApplication::platformName() == QLatin1String("cocoa")) + QSKIP("This test fails on OS X on CI"); + + const QPoint center = QGuiApplication::primaryScreen()->availableGeometry().center(); + const QPoint cursorPos = center - QPoint(100, 100); + + QScopedPointer<QMenu> menu1(new QMenu("Menu1")); + QScopedPointer<QMenu> menu2(new QMenu("Menu2")); + + QWidgetAction *wA1 = new QWidgetAction(menu1.data()); + MyWidget *w1 = new MyWidget(menu1.data()); + wA1->setDefaultWidget(w1); + + QWidgetAction *wA2 = new QWidgetAction(menu2.data()); + MyWidget *w2 = new MyWidget(menu2.data()); + wA2->setDefaultWidget(w2); + + QAction *nextMenuAct = menu1->addMenu(menu2.data()); + + menu1->addAction(wA1); + menu2->addAction(wA2); + + // Root menu + { + QCursor::setPos(cursorPos); + QCoreApplication::processEvents(); + + menu1->popup(center); + QVERIFY(QTest::qWaitForWindowExposed(menu1.data())); + + QCursor::setPos(w1->mapToGlobal(w1->rect().center())); + QVERIFY(w1->isVisible()); + QTRY_COMPARE(w1->leave, 0); + QTRY_COMPARE(w1->enter, 1); + + // Check whether leave event is not delivered on mouse move + w1->move = 0; + QCursor::setPos(w1->mapToGlobal(w1->rect().center()) + QPoint(1, 1)); + QTRY_COMPARE(w1->move, 1); + QTRY_COMPARE(w1->leave, 0); + QTRY_COMPARE(w1->enter, 1); + + QCursor::setPos(cursorPos); + QTRY_COMPARE(w1->leave, 1); + QTRY_COMPARE(w1->enter, 1); + } + + // Submenu + { + menu1->setActiveAction(nextMenuAct); + QVERIFY(QTest::qWaitForWindowExposed(menu2.data())); + + QCursor::setPos(w2->mapToGlobal(w2->rect().center())); + QVERIFY(w2->isVisible()); + QTRY_COMPARE(w2->leave, 0); + QTRY_COMPARE(w2->enter, 1); + + // Check whether leave event is not delivered on mouse move + w2->move = 0; + QCursor::setPos(w2->mapToGlobal(w2->rect().center()) + QPoint(1, 1)); + QTRY_COMPARE(w2->move, 1); + QTRY_COMPARE(w2->leave, 0); + QTRY_COMPARE(w2->enter, 1); + + QCursor::setPos(cursorPos); + QTRY_COMPARE(w2->leave, 1); + QTRY_COMPARE(w2->enter, 1); + } +} +#endif // !QT_NO_CURSOR + class MyMenu : public QMenu { Q_OBJECT |