aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2011-07-14 15:40:30 +1000
committerQt by Nokia <qt-info@nokia.com>2011-08-18 09:25:04 +0200
commiteaf52673ef38b4d7a14f9fb9f258d8f1c6097401 (patch)
treea607ea443865da0668029725283009cf17d2ffe1 /tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
parent36767e3fe1f0038441ae06ef5b5e1cb19a3738fa (diff)
Add support for a vector4d type in QML
QVector4D is a value-type which is supported but was not able to be constructed using a Qt object function. This commit allows properties of vector4d type to be constructed, and adds a function to the global Qt object and adds unit tests to ensure that it behaves correctly. Task-number: QTBUG-18559 Change-Id: I96509a4f496b644d20fdb1d977d0afe430d89e13 Reviewed-on: http://codereview.qt.nokia.com/1626 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
index 4a9bb4513c..d9cd2b8fdf 100644
--- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
+++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
@@ -72,6 +72,7 @@ private slots:
void point();
void size();
void vector();
+ void vector4d();
void lighter();
void darker();
void tint();
@@ -243,6 +244,26 @@ void tst_qdeclarativeqt::vector()
delete object;
}
+void tst_qdeclarativeqt::vector4d()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("vector4.qml"));
+
+ QString warning1 = component.url().toString() + ":6: Error: Qt.vector4d(): Invalid arguments";
+ QString warning2 = component.url().toString() + ":7: Error: Qt.vector4d(): Invalid arguments";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test1")), QVector4D(1, 0, 0.9, 0.6));
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test2")), QVector4D(102, -10, -982.1, 10));
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test3")), QVector4D());
+ QCOMPARE(qvariant_cast<QVector4D>(object->property("test4")), QVector4D());
+
+ delete object;
+}
+
void tst_qdeclarativeqt::lighter()
{
QDeclarativeComponent component(&engine, TEST_FILE("lighter.qml"));