From: Matthew Vogt Date: Mon, 30 Jul 2012 01:10:28 +0000 (+1000) Subject: Stabilize tst_qquickloader test case X-Git-Tag: upstream/5.2.1~1356 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9a8f869ef0c5a7cbd7b7b77cdbdff213176cf8d7;p=platform%2Fupstream%2Fqtdeclarative.git Stabilize tst_qquickloader test case Ensure cases are not affected by timer events of incubation controllers created in previous cases. Change-Id: Ia633ed142242d000de5f497896a685ca2f26e143 Reviewed-by: Chris Adams --- diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index 99ae42b..ba5b672 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -56,10 +56,9 @@ class PeriodicIncubationController : public QObject, public QQmlIncubationController { public: - PeriodicIncubationController() { - incubated = false; - startTimer(16); - } + PeriodicIncubationController() : incubated(false) {} + + void start() { startTimer(20); } bool incubated; @@ -901,10 +900,11 @@ void tst_QQuickLoader::asynchronous() QFETCH(QUrl, qmlFile); QFETCH(QStringList, expectedWarnings); - if (!engine.incubationController()) - engine.setIncubationController(new PeriodicIncubationController); - PeriodicIncubationController *controller = static_cast(engine.incubationController()); - controller->incubated = false; + PeriodicIncubationController *controller = new PeriodicIncubationController; + QQmlIncubationController *previous = engine.incubationController(); + engine.setIncubationController(controller); + delete previous; + QQmlComponent component(&engine, testFileUrl("asynchronous.qml")); QQuickItem *root = qobject_cast(component.create()); QVERIFY(root); @@ -923,6 +923,8 @@ void tst_QQuickLoader::asynchronous() if (expectedWarnings.isEmpty()) { QCOMPARE(loader->status(), QQuickLoader::Loading); + + controller->start(); QVERIFY(!controller->incubated); // asynchronous compilation means not immediately compiled/incubating. QTRY_VERIFY(controller->incubated); // but should start incubating once compilation is complete. QTRY_VERIFY(loader->item()); @@ -938,8 +940,11 @@ void tst_QQuickLoader::asynchronous() void tst_QQuickLoader::asynchronous_clear() { - if (!engine.incubationController()) - engine.setIncubationController(new PeriodicIncubationController); + PeriodicIncubationController *controller = new PeriodicIncubationController; + QQmlIncubationController *previous = engine.incubationController(); + engine.setIncubationController(controller); + delete previous; + QQmlComponent component(&engine, testFileUrl("asynchronous.qml")); QQuickItem *root = qobject_cast(component.create()); QVERIFY(root); @@ -952,6 +957,7 @@ void tst_QQuickLoader::asynchronous_clear() QMetaObject::invokeMethod(root, "loadComponent"); QVERIFY(!loader->item()); + controller->start(); QCOMPARE(loader->status(), QQuickLoader::Loading); QTRY_COMPARE(engine.incubationController()->incubatingObjectCount(), 1); @@ -983,10 +989,11 @@ void tst_QQuickLoader::asynchronous_clear() void tst_QQuickLoader::simultaneousSyncAsync() { - if (!engine.incubationController()) - engine.setIncubationController(new PeriodicIncubationController); - PeriodicIncubationController *controller = static_cast(engine.incubationController()); - controller->incubated = false; + PeriodicIncubationController *controller = new PeriodicIncubationController; + QQmlIncubationController *previous = engine.incubationController(); + engine.setIncubationController(controller); + delete previous; + QQmlComponent component(&engine, testFileUrl("simultaneous.qml")); QQuickItem *root = qobject_cast(component.create()); QVERIFY(root); @@ -1002,6 +1009,7 @@ void tst_QQuickLoader::simultaneousSyncAsync() QVERIFY(!asyncLoader->item()); QVERIFY(syncLoader->item()); + controller->start(); QCOMPARE(asyncLoader->status(), QQuickLoader::Loading); QVERIFY(!controller->incubated); // asynchronous compilation means not immediately compiled/incubating. QTRY_VERIFY(controller->incubated); // but should start incubating once compilation is complete.