diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-04-16 00:12:16 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-04-16 00:12:16 (GMT) |
commit | 7b0d764f37fa4009dc1556666eb8a141164fb0e0 (patch) | |
tree | 3d5d1c0f5aadc2f3e2a5eccacd2fc2f32b21e385 /tests | |
parent | bac82138b76ac9f6a0603fa454f6660d139287d0 (diff) | |
parent | 16ae00c689faac5d7af312ae31d7f715dc6e0745 (diff) | |
download | Qt-7b0d764f37fa4009dc1556666eb8a141164fb0e0.zip Qt-7b0d764f37fa4009dc1556666eb8a141164fb0e0.tar.gz Qt-7b0d764f37fa4009dc1556666eb8a141164fb0e0.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests')
29 files changed, 292 insertions, 110 deletions
diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index b316cb9..4c32524 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -4,6 +4,8 @@ macx:CONFIG -= app_bundle SOURCES += tst_examples.cpp +include(../../../../tools/qml/qml.pri) + DEFINES += SRCDIR=\\\"$$PWD\\\" CONFIG += parallel_test diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index e62aad2..c650346 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -43,8 +43,9 @@ #include <QDir> #include <QProcess> #include <QDebug> -#include <QFutureSynchronizer> -#include <QtConcurrentRun> +#include "qmlruntime.h" +#include <QDeclarativeView> +#include <QDeclarativeError> class tst_examples : public QObject { @@ -53,6 +54,7 @@ public: tst_examples(); private slots: + void examples_data(); void examples(); void namingConvention(); @@ -173,8 +175,6 @@ QStringList tst_examples::findQmlFiles(const QDir &d) return rv; } - - /* This test runs all the examples in the declarative UI source tree and ensures that they start and exit cleanly. @@ -182,57 +182,9 @@ that they start and exit cleanly. Examples are any .qml files under the examples/ or demos/ directory that start with a lower case letter. */ -#define THREADS 5 - -struct Example { -public: - Example() : result(Unknown) {} - - enum Result { Pass, Unknown, Fail }; - Result result; - QString file; - QString qmlruntime; - - void run(); -}; - -void Example::run() +void tst_examples::examples_data() { - QFileInfo fi(file); - QFileInfo dir(fi.path()); - QString script = SRCDIR "/data/"+dir.baseName()+"/"+fi.baseName(); - QFileInfo testdata(script+".qml"); - QStringList arguments; - arguments << "-script" << (testdata.exists() ? script : QLatin1String(SRCDIR "/data/dummytest")) - << "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure" - << file; -#ifdef Q_WS_QWS - arguments << "-qws"; -#endif - - QProcess p; - p.start(qmlruntime, arguments); - if (!p.waitForFinished()) { - result = Fail; - return; - } - - if (p.exitStatus() != QProcess::NormalExit || p.exitCode() != 0) - qWarning() << p.readAllStandardOutput() << p.readAllStandardError(); - - if (p.exitStatus() != QProcess::NormalExit || - p.exitCode() != 0) { - result = Fail; - return; - } else { - result = Pass; - return; - } -} - -void tst_examples::examples() -{ - QThreadPool::globalInstance()->setMaxThreadCount(5); + QTest::addColumn<QString>("file"); QString examples = QLatin1String(SRCDIR) + "/../../../../demos/declarative/"; QString demos = QLatin1String(SRCDIR) + "/../../../../examples/declarative/"; @@ -243,38 +195,31 @@ void tst_examples::examples() files << findQmlFiles(QDir(demos)); files << findQmlFiles(QDir(snippets)); - QList<Example> tests; - - for (int ii = 0; ii < files.count(); ++ii) { - Example e; - e.file = files.at(ii); - e.qmlruntime = qmlruntime; - tests << e; - } + foreach (const QString &file, files) + QTest::newRow(qPrintable(file)) << file; +} - QFutureSynchronizer<void> sync; +static void silentErrorsMsgHandler(QtMsgType, const char *) +{ +} - for (int ii = 0; ii < tests.count(); ++ii) { - Example *e = &tests[ii]; - QFuture<void> r = QtConcurrent::run(e, &Example::run); - sync.addFuture(r); - } +void tst_examples::examples() +{ + QFETCH(QString, file); - sync.waitForFinished(); + QDeclarativeViewer viewer; - QStringList failures; - for (int ii = 0; ii < tests.count(); ++ii) { - if (tests.at(ii).result != Example::Pass) - failures << QDir::cleanPath(tests.at(ii).file); - } + QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler); + QVERIFY(viewer.open(file)); + qInstallMsgHandler(old); - if (failures.count()) { - QString error("Failed examples: "); - error += failures.join(", "); + if (viewer.view()->status() == QDeclarativeView::Error) + qWarning() << viewer.view()->errors(); - QFAIL(qPrintable(error)); - } + QCOMPARE(viewer.view()->status(), QDeclarativeView::Ready); + viewer.show(); + QTest::qWaitForWindowShown(&viewer); } QTEST_MAIN(tst_examples) diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp index 0f03527..8621239 100644 --- a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp +++ b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp @@ -121,10 +121,10 @@ void tst_qdeclarativeborderimage::imageSource_data() QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << ""; QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false - << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) "; + << "QML BorderImage (file::2:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString(); QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true - << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; + << "QML BorderImage (file::2:1) Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; } void tst_qdeclarativeborderimage::imageSource() diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp index 35cffdc..851460f 100644 --- a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp +++ b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp @@ -172,8 +172,8 @@ void tst_qdeclarativecontext::parentContext() delete ctxt2; ctxt2 = 0; QCOMPARE(ctxt->parentContext(), engine->rootContext()); - QCOMPARE(ctxt3->parentContext(), ctxt2); - QCOMPARE(ctxt4->parentContext(), ctxt2); + QCOMPARE(ctxt3->parentContext(), (QDeclarativeContext *)0); + QCOMPARE(ctxt4->parentContext(), (QDeclarativeContext *)0); QCOMPARE(ctxt5->parentContext(), ctxt); QCOMPARE(ctxt6->parentContext(), engine->rootContext()); QCOMPARE(ctxt7->parentContext(), engine->rootContext()); @@ -181,9 +181,9 @@ void tst_qdeclarativecontext::parentContext() delete engine; engine = 0; QCOMPARE(ctxt->parentContext(), (QDeclarativeContext *)0); - QCOMPARE(ctxt3->parentContext(), ctxt2); - QCOMPARE(ctxt4->parentContext(), ctxt2); - QCOMPARE(ctxt5->parentContext(), ctxt); + QCOMPARE(ctxt3->parentContext(), (QDeclarativeContext *)0); + QCOMPARE(ctxt4->parentContext(), (QDeclarativeContext *)0); + QCOMPARE(ctxt5->parentContext(), (QDeclarativeContext *)0); QCOMPARE(ctxt6->parentContext(), (QDeclarativeContext *)0); QCOMPARE(ctxt7->parentContext(), (QDeclarativeContext *)0); diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 35b4d99..098ac36 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -1382,7 +1382,6 @@ void tst_qdeclarativeecmascript::callQtInvokables() o.reset(); { QScriptValue ret = engine->evaluate("object.method_NoArgs_QPointF()"); - QVERIFY(ret.isVariant()); QCOMPARE(ret.toVariant(), QVariant(QPointF(123, 4.5))); QCOMPARE(o.error(), false); QCOMPARE(o.invoked(), 3); diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index 53c208e..854bcdd 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -124,13 +124,14 @@ void tst_qdeclarativeimage::imageSource_data() QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << 120.0 << 120.0 << false << false << ""; QTest::newRow("local async") << QUrl::fromLocalFile(SRCDIR "/data/colors1.png").toString() << 120.0 << 120.0 << false << true << ""; QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << 0.0 << 0.0 << false - << false << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) "; + << false << "QML Image (file::2:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString(); QTest::newRow("local async not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() << 0.0 << 0.0 << false - << true << "\"Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() + "\" "; + << true << "QML Image (file::2:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString(); QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << ""; QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << ""; - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true << false - << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; + QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true + << false << "QML Image (file::2:1) Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; + } void tst_qdeclarativeimage::imageSource() diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp index 162c266..aca951b 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -96,9 +96,10 @@ void tst_qdeclarativeimageprovider::imageSource_data() QTest::newRow("exists") << "image://test/exists.png" << "" << QSize(100,100) << ""; QTest::newRow("scaled") << "image://test/exists.png" << "sourceSize: \"80x30\"" << QSize(80,30) << ""; QTest::newRow("missing") << "image://test/no-such-file.png" << "" << QSize() - << "\"Failed to get image from provider: image://test/no-such-file.png\" "; + << "QML Image (file::2:1) Failed to get image from provider: image://test/no-such-file.png"; QTest::newRow("unknown provider") << "image://bogus/exists.png" << "" << QSize() - << "\"Failed to get image from provider: image://bogus/exists.png\" "; + << "QML Image (file::2:1) Failed to get image from provider: image://bogus/exists.png"; + } void tst_qdeclarativeimageprovider::imageSource() @@ -157,7 +158,8 @@ void tst_qdeclarativeimageprovider::removeProvider() QCOMPARE(obj->width(), 100.0); // remove the provider and confirm - QString error("\"Failed to get image from provider: image://test2/exists2.png\" "); + QString error("QML Image (file::2:1) Failed to get image from provider: image://test2/exists2.png"); + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); engine.removeImageProvider("test2"); diff --git a/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml b/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml new file mode 100644 index 0000000..e5a7cf8 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml @@ -0,0 +1,8 @@ +import Test 1.0 +import Qt 4.6 + +MyQmlObject { + property int a: Math.max(10, 9) + property int b: 11 + Component.onDestruction: console.log("Destruction " + a + " " + b); +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt new file mode 100644 index 0000000..3348494 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt @@ -0,0 +1 @@ +4:5:Cannot assign to non-existent property "onDestroyed" diff --git a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml new file mode 100644 index 0000000..4eab50a --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +QtObject { + onDestroyed: print("Hello World!") +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml b/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml new file mode 100644 index 0000000..7ebae7b --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml @@ -0,0 +1,17 @@ +import Test 1.0 +import Qt 4.6 + +MyTypeObject { + // We set a and b to ensure that onCompleted is executed after bindings and + // constants have been assigned + property int a: Math.min(6, 7) + Component.onDestruction: console.log("Destruction " + a + " " + nestedObject.b) + + objectProperty: OnDestructionType { + qmlobjectProperty: MyQmlObject { + id: nestedObject + property int b: 10 + Component.onDestruction: console.log("Destruction " + a + " " + nestedObject.b) + } + } +} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 7c327c2..8feab32 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -113,6 +113,7 @@ private slots: void i18n(); void i18n_data(); void onCompleted(); + void onDestruction(); void scriptString(); void defaultPropertyListOrder(); void declaredPropertyValues(); @@ -329,6 +330,7 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false; QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false; QTest::newRow("enumTypes") << "enumTypes.qml" << "enumTypes.errors.txt" << false; + QTest::newRow("destroyedSignal") << "destroyedSignal.qml" << "destroyedSignal.errors.txt" << false; } @@ -1049,6 +1051,20 @@ void tst_qdeclarativelanguage::onCompleted() QVERIFY(object != 0); } +// Check that the Component::onDestruction attached property works +void tst_qdeclarativelanguage::onDestruction() +{ + QDeclarativeComponent component(&engine, TEST_FILE("onDestruction.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10"); + QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10"); + QTest::ignoreMessage(QtDebugMsg, "Destruction 10 11"); + delete object; +} + // Check that assignments to QDeclarativeScriptString properties work void tst_qdeclarativelanguage::scriptString() { diff --git a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp index f2ccf80..0cc13ad 100644 --- a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp +++ b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp @@ -126,19 +126,20 @@ void tst_qdeclarativepixmapcache::single() QFETCH(bool, exists); QFETCH(bool, neterror); + QString expectedError; if (neterror) { - QString expected = "\"Error downloading " + target.toString() + " - server replied: Not found\" "; - QTest::ignoreMessage(QtWarningMsg, expected.toLatin1()); + expectedError = "Error downloading " + target.toString() + " - server replied: Not found"; } else if (!exists) { - QString expected = "Cannot open QUrl( \"" + target.toString() + "\" ) "; - QTest::ignoreMessage(QtWarningMsg, expected.toLatin1()); + expectedError = "Cannot open: " + target.toString(); } QPixmap pixmap; QVERIFY(pixmap.width() <= 0); // Check Qt assumption - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(target, &pixmap); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(target, &pixmap, &errorString); if (incache) { + QCOMPARE(errorString, expectedError); if (exists) { QVERIFY(status == QDeclarativePixmapReply::Ready); QVERIFY(pixmap.width() > 0); @@ -156,13 +157,15 @@ void tst_qdeclarativepixmapcache::single() QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(getter.gotslot); + QString errorString; if (exists) { - QVERIFY(QDeclarativePixmapCache::get(target, &pixmap) == QDeclarativePixmapReply::Ready); + QVERIFY(QDeclarativePixmapCache::get(target, &pixmap, &errorString) == QDeclarativePixmapReply::Ready); QVERIFY(pixmap.width() > 0); } else { - QVERIFY(QDeclarativePixmapCache::get(target, &pixmap) == QDeclarativePixmapReply::Error); + QVERIFY(QDeclarativePixmapCache::get(target, &pixmap, &errorString) == QDeclarativePixmapReply::Error); QVERIFY(pixmap.width() <= 0); } + QCOMPARE(errorString, expectedError); } QCOMPARE(QDeclarativePixmapCache::pendingRequests(), 0); @@ -236,7 +239,8 @@ void tst_qdeclarativepixmapcache::parallel() for (int i=0; i<targets.count(); ++i) { QUrl target = targets.at(i); QPixmap pixmap; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(target, &pixmap); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(target, &pixmap, &errorString); QDeclarativePixmapReply *reply = 0; QVERIFY(status != QDeclarativePixmapReply::Error); if (status != QDeclarativePixmapReply::Error && status != QDeclarativePixmapReply::Ready) @@ -273,7 +277,8 @@ void tst_qdeclarativepixmapcache::parallel() } else { QVERIFY(getters[i]->gotslot); QPixmap pixmap; - QVERIFY(QDeclarativePixmapCache::get(targets[i], &pixmap) == QDeclarativePixmapReply::Ready); + QString errorString; + QVERIFY(QDeclarativePixmapCache::get(targets[i], &pixmap, &errorString) == QDeclarativePixmapReply::Ready); QVERIFY(pixmap.width() > 0); } delete getters[i]; diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 53640d0..edb4a32 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -871,10 +871,10 @@ void tst_qdeclarativetext::embeddedImages_data() QTest::addColumn<QString>("error"); QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocal.qml") << ""; QTest::newRow("local-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml") - << "\"Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/http/notexists.png").toString() + "\" "; + << "QML Text ("+QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml").toString()+":3:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/http/notexists.png").toString(); QTest::newRow("remote") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemote.qml") << ""; QTest::newRow("remote-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml") - << "\"Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found\" "; + << "QML Text ("+QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml").toString()+":3:1) Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found"; } void tst_qdeclarativetext::embeddedImages() @@ -897,10 +897,14 @@ void tst_qdeclarativetext::embeddedImages() QTRY_COMPARE(textObject->resourcesLoading(), 0); + QPixmap pm(SRCDIR "/data/http/exists.png"); if (error.isEmpty()) { - QPixmap pm(SRCDIR "/data/http/exists.png"); QCOMPARE(textObject->width(), double(pm.width())); QCOMPARE(textObject->height(), double(pm.height())); + } else { + QVERIFY(16 != pm.width()); // check test is effective + QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon + QCOMPARE(textObject->height(), 16.0); } } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml new file mode 100644 index 0000000..185e7ba --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml @@ -0,0 +1,17 @@ +import Test 1.0 +import Qt 4.6 + +MyTypeObject { + property bool test1: false; + property bool test2: false; + + Component.onCompleted: { + var a = method(); + + test1 = (a.width == 13) + test2 = (a.height == 14) + + size = a; + } +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h index 9057b4f..dd13429 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h +++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h @@ -129,6 +129,9 @@ public: signals: void changed(); void runScript(); + +public slots: + QSize method() { return QSize(13, 14); } }; QML_DECLARE_TYPE(MyTypeObject); diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index e653abf..b733b10 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -79,6 +79,7 @@ private slots: void cppClasses(); void enums(); void conflictingBindings(); + void returnValues(); private: QDeclarativeEngine engine; @@ -763,6 +764,19 @@ void tst_qdeclarativevaluetypes::conflictingBindings() } } +void tst_qdeclarativevaluetypes::returnValues() +{ + QDeclarativeComponent component(&engine, TEST_FILE("returnValues.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), true); + QCOMPARE(object->property("size").toSize(), QSize(13, 14)); + + delete object; +} + QTEST_MAIN(tst_qdeclarativevaluetypes) #include "tst_qdeclarativevaluetypes.moc" diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp index 638c810..2a42d6d 100644 --- a/tests/auto/qftp/tst_qftp.cpp +++ b/tests/auto/qftp/tst_qftp.cpp @@ -123,6 +123,8 @@ private slots: void doneSignal(); void queueMoreCommandsInDoneSlot(); + void qtbug7359Crash(); + protected slots: void stateChanged( int ); void listInfo( const QUrlInfo & ); @@ -2052,6 +2054,30 @@ void tst_QFtp::cdUpSlot(bool error) } } +void tst_QFtp::qtbug7359Crash() +{ + QFtp ftp; + ftp.connectToHost("127.0.0.1"); + + QTime t; + int elapsed; + + t.start(); + while ((elapsed = t.elapsed()) < 200) + QCoreApplication::processEvents(QEventLoop::AllEvents, 200 - elapsed); + + ftp.close(); + t.restart(); + while ((elapsed = t.elapsed()) < 1000) + QCoreApplication::processEvents(QEventLoop::AllEvents, 1000 - elapsed); + + ftp.connectToHost("127.0.0.1"); + + t.restart(); + while ((elapsed = t.elapsed()) < 2000) + QCoreApplication::processEvents(QEventLoop::AllEvents, 2000 - elapsed); +} + QTEST_MAIN(tst_QFtp) #include "tst_qftp.moc" diff --git a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp index 3a3ea79..f86ba63 100644 --- a/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp +++ b/tests/auto/qhttpsocketengine/tst_qhttpsocketengine.cpp @@ -641,7 +641,7 @@ void tst_QHttpSocketEngine::downloadBigFile() QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState); - QVERIFY(tmpSocket->write("GET /mediumfile HTTP/1.0\r\n") > 0); + QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(tmpSocket->write("Host: ") > 0); QVERIFY(tmpSocket->write(hostName.data()) > 0); QVERIFY(tmpSocket->write("\r\n") > 0); diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index d2181f8..f5c32cd 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -123,6 +123,7 @@ private slots: void taskQTBUG_435_deselectOnViewportClick(); void taskQTBUG_2678_spacingAndWrappedText(); void taskQTBUG_5877_skippingItemInPageDownUp(); + void taskQTBUG_9455_wrongScrollbarRanges(); }; // Testing get/set functions @@ -1941,5 +1942,34 @@ void tst_QListView::taskQTBUG_5877_skippingItemInPageDownUp() } } +class ListView_9455 : public QListView +{ +public: + QSize contentsSize() const + { + return QListView::contentsSize(); + } +}; + +void tst_QListView::taskQTBUG_9455_wrongScrollbarRanges() +{ + QStringList list; + const int nrItems = 8; + for (int i = 0; i < nrItems; i++) + list << QString().sprintf("item %d", i); + + QStringListModel model(list); + ListView_9455 w; + w.setModel(&model); + w.setViewMode(QListView::IconMode); + w.resize(116, 132); + w.setMovement(QListView::Static); + const int spacing = 40; + w.setSpacing(spacing); + w.show(); + QTest::qWaitForWindowShown(&w); + QCOMPARE(w.verticalScrollBar()->maximum(), w.contentsSize().height() - w.viewport()->geometry().height()); +} + QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index dd497b0..ff79c09 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -4113,7 +4113,7 @@ public slots: } } void startOne() { - QUrl url = "http://" + QtNetworkSettings::serverName() + "/gif/fluke.gif"; + QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/fluke.gif"; QNetworkRequest request(url); QNetworkReply *reply = manager.get(request); reply->setParent(this); diff --git a/tests/auto/qscriptengine/qscriptengine.pro b/tests/auto/qscriptengine/qscriptengine.pro index dd058a4..7d0f5d0 100644 --- a/tests/auto/qscriptengine/qscriptengine.pro +++ b/tests/auto/qscriptengine/qscriptengine.pro @@ -1,6 +1,7 @@ load(qttest_p4) QT = core gui script SOURCES += tst_qscriptengine.cpp +RESOURCES += qscriptengine.qrc wince* { DEFINES += SRCDIR=\\\"./\\\" diff --git a/tests/auto/qscriptengine/qscriptengine.qrc b/tests/auto/qscriptengine/qscriptengine.qrc new file mode 100644 index 0000000..b87f985 --- /dev/null +++ b/tests/auto/qscriptengine/qscriptengine.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>translations/translatable_la.qm</file> +</qresource> +</RCC> diff --git a/tests/auto/qscriptengine/translatable.js b/tests/auto/qscriptengine/translatable.js new file mode 100644 index 0000000..0c948e7 --- /dev/null +++ b/tests/auto/qscriptengine/translatable.js @@ -0,0 +1,7 @@ +qsTr("One"); +qsTranslate("FooContext", "Two"); + +var greeting_strings = [ + QT_TR_NOOP("Hello"), + QT_TRANSLATE_NOOP("FooContext", "Goodbye") +]; diff --git a/tests/auto/qscriptengine/translations/translatable_la.qm b/tests/auto/qscriptengine/translations/translatable_la.qm Binary files differnew file mode 100644 index 0000000..03fcc52 --- /dev/null +++ b/tests/auto/qscriptengine/translations/translatable_la.qm diff --git a/tests/auto/qscriptengine/translations/translatable_la.ts b/tests/auto/qscriptengine/translations/translatable_la.ts new file mode 100644 index 0000000..3f631de --- /dev/null +++ b/tests/auto/qscriptengine/translations/translatable_la.ts @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0" language="nb_NO"> +<context> + <name>FooContext</name> + <message> + <location filename="translatable.js" line="2"/> + <source>Two</source> + <translation>To</translation> + </message> + <message> + <location filename="translatable.js" line="6"/> + <source>Goodbye</source> + <translation>Farvel</translation> + </message> +</context> +<context> + <name>translatable</name> + <message> + <location filename="translatable.js" line="1"/> + <source>One</source> + <translation>En</translation> + </message> + <message> + <location filename="translatable.js" line="5"/> + <source>Hello</source> + <translation>Hallo</translation> + </message> + <message> + <source>Goodbye</source> + <translation type="obsolete">Farvel</translation> + </message> +</context> +</TS> diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 25d8e3df..96043f9 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -155,6 +155,7 @@ private slots: void incDecNonObjectProperty(); void installTranslatorFunctions_data(); void installTranslatorFunctions(); + void translateScript(); void functionScopes(); void nativeFunctionScopes(); void evaluateProgram(); @@ -4335,6 +4336,45 @@ void tst_QScriptEngine::installTranslatorFunctions() } } +void tst_QScriptEngine::translateScript() +{ + QScriptEngine engine; + + QTranslator translator; + translator.load(":/translations/translatable_la"); + QCoreApplication::instance()->installTranslator(&translator); + engine.installTranslatorFunctions(); + + QString fileName = QString::fromLatin1("translatable.js"); + // Top-level + QCOMPARE(engine.evaluate("qsTr('One')", fileName).toString(), QString::fromLatin1("En")); + QCOMPARE(engine.evaluate("qsTr('Hello')", fileName).toString(), QString::fromLatin1("Hallo")); + // From function + QCOMPARE(engine.evaluate("(function() { return qsTr('One'); })()", fileName).toString(), QString::fromLatin1("En")); + QCOMPARE(engine.evaluate("(function() { return qsTr('Hello'); })()", fileName).toString(), QString::fromLatin1("Hallo")); + // From eval + QCOMPARE(engine.evaluate("eval('qsTr(\\'One\\')')", fileName).toString(), QString::fromLatin1("En")); + QCOMPARE(engine.evaluate("eval('qsTr(\\'Hello\\')')", fileName).toString(), QString::fromLatin1("Hallo")); + + QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Two')", fileName).toString(), QString::fromLatin1("To")); + QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'Goodbye')", fileName).toString(), QString::fromLatin1("Farvel")); + // From eval + QCOMPARE(engine.evaluate("eval('qsTranslate(\\'FooContext\\', \\'Two\\')')", fileName).toString(), QString::fromLatin1("To")); + QCOMPARE(engine.evaluate("eval('qsTranslate(\\'FooContext\\', \\'Goodbye\\')')", fileName).toString(), QString::fromLatin1("Farvel")); + + // Don't exist in translation + QCOMPARE(engine.evaluate("qsTr('Three')", fileName).toString(), QString::fromLatin1("Three")); + QCOMPARE(engine.evaluate("qsTranslate('FooContext', 'So long')", fileName).toString(), QString::fromLatin1("So long")); + QCOMPARE(engine.evaluate("qsTranslate('BarContext', 'Goodbye')", fileName).toString(), QString::fromLatin1("Goodbye")); + + // From C++ + // There is no context, but it shouldn't crash + QCOMPARE(engine.globalObject().property("qsTr").call( + QScriptValue(), QScriptValueList() << "One").toString(), QString::fromLatin1("One")); + + QCoreApplication::instance()->removeTranslator(&translator); +} + void tst_QScriptEngine::functionScopes() { QScriptEngine eng; diff --git a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp index a679765..8f0cbc3 100644 --- a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -780,7 +780,7 @@ void tst_QSocks5SocketEngine::downloadBigFile() QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState); - QVERIFY(tmpSocket->write("GET /mediumfile HTTP/1.0\r\n") > 0); + QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(tmpSocket->write("HOST: ") > 0); QVERIFY(tmpSocket->write(hostName.data()) > 0); QVERIFY(tmpSocket->write("\r\n") > 0); diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index 5a209c2..cd512a1 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -1117,7 +1117,7 @@ void tst_QTcpSocket::downloadBigFile() QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState); - QVERIFY(tmpSocket->write("GET /mediumfile HTTP/1.0\r\n") > 0); + QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(tmpSocket->write("HOST: ") > 0); QVERIFY(tmpSocket->write(hostName.data()) > 0); QVERIFY(tmpSocket->write("\r\n") > 0); |