aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-02-02 09:50:10 +0100
committerLiang Qi <liang.qi@qt.io>2018-02-02 09:50:10 +0100
commit2e65f6c2a5d84f4369245cabdc03eca4c19851f0 (patch)
treeae662f1aca8dc42d4fbb309681c3051d6201ceb6 /tests/auto/quick
parenta8cff469b6f9055f084c31514481d08c11b5303b (diff)
parent6958308c09ceda855a30c5a2d491f078c5104071 (diff)
Merge remote-tracking branch 'origin/5.9' into 5.10
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/qquickloader/data/itemLoaderItemWindow.qml27
-rw-r--r--tests/auto/quick/qquickloader/data/itemLoaderWindow.qml22
-rw-r--r--tests/auto/quick/qquickloader/tst_qquickloader.cpp86
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp12
4 files changed, 145 insertions, 2 deletions
diff --git a/tests/auto/quick/qquickloader/data/itemLoaderItemWindow.qml b/tests/auto/quick/qquickloader/data/itemLoaderItemWindow.qml
new file mode 100644
index 0000000000..d4c5daecab
--- /dev/null
+++ b/tests/auto/quick/qquickloader/data/itemLoaderItemWindow.qml
@@ -0,0 +1,27 @@
+import QtQuick 2.0
+import QtQuick.Window 2.1
+
+Item {
+ width: 400
+ height: 400
+ objectName: "root Item"
+
+ Loader {
+ sourceComponent: Rectangle {
+ objectName: "yellow rectangle"
+ x: 50; y: 50; width: 300; height: 300
+ color: "yellow"
+ Window {
+ objectName: "red transient Window"
+ width: 100
+ height: 100
+ visible: true // makes it harder, because it wants to become visible before root has a window
+ color: "red"
+ title: "red"
+ flags: Qt.Dialog
+ onVisibilityChanged: console.log("visibility " + visibility)
+ onVisibleChanged: console.log("visible " + visible)
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickloader/data/itemLoaderWindow.qml b/tests/auto/quick/qquickloader/data/itemLoaderWindow.qml
new file mode 100644
index 0000000000..69421448e0
--- /dev/null
+++ b/tests/auto/quick/qquickloader/data/itemLoaderWindow.qml
@@ -0,0 +1,22 @@
+import QtQuick 2.0
+import QtQuick.Window 2.1
+
+Item {
+ width: 400
+ height: 400
+ objectName: "root Item"
+
+ Loader {
+ sourceComponent: Window {
+ objectName: "red transient Window"
+ width: 100
+ height: 100
+ visible: true // makes it harder, because it wants to become visible before root has a window
+ color: "red"
+ title: "red"
+ flags: Qt.Dialog
+ onVisibilityChanged: console.log("visibility " + visibility)
+ onVisibleChanged: console.log("visible " + visible)
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
index e557b592ee..65493f52e2 100644
--- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp
+++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
@@ -32,11 +32,15 @@
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
#include <QtQml/qqmlincubator.h>
+#include <QtQuick/qquickview.h>
#include <private/qquickloader_p.h>
+#include <private/qquickwindowmodule_p.h>
#include "testhttpserver.h"
#include "../../shared/util.h"
#include "../shared/geometrytestutil.h"
+Q_LOGGING_CATEGORY(lcTests, "qt.quick.tests")
+
class SlowComponent : public QQmlComponent
{
Q_OBJECT
@@ -112,6 +116,8 @@ private slots:
void parented();
void sizeBound();
void QTBUG_30183();
+ void transientWindow();
+ void nestedTransientWindow();
void sourceComponentGarbageCollection();
@@ -1159,6 +1165,86 @@ void tst_QQuickLoader::QTBUG_30183()
QCOMPARE(rect->height(), 120.0);
}
+void tst_QQuickLoader::transientWindow() // QTBUG-52944
+{
+ QQuickView view;
+ view.setSource(testFileUrl("itemLoaderWindow.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(view.rootObject());
+ QVERIFY(root);
+ QQuickLoader *loader = root->findChild<QQuickLoader *>();
+ QVERIFY(loader);
+ QTRY_COMPARE(loader->status(), QQuickLoader::Ready);
+ QQuickWindowQmlImpl *loadedWindow = qobject_cast<QQuickWindowQmlImpl *>(loader->item());
+ QVERIFY(loadedWindow);
+ QCOMPARE(loadedWindow->visibility(), QWindow::Hidden);
+
+ QElapsedTimer timer;
+ qint64 viewVisibleTime = -1;
+ qint64 loadedWindowVisibleTime = -1;
+ connect(&view, &QWindow::visibleChanged,
+ [&viewVisibleTime, &timer]() { viewVisibleTime = timer.elapsed(); } );
+ connect(loadedWindow, &QQuickWindowQmlImpl::visibilityChanged,
+ [&loadedWindowVisibleTime, &timer]() { loadedWindowVisibleTime = timer.elapsed(); } );
+ timer.start();
+ view.show();
+
+ QTest::qWaitForWindowExposed(&view);
+ QTRY_VERIFY(loadedWindowVisibleTime >= 0);
+ QVERIFY(viewVisibleTime >= 0);
+
+ // now that we're sure they are both visible, which one became visible first?
+ qCDebug(lcTests) << "transient Window became visible" << (loadedWindowVisibleTime - viewVisibleTime) << "ms after the root Item";
+ QVERIFY((loadedWindowVisibleTime - viewVisibleTime) >= 0);
+
+ QWindowList windows = QGuiApplication::topLevelWindows();
+ QTRY_COMPARE(windows.size(), 2);
+
+ // TODO Ideally we would now close the outer window and make sure the transient window closes too.
+ // It works during manual testing because of QWindowPrivate::maybeQuitOnLastWindowClosed()
+ // but quitting an autotest doesn't make sense.
+}
+
+void tst_QQuickLoader::nestedTransientWindow() // QTBUG-52944
+{
+ QQuickView view;
+ view.setSource(testFileUrl("itemLoaderItemWindow.qml"));
+ QQuickItem *root = qobject_cast<QQuickItem*>(view.rootObject());
+ QVERIFY(root);
+ QQuickLoader *loader = root->findChild<QQuickLoader *>();
+ QVERIFY(loader);
+ QTRY_COMPARE(loader->status(), QQuickLoader::Ready);
+ QQuickItem *loadedItem = qobject_cast<QQuickItem *>(loader->item());
+ QVERIFY(loadedItem);
+ QQuickWindowQmlImpl *loadedWindow = loadedItem->findChild<QQuickWindowQmlImpl *>();
+ QVERIFY(loadedWindow);
+ QCOMPARE(loadedWindow->visibility(), QWindow::Hidden);
+
+ QElapsedTimer timer;
+ qint64 viewVisibleTime = -1;
+ qint64 loadedWindowVisibleTime = -1;
+ connect(&view, &QWindow::visibleChanged,
+ [&viewVisibleTime, &timer]() { viewVisibleTime = timer.elapsed(); } );
+ connect(loadedWindow, &QQuickWindowQmlImpl::visibilityChanged,
+ [&loadedWindowVisibleTime, &timer]() { loadedWindowVisibleTime = timer.elapsed(); } );
+ timer.start();
+ view.show();
+
+ QTest::qWaitForWindowExposed(&view);
+ QTRY_VERIFY(loadedWindowVisibleTime >= 0);
+ QVERIFY(viewVisibleTime >= 0);
+
+ // now that we're sure they are both visible, which one became visible first?
+ qCDebug(lcTests) << "transient Window became visible" << (loadedWindowVisibleTime - viewVisibleTime) << "ms after the root Item";
+ QVERIFY((loadedWindowVisibleTime - viewVisibleTime) >= 0);
+
+ QWindowList windows = QGuiApplication::topLevelWindows();
+ QTRY_COMPARE(windows.size(), 2);
+
+ // TODO Ideally we would now close the outer window and make sure the transient window closes too.
+ // It works during manual testing because of QWindowPrivate::maybeQuitOnLastWindowClosed()
+ // but quitting an autotest doesn't make sense.
+}
+
void tst_QQuickLoader::sourceComponentGarbageCollection()
{
QQmlEngine engine;
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 9b526f80c5..5b2c585a92 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -6143,9 +6143,17 @@ void tst_qquicktextinput::keypress_inputMask_withValidator_data()
KeyList keys;
// inserting '1111.11' then two backspaces
keys << Qt::Key_Home << "1111.11" << Qt::Key_Backspace << Qt::Key_Backspace;
- QTest::newRow("backspaceWithRegExp") << QString("9999.99;_") << 0.0 << 0.0 << 0
+ QTest::newRow("backspaceWithRegExp") << QString("9999;_") << 0.0 << 0.0 << 0
<< QString("/^[-]?((\\.\\d+)|(\\d+(\\.\\d+)?))$/")
- << keys << QString("1111.") << QString("1111.__");
+ << keys << QString("11") << QString("11__");
+ }
+ {
+ KeyList keys;
+ // inserting '99' - QTBUG-64616
+ keys << Qt::Key_Home << "99";
+ QTest::newRow("invalidTextWithRegExp") << QString("X9;_") << 0.0 << 0.0 << 0
+ << QString("/[+-][0+9]/")
+ << keys << QString("") << QString("__");
}
}