summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-11-04 04:34:48 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-11-04 04:34:48 (GMT)
commita5e66c8c02db19a26fcb8378a1d61302ad2d2c5f (patch)
treeb5f299023f40385efe7c40eaff1bb4d626e8eeb8 /tests
parent69d6a95a4c12bacb700f3d7ccc9188d3cc22c8ae (diff)
parent47889bd63d8a14b10984576998a69d8a4cd0a8d0 (diff)
downloadQt-a5e66c8c02db19a26fcb8378a1d61302ad2d2c5f.zip
Qt-a5e66c8c02db19a26fcb8378a1d61302ad2d2c5f.tar.gz
Qt-a5e66c8c02db19a26fcb8378a1d61302ad2d2c5f.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/declarative.pro3
-rw-r--r--tests/auto/declarative/qmlpixmapcache/data/exists.png (renamed from tests/auto/declarative/qfxpixmapcache/data/exists.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qmlpixmapcache/data/exists1.png (renamed from tests/auto/declarative/qfxpixmapcache/data/exists1.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qmlpixmapcache/data/exists2.png (renamed from tests/auto/declarative/qfxpixmapcache/data/exists2.png)bin2738 -> 2738 bytes
-rw-r--r--tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro (renamed from tests/auto/declarative/qfxpixmapcache/qfxpixmapcache.pro)2
-rw-r--r--tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp (renamed from tests/auto/declarative/qfxpixmapcache/tst_qfxpixmapcache.cpp)40
-rw-r--r--tests/auto/declarative/qmlqt/data/closestangle.qml12
-rw-r--r--tests/auto/declarative/qmlqt/tst_qmlqt.cpp18
-rw-r--r--tests/auto/declarative/qmlxmllistmodel/data/model.qml10
-rw-r--r--tests/auto/declarative/qmlxmllistmodel/data/model.xml56
-rw-r--r--tests/auto/declarative/qmlxmllistmodel/qmlxmllistmodel.pro7
-rw-r--r--tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp80
12 files changed, 206 insertions, 22 deletions
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index 321e91b..f09d6cf 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 \
@@ -28,6 +28,7 @@ SUBDIRS += anchors \
qmlmetatype \
qmlpropertymap \
qmltimer \
+ qmlxmllistmodel \
repeater \
sql \
states \
diff --git a/tests/auto/declarative/qfxpixmapcache/data/exists.png b/tests/auto/declarative/qmlpixmapcache/data/exists.png
index 399bd0b..399bd0b 100644
--- a/tests/auto/declarative/qfxpixmapcache/data/exists.png
+++ b/tests/auto/declarative/qmlpixmapcache/data/exists.png
Binary files differ
diff --git a/tests/auto/declarative/qfxpixmapcache/data/exists1.png b/tests/auto/declarative/qmlpixmapcache/data/exists1.png
index 399bd0b..399bd0b 100644
--- a/tests/auto/declarative/qfxpixmapcache/data/exists1.png
+++ b/tests/auto/declarative/qmlpixmapcache/data/exists1.png
Binary files differ
diff --git a/tests/auto/declarative/qfxpixmapcache/data/exists2.png b/tests/auto/declarative/qmlpixmapcache/data/exists2.png
index 399bd0b..399bd0b 100644
--- a/tests/auto/declarative/qfxpixmapcache/data/exists2.png
+++ b/tests/auto/declarative/qmlpixmapcache/data/exists2.png
Binary files differ
diff --git a/tests/auto/declarative/qfxpixmapcache/qfxpixmapcache.pro b/tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro
index 218eeff..423fa2f 100644
--- a/tests/auto/declarative/qfxpixmapcache/qfxpixmapcache.pro
+++ b/tests/auto/declarative/qmlpixmapcache/qmlpixmapcache.pro
@@ -3,7 +3,7 @@ contains(QT_CONFIG,declarative): QT += declarative
QT += network
macx:CONFIG -= app_bundle
-SOURCES += tst_qfxpixmapcache.cpp
+SOURCES += tst_qmlpixmapcache.cpp
# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
# LIBS += -lgcov
diff --git a/tests/auto/declarative/qfxpixmapcache/tst_qfxpixmapcache.cpp b/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp
index 88fbdab..88d9df5 100644
--- a/tests/auto/declarative/qfxpixmapcache/tst_qfxpixmapcache.cpp
+++ b/tests/auto/declarative/qmlpixmapcache/tst_qmlpixmapcache.cpp
@@ -40,18 +40,18 @@
****************************************************************************/
#include <qtest.h>
#include <QtTest/QtTest>
-#include <private/qmlgraphicspixmapcache_p.h>
+#include <private/qmlpixmapcache_p.h>
#include <QtDeclarative/qmlengine.h>
#include <QNetworkReply>
// These don't let normal people run tests!
//#include "../network-settings.h"
-class tst_qfxpixmapcache : public QObject
+class tst_qmlpixmapcache : public QObject
{
Q_OBJECT
public:
- tst_qfxpixmapcache() :
+ tst_qmlpixmapcache() :
thisfile("file://" __FILE__)
{
}
@@ -97,9 +97,9 @@ static const bool localfile_optimized = true;
static const bool localfile_optimized = false;
#endif
-void tst_qfxpixmapcache::single_data()
+void tst_qmlpixmapcache::single_data()
{
- // Note, since QmlGraphicsPixmapCache is shared, tests affect each other!
+ // Note, since QmlPixmapCache is shared, tests affect each other!
// so use different files fore all test functions.
QTest::addColumn<QUrl>("target");
@@ -114,7 +114,7 @@ void tst_qfxpixmapcache::single_data()
QTest::newRow("remote") << QUrl("http://qt.nokia.com/thereisnologo.png") << false << false << true;
}
-void tst_qfxpixmapcache::single()
+void tst_qmlpixmapcache::single()
{
QFETCH(QUrl, target);
QFETCH(bool, incache);
@@ -130,7 +130,7 @@ void tst_qfxpixmapcache::single()
QPixmap pixmap;
QVERIFY(pixmap.width() <= 0); // Check Qt assumption
- QNetworkReply *reply= QmlGraphicsPixmapCache::get(&engine, target, &pixmap);
+ QNetworkReply *reply= QmlPixmapCache::get(&engine, target, &pixmap);
if (incache) {
QVERIFY(!reply);
@@ -148,20 +148,20 @@ void tst_qfxpixmapcache::single()
QVERIFY(!QTestEventLoop::instance().timeout());
QVERIFY(getter.gotslot);
if (exists) {
- QVERIFY(QmlGraphicsPixmapCache::find(target, &pixmap));
+ QVERIFY(QmlPixmapCache::find(target, &pixmap));
QVERIFY(pixmap.width() > 0);
} else {
- QVERIFY(!QmlGraphicsPixmapCache::find(target, &pixmap));
+ QVERIFY(!QmlPixmapCache::find(target, &pixmap));
QVERIFY(pixmap.width() <= 0);
}
}
- QCOMPARE(QmlGraphicsPixmapCache::pendingRequests(), 0);
+ QCOMPARE(QmlPixmapCache::pendingRequests(), 0);
}
-void tst_qfxpixmapcache::parallel_data()
+void tst_qmlpixmapcache::parallel_data()
{
- // Note, since QmlGraphicsPixmapCache is shared, tests affect each other!
+ // Note, since QmlPixmapCache is shared, tests affect each other!
// so use different files fore all test functions.
QTest::addColumn<QUrl>("target1");
@@ -211,7 +211,7 @@ void tst_qfxpixmapcache::parallel_data()
;
}
-void tst_qfxpixmapcache::parallel()
+void tst_qmlpixmapcache::parallel()
{
QFETCH(QUrl, target1);
QFETCH(QUrl, target2);
@@ -227,7 +227,7 @@ void tst_qfxpixmapcache::parallel()
for (int i=0; i<targets.count(); ++i) {
QUrl target = targets.at(i);
QPixmap pixmap;
- QNetworkReply *reply = QmlGraphicsPixmapCache::get(&engine, target, &pixmap);
+ QNetworkReply *reply = QmlPixmapCache::get(&engine, target, &pixmap);
replies.append(reply);
if (!reply) {
QVERIFY(pixmap.width() > 0);
@@ -240,10 +240,10 @@ void tst_qfxpixmapcache::parallel()
}
QCOMPARE(incache+slotters, targets.count());
- QCOMPARE(QmlGraphicsPixmapCache::pendingRequests(), requests);
+ QCOMPARE(QmlPixmapCache::pendingRequests(), requests);
if (cancel >= 0) {
- QmlGraphicsPixmapCache::cancelGet(targets.at(cancel), getters[cancel]);
+ QmlPixmapCache::cancelGet(targets.at(cancel), getters[cancel]);
slotters--;
}
@@ -260,16 +260,16 @@ void tst_qfxpixmapcache::parallel()
} else {
QVERIFY(getters[i]->gotslot);
QPixmap pixmap;
- QVERIFY(QmlGraphicsPixmapCache::find(targets[i], &pixmap));
+ QVERIFY(QmlPixmapCache::find(targets[i], &pixmap));
QVERIFY(pixmap.width() > 0);
}
delete getters[i];
}
}
- QCOMPARE(QmlGraphicsPixmapCache::pendingRequests(), 0);
+ QCOMPARE(QmlPixmapCache::pendingRequests(), 0);
}
-QTEST_MAIN(tst_qfxpixmapcache)
+QTEST_MAIN(tst_qmlpixmapcache)
-#include "tst_qfxpixmapcache.moc"
+#include "tst_qmlpixmapcache.moc"
diff --git a/tests/auto/declarative/qmlqt/data/closestangle.qml b/tests/auto/declarative/qmlqt/data/closestangle.qml
new file mode 100644
index 0000000..8f999e3
--- /dev/null
+++ b/tests/auto/declarative/qmlqt/data/closestangle.qml
@@ -0,0 +1,12 @@
+import Qt 4.6
+
+Object {
+ property var testSame: Qt.closestAngle(0,1)
+ property var testLess: Qt.closestAngle(0,-359)
+ property var testMore: Qt.closestAngle(0,361)
+ property var testFail: Qt.closestAngle(0)
+ property var test5: Qt.closestAngle(0,1,2)
+ property var test6: Qt.closestAngle(123.45465768,1.11)
+ property var test7: Qt.closestAngle(-3.1415,1.11)
+}
+
diff --git a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp
index 10402ae..cc9b94d 100644
--- a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp
+++ b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp
@@ -64,6 +64,7 @@ private slots:
void lighter();
void darker();
void tint();
+ void closestAngle();
void playSound();
void openUrlExternally();
@@ -249,6 +250,23 @@ void tst_qmlqt::tint()
delete object;
}
+void tst_qmlqt::closestAngle()
+{
+ QmlComponent component(&engine, TEST_FILE("closestangle.qml"));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<qreal>(object->property("testSame")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("testLess")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("testMore")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("testFail")), 0.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("test5")), 1.0);
+ QCOMPARE(qvariant_cast<qreal>(object->property("test6")), 1.11);
+ QCOMPARE(qvariant_cast<qreal>(object->property("test7")), 1.11);
+
+ delete object;
+}
+
void tst_qmlqt::playSound()
{
QEXPECT_FAIL("", "How do we test this?", Abort);
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 @@
+<ListModel>
+ <ListElement>
+ <name>Polly</name>
+ <type>Parrot</type>
+ <age>12</age>
+ <size>Small</size>
+ </ListElement>
+ <ListElement>
+ <name>Penny</name>
+ <type>Turtle</type>
+ <age>4</age>
+ <size>Small</size>
+ </ListElement>
+ <ListElement>
+ <name>Warren</name>
+ <type>Rabbit</type>
+ <age>2</age>
+ <size>Small</size>
+ </ListElement>
+ <ListElement>
+ <name>Spot</name>
+ <type>Dog</type>
+ <age>9</age>
+ <size>Medium</size>
+ </ListElement>
+ <ListElement>
+ <name>Whiskers</name>
+ <type>Cat</type>
+ <age>2</age>
+ <size>Medium</size>
+ </ListElement>
+ <ListElement>
+ <name>Joey</name>
+ <type>Kangaroo</type>
+ <age>1</age>
+ <size>Medium</size>
+ </ListElement>
+ <ListElement>
+ <name>Kimba</name>
+ <type>Bunny</type>
+ <age>65</age>
+ <size>Large</size>
+ </ListElement>
+ <ListElement>
+ <name>Rover</name>
+ <type>Dog</type>
+ <age>5</age>
+ <size>Large</size>
+ </ListElement>
+ <ListElement>
+ <name>Tiny</name>
+ <type>Elephant</type>
+ <age>15</age>
+ <size>Large</size>
+ </ListElement>
+</ListModel>
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 <qtest.h>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <private/qmlxmllistmodel_p.h>
+#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<QmlXmlListModel*>(component.create());
+ QVERIFY(listModel != 0);
+ QTRY_COMPARE(listModel->count(), 9);
+
+ QList<int> roles;
+ roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3;
+ QHash<int, QVariant> 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"