aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickloader
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-02-12 13:29:08 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2020-02-12 14:47:35 +0100
commit1a7ca47a7a92945e16006ddd00adea186535cdd5 (patch)
treea5029ce5c620ee525848da2daeb6a34c65c1518b /tests/auto/quick/qquickloader
parent70120c931faa0c6139354c75fcf8d39b77ec3b4a (diff)
QQuickLoader: store status
This allows us to emit the change signal only when the status has actually changed. Due to alignment restrictions, this does not even change the size of the class. Fixes: QTBUG-82002 Change-Id: I2192bf80e72b92108046780811c3acdab39af518 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickloader')
-rw-r--r--tests/auto/quick/qquickloader/data/statusChanged.qml16
-rw-r--r--tests/auto/quick/qquickloader/tst_qquickloader.cpp14
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickloader/data/statusChanged.qml b/tests/auto/quick/qquickloader/data/statusChanged.qml
new file mode 100644
index 0000000000..fe46bc7b24
--- /dev/null
+++ b/tests/auto/quick/qquickloader/data/statusChanged.qml
@@ -0,0 +1,16 @@
+import QtQuick 2.12
+import QtQuick.Window 2.12
+
+Window {
+ id: root
+ property int statusChangedCounter: 0
+ property alias status: loader.status
+ visible: true; width: 640; height: 480
+ Loader {
+ id: loader
+ anchors.fill: parent
+ asynchronous: true
+ source: "./RedRect.qml"
+ onStatusChanged: root.statusChangedCounter++
+ }
+}
diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
index d0a1a8a45b..7bd6f9466a 100644
--- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp
+++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
@@ -39,6 +39,7 @@
#include "testhttpserver.h"
#include "../../shared/util.h"
#include "../shared/geometrytestutil.h"
+#include <QQmlApplicationEngine>
Q_LOGGING_CATEGORY(lcTests, "qt.quick.tests")
@@ -128,6 +129,7 @@ private slots:
void rootContext();
void sourceURLKeepComponent();
+ void statusChangeOnlyEmittedOnce();
};
Q_DECLARE_METATYPE(QList<QQmlError>)
@@ -1446,6 +1448,18 @@ void tst_QQuickLoader::sourceURLKeepComponent()
}
+// QTBUG-82002
+void tst_QQuickLoader::statusChangeOnlyEmittedOnce()
+{
+ QQmlApplicationEngine engine;
+ auto url = testFileUrl("statusChanged.qml");
+ engine.load(url);
+ auto root = engine.rootObjects().at(0);
+ QVERIFY(root);
+ QTRY_COMPARE(QQuickLoader::Status(root->property("status").toInt()), QQuickLoader::Ready);
+ QCOMPARE(root->property("statusChangedCounter").toInt(), 2); // 1xLoading + 1xReady*/
+}
+
QTEST_MAIN(tst_QQuickLoader)
#include "tst_qquickloader.moc"