aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlecmascript')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js5
-rw-r--r--tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml10
-rw-r--r--tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings_crlf.1.qml13
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalAssignment.3.qml5
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalAssignment.4.qml6
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.h2
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp51
7 files changed, 84 insertions, 8 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js b/tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js
new file mode 100644
index 0000000000..7a4f434665
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/importModuleApi.js
@@ -0,0 +1,5 @@
+.import Qt.test 1.0 as QObjectModuleApi
+
+function testFunc() {
+ return QObjectModuleApi.qobjectTestProperty
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml
new file mode 100644
index 0000000000..b3e545dd7c
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/jsimport/testImportModuleApi.qml
@@ -0,0 +1,10 @@
+import QtQuick 2.0
+import "importModuleApi.js" as Script
+
+Item {
+ property variant testValue: 5
+
+ Component.onCompleted: {
+ testValue = Script.testFunc();
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings_crlf.1.qml b/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings_crlf.1.qml
new file mode 100644
index 0000000000..f84ba8c722
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/rewriteMultiLineStrings_crlf.1.qml
@@ -0,0 +1,13 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: root
+
+ Component.onCompleted: {
+ var o = Qt.createQmlObject("import QtQuick 2.0; \
+ \
+ Item { \
+ property bool b: true; \
+ }", root, "Instance")
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/signalAssignment.3.qml b/tests/auto/qml/qqmlecmascript/data/signalAssignment.3.qml
new file mode 100644
index 0000000000..690b7cf216
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/signalAssignment.3.qml
@@ -0,0 +1,5 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ onUnnamedArgumentSignal: setString('pass ' + a + ' ' + c)
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/signalAssignment.4.qml b/tests/auto/qml/qqmlecmascript/data/signalAssignment.4.qml
new file mode 100644
index 0000000000..0e1e728a86
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/signalAssignment.4.qml
@@ -0,0 +1,6 @@
+import Qt.test 1.0
+
+
+MyQmlObject {
+ onSignalWithGlobalName: setString('pass ' + parseInt("5"))
+}
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h
index 154e6f019c..1d68e8ae13 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.h
+++ b/tests/auto/qml/qqmlecmascript/testtypes.h
@@ -180,6 +180,7 @@ public:
signals:
void basicSignal();
void argumentSignal(int a, QString b, qreal c, MyEnum2 d, Qt::MouseButtons e);
+ void unnamedArgumentSignal(int a, qreal, QString c);
void stringChanged();
void urlChanged();
void objectChanged();
@@ -188,6 +189,7 @@ signals:
void signalWithUnknownType(const MyQmlObject::MyType &arg);
void signalWithVariant(const QVariant &arg);
void signalWithQJSValue(const QJSValue &arg);
+ void signalWithGlobalName(int parseInt);
void intChanged();
public slots:
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index af219c8826..676557a81c 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -376,6 +376,27 @@ void tst_qqmlecmascript::signalAssignment()
QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25 3 2"));
delete object;
}
+
+ {
+ QQmlComponent component(&engine, testFileUrl("signalAssignment.3.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->unnamedArgumentSignal(19, 10.25, "Hello world!");
+ QEXPECT_FAIL("", "QTBUG-24481", Continue);
+ QCOMPARE(object->string(), QString("pass 19 Hello world!"));
+ delete object;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("signalAssignment.4.qml"));
+ MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->string(), QString());
+ emit object->signalWithGlobalName(19);
+ QCOMPARE(object->string(), QString("pass 5"));
+ delete object;
+ }
}
void tst_qqmlecmascript::methods()
@@ -1570,8 +1591,6 @@ void tst_qqmlecmascript::compileInvalidBinding()
{
// QTBUG-23387: ensure that invalid bindings don't cause a crash.
QQmlComponent component(&engine, testFileUrl("v8bindingException.qml"));
- QString warning = component.url().toString() + ":16: SyntaxError: Unexpected token ILLEGAL";
- QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
QObject *object = component.create();
QVERIFY(object != 0);
delete object;
@@ -3248,6 +3267,13 @@ void tst_qqmlecmascript::importScripts_data()
<< QStringList()
<< (QStringList() << QLatin1String("testValue"))
<< (QVariantList() << QVariant(18));
+
+ QTest::newRow("import module api into js import")
+ << testFileUrl("jsimport/testImportModuleApi.qml")
+ << QString()
+ << QStringList()
+ << (QStringList() << QLatin1String("testValue"))
+ << (QVariantList() << QVariant(20));
}
void tst_qqmlecmascript::importScripts()
@@ -5287,12 +5313,21 @@ void tst_qqmlecmascript::qtbug_21864()
void tst_qqmlecmascript::rewriteMultiLineStrings()
{
- // QTBUG-23387
- QQmlComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml"));
- QObject *o = component.create();
- QVERIFY(o != 0);
- QTRY_COMPARE(o->property("test").toBool(), true);
- delete o;
+ {
+ // QTBUG-23387
+ QQmlComponent component(&engine, testFileUrl("rewriteMultiLineStrings.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QTRY_COMPARE(o->property("test").toBool(), true);
+ delete o;
+ }
+
+ {
+ QQmlComponent component(&engine, testFileUrl("rewriteMultiLineStrings_crlf.1.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ delete o;
+ }
}
void tst_qqmlecmascript::qobjectConnectionListExceptionHandling()