aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp2
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp40
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp5
-rw-r--r--tests/auto/qml/qqmlenginecleanup/data/testFile1.qml49
-rw-r--r--tests/auto/qml/qqmlenginecleanup/data/testFile2.qml46
-rw-r--r--tests/auto/qml/qqmlenginecleanup/data/testFile3.qml68
-rw-r--r--tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp45
-rw-r--r--tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp1
-rw-r--r--tests/auto/qml/qv4debugger/tst_qv4debugger.cpp83
9 files changed, 335 insertions, 4 deletions
diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
index c4c2705e01..e4c14a2e10 100644
--- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp
@@ -54,7 +54,6 @@ class tst_QQmlEngineDebugInspectorIntegration : public QQmlDataTest
public:
tst_QQmlEngineDebugInspectorIntegration()
: m_process(0)
- , m_connection(0)
, m_inspectorClient(0)
, m_engineDebugClient(0)
{
@@ -65,7 +64,6 @@ private:
QmlDebugObjectReference findRootObject();
QQmlDebugProcess *m_process;
- QQmlDebugConnection *m_connection;
QQmlInspectorClient *m_inspectorClient;
QQmlEngineDebugClient *m_engineDebugClient;
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
index 5bbbe8e1e9..7c931928d4 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
@@ -36,6 +36,7 @@
#include <QHostAddress>
#include <QDebug>
#include <QThread>
+#include <QModelIndex>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcontext.h>
@@ -73,6 +74,16 @@ signals:
};
QML_DECLARE_TYPE(NonScriptProperty)
+class CustomTypes : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QModelIndex modelIndex READ modelIndex)
+public:
+ CustomTypes(QObject *parent = 0) : QObject(parent) {}
+
+ QModelIndex modelIndex() { return QModelIndex(); }
+};
+
class tst_QQmlEngineDebugService : public QObject
{
Q_OBJECT
@@ -125,6 +136,7 @@ private slots:
void setBindingInStates();
void regression_QTCREATORBUG_7451();
+ void queryObjectWithNonStreamableTypes();
};
QmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
@@ -314,6 +326,12 @@ void tst_QQmlEngineDebugService::initTestCase()
"}\n"
;
+ // test non-streamable properties
+ qmlRegisterType<CustomTypes>("Backend", 1, 0, "CustomTypes");
+ qml << "import Backend 1.0\n"
+ "CustomTypes {}"
+ ;
+
for (int i=0; i<qml.count(); i++) {
QQmlComponent component(m_engine);
component.setData(qml[i], QUrl::fromLocalFile(""));
@@ -620,7 +638,7 @@ void tst_QQmlEngineDebugService::queryRootContexts()
// root context query sends only root object data - it doesn't fill in
// the children or property info
QCOMPARE(context.objects.count(), 0);
- QCOMPARE(context.contexts.count(), 5);
+ QCOMPARE(context.contexts.count(), 6);
QVERIFY(context.contexts[0].debugId >= 0);
QCOMPARE(context.contexts[0].name, QString("tst_QQmlDebug_childContext"));
}
@@ -819,6 +837,26 @@ void tst_QQmlEngineDebugService::regression_QTCREATORBUG_7451()
}
}
+void tst_QQmlEngineDebugService::queryObjectWithNonStreamableTypes()
+{
+ bool success;
+
+ QmlDebugObjectReference rootObject = findRootObject(4, true);
+
+ QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0);
+ unconnected->queryObject(rootObject, &success);
+ QVERIFY(!success);
+ delete unconnected;
+
+ m_dbg->queryObject(rootObject, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+
+ QmlDebugObjectReference obj = m_dbg->object();
+
+ QCOMPARE(findProperty(obj.properties, "modelIndex").value, QVariant());
+}
+
void tst_QQmlEngineDebugService::queryExpressionResult()
{
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 2e7fe34796..4e9da046b5 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -3200,6 +3200,11 @@ void tst_QJSEngine::installTranslatorFunctions()
QVERIFY(ret.isString());
QCOMPARE(ret.toString(), QString::fromLatin1("foo"));
}
+ {
+ QJSValue ret = eng.evaluate("qsTr('%1').arg('foo')");
+ QVERIFY(ret.isString());
+ QCOMPARE(ret.toString(), QString::fromLatin1("foo"));
+ }
QVERIFY(eng.evaluate("QT_TRID_NOOP()").isUndefined());
}
diff --git a/tests/auto/qml/qqmlenginecleanup/data/testFile1.qml b/tests/auto/qml/qqmlenginecleanup/data/testFile1.qml
new file mode 100644
index 0000000000..3bd8e22ce4
--- /dev/null
+++ b/tests/auto/qml/qqmlenginecleanup/data/testFile1.qml
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ Item {
+ id: c1
+ }
+ property Item a: c1
+}
diff --git a/tests/auto/qml/qqmlenginecleanup/data/testFile2.qml b/tests/auto/qml/qqmlenginecleanup/data/testFile2.qml
new file mode 100644
index 0000000000..9a32114918
--- /dev/null
+++ b/tests/auto/qml/qqmlenginecleanup/data/testFile2.qml
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ property variant a: Qt.rgba(0.3, 0.4, 0.5, 0.6)
+}
diff --git a/tests/auto/qml/qqmlenginecleanup/data/testFile3.qml b/tests/auto/qml/qqmlenginecleanup/data/testFile3.qml
new file mode 100644
index 0000000000..c55c355388
--- /dev/null
+++ b/tests/auto/qml/qqmlenginecleanup/data/testFile3.qml
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ width: 320
+ height: 480
+
+ ListView {
+ anchors.fill: parent
+ model: simpleModel
+ delegate: Text {
+ text: name
+ }
+ }
+
+ ListModel {
+ id: simpleModel
+ ListElement {
+ name: "first"
+ }
+ ListElement {
+ name: "second"
+ }
+ ListElement {
+ name: "third"
+ }
+ }
+}
diff --git a/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp b/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp
index fcc3e6a0a9..c8fae624a7 100644
--- a/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp
+++ b/tests/auto/qml/qqmlenginecleanup/tst_qqmlenginecleanup.cpp
@@ -46,6 +46,7 @@ public:
private slots:
void test_qmlClearTypeRegistrations();
+ void test_valueTypeProviderModule(); // QTBUG-43004
};
void tst_qqmlenginecleanup::test_qmlClearTypeRegistrations()
@@ -85,6 +86,50 @@ void tst_qqmlenginecleanup::test_qmlClearTypeRegistrations()
delete component;
}
+static void cleanState(QQmlEngine **e)
+{
+ delete *e;
+ qmlClearTypeRegistrations();
+ *e = new QQmlEngine;
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+}
+
+void tst_qqmlenginecleanup::test_valueTypeProviderModule()
+{
+ // this test ensures that a module which installs a value type
+ // provider can be reinitialized after multiple calls to
+ // qmlClearTypeRegistrations() without causing cycles in the
+ // value type provider list.
+ QQmlEngine *e = 0;
+ QUrl testFile1 = testFileUrl("testFile1.qml");
+ QUrl testFile2 = testFileUrl("testFile2.qml");
+ bool noCycles = false;
+ for (int i = 0; i < 20; ++i) {
+ cleanState(&e);
+ QQmlComponent c(e, this);
+ c.loadUrl(i % 2 == 0 ? testFile1 : testFile2); // this will hang if cycles exist.
+ }
+ delete e;
+ e = 0;
+ noCycles = true;
+ QVERIFY(noCycles);
+
+ // this test ensures that no crashes occur due to using
+ // a dangling QQmlType pointer in the type compiler
+ // which results from qmlClearTypeRegistrations()
+ QUrl testFile3 = testFileUrl("testFile3.qml");
+ bool noDangling = false;
+ for (int i = 0; i < 20; ++i) {
+ cleanState(&e);
+ QQmlComponent c(e, this);
+ c.loadUrl(i % 2 == 0 ? testFile1 : testFile3); // this will crash if dangling ptr exists.
+ }
+ delete e;
+ noDangling = true;
+ QVERIFY(noDangling);
+}
+
QTEST_MAIN(tst_qqmlenginecleanup)
#include "tst_qqmlenginecleanup.moc"
diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
index deb3f4e11b..1cdf8ce574 100644
--- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
+++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp
@@ -46,7 +46,6 @@
// From qquickfolderlistmodel.h
const int FileNameRole = Qt::UserRole+1;
-const int FilePathRole = Qt::UserRole+2;
enum SortField { Unsorted, Name, Time, Size, Type };
class tst_qquickfolderlistmodel : public QQmlDataTest
diff --git a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp
index 3fe14fa216..63bfffacaa 100644
--- a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp
+++ b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp
@@ -33,6 +33,8 @@
#include <QtTest/QtTest>
#include <QJSEngine>
+#include <QQmlEngine>
+#include <QQmlComponent>
#include <private/qv4engine_p.h>
#include <private/qv4debugging_p.h>
#include <private/qv8engine_p.h>
@@ -182,6 +184,14 @@ public:
m_stackTrace = debugger->stackTrace();
+ while (!m_expressionRequests.isEmpty()) {
+ ExpressionRequest request = m_expressionRequests.takeFirst();
+ QVariantMap result;
+ collector.setDestination(&result);
+ debugger->evaluateExpression(request.frameNr, request.expression, &collector);
+ m_expressionResults << result[QString::fromLatin1("body")];
+ }
+
if (m_captureContextInfo)
captureContextInfo(debugger);
@@ -233,6 +243,13 @@ public:
QList<QVariantMap> m_capturedLocals;
QVariant m_thrownValue;
+ struct ExpressionRequest {
+ QString expression;
+ int frameNr;
+ };
+ QVector<ExpressionRequest> m_expressionRequests;
+ QVector<QVariant> m_expressionResults;
+
// Utility methods:
void dumpStackTrace() const
{
@@ -259,6 +276,7 @@ private slots:
void addBreakPointWhilePaused();
void removeBreakPointForNextInstruction();
void conditionalBreakPoint();
+ void conditionalBreakPointInQml();
// context access:
void readArguments();
@@ -269,6 +287,8 @@ private slots:
// exceptions:
void pauseOnThrow();
+ void evaluateExpression();
+
private:
void evaluateJavaScript(const QString &script, const QString &fileName, int lineNumber = 1)
{
@@ -428,6 +448,42 @@ void tst_qv4debugger::conditionalBreakPoint()
QCOMPARE(m_debuggerAgent->m_capturedLocals[0]["i"].toInt(), 11);
}
+void tst_qv4debugger::conditionalBreakPointInQml()
+{
+ QQmlEngine engine;
+ QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine);
+ v4->enableDebugger();
+
+ QScopedPointer<QThread> debugThread(new QThread);
+ debugThread->start();
+ QScopedPointer<TestAgent> debuggerAgent(new TestAgent);
+ debuggerAgent->addDebugger(v4->debugger);
+ debuggerAgent->moveToThread(debugThread.data());
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQml 2.0\n"
+ "QtObject {\n"
+ " id: root\n"
+ " property int foo: 42\n"
+ " property bool success: false\n"
+ " Component.onCompleted: {\n"
+ " success = true;\n" // breakpoint here
+ " }\n"
+ "}\n", QUrl("test.qml"));
+
+ debuggerAgent->addBreakPoint("test.qml", 7, /*enabled*/true, "root.foo == 42");
+
+ QScopedPointer<QObject> obj(component.create());
+ QCOMPARE(obj->property("success").toBool(), true);
+
+ QCOMPARE(debuggerAgent->m_statesWhenPaused.count(), 1);
+ QCOMPARE(debuggerAgent->m_statesWhenPaused.at(0).fileName, QStringLiteral("test.qml"));
+ QCOMPARE(debuggerAgent->m_statesWhenPaused.at(0).lineNumber, 7);
+
+ debugThread->quit();
+ debugThread->wait();
+}
+
void tst_qv4debugger::readArguments()
{
m_debuggerAgent->m_captureContextInfo = true;
@@ -556,6 +612,33 @@ void tst_qv4debugger::pauseOnThrow()
QCOMPARE(m_debuggerAgent->m_thrownValue.toString(), QString("hard"));
}
+void tst_qv4debugger::evaluateExpression()
+{
+ QString script =
+ "function testFunction() {\n"
+ " var x = 10\n"
+ " return x\n" // breakpoint
+ "}\n"
+ "var x = 20\n"
+ "testFunction()\n";
+
+ TestAgent::ExpressionRequest request;
+ request.expression = "x";
+ request.frameNr = 0;
+ m_debuggerAgent->m_expressionRequests << request;
+ request.expression = "x";
+ request.frameNr = 1;
+ m_debuggerAgent->m_expressionRequests << request;
+
+ m_debuggerAgent->addBreakPoint("evaluateExpression", 3);
+
+ evaluateJavaScript(script, "evaluateExpression");
+
+ QCOMPARE(m_debuggerAgent->m_expressionResults.count(), 2);
+ QCOMPARE(m_debuggerAgent->m_expressionResults[0].toInt(), 10);
+ QCOMPARE(m_debuggerAgent->m_expressionResults[1].toInt(), 20);
+}
+
QTEST_MAIN(tst_qv4debugger)
#include "tst_qv4debugger.moc"