diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qmlqt/data/darker.qml | 8 | ||||
-rw-r--r-- | tests/auto/declarative/qmlqt/data/enums.qml | 9 | ||||
-rw-r--r-- | tests/auto/declarative/qmlqt/data/hsla.qml | 11 | ||||
-rw-r--r-- | tests/auto/declarative/qmlqt/data/lighter.qml | 7 | ||||
-rw-r--r-- | tests/auto/declarative/qmlqt/data/point.qml | 9 | ||||
-rw-r--r-- | tests/auto/declarative/qmlqt/data/rect.qml | 9 | ||||
-rw-r--r-- | tests/auto/declarative/qmlqt/data/rgba.qml | 10 | ||||
-rw-r--r-- | tests/auto/declarative/qmlqt/data/size.qml | 11 | ||||
-rw-r--r-- | tests/auto/declarative/qmlqt/data/tint.qml | 9 | ||||
-rw-r--r-- | tests/auto/declarative/qmlqt/data/vector.qml | 8 | ||||
-rw-r--r-- | tests/auto/declarative/qmlqt/qmlqt.pro | 9 | ||||
-rw-r--r-- | tests/auto/declarative/qmlqt/tst_qmlqt.cpp | 264 |
12 files changed, 364 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlqt/data/darker.qml b/tests/auto/declarative/qmlqt/data/darker.qml new file mode 100644 index 0000000..6369e8f --- /dev/null +++ b/tests/auto/declarative/qmlqt/data/darker.qml @@ -0,0 +1,8 @@ +import Qt 4.6 + +Object { + property var test1: Qt.darker(Qt.rgba(1, 0.8, 0.3)) + property var test2: Qt.darker() + property var test3: Qt.darker(Qt.rgba(1, 0.8, 0.3), 10) +} + diff --git a/tests/auto/declarative/qmlqt/data/enums.qml b/tests/auto/declarative/qmlqt/data/enums.qml new file mode 100644 index 0000000..f87886e --- /dev/null +++ b/tests/auto/declarative/qmlqt/data/enums.qml @@ -0,0 +1,9 @@ +import Qt 4.6 + +Object { + property int test1: Qt.Key_Escape + property int test2: Qt.DescendingOrder + property int test3: Qt.ElideMiddle + property int test4: Qt.AlignRight +} + diff --git a/tests/auto/declarative/qmlqt/data/hsla.qml b/tests/auto/declarative/qmlqt/data/hsla.qml new file mode 100644 index 0000000..fedb56a --- /dev/null +++ b/tests/auto/declarative/qmlqt/data/hsla.qml @@ -0,0 +1,11 @@ +import Qt 4.6 + +Object { + property color test1: Qt.hsla(1, 0, 0, 0.8); + property color test2: Qt.hsla(1, 0.5, 0.3); + property color test3: Qt.hsla(1, 1); + property color test4: Qt.hsla(1, 1, 1, 1, 1); + property color test5: Qt.hsla(1.2, 1, 1); + property color test6: Qt.hsla(-0.1, 1, 1); +} + diff --git a/tests/auto/declarative/qmlqt/data/lighter.qml b/tests/auto/declarative/qmlqt/data/lighter.qml new file mode 100644 index 0000000..6c888e7 --- /dev/null +++ b/tests/auto/declarative/qmlqt/data/lighter.qml @@ -0,0 +1,7 @@ +import Qt 4.6 + +Object { + property var test1: Qt.lighter(Qt.rgba(1, 0.8, 0.3)) + property var test2: Qt.lighter() + property var test3: Qt.lighter(Qt.rgba(1, 0.8, 0.3), 10) +} diff --git a/tests/auto/declarative/qmlqt/data/point.qml b/tests/auto/declarative/qmlqt/data/point.qml new file mode 100644 index 0000000..582cb00 --- /dev/null +++ b/tests/auto/declarative/qmlqt/data/point.qml @@ -0,0 +1,9 @@ +import Qt 4.6 + +Object { + property var test1: Qt.point(19, 34); + property var test2: Qt.point(-3, 109.2); + property var test3: Qt.point(-3); + property var test4: Qt.point(-3, 109.2, 1); +} + diff --git a/tests/auto/declarative/qmlqt/data/rect.qml b/tests/auto/declarative/qmlqt/data/rect.qml new file mode 100644 index 0000000..53d8c38 --- /dev/null +++ b/tests/auto/declarative/qmlqt/data/rect.qml @@ -0,0 +1,9 @@ +import Qt 4.6 + +Object { + property var test1: Qt.rect(10, 13, 100, 109) + property var test2: Qt.rect(-10, 13, 100, 109.6) + property var test3: Qt.rect(10, 13); + property var test4: Qt.rect(10, 13, 100, 109, 10) + property var test5: Qt.rect(10, 13, 100, -109) +} diff --git a/tests/auto/declarative/qmlqt/data/rgba.qml b/tests/auto/declarative/qmlqt/data/rgba.qml new file mode 100644 index 0000000..3fdfe2c --- /dev/null +++ b/tests/auto/declarative/qmlqt/data/rgba.qml @@ -0,0 +1,10 @@ +import Qt 4.6 + +Object { + property color test1: Qt.rgba(1, 0, 0, 0.8); + property color test2: Qt.rgba(1, 0.5, 0.3); + property color test3: Qt.rgba(1, 1); + property color test4: Qt.rgba(1, 1, 1, 1, 1); + property color test5: Qt.rgba(1.2, 1, 1); + property color test6: Qt.rgba(-0.1, 1, 1); +} diff --git a/tests/auto/declarative/qmlqt/data/size.qml b/tests/auto/declarative/qmlqt/data/size.qml new file mode 100644 index 0000000..f0d2e81 --- /dev/null +++ b/tests/auto/declarative/qmlqt/data/size.qml @@ -0,0 +1,11 @@ +import Qt 4.6 + +Object { + property var test1: Qt.size(19, 34); + property var test2: Qt.size(3, 109.2); + property var test3: Qt.size(-3, 10); + property var test4: Qt.size(3); + property var test5: Qt.size(3, 109.2, 1); +} + + diff --git a/tests/auto/declarative/qmlqt/data/tint.qml b/tests/auto/declarative/qmlqt/data/tint.qml new file mode 100644 index 0000000..31e67ba --- /dev/null +++ b/tests/auto/declarative/qmlqt/data/tint.qml @@ -0,0 +1,9 @@ +import Qt 4.6 + +Object { + property color test1: Qt.tint("red", "blue"); + property color test2: Qt.tint(Qt.rgba(1, 0, 0), Qt.rgba(0, 0, 0, 0)); + property color test3: Qt.tint("red", Qt.rgba(0, 0, 1, 0.5)); // XXX - what should this be? + property color test4: Qt.tint("red", Qt.rgba(0, 0, 1, 0.5), 10); + property color test5: Qt.tint("red") +} diff --git a/tests/auto/declarative/qmlqt/data/vector.qml b/tests/auto/declarative/qmlqt/data/vector.qml new file mode 100644 index 0000000..b879bd6 --- /dev/null +++ b/tests/auto/declarative/qmlqt/data/vector.qml @@ -0,0 +1,8 @@ +import Qt 4.6 + +Object { + property var test1: Qt.vector3d(1, 0, 0.9); + property var test2: Qt.vector3d(102, -10, -982.1); + property var test3: Qt.vector3d(102, -10); + property var test4: Qt.vector3d(102, -10, -982.1, 10); +} diff --git a/tests/auto/declarative/qmlqt/qmlqt.pro b/tests/auto/declarative/qmlqt/qmlqt.pro new file mode 100644 index 0000000..5e79ea6 --- /dev/null +++ b/tests/auto/declarative/qmlqt/qmlqt.pro @@ -0,0 +1,9 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +SOURCES += tst_qmlqt.cpp +macx:CONFIG -= app_bundle + +DEFINES += SRCDIR=\\\"$$PWD\\\" + +# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage +# LIBS += -lgcov diff --git a/tests/auto/declarative/qmlqt/tst_qmlqt.cpp b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp new file mode 100644 index 0000000..10402ae --- /dev/null +++ b/tests/auto/declarative/qmlqt/tst_qmlqt.cpp @@ -0,0 +1,264 @@ +/**************************************************************************** +** +** 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 <QDebug> +#include <QmlEngine> +#include <QFileInfo> +#include <QmlComponent> +#include <QDir> +#include <QVector3D> + +class tst_qmlqt : public QObject +{ + Q_OBJECT +public: + tst_qmlqt() {} + +private slots: + void enums(); + void rgba(); + void hsla(); + void rect(); + void point(); + void size(); + void vector(); + void lighter(); + void darker(); + void tint(); + void playSound(); + void openUrlExternally(); + +private: + QmlEngine engine; +}; + +inline QUrl TEST_FILE(const QString &filename) +{ + return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); +} + +void tst_qmlqt::enums() +{ + QmlComponent component(&engine, TEST_FILE("enums.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toInt(), (int)Qt::Key_Escape); + QCOMPARE(object->property("test2").toInt(), (int)Qt::DescendingOrder); + QCOMPARE(object->property("test3").toInt(), (int)Qt::ElideMiddle); + QCOMPARE(object->property("test4").toInt(), (int)Qt::AlignRight); + + delete object; +} + +void tst_qmlqt::rgba() +{ + QmlComponent component(&engine, TEST_FILE("rgba.qml")); + + QString warning1 = component.url().toString() + ":6: Unable to assign null to QColor"; + QString warning2 = component.url().toString() + ":7: Unable to assign null to QColor"; + QString warning3 = component.url().toString() + ":8: Unable to assign null to QColor"; + QString warning4 = component.url().toString() + ":9: Unable to assign null to QColor"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + + QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0, 0, 0.8)); + QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0.5, 0.3, 1)); + QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor()); + + delete object; +} + +void tst_qmlqt::hsla() +{ + QmlComponent component(&engine, TEST_FILE("hsla.qml")); + + QString warning1 = component.url().toString() + ":6: Unable to assign null to QColor"; + QString warning2 = component.url().toString() + ":7: Unable to assign null to QColor"; + QString warning3 = component.url().toString() + ":8: Unable to assign null to QColor"; + QString warning4 = component.url().toString() + ":9: Unable to assign null to QColor"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromHslF(1, 0, 0, 0.8)); + QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromHslF(1, 0.5, 0.3, 1)); + QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test6")), QColor()); + + delete object; +} + +void tst_qmlqt::rect() +{ + QmlComponent component(&engine, TEST_FILE("rect.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast<QRectF>(object->property("test1")), QRectF(10, 13, 100, 109)); + QCOMPARE(qvariant_cast<QRectF>(object->property("test2")), QRectF(-10, 13, 100, 109.6)); + QCOMPARE(qvariant_cast<QRectF>(object->property("test3")), QRectF()); + QCOMPARE(qvariant_cast<QRectF>(object->property("test4")), QRectF()); + QCOMPARE(qvariant_cast<QRectF>(object->property("test5")), QRectF()); + + delete object; +} + +void tst_qmlqt::point() +{ + QmlComponent component(&engine, TEST_FILE("point.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast<QPointF>(object->property("test1")), QPointF(19, 34)); + QCOMPARE(qvariant_cast<QPointF>(object->property("test2")), QPointF(-3, 109.2)); + QCOMPARE(qvariant_cast<QPointF>(object->property("test3")), QPointF()); + QCOMPARE(qvariant_cast<QPointF>(object->property("test4")), QPointF()); + + delete object; +} + +void tst_qmlqt::size() +{ + QmlComponent component(&engine, TEST_FILE("size.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast<QSizeF>(object->property("test1")), QSizeF(19, 34)); + QCOMPARE(qvariant_cast<QSizeF>(object->property("test2")), QSizeF(3, 109.2)); + QCOMPARE(qvariant_cast<QSizeF>(object->property("test3")), QSizeF(-3, 10)); + QCOMPARE(qvariant_cast<QSizeF>(object->property("test4")), QSizeF()); + QCOMPARE(qvariant_cast<QSizeF>(object->property("test5")), QSizeF()); + + delete object; +} + +void tst_qmlqt::vector() +{ + QmlComponent component(&engine, TEST_FILE("vector.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast<QVector3D>(object->property("test1")), QVector3D(1, 0, 0.9)); + QCOMPARE(qvariant_cast<QVector3D>(object->property("test2")), QVector3D(102, -10, -982.1)); + QCOMPARE(qvariant_cast<QVector3D>(object->property("test3")), QVector3D()); + QCOMPARE(qvariant_cast<QVector3D>(object->property("test4")), QVector3D()); + + delete object; +} + +void tst_qmlqt::lighter() +{ + QmlComponent component(&engine, TEST_FILE("lighter.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).lighter()); + QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor()); + + delete object; +} + +void tst_qmlqt::darker() +{ + QmlComponent component(&engine, TEST_FILE("darker.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(1, 0.8, 0.3).darker()); + QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor()); + + delete object; +} + +void tst_qmlqt::tint() +{ + QmlComponent component(&engine, TEST_FILE("tint.qml")); + + QString warning1 = component.url().toString() + ":7: Unable to assign null to QColor"; + QString warning2 = component.url().toString() + ":8: Unable to assign null to QColor"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(qvariant_cast<QColor>(object->property("test1")), QColor::fromRgbF(0, 0, 1)); + QCOMPARE(qvariant_cast<QColor>(object->property("test2")), QColor::fromRgbF(1, 0, 0)); + // Fails due to QT-2424 + QCOMPARE(qvariant_cast<QColor>(object->property("test3")), QColor::fromRgbF(1, 0, 0)); + QCOMPARE(qvariant_cast<QColor>(object->property("test4")), QColor()); + QCOMPARE(qvariant_cast<QColor>(object->property("test5")), QColor()); + + delete object; +} + +void tst_qmlqt::playSound() +{ + QEXPECT_FAIL("", "How do we test this?", Abort); +} + +void tst_qmlqt::openUrlExternally() +{ + QEXPECT_FAIL("", "How do we test this?", Abort); +} + +QTEST_MAIN(tst_qmlqt) + +#include "tst_qmlqt.moc" |