summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-04-08 06:13:31 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-04-08 06:18:43 (GMT)
commitdf1788b4dbbb2826ae63f26bdf166342595343f4 (patch)
treeb021f683c6da72f9c46d0decbf0f8aa97dd2a9d4 /tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
parent942a605a52dbbd6dfa824e3b76e37576c7d79f6e (diff)
downloadQt-df1788b4dbbb2826ae63f26bdf166342595343f4.zip
Qt-df1788b4dbbb2826ae63f26bdf166342595343f4.tar.gz
Qt-df1788b4dbbb2826ae63f26bdf166342595343f4.tar.bz2
Cleanup handling of errors in bindings and scripts
QML used to silently ignore a log of errors - such as a failed assignment to a QObject property. These errors are now all reported as exceptions in JavaScript. Other questionable activities, like assigning a JavaScript array to a "property var" property which appeared to work, thanks to QtScript's transparent conversion of arrays to a QVariantList, are now blocked entirely. QTBUG-9152 QTBUG-9382 QTBUG-9341 QTBUG-6886
Diffstat (limited to 'tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 8e73afa..32d407f 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -108,6 +108,8 @@ private slots:
void selfDeletingBinding();
void extendedObjectPropertyLookup();
void scriptErrors();
+ void functionErrors();
+ void propertyAssignmentErrors();
void signalTriggeredBindings();
void listProperties();
void exceptionClearsOnReeval();
@@ -995,6 +997,46 @@ void tst_qdeclarativeecmascript::scriptErrors()
}
/*
+Test file/lineNumbers for inline functions.
+*/
+void tst_qdeclarativeecmascript::functionErrors()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("functionErrors.qml"));
+ QString url = component.url().toString();
+
+ QString warning = url + ":5: Error: Invalid write to global property \"a\"";
+
+ QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
+/*
+Test various errors that can occur when assigning a property from script
+*/
+void tst_qdeclarativeecmascript::propertyAssignmentErrors()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("propertyAssignmentErrors.qml"));
+
+ QString url = component.url().toString();
+
+ QString warning1 = url + ":11:Error: Cannot assign [undefined] to int";
+ QString warning2 = url + ":17:Error: Cannot assign JavaScript array to QML variant property";
+ QString warning3 = url + ":23:Error: Cannot assign QString to int";
+
+ QTest::ignoreMessage(QtDebugMsg, warning1.toLatin1().constData());
+ QTest::ignoreMessage(QtDebugMsg, warning2.toLatin1().constData());
+ QTest::ignoreMessage(QtDebugMsg, warning3.toLatin1().constData());
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ delete object;
+}
+
+/*
Test bindings still work when the reeval is triggered from within
a signal script.
*/