diff options
Diffstat (limited to 'tests/auto/widgets/kernel')
16 files changed, 409 insertions, 125 deletions
diff --git a/tests/auto/widgets/kernel/qapplication/BLACKLIST b/tests/auto/widgets/kernel/qapplication/BLACKLIST index ca0efdff8a..d7de7bf16e 100644 --- a/tests/auto/widgets/kernel/qapplication/BLACKLIST +++ b/tests/auto/widgets/kernel/qapplication/BLACKLIST @@ -1,3 +1,4 @@ [touchEventPropagation] # QTBUG-66745 opensuse +opensuse-leap diff --git a/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro b/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro index a10ff71b05..442bf33b61 100644 --- a/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro +++ b/tests/auto/widgets/kernel/qapplication/desktopsettingsaware/desktopsettingsaware.pro @@ -1,6 +1,14 @@ QT += widgets -CONFIG -= app_bundle debug_and_release_target +CONFIG -= app_bundle -DESTDIR = ./ +debug_and_release { + CONFIG(debug, debug|release) { + TARGET = ../../debug/desktopsettingsaware_helper + } else { + TARGET = ../../release/desktopsettingsaware_helper + } +} else { + TARGET = ../desktopsettingsaware_helper +} SOURCES += main.cpp diff --git a/tests/auto/widgets/kernel/qapplication/modal/modal.pro b/tests/auto/widgets/kernel/qapplication/modal/modal.pro index a34871d2aa..e832d90821 100644 --- a/tests/auto/widgets/kernel/qapplication/modal/modal.pro +++ b/tests/auto/widgets/kernel/qapplication/modal/modal.pro @@ -1,7 +1,15 @@ QT += widgets SOURCES += main.cpp \ base.cpp -DESTDIR = ./ -CONFIG -= app_bundle debug_and_release_target +debug_and_release { + CONFIG(debug, debug|release) { + TARGET = ../../debug/modal_helper + } else { + TARGET = ../../release/modal_helper + } +} else { + TARGET = ../modal_helper +} +CONFIG -= app_bundle HEADERS += base.h diff --git a/tests/auto/widgets/kernel/qapplication/test/test.pro b/tests/auto/widgets/kernel/qapplication/test/test.pro index 41aad02a1b..8ade4d8364 100644 --- a/tests/auto/widgets/kernel/qapplication/test/test.pro +++ b/tests/auto/widgets/kernel/qapplication/test/test.pro @@ -1,18 +1,28 @@ CONFIG += testcase -CONFIG -= debug_and_release_target QT += widgets widgets-private testlib QT += core-private gui-private SOURCES += ../tst_qapplication.cpp -TARGET = ../tst_qapplication -TESTDATA = ../test/test.pro ../tmp/README +builtin_testdata: DEFINES += BUILTIN_TESTDATA -!android:!winrt { - SUBPROGRAMS = desktopsettingsaware modal - win32:SUBPROGRAMS += wincmdline +TESTDATA = ../test/test.pro ../tmp/README ../modal - for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}/$${file}" -} +!android:!winrt: SUBPROGRAMS = desktopsettingsaware modal +debug_and_release { + CONFIG(debug, debug|release) { + TARGET = ../../debug/tst_qapplication + !android:!winrt: TEST_HELPER_INSTALLS = ../debug/helper + for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../debug/$${file}" + } else { + TARGET = ../../release/tst_qapplication + !android:!winrt: TEST_HELPER_INSTALLS = ../release/helper + for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../release/$${file}" + } +} else { + TARGET = ../tst_qapplication + !android:!winrt: TEST_HELPER_INSTALLS = ../helper + for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}" +} diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index bd4dc3d6f3..d2a244b762 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -96,7 +96,6 @@ public: tst_QApplication(); private slots: - void initTestCase(); void cleanup(); void sendEventsOnProcessEvents(); // this must be the first test void staticSetup(); @@ -187,13 +186,6 @@ public: } }; -void tst_QApplication::initTestCase() -{ - // chdir to our testdata path and execute helper apps relative to that. - const QString testdataDir = QFileInfo(QFINDTESTDATA("desktopsettingsaware")).absolutePath(); - QVERIFY2(QDir::setCurrent(testdataDir), qPrintable("Could not chdir to " + testdataDir)); -} - void tst_QApplication::sendEventsOnProcessEvents() { int argc = 0; @@ -277,6 +269,9 @@ public: void tst_QApplication::alert() { +#ifdef Q_OS_WINRT + QSKIP("WinRT does not support more than 1 native widget at the same time"); +#endif int argc = 0; QApplication app(argc, 0); app.alert(0, 0); @@ -820,6 +815,9 @@ public: void tst_QApplication::closeAllWindows() { +#ifdef Q_OS_WINRT + QSKIP("PromptOnCloseWidget does not work on WinRT - QTBUG-68297"); +#endif int argc = 0; QApplication app(argc, 0); @@ -888,7 +886,11 @@ bool isPathListIncluded(const QStringList &l, const QStringList &r) #define QT_TST_QAPP_DEBUG void tst_QApplication::libraryPaths() { +#ifndef BUILTIN_TESTDATA const QString testDir = QFileInfo(QFINDTESTDATA("test/test.pro")).absolutePath(); +#else + const QString testDir = QFileInfo(QFINDTESTDATA("test.pro")).absolutePath(); +#endif QVERIFY(!testDir.isEmpty()); { QApplication::setLibraryPaths(QStringList() << testDir); @@ -921,6 +923,9 @@ void tst_QApplication::libraryPaths() QStringList expected = QSet<QString>::fromList((QStringList() << installPathPlugins << appDirPath)).toList(); expected.sort(); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "On WinRT PluginsPath is outside of sandbox. QTBUG-68297", Abort); +#endif QVERIFY2(isPathListIncluded(actual, expected), qPrintable("actual:\n - " + actual.join("\n - ") + "\nexpected:\n - " + expected.join("\n - "))); @@ -1040,6 +1045,9 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2() << QDir(app.applicationDirPath()).canonicalPath() << QDir(QDir::fromNativeSeparators(QString::fromLatin1(validPath))).canonicalPath(); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "On WinRT PluginsPath is outside of sandbox. QTBUG-68297", Abort); +#endif QVERIFY2(isPathListIncluded(app.libraryPaths(), expected), qPrintable("actual:\n - " + app.libraryPaths().join("\n - ") + "\nexpected:\n - " + expected.join("\n - "))); @@ -1434,20 +1442,10 @@ void tst_QApplication::testDeleteLaterProcessEvents() void tst_QApplication::desktopSettingsAware() { #if QT_CONFIG(process) - QString path; - { - // We need an application object for QFINDTESTDATA to work - // properly in all cases. - int argc = 0; - QCoreApplication app(argc, 0); - path = QFINDTESTDATA("desktopsettingsaware/"); - } - QVERIFY2(!path.isEmpty(), "Cannot locate desktopsettingsaware helper application"); - path += "desktopsettingsaware"; QProcess testProcess; - testProcess.start(path); + testProcess.start("desktopsettingsaware_helper"); QVERIFY2(testProcess.waitForStarted(), - qPrintable(QString::fromLatin1("Cannot start '%1': %2").arg(path, testProcess.errorString()))); + qPrintable(QString::fromLatin1("Cannot start 'desktopsettingsaware_helper': %1").arg(testProcess.errorString()))); QVERIFY(testProcess.waitForFinished(10000)); QCOMPARE(int(testProcess.state()), int(QProcess::NotRunning)); QVERIFY(int(testProcess.error()) != int(QProcess::Crashed)); @@ -1744,6 +1742,9 @@ void tst_QApplication::focusMouseClick() QSpontaneKeyEvent::setSpontaneous(&ev); QVERIFY(ev.spontaneous()); qApp->notify(&w2, &ev); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Fails on WinRT - QTBUG-68297", Abort); +#endif QTRY_COMPARE(QApplication::focusWidget(), &w2); // now back to tab focus and click again (it already had focus) -> focus should stay @@ -2112,23 +2113,12 @@ void tst_QApplication::touchEventPropagation() void tst_QApplication::qtbug_12673() { - QString path; - { - // We need an application object for QFINDTESTDATA to work - // properly in all cases. - int argc = 0; - QCoreApplication app(argc, 0); - path = QFINDTESTDATA("modal/"); - } - QVERIFY2(!path.isEmpty(), "Cannot locate modal helper application"); - path += "modal"; - #if QT_CONFIG(process) QProcess testProcess; QStringList arguments; - testProcess.start(path, arguments); + testProcess.start("modal_helper", arguments); QVERIFY2(testProcess.waitForStarted(), - qPrintable(QString::fromLatin1("Cannot start '%1': %2").arg(path, testProcess.errorString()))); + qPrintable(QString::fromLatin1("Cannot start 'modal_helper': %1").arg(testProcess.errorString()))); QVERIFY(testProcess.waitForFinished(20000)); QCOMPARE(testProcess.exitStatus(), QProcess::NormalExit); #else diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp index 8314dbedf5..b2650d1f32 100644 --- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp +++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp @@ -56,6 +56,7 @@ private slots: void taskQTBUG_40609_addingWidgetToItsOwnLayout(); void taskQTBUG_40609_addingLayoutToItself(); void replaceWidget(); + void indexOf(); }; class CustomLayoutStyle : public QProxyStyle @@ -512,5 +513,24 @@ void tst_QBoxLayout::replaceWidget() QCOMPARE(boxLayout->indexOf(replaceTo), 1); } +void tst_QBoxLayout::indexOf() +{ + QWidget w; + auto outer = new QVBoxLayout(&w); + auto inner = new QHBoxLayout(); + outer->addLayout(inner); + auto widget1 = new QWidget(); + QWidget widget2; + inner->addWidget(widget1); + + QCOMPARE(inner->indexOf(widget1), 0); + QCOMPARE(inner->indexOf(&widget2), -1); + QCOMPARE(outer->indexOf(widget1), -1); + QCOMPARE(outer->indexOf(&widget2), -1); + QCOMPARE(outer->indexOf(outer), -1); + QCOMPARE(outer->indexOf(inner), 0); + QCOMPARE(inner->indexOf(inner->itemAt(0)), 0); +} + QTEST_MAIN(tst_QBoxLayout) #include "tst_qboxlayout.moc" diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index 162da61584..cff3dad35e 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -273,6 +273,9 @@ void tst_QFormLayout::wrapping() w.setWindowTitle(QTest::currentTestFunction()); w.show(); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "setFixedWidth does not work on WinRT", Abort); +#endif QCOMPARE(le->geometry().y() > lbl->geometry().y(), true); //TODO: additional tests covering different wrapping cases diff --git a/tests/auto/widgets/kernel/qgesturerecognizer/BLACKLIST b/tests/auto/widgets/kernel/qgesturerecognizer/BLACKLIST deleted file mode 100644 index 7f55c2dae0..0000000000 --- a/tests/auto/widgets/kernel/qgesturerecognizer/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[panGesture:Two finger] -xcb diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp index 300a8878ba..936f581d89 100644 --- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp +++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp @@ -337,7 +337,7 @@ void tst_QLayout::adjustSizeShouldMakeSureLayoutIsActivated() void tst_QLayout::testRetainSizeWhenHidden() { -#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED) +#if (defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)) || defined(Q_OS_WINRT) QSKIP("Test does not work on platforms which default to showMaximized()"); #endif diff --git a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp index eb3264be53..89bb946be9 100644 --- a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp +++ b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp @@ -116,8 +116,16 @@ void tst_QSizePolicy::constExpr() { Q_CONSTEXPR QSizePolicy sp = QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); Q_UNUSED(sp); } { Q_CONSTEXPR QSizePolicy sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding, QSizePolicy::DefaultType); Q_CONSTEXPR QSizePolicy tp = sp.transposed(); Q_UNUSED(tp); } - { Q_RELAXED_CONSTEXPR auto sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::CheckBox); - Q_RELAXED_CONSTEXPR auto tp = sp.transposed(); Q_UNUSED(tp); } + { + // QTBUG-69983: For ControlType != QSizePolicy::DefaultType, qCountTrailingZeroBits() + // is used, which MSVC 15.8.1 does not consider constexpr due to built-ins +# if defined(QT_HAS_CONSTEXPR_BUILTINS) && (!defined(Q_CC_MSVC) || _MSC_VER < 1915) + Q_RELAXED_CONSTEXPR auto sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::CheckBox); +# else + Q_CONSTEXPR auto sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding, QSizePolicy::DefaultType); +# endif + Q_RELAXED_CONSTEXPR auto tp = sp.transposed(); Q_UNUSED(tp); + } #else QSKIP("QSizePolicy cannot be constexpr with this version of the compiler."); #endif diff --git a/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp b/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp index e02573f8e8..3d609d0b9c 100644 --- a/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp +++ b/tests/auto/widgets/kernel/qtooltip/tst_qtooltip.cpp @@ -46,6 +46,7 @@ private slots: void whatsThis(); void setPalette(); void qtbug64550_stylesheet(); + void dontCrashOutsideScreenGeometry(); }; void tst_QToolTip::init() @@ -218,5 +219,11 @@ void tst_QToolTip::qtbug64550_stylesheet() msgSizeTooSmall(toolTipSize, boundingRect.size()).constData()); } +void tst_QToolTip::dontCrashOutsideScreenGeometry() { + QToolTip::showText(QPoint(-10000, -10000), "tip outside monitor", nullptr); + QTRY_VERIFY(QToolTip::isVisible()); + QToolTip::hideText(); +} + QTEST_MAIN(tst_QToolTip) #include "tst_qtooltip.moc" diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index 6cebce26e8..1f68308bbe 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -2,35 +2,27 @@ [normalGeometry] ubuntu-16.04 [saveRestoreGeometry] -ubuntu-16.04 +xcb b2qt -# QTBUG-66708 -opensuse [restoreVersion1Geometry] -xcb osx [updateWhileMinimized] ubuntu-16.04 +ubuntu-18.04 rhel-7.4 osx [focusProxyAndInputMethods] linux -[showMaximized] -osx -[setGeometry] -osx [raise] # QTBUG-68175 opensuse -osx -[resizeEvent] -osx +opensuse-leap [setWindowGeometry] osx [windowMoveResize] osx [childEvents] -osx +osx ci [renderInvisible] osx [optimizedResizeMove] @@ -40,29 +32,11 @@ osx [render_systemClip] osx [showMinimizedKeepsFocus] -osx-10.11 ci osx-10.12 ci -[moveWindowInShowEvent:1] -osx -[moveWindowInShowEvent:2] -osx -[taskQTBUG_4055_sendSyntheticEnterLeave] -osx -[syntheticEnterLeave] -osx +osx-10.13 ci [maskedUpdate] -osx -opensuse-42.3 -[hideOpaqueChildWhileHidden] -osx -[resizeStaticContentsChildWidget_QTBUG35282] -osx -[lower] -osx -[setClearAndResizeMask] -osx -[setToolTip] -osx +opensuse +opensuse-leap [moveInResizeEvent] ubuntu-16.04 [moveChild:right] diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 6a049aedf1..360e6986f6 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -188,7 +188,8 @@ private slots: void reverseTabOrder(); void tabOrderWithProxy(); void tabOrderWithCompoundWidgets(); -#ifdef Q_OS_WIN + void tabOrderNoChange(); +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) void activation(); #endif void reparent(); @@ -416,8 +417,7 @@ private: bool tst_QWidget::ensureScreenSize(int width, int height) { - QSize available; - available = QDesktopWidget().availableGeometry().size(); + const QSize available = QGuiApplication::primaryScreen()->availableGeometry().size(); return (available.width() >= width && available.height() >= height); } @@ -1426,7 +1426,7 @@ void tst_QWidget::mapFromAndTo() subWindow2->setGeometry(75, 75, 100, 100); subSubWindow->setGeometry(10, 10, 10, 10); -#if !defined(Q_OS_QNX) +#if !defined(Q_OS_QNX) && !defined(Q_OS_WINRT) //update visibility if (windowMinimized) { if (!windowHidden) { @@ -1931,7 +1931,35 @@ void tst_QWidget::tabOrderWithCompoundWidgets() QVERIFY(lastEdit->hasFocus()); } -#ifdef Q_OS_WIN +static QVector<QWidget*> getFocusChain(QWidget *start, bool bForward) +{ + QVector<QWidget*> ret; + QWidget *cur = start; + do { + ret += cur; + auto widgetPrivate = static_cast<QWidgetPrivate *>(qt_widget_private(cur)); + cur = bForward ? widgetPrivate->focus_next : widgetPrivate->focus_prev; + } while (cur != start); + return ret; +} + +void tst_QWidget::tabOrderNoChange() +{ + QWidget w; + auto *verticalLayout = new QVBoxLayout(&w); + auto *tabWidget = new QTabWidget(&w); + auto *tv = new QTreeView(tabWidget); + tabWidget->addTab(tv, QStringLiteral("Tab 1")); + verticalLayout->addWidget(tabWidget); + + const auto focusChainForward = getFocusChain(&w, true); + const auto focusChainBackward = getFocusChain(&w, false); + QWidget::setTabOrder(tabWidget, tv); + QCOMPARE(focusChainForward, getFocusChain(&w, true)); + QCOMPARE(focusChainBackward, getFocusChain(&w, false)); +} + +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) void tst_QWidget::activation() { Q_CHECK_PAINTEVENTS @@ -1976,7 +2004,8 @@ void tst_QWidget::windowState() QPoint pos; QSize size = m_testWidgetSize; if (QGuiApplicationPrivate::platformIntegration()->defaultWindowState(Qt::Widget) - == Qt::WindowFullScreen) { + == Qt::WindowFullScreen + || m_platform == QStringLiteral("winrt")) { size = QGuiApplication::primaryScreen()->size(); } else { pos = QPoint(10, 10); @@ -2181,8 +2210,8 @@ void tst_QWidget::showFullScreen() QSKIP("QTBUG-52974"); #endif - if (m_platform == QStringLiteral("wayland")) - QSKIP("Wayland: This fails. Figure out why."); + if (m_platform == QStringLiteral("winrt")) + QSKIP("WinRT: This fails. QTBUG-68297"); QWidget plain; QHBoxLayout *layout; QWidget layouted; @@ -2304,6 +2333,8 @@ void tst_QWidget::resizeEvent() wTopLevel.resize(200, 200); wTopLevel.show(); QVERIFY(QTest::qWaitForWindowExposed(&wTopLevel)); + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT does not support resize", Abort); QCOMPARE (wTopLevel.m_resizeEventCount, 1); // initial resize event before paint for toplevels wTopLevel.hide(); QSize safeSize(640,480); @@ -2319,6 +2350,12 @@ void tst_QWidget::resizeEvent() void tst_QWidget::showMinimized() { + if (m_platform == QStringLiteral("wayland")) { + QSKIP("Wayland: Neither xdg_shell, wl_shell or ivi_application support " + "letting a client know whether it's minimized. So on these shells " + "Qt Wayland will always report that it's unmimized."); + } + QWidget plain; plain.move(100, 100); plain.resize(200, 200); @@ -2327,6 +2364,9 @@ void tst_QWidget::showMinimized() plain.showMinimized(); QVERIFY(plain.isMinimized()); QVERIFY(plain.isVisible()); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Winrt does not support move and resize", Abort); +#endif QCOMPARE(plain.pos(), pos); plain.showNormal(); @@ -2478,11 +2518,15 @@ void tst_QWidget::showMinimizedKeepsFocus() #ifdef Q_OS_OSX if (!macHasAccessToWindowsServer()) QEXPECT_FAIL("", "When not having WindowServer access, we lose focus.", Continue); +#elif defined(Q_OS_WINRT) + QEXPECT_FAIL("", "Winrt fails here - QTBUG-68297", Continue); #endif QTRY_COMPARE(window.focusWidget(), firstchild); #ifdef Q_OS_OSX if (!macHasAccessToWindowsServer()) QEXPECT_FAIL("", "When not having WindowServer access, we lose focus.", Continue); +#elif defined(Q_OS_WINRT) + QEXPECT_FAIL("", "Winrt fails here - QTBUG-68297", Continue); #endif QTRY_COMPARE(qApp->focusWidget(), firstchild); } @@ -2513,6 +2557,9 @@ void tst_QWidget::reparent() parent.show(); childTLW.show(); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "WinRT does not support more than 1 top level widget", Abort); +#endif QVERIFY(QTest::qWaitForWindowExposed(&parent)); parent.move(parentPosition); @@ -2610,6 +2657,8 @@ void tst_QWidget::normalGeometry() if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); + else if (m_platform == QStringLiteral("winrt")) + QSKIP("WinRT: This fails. Figure out why - QTBUG-68297."); QWidget parent; parent.setWindowTitle("NormalGeometry parent"); QWidget *child = new QWidget(&parent); @@ -2719,12 +2768,14 @@ void tst_QWidget::setGeometry() tlw.setGeometry(tr); child.setGeometry(cr); tlw.showNormal(); + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT does not support setGeometry", Abort); QTRY_COMPARE(tlw.geometry().size(), tr.size()); QCOMPARE(child.geometry(), cr); tlw.setParent(0, Qt::Window|Qt::FramelessWindowHint); tr = QRect(0,0,100,100); - tr.moveTopLeft(QApplication::desktop()->availableGeometry().topLeft()); + tr.moveTopLeft(QGuiApplication::primaryScreen()->availableGeometry().topLeft()); tlw.setGeometry(tr); QCOMPARE(tlw.geometry(), tr); tlw.showNormal(); @@ -3198,6 +3249,8 @@ void tst_QWidget::saveRestoreGeometry() QVERIFY(QTest::qWaitForWindowExposed(&widget)); QApplication::processEvents(); + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT does not support move/resize", Abort); QTRY_COMPARE(widget.pos(), position); QCOMPARE(widget.size(), size); savedGeometry = widget.saveGeometry(); @@ -3338,6 +3391,7 @@ void tst_QWidget::restoreVersion1Geometry() QFETCH(QString, fileName); QFETCH(uint, expectedWindowState); QFETCH(QPoint, expectedPosition); + Q_UNUSED(expectedPosition); QFETCH(QSize, expectedSize); QFETCH(QRect, expectedNormalGeometry); @@ -3357,28 +3411,28 @@ void tst_QWidget::restoreVersion1Geometry() QCOMPARE(uint(widget.windowState() & WindowStateMask), expectedWindowState); if (expectedWindowState == Qt::WindowNoState) { - QCOMPARE(widget.pos(), expectedPosition); + QTRY_COMPARE(widget.geometry(), expectedNormalGeometry); QCOMPARE(widget.size(), expectedSize); } + widget.showNormal(); QVERIFY(QTest::qWaitForWindowExposed(&widget)); QTest::qWait(100); + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT does not support restoreGeometry", Abort); + if (expectedWindowState == Qt::WindowNoState) { - QTRY_COMPARE(widget.pos(), expectedPosition); QTRY_COMPARE(widget.size(), expectedSize); + QCOMPARE(widget.geometry(), expectedNormalGeometry); } widget.showNormal(); QTest::qWait(10); - if (expectedWindowState != Qt::WindowNoState) { - // restoring from maximized or fullscreen, we can only restore to the normal geometry - QTRY_COMPARE(widget.geometry(), expectedNormalGeometry); - } else { - QTRY_COMPARE(widget.pos(), expectedPosition); - QTRY_COMPARE(widget.size(), expectedSize); - } + QTRY_COMPARE(widget.geometry(), expectedNormalGeometry); + if (expectedWindowState == Qt::WindowNoState) + QCOMPARE(widget.size(), expectedSize); #if 0 // Code for saving a new geometry*.dat files @@ -3413,6 +3467,8 @@ void tst_QWidget::widgetAt() QSKIP("Wayland: This fails. Figure out why."); if (m_platform == QStringLiteral("offscreen")) QSKIP("Platform offscreen does not support lower()/raise() or WindowMasks"); + if (m_platform == QStringLiteral("winrt")) + QSKIP("WinRT does not support more than 1 top level widget"); Q_CHECK_PAINTEVENTS @@ -3714,6 +3770,8 @@ void tst_QWidget::optimizedResizeMove() staticWidget.gotPaintEvent = false; staticWidget.move(staticWidget.pos() + QPoint(10, 10)); QTest::qWait(20); + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT does not support move/resize", Abort); QCOMPARE(staticWidget.gotPaintEvent, false); staticWidget.gotPaintEvent = false; @@ -3798,9 +3856,10 @@ void tst_QWidget::optimizedResize_topLevel() // a native function call works (it basically has to go through // WM_RESIZE in QApplication). This is a corner case, though. // See task 243708 - const QRect frame = topLevel.frameGeometry(); - MoveWindow(winHandleOf(&topLevel), frame.x(), frame.y(), - frame.width() + 10, frame.height() + 10, + RECT rect; + GetWindowRect(winHandleOf(&topLevel), &rect); + MoveWindow(winHandleOf(&topLevel), rect.left, rect.top, + rect.right - rect.left + 10, rect.bottom - rect.top + 10, true); QTest::qWait(100); #endif @@ -3812,6 +3871,8 @@ void tst_QWidget::optimizedResize_topLevel() QTRY_VERIFY(topLevel.gotPaintEvent); if (m_platform == QStringLiteral("xcb") || m_platform == QStringLiteral("offscreen")) QSKIP("QTBUG-26424"); + else if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT does not support move/resize", Abort); QCOMPARE(topLevel.partial, true); QCOMPARE(topLevel.paintedRegion, expectedUpdateRegion); } @@ -3860,7 +3921,7 @@ void tst_QWidget::setMinimumSize() QSize nonDefaultSize = defaultSize + QSize(5,5); w.setMinimumSize(nonDefaultSize); w.showNormal(); - QVERIFY(QTest::qWaitForWindowActive(&w)); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QVERIFY2(w.height() >= nonDefaultSize.height(), msgComparisonFailed(w.height(), ">=", nonDefaultSize.height())); QVERIFY2(w.width() >= nonDefaultSize.width(), @@ -3915,6 +3976,8 @@ void tst_QWidget::setFixedSize() QVERIFY(QTest::qWaitForWindowActive(&w)); if (m_platform == QStringLiteral("xcb")) QSKIP("QTBUG-26424"); + else if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT does not support move/resize", Abort); QCOMPARE(w.size(), defaultSize + QSize(150,150)); } @@ -4115,6 +4178,8 @@ void tst_QWidget::transientParent() void tst_QWidget::showNativeChild() { + if (m_platform == QStringLiteral("winrt")) + QSKIP("WinRT does not support setGeometry"); QWidget topLevel; topLevel.setGeometry(QRect(m_availableTopLeft + QPoint(100, 100), m_testWidgetSize)); topLevel.setWindowTitle(__FUNCTION__); @@ -4297,6 +4362,8 @@ void tst_QWidget::update() // widgets are transparent by default, so both should get repaints { + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT does not support setGeometry", Abort); QApplication::processEvents(); QApplication::processEvents(); QCOMPARE(child.numPaintEvents, 1); @@ -4518,8 +4585,9 @@ void tst_QWidget::scroll() { if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); - const int w = qMin(500, qApp->desktop()->availableGeometry().width() / 2); - const int h = qMin(500, qApp->desktop()->availableGeometry().height() / 2); + QScreen *screen = QGuiApplication::primaryScreen(); + const int w = qMin(500, screen->availableGeometry().width() / 2); + const int h = qMin(500, screen->availableGeometry().height() / 2); UpdateWidget updateWidget; updateWidget.resize(w, h); @@ -4536,6 +4604,8 @@ void tst_QWidget::scroll() qApp->processEvents(); QRegion dirty(QRect(0, 0, w, 10)); dirty += QRegion(QRect(0, 10, 10, h - 10)); + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT does not support move/resize", Abort); QTRY_COMPARE(updateWidget.paintedRegion, dirty); } @@ -4647,7 +4717,7 @@ void tst_QWidget::setWindowGeometry_data() QList<QList<QRect> > rects; const int width = m_testWidgetSize.width(); const int height = m_testWidgetSize.height(); - const QRect availableAdjusted = QApplication::desktop()->availableGeometry().adjusted(100, 100, -100, -100); + const QRect availableAdjusted = QGuiApplication::primaryScreen()->availableGeometry().adjusted(100, 100, -100, -100); rects << (QList<QRect>() << QRect(m_availableTopLeft + QPoint(100, 100), m_testWidgetSize) << availableAdjusted @@ -4711,6 +4781,8 @@ void tst_QWidget::setWindowGeometry() { if (m_platform == QStringLiteral("xcb")) QSKIP("X11: Skip this test due to Window manager positioning issues."); + else if (m_platform == QStringLiteral("winrt")) + QSKIP("WinRT does not support setWindowGeometry"); QFETCH(QList<QRect>, rects); QFETCH(int, windowFlags); @@ -4877,6 +4949,8 @@ void tst_QWidget::windowMoveResize() QSKIP("X11: Skip this test due to Window manager positioning issues."); if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); + if (m_platform == QStringLiteral("winrt")) + QSKIP("WinRT does not support move/resize"); QFETCH(QList<QRect>, rects); QFETCH(int, windowFlags); @@ -5197,6 +5271,9 @@ void tst_QWidget::moveChild() QTRY_COMPARE(parent.r, QRegion(parent.rect()) - child.geometry()); QTRY_COMPARE(child.r, QRegion(child.rect())); + + if (m_platform == QStringLiteral("winrt")) + QSKIP("WinRT does not support setGeometry (and we cannot use QEXPECT_FAIL because of VERIFY_COLOR)"); VERIFY_COLOR(child, child.rect(), child.color); VERIFY_COLOR(parent, QRegion(parent.rect()) - child.geometry(), parent.color); @@ -5253,6 +5330,8 @@ void tst_QWidget::showAndMoveChild() child.move(desktopDimensions.width()/2, desktopDimensions.height()/2); qApp->processEvents(); + if (m_platform == QStringLiteral("winrt")) + QSKIP("WinRT does not support setGeometry (and we cannot use QEXPECT_FAIL because of VERIFY_COLOR)"); VERIFY_COLOR(child, child.rect(), Qt::blue); VERIFY_COLOR(parent, QRegion(parent.rect()) - child.geometry(), Qt::red); } @@ -5341,6 +5420,8 @@ void tst_QWidget::multipleToplevelFocusCheck() if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); + else if (m_platform == QStringLiteral("winrt")) + QSKIP("Winrt: Sometimes crashes in QTextLayout. - QTBUG-68297"); TopLevelFocusCheck w1; TopLevelFocusCheck w2; @@ -5499,6 +5580,8 @@ void tst_QWidget::setFocus() testWidget->clearFocus(); child1.setFocus(); + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT fails here - QTBUG-68297", Abort); QVERIFY(!child1.hasFocus()); QCOMPARE(window.focusWidget(), &child1); QCOMPARE(QApplication::focusWidget(), nullptr); @@ -6185,8 +6268,8 @@ QByteArray EventRecorder::msgEventListMismatch(const EventList &expected, const void tst_QWidget::childEvents() { - if (m_platform == QStringLiteral("wayland")) - QSKIP("Wayland: This fails. Figure out why."); + if (m_platform == QStringLiteral("winrt")) + QSKIP("WinRT: This fails. QTBUG-68297."); EventRecorder::EventList expected; // Move away the cursor; otherwise it might result in an enter event if it's @@ -6582,6 +6665,8 @@ void tst_QWidget::renderInvisible() { if (m_platform == QStringLiteral("xcb")) QSKIP("QTBUG-26424"); + if (m_platform == QStringLiteral("winrt")) + QSKIP("WinRT: This fails. QTBUG-68297."); QScopedPointer<QCalendarWidget> calendar(new QCalendarWidget); calendar->move(m_availableTopLeft + QPoint(100, 100)); @@ -7430,7 +7515,7 @@ void tst_QWidget::moveWindowInShowEvent_data() QTest::addColumn<QPoint>("initial"); QTest::addColumn<QPoint>("position"); - QPoint p = QApplication::desktop()->availableGeometry().topLeft(); + QPoint p = QGuiApplication::primaryScreen()->availableGeometry().topLeft(); QTest::newRow("1") << p << (p + QPoint(10, 10)); QTest::newRow("2") << (p + QPoint(10,10)) << p; @@ -7455,7 +7540,8 @@ void tst_QWidget::moveWindowInShowEvent() }; MoveWindowInShowEventWidget widget; - widget.resize(QSize(qApp->desktop()->availableGeometry().size() / 3).expandedTo(QSize(1, 1))); + QScreen *screen = QGuiApplication::primaryScreen(); + widget.resize(QSize(screen->availableGeometry().size() / 3).expandedTo(QSize(1, 1))); // move to this position in showEvent() widget.position = position; @@ -7524,6 +7610,8 @@ void tst_QWidget::hideOpaqueChildWhileHidden() child.hide(); child2.hide(); + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort); QTRY_COMPARE(w.r, QRegion(child.geometry())); child.show(); @@ -7561,6 +7649,8 @@ void tst_QWidget::updateWhileMinimized() // Make sure update requests are discarded until the widget is shown again. widget.update(0, 0, 50, 50); QTest::qWait(10); + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort); QCOMPARE(widget.numPaintEvents, 0); // Restore window. @@ -8088,6 +8178,8 @@ void tst_QWidget::doubleRepaint() #if defined(Q_OS_QNX) QEXPECT_FAIL("", "Platform does not support showMinimized()", Continue); #endif + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort); QCOMPARE(widget.numPaintEvents, 0); widget.numPaintEvents = 0; @@ -8105,7 +8197,7 @@ void tst_QWidget::resizeInPaintEvent() window.resize(200, 200); window.show(); qApp->setActiveWindow(&window); - QVERIFY(QTest::qWaitForWindowActive(&window)); + QVERIFY(QTest::qWaitForWindowExposed(&window)); QTRY_VERIFY(widget.numPaintEvents > 0); widget.reset(); @@ -8217,6 +8309,8 @@ void tst_QWidget::setMaskInResizeEvent() QRegion expectedParentUpdate(0, 0, 100, 10); // Old testWidget area. expectedParentUpdate += testWidget.geometry(); // New testWidget area. + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort); QTRY_COMPARE(w.paintedRegion, expectedParentUpdate); QTRY_COMPARE(testWidget.paintedRegion, testWidget.mask()); @@ -8645,7 +8739,7 @@ void tst_QWidget::translucentWidget() ColorRedWidget label; label.setFixedSize(16,16); label.setAttribute(Qt::WA_TranslucentBackground); - const QPoint labelPos = qApp->desktop()->availableGeometry().topLeft(); + const QPoint labelPos = QGuiApplication::primaryScreen()->availableGeometry().topLeft(); label.move(labelPos); label.show(); QVERIFY(QTest::qWaitForWindowExposed(&label)); @@ -8661,6 +8755,8 @@ void tst_QWidget::translucentWidget() widgetSnapshot = label.grab(QRect(QPoint(0, 0), label.size())); const QImage actual = widgetSnapshot.toImage().convertToFormat(QImage::Format_RGB32); const QImage expected = pm.toImage().scaled(label.devicePixelRatioF() * pm.size()); + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort); QCOMPARE(actual.size(),expected.size()); QCOMPARE(actual,expected); } @@ -8704,7 +8800,7 @@ void tst_QWidget::setClearAndResizeMask() centerOnScreen(&topLevel); topLevel.show(); qApp->setActiveWindow(&topLevel); - QVERIFY(QTest::qWaitForWindowActive(&topLevel)); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); QTRY_VERIFY(topLevel.numPaintEvents > 0); topLevel.reset(); @@ -9104,7 +9200,7 @@ void tst_QWidget::syntheticEnterLeave() void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() { if (m_platform == QStringLiteral("wayland")) - QSKIP("Wayland: This fails. Figure out why."); + QSKIP("Wayland: Clients can't set cursor position on wayland."); class SELParent : public QWidget { public: @@ -9122,7 +9218,8 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() void mouseMoveEvent(QMouseEvent *event) { QCOMPARE(event->button(), Qt::NoButton); - QCOMPARE(event->buttons(), Qt::MouseButtons(Qt::NoButton)); + QCOMPARE(event->buttons(), QApplication::mouseButtons()); + QCOMPARE(event->modifiers(), QApplication::keyboardModifiers()); ++numMouseMoveEvents; } void reset() { numEnterEvents = numMouseMoveEvents = 0; } @@ -9156,11 +9253,11 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() child.setMouseTracking(true); child.show(); - // Make sure the child gets enter event and mouse move event. + // Make sure the child gets enter event. // Note that we verify event->button() and event->buttons() // in SELChild::mouseMoveEvent(). QTRY_COMPARE(child.numEnterEvents, 1); - QCOMPARE(child.numMouseMoveEvents, 1); + QCOMPARE(child.numMouseMoveEvents, 0); // Sending synthetic enter/leave trough the parent's mousePressEvent handler. parent.child = &child; @@ -9169,12 +9266,21 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() child.reset(); QTest::mouseClick(&parent, Qt::LeftButton); - // Make sure the child gets enter event and one mouse move event. + // Make sure the child gets enter event. QTRY_COMPARE(child.numEnterEvents, 1); - QCOMPARE(child.numMouseMoveEvents, 1); + QCOMPARE(child.numMouseMoveEvents, 0); child.hide(); child.reset(); + QTest::keyPress(&parent, Qt::Key_Shift); + QTest::mouseClick(&parent, Qt::LeftButton); + + // Make sure the child gets enter event + QTRY_COMPARE(child.numEnterEvents, 1); + QCOMPARE(child.numMouseMoveEvents, 0); + QTest::keyRelease(&child, Qt::Key_Shift); + child.hide(); + child.reset(); child.setMouseTracking(false); QTest::mouseClick(&parent, Qt::LeftButton); @@ -9351,6 +9457,8 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779() correct.fill(Qt::green); const QPixmap mainPixmap = grabFromWidget(&main, QRect(QPoint(0, 0), QSize(-1, -1))); + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort); QTRY_COMPARE(mainPixmap.toImage().convertToFormat(QImage::Format_RGB32), correct.toImage().convertToFormat(QImage::Format_RGB32)); #ifndef QT_NO_CURSOR @@ -9442,6 +9550,8 @@ void tst_QWidget::activateWindow() qApp->processEvents(); QTRY_VERIFY(mainwindow->isActiveWindow()); + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort); QTRY_VERIFY(!mainwindow2->isActiveWindow()); } @@ -9960,9 +10070,6 @@ public: void tst_QWidget::touchEventSynthesizedMouseEvent() { - if (m_platform == QStringLiteral("wayland")) - QSKIP("Wayland: This fails. Figure out why."); - { // Simple case, we ignore the touch events, we get mouse events instead TouchMouseWidget widget; @@ -10544,7 +10651,7 @@ void tst_QWidget::keyboardModifiers() KeyboardWidget w; w.resize(300, 300); w.show(); - QVERIFY(QTest::qWaitForWindowActive(&w)); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QTest::mouseClick(&w, Qt::LeftButton, Qt::ControlModifier); QCOMPARE(w.m_eventCounter, 1); QCOMPARE(int(w.m_modifiers), int(Qt::ControlModifier)); @@ -10605,6 +10712,8 @@ void tst_QWidget::resizeStaticContentsChildWidget_QTBUG35282() widget.showNormal(); QVERIFY(QTest::qWaitForWindowExposed(&widget)); + if (m_platform == QStringLiteral("winrt")) + QEXPECT_FAIL("", "WinRT: This fails. QTBUG-68297.", Abort); QCOMPARE(childWidget.numPaintEvents, 0); childWidget.reset(); diff --git a/tests/auto/widgets/kernel/qwidget_window/BLACKLIST b/tests/auto/widgets/kernel/qwidget_window/BLACKLIST index d3bfaba433..c980325d9a 100644 --- a/tests/auto/widgets/kernel/qwidget_window/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget_window/BLACKLIST @@ -2,3 +2,6 @@ # QTBUG-66345 opensuse-42.3 ubuntu-16.04 +ubuntu-18.04 +[setWindowState] +ubuntu-18.04 diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index b143555b0d..f4da4c3e5f 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -44,6 +44,8 @@ #include <qmainwindow.h> #include <qtoolbar.h> #include <private/qwindow_p.h> +#include <private/qguiapplication_p.h> +#include <qpa/qplatformintegration.h> #include <QtTest/private/qtesthelpers_p.h> @@ -79,10 +81,12 @@ private slots: void tst_showWithoutActivating(); void tst_paintEventOnSecondShow(); + void tst_exposeObscuredMapped_QTBUG39220(); void tst_paintEventOnResize_QTBUG50796(); #if QT_CONFIG(draganddrop) void tst_dnd(); + void tst_dnd_events(); #endif void tst_qtbug35600(); @@ -156,6 +160,9 @@ void tst_QWidget_window::tst_move_show() QWidget w; w.move(100, 100); w.show(); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Winrt does not support move", Abort); +#endif QCOMPARE(w.pos(), QPoint(100, 100)); // QCoreApplication::processEvents(QEventLoop::AllEvents, 3000); } @@ -185,6 +192,9 @@ void tst_QWidget_window::tst_resize_show() QWidget w; w.resize(200, 200); w.show(); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Winrt does not support resize", Abort); +#endif QCOMPARE(w.size(), QSize(200, 200)); // QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); } @@ -370,6 +380,33 @@ void tst_QWidget_window::tst_paintEventOnSecondShow() QTRY_VERIFY(w.paintEventCount > 0); } +void tst_QWidget_window::tst_exposeObscuredMapped_QTBUG39220() +{ + const auto integration = QGuiApplicationPrivate::platformIntegration(); + if (!integration->hasCapability(QPlatformIntegration::MultipleWindows) + || !integration->hasCapability(QPlatformIntegration::NonFullScreenWindows) + || QGuiApplication::platformName() == QLatin1String("winrt")) { + QSKIP("The platform does not have the required capabilities"); + } + // QTBUG-39220: Fully obscured parent widgets may not receive expose + // events (as is the case for frameless, obscured parents on Windows). + // Ensure Qt::WA_Mapped is set so updating works. + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); + const QSize size = availableGeometry.size() / 6; + QWidget topLevel; + setFrameless(&topLevel); + topLevel.resize(size); + const QPoint sizeP(size.width(), size.height()); + topLevel.move(availableGeometry.center() - sizeP / 2); + QWidget *child = new QWidget(&topLevel); + child->resize(size); + child->move(0, 0); + QVERIFY(child->winId()); + topLevel.show(); + QTRY_VERIFY(child->testAttribute(Qt::WA_Mapped)); + QVERIFY(topLevel.testAttribute(Qt::WA_Mapped)); +} + void tst_QWidget_window::tst_paintEventOnResize_QTBUG50796() { const QRect availableGeo = QGuiApplication::primaryScreen()->availableGeometry(); @@ -416,6 +453,7 @@ static const char *expectedLogC[] = { "Event at 11,81 ignored", "Event at 11,101 ignored", "acceptingDropsWidget1::dragEnterEvent at 1,11 action=1 MIME_DATA_ADDRESS 'testmimetext'", + "acceptingDropsWidget1::dragMoveEvent at 1,11 action=1 MIME_DATA_ADDRESS 'testmimetext'", "Event at 11,121 accepted", "acceptingDropsWidget1::dragMoveEvent at 1,31 action=1 MIME_DATA_ADDRESS 'testmimetext'", "Event at 11,141 accepted", @@ -426,6 +464,7 @@ static const char *expectedLogC[] = { "acceptingDropsWidget1::dragLeaveEvent QDragLeaveEvent", "Event at 11,201 ignored", "acceptingDropsWidget2::dragEnterEvent at 1,11 action=1 MIME_DATA_ADDRESS 'testmimetext'", + "acceptingDropsWidget2::dragMoveEvent at 1,11 action=1 MIME_DATA_ADDRESS 'testmimetext'", "Event at 11,221 accepted", "acceptingDropsWidget2::dragMoveEvent at 1,31 action=1 MIME_DATA_ADDRESS 'testmimetext'", "Event at 11,241 accepted", @@ -591,6 +630,92 @@ void tst_QWidget_window::tst_dnd() QCOMPARE(log, expectedLog); } + +class DnDEventRecorder : public QWidget +{ + Q_OBJECT +public: + QString _dndEvents; + DnDEventRecorder() { setAcceptDrops(true); } + +protected: + void mousePressEvent(QMouseEvent *) + { + QMimeData *mimeData = new QMimeData; + mimeData->setData("application/x-dnditemdata", "some data"); + QDrag *drag = new QDrag(this); + drag->setMimeData(mimeData); + drag->exec(); + } + + void dragEnterEvent(QDragEnterEvent *e) + { + e->accept(); + _dndEvents.append(QStringLiteral("DragEnter ")); + } + void dragMoveEvent(QDragMoveEvent *e) + { + e->accept(); + _dndEvents.append(QStringLiteral("DragMove ")); + emit releaseMouseButton(); + } + void dragLeaveEvent(QDragLeaveEvent *e) + { + e->accept(); + _dndEvents.append(QStringLiteral("DragLeave ")); + } + void dropEvent(QDropEvent *e) + { + e->accept(); + _dndEvents.append(QStringLiteral("DropEvent ")); + } + +signals: + void releaseMouseButton(); +}; + +void tst_QWidget_window::tst_dnd_events() +{ + // Note: This test is somewhat a hack as testing DnD with qtestlib is not + // supported at the moment. The test verifies that we get an expected event + // sequence on dnd operation that does not move a mouse. This logic is implemented + // in QGuiApplication, so we have to go via QWindowSystemInterface API (QTest::mouse*). + const auto platformName = QGuiApplication::platformName().toLower(); + // The test is known to work with XCB and platforms that use the default dnd + // implementation QSimpleDrag (e.g. qnx). Running on XCB should be sufficient to + // catch regressions at cross platform code: QGuiApplication::processDrag/Leave(). + if (platformName != "xcb") + return; + + const QString expectedDndEvents = "DragEnter DragMove DropEvent DragEnter DragMove " + "DropEvent DragEnter DragMove DropEvent "; + DnDEventRecorder dndWidget; + dndWidget.setGeometry(100, 100, 200, 200); + dndWidget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&dndWidget)); + QVERIFY(QTest::qWaitForWindowActive(&dndWidget)); + + // ### FIXME - QTBUG-35117 ??? + auto targetCenter = QPoint(dndWidget.width(), dndWidget.height()) / 2; + auto targetCenterGlobal = dndWidget.mapToGlobal(targetCenter); + QCursor::setPos(targetCenterGlobal); + QVERIFY(QTest::qWaitFor([&]() { return QCursor::pos() == targetCenterGlobal; })); + QCoreApplication::processEvents(); // clear mouse events generated from cursor + + auto window = dndWidget.window()->windowHandle(); + + // Some dnd implementation rely on running internal event loops, so we have to use + // the following queued signal hack to simulate mouse clicks in the widget. + QObject::connect(&dndWidget, &DnDEventRecorder::releaseMouseButton, this, [=]() { + QTest::mouseRelease(window, Qt::LeftButton); + }, Qt::QueuedConnection); + + QTest::mousePress(window, Qt::LeftButton); + QTest::mousePress(window, Qt::LeftButton); + QTest::mousePress(window, Qt::LeftButton); + + QCOMPARE(dndWidget._dndEvents, expectedDndEvents); +} #endif void tst_QWidget_window::tst_qtbug35600() @@ -704,6 +829,9 @@ void tst_QWidget_window::tst_resize_count() ResizeWidget resize; resize.show(); QVERIFY(QTest::qWaitForWindowExposed(&resize)); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Winrt does not support resize", Abort); +#endif QCOMPARE(resize.resizeCount, 1); resize.resizeCount = 0; QSize size = resize.size(); @@ -901,6 +1029,11 @@ void tst_QWidget_window::setWindowState() w.setWindowState(state); QCOMPARE(w.windowState(), state); w.show(); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("0", "Winrt windows are maximized by default", Abort); + QEXPECT_FAIL("Qt::WindowMinimized", "Winrt windows are maximized by default", Abort); + QEXPECT_FAIL("Qt::WindowFullScreen", "Winrt windows are maximized by default", Abort); +#endif QCOMPARE(w.windowState(), state); QCOMPARE(w.windowHandle()->windowStates(), state); if (!(state & Qt::WindowMinimized)) diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp index c9c8e193b3..693a792f0a 100644 --- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp +++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp @@ -104,6 +104,9 @@ void tst_QWindowContainer::testShow() root.show(); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Fails on WinRT - QTBUG-68297", Abort); +#endif QVERIFY(QTest::qWaitForWindowExposed(window)); } @@ -140,6 +143,9 @@ void tst_QWindowContainer::testExposeObscure() container->show(); QVERIFY(QTest::qWaitForWindowExposed(container.data())); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Fails on WinRT - QTBUG-68297", Abort); +#endif QVERIFY(QTest::qWaitForWindowExposed(window)); QVERIFY(window->numberOfExposes > 0); @@ -255,6 +261,9 @@ void tst_QWindowContainer::testUnparentReparent() QTRY_VERIFY(!window->isVisible()); container->show(); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Fails on WinRT - QTBUG-68297", Abort); +#endif QVERIFY(QTest::qWaitForWindowExposed(window)); QTRY_VERIFY(window->isVisible()); @@ -359,6 +368,9 @@ void tst_QWindowContainer::testNativeContainerParent() root.show(); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "Fails on WinRT - QTBUG-68297", Abort); +#endif QVERIFY(QTest::qWaitForWindowExposed(window)); QTRY_COMPARE(window->parent(), container->windowHandle()); } |