diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2012-02-28 16:32:45 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-02 07:22:53 +0100 |
commit | 4dde313139960d706a747d0c3260c774c3966c3d (patch) | |
tree | 4be5e09dbb9a4a9b4edb8321b7a2164b67dbc6b0 /tests | |
parent | 04fb631120590c55812a11a576dca48dafec6aea (diff) |
Add QColor support to v4.
Change-Id: I033e92007f894d45695ea48d7f954d534a2fadee
Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/v4/data/colorType.qml | 18 | ||||
-rw-r--r-- | tests/auto/declarative/v4/tst_v4.cpp | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/declarative/v4/data/colorType.qml b/tests/auto/declarative/v4/data/colorType.qml new file mode 100644 index 0000000000..f6a98a4a3e --- /dev/null +++ b/tests/auto/declarative/v4/data/colorType.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +QtObject { + property bool useMyColor: true + property color myColor: "red" + property color myOtherColor: "green" + + property color test1: useMyColor ? myColor : myOtherColor + property color test2: useMyColor ? "red" : "green" + property color test3: useMyColor ? myColor : "green" + + property bool test4: !myColor ? false : true + + property bool test5: myColor != "red" + property bool test6: myColor == "#ff0000" + property bool test7: myColor != "#00ff00" +} + diff --git a/tests/auto/declarative/v4/tst_v4.cpp b/tests/auto/declarative/v4/tst_v4.cpp index 927dc0f082..99e3f3255f 100644 --- a/tests/auto/declarative/v4/tst_v4.cpp +++ b/tests/auto/declarative/v4/tst_v4.cpp @@ -45,6 +45,7 @@ #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> #include <QtCore/qdebug.h> +#include <QtGui/qcolor.h> #include <private/qv4compiler_p.h> @@ -73,6 +74,7 @@ private slots: void stringComparison(); void unaryMinus(); void unaryPlus(); + void colorType(); private: QDeclarativeEngine engine; @@ -348,6 +350,22 @@ void tst_v4::unaryPlus() delete o; } +void tst_v4::colorType() +{ + QDeclarativeComponent component(&engine, testFileUrl("colorType.qml")); + + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test1").value<QColor>(), QColor("red")); + QCOMPARE(o->property("test2").value<QColor>(), QColor("red")); + QCOMPARE(o->property("test3").value<QColor>(), QColor("red")); + QCOMPARE(o->property("test4").toBool(), true); + QCOMPARE(o->property("test5").toBool(), true); + QCOMPARE(o->property("test6").toBool(), true); + QCOMPARE(o->property("test7").toBool(), true); + delete o; +} + QTEST_MAIN(tst_v4) #include "tst_v4.moc" |