diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-01-13 02:48:18 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-01-13 03:23:31 (GMT) |
commit | 8f1fb137cb47951dc67409372a6763ddb17d65ca (patch) | |
tree | 79b09b50cad4d200e33bed9b45c034bdebab0027 /tests/auto | |
parent | 05adc294d063171d9d0accf819826684813d396a (diff) | |
download | Qt-8f1fb137cb47951dc67409372a6763ddb17d65ca.zip Qt-8f1fb137cb47951dc67409372a6763ddb17d65ca.tar.gz Qt-8f1fb137cb47951dc67409372a6763ddb17d65ca.tar.bz2 |
Fix tests after 05adc294d063171d9d0accf819826684813d396a
Diffstat (limited to 'tests/auto')
18 files changed, 298 insertions, 151 deletions
diff --git a/tests/auto/declarative/animatedimage/tst_animatedimage.cpp b/tests/auto/declarative/animatedimage/tst_animatedimage.cpp index 5ba0068..20b344d 100644 --- a/tests/auto/declarative/animatedimage/tst_animatedimage.cpp +++ b/tests/auto/declarative/animatedimage/tst_animatedimage.cpp @@ -173,7 +173,8 @@ void tst_animatedimage::remote_data() void tst_animatedimage::invalidSource() { QmlEngine engine; - QmlComponent component(&engine, "import Qt 4.6\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl("file://")); + QmlComponent component(&engine); + component.setData("import Qt 4.6\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl("file://")); QVERIFY(component.isReady()); QTest::ignoreMessage(QtWarningMsg, "Error Reading Animated Image File QUrl( \"file:no-such-file.gif\" ) "); diff --git a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp index e9b4879..b5437b9 100644 --- a/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp +++ b/tests/auto/declarative/datetimeformatter/tst_datetimeformatter.cpp @@ -59,8 +59,9 @@ private slots: void tst_datetimeformatter::date() { QmlEngine engine; - QmlComponent formatterComponent(&engine, QByteArray("import Qt 4.6\n DateTimeFormatter { date: \"2008-12-24\" }"), - QUrl("file://")); + QmlComponent formatterComponent(&engine); + formatterComponent.setData(QByteArray("import Qt 4.6\n DateTimeFormatter { date: \"2008-12-24\" }"), + QUrl("file://")); QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create()); if(formatterComponent.isError()) qDebug() << formatterComponent.errors(); @@ -88,7 +89,8 @@ void tst_datetimeformatter::date() void tst_datetimeformatter::time() { QmlEngine engine; - QmlComponent formatterComponent(&engine, "import Qt 4.6\n DateTimeFormatter { time: \"14:15:38.200\" }", QUrl("file://")); + QmlComponent formatterComponent(&engine); + formatterComponent.setData("import Qt 4.6\n DateTimeFormatter { time: \"14:15:38.200\" }", QUrl("file://")); QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create()); if(formatterComponent.isError()) qDebug() << formatterComponent.errors(); @@ -120,7 +122,8 @@ void tst_datetimeformatter::time() void tst_datetimeformatter::dateTime() { QmlEngine engine; - QmlComponent formatterComponent(&engine, "import Qt 4.6\n DateTimeFormatter { dateTime: \"1978-03-04T09:13:54\" }", QUrl("file://")); + QmlComponent formatterComponent(&engine); + formatterComponent.setData("import Qt 4.6\n DateTimeFormatter { dateTime: \"1978-03-04T09:13:54\" }", QUrl("file://")); QmlDateTimeFormatter *formatter = qobject_cast<QmlDateTimeFormatter*>(formatterComponent.create()); if(formatterComponent.isError()) qDebug() << formatterComponent.errors(); diff --git a/tests/auto/declarative/numberformatter/tst_numberformatter.cpp b/tests/auto/declarative/numberformatter/tst_numberformatter.cpp index 1d68f35..e297961 100644 --- a/tests/auto/declarative/numberformatter/tst_numberformatter.cpp +++ b/tests/auto/declarative/numberformatter/tst_numberformatter.cpp @@ -203,7 +203,8 @@ void tst_numberformat::text() QString componentStr = QString("import Qt 4.6\nNumberFormatter { number: ") + string + QString("; format: \"") + format + QString("\" }"); QmlEngine engine; - QmlComponent formatterComponent(&engine, componentStr.toAscii(), QUrl("file:///")); + QmlComponent formatterComponent(&engine); + formatterComponent.setData(componentStr.toUtf8(), QUrl("file:///")); if(formatterComponent.isError()) qDebug() << formatterComponent.errors(); QVERIFY(formatterComponent.isReady()); diff --git a/tests/auto/declarative/parserstress/tst_parserstress.cpp b/tests/auto/declarative/parserstress/tst_parserstress.cpp index e584140..fe177d1 100644 --- a/tests/auto/declarative/parserstress/tst_parserstress.cpp +++ b/tests/auto/declarative/parserstress/tst_parserstress.cpp @@ -130,8 +130,8 @@ void tst_parserstress::ecmascript() QByteArray qmlData = qml.toUtf8(); - QmlComponent component(&engine, qmlData, - QUrl::fromLocalFile(SRCDIR + QString("/dummy.qml"))); + QmlComponent component(&engine); + component.setData(qmlData, QUrl::fromLocalFile(SRCDIR + QString("/dummy.qml"))); QVERIFY(!component.isError()); } diff --git a/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp b/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp index 954046e..27664fb 100644 --- a/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp +++ b/tests/auto/declarative/qmlfontloader/tst_qmlfontloader.cpp @@ -72,7 +72,8 @@ tst_qmlfontloader::tst_qmlfontloader() void tst_qmlfontloader::noFont() { QString componentStr = "import Qt 4.6\nFontLoader { }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create()); QVERIFY(fontObject != 0); @@ -86,7 +87,8 @@ void tst_qmlfontloader::noFont() void tst_qmlfontloader::namedFont() { QString componentStr = "import Qt 4.6\nFontLoader { name: \"Helvetica\" }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create()); QVERIFY(fontObject != 0); @@ -98,7 +100,8 @@ void tst_qmlfontloader::namedFont() void tst_qmlfontloader::localFont() { QString componentStr = "import Qt 4.6\nFontLoader { source: \"" SRCDIR "/data/FreeMono.ttf\" }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create()); QVERIFY(fontObject != 0); @@ -111,7 +114,8 @@ void tst_qmlfontloader::failLocalFont() { QString componentStr = "import Qt 4.6\nFontLoader { source: \"" SRCDIR "/data/dummy.ttf\" }"; QTest::ignoreMessage(QtWarningMsg, "Cannot load font: QUrl( \"file://" SRCDIR "/data/dummy.ttf\" ) "); - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create()); QVERIFY(fontObject != 0); @@ -123,7 +127,8 @@ void tst_qmlfontloader::failLocalFont() void tst_qmlfontloader::webFont() { QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://www.princexml.com/fonts/steffmann/Starburst.ttf\" }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create()); QVERIFY(fontObject != 0); @@ -136,7 +141,8 @@ void tst_qmlfontloader::failWebFont() { QString componentStr = "import Qt 4.6\nFontLoader { source: \"http://wrong.address.com/Starburst.ttf\" }"; QTest::ignoreMessage(QtWarningMsg, "Cannot load font: QUrl( \"http://wrong.address.com/Starburst.ttf\" ) "); - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlFontLoader *fontObject = qobject_cast<QmlFontLoader*>(component.create()); QVERIFY(fontObject != 0); diff --git a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp index bcdfa2e..ceee8f6 100644 --- a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp +++ b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp @@ -100,7 +100,8 @@ tst_qmlgraphicsborderimage::tst_qmlgraphicsborderimage() void tst_qmlgraphicsborderimage::noSource() { QString componentStr = "import Qt 4.6\nBorderImage { source: \"\" }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->source(), QUrl()); @@ -123,7 +124,7 @@ void tst_qmlgraphicsborderimage::imageSource_data() << "Cannot open QUrl( \"file://" SRCDIR "/data/no-such-file.png\" ) "; QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true - << "Network error loading QUrl( \"" SERVER_ADDR "/no-such-file.png\" ) " + << "Network error loading \"" SERVER_ADDR "/no-such-file.png\" " "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; } @@ -144,7 +145,8 @@ void tst_qmlgraphicsborderimage::imageSource() QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create()); QVERIFY(obj != 0); @@ -172,7 +174,8 @@ void tst_qmlgraphicsborderimage::clearSource() QString componentStr = "import Qt 4.6\nBorderImage { source: srcImage }"; QmlContext *ctxt = engine.rootContext(); ctxt->setContextProperty("srcImage", SRCDIR "/data/colors.png"); - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create()); QVERIFY(obj != 0); QVERIFY(obj->status() == QmlGraphicsBorderImage::Ready); @@ -189,7 +192,8 @@ void tst_qmlgraphicsborderimage::clearSource() void tst_qmlgraphicsborderimage::resized() { QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), 300.); @@ -203,7 +207,8 @@ void tst_qmlgraphicsborderimage::resized() void tst_qmlgraphicsborderimage::smooth() { QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), 300.); @@ -219,7 +224,8 @@ void tst_qmlgraphicsborderimage::tileModes() { { QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), 100.); @@ -231,7 +237,8 @@ void tst_qmlgraphicsborderimage::tileModes() } { QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), 300.); @@ -257,7 +264,8 @@ void tst_qmlgraphicsborderimage::sciSource() } QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create()); QVERIFY(obj != 0); @@ -301,7 +309,8 @@ void tst_qmlgraphicsborderimage::invalidSciFile() QTest::ignoreMessage(QtWarningMsg, "Unknown tile rule specified. Using Stretch "); // for "Repea" QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/invalid.sci\"; width: 300; height: 300 }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), 300.); @@ -318,7 +327,8 @@ void tst_qmlgraphicsborderimage::pendingRemoteRequest() QFETCH(QString, source); QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->status(), QmlGraphicsBorderImage::Loading); diff --git a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp index 26f5175..9731ef1 100644 --- a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp +++ b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp @@ -94,7 +94,8 @@ tst_qmlgraphicsimage::tst_qmlgraphicsimage() void tst_qmlgraphicsimage::noSource() { QString componentStr = "import Qt 4.6\nImage { source: \"\" }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->source(), QUrl()); @@ -138,7 +139,8 @@ void tst_qmlgraphicsimage::imageSource() QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create()); QVERIFY(obj != 0); @@ -165,7 +167,8 @@ void tst_qmlgraphicsimage::clearSource() QString componentStr = "import Qt 4.6\nImage { source: srcImage }"; QmlContext *ctxt = engine.rootContext(); ctxt->setContextProperty("srcImage", SRCDIR "/data/colors.png"); - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create()); QVERIFY(obj != 0); QVERIFY(obj->status() == QmlGraphicsImage::Ready); @@ -184,7 +187,8 @@ void tst_qmlgraphicsimage::clearSource() void tst_qmlgraphicsimage::resized() { QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), 300.); @@ -197,7 +201,8 @@ void tst_qmlgraphicsimage::resized() void tst_qmlgraphicsimage::smooth() { QString componentStr = "import Qt 4.6\nImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create()); QVERIFY(obj != 0); QCOMPARE(obj->width(), 300.); @@ -216,7 +221,8 @@ void tst_qmlgraphicsimage::pixmap() QmlContext *ctxt = engine.rootContext(); ctxt->setContextProperty("testPixmap", pixmap); - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsImage *obj = qobject_cast<QmlGraphicsImage*>(component.create()); QVERIFY(obj != 0); diff --git a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp b/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp index b1e76e1..9d61f50 100644 --- a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp +++ b/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp @@ -92,7 +92,8 @@ tst_QmlGraphicsLoader::tst_QmlGraphicsLoader() void tst_QmlGraphicsLoader::url() { - QmlComponent component(&engine, QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), TEST_FILE("")); + QmlComponent component(&engine); + component.setData(QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), TEST_FILE("")); QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create()); QVERIFY(loader != 0); QVERIFY(loader->item()); @@ -124,7 +125,8 @@ void tst_QmlGraphicsLoader::invalidUrl() { QTest::ignoreMessage(QtWarningMsg, "(:-1: File error for URL file://" SRCDIR "/data/IDontExist.qml) "); - QmlComponent component(&engine, QByteArray("import Qt 4.6\nLoader { source: \"IDontExist.qml\" }"), TEST_FILE("")); + QmlComponent component(&engine); + component.setData(QByteArray("import Qt 4.6\nLoader { source: \"IDontExist.qml\" }"), TEST_FILE("")); QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create()); QVERIFY(loader != 0); QVERIFY(loader->item() == 0); @@ -138,7 +140,8 @@ void tst_QmlGraphicsLoader::invalidUrl() void tst_QmlGraphicsLoader::clear() { { - QmlComponent component(&engine, QByteArray( + QmlComponent component(&engine); + component.setData(QByteArray( "import Qt 4.6\n" " Loader { id: loader\n" " source: 'Rect120x60.qml'\n" @@ -184,7 +187,8 @@ void tst_QmlGraphicsLoader::clear() void tst_QmlGraphicsLoader::urlToComponent() { - QmlComponent component(&engine, QByteArray("import Qt 4.6\n" + QmlComponent component(&engine); + component.setData(QByteArray("import Qt 4.6\n" "Loader {\n" " id: loader\n" " Component { id: myComp; Rectangle { width: 10; height: 10 } }\n" @@ -292,7 +296,8 @@ void tst_QmlGraphicsLoader::networkRequestUrl() QVERIFY(server.isValid()); server.serveDirectory("data"); - QmlComponent component(&engine, QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/Rect120x60.qml\" }"), TEST_FILE("")); + QmlComponent component(&engine); + component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/Rect120x60.qml\" }"), TEST_FILE("")); QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create()); QVERIFY(loader != 0); @@ -312,7 +317,8 @@ void tst_QmlGraphicsLoader::networkComponent() QVERIFY(server.isValid()); server.serveDirectory("slowdata", TestHTTPServer::Delay); - QmlComponent component(&engine, QByteArray( + QmlComponent component(&engine); + component.setData(QByteArray( "import Qt 4.6\n" "import \"http://127.0.0.1:14445/\" as NW\n" "Item {\n" @@ -344,7 +350,8 @@ void tst_QmlGraphicsLoader::failNetworkRequest() QTest::ignoreMessage(QtWarningMsg, "(:-1: Network error for URL http://127.0.0.1:14445/IDontExist.qml) "); - QmlComponent component(&engine, QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/IDontExist.qml\" }"), TEST_FILE("")); + QmlComponent component(&engine); + component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/IDontExist.qml\" }"), TEST_FILE("")); QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create()); QVERIFY(loader != 0); diff --git a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp index 1e10873..72ec5ec 100644 --- a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp +++ b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp @@ -155,7 +155,8 @@ tst_qmlgraphicstext::tst_qmlgraphicstext() void tst_qmlgraphicstext::text() { { - QmlComponent textComponent(&engine, "import Qt 4.6\nText { text: \"\" }", QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData("import Qt 4.6\nText { text: \"\" }", QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -168,7 +169,9 @@ void tst_qmlgraphicstext::text() for (int i = 0; i < standard.size(); i++) { QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -179,7 +182,8 @@ void tst_qmlgraphicstext::text() for (int i = 0; i < richText.size(); i++) { QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -193,7 +197,8 @@ void tst_qmlgraphicstext::width() { // uses Font metrics to find the width for standard and document to find the width for rich { - QmlComponent textComponent(&engine, "import Qt 4.6\nText { text: \"\" }", QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData("import Qt 4.6\nText { text: \"\" }", QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -210,7 +215,8 @@ void tst_qmlgraphicstext::width() metricWidth = floor(metricWidth); QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -229,7 +235,8 @@ void tst_qmlgraphicstext::width() int documentWidth = document.idealWidth(); QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -243,7 +250,8 @@ void tst_qmlgraphicstext::wrap() int textHeight = 0; // for specified width and wrap set true { - QmlComponent textComponent(&engine, "import Qt 4.6\nText { text: \"Hello\"; wrap: true; width: 300 }", QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData("import Qt 4.6\nText { text: \"Hello\"; wrap: true; width: 300 }", QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); textHeight = textObject->height(); @@ -255,7 +263,8 @@ void tst_qmlgraphicstext::wrap() for (int i = 0; i < standard.size(); i++) { QString componentStr = "import Qt 4.6\nText { wrap: true; width: 30; text: \"" + standard.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -270,7 +279,8 @@ void tst_qmlgraphicstext::wrap() for (int i = 0; i < richText.size(); i++) { QString componentStr = "import Qt 4.6\nText { wrap: true; width: 30; text: \"" + richText.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -289,7 +299,8 @@ void tst_qmlgraphicstext::elide() // XXX Poor coverage. { - QmlComponent textComponent(&engine, ("import Qt 4.6\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(("import Qt 4.6\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->elideMode(), m); @@ -299,7 +310,8 @@ void tst_qmlgraphicstext::elide() for (int i = 0; i < standard.size(); i++) { QString componentStr = "import Qt 4.6\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->elideMode(), m); @@ -310,7 +322,8 @@ void tst_qmlgraphicstext::elide() for (int i = 0; i < richText.size(); i++) { QString componentStr = "import Qt 4.6\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->elideMode(), m); @@ -322,14 +335,16 @@ void tst_qmlgraphicstext::elide() void tst_qmlgraphicstext::textFormat() { { - QmlComponent textComponent(&engine, "import Qt 4.6\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData("import Qt 4.6\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); QVERIFY(textObject->textFormat() == QmlGraphicsText::RichText); } { - QmlComponent textComponent(&engine, "import Qt 4.6\nText { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData("import Qt 4.6\nText { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -347,7 +362,8 @@ void tst_qmlgraphicstext::horizontalAlignment() for (int j=0; j < horizontalAlignmentmentStrings.size(); j++) { QString componentStr = "import Qt 4.6\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j)); @@ -359,7 +375,8 @@ void tst_qmlgraphicstext::horizontalAlignment() for (int j=0; j < horizontalAlignmentmentStrings.size(); j++) { QString componentStr = "import Qt 4.6\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j)); @@ -377,7 +394,8 @@ void tst_qmlgraphicstext::verticalAlignment() for (int j=0; j < verticalAlignmentmentStrings.size(); j++) { QString componentStr = "import Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -390,7 +408,8 @@ void tst_qmlgraphicstext::verticalAlignment() for (int j=0; j < verticalAlignmentmentStrings.size(); j++) { QString componentStr = "import Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -405,7 +424,8 @@ void tst_qmlgraphicstext::font() //test size, then bold, then italic, then family { QString componentStr = "import Qt 4.6\nText { font.pointSize: 40; text: \"Hello World\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->font().pointSize(), 40); @@ -415,7 +435,8 @@ void tst_qmlgraphicstext::font() { QString componentStr = "import Qt 4.6\nText { font.pixelSize: 40; text: \"Hello World\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->font().pixelSize(), 40); @@ -425,7 +446,8 @@ void tst_qmlgraphicstext::font() { QString componentStr = "import Qt 4.6\nText { font.bold: true; text: \"Hello World\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->font().bold(), true); @@ -434,7 +456,8 @@ void tst_qmlgraphicstext::font() { QString componentStr = "import Qt 4.6\nText { font.italic: true; text: \"Hello World\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->font().italic(), true); @@ -443,7 +466,8 @@ void tst_qmlgraphicstext::font() { QString componentStr = "import Qt 4.6\nText { font.family: \"Helvetica\"; text: \"Hello World\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->font().family(), QString("Helvetica")); @@ -453,7 +477,8 @@ void tst_qmlgraphicstext::font() { QString componentStr = "import Qt 4.6\nText { font.family: \"\"; text: \"Hello World\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->font().family(), QString("")); @@ -466,7 +491,8 @@ void tst_qmlgraphicstext::style() for (int i = 0; i < styles.size(); i++) { QString componentStr = "import Qt 4.6\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE((int)textObject->style(), (int)styles.at(i)); @@ -480,7 +506,8 @@ void tst_qmlgraphicstext::color() for (int i = 0; i < colorStrings.size(); i++) { QString componentStr = "import Qt 4.6\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->color(), QColor(colorStrings.at(i))); @@ -490,7 +517,8 @@ void tst_qmlgraphicstext::color() for (int i = 0; i < colorStrings.size(); i++) { QString componentStr = "import Qt 4.6\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i))); @@ -503,7 +531,8 @@ void tst_qmlgraphicstext::color() for (int j = 0; j < colorStrings.size(); j++) { QString componentStr = "import Qt 4.6\nText { color: \"" + colorStrings.at(i) + "\"; styleColor: \"" + colorStrings.at(j) + "\"; text: \"Hello World\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->color(), QColor(colorStrings.at(i))); @@ -516,7 +545,8 @@ void tst_qmlgraphicstext::color() testColor.setAlpha(170); QString componentStr = "import Qt 4.6\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->color(), testColor); @@ -529,13 +559,15 @@ void tst_qmlgraphicstext::smooth() { { QString componentStr = "import Qt 4.6\nText { smooth: true; text: \"" + standard.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->smooth(), true); } { QString componentStr = "import Qt 4.6\nText { text: \"" + standard.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->smooth(), false); } @@ -544,13 +576,15 @@ void tst_qmlgraphicstext::smooth() { { QString componentStr = "import Qt 4.6\nText { smooth: true; text: \"" + richText.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->smooth(), true); } { QString componentStr = "import Qt 4.6\nText { text: \"" + richText.at(i) + "\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QCOMPARE(textObject->smooth(), false); } @@ -561,7 +595,8 @@ void tst_qmlgraphicstext::weight() { { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -569,7 +604,8 @@ void tst_qmlgraphicstext::weight() } { QString componentStr = "import Qt 4.6\nText { font.weight: \"Bold\"; text: \"Hello world!\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -581,7 +617,8 @@ void tst_qmlgraphicstext::underline() { { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -589,7 +626,8 @@ void tst_qmlgraphicstext::underline() } { QString componentStr = "import Qt 4.6\nText { font.underline: true; text: \"Hello world!\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -601,7 +639,8 @@ void tst_qmlgraphicstext::overline() { { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -609,7 +648,8 @@ void tst_qmlgraphicstext::overline() } { QString componentStr = "import Qt 4.6\nText { font.overline: true; text: \"Hello world!\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -621,7 +661,8 @@ void tst_qmlgraphicstext::strikeout() { { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -629,7 +670,8 @@ void tst_qmlgraphicstext::strikeout() } { QString componentStr = "import Qt 4.6\nText { font.strikeout: true; text: \"Hello world!\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -641,7 +683,8 @@ void tst_qmlgraphicstext::capitalization() { { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -649,7 +692,8 @@ void tst_qmlgraphicstext::capitalization() } { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -657,7 +701,8 @@ void tst_qmlgraphicstext::capitalization() } { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -665,7 +710,8 @@ void tst_qmlgraphicstext::capitalization() } { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -673,7 +719,8 @@ void tst_qmlgraphicstext::capitalization() } { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -685,7 +732,8 @@ void tst_qmlgraphicstext::letterSpacing() { { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -693,7 +741,8 @@ void tst_qmlgraphicstext::letterSpacing() } { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.letterSpacing: -50 }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -701,7 +750,8 @@ void tst_qmlgraphicstext::letterSpacing() } { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.letterSpacing: 200 }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -713,7 +763,8 @@ void tst_qmlgraphicstext::wordSpacing() { { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -721,7 +772,8 @@ void tst_qmlgraphicstext::wordSpacing() } { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.wordSpacing: -50 }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -729,7 +781,8 @@ void tst_qmlgraphicstext::wordSpacing() } { QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.wordSpacing: 200 }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); @@ -759,7 +812,8 @@ void tst_qmlgraphicstext::clickLink() { { QString componentStr = "import Qt 4.6\nText { text: \"<a href=\\\"http://qt.nokia.com\\\">Hello world!</a>\" }"; - QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast<QmlGraphicsText*>(textComponent.create()); QVERIFY(textObject != 0); diff --git a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp index 66ecff6..23ecf2b 100644 --- a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp +++ b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp @@ -144,7 +144,8 @@ tst_qmlgraphicstextedit::tst_qmlgraphicstextedit() void tst_qmlgraphicstextedit::text() { { - QmlComponent texteditComponent(&engine, "import Qt 4.6\nTextEdit { text: \"\" }", QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\" }", QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -154,7 +155,8 @@ void tst_qmlgraphicstextedit::text() for (int i = 0; i < standard.size(); i++) { QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -164,7 +166,8 @@ void tst_qmlgraphicstextedit::text() for (int i = 0; i < richText.size(); i++) { QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + richText.at(i) + "\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -182,7 +185,8 @@ void tst_qmlgraphicstextedit::width() { // uses Font metrics to find the width for standard and document to find the width for rich { - QmlComponent texteditComponent(&engine, "import Qt 4.6\nTextEdit { text: \"\" }", QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\" }", QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -197,7 +201,8 @@ void tst_qmlgraphicstextedit::width() metricWidth = floor(metricWidth); QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + standard.at(i) + "\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -213,7 +218,8 @@ void tst_qmlgraphicstextedit::width() int documentWidth = document.idealWidth(); QString componentStr = "import Qt 4.6\nTextEdit { text: \"" + richText.at(i) + "\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -225,7 +231,8 @@ void tst_qmlgraphicstextedit::wrap() { // for specified width and wrap set true { - QmlComponent texteditComponent(&engine, "import Qt 4.6\nTextEdit { text: \"\"; wrap: true; width: 300 }", QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData("import Qt 4.6\nTextEdit { text: \"\"; wrap: true; width: 300 }", QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -235,7 +242,8 @@ void tst_qmlgraphicstextedit::wrap() for (int i = 0; i < standard.size(); i++) { QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + standard.at(i) + "\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -245,7 +253,8 @@ void tst_qmlgraphicstextedit::wrap() for (int i = 0; i < richText.size(); i++) { QString componentStr = "import Qt 4.6\nTextEdit { wrap: true; width: 300; text: \"" + richText.at(i) + "\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -257,14 +266,16 @@ void tst_qmlgraphicstextedit::wrap() void tst_qmlgraphicstextedit::textFormat() { { - QmlComponent textComponent(&engine, "import Qt 4.6\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData("import Qt 4.6\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl("file://")); QmlGraphicsTextEdit *textObject = qobject_cast<QmlGraphicsTextEdit*>(textComponent.create()); QVERIFY(textObject != 0); QVERIFY(textObject->textFormat() == QmlGraphicsTextEdit::RichText); } { - QmlComponent textComponent(&engine, "import Qt 4.6\nTextEdit { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl("file://")); + QmlComponent textComponent(&engine); + textComponent.setData("import Qt 4.6\nTextEdit { text: \"<b>Hello</b>\"; textFormat: Text.PlainText }", QUrl("file://")); QmlGraphicsTextEdit *textObject = qobject_cast<QmlGraphicsTextEdit*>(textComponent.create()); QVERIFY(textObject != 0); @@ -282,7 +293,8 @@ void tst_qmlgraphicstextedit::hAlign() for (int j=0; j < hAlignmentStrings.size(); j++) { QString componentStr = "import Qt 4.6\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -295,7 +307,8 @@ void tst_qmlgraphicstextedit::hAlign() for (int j=0; j < hAlignmentStrings.size(); j++) { QString componentStr = "import Qt 4.6\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -314,7 +327,8 @@ void tst_qmlgraphicstextedit::vAlign() for (int j=0; j < vAlignmentStrings.size(); j++) { QString componentStr = "import Qt 4.6\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -327,7 +341,8 @@ void tst_qmlgraphicstextedit::vAlign() for (int j=0; j < vAlignmentStrings.size(); j++) { QString componentStr = "import Qt 4.6\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -342,7 +357,8 @@ void tst_qmlgraphicstextedit::font() //test size, then bold, then italic, then family { QString componentStr = "import Qt 4.6\nTextEdit { font.pointSize: 40; text: \"Hello World\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -353,7 +369,8 @@ void tst_qmlgraphicstextedit::font() { QString componentStr = "import Qt 4.6\nTextEdit { font.bold: true; text: \"Hello World\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -363,7 +380,8 @@ void tst_qmlgraphicstextedit::font() { QString componentStr = "import Qt 4.6\nTextEdit { font.italic: true; text: \"Hello World\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -373,7 +391,8 @@ void tst_qmlgraphicstextedit::font() { QString componentStr = "import Qt 4.6\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -384,7 +403,8 @@ void tst_qmlgraphicstextedit::font() { QString componentStr = "import Qt 4.6\nTextEdit { font.family: \"\"; text: \"Hello World\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -398,7 +418,8 @@ void tst_qmlgraphicstextedit::color() for (int i = 0; i < colorStrings.size(); i++) { QString componentStr = "import Qt 4.6\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); //qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i)); QVERIFY(textEditObject != 0); @@ -409,7 +430,8 @@ void tst_qmlgraphicstextedit::color() for (int i = 0; i < colorStrings.size(); i++) { QString componentStr = "import Qt 4.6\nTextEdit { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->selectionColor(), QColor(colorStrings.at(i))); @@ -419,7 +441,8 @@ void tst_qmlgraphicstextedit::color() for (int i = 0; i < colorStrings.size(); i++) { QString componentStr = "import Qt 4.6\nTextEdit { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->selectedTextColor(), QColor(colorStrings.at(i))); @@ -431,7 +454,8 @@ void tst_qmlgraphicstextedit::color() testColor.setAlpha(170); QString componentStr = "import Qt 4.6\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); @@ -443,7 +467,8 @@ void tst_qmlgraphicstextedit::textMargin() { for(qreal i=0; i<=10; i+=0.3){ QString componentStr = "import Qt 4.6\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->textMargin(), i); @@ -454,7 +479,8 @@ void tst_qmlgraphicstextedit::persistentSelection() { { QString componentStr = "import Qt 4.6\nTextEdit { persistentSelection: true; text: \"Hello World\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->persistentSelection(), true); @@ -462,7 +488,8 @@ void tst_qmlgraphicstextedit::persistentSelection() { QString componentStr = "import Qt 4.6\nTextEdit { persistentSelection: false; text: \"Hello World\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->persistentSelection(), false); @@ -473,7 +500,8 @@ void tst_qmlgraphicstextedit::focusOnPress() { { QString componentStr = "import Qt 4.6\nTextEdit { focusOnPress: true; text: \"Hello World\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->focusOnPress(), true); @@ -481,7 +509,8 @@ void tst_qmlgraphicstextedit::focusOnPress() { QString componentStr = "import Qt 4.6\nTextEdit { focusOnPress: false; text: \"Hello World\" }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); QCOMPARE(textEditObject->focusOnPress(), false); @@ -492,7 +521,8 @@ void tst_qmlgraphicstextedit::selection() { QString testStr = standard[0];//TODO: What should happen for multiline/rich text? QString componentStr = "import Qt 4.6\nTextEdit { text: \""+ testStr +"\"; }"; - QmlComponent texteditComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent texteditComponent(&engine); + texteditComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextEdit *textEditObject = qobject_cast<QmlGraphicsTextEdit*>(texteditComponent.create()); QVERIFY(textEditObject != 0); diff --git a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp index 0eba11b..02772ec 100644 --- a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp +++ b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp @@ -100,7 +100,8 @@ tst_qmlgraphicstextinput::tst_qmlgraphicstextinput() void tst_qmlgraphicstextinput::text() { { - QmlComponent textinputComponent(&engine, "import Qt 4.6\nTextInput { text: \"\" }", QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData("import Qt 4.6\nTextInput { text: \"\" }", QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); @@ -110,7 +111,8 @@ void tst_qmlgraphicstextinput::text() for (int i = 0; i < standard.size(); i++) { QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }"; - QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); @@ -123,7 +125,8 @@ void tst_qmlgraphicstextinput::width() { // uses Font metrics to find the width for standard { - QmlComponent textinputComponent(&engine, "import Qt 4.6\nTextInput { text: \"\" }", QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData("import Qt 4.6\nTextInput { text: \"\" }", QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); @@ -137,7 +140,8 @@ void tst_qmlgraphicstextinput::width() qreal metricWidth = fm.width(standard.at(i)); QString componentStr = "import Qt 4.6\nTextInput { text: \"" + standard.at(i) + "\" }"; - QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); @@ -150,7 +154,8 @@ void tst_qmlgraphicstextinput::font() //test size, then bold, then italic, then family { QString componentStr = "import Qt 4.6\nTextInput { font.pointSize: 40; text: \"Hello World\" }"; - QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); @@ -161,7 +166,8 @@ void tst_qmlgraphicstextinput::font() { QString componentStr = "import Qt 4.6\nTextInput { font.bold: true; text: \"Hello World\" }"; - QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); @@ -171,7 +177,8 @@ void tst_qmlgraphicstextinput::font() { QString componentStr = "import Qt 4.6\nTextInput { font.italic: true; text: \"Hello World\" }"; - QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); @@ -181,7 +188,8 @@ void tst_qmlgraphicstextinput::font() { QString componentStr = "import Qt 4.6\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }"; - QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); @@ -192,7 +200,8 @@ void tst_qmlgraphicstextinput::font() { QString componentStr = "import Qt 4.6\nTextInput { font.family: \"\"; text: \"Hello World\" }"; - QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); @@ -206,7 +215,8 @@ void tst_qmlgraphicstextinput::color() for (int i = 0; i < colorStrings.size(); i++) { QString componentStr = "import Qt 4.6\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i))); @@ -216,7 +226,8 @@ void tst_qmlgraphicstextinput::color() for (int i = 0; i < colorStrings.size(); i++) { QString componentStr = "import Qt 4.6\nTextInput { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i))); @@ -226,7 +237,8 @@ void tst_qmlgraphicstextinput::color() for (int i = 0; i < colorStrings.size(); i++) { QString componentStr = "import Qt 4.6\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i))); @@ -238,7 +250,8 @@ void tst_qmlgraphicstextinput::color() testColor.setAlpha(170); QString componentStr = "import Qt 4.6\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }"; - QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); @@ -250,7 +263,8 @@ void tst_qmlgraphicstextinput::selection() { QString testStr = standard[0]; QString componentStr = "import Qt 4.6\nTextInput { text: \""+ testStr +"\"; }"; - QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); @@ -380,7 +394,8 @@ void tst_qmlgraphicstextinput::masks() void tst_qmlgraphicstextinput::validators() { QString componentStr = "import Qt 4.6\nTextInput { maximumLength: 10; }"; - QmlComponent textinputComponent(&engine, componentStr.toLatin1(), QUrl()); + QmlComponent textinputComponent(&engine); + textinputComponent.setData(componentStr.toLatin1(), QUrl()); QmlGraphicsTextInput *textinputObject = qobject_cast<QmlGraphicsTextInput*>(textinputComponent.create()); QVERIFY(textinputObject != 0); diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index 3b7c298..506c71a 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -1000,7 +1000,8 @@ void tst_qmllanguage::scriptString() // Check that first child of qml is of given type. Empty type insists on error. void tst_qmllanguage::testType(const QString& qml, const QString& type) { - QmlComponent component(&engine, qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports + QmlComponent component(&engine); + component.setData(qml.toUtf8(), TEST_FILE("empty.qml")); // just a file for relative local imports QTRY_VERIFY(!component.isLoading()); @@ -1313,7 +1314,8 @@ void tst_qmllanguage::qmlAttachedPropertiesObjectMethod() void tst_qmllanguage::crash1() { - QmlComponent component(&engine, "Component {}"); + QmlComponent component(&engine); + component.setData("import Qt 4.6\nComponent {}", QUrl()); } void tst_qmllanguage::crash2() diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp index 0d09b54..0986d20 100644 --- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp +++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp @@ -63,7 +63,8 @@ void tst_QmlListModel::static_i18n() QString expect = QString::fromUtf8("na\303\257ve"); QString componentStr = "import Qt 4.6\nListModel { ListElement { prop1: \""+expect+"\" } }"; QmlEngine engine; - QmlComponent component(&engine, componentStr.toUtf8(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toUtf8(), QUrl("file://")); QmlListModel *obj = qobject_cast<QmlListModel*>(component.create()); QVERIFY(obj != 0); QString prop = obj->get(0).property(QLatin1String("prop1")).toString(); @@ -208,8 +209,9 @@ void tst_QmlListModel::error() QFETCH(QString, error); QmlEngine engine; - QmlComponent component(&engine, qml.toUtf8(), - QUrl::fromLocalFile(QString("dummy.qml"))); + QmlComponent component(&engine); + component.setData(qml.toUtf8(), + QUrl::fromLocalFile(QString("dummy.qml"))); if (error.isEmpty()) { QVERIFY(!component.isError()); } else { diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp index 8dcfc11..63d8274 100644 --- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp +++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp @@ -900,7 +900,8 @@ void tst_qmlmetaproperty::write() void tst_qmlmetaproperty::writeObjectToList() { - QmlComponent containerComponent(&engine, "import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl()); + QmlComponent containerComponent(&engine); + containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl()); MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create()); QVERIFY(container != 0); QVERIFY(container->children()->size() == 1); @@ -915,7 +916,8 @@ void tst_qmlmetaproperty::writeObjectToList() Q_DECLARE_METATYPE(QList<QObject *>); void tst_qmlmetaproperty::writeListToList() { - QmlComponent containerComponent(&engine, "import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl()); + QmlComponent containerComponent(&engine); + containerComponent.setData("import Test 1.0\nMyContainer { children: MyQmlObject {} }", QUrl()); MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create()); QVERIFY(container != 0); QVERIFY(container->children()->size() == 1); @@ -935,7 +937,8 @@ void tst_qmlmetaproperty::writeListToList() void tst_qmlmetaproperty::writeObjectToQmlList() { - QmlComponent containerComponent(&engine, "import Test 1.0\nMyContainer { qmlChildren: MyQmlObject {} }", QUrl()); + QmlComponent containerComponent(&engine); + containerComponent.setData("import Test 1.0\nMyContainer { qmlChildren: MyQmlObject {} }", QUrl()); MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create()); QVERIFY(container != 0); QVERIFY(container->qmlChildren()->size() == 1); diff --git a/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp b/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp index fe2658c..ba3bdd2 100644 --- a/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp +++ b/tests/auto/declarative/qmlpropertymap/tst_qmlpropertymap.cpp @@ -135,7 +135,8 @@ void tst_QmlPropertyMap::changed() QmlEngine engine; QmlContext *ctxt = engine.rootContext(); ctxt->setContextProperty(QLatin1String("testdata"), &map); - QmlComponent component(&engine, "import Qt 4.6\nText { text: { testdata.key1 = 'Hello World'; 'X' } }", + QmlComponent component(&engine); + component.setData("import Qt 4.6\nText { text: { testdata.key1 = 'Hello World'; 'X' } }", QUrl("file://")); QVERIFY(component.isReady()); QmlGraphicsText *txt = qobject_cast<QmlGraphicsText*>(component.create()); diff --git a/tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp b/tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp index 008dfb3..12e3a70 100644 --- a/tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp +++ b/tests/auto/declarative/qmlsystempalette/tst_qmlsystempalette.cpp @@ -71,7 +71,8 @@ tst_qmlsystempalette::tst_qmlsystempalette() void tst_qmlsystempalette::activePalette() { QString componentStr = "import Qt 4.6\nSystemPalette { }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlSystemPalette *object = qobject_cast<QmlSystemPalette*>(component.create()); QVERIFY(object != 0); @@ -99,7 +100,8 @@ void tst_qmlsystempalette::activePalette() void tst_qmlsystempalette::inactivePalette() { QString componentStr = "import Qt 4.6\nSystemPalette { colorGroup: SystemPalette.Inactive }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlSystemPalette *object = qobject_cast<QmlSystemPalette*>(component.create()); QVERIFY(object != 0); @@ -128,7 +130,8 @@ void tst_qmlsystempalette::inactivePalette() void tst_qmlsystempalette::disabledPalette() { QString componentStr = "import Qt 4.6\nSystemPalette { colorGroup: SystemPalette.Disabled }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlSystemPalette *object = qobject_cast<QmlSystemPalette*>(component.create()); QVERIFY(object != 0); @@ -157,7 +160,8 @@ void tst_qmlsystempalette::disabledPalette() void tst_qmlsystempalette::paletteChanged() { QString componentStr = "import Qt 4.6\nSystemPalette { }"; - QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl("file://")); QmlSystemPalette *object = qobject_cast<QmlSystemPalette*>(component.create()); QVERIFY(object != 0); diff --git a/tests/auto/declarative/shared/debugutil.cpp b/tests/auto/declarative/shared/debugutil.cpp index 8f6fdef..b8245b5 100644 --- a/tests/auto/declarative/shared/debugutil.cpp +++ b/tests/auto/declarative/shared/debugutil.cpp @@ -157,7 +157,8 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList<QByteArray> &qml QmlEngine engine; // blocks until client connects foreach (const QByteArray &code, qml) { - QmlComponent c(&engine, code, QUrl("file://")); + QmlComponent c(&engine); + c.setData(code, QUrl("file://")); Q_ASSERT(c.isReady()); // fails if bad syntax data.items << qobject_cast<QmlGraphicsItem*>(c.create()); } diff --git a/tests/auto/declarative/sql/tst_sql.cpp b/tests/auto/declarative/sql/tst_sql.cpp index 1e4e6f8..9bc667d 100644 --- a/tests/auto/declarative/sql/tst_sql.cpp +++ b/tests/auto/declarative/sql/tst_sql.cpp @@ -200,7 +200,8 @@ void tst_sql::testQml() "Text { Script { source: \""+jsfile+"\" } text: test() }"; engine->setOfflineStoragePath(dbDir()); - QmlComponent component(engine, qml.toUtf8(), QUrl::fromLocalFile(SRCDIR "/empty.qml")); // just a file for relative local imports + QmlComponent component(engine); + component.setData(qml.toUtf8(), QUrl::fromLocalFile(SRCDIR "/empty.qml")); // just a file for relative local imports QmlGraphicsText *text = qobject_cast<QmlGraphicsText*>(component.create()); QVERIFY(text != 0); QCOMPARE(text->text(),QString("passed")); |