aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-07-05 16:09:27 +1000
committerQt by Nokia <qt-info@nokia.com>2012-07-11 17:37:55 +0200
commitb5eb3d69b40c4b750a1bbece7be2acbe7cf918e3 (patch)
treef4009d3023d0fa9a511e94e8cc145c222c3b7552 /tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
parentaeb2b05e3cad95164779e8778351b492b0e2fffa (diff)
Allow color to be explicitly compared to a string
Add the Qt.colorEqual() function which compares any combination of two supplied color and string arguments, by converting the string arguments to colors as necessary. Task-number: QTBUG-18754 Change-Id: I75baef9a2edd30a5f8b9cb5e151e4adba6f6a371 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlqt/tst_qqmlqt.cpp')
-rw-r--r--tests/auto/qml/qqmlqt/tst_qqmlqt.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
index 6fd6fc8822..3497fd7aa0 100644
--- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
+++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp
@@ -69,6 +69,7 @@ private slots:
void enums();
void rgba();
void hsla();
+ void colorEqual();
void rect();
void point();
void size();
@@ -162,6 +163,89 @@ void tst_qqmlqt::hsla()
delete object;
}
+void tst_qqmlqt::colorEqual()
+{
+ QQmlComponent component(&engine, testFileUrl("colorEqual.qml"));
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(component.url().toString() + ":6: Error: Qt.colorEqual(): Invalid arguments"));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(component.url().toString() + ":7: Error: Qt.colorEqual(): Invalid arguments"));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(component.url().toString() + ":9: Error: Qt.colorEqual(): Invalid color name"));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(component.url().toString() + ":10: Error: Qt.colorEqual(): Invalid color name"));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(component.url().toString() + ":12: Error: Qt.colorEqual(): Invalid arguments"));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(component.url().toString() + ":13: Error: Qt.colorEqual(): Invalid arguments"));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(component.url().toString() + ":17: Error: Qt.colorEqual(): Invalid arguments"));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(component.url().toString() + ":18: Error: Qt.colorEqual(): Invalid arguments"));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(component.url().toString() + ":34: Error: Qt.colorEqual(): Invalid color name"));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(component.url().toString() + ":35: Error: Qt.colorEqual(): Invalid color name"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1a").toBool(), false);
+ QCOMPARE(object->property("test1b").toBool(), false);
+ QCOMPARE(object->property("test1c").toBool(), false);
+ QCOMPARE(object->property("test1d").toBool(), false);
+ QCOMPARE(object->property("test1e").toBool(), false);
+ QCOMPARE(object->property("test1f").toBool(), false);
+ QCOMPARE(object->property("test1g").toBool(), false);
+ QCOMPARE(object->property("test1h").toBool(), false);
+
+ QCOMPARE(object->property("test2a").toBool(), true);
+ QCOMPARE(object->property("test2b").toBool(), true);
+ QCOMPARE(object->property("test2c").toBool(), true);
+ QCOMPARE(object->property("test2d").toBool(), true);
+ QCOMPARE(object->property("test2e").toBool(), true);
+ QCOMPARE(object->property("test2f").toBool(), true);
+ QCOMPARE(object->property("test2g").toBool(), true);
+ QCOMPARE(object->property("test2h").toBool(), true);
+ QCOMPARE(object->property("test2i").toBool(), false);
+ QCOMPARE(object->property("test2j").toBool(), false);
+ QCOMPARE(object->property("test2k").toBool(), false);
+ QCOMPARE(object->property("test2l").toBool(), false);
+ QCOMPARE(object->property("test2m").toBool(), false);
+ QCOMPARE(object->property("test2n").toBool(), false);
+
+ QCOMPARE(object->property("test3a").toBool(), true);
+ QCOMPARE(object->property("test3b").toBool(), true);
+ QCOMPARE(object->property("test3c").toBool(), true);
+ QCOMPARE(object->property("test3d").toBool(), true);
+ QCOMPARE(object->property("test3e").toBool(), true);
+ QCOMPARE(object->property("test3f").toBool(), true);
+ QCOMPARE(object->property("test3g").toBool(), false);
+ QCOMPARE(object->property("test3h").toBool(), false);
+ QCOMPARE(object->property("test3i").toBool(), true);
+ QCOMPARE(object->property("test3j").toBool(), true);
+ QCOMPARE(object->property("test3k").toBool(), true);
+ QCOMPARE(object->property("test3l").toBool(), true);
+ QCOMPARE(object->property("test3m").toBool(), true);
+ QCOMPARE(object->property("test3n").toBool(), true);
+
+ QCOMPARE(object->property("test4a").toBool(), true);
+ QCOMPARE(object->property("test4b").toBool(), true);
+ QCOMPARE(object->property("test4c").toBool(), false);
+ QCOMPARE(object->property("test4d").toBool(), false);
+ QCOMPARE(object->property("test4e").toBool(), false);
+ QCOMPARE(object->property("test4f").toBool(), false);
+ QCOMPARE(object->property("test4g").toBool(), false);
+ QCOMPARE(object->property("test4h").toBool(), false);
+ QCOMPARE(object->property("test4i").toBool(), false);
+ QCOMPARE(object->property("test4j").toBool(), false);
+
+ QCOMPARE(object->property("test5a").toBool(), true);
+ QCOMPARE(object->property("test5b").toBool(), true);
+ QCOMPARE(object->property("test5c").toBool(), true);
+ QCOMPARE(object->property("test5d").toBool(), false);
+ QCOMPARE(object->property("test5e").toBool(), false);
+
+ QCOMPARE(object->property("test6a").toBool(), true);
+ QCOMPARE(object->property("test6b").toBool(), true);
+ QCOMPARE(object->property("test6c").toBool(), true);
+ QCOMPARE(object->property("test6d").toBool(), false);
+ QCOMPARE(object->property("test6e").toBool(), false);
+
+ delete object;
+}
+
void tst_qqmlqt::rect()
{
QQmlComponent component(&engine, testFileUrl("rect.qml"));