diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-22 03:07:09 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-22 03:07:53 (GMT) |
commit | e6b5d2a4df73aa26812e26daa3199443bd84cc90 (patch) | |
tree | 1c6683e6f4ef92fc8e13f99d3c3045f0833faa82 /tests/auto/declarative/qdeclarativeqt | |
parent | 9a40a3e76171c06d32ab4cadf700f6504dada129 (diff) | |
download | Qt-e6b5d2a4df73aa26812e26daa3199443bd84cc90.zip Qt-e6b5d2a4df73aa26812e26daa3199443bd84cc90.tar.gz Qt-e6b5d2a4df73aa26812e26daa3199443bd84cc90.tar.bz2 |
Autotests and doc
Diffstat (limited to 'tests/auto/declarative/qdeclarativeqt')
-rw-r--r-- | tests/auto/declarative/qdeclarativeqt/data/atob.qml | 7 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeqt/data/btoa.qml | 6 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp | 83 |
3 files changed, 72 insertions, 24 deletions
diff --git a/tests/auto/declarative/qdeclarativeqt/data/atob.qml b/tests/auto/declarative/qdeclarativeqt/data/atob.qml new file mode 100644 index 0000000..8355fa5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeqt/data/atob.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +QtObject { + property string test1: Qt.atob() + property string test2: Qt.atob("SGVsbG8gd29ybGQh") +} + diff --git a/tests/auto/declarative/qdeclarativeqt/data/btoa.qml b/tests/auto/declarative/qdeclarativeqt/data/btoa.qml new file mode 100644 index 0000000..c2993ff --- /dev/null +++ b/tests/auto/declarative/qdeclarativeqt/data/btoa.qml @@ -0,0 +1,6 @@ +import Qt 4.7 + +QtObject { + property string test1: Qt.btoa() + property string test2: Qt.btoa("Hello world!") +} diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 727d74c..f5d5926 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -74,6 +74,8 @@ private slots: void consoleLog(); void formatting(); void isQtObject(); + void btoa(); + void atob(); private: QDeclarativeEngine engine; @@ -102,8 +104,8 @@ void tst_qdeclarativeqt::rgba() { QDeclarativeComponent component(&engine, TEST_FILE("rgba.qml")); - QString warning1 = component.url().toString() + ":6: Error: expected 3 or 4 parameters"; - QString warning2 = component.url().toString() + ":7: Error: expected 3 or 4 parameters"; + QString warning1 = component.url().toString() + ":6: Error: Qt.rgba(): Invalid arguments"; + QString warning2 = component.url().toString() + ":7: Error: Qt.rgba(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -125,8 +127,8 @@ void tst_qdeclarativeqt::hsla() { QDeclarativeComponent component(&engine, TEST_FILE("hsla.qml")); - QString warning1 = component.url().toString() + ":6: Error: expected 3 or 4 parameters"; - QString warning2 = component.url().toString() + ":7: Error: expected 3 or 4 parameters"; + QString warning1 = component.url().toString() + ":6: Error: Qt.hsla(): Invalid arguments"; + QString warning2 = component.url().toString() + ":7: Error: Qt.hsla(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -147,8 +149,8 @@ void tst_qdeclarativeqt::rect() { QDeclarativeComponent component(&engine, TEST_FILE("rect.qml")); - QString warning1 = component.url().toString() + ":6: Error: expected 4 parameters"; - QString warning2 = component.url().toString() + ":7: Error: expected 4 parameters"; + QString warning1 = component.url().toString() + ":6: Error: Qt.rect(): Invalid arguments"; + QString warning2 = component.url().toString() + ":7: Error: Qt.rect(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -168,8 +170,8 @@ void tst_qdeclarativeqt::point() { QDeclarativeComponent component(&engine, TEST_FILE("point.qml")); - QString warning1 = component.url().toString() + ":6: Error: expected 2 parameters"; - QString warning2 = component.url().toString() + ":7: Error: expected 2 parameters"; + QString warning1 = component.url().toString() + ":6: Error: Qt.point(): Invalid arguments"; + QString warning2 = component.url().toString() + ":7: Error: Qt.point(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -188,8 +190,8 @@ void tst_qdeclarativeqt::size() { QDeclarativeComponent component(&engine, TEST_FILE("size.qml")); - QString warning1 = component.url().toString() + ":7: Error: expected 2 parameters"; - QString warning2 = component.url().toString() + ":8: Error: expected 2 parameters"; + QString warning1 = component.url().toString() + ":7: Error: Qt.size(): Invalid arguments"; + QString warning2 = component.url().toString() + ":8: Error: Qt.size(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -209,8 +211,8 @@ void tst_qdeclarativeqt::vector() { QDeclarativeComponent component(&engine, TEST_FILE("vector.qml")); - QString warning1 = component.url().toString() + ":6: Error: expected 3 parameters"; - QString warning2 = component.url().toString() + ":7: Error: expected 3 parameters"; + QString warning1 = component.url().toString() + ":6: Error: Qt.vector(): Invalid arguments"; + QString warning2 = component.url().toString() + ":7: Error: Qt.vector(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -229,8 +231,8 @@ void tst_qdeclarativeqt::lighter() { QDeclarativeComponent component(&engine, TEST_FILE("lighter.qml")); - QString warning1 = component.url().toString() + ":5: Error: expected 1 parameter"; - QString warning2 = component.url().toString() + ":6: Error: expected 1 parameter"; + QString warning1 = component.url().toString() + ":5: Error: Qt.lighter(): Invalid arguments"; + QString warning2 = component.url().toString() + ":6: Error: Qt.lighter(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -251,8 +253,8 @@ void tst_qdeclarativeqt::darker() { QDeclarativeComponent component(&engine, TEST_FILE("darker.qml")); - QString warning1 = component.url().toString() + ":5: Error: expected 1 parameter"; - QString warning2 = component.url().toString() + ":6: Error: expected 1 parameter"; + QString warning1 = component.url().toString() + ":5: Error: Qt.darker(): Invalid arguments"; + QString warning2 = component.url().toString() + ":6: Error: Qt.darker(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -273,8 +275,8 @@ void tst_qdeclarativeqt::tint() { QDeclarativeComponent component(&engine, TEST_FILE("tint.qml")); - QString warning1 = component.url().toString() + ":7: Error: expected 2 parameters"; - QString warning2 = component.url().toString() + ":8: Error: expected 2 parameters"; + QString warning1 = component.url().toString() + ":7: Error: Qt.tint(): Invalid arguments"; + QString warning2 = component.url().toString() + ":8: Error: Qt.tint(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -322,10 +324,13 @@ void tst_qdeclarativeqt::openUrlExternally() void tst_qdeclarativeqt::md5() { QDeclarativeComponent component(&engine, TEST_FILE("md5.qml")); + + QString warning1 = component.url().toString() + ":4: Error: Qt.md5(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + QObject *object = component.create(); QVERIFY(object != 0); - QCOMPARE(object->property("test1").toString(), QLatin1String(QCryptographicHash::hash(QByteArray(), QCryptographicHash::Md5).toHex())); QCOMPARE(object->property("test2").toString(), QLatin1String(QCryptographicHash::hash("Hello World", QCryptographicHash::Md5).toHex())); delete object; @@ -335,8 +340,8 @@ void tst_qdeclarativeqt::createComponent() { QDeclarativeComponent component(&engine, TEST_FILE("createComponent.qml")); - QString warning1 = component.url().toString() + ":9: Error: expected 1 parameter"; - QString warning2 = component.url().toString() + ":10: Error: expected 1 parameter"; + QString warning1 = component.url().toString() + ":9: Error: Qt.createComponent(): Invalid arguments"; + QString warning2 = component.url().toString() + ":10: Error: Qt.createComponent(): Invalid arguments"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); @@ -353,11 +358,11 @@ void tst_qdeclarativeqt::createQmlObject() { QDeclarativeComponent component(&engine, TEST_FILE("createQmlObject.qml")); - QString warning1 = component.url().toString() + ":7: Error: expected 2 or 3 parameters"; + QString warning1 = component.url().toString() + ":7: Error: Qt.createQmlObject(): Invalid arguments"; QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject() failed to create object: " + TEST_FILE("inline").toString() + ":2:10: Blah is not a type\n"; QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject() failed to create object: " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name\n"; - QString warning4 = component.url().toString()+ ":9: Error: parent object not found"; - QString warning5 = component.url().toString()+ ":8: Error: expected 2 or 3 parameters"; + QString warning4 = component.url().toString()+ ":9: Error: Qt.createQmlObject(): Missing parent object"; + QString warning5 = component.url().toString()+ ":8: Error: Qt.createQmlObject(): Invalid arguments"; QString warning6 = "RunTimeError: Qt.createQmlObject() failed to create object: " + TEST_FILE("inline").toString() + ":3: Cannot assign object type QObject with no default method\n"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); @@ -433,6 +438,36 @@ void tst_qdeclarativeqt::isQtObject() delete object; } +void tst_qdeclarativeqt::btoa() +{ + QDeclarativeComponent component(&engine, TEST_FILE("btoa.qml")); + + QString warning1 = component.url().toString() + ":4: Error: Qt.btoa(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test2").toString(), QString("SGVsbG8gd29ybGQh")); + + delete object; +} + +void tst_qdeclarativeqt::atob() +{ + QDeclarativeComponent component(&engine, TEST_FILE("atob.qml")); + + QString warning1 = component.url().toString() + ":4: Error: Qt.atob(): Invalid arguments"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); + + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test2").toString(), QString("Hello world!")); + + delete object; +} + QTEST_MAIN(tst_qdeclarativeqt) #include "tst_qdeclarativeqt.moc" |