aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/debugger/qv4debugger/data/breakPointInJSModule.qml4
-rw-r--r--tests/auto/qml/debugger/qv4debugger/data/module1.js5
-rw-r--r--tests/auto/qml/debugger/qv4debugger/data/module2.mjs7
-rw-r--r--tests/auto/qml/debugger/qv4debugger/data/module3.mjs0
-rw-r--r--tests/auto/qml/debugger/qv4debugger/data/module4.mjs0
-rw-r--r--tests/auto/qml/debugger/qv4debugger/qv4debugger.pro3
-rw-r--r--tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp49
-rw-r--r--tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp10
-rw-r--r--tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp20
-rw-r--r--tests/auto/quick/qquickgridview/data/qtbug86255.qml55
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp13
-rw-r--r--tests/auto/quick/qquickstates/data/jsValueWhen.qml18
-rw-r--r--tests/auto/quick/qquickstates/tst_qquickstates.cpp11
13 files changed, 183 insertions, 12 deletions
diff --git a/tests/auto/qml/debugger/qv4debugger/data/breakPointInJSModule.qml b/tests/auto/qml/debugger/qv4debugger/data/breakPointInJSModule.qml
new file mode 100644
index 0000000000..2582a23ec5
--- /dev/null
+++ b/tests/auto/qml/debugger/qv4debugger/data/breakPointInJSModule.qml
@@ -0,0 +1,4 @@
+import QtQml 2.15
+import "module1.js" as Module1
+
+QtObject {}
diff --git a/tests/auto/qml/debugger/qv4debugger/data/module1.js b/tests/auto/qml/debugger/qv4debugger/data/module1.js
new file mode 100644
index 0000000000..9ce1f1e6b1
--- /dev/null
+++ b/tests/auto/qml/debugger/qv4debugger/data/module1.js
@@ -0,0 +1,5 @@
+.pragma library
+
+.import "module2.mjs" as Module2
+
+Module2.crashMe();
diff --git a/tests/auto/qml/debugger/qv4debugger/data/module2.mjs b/tests/auto/qml/debugger/qv4debugger/data/module2.mjs
new file mode 100644
index 0000000000..80f82af953
--- /dev/null
+++ b/tests/auto/qml/debugger/qv4debugger/data/module2.mjs
@@ -0,0 +1,7 @@
+import * as Module3 from "module3.mjs"
+import * as Module4 from "module4.mjs"
+
+export function crashMe()
+{
+ console.log("Hello world!");
+}
diff --git a/tests/auto/qml/debugger/qv4debugger/data/module3.mjs b/tests/auto/qml/debugger/qv4debugger/data/module3.mjs
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/qml/debugger/qv4debugger/data/module3.mjs
diff --git a/tests/auto/qml/debugger/qv4debugger/data/module4.mjs b/tests/auto/qml/debugger/qv4debugger/data/module4.mjs
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/qml/debugger/qv4debugger/data/module4.mjs
diff --git a/tests/auto/qml/debugger/qv4debugger/qv4debugger.pro b/tests/auto/qml/debugger/qv4debugger/qv4debugger.pro
index e25b4260e5..63cdfc2394 100644
--- a/tests/auto/qml/debugger/qv4debugger/qv4debugger.pro
+++ b/tests/auto/qml/debugger/qv4debugger/qv4debugger.pro
@@ -16,4 +16,7 @@ HEADERS += \
INCLUDEPATH += \
$$PWD/../../../../../src/plugins/qmltooling/qmldbg_debugger
+include (../../../shared/util.pri)
+TESTDATA = data/*
+
QT += core-private gui-private qml-private network testlib
diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
index e4e7728508..486e617f1e 100644
--- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
+++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp
@@ -41,6 +41,8 @@
#include <private/qqmlbuiltinfunctions_p.h>
#include <private/qqmldebugservice_p.h>
+#include "../../../shared/util.h"
+
using namespace QV4;
using namespace QV4::Debugging;
@@ -224,10 +226,14 @@ public:
QJsonArray scopes = frameObj.value(QLatin1String("scopes")).toArray();
int nscopes = scopes.size();
int s = 0;
- for (s = 0; s < nscopes; ++s) {
- QJsonObject o = scopes.at(s).toObject();
- if (o.value(QLatin1String("type")).toInt(-2) == 1) // CallContext
- break;
+ if (m_targetScope != -1) {
+ s = m_targetScope;
+ } else {
+ for (s = 0; s < nscopes; ++s) {
+ QJsonObject o = scopes.at(s).toObject();
+ if (o.value(QLatin1String("type")).toInt(-2) == 1) // CallContext
+ break;
+ }
}
if (s == nscopes)
return;
@@ -257,6 +263,7 @@ public:
bool m_wasPaused;
QV4Debugger::PauseReason m_pauseReason;
bool m_captureContextInfo;
+ int m_targetScope = -1;
QList<QV4Debugger::ExecutionState> m_statesWhenPaused;
QList<TestBreakPoint> m_breakPointsToAddWhenPaused;
QVector<QV4::StackFrame> m_stackTrace;
@@ -284,11 +291,12 @@ public:
}
};
-class tst_qv4debugger : public QObject
+class tst_qv4debugger : public QQmlDataTest
{
Q_OBJECT
private slots:
+ void initTestCase() { QQmlDataTest::initTestCase(); }
void init();
void cleanup();
@@ -323,6 +331,8 @@ private slots:
void readThis();
void signalParameters();
+ void breakPointInJSModule();
+
private:
QV4Debugger *debugger() const
{
@@ -939,6 +949,35 @@ void tst_qv4debugger::signalParameters()
QCOMPARE(obj->property("resultCallbackExternal").toString(), QLatin1String("unset"));
}
+void tst_qv4debugger::breakPointInJSModule()
+{
+ QQmlEngine engine;
+ QV4::ExecutionEngine *v4 = engine.handle();
+ QPointer<QV4Debugger> v4Debugger = new QV4Debugger(v4);
+ v4->setDebugger(v4Debugger.data());
+
+ QScopedPointer<QThread> debugThread(new QThread);
+ debugThread->start();
+ QScopedPointer<TestAgent> debuggerAgent(new TestAgent(v4));
+ debuggerAgent->addDebugger(v4Debugger);
+ debuggerAgent->moveToThread(debugThread.data());
+
+ QQmlComponent component(&engine, testFileUrl("breakPointInJSModule.qml"));
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+
+ debuggerAgent->m_captureContextInfo = true;
+ debuggerAgent->m_targetScope = 1;
+ v4Debugger->addBreakPoint("module2.mjs", 6);
+
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+
+ QVERIFY(!debuggerAgent->m_capturedScope.isEmpty());
+
+ debugThread->quit();
+ debugThread->wait();
+}
+
QTEST_MAIN(tst_qv4debugger)
#include "tst_qv4debugger.moc"
diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
index 6754f22049..2866988a1a 100644
--- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
+++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
@@ -73,6 +73,8 @@ private slots:
void contextObjectHierarchy();
void destroyContextProperty();
+ void numericContextProperty();
+
private:
QQmlEngine engine;
};
@@ -918,6 +920,14 @@ void tst_qqmlcontext::destroyContextProperty()
// TODO: Or are we?
}
+void tst_qqmlcontext::numericContextProperty()
+{
+ QQmlEngine engine;
+ auto context = engine.rootContext();
+ context->setContextProperty(QLatin1String("11"), 42);
+ QCOMPARE(context->contextProperty(QLatin1String("11")).toInt(), 42);
+}
+
QTEST_MAIN(tst_qqmlcontext)
#include "tst_qqmlcontext.moc"
diff --git a/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp b/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp
index d5587432de..7d53762efa 100644
--- a/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp
+++ b/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp
@@ -59,7 +59,8 @@ void tst_qqmlinstantiator::createNone()
{
QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("createNone.qml"));
- QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator*>(component.create());
+ QScopedPointer<QObject> o(component.create());
+ QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator*>(o.data());
QVERIFY(instantiator != nullptr);
QCOMPARE(instantiator->isActive(), true);
QCOMPARE(instantiator->count(), 0);
@@ -71,7 +72,8 @@ void tst_qqmlinstantiator::createSingle()
{
QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("createSingle.qml"));
- QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator*>(component.create());
+ QScopedPointer<QObject> o(component.create());
+ QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator*>(o.data());
QVERIFY(instantiator != nullptr);
QCOMPARE(instantiator->isActive(), true);
QCOMPARE(instantiator->count(), 1);
@@ -88,7 +90,8 @@ void tst_qqmlinstantiator::createMultiple()
{
QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("createMultiple.qml"));
- QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator*>(component.create());
+ QScopedPointer<QObject> o(component.create());
+ QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator*>(o.data());
QVERIFY(instantiator != nullptr);
QCOMPARE(instantiator->isActive(), true);
QCOMPARE(instantiator->count(), 10);
@@ -106,7 +109,8 @@ void tst_qqmlinstantiator::stringModel()
{
QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("stringModel.qml"));
- QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator*>(component.create());
+ QScopedPointer<QObject> o(component.create());
+ QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator*>(o.data());
QVERIFY(instantiator != nullptr);
QCOMPARE(instantiator->isActive(), true);
QCOMPARE(instantiator->count(), 4);
@@ -123,7 +127,8 @@ void tst_qqmlinstantiator::activeProperty()
{
QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("inactive.qml"));
- QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator*>(component.create());
+ QScopedPointer<QObject> o(component.create());
+ QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator*>(o.data());
QVERIFY(instantiator != nullptr);
QSignalSpy activeSpy(instantiator, SIGNAL(activeChanged()));
QSignalSpy countSpy(instantiator, SIGNAL(countChanged()));
@@ -178,7 +183,8 @@ void tst_qqmlinstantiator::intModelChange()
{
QQmlEngine engine;
QQmlComponent component(&engine, testFileUrl("createMultiple.qml"));
- QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator*>(component.create());
+ QScopedPointer<QObject> o(component.create());
+ QQmlInstantiator *instantiator = qobject_cast<QQmlInstantiator*>(o.data());
QVERIFY(instantiator != nullptr);
QSignalSpy activeSpy(instantiator, SIGNAL(activeChanged()));
QSignalSpy countSpy(instantiator, SIGNAL(countChanged()));
@@ -214,7 +220,7 @@ void tst_qqmlinstantiator::createAndRemove()
QScopedPointer<StringModel> model {new StringModel("model1")};
qmlRegisterSingletonInstance("Test", 1, 0, "Model1", model.get());
QQmlComponent component(&engine, testFileUrl("createAndRemove.qml"));
- QObject *rootObject = component.create();
+ QScopedPointer<QObject> rootObject(component.create());
QVERIFY(rootObject != nullptr);
QQmlInstantiator *instantiator =
diff --git a/tests/auto/quick/qquickgridview/data/qtbug86255.qml b/tests/auto/quick/qquickgridview/data/qtbug86255.qml
new file mode 100644
index 0000000000..20688b1967
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/data/qtbug86255.qml
@@ -0,0 +1,55 @@
+import QtQuick 2.15
+
+Item {
+ width: 240
+ height: 320
+
+ GridView {
+ id: grid
+ objectName: "view"
+ anchors.fill: parent
+ cellWidth: 64
+ cellHeight: 64
+ model: ListModel {
+ id: listModel
+
+ Component.onCompleted: reload()
+
+ function reload() {
+ clear();
+ for (let i = 0; i < 1000; i++) {
+ let magic = Math.random();
+ append( { magic } );
+ }
+ }
+ }
+ clip: true
+ delegate: Item {
+ id: d
+ property string val: magic
+ Loader {
+ property alias value: d.val
+ asynchronous: true
+ sourceComponent: cmp
+ }
+ }
+ }
+
+ Timer {
+ running: true
+ interval: 1000
+ onTriggered: listModel.reload()
+ }
+ Timer {
+ running: true
+ interval: 500
+ onTriggered: grid.flick(0, -4000)
+ }
+
+ Component {
+ id: cmp
+ Text {
+ text: value
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index 94ec4f44d5..7d0d9fa7a7 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -213,6 +213,7 @@ private slots:
void QTBUG_45640();
void QTBUG_49218();
void QTBUG_48870_fastModelUpdates();
+ void QTBUG_86255();
void keyNavigationEnabled();
void resizeDynamicCellWidthRtL();
@@ -6814,6 +6815,18 @@ void tst_QQuickGridView::resizeDynamicCellWidthRtL()
QTRY_COMPARE(gridview->contentX(), 0.f);
}
+void tst_QQuickGridView::QTBUG_86255()
+{
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("qtbug86255.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QQuickGridView *view = findItem<QQuickGridView>(window->rootObject(), "view");
+ QVERIFY(view != nullptr);
+ QTRY_COMPARE(view->isFlicking(), true);
+ QTRY_COMPARE(view->isFlicking(), false);
+}
+
void tst_QQuickGridView::releaseItems()
{
QScopedPointer<QQuickView> view(createView());
diff --git a/tests/auto/quick/qquickstates/data/jsValueWhen.qml b/tests/auto/quick/qquickstates/data/jsValueWhen.qml
new file mode 100644
index 0000000000..6d5eb1600c
--- /dev/null
+++ b/tests/auto/quick/qquickstates/data/jsValueWhen.qml
@@ -0,0 +1,18 @@
+import QtQuick 2.15
+
+Item {
+ id: root
+ property var prop: null
+ property bool works: false
+ states: [
+ State {
+ name: "mystate"
+ when: root.prop
+ PropertyChanges {
+ target: root
+ works: "works"
+ }
+ }
+ ]
+ Component.onCompleted: root.prop = new Object
+}
diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
index aa55b42935..26e86672b0 100644
--- a/tests/auto/quick/qquickstates/tst_qquickstates.cpp
+++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
@@ -188,6 +188,7 @@ private slots:
void revertListMemoryLeak();
void duplicateStateName();
void trivialWhen();
+ void jsValueWhen();
void noStateOsciallation();
void parentChangeCorrectReversal();
void revertNullObjectBinding();
@@ -1734,6 +1735,16 @@ void tst_qquickstates::trivialWhen()
QVERIFY(c.create());
}
+void tst_qquickstates::jsValueWhen()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("jsValueWhen.qml"));
+ QScopedPointer<QObject> root(c.create());
+ QVERIFY(root);
+ QVERIFY(root->property("works").toBool());
+}
+
void tst_qquickstates::noStateOsciallation()
{
QQmlEngine engine;