diff options
19 files changed, 364 insertions, 141 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index 29eb983..9465c4c 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -843,6 +843,9 @@ QmlComponent *QmlGraphicsGridView::delegate() const void QmlGraphicsGridView::setDelegate(QmlComponent *delegate) { Q_D(QmlGraphicsGridView); + if (delegate == this->delegate()) + return; + if (!d->ownModel) { d->model = new QmlGraphicsVisualDataModel(qmlContext(this)); d->ownModel = true; @@ -944,9 +947,11 @@ QmlComponent *QmlGraphicsGridView::highlight() const void QmlGraphicsGridView::setHighlight(QmlComponent *highlight) { Q_D(QmlGraphicsGridView); - delete d->highlightComponent; - d->highlightComponent = highlight; - d->updateCurrent(d->currentIndex); + if (highlight != d->highlightComponent) { + delete d->highlightComponent; + d->highlightComponent = highlight; + d->updateCurrent(d->currentIndex); + } } /*! @@ -978,12 +983,14 @@ bool QmlGraphicsGridView::highlightFollowsCurrentItem() const void QmlGraphicsGridView::setHighlightFollowsCurrentItem(bool autoHighlight) { Q_D(QmlGraphicsGridView); - d->autoHighlight = autoHighlight; - if (d->highlightXAnimator) { - d->highlightXAnimator->setEnabled(d->autoHighlight); - d->highlightYAnimator->setEnabled(d->autoHighlight); + if (d->autoHighlight != autoHighlight) { + d->autoHighlight = autoHighlight; + if (d->highlightXAnimator) { + d->highlightXAnimator->setEnabled(d->autoHighlight); + d->highlightYAnimator->setEnabled(d->autoHighlight); + } + d->updateHighlight(); } - d->updateHighlight(); } /*! diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index edcd094..c075a8a 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -1158,6 +1158,8 @@ QmlComponent *QmlGraphicsListView::delegate() const void QmlGraphicsListView::setDelegate(QmlComponent *delegate) { Q_D(QmlGraphicsListView); + if (delegate == this->delegate()) + return; if (!d->ownModel) { d->model = new QmlGraphicsVisualDataModel(qmlContext(this)); d->ownModel = true; @@ -1263,9 +1265,11 @@ QmlComponent *QmlGraphicsListView::highlight() const void QmlGraphicsListView::setHighlight(QmlComponent *highlight) { Q_D(QmlGraphicsListView); - delete d->highlightComponent; - d->highlightComponent = highlight; - d->updateCurrent(d->currentIndex); + if (highlight != d->highlightComponent) { + delete d->highlightComponent; + d->highlightComponent = highlight; + d->updateCurrent(d->currentIndex); + } } /*! @@ -1295,12 +1299,14 @@ bool QmlGraphicsListView::highlightFollowsCurrentItem() const void QmlGraphicsListView::setHighlightFollowsCurrentItem(bool autoHighlight) { Q_D(QmlGraphicsListView); - d->autoHighlight = autoHighlight; - if (d->highlightPosAnimator) { - d->highlightPosAnimator->setEnabled(d->autoHighlight); - d->highlightSizeAnimator->setEnabled(d->autoHighlight); + if (d->autoHighlight != autoHighlight) { + d->autoHighlight = autoHighlight; + if (d->highlightPosAnimator) { + d->highlightPosAnimator->setEnabled(d->autoHighlight); + d->highlightSizeAnimator->setEnabled(d->autoHighlight); + } + d->updateHighlight(); } - d->updateHighlight(); } /*! @@ -1520,8 +1526,7 @@ qreal QmlGraphicsListView::highlightMoveSpeed() const void QmlGraphicsListView::setHighlightMoveSpeed(qreal speed) { Q_D(QmlGraphicsListView);\ - if (d->highlightMoveSpeed != speed) - { + if (d->highlightMoveSpeed != speed) { d->highlightMoveSpeed = speed; if (d->highlightPosAnimator) d->highlightPosAnimator->setVelocity(d->highlightMoveSpeed); @@ -1538,8 +1543,7 @@ qreal QmlGraphicsListView::highlightResizeSpeed() const void QmlGraphicsListView::setHighlightResizeSpeed(qreal speed) { Q_D(QmlGraphicsListView);\ - if (d->highlightResizeSpeed != speed) - { + if (d->highlightResizeSpeed != speed) { d->highlightResizeSpeed = speed; if (d->highlightSizeAnimator) d->highlightSizeAnimator->setVelocity(d->highlightResizeSpeed); diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index 7dbe788..fa68951 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -168,6 +168,7 @@ QmlCompositeTypeData *QmlCompositeTypeManager::get(const QUrl &url) if (!unit) { unit = new QmlCompositeTypeData; unit->status = QmlCompositeTypeData::Waiting; + unit->progress = 0.0; unit->imports.setBaseUrl(url); components.insert(url.toString(), unit); @@ -217,7 +218,6 @@ void QmlCompositeTypeManager::replyFinished() Q_ASSERT(unit); if (reply->error() != QNetworkReply::NoError) { - QString errorDescription; // ### - Fill in error errorDescription = QLatin1String("Network error for URL ") + diff --git a/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml b/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml index d9e9f27..32833d2 100644 --- a/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml +++ b/tests/auto/declarative/qmlgraphicsgridview/data/gridview-initCurrent.qml @@ -45,7 +45,7 @@ Rectangle { currentIndex: 5 cellWidth: 80 cellHeight: 60 - model: testModel delegate: myDelegate + model: testModel } } diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp index d09aad7..d0b7462 100644 --- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp +++ b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp @@ -390,7 +390,11 @@ void tst_QmlGraphicsGridView::removed() gridview->setViewportY(120); gridview->setCurrentIndex(10); + // let transitions settle. + QTest::qWait(300); + model.removeItem(1); + // let transitions settle. QTest::qWait(300); diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml index 65a9d8a..74f5ef4 100644 --- a/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml +++ b/tests/auto/declarative/qmlgraphicslistview/data/listview-initCurrent.qml @@ -43,8 +43,8 @@ Rectangle { width: 240 height: 320 keyNavigationWraps: testWrap - model: testModel delegate: myDelegate highlightMoveSpeed: 1000 + model: testModel } } diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml index ccefeba..ec8bb68 100644 --- a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml +++ b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml @@ -4,6 +4,29 @@ Rectangle { width: 240 height: 320 color: "#ffffff" + function checkProperties() { + testObject.error = false; + if (list.model != testModel) { + print("model property incorrect"); + testObject.error = true; + } + if (!testObject.animate && list.delegate != myDelegate) { + print("delegate property incorrect - expected myDelegate"); + testObject.error = true; + } + if (testObject.animate && list.delegate != animatedDelegate) { + print("delegate property incorrect - expected animatedDelegate"); + testObject.error = true; + } + if (testObject.invalidHighlight && list.highlight != invalidHl) { + print("highlight property incorrect - expected invalidHl"); + testObject.error = true; + } + if (!testObject.invalidHighlight && list.highlight != myHighlight) { + print("highlight property incorrect - expected myHighlight"); + testObject.error = true; + } + } resources: [ Component { id: myDelegate @@ -70,6 +93,14 @@ Rectangle { */ } } + }, + Component { + id: myHighlight + Rectangle { color: "green" } + }, + Component { + id: invalidHl + EaseFollow {} } ] ListView { @@ -79,7 +110,8 @@ Rectangle { width: 240 height: 320 model: testModel - delegate: testAnimate ? myDelegate : animatedDelegate + delegate: testObject.animate ? animatedDelegate : myDelegate + highlight: testObject.invalidHighlight ? invalidHl : myHighlight highlightMoveSpeed: 1000 highlightResizeSpeed: 1000 } diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp index d416603..7e6dc0d 100644 --- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp +++ b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp @@ -90,6 +90,38 @@ private: QList<T*> findItems(QmlGraphicsItem *parent, const QString &objectName); }; +class TestObject : public QObject +{ + Q_OBJECT + + Q_PROPERTY(bool error READ error WRITE setError NOTIFY changedError) + Q_PROPERTY(bool animate READ animate NOTIFY changedAnim) + Q_PROPERTY(bool invalidHighlight READ invalidHighlight NOTIFY changedHl) + +public: + TestObject(QObject *parent = 0) + : QObject(parent), mError(true), mAnimate(false), mInvalidHighlight(false) {} + + bool error() const { return mError; } + void setError(bool err) { mError = err; emit changedError(); } + + bool animate() const { return mAnimate; } + void setAnimate(bool anim) { mAnimate = anim; emit changedAnim(); } + + bool invalidHighlight() const { return mInvalidHighlight; } + void setInvalidHighlight(bool invalid) { mInvalidHighlight = invalid; emit changedHl(); } + +signals: + void changedError(); + void changedAnim(); + void changedHl(); + +public: + bool mError; + bool mAnimate; + bool mInvalidHighlight; +}; + class TestModel : public QListModelInterface { Q_OBJECT @@ -243,7 +275,9 @@ void tst_QmlGraphicsListView::items() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -254,6 +288,9 @@ void tst_QmlGraphicsListView::items() QmlGraphicsItem *viewport = listview->viewport(); QVERIFY(viewport != 0); + QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QVERIFY(testObject->error() == false); + QCOMPARE(listview->count(), model.count()); QCOMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item @@ -269,6 +306,16 @@ void tst_QmlGraphicsListView::items() QCOMPARE(number->text(), model.number(i)); } + // switch to other delegate + testObject->setAnimate(true); + QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QVERIFY(testObject->error() == false); + + // set invalid highlight + testObject->setInvalidHighlight(true); + QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QVERIFY(testObject->error() == false); + // set an empty model and confirm that items are destroyed T model2; ctxt->setContextProperty("testModel", &model2); @@ -294,7 +341,9 @@ void tst_QmlGraphicsListView::changed() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -328,7 +377,9 @@ void tst_QmlGraphicsListView::inserted() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -415,7 +466,10 @@ void tst_QmlGraphicsListView::removed(bool animated) QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(animated)); + + TestObject *testObject = new TestObject; + testObject->setAnimate(animated); + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -526,7 +580,9 @@ void tst_QmlGraphicsListView::moved() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -665,7 +721,9 @@ void tst_QmlGraphicsListView::spacing() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -934,7 +992,9 @@ void tst_QmlGraphicsListView::cacheBuffer() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testAnimate", QVariant(false)); + + TestObject *testObject = new TestObject; + ctxt->setContextProperty("testObject", testObject); canvas->execute(); qApp->processEvents(); @@ -944,6 +1004,9 @@ void tst_QmlGraphicsListView::cacheBuffer() QmlGraphicsItem *viewport = listview->viewport(); QVERIFY(viewport != 0); + QVERIFY(listview->delegate() != 0); + QVERIFY(listview->model() != 0); + QVERIFY(listview->highlight() == 0); // Confirm items positioned correctly int itemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count(); @@ -955,6 +1018,7 @@ void tst_QmlGraphicsListView::cacheBuffer() } listview->setCacheBuffer(400); + QVERIFY(listview->cacheBuffer() == 400); int newItemCount = findItems<QmlGraphicsItem>(viewport, "wrapper").count(); QVERIFY(newItemCount > itemCount); diff --git a/tests/auto/declarative/qmlgraphicsloader/NoResize.qml b/tests/auto/declarative/qmlgraphicsloader/data/NoResize.qml index cfbb55a..cfbb55a 100644 --- a/tests/auto/declarative/qmlgraphicsloader/NoResize.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/NoResize.qml diff --git a/tests/auto/declarative/qmlgraphicsloader/Rect120x60.qml b/tests/auto/declarative/qmlgraphicsloader/data/Rect120x60.qml index aa4b0c2..aa4b0c2 100644 --- a/tests/auto/declarative/qmlgraphicsloader/Rect120x60.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/Rect120x60.qml diff --git a/tests/auto/declarative/qmlgraphicsloader/SetSourceComponent.qml b/tests/auto/declarative/qmlgraphicsloader/data/SetSourceComponent.qml index 1db56c4..1db56c4 100644 --- a/tests/auto/declarative/qmlgraphicsloader/SetSourceComponent.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/SetSourceComponent.qml diff --git a/tests/auto/declarative/qmlgraphicsloader/SizeToItem.qml b/tests/auto/declarative/qmlgraphicsloader/data/SizeToItem.qml index b52fa03..b52fa03 100644 --- a/tests/auto/declarative/qmlgraphicsloader/SizeToItem.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/SizeToItem.qml diff --git a/tests/auto/declarative/qmlgraphicsloader/SizeToLoader.qml b/tests/auto/declarative/qmlgraphicsloader/data/SizeToLoader.qml index 1a107e1..1a107e1 100644 --- a/tests/auto/declarative/qmlgraphicsloader/SizeToLoader.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/SizeToLoader.qml diff --git a/tests/auto/declarative/qmlgraphicsloader/qmlgraphicsloader.pro b/tests/auto/declarative/qmlgraphicsloader/qmlgraphicsloader.pro index 8be8cdf..4837075 100644 --- a/tests/auto/declarative/qmlgraphicsloader/qmlgraphicsloader.pro +++ b/tests/auto/declarative/qmlgraphicsloader/qmlgraphicsloader.pro @@ -1,7 +1,11 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative gui +contains(QT_CONFIG,declarative): QT += declarative gui network macx:CONFIG -= app_bundle -SOURCES += tst_qmlgraphicsloader.cpp +INCLUDEPATH += ../shared/ +HEADERS += ../shared/testhttpserver.h +SOURCES += tst_qmlgraphicsloader.cpp \ + ../shared/testhttpserver.cpp DEFINES += SRCDIR=\\\"$$PWD\\\" + diff --git a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp b/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp index a88026b..a5f769e 100644 --- a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp +++ b/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp @@ -42,6 +42,23 @@ #include <QtDeclarative/qmlengine.h> #include <QtDeclarative/qmlcomponent.h> #include <private/qmlgraphicsloader_p.h> +#include "testhttpserver.h" + +#define SERVER_PORT 14445 + +inline QUrl TEST_FILE(const QString &filename) +{ + return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); +} + +#define TRY_WAIT(expr) \ + do { \ + for (int ii = 0; ii < 6; ++ii) { \ + if ((expr)) break; \ + QTest::qWait(50); \ + } \ + QVERIFY((expr)); \ + } while (false) class tst_QmlGraphicsLoader : public QObject @@ -60,23 +77,13 @@ private slots: void sizeLoaderToItem(); void sizeItemToLoader(); void noResize(); + void networkRequest(); + void failNetworkRequest(); private: QmlEngine engine; }; -/* -inline QUrl TEST_FILE(const QString &filename) -{ - QFileInfo fileInfo(__FILE__); - return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(filename)); -} - -inline QUrl TEST_FILE(const char *filename) -{ - return TEST_FILE(QLatin1String(filename)); -} -*/ tst_QmlGraphicsLoader::tst_QmlGraphicsLoader() { @@ -84,11 +91,11 @@ tst_QmlGraphicsLoader::tst_QmlGraphicsLoader() void tst_QmlGraphicsLoader::url() { - QmlComponent component(&engine, QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), QUrl("file://" SRCDIR "/")); + QmlComponent component(&engine, QByteArray("import Qt 4.6\nLoader { source: \"Rect120x60.qml\" }"), TEST_FILE("")); QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create()); QVERIFY(loader != 0); QVERIFY(loader->item()); - QVERIFY(loader->source() == QUrl("file://" SRCDIR "/Rect120x60.qml")); + QVERIFY(loader->source() == QUrl("file://" SRCDIR "/data/Rect120x60.qml")); QCOMPARE(loader->progress(), 1.0); QCOMPARE(loader->status(), QmlGraphicsLoader::Ready); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); @@ -98,7 +105,7 @@ void tst_QmlGraphicsLoader::url() void tst_QmlGraphicsLoader::component() { - QmlComponent component(&engine, QUrl("file://" SRCDIR "/SetSourceComponent.qml")); + QmlComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create()); QVERIFY(item); @@ -114,9 +121,9 @@ void tst_QmlGraphicsLoader::component() void tst_QmlGraphicsLoader::invalidUrl() { - QTest::ignoreMessage(QtWarningMsg, "(:-1: File error for URL file://" SRCDIR "/IDontExist.qml) "); + 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\" }"), QUrl("file://" SRCDIR "/")); + QmlComponent component(&engine, 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); @@ -136,7 +143,7 @@ void tst_QmlGraphicsLoader::clear() " source: 'Rect120x60.qml'\n" " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n" " }") - , QUrl("file://" SRCDIR "/")); + , TEST_FILE("")); QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create()); QVERIFY(loader != 0); QVERIFY(loader->item()); @@ -153,7 +160,7 @@ void tst_QmlGraphicsLoader::clear() delete loader; } { - QmlComponent component(&engine, QUrl("file://" SRCDIR "/SetSourceComponent.qml")); + QmlComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create()); QVERIFY(item); @@ -183,7 +190,7 @@ void tst_QmlGraphicsLoader::urlToComponent() " source: \"Rect120x60.qml\"\n" " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n" "}" ) - , QUrl("file://" SRCDIR "/")); + , TEST_FILE("")); QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create()); QTest::qWait(500); QVERIFY(loader != 0); @@ -198,7 +205,7 @@ void tst_QmlGraphicsLoader::urlToComponent() void tst_QmlGraphicsLoader::componentToUrl() { - QmlComponent component(&engine, QUrl("file://" SRCDIR "/SetSourceComponent.qml")); + QmlComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); QmlGraphicsItem *item = qobject_cast<QmlGraphicsItem*>(component.create()); QVERIFY(item); @@ -208,7 +215,7 @@ void tst_QmlGraphicsLoader::componentToUrl() QCOMPARE(loader->progress(), 1.0); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); - loader->setSource(QUrl("file://" SRCDIR "/Rect120x60.qml")); + loader->setSource(TEST_FILE("/Rect120x60.qml")); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); @@ -220,7 +227,7 @@ void tst_QmlGraphicsLoader::componentToUrl() void tst_QmlGraphicsLoader::sizeLoaderToItem() { - QmlComponent component(&engine, QUrl("file://" SRCDIR "/SizeToItem.qml")); + QmlComponent component(&engine, TEST_FILE("/SizeToItem.qml")); QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create()); QVERIFY(loader != 0); QVERIFY(loader->resizeMode() == QmlGraphicsLoader::SizeLoaderToItem); @@ -245,7 +252,7 @@ void tst_QmlGraphicsLoader::sizeLoaderToItem() void tst_QmlGraphicsLoader::sizeItemToLoader() { - QmlComponent component(&engine, QUrl("file://" SRCDIR "/SizeToLoader.qml")); + QmlComponent component(&engine, TEST_FILE("/SizeToLoader.qml")); QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create()); QVERIFY(loader != 0); QVERIFY(loader->resizeMode() == QmlGraphicsLoader::SizeItemToLoader); @@ -266,7 +273,7 @@ void tst_QmlGraphicsLoader::sizeItemToLoader() void tst_QmlGraphicsLoader::noResize() { - QmlComponent component(&engine, QUrl("file://" SRCDIR "/NoResize.qml")); + QmlComponent component(&engine, TEST_FILE("/NoResize.qml")); QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create()); QVERIFY(loader != 0); QCOMPARE(loader->width(), 200.0); @@ -278,6 +285,46 @@ void tst_QmlGraphicsLoader::noResize() QCOMPARE(rect->height(), 60.0); } +void tst_QmlGraphicsLoader::networkRequest() +{ + TestHTTPServer server(SERVER_PORT); + 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("")); + QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create()); + QVERIFY(loader != 0); + + TRY_WAIT(loader->status() == QmlGraphicsLoader::Ready); + + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); + + delete loader; +} + +void tst_QmlGraphicsLoader::failNetworkRequest() +{ + TestHTTPServer server(SERVER_PORT); + QVERIFY(server.isValid()); + server.serveDirectory("data"); + + 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("")); + QmlGraphicsLoader *loader = qobject_cast<QmlGraphicsLoader*>(component.create()); + QVERIFY(loader != 0); + + TRY_WAIT(loader->status() == QmlGraphicsLoader::Error); + + QVERIFY(loader->item() == 0); + QCOMPARE(loader->progress(), 0.0); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0); + + delete loader; +} + QTEST_MAIN(tst_QmlGraphicsLoader) #include "tst_qmlgraphicsloader.moc" diff --git a/tests/auto/declarative/qmlgraphicspathview/data/path.qml b/tests/auto/declarative/qmlgraphicspathview/data/path.qml new file mode 100644 index 0000000..7e82a48 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicspathview/data/path.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Path { + startX: 120; startY: 100 + + PathAttribute { name: "scale"; value: 1.0 } + PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } + PathPercent { value: 0.3 } + PathLine { x: 120; y: 100 } + PathCubic { + x: 180; y: 0; control1X: -10; control1Y: 90 + control2X: 210; control2Y: 90 + } +} diff --git a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp index c36b969..561392a 100644 --- a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp +++ b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include <private/qmlgraphicspathview_p.h> +#include <private/qmlgraphicspath_p.h> #include <qmlcontext.h> #include <qmlexpression.h> #include <qtest.h> @@ -57,6 +58,7 @@ private slots: void initValues(); void pathview2(); void pathview3(); + void path(); }; @@ -118,6 +120,51 @@ void tst_QmlGraphicsPathView::pathview3() QCOMPARE(obj->pathItemCount(), 4); } +void tst_QmlGraphicsPathView::path() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/path.qml")); + QmlGraphicsPath *obj = qobject_cast<QmlGraphicsPath*>(c.create()); + + QVERIFY(obj != 0); + QCOMPARE(obj->startX(), 120.); + QCOMPARE(obj->startY(), 100.); + QVERIFY(obj->path() != QPainterPath()); + + QList<QmlGraphicsPathElement*> *list = obj->pathElements(); + QCOMPARE(list->count(), 5); + + QmlGraphicsPathAttribute* attr = qobject_cast<QmlGraphicsPathAttribute*>(list->at(0)); + QVERIFY(attr != 0); + QCOMPARE(attr->name(), QString("scale")); + QCOMPARE(attr->value(), 1.0); + + QmlGraphicsPathQuad* quad = qobject_cast<QmlGraphicsPathQuad*>(list->at(1)); + QVERIFY(quad != 0); + QCOMPARE(quad->x(), 120.); + QCOMPARE(quad->y(), 25.); + QCOMPARE(quad->controlX(), 260.); + QCOMPARE(quad->controlY(), 75.); + + QmlGraphicsPathPercent* perc = qobject_cast<QmlGraphicsPathPercent*>(list->at(2)); + QVERIFY(perc != 0); + QCOMPARE(perc->value(), 0.3); + + QmlGraphicsPathLine* line = qobject_cast<QmlGraphicsPathLine*>(list->at(3)); + QVERIFY(line != 0); + QCOMPARE(line->x(), 120.); + QCOMPARE(line->y(), 100.); + + QmlGraphicsPathCubic* cubic = qobject_cast<QmlGraphicsPathCubic*>(list->at(4)); + QVERIFY(cubic != 0); + QCOMPARE(cubic->x(), 180.); + QCOMPARE(cubic->y(), 0.); + QCOMPARE(cubic->control1X(), -10.); + QCOMPARE(cubic->control1Y(), 90.); + QCOMPARE(cubic->control2X(), 210.); + QCOMPARE(cubic->control2Y(), 90.); +} + QTEST_MAIN(tst_QmlGraphicsPathView) #include "tst_qmlgraphicspathview.moc" diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.0.png b/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.0.png Binary files differindex 05a6e51..67b497f 100644 --- a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.0.png +++ b/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.0.png diff --git a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.qml b/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.qml index 045dda0..ab17eb1 100644 --- a/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.qml +++ b/tests/auto/declarative/visual/qmlgraphicstext/font/data-MAC/plaintext.qml @@ -6,239 +6,239 @@ VisualTest { } Frame { msec: 16 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 32 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 48 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 64 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 80 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 96 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 112 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 128 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 144 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 160 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 176 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 192 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 208 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 224 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 240 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 256 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 272 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 288 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 304 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 320 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 336 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 352 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 368 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 384 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 400 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 416 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 432 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 448 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 464 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 480 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 496 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 512 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 528 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 544 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 560 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 576 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 592 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 608 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 624 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 640 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 656 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 672 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 688 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 704 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 720 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 736 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 752 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 768 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 784 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 800 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 816 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 832 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 848 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 864 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 880 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 896 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 912 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 928 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 944 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 960 @@ -246,59 +246,59 @@ VisualTest { } Frame { msec: 976 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 992 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1008 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1024 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1040 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1056 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1072 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1088 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1104 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1120 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1136 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1152 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1168 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1184 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Key { type: 6 @@ -310,42 +310,42 @@ VisualTest { } Frame { msec: 1200 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1216 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1232 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1248 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1264 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1280 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1296 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1312 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1328 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } Frame { msec: 1344 - hash: "d6479cc04d67055c2fd8f4ed2fca829b" + hash: "cbf65bcb64a4781b79132b87f98d5fc7" } } |