aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcomponent
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@pelagicore.com>2015-06-17 16:38:47 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-23 17:31:51 +0000
commit1b4f94c8fe0452cc053907fea2ad8be3930df8ce (patch)
tree3c65361cdeb08ce764979b8e35604f4a84c8f909 /tests/auto/qml/qqmlcomponent
parentfcbefee383ccff2a6485acc120631123e30b41dd (diff)
Force completion of asynchronously loaded components.
[ChangeLog][QtQuick][QQmlComponent] Synchronously complete the loading of a Asynchronous QQmlComponent, if a PreferSynchronous QQmlComponent is created for the same url (given that this url does support synchronous loading). Change-Id: I3291d0569a69bac2aeb4815f1068a426ef2707ef Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests/auto/qml/qqmlcomponent')
-rw-r--r--tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
index bb159d5931..4c1f827915 100644
--- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
+++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
@@ -110,6 +110,7 @@ private slots:
void qmlCreateParentReference();
void async();
void asyncHierarchy();
+ void asyncForceSync();
void componentUrlCanonicalization();
void onDestructionLookup();
void onDestructionCount();
@@ -371,6 +372,35 @@ void tst_qqmlcomponent::asyncHierarchy()
delete root;
}
+void tst_qqmlcomponent::asyncForceSync()
+{
+ {
+ // 1) make sure that HTTP URLs cannot be completed synchronously
+ TestHTTPServer server;
+ QVERIFY2(server.listen(), qPrintable(server.errorString()));
+ server.serveDirectory(dataDirectory());
+
+ // ensure that the item hierarchy is compiled correctly.
+ QQmlComponent component(&engine);
+ component.loadUrl(server.url("/TestComponent.2.qml"), QQmlComponent::Asynchronous);
+ QCOMPARE(component.status(), QQmlComponent::Loading);
+ QQmlComponent component2(&engine, server.url("/TestComponent.2.qml"), QQmlComponent::PreferSynchronous);
+ QCOMPARE(component2.status(), QQmlComponent::Loading);
+ }
+ {
+ // 2) make sure that file:// URL can be completed synchronously
+
+ // ensure that the item hierarchy is compiled correctly.
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("/TestComponent.2.qml"), QQmlComponent::Asynchronous);
+ QCOMPARE(component.status(), QQmlComponent::Loading);
+ QQmlComponent component2(&engine, testFileUrl("/TestComponent.2.qml"), QQmlComponent::PreferSynchronous);
+ QCOMPARE(component2.status(), QQmlComponent::Ready);
+ QCOMPARE(component.status(), QQmlComponent::Loading);
+ QTRY_COMPARE_WITH_TIMEOUT(component.status(), QQmlComponent::Ready, 0);
+ }
+}
+
void tst_qqmlcomponent::componentUrlCanonicalization()
{
// ensure that url canonicalization succeeds so that type information