summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-04-22 05:01:02 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-04-27 01:56:45 (GMT)
commitddc7fcee9c3602bcbb79a6b8538315a633fa3db4 (patch)
tree90b7669402ff1e4d2e8bbe9e98762f772a53fdba /tests
parent46cf45c5c9dc74bf2cbe42c8a57be194ea9cf8cd (diff)
downloadQt-ddc7fcee9c3602bcbb79a6b8538315a633fa3db4.zip
Qt-ddc7fcee9c3602bcbb79a6b8538315a633fa3db4.tar.gz
Qt-ddc7fcee9c3602bcbb79a6b8538315a633fa3db4.tar.bz2
Autotests
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp20
-rw-r--r--tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/formatting.qml10
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp15
5 files changed, 57 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml
new file mode 100644
index 0000000..9c46c3f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/deferredPropertiesErrors.qml
@@ -0,0 +1,10 @@
+import Qt.test 1.0
+import Qt 4.7
+
+MyDeferredObject {
+ value: undefined // error is resolved before complete
+ objectProperty: undefined // immediate error
+ objectProperty2: QtObject {
+ Component.onCompleted: value = 10
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 97fced4..d0a2f7c 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -89,6 +89,7 @@ private slots:
void contextPropertiesTriggerReeval();
void objectPropertiesTriggerReeval();
void deferredProperties();
+ void deferredPropertiesErrors();
void extensionObjects();
void overrideExtensionProperties();
void attachedProperties();
@@ -543,6 +544,25 @@ void tst_qdeclarativeecmascript::deferredProperties()
QCOMPARE(qmlObject->value(), 19);
}
+// Check errors on deferred properties are correctly emitted
+void tst_qdeclarativeecmascript::deferredPropertiesErrors()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("deferredPropertiesErrors.qml"));
+ MyDeferredObject *object =
+ qobject_cast<MyDeferredObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->value(), 0);
+ QVERIFY(object->objectProperty() == 0);
+ QVERIFY(object->objectProperty2() == 0);
+
+ QString warning = component.url().toString() + ":6: Unable to assign [undefined] to QObject*";
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
+
+ qmlExecuteDeferred(object);
+
+ delete object;
+}
+
void tst_qdeclarativeecmascript::extensionObjects()
{
QDeclarativeComponent component(&engine, TEST_FILE("extensionObjects.qml"));
diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
index ee320aa..b0db771 100644
--- a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
+++ b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp
@@ -297,6 +297,8 @@ void tst_qdeclarativeengine::objectOwnership()
{
QObject o;
QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership);
+ QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::CppOwnership);
+ QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::CppOwnership);
QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::JavaScriptOwnership);
QCOMPARE(QDeclarativeEngine::objectOwnership(&o), QDeclarativeEngine::JavaScriptOwnership);
QDeclarativeEngine::setObjectOwnership(&o, QDeclarativeEngine::CppOwnership);
diff --git a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml
index 59a15929..7f48639 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/formatting.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/formatting.qml
@@ -16,4 +16,14 @@ QtObject {
property string test8: Qt.formatDateTime(dateTime1)
property string test9: Qt.formatDateTime(dateTime1, Qt.DefaultLocaleLongDate)
property string test10: Qt.formatDateTime(dateTime1, "M/d/yy H:m:s a")
+
+ // Error cases
+ property string test11: Qt.formatDate()
+ property string test12: Qt.formatDate(new Date, new Object)
+
+ property string test13: Qt.formatTime()
+ property string test14: Qt.formatTime(new Date, new Object)
+
+ property string test15: Qt.formatDateTime()
+ property string test16: Qt.formatDateTime(new Date, new Object)
}
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
index f5d5926..7cbd8db 100644
--- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
+++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
@@ -398,6 +398,21 @@ void tst_qdeclarativeqt::consoleLog()
void tst_qdeclarativeqt::formatting()
{
QDeclarativeComponent component(&engine, TEST_FILE("formatting.qml"));
+
+ QString warning1 = component.url().toString() + ":22: Error: Qt.formatDate(): Invalid date format";
+ QString warning2 = component.url().toString() + ":21: Error: Qt.formatDate(): Invalid arguments";
+ QString warning3 = component.url().toString() + ":28: Error: Qt.formatDateTime(): Invalid datetime format";
+ QString warning4 = component.url().toString() + ":27: Error: Qt.formatDateTime(): Invalid arguments";
+ QString warning5 = component.url().toString() + ":25: Error: Qt.formatTime(): Invalid time format";
+ QString warning6 = component.url().toString() + ":24: Error: Qt.formatTime(): Invalid arguments";
+
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning4));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning5));
+ QTest::ignoreMessage(QtWarningMsg, qPrintable(warning6));
+
QObject *object = component.create();
QVERIFY(object != 0);