From 630d3b9ba9da12331c72406c311ca26f88c6061a Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 4 Nov 2009 13:21:38 +1000 Subject: Fix test after rename. --- tests/auto/declarative/declarative.pro | 2 +- .../declarative/qfxpixmapcache/data/exists.png | Bin 2738 -> 0 bytes .../declarative/qfxpixmapcache/data/exists1.png | Bin 2738 -> 0 bytes .../declarative/qfxpixmapcache/data/exists2.png | Bin 2738 -> 0 bytes .../declarative/qfxpixmapcache/qfxpixmapcache.pro | 9 - .../qfxpixmapcache/tst_qfxpixmapcache.cpp | 275 --------------------- .../declarative/qmlpixmapcache/data/exists.png | Bin 0 -> 2738 bytes .../declarative/qmlpixmapcache/data/exists1.png | Bin 0 -> 2738 bytes .../declarative/qmlpixmapcache/data/exists2.png | Bin 0 -> 2738 bytes .../declarative/qmlpixmapcache/qmlpixmapcache.pro | 9 + .../qmlpixmapcache/tst_qmlpixmapcache.cpp | 275 +++++++++++++++++++++ 11 files changed, 285 insertions(+), 285 deletions(-) delete mode 100644 tests/auto/declarative/qfxpixmapcache/data/exists.png delete mode 100644 tests/auto/declarative/qfxpixmapcache/data/exists1.png delete mode 100644 tests/auto/declarative/qfxpixmapcache/data/exists2.png delete mode 100644 tests/auto/declarative/qfxpixmapcache/qfxpixmapcache.pro delete mode 100644 tests/auto/declarative/qfxpixmapcache/tst_qfxpixmapcache.cpp create mode 100644 tests/auto/declarative/qmlpixmapcache/data/exists.png create mode 100644 tests/auto/declarative/qmlpixmapcache/data/exists1.png create mode 100644 tests/auto/declarative/qmlpixmapcache/data/exists2.png create mode 100644 tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro create mode 100644 tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 321e91b..7e3bf1e 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -10,7 +10,7 @@ SUBDIRS += anchors \ numberformatter \ pathview \ qfxloader \ - qfxpixmapcache \ + qmlpixmapcache \ qfxtextedit \ qfxtextinput \ qfxwebview \ diff --git a/tests/auto/declarative/qfxpixmapcache/data/exists.png b/tests/auto/declarative/qfxpixmapcache/data/exists.png deleted file mode 100644 index 399bd0b..0000000 Binary files a/tests/auto/declarative/qfxpixmapcache/data/exists.png and /dev/null differ diff --git a/tests/auto/declarative/qfxpixmapcache/data/exists1.png b/tests/auto/declarative/qfxpixmapcache/data/exists1.png deleted file mode 100644 index 399bd0b..0000000 Binary files a/tests/auto/declarative/qfxpixmapcache/data/exists1.png and /dev/null differ diff --git a/tests/auto/declarative/qfxpixmapcache/data/exists2.png b/tests/auto/declarative/qfxpixmapcache/data/exists2.png deleted file mode 100644 index 399bd0b..0000000 Binary files a/tests/auto/declarative/qfxpixmapcache/data/exists2.png and /dev/null differ diff --git a/tests/auto/declarative/qfxpixmapcache/qfxpixmapcache.pro b/tests/auto/declarative/qfxpixmapcache/qfxpixmapcache.pro deleted file mode 100644 index 218eeff..0000000 --- a/tests/auto/declarative/qfxpixmapcache/qfxpixmapcache.pro +++ /dev/null @@ -1,9 +0,0 @@ -load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative -QT += network -macx:CONFIG -= app_bundle - -SOURCES += tst_qfxpixmapcache.cpp - -# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -# LIBS += -lgcov diff --git a/tests/auto/declarative/qfxpixmapcache/tst_qfxpixmapcache.cpp b/tests/auto/declarative/qfxpixmapcache/tst_qfxpixmapcache.cpp deleted file mode 100644 index 88fbdab..0000000 --- a/tests/auto/declarative/qfxpixmapcache/tst_qfxpixmapcache.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include - -// These don't let normal people run tests! -//#include "../network-settings.h" - -class tst_qfxpixmapcache : public QObject -{ - Q_OBJECT -public: - tst_qfxpixmapcache() : - thisfile("file://" __FILE__) - { - } - -private slots: - void single(); - void single_data(); - void parallel(); - void parallel_data(); - -private: - QmlEngine engine; - QUrl thisfile; -}; - - -static int slotters=0; - -class Slotter : public QObject -{ - Q_OBJECT -public: - Slotter() - { - gotslot = false; - slotters++; - } - bool gotslot; - -public slots: - void got() - { - gotslot = true; - --slotters; - if (slotters==0) - QTestEventLoop::instance().exitLoop(); - } -}; - -#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML -static const bool localfile_optimized = true; -#else -static const bool localfile_optimized = false; -#endif - -void tst_qfxpixmapcache::single_data() -{ - // Note, since QmlGraphicsPixmapCache is shared, tests affect each other! - // so use different files fore all test functions. - - QTest::addColumn("target"); - QTest::addColumn("incache"); - QTest::addColumn("exists"); - QTest::addColumn("neterror"); - - // File URLs are optimized - QTest::newRow("local") << thisfile.resolved(QUrl("data/exists.png")) << localfile_optimized << true << false; - QTest::newRow("local") << thisfile.resolved(QUrl("data/notexists.png")) << localfile_optimized << false << false; - QTest::newRow("remote") << QUrl("http://qt.nokia.com/logo.png") << false << true << false; - QTest::newRow("remote") << QUrl("http://qt.nokia.com/thereisnologo.png") << false << false << true; -} - -void tst_qfxpixmapcache::single() -{ - QFETCH(QUrl, target); - QFETCH(bool, incache); - QFETCH(bool, exists); - QFETCH(bool, neterror); - - if (neterror) { - QString expected = "Network error loading QUrl( \"" - +target.toString()+"\" ) \"Error downloading " - +target.toString()+" - server replied: Not Found\" "; - QTest::ignoreMessage(QtWarningMsg, expected.toLatin1()); - } - - QPixmap pixmap; - QVERIFY(pixmap.width() <= 0); // Check Qt assumption - QNetworkReply *reply= QmlGraphicsPixmapCache::get(&engine, target, &pixmap); - - if (incache) { - QVERIFY(!reply); - if (exists) - QVERIFY(pixmap.width() > 0); - else - QVERIFY(pixmap.width() <= 0); - } else { - QVERIFY(reply); - QVERIFY(pixmap.width() <= 0); - - Slotter getter; - connect(reply, SIGNAL(finished()), &getter, SLOT(got())); - QTestEventLoop::instance().enterLoop(10); - QVERIFY(!QTestEventLoop::instance().timeout()); - QVERIFY(getter.gotslot); - if (exists) { - QVERIFY(QmlGraphicsPixmapCache::find(target, &pixmap)); - QVERIFY(pixmap.width() > 0); - } else { - QVERIFY(!QmlGraphicsPixmapCache::find(target, &pixmap)); - QVERIFY(pixmap.width() <= 0); - } - } - - QCOMPARE(QmlGraphicsPixmapCache::pendingRequests(), 0); -} - -void tst_qfxpixmapcache::parallel_data() -{ - // Note, since QmlGraphicsPixmapCache is shared, tests affect each other! - // so use different files fore all test functions. - - QTest::addColumn("target1"); - QTest::addColumn("target2"); - QTest::addColumn("incache"); - QTest::addColumn("cancel"); // which one to cancel - QTest::addColumn("requests"); - - QTest::newRow("local") - << thisfile.resolved(QUrl("data/exists1.png")) - << thisfile.resolved(QUrl("data/exists2.png")) - << (localfile_optimized ? 2 : 0) - << -1 - << (localfile_optimized ? 0 : 2) - ; - - QTest::newRow("remote") - << QUrl("http://qt.nokia.com/images/template/checkbox-on.png") - << QUrl("http://qt.nokia.com/images/products/qt-logo/image_tile") - << 0 - << -1 - << 2 - ; - - QTest::newRow("remoteagain") - << QUrl("http://qt.nokia.com/images/template/checkbox-on.png") - << QUrl("http://qt.nokia.com/images/products/qt-logo/image_tile") - << 2 - << -1 - << 0 - ; - - QTest::newRow("remotecopy") - << QUrl("http://qt.nokia.com/images/template/checkbox-off.png") - << QUrl("http://qt.nokia.com/images/template/checkbox-off.png") - << 0 - << -1 - << 1 - ; - - QTest::newRow("remotecopycancel") - << QUrl("http://qt.nokia.com/rounded_block_bg.png") - << QUrl("http://qt.nokia.com/rounded_block_bg.png") - << 0 - << 0 - << 1 - ; -} - -void tst_qfxpixmapcache::parallel() -{ - QFETCH(QUrl, target1); - QFETCH(QUrl, target2); - QFETCH(int, incache); - QFETCH(int, cancel); - QFETCH(int, requests); - - QList targets; - targets << target1 << target2; - - QList replies; - QList getters; - for (int i=0; i 0); - getters.append(0); - } else { - QVERIFY(pixmap.width() <= 0); - getters.append(new Slotter); - connect(reply, SIGNAL(finished()), getters[i], SLOT(got())); - } - } - - QCOMPARE(incache+slotters, targets.count()); - QCOMPARE(QmlGraphicsPixmapCache::pendingRequests(), requests); - - if (cancel >= 0) { - QmlGraphicsPixmapCache::cancelGet(targets.at(cancel), getters[cancel]); - slotters--; - } - - if (slotters) { - QTestEventLoop::instance().enterLoop(10); - QVERIFY(!QTestEventLoop::instance().timeout()); - } - - for (int i=0; igotslot); - } else { - QVERIFY(getters[i]->gotslot); - QPixmap pixmap; - QVERIFY(QmlGraphicsPixmapCache::find(targets[i], &pixmap)); - QVERIFY(pixmap.width() > 0); - } - delete getters[i]; - } - } - - QCOMPARE(QmlGraphicsPixmapCache::pendingRequests(), 0); -} - -QTEST_MAIN(tst_qfxpixmapcache) - -#include "tst_qfxpixmapcache.moc" diff --git a/tests/auto/declarative/qmlpixmapcache/data/exists.png b/tests/auto/declarative/qmlpixmapcache/data/exists.png new file mode 100644 index 0000000..399bd0b Binary files /dev/null and b/tests/auto/declarative/qmlpixmapcache/data/exists.png differ diff --git a/tests/auto/declarative/qmlpixmapcache/data/exists1.png b/tests/auto/declarative/qmlpixmapcache/data/exists1.png new file mode 100644 index 0000000..399bd0b Binary files /dev/null and b/tests/auto/declarative/qmlpixmapcache/data/exists1.png differ diff --git a/tests/auto/declarative/qmlpixmapcache/data/exists2.png b/tests/auto/declarative/qmlpixmapcache/data/exists2.png new file mode 100644 index 0000000..399bd0b Binary files /dev/null and b/tests/auto/declarative/qmlpixmapcache/data/exists2.png differ diff --git a/tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro b/tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro new file mode 100644 index 0000000..423fa2f --- /dev/null +++ b/tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro @@ -0,0 +1,9 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +QT += network +macx:CONFIG -= app_bundle + +SOURCES += tst_qmlpixmapcache.cpp + +# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage +# LIBS += -lgcov diff --git a/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp b/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp new file mode 100644 index 0000000..88d9df5 --- /dev/null +++ b/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp @@ -0,0 +1,275 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include + +// These don't let normal people run tests! +//#include "../network-settings.h" + +class tst_qmlpixmapcache : public QObject +{ + Q_OBJECT +public: + tst_qmlpixmapcache() : + thisfile("file://" __FILE__) + { + } + +private slots: + void single(); + void single_data(); + void parallel(); + void parallel_data(); + +private: + QmlEngine engine; + QUrl thisfile; +}; + + +static int slotters=0; + +class Slotter : public QObject +{ + Q_OBJECT +public: + Slotter() + { + gotslot = false; + slotters++; + } + bool gotslot; + +public slots: + void got() + { + gotslot = true; + --slotters; + if (slotters==0) + QTestEventLoop::instance().exitLoop(); + } +}; + +#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML +static const bool localfile_optimized = true; +#else +static const bool localfile_optimized = false; +#endif + +void tst_qmlpixmapcache::single_data() +{ + // Note, since QmlPixmapCache is shared, tests affect each other! + // so use different files fore all test functions. + + QTest::addColumn("target"); + QTest::addColumn("incache"); + QTest::addColumn("exists"); + QTest::addColumn("neterror"); + + // File URLs are optimized + QTest::newRow("local") << thisfile.resolved(QUrl("data/exists.png")) << localfile_optimized << true << false; + QTest::newRow("local") << thisfile.resolved(QUrl("data/notexists.png")) << localfile_optimized << false << false; + QTest::newRow("remote") << QUrl("http://qt.nokia.com/logo.png") << false << true << false; + QTest::newRow("remote") << QUrl("http://qt.nokia.com/thereisnologo.png") << false << false << true; +} + +void tst_qmlpixmapcache::single() +{ + QFETCH(QUrl, target); + QFETCH(bool, incache); + QFETCH(bool, exists); + QFETCH(bool, neterror); + + if (neterror) { + QString expected = "Network error loading QUrl( \"" + +target.toString()+"\" ) \"Error downloading " + +target.toString()+" - server replied: Not Found\" "; + QTest::ignoreMessage(QtWarningMsg, expected.toLatin1()); + } + + QPixmap pixmap; + QVERIFY(pixmap.width() <= 0); // Check Qt assumption + QNetworkReply *reply= QmlPixmapCache::get(&engine, target, &pixmap); + + if (incache) { + QVERIFY(!reply); + if (exists) + QVERIFY(pixmap.width() > 0); + else + QVERIFY(pixmap.width() <= 0); + } else { + QVERIFY(reply); + QVERIFY(pixmap.width() <= 0); + + Slotter getter; + connect(reply, SIGNAL(finished()), &getter, SLOT(got())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(getter.gotslot); + if (exists) { + QVERIFY(QmlPixmapCache::find(target, &pixmap)); + QVERIFY(pixmap.width() > 0); + } else { + QVERIFY(!QmlPixmapCache::find(target, &pixmap)); + QVERIFY(pixmap.width() <= 0); + } + } + + QCOMPARE(QmlPixmapCache::pendingRequests(), 0); +} + +void tst_qmlpixmapcache::parallel_data() +{ + // Note, since QmlPixmapCache is shared, tests affect each other! + // so use different files fore all test functions. + + QTest::addColumn("target1"); + QTest::addColumn("target2"); + QTest::addColumn("incache"); + QTest::addColumn("cancel"); // which one to cancel + QTest::addColumn("requests"); + + QTest::newRow("local") + << thisfile.resolved(QUrl("data/exists1.png")) + << thisfile.resolved(QUrl("data/exists2.png")) + << (localfile_optimized ? 2 : 0) + << -1 + << (localfile_optimized ? 0 : 2) + ; + + QTest::newRow("remote") + << QUrl("http://qt.nokia.com/images/template/checkbox-on.png") + << QUrl("http://qt.nokia.com/images/products/qt-logo/image_tile") + << 0 + << -1 + << 2 + ; + + QTest::newRow("remoteagain") + << QUrl("http://qt.nokia.com/images/template/checkbox-on.png") + << QUrl("http://qt.nokia.com/images/products/qt-logo/image_tile") + << 2 + << -1 + << 0 + ; + + QTest::newRow("remotecopy") + << QUrl("http://qt.nokia.com/images/template/checkbox-off.png") + << QUrl("http://qt.nokia.com/images/template/checkbox-off.png") + << 0 + << -1 + << 1 + ; + + QTest::newRow("remotecopycancel") + << QUrl("http://qt.nokia.com/rounded_block_bg.png") + << QUrl("http://qt.nokia.com/rounded_block_bg.png") + << 0 + << 0 + << 1 + ; +} + +void tst_qmlpixmapcache::parallel() +{ + QFETCH(QUrl, target1); + QFETCH(QUrl, target2); + QFETCH(int, incache); + QFETCH(int, cancel); + QFETCH(int, requests); + + QList targets; + targets << target1 << target2; + + QList replies; + QList getters; + for (int i=0; i 0); + getters.append(0); + } else { + QVERIFY(pixmap.width() <= 0); + getters.append(new Slotter); + connect(reply, SIGNAL(finished()), getters[i], SLOT(got())); + } + } + + QCOMPARE(incache+slotters, targets.count()); + QCOMPARE(QmlPixmapCache::pendingRequests(), requests); + + if (cancel >= 0) { + QmlPixmapCache::cancelGet(targets.at(cancel), getters[cancel]); + slotters--; + } + + if (slotters) { + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + } + + for (int i=0; igotslot); + } else { + QVERIFY(getters[i]->gotslot); + QPixmap pixmap; + QVERIFY(QmlPixmapCache::find(targets[i], &pixmap)); + QVERIFY(pixmap.width() > 0); + } + delete getters[i]; + } + } + + QCOMPARE(QmlPixmapCache::pendingRequests(), 0); +} + +QTEST_MAIN(tst_qmlpixmapcache) + +#include "tst_qmlpixmapcache.moc" -- cgit v0.12 From 99fe55b3b4c031f1288f9e1c16455ca08663059c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 4 Nov 2009 14:15:20 +1000 Subject: Start on QmlXmlListModel autotest. --- tests/auto/declarative/declarative.pro | 1 + .../declarative/qmlxmllistmodel/data/model.qml | 10 +++ .../declarative/qmlxmllistmodel/data/model.xml | 56 +++++++++++++++ .../qmlxmllistmodel/qmlxmllistmodel.pro | 7 ++ .../qmlxmllistmodel/tst_qmlxmllistmodel.cpp | 80 ++++++++++++++++++++++ 5 files changed, 154 insertions(+) create mode 100644 tests/auto/declarative/qmlxmllistmodel/data/model.qml create mode 100644 tests/auto/declarative/qmlxmllistmodel/data/model.xml create mode 100644 tests/auto/declarative/qmlxmllistmodel/qmlxmllistmodel.pro create mode 100644 tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 7e3bf1e..f09d6cf 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -28,6 +28,7 @@ SUBDIRS += anchors \ qmlmetatype \ qmlpropertymap \ qmltimer \ + qmlxmllistmodel \ repeater \ sql \ states \ diff --git a/tests/auto/declarative/qmlxmllistmodel/data/model.qml b/tests/auto/declarative/qmlxmllistmodel/data/model.qml new file mode 100644 index 0000000..199a447 --- /dev/null +++ b/tests/auto/declarative/qmlxmllistmodel/data/model.qml @@ -0,0 +1,10 @@ +import Qt 4.6 + +XmlListModel { + source: "model.xml" + query: "/ListModel/ListElement" + XmlRole { name: "name"; query: "name/string()" } + XmlRole { name: "type"; query: "type/string()" } + XmlRole { name: "age"; query: "age/number()" } + XmlRole { name: "size"; query: "size/string()" } +} diff --git a/tests/auto/declarative/qmlxmllistmodel/data/model.xml b/tests/auto/declarative/qmlxmllistmodel/data/model.xml new file mode 100644 index 0000000..f1fe742 --- /dev/null +++ b/tests/auto/declarative/qmlxmllistmodel/data/model.xml @@ -0,0 +1,56 @@ + + + Polly + Parrot + 12 + Small + + + Penny + Turtle + 4 + Small + + + Warren + Rabbit + 2 + Small + + + Spot + Dog + 9 + Medium + + + Whiskers + Cat + 2 + Medium + + + Joey + Kangaroo + 1 + Medium + + + Kimba + Bunny + 65 + Large + + + Rover + Dog + 5 + Large + + + Tiny + Elephant + 15 + Large + + diff --git a/tests/auto/declarative/qmlxmllistmodel/qmlxmllistmodel.pro b/tests/auto/declarative/qmlxmllistmodel/qmlxmllistmodel.pro new file mode 100644 index 0000000..462723e --- /dev/null +++ b/tests/auto/declarative/qmlxmllistmodel/qmlxmllistmodel.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui +macx:CONFIG -= app_bundle + +SOURCES += tst_qmlxmllistmodel.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp b/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp new file mode 100644 index 0000000..0fc9006 --- /dev/null +++ b/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include +#include +#include +#include +#include "../../../shared/util.h" + +class tst_qmlxmllistmodel : public QObject + +{ + Q_OBJECT +public: + tst_qmlxmllistmodel() {} + +private slots: + void buildModel(); + +private: + QmlEngine engine; +}; + +void tst_qmlxmllistmodel::buildModel() +{ + QmlComponent component(&engine, QUrl("file://" SRCDIR "/data/model.qml")); + QmlXmlListModel *listModel = qobject_cast(component.create()); + QVERIFY(listModel != 0); + QTRY_COMPARE(listModel->count(), 9); + + QList roles; + roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3; + QHash data = listModel->data(3, roles); + QVERIFY(data.count() == 4); + QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Spot")); + QCOMPARE(data.value(Qt::UserRole+1).toString(), QLatin1String("Dog")); + QCOMPARE(data.value(Qt::UserRole+2).toInt(), 9); + QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String("Medium")); +} + +QTEST_MAIN(tst_qmlxmllistmodel) + +#include "tst_qmlxmllistmodel.moc" -- cgit v0.12 From 2c6d4485b7a0c8c819a225e56ca9a43ab4fcccf4 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 4 Nov 2009 14:15:46 +1000 Subject: Doc. --- src/declarative/qml/qmlmetaproperty.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 8385352..f340612 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -558,6 +558,9 @@ QmlAbstractBinding *QmlMetaProperty::binding() const Ownership of \a newBinding transfers to QML. Ownership of the return value is assumed by the caller. + + \a flags is passed through to the binding and is used for the initial update (when + the binding sets the intial value, it will use these flags for the write). */ QmlAbstractBinding * QmlMetaProperty::setBinding(QmlAbstractBinding *newBinding, QmlMetaProperty::WriteFlags flags) const -- cgit v0.12 From 69d6a95a4c12bacb700f3d7ccc9188d3cc22c8ae Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 4 Nov 2009 14:34:22 +1000 Subject: more autotests --- .../declarative/animations/color-animation.qml | 5 +- .../qmlgraphicstext/tst_qmlgraphicstext.cpp | 257 ++++++++++++++++++--- 2 files changed, 226 insertions(+), 36 deletions(-) diff --git a/examples/declarative/animations/color-animation.qml b/examples/declarative/animations/color-animation.qml index edb0659..54608c7 100644 --- a/examples/declarative/animations/color-animation.qml +++ b/examples/declarative/animations/color-animation.qml @@ -31,10 +31,7 @@ Item { Item { width: parent.width; height: 2 * parent.height transformOrigin: Item.Center - rotation: SequentialAnimation { - running: true; repeat: true - NumberAnimation { from: 0; to: 360; duration: 10000 } - } + rotation: NumberAnimation { from: 0; to: 360; duration: 10000; running: true; repeat: true } Image { source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter transformOrigin: Item.Center; rotation: -3 * parent.rotation diff --git a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp index 1a90575..3e86cab 100644 --- a/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp +++ b/tests/auto/declarative/qmlgraphicstext/tst_qmlgraphicstext.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include class tst_qmlgraphicstext : public QObject @@ -67,6 +68,15 @@ private slots: void color(); void smooth(); + // QmlFontValueType + void weight(); + void underline(); + void overline(); + void strikeout(); + void capitalization(); + void letterSpacing(); + void wordSpacing(); + private: QStringList standard; QStringList richText; @@ -88,54 +98,54 @@ private: tst_qmlgraphicstext::tst_qmlgraphicstext() { standard << "the quick brown fox jumped over the lazy dog" - << "the quick brown fox\n jumped over the lazy dog"; + << "the quick brown fox\n jumped over the lazy dog"; richText << "the quick brown fox jumped over the lazy dog" - << "the quick brown fox
jumped over the lazy dog
"; + << "the quick brown fox
jumped over the lazy dog
"; horizontalAlignmentmentStrings << "AlignLeft" - << "AlignRight" - << "AlignHCenter"; + << "AlignRight" + << "AlignHCenter"; verticalAlignmentmentStrings << "AlignTop" - << "AlignBottom" - << "AlignVCenter"; + << "AlignBottom" + << "AlignVCenter"; horizontalAlignmentments << Qt::AlignLeft - << Qt::AlignRight - << Qt::AlignHCenter; + << Qt::AlignRight + << Qt::AlignHCenter; verticalAlignmentments << Qt::AlignTop - << Qt::AlignBottom - << Qt::AlignVCenter; + << Qt::AlignBottom + << Qt::AlignVCenter; styleStrings << "Normal" - << "Outline" - << "Raised" - << "Sunken"; + << "Outline" + << "Raised" + << "Sunken"; styles << QmlGraphicsText::Normal - << QmlGraphicsText::Outline - << QmlGraphicsText::Raised - << QmlGraphicsText::Sunken; + << QmlGraphicsText::Outline + << QmlGraphicsText::Raised + << QmlGraphicsText::Sunken; colorStrings << "aliceblue" - << "antiquewhite" - << "aqua" - << "darkkhaki" - << "darkolivegreen" - << "dimgray" - << "palevioletred" - << "lightsteelblue" - << "#000000" - << "#AAAAAA" - << "#FFFFFF" - << "#2AC05F"; - // - // need a different test to do alpha channel test - // << "#AA0011DD" - // << "#00F16B11"; - // + << "antiquewhite" + << "aqua" + << "darkkhaki" + << "darkolivegreen" + << "dimgray" + << "palevioletred" + << "lightsteelblue" + << "#000000" + << "#AAAAAA" + << "#FFFFFF" + << "#2AC05F"; + // + // need a different test to do alpha channel test + // << "#AA0011DD" + // << "#00F16B11"; + // } void tst_qmlgraphicstext::text() @@ -353,6 +363,8 @@ void tst_qmlgraphicstext::verticalAlignment() QString componentStr = "import Qt 4.6\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j)); } } @@ -365,6 +377,7 @@ void tst_qmlgraphicstext::verticalAlignment() QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + QVERIFY(textObject != 0); QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j)); } } @@ -528,6 +541,186 @@ void tst_qmlgraphicstext::smooth() } } +void tst_qmlgraphicstext::weight() +{ + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().weight(), (int)QmlFontValueType::Normal); + } + { + QString componentStr = "import Qt 4.6\nText { font.weight: \"Bold\"; text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().weight(), (int)QmlFontValueType::Bold); + } +} + +void tst_qmlgraphicstext::underline() +{ + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().underline(), false); + } + { + QString componentStr = "import Qt 4.6\nText { font.underline: true; text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().underline(), true); + } +} + +void tst_qmlgraphicstext::overline() +{ + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().overline(), false); + } + { + QString componentStr = "import Qt 4.6\nText { font.overline: true; text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().overline(), true); + } +} + +void tst_qmlgraphicstext::strikeout() +{ + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().strikeOut(), false); + } + { + QString componentStr = "import Qt 4.6\nText { font.strikeout: true; text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().strikeOut(), true); + } +} + +void tst_qmlgraphicstext::capitalization() +{ + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::MixedCase); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::AllUppercase); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::AllLowercase); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::SmallCaps); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE((int)textObject->font().capitalization(), (int)QmlFontValueType::Capitalize); + } +} + +void tst_qmlgraphicstext::letterSpacing() +{ + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().letterSpacing(), 0.0); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.letterSpacing: -50 }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().letterSpacing(), -50.); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.letterSpacing: 200 }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().letterSpacing(), 200.); + } +} + +void tst_qmlgraphicstext::wordSpacing() +{ + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\" }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().wordSpacing(), 0.0); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.wordSpacing: -50 }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().wordSpacing(), -50.); + } + { + QString componentStr = "import Qt 4.6\nText { text: \"Hello world!\"; font.wordSpacing: 200 }"; + QmlComponent textComponent(&engine, componentStr.toLatin1(), QUrl("file://")); + QmlGraphicsText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->font().wordSpacing(), 200.); + } +} + QTEST_MAIN(tst_qmlgraphicstext) #include "tst_qmlgraphicstext.moc" -- cgit v0.12