diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-05-09 16:25:58 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@jollamobile.com> | 2014-05-10 11:53:47 +0200 |
commit | 66646dd8c37adb488a79ab274b2396a649674e6d (patch) | |
tree | b0f5ac752a52cec3de1d47692e09295197622dcd /tests/auto/quick/qquickwindow | |
parent | da15ea0f3b5805db657f13060c21efa78f10cde2 (diff) | |
parent | d82a17b929dd88fe76258b0f801beaa1b2ee343e (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
.qmake.conf
src/plugins/accessible/quick/quick.pro
src/quick/items/qquickpincharea.cpp
src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
src/quick/scenegraph/qsgthreadedrenderloop.cpp
Manually adjusted for TestHTTPServer constructor change:
tests/auto/quick/qquickimage/tst_qquickimage.cpp
Change-Id: I5e58a7c08ea92d6fc5e3bce98571c54f7b2ce08f
Diffstat (limited to 'tests/auto/quick/qquickwindow')
-rw-r--r-- | tests/auto/quick/qquickwindow/data/active.qml | 2 | ||||
-rw-r--r-- | tests/auto/quick/qquickwindow/data/windoworder.qml | 42 | ||||
-rw-r--r-- | tests/auto/quick/qquickwindow/qquickwindow.pro | 3 | ||||
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 93 |
4 files changed, 135 insertions, 5 deletions
diff --git a/tests/auto/quick/qquickwindow/data/active.qml b/tests/auto/quick/qquickwindow/data/active.qml index af0b7edeb2..4d47225b4e 100644 --- a/tests/auto/quick/qquickwindow/data/active.qml +++ b/tests/auto/quick/qquickwindow/data/active.qml @@ -14,7 +14,6 @@ Window { anchors.fill: parent; onPressed: window2.requestActivate(); } - Component.onCompleted: window2.show(); } Window { @@ -22,6 +21,7 @@ Window { objectName: "window2"; color: "#FF0000"; width: 100; height: 100; + visible: true Item { width: 100; height: 100; } diff --git a/tests/auto/quick/qquickwindow/data/windoworder.qml b/tests/auto/quick/qquickwindow/data/windoworder.qml new file mode 100644 index 0000000000..33aea95694 --- /dev/null +++ b/tests/auto/quick/qquickwindow/data/windoworder.qml @@ -0,0 +1,42 @@ +import QtQuick 2.1 +import QtQuick.Window 2.1 + +Window { + id: window1; + objectName: "window1"; + width: 100; height: 100; + visible: true + color: "blue" + property alias win2: window2 + property alias win3: window3 + property alias win4: window4 + property alias win5: window5 + Window { + id: window2; + objectName: "window2"; + width: 100; height: 100; + visible: true + color: "green" + Window { + id: window3; + objectName: "window3"; + width: 100; height: 100; + visible: true + } + + Window { //Is invisible by default + id: window4 + objectName: "window4"; + height: 200 + width: 200 + color: "black" + Window { + id: window5 + objectName: "window5"; + height: 200 + width: 200 + visible: true + } + } + } +} diff --git a/tests/auto/quick/qquickwindow/qquickwindow.pro b/tests/auto/quick/qquickwindow/qquickwindow.pro index 2d1d62c135..e95b7dbb10 100644 --- a/tests/auto/quick/qquickwindow/qquickwindow.pro +++ b/tests/auto/quick/qquickwindow/qquickwindow.pro @@ -15,6 +15,7 @@ OTHER_FILES += \ data/active.qml \ data/AnimationsWhileHidden.qml \ data/Headless.qml \ - data/showHideAnimate.qml + data/showHideAnimate.qml \ + data/windoworder.qml DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index de4067b6e5..a2e2980223 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -343,6 +343,8 @@ private slots: void requestActivate(); + void testWindowVisibilityOrder(); + void blockClosing(); void crashWhenHoverItemDeleted(); @@ -1132,6 +1134,43 @@ void tst_qquickwindow::animationsWhileHidden() QTRY_VERIFY(window->isVisible()); } +// When running on native Nvidia graphics cards on linux, the +// distance field glyph pixels have a measurable, but not visible +// pixel error. Use a custom compare function to avoid +// +// This was GT-216 with the ubuntu "nvidia-319" driver package. +// llvmpipe does not show the same issue. +// +bool compareImages(const QImage &ia, const QImage &ib) +{ + if (ia.size() != ib.size()) + qDebug() << "images are of different size" << ia.size() << ib.size(); + Q_ASSERT(ia.size() == ib.size()); + Q_ASSERT(ia.format() == ib.format()); + + int w = ia.width(); + int h = ia.height(); + const int tolerance = 5; + for (int y=0; y<h; ++y) { + const uint *as= (const uint *) ia.constScanLine(y); + const uint *bs= (const uint *) ib.constScanLine(y); + for (int x=0; x<w; ++x) { + uint a = as[x]; + uint b = bs[x]; + + // No tolerance for error in the alpha. + if ((a & 0xff000000) != (b & 0xff000000)) + return false; + if (qAbs(qRed(a) - qRed(b)) > tolerance) + return false; + if (qAbs(qRed(a) - qRed(b)) > tolerance) + return false; + if (qAbs(qRed(a) - qRed(b)) > tolerance) + return false; + } + } + return true; +} void tst_qquickwindow::headless() { @@ -1179,8 +1218,7 @@ void tst_qquickwindow::headless() // Verify that the visual output is the same QImage newContent = window->grabWindow(); - - QCOMPARE(originalContent, newContent); + QVERIFY(compareImages(newContent, originalContent)); } void tst_qquickwindow::noUpdateWhenNothingChanges() @@ -1600,7 +1638,8 @@ void tst_qquickwindow::requestActivate() QVERIFY(windows.at(0)->objectName() == "window2"); window1->show(); - window1->requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(windows.at(0))); //We wait till window 2 comes up + window1->requestActivate(); // and then transfer the focus to window1 QTRY_VERIFY(QGuiApplication::focusWindow() == window1); QVERIFY(window1->isActive() == true); @@ -1626,6 +1665,54 @@ void tst_qquickwindow::requestActivate() QTRY_VERIFY(QGuiApplication::focusWindow() == windows.at(0)); QVERIFY(windows.at(0)->isActive()); + delete window1; +} + +void tst_qquickwindow::testWindowVisibilityOrder() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("windoworder.qml")); + QQuickWindow *window1 = qobject_cast<QQuickWindow *>(component.create()); + QQuickWindow *window2 = window1->property("win2").value<QQuickWindow*>(); + QQuickWindow *window3 = window1->property("win3").value<QQuickWindow*>(); + QQuickWindow *window4 = window1->property("win4").value<QQuickWindow*>(); + QQuickWindow *window5 = window1->property("win5").value<QQuickWindow*>(); + QVERIFY(window1); + QVERIFY(window2); + QVERIFY(window3); + + QTest::qWaitForWindowExposed(window3); + + QWindowList windows = QGuiApplication::topLevelWindows(); + QTRY_COMPARE(windows.size(), 5); + + QVERIFY(window3 == QGuiApplication::focusWindow()); + QVERIFY(window1->isActive()); + QVERIFY(window2->isActive()); + QVERIFY(window3->isActive()); + + //Test if window4 is shown 2 seconds after the application startup + //with window4 visible window5 (transient child) should also become visible + QVERIFY(!window4->isVisible()); + QVERIFY(!window5->isVisible()); + + window4->setVisible(true); + + QTest::qWaitForWindowExposed(window5); + QVERIFY(window4->isVisible()); + QVERIFY(window5->isVisible()); + window4->hide(); + window5->hide(); + + window3->hide(); +#if defined(Q_OS_OSX) + QEXPECT_FAIL("","Focus is not transferred to transient parent on window close (QTBUG-33423)", Continue); +#endif + QTRY_COMPARE(window2 == QGuiApplication::focusWindow(), true); + + window2->hide(); + QTRY_COMPARE(window1 == QGuiApplication::focusWindow(), true); } void tst_qquickwindow::blockClosing() |