diff options
author | Bea Lam <bea.lam@nokia.com> | 2011-01-27 04:03:13 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2011-01-27 04:03:13 (GMT) |
commit | 05ba01a2519996a3dffaab2e498dc3d2a999dc45 (patch) | |
tree | c478929354b59407bea92e885baf0eecb4e351c8 /tests | |
parent | f15778e60ba538b8715f6433a472ffe08a21d934 (diff) | |
parent | 5c91e32a6238fd112a7282443214c8686cda51de (diff) | |
download | Qt-05ba01a2519996a3dffaab2e498dc3d2a999dc45.zip Qt-05ba01a2519996a3dffaab2e498dc3d2a999dc45.tar.gz Qt-05ba01a2519996a3dffaab2e498dc3d2a999dc45.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into qtquick11
Conflicts:
src/declarative/graphicsitems/qdeclarativegridview.cpp
src/declarative/graphicsitems/qdeclarativelistview.cpp
Diffstat (limited to 'tests')
11 files changed, 129 insertions, 85 deletions
diff --git a/tests/auto/declarative/qdeclarativeborderimage/data/colors-round-remote.sci b/tests/auto/declarative/qdeclarativeborderimage/data/colors-round-remote.sci new file mode 100644 index 0000000..c673bed --- /dev/null +++ b/tests/auto/declarative/qdeclarativeborderimage/data/colors-round-remote.sci @@ -0,0 +1,7 @@ +border.left:10 +border.top:20 +border.right:30 +border.bottom:40 +horizontalTileRule:Round +verticalTileRule:Repeat +source:http://127.0.0.1:14446/colors.png diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp index a2f4e0c..9a9d22b 100644 --- a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp +++ b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp @@ -332,6 +332,7 @@ void tst_qdeclarativeborderimage::sciSource_data() QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors-round.sci").toString() << true; QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.sci").toString() << false; QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true; + QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true; QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false; } diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index d4f318b..4fff071 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -1331,6 +1331,19 @@ void tst_QDeclarativeListView::positionViewAtIndex() QTRY_COMPARE(item->y(), i*20.); } + // Position at End using last index + listview->positionViewAtIndex(model.count()-1, QDeclarativeListView::End); + QTRY_COMPARE(listview->contentY(), 480.); + + // Confirm items positioned correctly + itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count(); + for (int i = 24; i < model.count(); ++i) { + QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->y(), i*20.); + } + // Position at End listview->positionViewAtIndex(20, QDeclarativeListView::End); QTRY_COMPARE(listview->contentY(), 100.); diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index 358822e..bfa81ed 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -69,8 +69,9 @@ public: tst_QDeclarativeLoader(); private slots: - void sourceOrComponent(); - void sourceOrComponent_data(); + void url(); + void invalidUrl(); + void component(); void clear(); void urlToComponent(); void componentToUrl(); @@ -99,71 +100,56 @@ tst_QDeclarativeLoader::tst_QDeclarativeLoader() { } -void tst_QDeclarativeLoader::sourceOrComponent() +void tst_QDeclarativeLoader::url() { - QFETCH(QString, sourceDefinition); - QFETCH(QUrl, sourceUrl); - QFETCH(QString, errorString); - - bool error = !errorString.isEmpty(); - if (error) - QTest::ignoreMessage(QtWarningMsg, errorString.toUtf8().constData()); - QDeclarativeComponent component(&engine); - component.setData(QByteArray( - "import QtQuick 1.0\n" - "Loader {\n" - " property int onItemChangedCount: 0\n" - " property int onSourceChangedCount: 0\n" - " property int onStatusChangedCount: 0\n" - " property int onProgressChangedCount: 0\n" - " property int onLoadedCount: 0\n") - + sourceDefinition.toUtf8() - + QByteArray( - " onItemChanged: onItemChangedCount += 1\n" - " onSourceChanged: onSourceChangedCount += 1\n" - " onStatusChanged: onStatusChangedCount += 1\n" - " onProgressChanged: onProgressChangedCount += 1\n" - " onLoaded: onLoadedCount += 1\n" - "}") - , TEST_FILE("")); - + component.setData(QByteArray("import QtQuick 1.0\nLoader { property int did_load: 0; onLoaded: did_load=123; source: \"Rect120x60.qml\" }"), TEST_FILE("")); QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); QVERIFY(loader != 0); - QCOMPARE(loader->item() == 0, error); - QCOMPARE(loader->source(), sourceUrl); + QVERIFY(loader->item()); + QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml")); QCOMPARE(loader->progress(), 1.0); + QCOMPARE(loader->status(), QDeclarativeLoader::Ready); + QCOMPARE(loader->property("did_load").toInt(), 123); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); - QCOMPARE(loader->status(), error ? QDeclarativeLoader::Error : QDeclarativeLoader::Ready); - QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), error ? 0: 1); + delete loader; +} - if (!error) { - QDeclarativeComponent *c = qobject_cast<QDeclarativeComponent*>(loader->QGraphicsObject::children().at(0)); - QVERIFY(c); - QCOMPARE(loader->sourceComponent(), c); - } +void tst_QDeclarativeLoader::component() +{ + QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(item); - QCOMPARE(loader->property("onSourceChangedCount").toInt(), 1); - QCOMPARE(loader->property("onStatusChangedCount").toInt(), 1); - QCOMPARE(loader->property("onProgressChangedCount").toInt(), 1); + QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(1)); + QVERIFY(loader); + QVERIFY(loader->item()); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(loader->status(), QDeclarativeLoader::Ready); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); - QCOMPARE(loader->property("onItemChangedCount").toInt(), error ? 0 : 1); - QCOMPARE(loader->property("onLoadedCount").toInt(), error ? 0 : 1); + QDeclarativeComponent *c = qobject_cast<QDeclarativeComponent*>(item->QGraphicsObject::children().at(0)); + QVERIFY(c); + QCOMPARE(loader->sourceComponent(), c); - delete loader; + delete item; } -void tst_QDeclarativeLoader::sourceOrComponent_data() +void tst_QDeclarativeLoader::invalidUrl() { - QTest::addColumn<QString>("sourceDefinition"); - QTest::addColumn<QUrl>("sourceUrl"); - QTest::addColumn<QString>("errorString"); + QTest::ignoreMessage(QtWarningMsg, QString(QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ": File not found").toUtf8().constData()); - QTest::newRow("source") << "source: 'Rect120x60.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml") << ""; - QTest::newRow("sourceComponent") << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << ""; + QDeclarativeComponent component(&engine); + component.setData(QByteArray("import QtQuick 1.0\nLoader { source: \"IDontExist.qml\" }"), TEST_FILE("")); + QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); + QVERIFY(loader != 0); + QVERIFY(loader->item() == 0); + QCOMPARE(loader->progress(), 1.0); + QCOMPARE(loader->status(), QDeclarativeLoader::Error); + QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0); - QTest::newRow("invalid source") << "source: 'IDontExist.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml") - << QString(QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ": File not found"); + delete loader; } void tst_QDeclarativeLoader::clear() @@ -460,7 +446,7 @@ void tst_QDeclarativeLoader::networkRequestUrl() server.serveDirectory(SRCDIR "/data"); QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), QUrl::fromLocalFile(SRCDIR "/dummy.qml")); + component.setData(QByteArray("import QtQuick 1.0\nLoader { property int did_load : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: did_load=123 }"), QUrl::fromLocalFile(SRCDIR "/dummy.qml")); if (component.isError()) qDebug() << component.errors(); QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); @@ -470,7 +456,7 @@ void tst_QDeclarativeLoader::networkRequestUrl() QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); - QCOMPARE(loader->property("signalCount").toInt(), 1); + QCOMPARE(loader->property("did_load").toInt(), 123); QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1); delete loader; diff --git a/tests/auto/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/qfontdatabase/tst_qfontdatabase.cpp index ead000c..8b6f621 100644 --- a/tests/auto/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/qfontdatabase/tst_qfontdatabase.cpp @@ -191,9 +191,6 @@ void tst_QFontDatabase::addAppFont_data() void tst_QFontDatabase::addAppFont() { -#ifdef Q_OS_SYMBIAN - QSKIP( "Symbian: Application fonts are not yet supported", SkipAll ); -#else QFETCH(bool, useMemoryFont); QSignalSpy fontDbChangedSpy(QApplication::instance(), SIGNAL(fontDatabaseChanged())); @@ -243,7 +240,6 @@ void tst_QFontDatabase::addAppFont() QCOMPARE(fontDbChangedSpy.count(), 2); QVERIFY(db.families() == oldFamilies); -#endif } QTEST_MAIN(tst_QFontDatabase) diff --git a/tests/auto/qlayout/qlayout.pro b/tests/auto/qlayout/qlayout.pro index c99f1d9..d3b76e3 100644 --- a/tests/auto/qlayout/qlayout.pro +++ b/tests/auto/qlayout/qlayout.pro @@ -10,5 +10,11 @@ wince*|symbian: { addFiles.sources = baseline addFiles.path = . DEPLOYMENT += addFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" + + test_data.files = baseline/* + test_data.path = $${target.path}/baseline + INSTALLS += test_data } diff --git a/tests/auto/qlayout/tst_qlayout.cpp b/tests/auto/qlayout/tst_qlayout.cpp index 65eae55..3090ebb 100644 --- a/tests/auto/qlayout/tst_qlayout.cpp +++ b/tests/auto/qlayout/tst_qlayout.cpp @@ -156,7 +156,8 @@ void tst_QLayout::smartMaxSize() { QVector<int> expectedWidths; - QFile f(QLatin1String("baseline/smartmaxsize")); + QFile f(QLatin1String(SRCDIR "/baseline/smartmaxsize")); + QCOMPARE(f.open(QIODevice::ReadOnly | QIODevice::Text), true); QTextStream stream(&f); diff --git a/tests/auto/qmake/testcompiler.cpp b/tests/auto/qmake/testcompiler.cpp index 021fe9b..dbdeee8 100644 --- a/tests/auto/qmake/testcompiler.cpp +++ b/tests/auto/qmake/testcompiler.cpp @@ -142,23 +142,16 @@ bool TestCompiler::runCommand( QString cmdline ) bool failed = false; child.setReadChannel(QProcess::StandardError); - while (QProcess::Running == child.state()) { - if (child.waitForReadyRead(1000)) { - QString output = child.readAllStandardError(); - testOutput_.append(output); - - output.prepend('\n'); - if (output.contains("\nProject MESSAGE: FAILED")) - failed = true; - } - } - child.waitForFinished(-1); - return failed - ? false - : (child.exitStatus() == QProcess::NormalExit) - && (child.exitCode() == 0); + foreach (const QByteArray &output, child.readAllStandardError().split('\n')) { + testOutput_.append(QString::fromLocal8Bit(output)); + + if (output.startsWith("Project MESSAGE: FAILED")) + failed = true; + } + + return !failed && child.exitStatus() == QProcess::NormalExit && child.exitCode() == 0; } void TestCompiler::setBaseCommands( QString makeCmd, QString qmakeCmd ) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index bd22837..8274140 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -212,6 +212,7 @@ private Q_SLOTS: void ioGetFromBuiltinHttp(); void ioGetFromHttpWithReuseParallel(); void ioGetFromHttpWithReuseSequential(); + void ioGetFromHttpWithAuth_data(); void ioGetFromHttpWithAuth(); void ioGetFromHttpWithAuthSynchronous(); void ioGetFromHttpWithProxyAuth(); @@ -2163,15 +2164,27 @@ void tst_QNetworkReply::ioGetFromHttpWithReuseSequential() } } +void tst_QNetworkReply::ioGetFromHttpWithAuth_data() +{ + QTest::addColumn<QUrl>("url"); + QTest::addColumn<QByteArray>("expectedData"); + + QFile reference(SRCDIR "/rfc3252.txt"); + reference.open(QIODevice::ReadOnly); + QByteArray referenceData = reference.readAll(); + QTest::newRow("basic") << QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfcs-auth/rfc3252.txt") << referenceData; + QTest::newRow("digest") << QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/auth-digest/") << QByteArray("digest authentication successful\n"); +} + void tst_QNetworkReply::ioGetFromHttpWithAuth() { // This test sends three requests // The first two in parallel // The third after the first two finished - QFile reference(SRCDIR "/rfc3252.txt"); - QVERIFY(reference.open(QIODevice::ReadOnly)); - QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfcs-auth/rfc3252.txt")); + QFETCH(QUrl, url); + QFETCH(QByteArray, expectedData); + QNetworkRequest request(url); { QNetworkReplyPtr reply1 = manager.get(request); QNetworkReplyPtr reply2 = manager.get(request); @@ -2196,14 +2209,12 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth() QCOMPARE(reply1->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); QCOMPARE(reply2->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); - QByteArray referenceData = reference.readAll(); - QCOMPARE(reader1.data, referenceData); - QCOMPARE(reader2.data, referenceData); + QCOMPARE(reader1.data, expectedData); + QCOMPARE(reader2.data, expectedData); QCOMPARE(authspy.count(), 1); } - reference.seek(0); // rinse and repeat: { QNetworkReplyPtr reply = manager.get(request); @@ -2219,13 +2230,12 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth() this, SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); - QCOMPARE(reader.data, reference.readAll()); + QCOMPARE(reader.data, expectedData); QCOMPARE(authspy.count(), 0); } // now check with synchronous calls: - reference.seek(0); { request.setAttribute( static_cast<QNetworkRequest::Attribute>(SynchronousRequestAttribute), @@ -2241,7 +2251,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth() // the only thing we check here is that the auth cache was used when using synchronous requests QCOMPARE(replySync->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); - QCOMPARE(replySync->readAll(), reference.readAll()); + QCOMPARE(replySync->readAll(), expectedData); } } diff --git a/tests/auto/qtextcursor/tst_qtextcursor.cpp b/tests/auto/qtextcursor/tst_qtextcursor.cpp index ee2baef..4d52dd7 100644 --- a/tests/auto/qtextcursor/tst_qtextcursor.cpp +++ b/tests/auto/qtextcursor/tst_qtextcursor.cpp @@ -134,6 +134,7 @@ private slots: void endOfLine(); void editBlocksDuringRemove(); + void selectAllDuringRemove(); void update_data(); void update(); @@ -1388,6 +1389,17 @@ public slots: ++recordingCount; } + void selectAllContents() + { + // Only test the first time + if (!recordingCount) { + recordingCount++; + cursor->select(QTextCursor::Document); + lastRecordedPosition = cursor->position(); + lastRecordedAnchor = cursor->anchor(); + } + } + private: QTextCursor *cursor; }; @@ -1411,6 +1423,22 @@ void tst_QTextCursor::editBlocksDuringRemove() QVERIFY(doc->toPlainText().isEmpty()); } +void tst_QTextCursor::selectAllDuringRemove() +{ + CursorListener listener(&cursor); + + cursor.insertText("Hello World"); + cursor.movePosition(QTextCursor::End); + + connect(doc, SIGNAL(contentsChanged()), &listener, SLOT(selectAllContents())); + listener.recordingCount = 0; + QTextCursor localCursor = cursor; + localCursor.deletePreviousChar(); + + QCOMPARE(listener.lastRecordedPosition, 10); + QCOMPARE(listener.lastRecordedAnchor, 0); +} + void tst_QTextCursor::update_data() { QTest::addColumn<QString>("text"); diff --git a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp index 50205bc..f11519b 100644 --- a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp +++ b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp @@ -332,6 +332,8 @@ void tst_QSharedMemory::attach() QVERIFY(sm.detach()); // Make sure detach doesn't screw up something and we can't re-attach. QVERIFY(sm.attach()); + QVERIFY(sm.data() != 0); + QVERIFY(sm.size() != 0); QVERIFY(sm.detach()); QCOMPARE(sm.size(), 0); QVERIFY(sm.data() == 0); @@ -358,7 +360,8 @@ void tst_QSharedMemory::lock() QVERIFY(shm.lock()); QTest::ignoreMessage(QtWarningMsg, "QSharedMemory::lock: already locked"); QVERIFY(shm.lock()); - // don't lock forever + // we didn't unlock(), so ignore the warning from auto-detach in destructor + QTest::ignoreMessage(QtWarningMsg, "QSharedMemory::lock: already locked"); } /*! |