diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2011-07-29 14:41:16 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-29 09:39:41 +0200 |
commit | f1407da2cbaffcc1f175ec66ad389c3326efbe4a (patch) | |
tree | 0da4bf4bab76877663ed2834c7be06c6a83a6a94 /tests | |
parent | 9bfdaadd36cdb5254d808688aa8485e5a592937d (diff) |
Add sourceComponentChanged signal to Loader
When setting the 'sourceComponent' property in Loader, we emit
a sourceChanged signal with source == "". We should emit
sourceComponentChanged instead.
Task-number: QTBUG-20628
Change-Id: If5f8f389b7dc214e729b366d82fe4d32827408ee
Reviewed-on: http://codereview.qt.nokia.com/2371
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qsgloader/tst_qsgloader.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/auto/declarative/qsgloader/tst_qsgloader.cpp b/tests/auto/declarative/qsgloader/tst_qsgloader.cpp index 89285ebca6..c7e01da7ba 100644 --- a/tests/auto/declarative/qsgloader/tst_qsgloader.cpp +++ b/tests/auto/declarative/qsgloader/tst_qsgloader.cpp @@ -99,6 +99,7 @@ tst_QSGLoader::tst_QSGLoader() void tst_QSGLoader::sourceOrComponent() { + QFETCH(QString, sourceOrComponent); QFETCH(QString, sourceDefinition); QFETCH(QUrl, sourceUrl); QFETCH(QString, errorString); @@ -113,6 +114,7 @@ void tst_QSGLoader::sourceOrComponent() "Loader {\n" " property int onItemChangedCount: 0\n" " property int onSourceChangedCount: 0\n" + " property int onSourceComponentChangedCount: 0\n" " property int onStatusChangedCount: 0\n" " property int onProgressChangedCount: 0\n" " property int onLoadedCount: 0\n") @@ -120,6 +122,7 @@ void tst_QSGLoader::sourceOrComponent() + QByteArray( " onItemChanged: onItemChangedCount += 1\n" " onSourceChanged: onSourceChangedCount += 1\n" + " onSourceComponentChanged: onSourceComponentChangedCount += 1\n" " onStatusChanged: onStatusChangedCount += 1\n" " onProgressChanged: onProgressChangedCount += 1\n" " onLoaded: onLoadedCount += 1\n" @@ -141,7 +144,13 @@ void tst_QSGLoader::sourceOrComponent() QCOMPARE(loader->sourceComponent(), c); } - QCOMPARE(loader->property("onSourceChangedCount").toInt(), 1); + if (sourceOrComponent == "component") { + QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 1); + QCOMPARE(loader->property("onSourceChangedCount").toInt(), 0); + } else { + QCOMPARE(loader->property("onSourceComponentChangedCount").toInt(), 0); + QCOMPARE(loader->property("onSourceChangedCount").toInt(), 1); + } QCOMPARE(loader->property("onStatusChangedCount").toInt(), 1); QCOMPARE(loader->property("onProgressChangedCount").toInt(), 1); @@ -153,14 +162,14 @@ void tst_QSGLoader::sourceOrComponent() void tst_QSGLoader::sourceOrComponent_data() { + QTest::addColumn<QString>("sourceOrComponent"); QTest::addColumn<QString>("sourceDefinition"); QTest::addColumn<QUrl>("sourceUrl"); QTest::addColumn<QString>("errorString"); - QTest::newRow("source") << "source: 'Rect120x60.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml") << ""; - QTest::newRow("sourceComponent") << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << ""; - - QTest::newRow("invalid source") << "source: 'IDontExist.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml") + QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml") << ""; + QTest::newRow("sourceComponent") << "component" << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << ""; + QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml") << QString(QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ": File not found"); } |