diff options
Diffstat (limited to 'tests/auto/qml')
192 files changed, 3116 insertions, 1081 deletions
diff --git a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp index 21384ef3d8..92065d35e3 100644 --- a/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp +++ b/tests/auto/qml/animation/qpauseanimationjob/tst_qpauseanimationjob.cpp @@ -120,10 +120,10 @@ void tst_QPauseAnimationJob::changeDirectionWhileRunning() animation.setDuration(400); animation.start(); QTest::qWait(100); - QVERIFY(animation.state() == QAbstractAnimationJob::Running); + QCOMPARE(animation.state(), QAbstractAnimationJob::Running); animation.setDirection(QAbstractAnimationJob::Backward); QTest::qWait(animation.totalDuration() + 50); - QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(animation.state(), QAbstractAnimationJob::Stopped); } void tst_QPauseAnimationJob::noTimerUpdates_data() @@ -155,7 +155,7 @@ void tst_QPauseAnimationJob::noTimerUpdates() QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(animation.state(), QAbstractAnimationJob::Stopped); const int expectedLoopCount = 1 + loopCount; #ifdef Q_OS_WIN @@ -183,13 +183,13 @@ void tst_QPauseAnimationJob::multiplePauseAnimations() if (animation.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(animation.state(), QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (animation2.state() != QAbstractAnimationJob::Running) QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(animation2.state() == QAbstractAnimationJob::Running); + QCOMPARE(animation2.state(), QAbstractAnimationJob::Running); #ifdef Q_OS_WIN if (animation.m_updateCurrentTimeCount != 2) @@ -224,7 +224,7 @@ void tst_QPauseAnimationJob::pauseAndPropertyAnimations() QCOMPARE(animation.state(), QAbstractAnimationJob::Running); QTRY_COMPARE(animation.state(), QAbstractAnimationJob::Running); - QVERIFY(pause.state() == QAbstractAnimationJob::Running); + QCOMPARE(pause.state(), QAbstractAnimationJob::Running); QVERIFY2(pause.m_updateCurrentTimeCount >= 2, QByteArrayLiteral("pause.m_updateCurrentTimeCount=") + QByteArray::number(pause.m_updateCurrentTimeCount)); @@ -245,7 +245,7 @@ void tst_QPauseAnimationJob::pauseResume() QCOMPARE(animation.state(), QAbstractAnimationJob::Paused); animation.start(); QTest::qWait(300); - QTRY_VERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QTRY_COMPARE(animation.state(), QAbstractAnimationJob::Stopped); QVERIFY2(animation.m_updateCurrentTimeCount >= 3, QByteArrayLiteral("animation.m_updateCurrentTimeCount=") + QByteArray::number(animation.m_updateCurrentTimeCount)); } @@ -266,39 +266,39 @@ void tst_QPauseAnimationJob::sequentialPauseGroup() QCOMPARE(animation2.m_updateCurrentTimeCount, 0); QCOMPARE(animation3.m_updateCurrentTimeCount, 0); - QVERIFY(group.state() == QAbstractAnimationJob::Running); - QVERIFY(animation1.state() == QAbstractAnimationJob::Running); - QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped); - QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(group.state(), QAbstractAnimationJob::Running); + QCOMPARE(animation1.state(), QAbstractAnimationJob::Running); + QCOMPARE(animation2.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(animation3.state(), QAbstractAnimationJob::Stopped); group.setCurrentTime(250); QCOMPARE(animation1.m_updateCurrentTimeCount, 2); QCOMPARE(animation2.m_updateCurrentTimeCount, 1); QCOMPARE(animation3.m_updateCurrentTimeCount, 0); - QVERIFY(group.state() == QAbstractAnimationJob::Running); - QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(group.state(), QAbstractAnimationJob::Running); + QCOMPARE(animation1.state(), QAbstractAnimationJob::Stopped); QCOMPARE((QAbstractAnimationJob*)&animation2, group.currentAnimation()); - QVERIFY(animation2.state() == QAbstractAnimationJob::Running); - QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(animation2.state(), QAbstractAnimationJob::Running); + QCOMPARE(animation3.state(), QAbstractAnimationJob::Stopped); group.setCurrentTime(500); QCOMPARE(animation1.m_updateCurrentTimeCount, 2); QCOMPARE(animation2.m_updateCurrentTimeCount, 2); QCOMPARE(animation3.m_updateCurrentTimeCount, 1); - QVERIFY(group.state() == QAbstractAnimationJob::Running); - QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped); - QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(group.state(), QAbstractAnimationJob::Running); + QCOMPARE(animation1.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(animation2.state(), QAbstractAnimationJob::Stopped); QCOMPARE((QAbstractAnimationJob*)&animation3, group.currentAnimation()); - QVERIFY(animation3.state() == QAbstractAnimationJob::Running); + QCOMPARE(animation3.state(), QAbstractAnimationJob::Running); group.setCurrentTime(750); - QVERIFY(group.state() == QAbstractAnimationJob::Stopped); - QVERIFY(animation1.state() == QAbstractAnimationJob::Stopped); - QVERIFY(animation2.state() == QAbstractAnimationJob::Stopped); - QVERIFY(animation3.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(group.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(animation1.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(animation2.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(animation3.state(), QAbstractAnimationJob::Stopped); QCOMPARE(animation1.m_updateCurrentTimeCount, 2); QCOMPARE(animation2.m_updateCurrentTimeCount, 2); @@ -318,22 +318,22 @@ void tst_QPauseAnimationJob::sequentialGroupWithPause() group.start(); - QVERIFY(group.state() == QAbstractAnimationJob::Running); - QVERIFY(animation.state() == QAbstractAnimationJob::Running); - QVERIFY(pause.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(group.state(), QAbstractAnimationJob::Running); + QCOMPARE(animation.state(), QAbstractAnimationJob::Running); + QCOMPARE(pause.state(), QAbstractAnimationJob::Stopped); group.setCurrentTime(300); - QVERIFY(group.state() == QAbstractAnimationJob::Running); - QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(group.state(), QAbstractAnimationJob::Running); + QCOMPARE(animation.state(), QAbstractAnimationJob::Stopped); QCOMPARE((QAbstractAnimationJob*)&pause, group.currentAnimation()); - QVERIFY(pause.state() == QAbstractAnimationJob::Running); + QCOMPARE(pause.state(), QAbstractAnimationJob::Running); group.setCurrentTime(600); - QVERIFY(group.state() == QAbstractAnimationJob::Stopped); - QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); - QVERIFY(pause.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(group.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(animation.state(), QAbstractAnimationJob::Stopped); + QCOMPARE(pause.state(), QAbstractAnimationJob::Stopped); QCOMPARE(pause.m_updateCurrentTimeCount, 2); } @@ -383,11 +383,11 @@ void tst_QPauseAnimationJob::multipleSequentialGroups() group.start(); - QVERIFY(group.state() == QAbstractAnimationJob::Running); - QVERIFY(subgroup1.state() == QAbstractAnimationJob::Running); - QVERIFY(subgroup2.state() == QAbstractAnimationJob::Running); - QVERIFY(subgroup3.state() == QAbstractAnimationJob::Running); - QVERIFY(subgroup4.state() == QAbstractAnimationJob::Running); + QCOMPARE(group.state(), QAbstractAnimationJob::Running); + QCOMPARE(subgroup1.state(), QAbstractAnimationJob::Running); + QCOMPARE(subgroup2.state(), QAbstractAnimationJob::Running); + QCOMPARE(subgroup3.state(), QAbstractAnimationJob::Running); + QCOMPARE(subgroup4.state(), QAbstractAnimationJob::Running); // This is a pretty long animation so it tends to get rather out of sync // when using the consistent timer, so run for an extra half second for good @@ -398,31 +398,31 @@ void tst_QPauseAnimationJob::multipleSequentialGroups() if (group.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif - QTRY_VERIFY(group.state() == QAbstractAnimationJob::Stopped); + QTRY_COMPARE(group.state(), QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (subgroup1.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(subgroup1.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(subgroup1.state(), QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (subgroup2.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(subgroup2.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(subgroup2.state(), QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (subgroup3.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(subgroup3.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(subgroup3.state(), QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (subgroup4.state() != QAbstractAnimationJob::Stopped) QEXPECT_FAIL("", winTimerError, Abort); #endif - QVERIFY(subgroup4.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(subgroup4.state(), QAbstractAnimationJob::Stopped); #ifdef Q_OS_WIN if (pause5.m_updateCurrentTimeCount != 4) @@ -437,7 +437,7 @@ void tst_QPauseAnimationJob::zeroDuration() animation.setDuration(0); animation.start(); QTest::qWait(animation.totalDuration() + 100); - QVERIFY(animation.state() == QAbstractAnimationJob::Stopped); + QCOMPARE(animation.state(), QAbstractAnimationJob::Stopped); QCOMPARE(animation.m_updateCurrentTimeCount, 1); } diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/BLACKLIST b/tests/auto/qml/animation/qsequentialanimationgroupjob/BLACKLIST new file mode 100644 index 0000000000..2afe6074d7 --- /dev/null +++ b/tests/auto/qml/animation/qsequentialanimationgroupjob/BLACKLIST @@ -0,0 +1,2 @@ +[finishWithUncontrolledAnimation] +* diff --git a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp index 848bec0b0b..f004593d94 100644 --- a/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp +++ b/tests/auto/qml/animation/qsequentialanimationgroupjob/tst_qsequentialanimationgroupjob.cpp @@ -911,7 +911,7 @@ void tst_QSequentialAnimationGroupJob::startDelay() QTest::qWait(500); QTRY_COMPARE(group.state(), QAnimationGroupJob::Stopped); - QVERIFY(group.currentLoopTime() == 375); + QCOMPARE(group.currentLoopTime(), 375); } void tst_QSequentialAnimationGroupJob::clearGroup() @@ -1456,7 +1456,7 @@ void tst_QSequentialAnimationGroupJob::addRemoveAnimation() void tst_QSequentialAnimationGroupJob::currentAnimation() { QSequentialAnimationGroupJob group; - QVERIFY(group.currentAnimation() == 0); + QVERIFY(!group.currentAnimation()); TestAnimation anim(0); group.appendAnimation(&anim); @@ -1466,7 +1466,7 @@ void tst_QSequentialAnimationGroupJob::currentAnimation() void tst_QSequentialAnimationGroupJob::currentAnimationWithZeroDuration() { QSequentialAnimationGroupJob group; - QVERIFY(group.currentAnimation() == 0); + QVERIFY(!group.currentAnimation()); TestAnimation zero1(0); TestAnimation zero2(0); diff --git a/tests/auto/qml/debugger/debugger.pro b/tests/auto/qml/debugger/debugger.pro index fc1c0b537b..6b47801720 100644 --- a/tests/auto/qml/debugger/debugger.pro +++ b/tests/auto/qml/debugger/debugger.pro @@ -8,10 +8,12 @@ PUBLICTESTS += \ qpacketprotocol \ qqmlenginedebuginspectorintegrationtest \ qqmlenginecontrol \ - qqmldebuggingenabler + qqmldebuggingenabler \ + qqmlnativeconnector PRIVATETESTS += \ qqmldebugclient \ + qqmldebuglocal \ qqmldebugservice SUBDIRS += $$PUBLICTESTS diff --git a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp index 6f559d7833..d0801dd4ee 100644 --- a/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp +++ b/tests/auto/qml/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp @@ -185,7 +185,7 @@ void tst_QDebugMessageService::init() if (m_client->state() != QQmlDebugClient::Enabled) QQmlDebugTest::waitForSignal(m_client, SIGNAL(enabled())); - QVERIFY(m_client->state() == QQmlDebugClient::Enabled); + QCOMPARE(m_client->state(), QQmlDebugClient::Enabled); } void tst_QDebugMessageService::cleanup() diff --git a/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp index 155f11bdaf..db9e621d54 100644 --- a/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp +++ b/tests/auto/qml/debugger/qpacketprotocol/tst_qpacketprotocol.cpp @@ -222,7 +222,7 @@ void tst_QPacketProtocol::read() void tst_QPacketProtocol::device() { QPacketProtocol p(m_client); - QVERIFY(p.device() == m_client); + QCOMPARE(p.device(), m_client); } void tst_QPacketProtocol::tst_QPacket_clear() diff --git a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp index 7ca69b6d44..6fc6c6a914 100644 --- a/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp +++ b/tests/auto/qml/debugger/qqmldebugclient/tst_qqmldebugclient.cpp @@ -42,6 +42,8 @@ #include "debugutil_p.h" #include "qqmldebugtestservice.h" +#include <private/qqmldebugconnector_p.h> + #define PORT 13770 #define STR_PORT "13770" @@ -51,6 +53,7 @@ class tst_QQmlDebugClient : public QObject private: QQmlDebugConnection *m_conn; + QQmlDebugTestService *m_service; private slots: void initTestCase(); @@ -64,26 +67,31 @@ private slots: void tst_QQmlDebugClient::initTestCase() { + QQmlDebugConnector::setPluginKey(QLatin1String("QQmlDebugServer")); + QTest::ignoreMessage(QtWarningMsg, + "QML debugger: Cannot set plugin key after loading the plugin."); + + m_service = new QQmlDebugTestService("tst_QQmlDebugClient::handshake()"); const QString waitingMsg = QString("QML Debugger: Waiting for connection on port %1...").arg(PORT); QTest::ignoreMessage(QtDebugMsg, waitingMsg.toLatin1().constData()); + QQmlDebuggingEnabler::startTcpDebugServer(PORT); + new QQmlEngine(this); m_conn = new QQmlDebugConnection(this); QQmlDebugTestClient client("tst_QQmlDebugClient::handshake()", m_conn); - QQmlDebugTestService service("tst_QQmlDebugClient::handshake()"); + for (int i = 0; i < 50; ++i) { // try for 5 seconds ... m_conn->connectToHost("127.0.0.1", PORT); - if (m_conn->waitForConnected()) + if (m_conn->waitForConnected(100)) break; - QTest::qSleep(100); } QVERIFY(m_conn->isConnected()); - QTRY_VERIFY(QQmlDebugService::hasDebuggingClient()); QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); } @@ -107,14 +115,6 @@ void tst_QQmlDebugClient::state() QQmlDebugTestClient client("tst_QQmlDebugClient::state()", m_conn); QCOMPARE(client.state(), QQmlDebugClient::Unavailable); - { - QQmlDebugTestService service("tst_QQmlDebugClient::state()", 2); - QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); - QCOMPARE(client.serviceVersion(), 2.0f); - } - - QTRY_COMPARE(client.state(), QQmlDebugClient::Unavailable); - // duplicate plugin name QTest::ignoreMessage(QtWarningMsg, "QQmlDebugClient: Conflicting plugin name \"tst_QQmlDebugClient::state()\""); QQmlDebugClient client2("tst_QQmlDebugClient::state()", m_conn); @@ -126,8 +126,7 @@ void tst_QQmlDebugClient::state() void tst_QQmlDebugClient::sendMessage() { - QQmlDebugTestService service("tst_QQmlDebugClient::sendMessage()"); - QQmlDebugTestClient client("tst_QQmlDebugClient::sendMessage()", m_conn); + QQmlDebugTestClient client("tst_QQmlDebugClient::handshake()", m_conn); QByteArray msg = "hello!"; @@ -153,7 +152,6 @@ void tst_QQmlDebugClient::sequentialConnect() { QQmlDebugConnection connection2; QQmlDebugTestClient client2("tst_QQmlDebugClient::handshake()", &connection2); - QQmlDebugTestService service("tst_QQmlDebugClient::handshake()"); m_conn->close(); QVERIFY(!m_conn->isConnected()); @@ -165,23 +163,10 @@ void tst_QQmlDebugClient::sequentialConnect() connection2.connectToHost("127.0.0.1", PORT); QVERIFY(connection2.waitForConnected()); QVERIFY(connection2.isConnected()); - QTRY_VERIFY(client2.state() == QQmlDebugClient::Enabled); + QTRY_COMPARE(client2.state(), QQmlDebugClient::Enabled); } -int main(int argc, char *argv[]) -{ - int _argc = argc + 1; - char **_argv = new char*[_argc]; - for (int i = 0; i < argc; ++i) - _argv[i] = argv[i]; - char arg[] = "-qmljsdebugger=port:" STR_PORT; - _argv[_argc - 1] = arg; - - QGuiApplication app(_argc, _argv); - tst_QQmlDebugClient tc; - return QTest::qExec(&tc, _argc, _argv); - delete _argv; -} +QTEST_MAIN(tst_QQmlDebugClient) #include "tst_qqmldebugclient.moc" diff --git a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp index 4ab1ac0a4c..98ef590317 100644 --- a/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp +++ b/tests/auto/qml/debugger/qqmldebuggingenabler/qqmldebuggingenabler/tst_qqmldebuggingenabler.cpp @@ -98,7 +98,7 @@ bool tst_QQmlDebuggingEnabler::init(bool blockMode, bool qmlscene, int portFrom, if (qmlscene) { process->start(QStringList() << QLatin1String("-qmljsdebugger=port:") + - QString::number(portFrom) + QLatin1String(",") + QString::number(portTo) + + QString::number(portFrom) + QLatin1Char(',') + QString::number(portTo) + QLatin1String(blockMode ? ",block": "") << testFile(QLatin1String("test.qml"))); } else { diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp index ed424b5a67..7dbe35807d 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp +++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp @@ -120,6 +120,8 @@ const char *UNCAUGHT = "uncaught"; const char *BLOCKMODE = "-qmljsdebugger=port:3771,3800,block"; const char *NORMALMODE = "-qmljsdebugger=port:3771,3800"; +const char *BLOCKRESTRICTEDMODE = "-qmljsdebugger=port:3771,3800,block,services:V8Debugger"; +const char *NORMALRESTRICTEDMODE = "-qmljsdebugger=port:3771,3800,services:V8Debugger"; const char *TEST_QMLFILE = "test.qml"; const char *TEST_JSFILE = "test.js"; const char *TIMER_QMLFILE = "timer.qml"; @@ -157,7 +159,8 @@ class tst_QQmlDebugJS : public QQmlDataTest { Q_OBJECT - bool init(const QString &qmlFile = QString(TEST_QMLFILE), bool blockMode = true); + void init(const QString &qmlFile = QString(TEST_QMLFILE), bool blockMode = true, + bool restrictServices = false); private slots: void initTestCase(); @@ -165,6 +168,7 @@ private slots: void cleanup(); + void connect_data(); void connect(); void interrupt(); void getVersion(); @@ -822,33 +826,29 @@ void tst_QQmlDebugJS::cleanupTestCase() // qDebug() << "Time Elapsed:" << t.elapsed(); } -bool tst_QQmlDebugJS::init(const QString &qmlFile, bool blockMode) +void tst_QQmlDebugJS::init(const QString &qmlFile, bool blockMode, bool restrictServices) { connection = new QQmlDebugConnection(); process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); client = new QJSDebugClient(connection); + const char *args = 0; if (blockMode) - process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(qmlFile)); + args = restrictServices ? BLOCKRESTRICTEDMODE : BLOCKMODE; else - process->start(QStringList() << QLatin1String(NORMALMODE) << testFile(qmlFile)); + args = restrictServices ? NORMALRESTRICTEDMODE : NORMALMODE; - if (!process->waitForSessionStart()) { - qDebug() << "could not launch application, or did not get 'Waiting for connection'."; - return false; - } + process->start(QStringList() << QLatin1String(args) << testFile(qmlFile)); + + QVERIFY(process->waitForSessionStart()); const int port = process->debugPort(); connection->connectToHost("127.0.0.1", port); - if (!connection->waitForConnected()) { - qDebug() << "could not connect to host!"; - return false; - } + QVERIFY(connection->waitForConnected()); - if (client->state() == QQmlDebugClient::Enabled) - return true; - return QQmlDebugTest::waitForSignal(client, SIGNAL(enabled())); + if (client->state() != QQmlDebugClient::Enabled) + QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(enabled()))); } void tst_QQmlDebugJS::cleanup() @@ -874,11 +874,21 @@ void tst_QQmlDebugJS::cleanup() connection = 0; } -void tst_QQmlDebugJS::connect() +void tst_QQmlDebugJS::connect_data() { - //void connect() + QTest::addColumn<bool>("blockMode"); + QTest::addColumn<bool>("restrictMode"); + QTest::newRow("normal/unrestricted") << false << false; + QTest::newRow("block/unrestricted") << true << false; + QTest::newRow("normal/restricted") << false << true; + QTest::newRow("block/restricted") << true << true; +} - QVERIFY(init()); +void tst_QQmlDebugJS::connect() +{ + QFETCH(bool, blockMode); + QFETCH(bool, restrictMode); + init(QString(TEST_QMLFILE), blockMode, restrictMode); client->connect(); QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(connected()))); } @@ -887,7 +897,7 @@ void tst_QQmlDebugJS::interrupt() { //void connect() - QVERIFY(init()); + init(); client->connect(); client->interrupt(); @@ -898,7 +908,7 @@ void tst_QQmlDebugJS::getVersion() { //void version() - QVERIFY(init()); + init(); client->connect(); QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(connected()))); @@ -923,7 +933,7 @@ void tst_QQmlDebugJS::disconnect() { //void disconnect() - QVERIFY(init()); + init(); client->connect(); client->disconnect(); @@ -935,7 +945,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnCompleted() //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) int sourceLine = 39; - QVERIFY(init(ONCOMPLETED_QMLFILE)); + init(ONCOMPLETED_QMLFILE); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); client->connect(); @@ -955,7 +965,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated() //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) int sourceLine = 39; - QVERIFY(init(CREATECOMPONENT_QMLFILE)); + init(CREATECOMPONENT_QMLFILE); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); client->connect(); @@ -973,7 +983,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComponentCreated() void tst_QQmlDebugJS::setBreakpointInScriptOnTimerCallback() { int sourceLine = 40; - QVERIFY(init(TIMER_QMLFILE)); + init(TIMER_QMLFILE); client->connect(); //We can set the breakpoint after connect() here because the timer is repeating and if we miss @@ -995,7 +1005,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptInDifferentFile() //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) int sourceLine = 35; - QVERIFY(init(LOADJSFILE_QMLFILE)); + init(LOADJSFILE_QMLFILE); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(TEST_JSFILE), sourceLine, -1, true); client->connect(); @@ -1016,7 +1026,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnComment() int sourceLine = 39; int actualLine = 41; - QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE)); + init(BREAKPOINTRELOCATION_QMLFILE); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); client->connect(); @@ -1038,7 +1048,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnEmptyLine() int sourceLine = 40; int actualLine = 41; - QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE)); + init(BREAKPOINTRELOCATION_QMLFILE); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); client->connect(); @@ -1059,7 +1069,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptOnOptimizedBinding() //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) int sourceLine = 44; - QVERIFY(init(BREAKPOINTRELOCATION_QMLFILE)); + init(BREAKPOINTRELOCATION_QMLFILE); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(BREAKPOINTRELOCATION_QMLFILE), sourceLine, -1, true); client->connect(); @@ -1078,7 +1088,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition() { int out = 10; int sourceLine = 42; - QVERIFY(init(CONDITION_QMLFILE)); + init(CONDITION_QMLFILE); client->connect(); //The breakpoint is in a timer loop so we can set it after connect(). @@ -1112,7 +1122,7 @@ void tst_QQmlDebugJS::setBreakpointInScriptWithCondition() void tst_QQmlDebugJS::setBreakpointInScriptThatQuits() { - QVERIFY(init(QUIT_QMLFILE)); + init(QUIT_QMLFILE); int sourceLine = 41; @@ -1153,7 +1163,7 @@ void tst_QQmlDebugJS::setBreakpointOnEvent() //void setBreakpoint(QString type, QString target, int line = -1, int column = -1, bool enabled = false, QString condition = QString(), int ignoreCount = -1) - QVERIFY(init(TIMER_QMLFILE)); + init(TIMER_QMLFILE); client->setBreakpoint(QLatin1String(EVENT), QLatin1String("triggered"), -1, -1, true); client->connect(); @@ -1174,7 +1184,7 @@ void tst_QQmlDebugJS::clearBreakpoint() int sourceLine1 = 42; int sourceLine2 = 43; - QVERIFY(init(CHANGEBREAKPOINT_QMLFILE)); + init(CHANGEBREAKPOINT_QMLFILE); client->connect(); //The breakpoints are in a timer loop so we can set them after connect(). @@ -1219,7 +1229,7 @@ void tst_QQmlDebugJS::setExceptionBreak() { //void setExceptionBreak(QString type, bool enabled = false); - QVERIFY(init(EXCEPTION_QMLFILE)); + init(EXCEPTION_QMLFILE); client->setExceptionBreak(QJSDebugClient::All,true); client->connect(); QVERIFY(QQmlDebugTest::waitForSignal(client, SIGNAL(stopped()))); @@ -1230,7 +1240,7 @@ void tst_QQmlDebugJS::stepNext() //void continueDebugging(StepAction stepAction, int stepCount = 1); int sourceLine = 42; - QVERIFY(init(STEPACTION_QMLFILE)); + init(STEPACTION_QMLFILE); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); client->connect(); @@ -1254,7 +1264,7 @@ void tst_QQmlDebugJS::stepIn() int sourceLine = 46; int actualLine = 42; - QVERIFY(init(STEPACTION_QMLFILE)); + init(STEPACTION_QMLFILE); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, 1, true); client->connect(); @@ -1278,7 +1288,7 @@ void tst_QQmlDebugJS::stepOut() int sourceLine = 42; int actualLine = 46; - QVERIFY(init(STEPACTION_QMLFILE)); + init(STEPACTION_QMLFILE); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine, -1, true); client->connect(); @@ -1302,7 +1312,7 @@ void tst_QQmlDebugJS::continueDebugging() int sourceLine1 = 46; int sourceLine2 = 43; - QVERIFY(init(STEPACTION_QMLFILE)); + init(STEPACTION_QMLFILE); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine1, -1, true); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(STEPACTION_QMLFILE), sourceLine2, -1, true); @@ -1326,7 +1336,7 @@ void tst_QQmlDebugJS::backtrace() //void backtrace(int fromFrame = -1, int toFrame = -1, bool bottom = false); int sourceLine = 39; - QVERIFY(init(ONCOMPLETED_QMLFILE)); + init(ONCOMPLETED_QMLFILE); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); client->connect(); @@ -1341,7 +1351,7 @@ void tst_QQmlDebugJS::getFrameDetails() //void frame(int number = -1); int sourceLine = 39; - QVERIFY(init(ONCOMPLETED_QMLFILE)); + init(ONCOMPLETED_QMLFILE); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); client->connect(); @@ -1356,7 +1366,7 @@ void tst_QQmlDebugJS::getScopeDetails() //void scope(int number = -1, int frameNumber = -1); int sourceLine = 39; - QVERIFY(init(ONCOMPLETED_QMLFILE)); + init(ONCOMPLETED_QMLFILE); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); client->connect(); @@ -1371,7 +1381,7 @@ void tst_QQmlDebugJS::evaluateInGlobalScope() { //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap()); - QVERIFY(init()); + init(); client->connect(); client->evaluate(QLatin1String("console.log('Hello World')"), true); @@ -1393,7 +1403,7 @@ void tst_QQmlDebugJS::evaluateInLocalScope() //void evaluate(QString expr, bool global = false, bool disableBreak = false, int frame = -1, const QVariantMap &addContext = QVariantMap()); int sourceLine = 47; - QVERIFY(init(ONCOMPLETED_QMLFILE)); + init(ONCOMPLETED_QMLFILE); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QLatin1String(ONCOMPLETED_QMLFILE), sourceLine, -1, true); client->connect(); @@ -1427,7 +1437,7 @@ void tst_QQmlDebugJS::getScripts() { //void scripts(int types = -1, QList<int> ids = QList<int>(), bool includeSource = false, QVariant filter = QVariant()); - QVERIFY(init()); + init(); client->setBreakpoint(QLatin1String(SCRIPTREGEXP), QString(TEST_QMLFILE), 40, -1, true); client->connect(); diff --git a/tests/auto/qml/debugger/qqmldebuglocal/qqmldebuglocal.pro b/tests/auto/qml/debugger/qqmldebuglocal/qqmldebuglocal.pro new file mode 100644 index 0000000000..b612da11de --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebuglocal/qqmldebuglocal.pro @@ -0,0 +1,16 @@ +CONFIG += testcase +TARGET = tst_qqmldebuglocal +osx:CONFIG -= app_bundle + +HEADERS += ../shared/qqmldebugtestservice.h + +SOURCES += tst_qqmldebuglocal.cpp \ + ../shared/qqmldebugtestservice.cpp + +INCLUDEPATH += ../shared +include(../shared/debugutil.pri) + +CONFIG += parallel_test +QT += qml-private testlib gui-private core-private + +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 QT_QML_DEBUG_NO_WARNING diff --git a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp new file mode 100644 index 0000000000..0343ea77ee --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qtest.h> +#include <QSignalSpy> +#include <QTimer> +#include <QHostAddress> +#include <QDebug> +#include <QThread> +#include <ctime> + +#include "debugutil_p.h" +#include "qqmldebugtestservice.h" + +#include <private/qqmldebugconnector_p.h> + +QString fileName; + +class tst_QQmlDebugLocal : public QObject +{ + Q_OBJECT + +private: + QQmlDebugConnection *m_conn; + QQmlDebugTestService *m_service; + + bool connect(); + +signals: + void waiting(); + void parallel(); + +private slots: + void initTestCase(); + + void name(); + void state(); + void sendMessage(); +}; + +void tst_QQmlDebugLocal::initTestCase() +{ + fileName = QString::fromLatin1("tst_QQmlDebugLocal%1").arg(std::time(0)); + QQmlDebugConnector::setPluginKey("QQmlDebugServer"); + QTest::ignoreMessage(QtWarningMsg, + "QML debugger: Cannot set plugin key after loading the plugin."); + m_service = new QQmlDebugTestService("tst_QQmlDebugLocal::handshake()"); + + const QString waitingMsg = QString("QML Debugger: Connecting to socket %1...").arg(fileName); + QTest::ignoreMessage(QtDebugMsg, waitingMsg.toLatin1().constData()); + + m_conn = new QQmlDebugConnection(this); + m_conn->startLocalServer(fileName); + + QQmlDebuggingEnabler::connectToLocalDebugger(fileName); + + new QQmlEngine(this); + + QQmlDebugTestClient client("tst_QQmlDebugLocal::handshake()", m_conn); + + for (int i = 0; i < 50; ++i) { + // try for 5 seconds ... + if (m_conn->waitForConnected(100)) + break; + } + + QVERIFY(m_conn->isConnected()); + + QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); +} + +void tst_QQmlDebugLocal::name() +{ + QString name = "tst_QQmlDebugLocal::name()"; + + QQmlDebugClient client(name, m_conn); + QCOMPARE(client.name(), name); +} + +void tst_QQmlDebugLocal::state() +{ + { + QQmlDebugConnection dummyConn; + QQmlDebugClient client("tst_QQmlDebugLocal::state()", &dummyConn); + QCOMPARE(client.state(), QQmlDebugClient::NotConnected); + QCOMPARE(client.serviceVersion(), -1.0f); + } + + QQmlDebugTestClient client("tst_QQmlDebugLocal::state()", m_conn); + QCOMPARE(client.state(), QQmlDebugClient::Unavailable); + + // duplicate plugin name + QTest::ignoreMessage(QtWarningMsg, "QQmlDebugClient: Conflicting plugin name \"tst_QQmlDebugLocal::state()\""); + QQmlDebugClient client2("tst_QQmlDebugLocal::state()", m_conn); + QCOMPARE(client2.state(), QQmlDebugClient::NotConnected); + + QQmlDebugClient client3("tst_QQmlDebugLocal::state3()", 0); + QCOMPARE(client3.state(), QQmlDebugClient::NotConnected); +} + +void tst_QQmlDebugLocal::sendMessage() +{ + QQmlDebugTestClient client("tst_QQmlDebugLocal::handshake()", m_conn); + + QByteArray msg = "hello!"; + + QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); + + client.sendMessage(msg); + QByteArray resp = client.waitForResponse(); + QCOMPARE(resp, msg); +} + +QTEST_MAIN(tst_QQmlDebugLocal) + +#include "tst_qqmldebuglocal.moc" diff --git a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.pro b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.pro new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.pro diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp index de05594161..b63c5c0a6d 100644 --- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp +++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp @@ -44,6 +44,7 @@ #include "debugutil_p.h" #include "qqmldebugclient.h" #include "qqmldebugtestservice.h" +#include <private/qqmldebugconnector_p.h> #define PORT 3769 #define STR_PORT "3769" @@ -53,7 +54,7 @@ class tst_QQmlDebugService : public QQmlDataTest Q_OBJECT private: QQmlDebugConnection *m_conn; - + QQmlDebugTestService *m_service; private slots: @@ -65,7 +66,6 @@ private slots: void sendMessage(); void idForObject(); void objectForId(); - void objectToString(); void checkSupportForDataStreamVersion(); void checkSupportForOldDataStreamVersion(); }; @@ -73,8 +73,15 @@ private slots: void tst_QQmlDebugService::initTestCase() { QQmlDataTest::initTestCase(); + QQmlDebugConnector::setPluginKey(QLatin1String("QQmlDebugServer")); + QTest::ignoreMessage(QtWarningMsg, + "QML debugger: Cannot set plugin key after loading the plugin."); + m_service = new QQmlDebugTestService("tst_QQmlDebugService", 2); + const QString waitingMsg = QString("QML Debugger: Waiting for connection on port %1...").arg(PORT); QTest::ignoreMessage(QtDebugMsg, waitingMsg.toLatin1().constData()); + QQmlDebuggingEnabler::startTcpDebugServer(PORT); + new QQmlEngine(this); m_conn = new QQmlDebugConnection(this); @@ -87,8 +94,6 @@ void tst_QQmlDebugService::initTestCase() QTest::qSleep(100); } QVERIFY(m_conn->isConnected()); - - QTRY_VERIFY(QQmlDebugService::hasDebuggingClient()); } void tst_QQmlDebugService::checkPortRange() @@ -128,67 +133,64 @@ void tst_QQmlDebugService::checkPortRange() void tst_QQmlDebugService::name() { - QString name = "tst_QQmlDebugService::name()"; - - QQmlDebugService service(name, 1); - QCOMPARE(service.name(), name); + QCOMPARE(m_service->name(), QLatin1String("tst_QQmlDebugService")); } void tst_QQmlDebugService::version() { - QString name = "tst_QQmlDebugService::name()"; - - QQmlDebugService service(name, 2); - QCOMPARE(service.version(), 2.0f); + QCOMPARE(m_service->version(), 2.0f); } void tst_QQmlDebugService::state() { - QQmlDebugTestService service("tst_QQmlDebugService::state()"); - QCOMPARE(service.state(), QQmlDebugService::Unavailable); + QCOMPARE(m_service->state(), QQmlDebugService::Unavailable); { - QQmlDebugTestClient client("tst_QQmlDebugService::state()", m_conn); + QQmlDebugTestClient client("tst_QQmlDebugService", m_conn); QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); - QTRY_COMPARE(service.state(), QQmlDebugService::Enabled); + QTRY_COMPARE(m_service->state(), QQmlDebugService::Enabled); } + QTRY_COMPARE(m_service->state(), QQmlDebugService::Unavailable); - QTRY_COMPARE(service.state(), QQmlDebugService::Unavailable); - - QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::state()\""); - QQmlDebugTestService duplicate("tst_QQmlDebugService::state()"); + // We can do this because it will never addService() + QTest::ignoreMessage(QtWarningMsg, + "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService\""); + QQmlDebugTestService duplicate("tst_QQmlDebugService"); QCOMPARE(duplicate.state(), QQmlDebugService::NotConnected); + QTest::ignoreMessage(QtWarningMsg, + "QQmlDebugService: Plugin \"tst_QQmlDebugService\" is not registered."); } void tst_QQmlDebugService::sendMessage() { - QQmlDebugTestService service("tst_QQmlDebugService::sendMessage()"); - QQmlDebugTestClient client("tst_QQmlDebugService::sendMessage()", m_conn); + QQmlDebugTestClient client("tst_QQmlDebugService", m_conn); QByteArray msg = "hello!"; QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); - QTRY_COMPARE(service.state(), QQmlDebugService::Enabled); + QTRY_COMPARE(m_service->state(), QQmlDebugService::Enabled); client.sendMessage(msg); QByteArray resp = client.waitForResponse(); QCOMPARE(resp, msg); - QTest::ignoreMessage(QtWarningMsg, "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService::sendMessage()\""); - QQmlDebugTestService duplicate("tst_QQmlDebugService::sendMessage()"); - duplicate.sendMessage("msg"); + QTest::ignoreMessage(QtWarningMsg, + "QQmlDebugService: Conflicting plugin name \"tst_QQmlDebugService\""); + QQmlDebugTestService duplicate("tst_QQmlDebugService"); + emit duplicate.messageToClient(duplicate.name(), "msg"); + QTest::ignoreMessage(QtWarningMsg, + "QQmlDebugService: Plugin \"tst_QQmlDebugService\" is not registered."); } void tst_QQmlDebugService::checkSupportForDataStreamVersion() { - QQmlDebugTestService service("tst_QQmlDebugService::sendMessage2()"); - QQmlDebugTestClient client("tst_QQmlDebugService::sendMessage2()", m_conn); + QQmlDebugTestClient client("tst_QQmlDebugService", m_conn); QByteArray msg = "hello!"; QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); - QTRY_COMPARE(service.state(), QQmlDebugService::Enabled); + QTRY_COMPARE(m_service->state(), QQmlDebugService::Enabled); client.sendMessage(msg); QByteArray resp = client.waitForResponse(); @@ -231,18 +233,6 @@ void tst_QQmlDebugService::objectForId() QCOMPARE(QQmlDebugService::objectForId(id), static_cast<QObject*>(0)); } -void tst_QQmlDebugService::objectToString() -{ - QCOMPARE(QQmlDebugService::objectToString(0), QString("NULL")); - - QObject *obj = new QObject; - QCOMPARE(QQmlDebugService::objectToString(obj), QString("QObject: <unnamed>")); - - obj->setObjectName("Hello"); - QCOMPARE(QQmlDebugService::objectToString(obj), QString("QObject: Hello")); - delete obj; -} - void tst_QQmlDebugService::checkSupportForOldDataStreamVersion() { //create a new connection; @@ -258,14 +248,12 @@ void tst_QQmlDebugService::checkSupportForOldDataStreamVersion() } QVERIFY(m_conn->isConnected()); - QTRY_VERIFY(QQmlDebugService::hasDebuggingClient()); - QQmlDebugTestService service("tst_QQmlDebugService::sendMessage2()"); - QQmlDebugTestClient client("tst_QQmlDebugService::sendMessage2()", m_conn); + QQmlDebugTestClient client("tst_QQmlDebugService", m_conn); QByteArray msg = "hello!"; QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); - QTRY_COMPARE(service.state(), QQmlDebugService::Enabled); + QTRY_COMPARE(m_service->state(), QQmlDebugService::Enabled); client.sendMessage(msg); QByteArray resp = client.waitForResponse(); @@ -273,20 +261,6 @@ void tst_QQmlDebugService::checkSupportForOldDataStreamVersion() QCOMPARE(m_conn->dataStreamVersion(), int(QDataStream::Qt_4_7)); } - -int main(int argc, char *argv[]) -{ - int _argc = argc + 1; - char **_argv = new char*[_argc]; - for (int i = 0; i < argc; ++i) - _argv[i] = argv[i]; - char arg[] = "-qmljsdebugger=port:" STR_PORT ",host:127.0.0.1"; - _argv[_argc - 1] = arg; - - QGuiApplication app(_argc, _argv); - tst_QQmlDebugService tc; - return QTest::qExec(&tc, _argc, _argv); - delete _argv; -} +QTEST_MAIN(tst_QQmlDebugService) #include "tst_qqmldebugservice.moc" diff --git a/tests/auto/qml/debugger/qqmlenginecontrol/tst_qqmlenginecontrol.cpp b/tests/auto/qml/debugger/qqmlenginecontrol/tst_qqmlenginecontrol.cpp index f6cf9dae60..11fa56d710 100644 --- a/tests/auto/qml/debugger/qqmlenginecontrol/tst_qqmlenginecontrol.cpp +++ b/tests/auto/qml/debugger/qqmlenginecontrol/tst_qqmlenginecontrol.cpp @@ -103,12 +103,15 @@ private: QQmlDebugConnection *m_connection; QQmlEngineControlClient *m_client; - void connect(const QString &testFile); + void connect(const QString &testFile, bool restrictServices); + void engine_data(); private slots: void cleanup(); + void startEngine_data(); void startEngine(); + void stopEngine_data(); void stopEngine(); }; @@ -148,11 +151,13 @@ void QQmlEngineControlClient::messageReceived(const QByteArray &message) QVERIFY(stream.atEnd()); } -void tst_QQmlEngineControl::connect(const QString &testFile) +void tst_QQmlEngineControl::connect(const QString &testFile, bool restrictServices) { const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene"; QStringList arguments; - arguments << QString("-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ",block"); + arguments << QString::fromLatin1("-qmljsdebugger=port:%1,%2,block%3") + .arg(STR_PORT_FROM).arg(STR_PORT_TO) + .arg(restrictServices ? QStringLiteral(",services:EngineControl") : QString()); arguments << QQmlDataTest::instance()->testFile(testFile); @@ -165,6 +170,8 @@ void tst_QQmlEngineControl::connect(const QString &testFile) const int port = m_process->debugPort(); m_connection->connectToHost(QLatin1String("127.0.0.1"), port); + + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); } void tst_QQmlEngineControl::cleanup() @@ -183,11 +190,23 @@ void tst_QQmlEngineControl::cleanup() m_connection = 0; } +void tst_QQmlEngineControl::engine_data() +{ + QTest::addColumn<bool>("restrictMode"); + QTest::newRow("unrestricted") << false; + QTest::newRow("restricted") << true; +} + +void tst_QQmlEngineControl::startEngine_data() +{ + engine_data(); +} + void tst_QQmlEngineControl::startEngine() { - connect("test.qml"); - QVERIFY(m_client); - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + QFETCH(bool, restrictMode); + + connect("test.qml", restrictMode); QTRY_VERIFY(!m_client->startingEngines.empty()); m_client->command(QQmlEngineControlClient::StartWaitingEngine, m_client->startingEngines.last()); @@ -196,11 +215,16 @@ void tst_QQmlEngineControl::startEngine() "No engine start message received in time."); } +void tst_QQmlEngineControl::stopEngine_data() +{ + engine_data(); +} + void tst_QQmlEngineControl::stopEngine() { - connect("exit.qml"); - QVERIFY(m_client); - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + QFETCH(bool, restrictMode); + + connect("exit.qml", restrictMode); QTRY_VERIFY(!m_client->startingEngines.empty()); m_client->command(QQmlEngineControlClient::StartWaitingEngine, m_client->startingEngines.last()); diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp index 8d119a30d7..0285bae189 100644 --- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp @@ -61,6 +61,7 @@ public: private: + void init(bool restrictServices); QmlDebugObjectReference findRootObject(); QQmlDebugProcess *m_process; @@ -68,9 +69,9 @@ private: QQmlEngineDebugClient *m_engineDebugClient; private slots: - void init(); void cleanup(); + void connect_data(); void connect(); void clearObjectReferenceHashonReloadQml(); }; @@ -93,9 +94,12 @@ QmlDebugObjectReference tst_QQmlEngineDebugInspectorIntegration::findRootObject( } -void tst_QQmlEngineDebugInspectorIntegration::init() +void tst_QQmlEngineDebugInspectorIntegration::init(bool restrictServices) { - const QString argument = "-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ",block"; + const QString argument = QString::fromLatin1("-qmljsdebugger=port:%1,%2,block%3") + .arg(STR_PORT_FROM).arg(STR_PORT_TO) + .arg(restrictServices ? QStringLiteral(",services:QmlDebugger,QmlInspector") : + QString()); // ### Still using qmlscene because of QTBUG-33376 m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) @@ -108,10 +112,8 @@ void tst_QQmlEngineDebugInspectorIntegration::init() m_inspectorClient = new QQmlInspectorClient(m_connection); m_engineDebugClient = new QQmlEngineDebugClient(m_connection); - const int port = m_process->debugPort(); - m_connection->connectToHost(QLatin1String("127.0.0.1"), port); - bool ok = m_connection->waitForConnected(); - QVERIFY(ok); + m_connection->connectToHost(QLatin1String("127.0.0.1"), m_process->debugPort()); + QVERIFY(m_connection->waitForConnected()); } void tst_QQmlEngineDebugInspectorIntegration::cleanup() @@ -125,14 +127,24 @@ void tst_QQmlEngineDebugInspectorIntegration::cleanup() delete m_inspectorClient; } +void tst_QQmlEngineDebugInspectorIntegration::connect_data() +{ + QTest::addColumn<bool>("restrictMode"); + QTest::newRow("unrestricted") << false; + QTest::newRow("restricted") << true; +} + void tst_QQmlEngineDebugInspectorIntegration::connect() { + QFETCH(bool, restrictMode); + init(restrictMode); QTRY_COMPARE(m_inspectorClient->state(), QQmlDebugClient::Enabled); QTRY_COMPARE(m_engineDebugClient->state(), QQmlDebugClient::Enabled); } void tst_QQmlEngineDebugInspectorIntegration::clearObjectReferenceHashonReloadQml() { + init(true); QTRY_COMPARE(m_engineDebugClient->state(), QQmlDebugClient::Enabled); bool success = false; QmlDebugObjectReference rootObject = findRootObject(); diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index d3bb5c38ca..bc3220ad8c 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -87,6 +87,8 @@ public: class tst_QQmlEngineDebugService : public QObject { Q_OBJECT +public: + tst_QQmlEngineDebugService() : m_conn(0), m_dbg(0), m_engine(0), m_rootItem(0) {} private: QmlDebugObjectReference findRootObject(int context = 0, @@ -349,9 +351,8 @@ void tst_QQmlEngineDebugService::initTestCase() bool ok = m_conn->waitForConnected(); QVERIFY(ok); - QTRY_VERIFY(QQmlDebugService::hasDebuggingClient()); m_dbg = new QQmlEngineDebugClient(m_conn); - QTRY_VERIFY(m_dbg->state() == QQmlEngineDebugClient::Enabled); + QTRY_COMPARE(m_dbg->state(), QQmlEngineDebugClient::Enabled); } void tst_QQmlEngineDebugService::cleanupTestCase() @@ -372,7 +373,7 @@ void tst_QQmlEngineDebugService::setMethodBody() QVariant rv; QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection, Q_RETURN_ARG(QVariant, rv))); - QVERIFY(rv == QVariant(qreal(3))); + QCOMPARE(rv, QVariant(qreal(3))); QVERIFY(m_dbg->setMethodBody(obj.debugId, "myMethodNoArgs", "return 7", @@ -382,7 +383,7 @@ void tst_QQmlEngineDebugService::setMethodBody() QVERIFY(QMetaObject::invokeMethod(root, "myMethodNoArgs", Qt::DirectConnection, Q_RETURN_ARG(QVariant, rv))); - QVERIFY(rv == QVariant(qreal(7))); + QCOMPARE(rv, QVariant(qreal(7))); } // With args @@ -390,7 +391,7 @@ void tst_QQmlEngineDebugService::setMethodBody() QVariant rv; QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection, Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19)))); - QVERIFY(rv == QVariant(qreal(28))); + QCOMPARE(rv, QVariant(qreal(28))); QVERIFY(m_dbg->setMethodBody(obj.debugId, "myMethod", "return a + 7", &success)); @@ -399,7 +400,7 @@ void tst_QQmlEngineDebugService::setMethodBody() QVERIFY(QMetaObject::invokeMethod(root, "myMethod", Qt::DirectConnection, Q_RETURN_ARG(QVariant, rv), Q_ARG(QVariant, QVariant(19)))); - QVERIFY(rv == QVariant(qreal(26))); + QCOMPARE(rv, QVariant(qreal(26))); } } @@ -731,7 +732,7 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation() QVERIFY(success); QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result()))); - QVERIFY(m_dbg->objects().count() == 1); + QCOMPARE(m_dbg->objects().count(), 1); QmlDebugObjectReference obj = m_dbg->objects().first(); // check source as defined in main() @@ -1018,7 +1019,7 @@ void tst_QQmlEngineDebugService::setBindingForObject() mouseAreaObject = m_dbg->object(); onEnteredRef = findProperty(mouseAreaObject.properties, "onEntered"); QCOMPARE(onEnteredRef.name, QString("onEntered")); - QCOMPARE(onEnteredRef.value, QVariant("{console.log('hello, world') }")); + QCOMPARE(onEnteredRef.value, QVariant("function() { [code] }")); } void tst_QQmlEngineDebugService::resetBindingForObject() @@ -1224,7 +1225,7 @@ int main(int argc, char *argv[]) char **_argv = new char*[_argc]; for (int i = 0; i < argc; ++i) _argv[i] = argv[i]; - char arg[] = "-qmljsdebugger=port:3768"; + char arg[] = "-qmljsdebugger=port:3768,services:QmlDebugger"; _argv[_argc - 1] = arg; QGuiApplication app(_argc, _argv); diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp index 5ed866c04d..70833f5e2c 100644 --- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp +++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp @@ -60,7 +60,7 @@ public: } private: - void startQmlsceneProcess(const char *qmlFile); + void startQmlsceneProcess(const char *qmlFile, bool restrictMode = true); private: QQmlDebugProcess *m_process; @@ -68,18 +68,20 @@ private: QQmlInspectorClient *m_client; private slots: - void init(); void cleanup(); + void connect_data(); void connect(); void showAppOnTop(); void reloadQml(); void reloadQmlWindow(); }; -void tst_QQmlInspector::startQmlsceneProcess(const char * /* qmlFile */) +void tst_QQmlInspector::startQmlsceneProcess(const char * /* qmlFile */, bool restrictServices) { - const QString argument = "-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ",block"; + const QString argument = QString::fromLatin1("-qmljsdebugger=port:%1,%2,block%3") + .arg(STR_PORT_FROM).arg(STR_PORT_TO) + .arg(restrictServices ? QStringLiteral(",services:QmlInspector") : QString()); // ### This should be using qml instead of qmlscene, but can't because of QTBUG-33376 (same as the XFAIL testcase) m_process = new QQmlDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", this); @@ -87,15 +89,13 @@ void tst_QQmlInspector::startQmlsceneProcess(const char * /* qmlFile */) QVERIFY2(m_process->waitForSessionStart(), "Could not launch application, or did not get 'Waiting for connection'."); - QQmlDebugConnection *m_connection = new QQmlDebugConnection(); + m_connection = new QQmlDebugConnection(); m_client = new QQmlInspectorClient(m_connection); - const int port = m_process->debugPort(); - m_connection->connectToHost(QLatin1String("127.0.0.1"), port); -} + m_connection->connectToHost(QLatin1String("127.0.0.1"), m_process->debugPort()); + QVERIFY(m_client); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); -void tst_QQmlInspector::init() -{ } void tst_QQmlInspector::cleanup() @@ -104,20 +104,31 @@ void tst_QQmlInspector::cleanup() qDebug() << "Process State:" << m_process->state(); qDebug() << "Application Output:" << m_process->output(); } - delete m_process; - delete m_connection; delete m_client; + m_client = 0; + delete m_connection; + m_connection = 0; + delete m_process; + m_process = 0; +} + +void tst_QQmlInspector::connect_data() +{ + QTest::addColumn<bool>("restrictMode"); + QTest::newRow("unrestricted") << false; + QTest::newRow("restricted") << true; } void tst_QQmlInspector::connect() { - startQmlsceneProcess("qtquick2.qml"); - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + QFETCH(bool, restrictMode); + startQmlsceneProcess("qtquick2.qml", restrictMode); } void tst_QQmlInspector::showAppOnTop() { startQmlsceneProcess("qtquick2.qml"); + QVERIFY(m_client); QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->setShowAppOnTop(true); @@ -132,6 +143,7 @@ void tst_QQmlInspector::showAppOnTop() void tst_QQmlInspector::reloadQml() { startQmlsceneProcess("qtquick2.qml"); + QVERIFY(m_client); QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); QByteArray fileContents; @@ -157,6 +169,7 @@ void tst_QQmlInspector::reloadQml() void tst_QQmlInspector::reloadQmlWindow() { startQmlsceneProcess("window.qml"); + QVERIFY(m_client); QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); QByteArray fileContents; @@ -173,8 +186,8 @@ void tst_QQmlInspector::reloadQmlWindow() QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(responseReceived()))); QEXPECT_FAIL("", "cannot debug with a QML file containing a top-level Window", Abort); // QTBUG-33376 - QTRY_COMPARE(m_process->output().contains( - QString("version 2.0")), true); + // TODO: remove the timeout once we don't expect it to fail anymore. + QTRY_VERIFY_WITH_TIMEOUT(m_process->output().contains(QString("version 2.0")), 1); QCOMPARE(m_client->m_requestResult, true); QCOMPARE(m_client->m_reloadRequestId, m_client->m_responseId); diff --git a/tests/auto/qml/debugger/qqmlnativeconnector/qqmlnativeconnector.pro b/tests/auto/qml/debugger/qqmlnativeconnector/qqmlnativeconnector.pro new file mode 100644 index 0000000000..757aa0306d --- /dev/null +++ b/tests/auto/qml/debugger/qqmlnativeconnector/qqmlnativeconnector.pro @@ -0,0 +1,6 @@ +CONFIG += testcase qml_debug +TARGET = tst_qqmlnativeconnector +QT += qml testlib gui-private core-private +osx:CONFIG -= app_bundle + +SOURCES += tst_qqmlnativeconnector.cpp diff --git a/tests/auto/qml/debugger/qqmlnativeconnector/tst_qqmlnativeconnector.cpp b/tests/auto/qml/debugger/qqmlnativeconnector/tst_qqmlnativeconnector.cpp new file mode 100644 index 0000000000..099b952352 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlnativeconnector/tst_qqmlnativeconnector.cpp @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/qjsondocument.h> +#include <QtCore/qjsonobject.h> +#include <QtCore/qtimer.h> +#include <QtTest/qtest.h> +#include <QtQml/qqmlapplicationengine.h> +#include <QtQml/qqmlcomponent.h> + +#include <private/qhooks_p.h> + +const char testData[] = +"import QtQuick 2.0\n" +"Item {\n" +" id: item\n" +" property int a: 0\n" +" Timer {\n" +" id: timer; interval: 1; repeat: true; running: true\n" +" onTriggered: {\n" +" a++\n" +" }\n" +" }\n" +"}\n"; + +struct ResolvedHooks +{ + quintptr version; + quintptr numEntries; + const char **qt_qmlDebugMessageBuffer; + int *qt_qmlDebugMessageLength; + bool (*qt_qmlDebugSendDataToService)(const char *serviceName, const char *hexData); + bool (*qt_qmlDebugEnableService)(const char *data); + bool (*qt_qmlDebugDisableService)(const char *data); + void (*qt_qmlDebugObjectAvailable)(); +} *hooks; + +class Application : public QGuiApplication +{ + Q_OBJECT +public: + Application(int &argc, char **argv) + : QGuiApplication(argc, argv), + component(&engine) + { + component.setData(testData, QUrl("MyStuff")); + mainObject = component.create(); + } + +private slots: + void testEcho() + { + QJsonObject request; + QJsonObject arguments; + arguments.insert(QLatin1String("test"), QLatin1String("BUH")); + request.insert(QLatin1String("command"), QLatin1String("echo")); + request.insert(QLatin1String("arguments"), arguments); + QJsonDocument doc; + doc.setObject(request); + QByteArray hexdata = doc.toJson(QJsonDocument::Compact).toHex(); + + hooks = (ResolvedHooks *)qtHookData[QHooks::Startup]; + QCOMPARE(bool(hooks), true); // Available after connector start only. + QCOMPARE(hooks->version, quintptr(1)); + QCOMPARE(hooks->numEntries, quintptr(6)); + QCOMPARE(bool(hooks->qt_qmlDebugSendDataToService), true); + QCOMPARE(bool(hooks->qt_qmlDebugMessageBuffer), true); + QCOMPARE(bool(hooks->qt_qmlDebugMessageLength), true); + QCOMPARE(bool(hooks->qt_qmlDebugEnableService), true); + + hooks->qt_qmlDebugEnableService("NativeQmlDebugger"); + hooks->qt_qmlDebugSendDataToService("NativeQmlDebugger", hexdata); + QByteArray response(*hooks->qt_qmlDebugMessageBuffer, *hooks->qt_qmlDebugMessageLength); + + QCOMPARE(response, QByteArray("NativeQmlDebugger 25 {\"result\":{\"test\":\"BUH\"}}")); + } + +private: + QQmlApplicationEngine engine; + QQmlComponent component; + QObject *mainObject; +}; + +int main(int argc, char *argv[]) +{ + char **argv2 = new char *[argc + 2]; + for (int i = 0; i < argc; ++i) + argv2[i] = argv[i]; + argv2[argc] = strdup("-qmljsdebugger=native,services:NativeQmlDebugger"); + ++argc; + argv2[argc] = 0; + Application app(argc, argv2); + return QTest::qExec(&app, argc, argv); +} + +#include "tst_qqmlnativeconnector.moc" diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/data/timer.qml b/tests/auto/qml/debugger/qqmlprofilerservice/data/timer.qml new file mode 100644 index 0000000000..18b8947172 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlprofilerservice/data/timer.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + width: 100 + height: 62 + + Timer { + running: true + repeat: true + interval: 50 + onTriggered: height = (2 * height) % 99; + } +} + diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro index ec84139797..e422d3ef99 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro +++ b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro @@ -21,4 +21,5 @@ OTHER_FILES += \ data/scenegraphTest.qml \ data/TestImage_2x2.png \ data/signalSourceLocation.qml \ - data/javascript.qml + data/javascript.qml \ + data/timer.qml diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index 094bf43549..0e63e18952 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -139,16 +139,18 @@ public: { } - QList<QQmlProfilerData> qmlMessages; - QList<QQmlProfilerData> javascriptMessages; - QList<QQmlProfilerData> jsHeapMessages; - QList<QQmlProfilerData> asynchronousMessages; - QList<QQmlProfilerData> pixmapMessages; + QVector<QQmlProfilerData> qmlMessages; + QVector<QQmlProfilerData> javascriptMessages; + QVector<QQmlProfilerData> jsHeapMessages; + QVector<QQmlProfilerData> asynchronousMessages; + QVector<QQmlProfilerData> pixmapMessages; - void setTraceState(bool enabled) { + void setTraceState(bool enabled, quint32 flushInterval = 0) { QByteArray message; QDataStream stream(&message, QIODevice::WriteOnly); stream << enabled; + if (enabled && flushInterval) + stream << -1 << std::numeric_limits<quint64>::max() << flushInterval; sendMessage(message); } @@ -195,7 +197,7 @@ private: CheckAll = CheckMessageType | CheckDetailType | CheckLine | CheckColumn | CheckDataEndsWith }; - void connect(bool block, const QString &testFile); + void connect(bool block, const QString &testFile, bool restrictServices = true); void checkTraceReceived(); void checkJsHeap(); bool verify(MessageListType type, int expectedPosition, const QQmlProfilerData &expected, @@ -204,15 +206,15 @@ private: private slots: void cleanup(); - void blockingConnectWithTraceEnabled(); - void blockingConnectWithTraceDisabled(); - void nonBlockingConnect(); + void connect_data(); + void connect(); void pixmapCacheData(); void scenegraphData(); void profileOnExit(); void controlFromJS(); void signalSourceLocation(); void javascript(); + void flushInterval(); }; #define VERIFY(type, position, expected, checks) QVERIFY(verify(type, position, expected, checks)) @@ -354,17 +356,16 @@ void QQmlProfilerClient::messageReceived(const QByteArray &message) qmlMessages.append(data); } -void tst_QQmlProfilerService::connect(bool block, const QString &testFile) +void tst_QQmlProfilerService::connect(bool block, const QString &testFile, bool restrictServices) { // ### Still using qmlscene due to QTBUG-33377 const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene"; QStringList arguments; - if (block) - arguments << QString("-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ",block"); - else - arguments << QString("-qmljsdebugger=port:" STR_PORT_FROM "," STR_PORT_TO ); - - arguments << QQmlDataTest::instance()->testFile(testFile); + arguments << QString::fromLatin1("-qmljsdebugger=port:%1,%2%3%4") + .arg(STR_PORT_FROM).arg(STR_PORT_TO) + .arg(block ? QStringLiteral(",block") : QString()) + .arg(restrictServices ? QStringLiteral(",services:CanvasFrameRate") : QString()) + << QQmlDataTest::instance()->testFile(testFile); m_process = new QQmlDebugProcess(executable, this); m_process->start(QStringList() << arguments); @@ -375,6 +376,8 @@ void tst_QQmlProfilerService::connect(bool block, const QString &testFile) const int port = m_process->debugPort(); m_connection->connectToHost(QLatin1String("127.0.0.1"), port); + QVERIFY(m_client); + QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); } void tst_QQmlProfilerService::checkTraceReceived() @@ -449,7 +452,7 @@ bool tst_QQmlProfilerService::verify(tst_QQmlProfilerService::MessageListType ty int expectedPosition, const QQmlProfilerData &expected, quint32 checks) { - QList<QQmlProfilerData> *target = 0; + QVector<QQmlProfilerData> *target = 0; switch (type) { case MessageListQML: target = &(m_client->qmlMessages); break; case MessageListJavaScript: target = &(m_client->javascriptMessages); break; @@ -509,7 +512,7 @@ bool tst_QQmlProfilerService::verify(tst_QQmlProfilerService::MessageListType ty void tst_QQmlProfilerService::cleanup() { - if (QTest::currentTestFailed()) { + if (m_client && QTest::currentTestFailed()) { qDebug() << "QML Messages:" << m_client->qmlMessages.count(); int i = 0; foreach (const QQmlProfilerData &data, m_client->qmlMessages) { @@ -547,7 +550,7 @@ void tst_QQmlProfilerService::cleanup() qDebug() << "Process State:" << (m_process ? m_process->state() : QLatin1String("null")); qDebug() << "Application Output:" << (m_process ? m_process->output() : QLatin1String("null")); qDebug() << "Connection State:" << (m_connection ? m_connection->stateString() : QLatin1String("null")); - qDebug() << "Client State:" << (m_client ? m_client->stateString() : QLatin1String("null")); + qDebug() << "Client State:" << m_client->stateString(); } delete m_process; m_process = 0; @@ -557,37 +560,32 @@ void tst_QQmlProfilerService::cleanup() m_connection = 0; } -void tst_QQmlProfilerService::blockingConnectWithTraceEnabled() +void tst_QQmlProfilerService::connect_data() { - connect(true, "test.qml"); - QVERIFY(m_client); - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); - - m_client->setTraceState(true); - m_client->setTraceState(false); - checkTraceReceived(); - checkJsHeap(); + QTest::addColumn<bool>("blockMode"); + QTest::addColumn<bool>("restrictMode"); + QTest::addColumn<bool>("traceEnabled"); + QTest::newRow("normal/unrestricted/disabled") << false << false << false; + QTest::newRow("block/unrestricted/disabled") << true << false << false; + QTest::newRow("normal/restricted/disabled") << false << true << false; + QTest::newRow("block/restricted/disabled") << true << true << false; + QTest::newRow("normal/unrestricted/enabled") << false << false << true; + QTest::newRow("block/unrestricted/enabled") << true << false << true; + QTest::newRow("normal/restricted/enabled") << false << true << true; + QTest::newRow("block/restricted/enabled") << true << true << true; } -void tst_QQmlProfilerService::blockingConnectWithTraceDisabled() +void tst_QQmlProfilerService::connect() { - connect(true, "test.qml"); - QVERIFY(m_client); - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + QFETCH(bool, blockMode); + QFETCH(bool, restrictMode); + QFETCH(bool, traceEnabled); - m_client->setTraceState(false); - m_client->setTraceState(true); - m_client->setTraceState(false); - checkTraceReceived(); - checkJsHeap(); -} - -void tst_QQmlProfilerService::nonBlockingConnect() -{ - connect(false, "test.qml"); - QVERIFY(m_client); - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); + connect(blockMode, "test.qml", restrictMode); + // if the engine is waiting, then the first message determines if it starts with trace enabled + if (!traceEnabled) + m_client->setTraceState(false); m_client->setTraceState(true); m_client->setTraceState(false); checkTraceReceived(); @@ -597,8 +595,6 @@ void tst_QQmlProfilerService::nonBlockingConnect() void tst_QQmlProfilerService::pixmapCacheData() { connect(true, "pixmapCacheTest.qml"); - QVERIFY(m_client); - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->setTraceState(true); QVERIFY(QQmlDebugTest::waitForSignal(m_process, SIGNAL(readyReadStandardOutput()))); @@ -636,8 +632,6 @@ void tst_QQmlProfilerService::pixmapCacheData() void tst_QQmlProfilerService::scenegraphData() { connect(true, "scenegraphTest.qml"); - QVERIFY(m_client); - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->setTraceState(true); @@ -690,8 +684,6 @@ void tst_QQmlProfilerService::scenegraphData() void tst_QQmlProfilerService::profileOnExit() { connect(true, "exit.qml"); - QVERIFY(m_client); - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->setTraceState(true); @@ -702,8 +694,6 @@ void tst_QQmlProfilerService::profileOnExit() void tst_QQmlProfilerService::controlFromJS() { connect(true, "controlFromJS.qml"); - QVERIFY(m_client); - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->setTraceState(false); checkTraceReceived(); @@ -713,8 +703,6 @@ void tst_QQmlProfilerService::controlFromJS() void tst_QQmlProfilerService::signalSourceLocation() { connect(true, "signalSourceLocation.qml"); - QVERIFY(m_client); - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->setTraceState(true); while (!(m_process->output().contains(QLatin1String("500")))) @@ -738,8 +726,6 @@ void tst_QQmlProfilerService::signalSourceLocation() void tst_QQmlProfilerService::javascript() { connect(true, "javascript.qml"); - QVERIFY(m_client); - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); m_client->setTraceState(true); while (!(m_process->output().contains(QLatin1String("done")))) @@ -766,6 +752,22 @@ void tst_QQmlProfilerService::javascript() VERIFY(MessageListJavaScript, 21, expected, CheckMessageType | CheckDetailType); } +void tst_QQmlProfilerService::flushInterval() +{ + connect(true, "timer.qml"); + + m_client->setTraceState(true, 1); + + // Make sure we get multiple messages + QTRY_VERIFY(m_client->qmlMessages.length() > 0); + QVERIFY(m_client->qmlMessages.length() < 100); + QTRY_VERIFY(m_client->qmlMessages.length() > 100); + + m_client->setTraceState(false); + checkTraceReceived(); + checkJsHeap(); +} + QTEST_MAIN(tst_QQmlProfilerService) #include "tst_qqmlprofilerservice.moc" diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp index 74f22e6997..51d706b818 100644 --- a/tests/auto/qml/debugger/shared/debugutil.cpp +++ b/tests/auto/qml/debugger/shared/debugutil.cpp @@ -91,7 +91,7 @@ QQmlDebugProcess::QQmlDebugProcess(const QString &executable, QObject *parent) m_timer.setSingleShot(true); m_timer.setInterval(5000); connect(&m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(processAppOutput())); - connect(&m_process, SIGNAL(error(QProcess::ProcessError)), + connect(&m_process, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError))); connect(&m_timer, SIGNAL(timeout()), SLOT(timeout())); } diff --git a/tests/auto/qml/debugger/shared/debugutil_p.h b/tests/auto/qml/debugger/shared/debugutil_p.h index 440cf34e81..d544a89ff2 100644 --- a/tests/auto/qml/debugger/shared/debugutil_p.h +++ b/tests/auto/qml/debugger/shared/debugutil_p.h @@ -35,6 +35,17 @@ #ifndef DEBUGUTIL_H #define DEBUGUTIL_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QEventLoop> #include <QTimer> #include <QThread> diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp index c7281dec69..0f7e572e02 100644 --- a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp +++ b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp @@ -39,6 +39,8 @@ #include <QtCore/qstringlist.h> #include <QtCore/qtimer.h> #include <QtNetwork/qnetworkproxy.h> +#include <QtNetwork/qlocalserver.h> +#include <QtNetwork/qlocalsocket.h> const int protocolVersion = 1; const QString serverId = QLatin1String("QDeclarativeDebugServer"); @@ -61,6 +63,7 @@ public: QQmlDebugConnection *q; QPacketProtocol *protocol; QIODevice *device; + QLocalServer *server; QEventLoop handshakeEventLoop; QTimer handshakeTimer; @@ -72,6 +75,10 @@ public: void connectDeviceSignals(); public Q_SLOTS: + void forwardStateChange(QLocalSocket::LocalSocketState state); + void forwardError(QLocalSocket::LocalSocketError error); + + void newConnection(); void connected(); void readyRead(); void deviceAboutToClose(); @@ -79,7 +86,7 @@ public Q_SLOTS: }; QQmlDebugConnectionPrivate::QQmlDebugConnectionPrivate(QQmlDebugConnection *c) - : QObject(c), q(c), protocol(0), device(0), gotHello(false) + : QObject(c), q(c), protocol(0), device(0), server(0), gotHello(false) { protocol = new QPacketProtocol(q, this); QObject::connect(c, SIGNAL(connected()), this, SLOT(connected())); @@ -307,10 +314,13 @@ void QQmlDebugConnection::close() bool QQmlDebugConnection::waitForConnected(int msecs) { QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device); - if (!socket) - return false; - if (!socket->waitForConnected(msecs)) + if (!socket) { + if (!d->server || (!d->server->hasPendingConnections() && + !d->server->waitForNewConnection(msecs))) + return false; + } else if (!socket->waitForConnected(msecs)) { return false; + } // wait for handshake d->handshakeTimer.start(); d->handshakeEventLoop.exec(); @@ -336,9 +346,13 @@ QString QQmlDebugConnection::stateString() const QAbstractSocket::SocketState QQmlDebugConnection::state() const { - QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device); - if (socket) - return socket->state(); + QAbstractSocket *abstractSocket = qobject_cast<QAbstractSocket*>(d->device); + if (abstractSocket) + return abstractSocket->state(); + + QLocalSocket *localSocket = qobject_cast<QLocalSocket*>(d->device); + if (localSocket) + return static_cast<QAbstractSocket::SocketState>(localSocket->state()); return QAbstractSocket::UnconnectedState; } @@ -366,6 +380,29 @@ void QQmlDebugConnection::connectToHost(const QString &hostName, quint16 port) QIODevice::open(ReadWrite | Unbuffered); } +void QQmlDebugConnection::startLocalServer(const QString &fileName) +{ + d->gotHello = false; + d->server = new QLocalServer(d); + // QueuedConnection so that waitForNewConnection() returns true. + connect(d->server, SIGNAL(newConnection()), d, SLOT(newConnection()), Qt::QueuedConnection); + d->server->listen(fileName); + QIODevice::open(ReadWrite | Unbuffered); +} + +void QQmlDebugConnectionPrivate::newConnection() +{ + QLocalSocket *socket = server->nextPendingConnection(); + server->close(); + device = socket; + connectDeviceSignals(); + connect(socket, SIGNAL(stateChanged(QLocalSocket::LocalSocketState)), + this, SLOT(forwardStateChange(QLocalSocket::LocalSocketState))); + connect(socket, SIGNAL(error(QLocalSocket::LocalSocketError)), + this, SLOT(forwardError(QLocalSocket::LocalSocketError))); + emit q->connected(); +} + void QQmlDebugConnectionPrivate::connectDeviceSignals() { connect(device, SIGNAL(bytesWritten(qint64)), q, SIGNAL(bytesWritten(qint64))); @@ -373,7 +410,15 @@ void QQmlDebugConnectionPrivate::connectDeviceSignals() connect(device, SIGNAL(aboutToClose()), this, SLOT(deviceAboutToClose())); } -// +void QQmlDebugConnectionPrivate::forwardStateChange(QLocalSocket::LocalSocketState state) +{ + emit q->stateChanged(static_cast<QAbstractSocket::SocketState>(state)); +} + +void QQmlDebugConnectionPrivate::forwardError(QLocalSocket::LocalSocketError error) +{ + emit q->error(static_cast<QAbstractSocket::SocketError>(error)); +} QQmlDebugClientPrivate::QQmlDebugClientPrivate() : connection(0) diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.h b/tests/auto/qml/debugger/shared/qqmldebugclient.h index 52f428cca7..fe9da693c8 100644 --- a/tests/auto/qml/debugger/shared/qqmldebugclient.h +++ b/tests/auto/qml/debugger/shared/qqmldebugclient.h @@ -46,6 +46,7 @@ public: ~QQmlDebugConnection(); void connectToHost(const QString &hostName, quint16 port); + void startLocalServer(const QString &fileName); void setDataStreamVersion(int dataStreamVersion); int dataStreamVersion(); diff --git a/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp b/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp index 990cb1caa1..e62aa2ce61 100644 --- a/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp +++ b/tests/auto/qml/debugger/shared/qqmldebugtestservice.cpp @@ -37,13 +37,12 @@ QQmlDebugTestService::QQmlDebugTestService(const QString &s, float version, QObject *parent) : QQmlDebugService(s, version, parent) { - registerService(); } void QQmlDebugTestService::messageReceived(const QByteArray &ba) { Q_ASSERT(QThread::currentThread() != thread()); - QMetaObject::invokeMethod(this, "_sendMessage", Qt::QueuedConnection, Q_ARG(QByteArray, ba)); + emit messageToClient(name(), ba); } void QQmlDebugTestService::stateAboutToBeChanged(QQmlDebugService::State) @@ -56,8 +55,3 @@ void QQmlDebugTestService::stateChanged(State) Q_ASSERT(QThread::currentThread() != thread()); emit stateHasChanged(); } - -void QQmlDebugTestService::_sendMessage(const QByteArray &msg) -{ - QQmlDebugService::sendMessage(msg); -} diff --git a/tests/auto/qml/debugger/shared/qqmldebugtestservice.h b/tests/auto/qml/debugger/shared/qqmldebugtestservice.h index 7cb09798de..cc24f3c119 100644 --- a/tests/auto/qml/debugger/shared/qqmldebugtestservice.h +++ b/tests/auto/qml/debugger/shared/qqmldebugtestservice.h @@ -46,9 +46,6 @@ public: signals: void stateHasChanged(); -private slots: - void _sendMessage(const QByteArray &msg); - protected: virtual void messageReceived(const QByteArray &ba); virtual void stateAboutToBeChanged(State state); diff --git a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.13-1.js b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.13-1.js index 720b39dd54..720b39dd54 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.13-1.js +++ b/tests/auto/qml/parserstress/tests/ecma/Date/15.9.1.13-1.js diff --git a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js index 3762842461..3762842461 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js +++ b/tests/auto/qml/parserstress/tests/ecma/ExecutionContexts/10.1.3-2.js diff --git a/tests/auto/qml/parserstress/tests/ecma/README b/tests/auto/qml/parserstress/tests/ecma/README index 91f174ab61..91f174ab61 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma/README +++ b/tests/auto/qml/parserstress/tests/ecma/README diff --git a/tests/auto/qml/parserstress/tests/ecma_2/README b/tests/auto/qml/parserstress/tests/ecma_2/README index 6da6cdd514..6da6cdd514 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_2/README +++ b/tests/auto/qml/parserstress/tests/ecma_2/README diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/constructor-001.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/constructor-001.js index cc7907d006..cc7907d006 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_2/extensions/constructor-001.js +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/constructor-001.js diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/function-001.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/function-001.js index 5153d25f9d..5153d25f9d 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_2/extensions/function-001.js +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/function-001.js diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-001.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-001.js index 8ea446a248..8ea446a248 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-001.js +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-001.js diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-002.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-002.js index 9cc837d8ef..9cc837d8ef 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-002.js +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-002.js diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-003-n.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-003-n.js index 7a763a895c..7a763a895c 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-003-n.js +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-003-n.js diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-004-n.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-004-n.js index 1662ae566b..1662ae566b 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-004-n.js +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-004-n.js diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-005-n.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-005-n.js index 1a9b1b3437..1a9b1b3437 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-005-n.js +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-005-n.js diff --git a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-006.js b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-006.js index 03c0f16fb9..03c0f16fb9 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-006.js +++ b/tests/auto/qml/parserstress/tests/ecma_2/extensions/instanceof-006.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.11-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.11-01.js index 0436b8c1e0..0436b8c1e0 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.11-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.4.11-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.5.1-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.5.1-01.js index b55430b44e..b55430b44e 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.5.1-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/15.4.5.1-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-01.js index 4e277e6da5..4e277e6da5 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-02.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-02.js index ee426a0cec..ee426a0cec 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-02.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-02.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-03.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-03.js index 95ee7f7a92..95ee7f7a92 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-03.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-03.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-04.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-04.js index fe9f8fc71e..fe9f8fc71e 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-04.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-322135-04.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-387501.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-387501.js index 36cf1478d2..36cf1478d2 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-387501.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-387501.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-421325.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-421325.js index c869d7bff4..c869d7bff4 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-421325.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-421325.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-430717.js b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-430717.js index f750ffb449..f750ffb449 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-430717.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Array/regress-430717.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.1.2-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.1.2-01.js index 61b1de6ef1..61b1de6ef1 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.1.2-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.1.2-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.3.2-1.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.3.2-1.js index d79b60b996..d79b60b996 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.3.2-1.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.3.2-1.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.4.3.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.4.3.js index b197dcb9c2..b197dcb9c2 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.4.3.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.4.3.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5-02.js b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5-02.js index e3b073e7ec..e3b073e7ec 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5-02.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Date/15.9.5.5-02.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js index 6fbe85e19f..6fbe85e19f 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/10.6.1-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js index f303199b51..f303199b51 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/ExecutionContexts/regress-448595-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-01.js index fd47d5d86b..fd47d5d86b 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-02.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-02.js index 8f387c1349..8f387c1349 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-02.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-02.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-03.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-03.js index 99af0f87c5..99af0f87c5 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-03.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.10-03.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.1-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.1-01.js index 05f9622ce2..05f9622ce2 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.1-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.1-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.2-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.2-01.js index 64e426888a..64e426888a 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.2-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.2-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.3-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.3-01.js index d5af3b86d4..d5af3b86d4 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.3-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Expressions/11.7.3-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-002.js index 78005560a7..78005560a7 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-002.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/arguments-002.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-313570.js b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-313570.js index e159c4c87f..e159c4c87f 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-313570.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Function/regress-313570.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js b/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js index 10ee26f929..10ee26f929 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/LexicalConventions/7.9.1.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Number/regress-442242-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Number/regress-442242-01.js index e3fa070e5a..e3fa070e5a 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Number/regress-442242-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Number/regress-442242-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.1-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.1-01.js index 2897ece555..2897ece555 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.1-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.1-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-361274.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-361274.js index d3962004e3..d3962004e3 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-361274.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-361274.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-385393-07.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-385393-07.js index 0473fe4956..0473fe4956 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-385393-07.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-385393-07.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-002.js index 5d3307e4a7..5d3307e4a7 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-002.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.13.1-002.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-002.js index c48565ba5f..c48565ba5f 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-002.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/11.4.1-002.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Operators/order-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Operators/order-01.js index 671faceb81..671faceb81 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Operators/order-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Operators/order-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/README b/tests/auto/qml/parserstress/tests/ecma_3/README index eebd421c2e..eebd421c2e 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/README +++ b/tests/auto/qml/parserstress/tests/ecma_3/README diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2.12.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2.12.js index d68b86c2ed..d68b86c2ed 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2.12.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/15.10.2.12.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-285219.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-285219.js index 9d462359fa..9d462359fa 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-285219.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-285219.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-289669.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-289669.js index 2e3d044b74..2e3d044b74 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-289669.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-289669.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-307456.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-307456.js index dd2f540f6c..dd2f540f6c 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-307456.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-307456.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-309840.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-309840.js index 8680b7bcfd..8680b7bcfd 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-309840.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-309840.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-311414.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-311414.js index a24a07bb2b..a24a07bb2b 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-311414.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-311414.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-312351.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-312351.js index a9b00d317c..a9b00d317c 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-312351.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-312351.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-330684.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-330684.js index b097fbc3d7..b097fbc3d7 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-330684.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-330684.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-334158.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-334158.js index 41ebf0a731..41ebf0a731 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-334158.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-334158.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-346090.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-346090.js index dfd53a9922..dfd53a9922 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-346090.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-346090.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-367888.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-367888.js index 923c1e5ab3..923c1e5ab3 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-367888.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-367888.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375642.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375642.js index 236eb00d28..236eb00d28 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375642.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375642.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375711.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375711.js index 6e7339f9e9..6e7339f9e9 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375711.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375711.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js index 437dcbd5c5..437dcbd5c5 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-01-n.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-02.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-02.js index 3cd858e845..3cd858e845 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-02.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-02.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-03.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-03.js index ffc5c5a4cc..ffc5c5a4cc 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-03.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-03.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-04.js b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-04.js index 0c78a372ee..0c78a372ee 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-04.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/RegExp/regress-375715-04.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-385393-04.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-385393-04.js index 6e735fd1d2..6e735fd1d2 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-385393-04.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-385393-04.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-419152.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-419152.js index f57f3a4f98..f57f3a4f98 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-419152.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-419152.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420087.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420087.js index 1f21d19739..1f21d19739 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420087.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420087.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420610.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420610.js index ecd5a2dd42..ecd5a2dd42 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420610.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-420610.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js index 27ddfab51d..27ddfab51d 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Regress/regress-441477-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Statements/12.6.3.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/12.6.3.js index 97c3ca3136..97c3ca3136 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Statements/12.6.3.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/12.6.3.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-302439.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-302439.js index e1ebdb6e30..e1ebdb6e30 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-302439.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-302439.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-324650.js b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-324650.js index 003cd0fa42..003cd0fa42 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-324650.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Statements/regress-324650.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js index 733cd713d8..733cd713d8 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-304376.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js index 9610238cc3..9610238cc3 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-313567.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js index 59564b272e..59564b272e 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/String/regress-392378.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-01.js index bb10ac6f7a..bb10ac6f7a 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-01.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/Unicode/regress-352044-01.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/browser.js index 2339522cb6..2339522cb6 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/browser.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/browser.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/extensions/10.1.3-2.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/10.1.3-2.js index f941cb7800..f941cb7800 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/extensions/10.1.3-2.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/10.1.3-2.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/extensions/7.9.1.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/7.9.1.js index b69e9d065a..b69e9d065a 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/extensions/7.9.1.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/7.9.1.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-274152.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-274152.js index d7074d9128..d7074d9128 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-274152.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-274152.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-320854.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-320854.js index 85e684882f..85e684882f 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-320854.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-320854.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-327170.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-327170.js index 5d15ce31a9..5d15ce31a9 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-327170.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-327170.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-368516.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-368516.js index a5f5fb769b..a5f5fb769b 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-368516.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-368516.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-385393-03.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-385393-03.js index 40c7e8dd81..40c7e8dd81 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-385393-03.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-385393-03.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-429248.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-429248.js index 9966269115..9966269115 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-429248.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-429248.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-430740.js b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-430740.js index 446adb95a6..446adb95a6 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-430740.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/extensions/regress-430740.js diff --git a/tests/auto/qml/parserstress/tests/ecma_3/template.js b/tests/auto/qml/parserstress/tests/ecma_3/template.js index 4dedd5a0e3..4dedd5a0e3 100755..100644 --- a/tests/auto/qml/parserstress/tests/ecma_3/template.js +++ b/tests/auto/qml/parserstress/tests/ecma_3/template.js diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 5a9d6d20eb..39bc8b2e5f 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -155,7 +155,7 @@ private slots: void callConstants(); - void installTranslatorFunctions(); + void installTranslationFunctions(); void translateScript_data(); void translateScript(); void translateScript_crossScript(); @@ -172,6 +172,16 @@ private slots: void translateScriptUnicodeIdBased(); void translateFromBuiltinCallback(); + void installConsoleFunctions(); + void logging(); + void tracing(); + void asserts(); + void exceptions(); + + void installGarbageCollectionFunctions(); + + void installAllExtensions(); + void privateMethods(); void engineForObject(); @@ -336,7 +346,7 @@ void tst_QJSEngine::constructWithParent() QJSEngine *engine = new QJSEngine(&obj); ptr = engine; } - QVERIFY(ptr == 0); + QVERIFY(ptr.isNull()); } void tst_QJSEngine::newObject() @@ -631,7 +641,7 @@ void tst_QJSEngine::newQObject_ownership() eng.collectGarbage(); if (ptr) QGuiApplication::sendPostedEvents(ptr, QEvent::DeferredDelete); - QVERIFY(ptr == 0); + QVERIFY(ptr.isNull()); } { QPointer<QObject> ptr = new QObject(this); @@ -641,7 +651,7 @@ void tst_QJSEngine::newQObject_ownership() } QObject *before = ptr; eng.collectGarbage(); - QVERIFY(ptr == before); + QCOMPARE(ptr.data(), before); delete ptr; } { @@ -662,7 +672,7 @@ void tst_QJSEngine::newQObject_ownership() // no parent, so it should be like ScriptOwnership if (ptr) QGuiApplication::sendPostedEvents(ptr, QEvent::DeferredDelete); - QVERIFY(ptr == 0); + QVERIFY(ptr.isNull()); } { QObject *parent = new QObject(); @@ -1258,7 +1268,7 @@ void tst_QJSEngine::valueConversion_QVariant() { QVariant tmp1; QVariant tmp2(QMetaType::QVariant, &tmp1); - QVERIFY(QMetaType::Type(tmp2.type()) == QMetaType::QVariant); + QCOMPARE(QMetaType::Type(tmp2.type()), QMetaType::QVariant); QJSValue val1 = eng.toScriptValue(tmp1); QJSValue val2 = eng.toScriptValue(tmp2); @@ -1273,9 +1283,9 @@ void tst_QJSEngine::valueConversion_QVariant() QVariant tmp1(123); QVariant tmp2(QMetaType::QVariant, &tmp1); QVariant tmp3(QMetaType::QVariant, &tmp2); - QVERIFY(QMetaType::Type(tmp1.type()) == QMetaType::Int); - QVERIFY(QMetaType::Type(tmp2.type()) == QMetaType::QVariant); - QVERIFY(QMetaType::Type(tmp3.type()) == QMetaType::QVariant); + QCOMPARE(QMetaType::Type(tmp1.type()), QMetaType::Int); + QCOMPARE(QMetaType::Type(tmp2.type()), QMetaType::QVariant); + QCOMPARE(QMetaType::Type(tmp3.type()), QMetaType::QVariant); QJSValue val1 = eng.toScriptValue(tmp2); QJSValue val2 = eng.toScriptValue(tmp3); @@ -1285,8 +1295,8 @@ void tst_QJSEngine::valueConversion_QVariant() QVERIFY(val1.isVariant()); QEXPECT_FAIL("", "Variant are unrwapped, maybe we should not...", Continue); QVERIFY(val2.isVariant()); - QVERIFY(val1.toVariant().toInt() == 123); - QVERIFY(eng.toScriptValue(val2.toVariant()).toVariant().toInt() == 123); + QCOMPARE(val1.toVariant().toInt(), 123); + QCOMPARE(eng.toScriptValue(val2.toVariant()).toVariant().toInt(), 123); } { QJSValue val = eng.toScriptValue(QVariant(true)); @@ -1472,7 +1482,7 @@ void tst_QJSEngine::collectGarbage() eng.collectGarbage(); if (ptr) QGuiApplication::sendPostedEvents(ptr, QEvent::DeferredDelete); - QVERIFY(ptr == 0); + QVERIFY(ptr.isNull()); } void tst_QJSEngine::gcWithNestedDataStructure() @@ -1480,6 +1490,8 @@ void tst_QJSEngine::gcWithNestedDataStructure() // The GC must be able to traverse deeply nested objects, otherwise this // test would crash. QJSEngine eng; + eng.installExtensions(QJSEngine::GarbageCollectionExtension); + QJSValue ret = eng.evaluate( "function makeList(size)" "{" @@ -3171,7 +3183,7 @@ void tst_QJSEngine::callConstants() QCOMPARE(exceptionResult.toString(), QString("TypeError: true is not a function")); } -void tst_QJSEngine::installTranslatorFunctions() +void tst_QJSEngine::installTranslationFunctions() { QJSEngine eng; QJSValue global = eng.globalObject(); @@ -3182,7 +3194,7 @@ void tst_QJSEngine::installTranslatorFunctions() QVERIFY(global.property("qsTrId").isUndefined()); QVERIFY(global.property("QT_TRID_NOOP").isUndefined()); - eng.installTranslatorFunctions(); + eng.installExtensions(QJSEngine::TranslationExtension); QVERIFY(global.property("qsTranslate").isCallable()); QVERIFY(global.property("QT_TRANSLATE_NOOP").isCallable()); QVERIFY(global.property("qsTr").isCallable()); @@ -3597,6 +3609,107 @@ void tst_QJSEngine::translateFromBuiltinCallback() eng.evaluate("[10,20].forEach(foo)", "script.js"); } +void tst_QJSEngine::installConsoleFunctions() +{ + QJSEngine engine; + QJSValue global = engine.globalObject(); + QVERIFY(global.property("console").isUndefined()); + QVERIFY(global.property("print").isUndefined()); + + engine.installExtensions(QJSEngine::ConsoleExtension); + QVERIFY(global.property("console").isObject()); + QVERIFY(global.property("print").isCallable()); +} + +void tst_QJSEngine::logging() +{ + QLoggingCategory loggingCategory("js"); + QVERIFY(loggingCategory.isDebugEnabled()); + QVERIFY(loggingCategory.isWarningEnabled()); + QVERIFY(loggingCategory.isCriticalEnabled()); + + QJSEngine engine; + engine.installExtensions(QJSEngine::ConsoleExtension); + + QTest::ignoreMessage(QtDebugMsg, "console.debug"); + engine.evaluate("console.debug('console.debug')"); + QTest::ignoreMessage(QtDebugMsg, "console.log"); + engine.evaluate("console.log('console.log')"); + QTest::ignoreMessage(QtInfoMsg, "console.info"); + engine.evaluate("console.info('console.info')"); + QTest::ignoreMessage(QtWarningMsg, "console.warn"); + engine.evaluate("console.warn('console.warn')"); + QTest::ignoreMessage(QtCriticalMsg, "console.error"); + engine.evaluate("console.error('console.error')"); + + QTest::ignoreMessage(QtDebugMsg, ": 1"); + engine.evaluate("console.count()"); + + QTest::ignoreMessage(QtDebugMsg, ": 2"); + engine.evaluate("console.count()"); +} + +void tst_QJSEngine::tracing() +{ + QJSEngine engine; + engine.installExtensions(QJSEngine::ConsoleExtension); + + QTest::ignoreMessage(QtDebugMsg, "%entry (:1)"); + engine.evaluate("console.trace()"); + + QTest::ignoreMessage(QtDebugMsg, "a (:1)\nb (:1)\nc (:1)\n%entry (:1)"); + engine.evaluate("function a() { console.trace(); } function b() { a(); } function c() { b(); }"); + engine.evaluate("c()"); +} + +void tst_QJSEngine::asserts() +{ + QJSEngine engine; + engine.installExtensions(QJSEngine::ConsoleExtension); + + QTest::ignoreMessage(QtCriticalMsg, "This will fail\n%entry (:1)"); + engine.evaluate("console.assert(0, 'This will fail')"); + + QTest::ignoreMessage(QtCriticalMsg, "This will fail too\n%entry (:1)"); + engine.evaluate("console.assert(1 > 2, 'This will fail too')"); +} + +void tst_QJSEngine::exceptions() +{ + QJSEngine engine; + engine.installExtensions(QJSEngine::ConsoleExtension); + + QTest::ignoreMessage(QtCriticalMsg, "Exception 1\n%entry (:1)"); + engine.evaluate("console.exception('Exception 1')"); +} + +void tst_QJSEngine::installGarbageCollectionFunctions() +{ + QJSEngine engine; + QJSValue global = engine.globalObject(); + QVERIFY(global.property("gc").isUndefined()); + + engine.installExtensions(QJSEngine::GarbageCollectionExtension); + QVERIFY(global.property("gc").isCallable()); +} + +void tst_QJSEngine::installAllExtensions() +{ + QJSEngine engine; + QJSValue global = engine.globalObject(); + // Pick out a few properties from each extension and check that they're there. + QVERIFY(global.property("qsTranslate").isUndefined()); + QVERIFY(global.property("console").isUndefined()); + QVERIFY(global.property("print").isUndefined()); + QVERIFY(global.property("gc").isUndefined()); + + engine.installExtensions(QJSEngine::AllExtensions); + QVERIFY(global.property("qsTranslate").isCallable()); + QVERIFY(global.property("console").isObject()); + QVERIFY(global.property("print").isCallable()); + QVERIFY(global.property("gc").isCallable()); +} + class ObjectWithPrivateMethods : public QObject { Q_OBJECT diff --git a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp index e01ea73e1b..52d676ef3c 100644 --- a/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp +++ b/tests/auto/qml/qjsonbinding/tst_qjsonbinding.cpp @@ -110,7 +110,7 @@ QJsonValue tst_qjsonbinding::valueFromJson(const QByteArray &json) // QJsonDocument::fromJson() only handles objects and arrays... // Wrap the JSON inside a dummy object and extract the value. - QByteArray wrappedJson = "{\"prop\":" + json + "}"; + QByteArray wrappedJson = "{\"prop\":" + json + '}'; doc = QJsonDocument::fromJson(wrappedJson); Q_ASSERT(doc.isObject()); return doc.object().value("prop"); diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index d608379d52..bf9bd18807 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -1076,7 +1076,7 @@ void tst_QJSValue::toVariant() QVariantList listOut = ret.toList(); QCOMPARE(listOut.size(), listIn.size()); for (int i = 0; i < listIn.size(); ++i) - QVERIFY(listOut.at(i) == listIn.at(i)); + QCOMPARE(listOut.at(i), listIn.at(i)); // round-trip conversion QJSValue array2 = eng.toScriptValue(ret); QVERIFY(array2.isArray()); @@ -2261,7 +2261,7 @@ void tst_QJSValue::castToPointer() QCOMPARE(*cp, c); QBrush *bp = qjsvalue_cast<QBrush*>(v); - QVERIFY(bp == 0); + QVERIFY(!bp); QJSValue v2 = eng.toScriptValue(qVariantFromValue(cp)); QCOMPARE(qjsvalue_cast<QColor*>(v2), cp); @@ -2436,7 +2436,7 @@ void tst_QJSValue::prettyPrinter() QFETCH(QString, function); QFETCH(QString, expected); QJSEngine eng; - QJSValue val = eng.evaluate("(" + function + ")"); + QJSValue val = eng.evaluate(QLatin1Char('(') + function + QLatin1Char(')')); QVERIFY(val.isCallable()); QString actual = val.toString(); QSKIP("Function::toString() doesn't give the whole function on v4"); @@ -2465,15 +2465,15 @@ void tst_QJSValue::engineDeleted() delete eng; QVERIFY(v1.isUndefined()); - QVERIFY(v1.engine() == 0); + QVERIFY(!v1.engine()); QVERIFY(v2.isUndefined()); - QVERIFY(v2.engine() == 0); + QVERIFY(!v2.engine()); QVERIFY(v3.isUndefined()); - QVERIFY(v3.engine() == 0); + QVERIFY(!v3.engine()); QVERIFY(v4.isUndefined()); - QVERIFY(v4.engine() == 0); + QVERIFY(!v4.engine()); QVERIFY(v5.isString()); // was not bound to engine - QVERIFY(v5.engine() == 0); + QVERIFY(!v5.engine()); QVERIFY(v3.property("foo").isUndefined()); } diff --git a/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp b/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp index 6049e423e8..81a79331c3 100644 --- a/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp +++ b/tests/auto/qml/qjsvalueiterator/tst_qjsvalueiterator.cpp @@ -92,7 +92,7 @@ void tst_QJSValueIterator::iterateForward() QFETCH(QStringList, propertyNames); QFETCH(QStringList, propertyValues); QMap<QString, QString> pmap; - QVERIFY(propertyNames.size() == propertyValues.size()); + QCOMPARE(propertyNames.size(), propertyValues.size()); QJSEngine engine; QJSValue object = engine.newObject(); diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index 5d58beea1e..66c19098ef 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -37,6 +37,7 @@ PRIVATETESTS += \ qqmldirparser \ qqmlglobal \ qqmllanguage \ + qqmlopenmetaobject \ qqmlproperty \ qqmlpropertycache \ qqmlpropertymap \ @@ -60,7 +61,8 @@ PRIVATETESTS += \ qqmlenginecleanup \ v4misc \ qqmltranslation \ - qqmlimport + qqmlimport \ + qqmlobjectmodel qtHaveModule(widgets) { PUBLICTESTS += \ @@ -70,7 +72,10 @@ qtHaveModule(widgets) { SUBDIRS += $$PUBLICTESTS SUBDIRS += $$METATYPETESTS -!winrt: SUBDIRS += debugger qmllint # no QProcess on winrt +!winrt { # no QProcess on winrt + !contains(QT_CONFIG, no-qml-debug): SUBDIRS += debugger + SUBDIRS += qmllint +} contains(QT_CONFIG, private_tests) { SUBDIRS += $$PRIVATETESTS diff --git a/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/Singleton.qml b/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/Singleton.qml new file mode 100644 index 0000000000..b47d2e98f4 --- /dev/null +++ b/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/Singleton.qml @@ -0,0 +1,6 @@ +pragma Singleton +import QtQuick 2.0 + +QtObject { + property int test: 0 +} diff --git a/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/qmldir b/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/qmldir new file mode 100644 index 0000000000..8df57f6d47 --- /dev/null +++ b/tests/auto/qml/qmlplugindump/tests/dumper/CompositeSingleton/qmldir @@ -0,0 +1,3 @@ +module tests.dumper.CompositeSingleton +singleton Singleton 1.0 Singleton.qml +depends QtQuick 2.0 diff --git a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp index 2a534b5913..82506b4217 100644 --- a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp +++ b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp @@ -47,6 +47,7 @@ public: private slots: void initTestCase(); void builtins(); + void singleton(); private: QString qmlplugindumpPath; @@ -84,7 +85,7 @@ void tst_qmlplugindump::builtins() if (dumper.error() != QProcess::UnknownError || dumper.exitStatus() != QProcess::NormalExit) { qWarning() << QString("Error while running '%1 %2'").arg( - qmlplugindumpPath, args.join(QLatin1String(" "))); + qmlplugindumpPath, args.join(QLatin1Char(' '))); } if (dumper.error() == QProcess::FailedToStart) { @@ -102,6 +103,20 @@ void tst_qmlplugindump::builtins() QVERIFY(result.contains(QLatin1String("Module {"))); } +void tst_qmlplugindump::singleton() +{ + QProcess dumper; + QStringList args; + args << QLatin1String("tests.dumper.CompositeSingleton") << QLatin1String("1.0") + << QLatin1String("."); + dumper.start(qmlplugindumpPath, args); + dumper.waitForFinished(); + + const QString &result = dumper.readAllStandardOutput(); + QVERIFY(result.contains(QLatin1String("exports: [\"Singleton 1.0\"]"))); + QVERIFY(result.contains(QLatin1String("exportMetaObjectRevisions: [0]"))); +} + QTEST_MAIN(tst_qmlplugindump) #include "tst_qmlplugindump.moc" diff --git a/tests/auto/qml/qqmlbinding/data/readonlyProperty.qml b/tests/auto/qml/qqmlbinding/data/readonlyProperty.qml new file mode 100644 index 0000000000..fa8d93d355 --- /dev/null +++ b/tests/auto/qml/qqmlbinding/data/readonlyProperty.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item { + id: root + + readonly property string name: "John" + + Binding { + target: root + property: "name" + value: "Doe" + } +} diff --git a/tests/auto/qml/qqmlbinding/data/unknownProperty.qml b/tests/auto/qml/qqmlbinding/data/unknownProperty.qml new file mode 100644 index 0000000000..36157bb4e7 --- /dev/null +++ b/tests/auto/qml/qqmlbinding/data/unknownProperty.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Item { + id: root + + Binding { + target: root + property: "unknown" + value: 42 + } +} diff --git a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp index 2d267cc668..3e49f3b3c4 100644 --- a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp +++ b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp @@ -50,6 +50,8 @@ private slots: void restoreBindingWithLoop(); void restoreBindingWithoutCrash(); void deletedObject(); + void warningOnUnknownProperty(); + void warningOnReadOnlyProperty(); private: QQmlEngine engine; @@ -224,6 +226,38 @@ void tst_qqmlbinding::deletedObject() delete rect; } +void tst_qqmlbinding::warningOnUnknownProperty() +{ + QQmlTestMessageHandler messageHandler; + + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("unknownProperty.qml")); + QQuickItem *item = qobject_cast<QQuickItem*>(c.create()); + QVERIFY(item); + delete item; + + QCOMPARE(messageHandler.messages().count(), 1); + + const QString expectedMessage = c.url().toString() + QLatin1String(":6:5: QML Binding: Property 'unknown' does not exist on Item."); + QCOMPARE(messageHandler.messages().first(), expectedMessage); +} + +void tst_qqmlbinding::warningOnReadOnlyProperty() +{ + QQmlTestMessageHandler messageHandler; + + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("readonlyProperty.qml")); + QQuickItem *item = qobject_cast<QQuickItem*>(c.create()); + QVERIFY(item); + delete item; + + QCOMPARE(messageHandler.messages().count(), 1); + + const QString expectedMessage = c.url().toString() + QLatin1String(":8:5: QML Binding: Property 'name' on Item is read-only."); + QCOMPARE(messageHandler.messages().first(), expectedMessage); +} + QTEST_MAIN(tst_qqmlbinding) #include "tst_qqmlbinding.moc" diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index bb159d5931..85579a6019 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -110,6 +110,7 @@ private slots: void qmlCreateParentReference(); void async(); void asyncHierarchy(); + void asyncForceSync(); void componentUrlCanonicalization(); void onDestructionLookup(); void onDestructionCount(); @@ -157,7 +158,7 @@ void tst_qqmlcomponent::qmlIncubateObject() QCOMPARE(object->property("test1").toBool(), true); QCOMPARE(object->property("test2").toBool(), false); - QTRY_VERIFY(object->property("test2").toBool() == true); + QTRY_VERIFY(object->property("test2").toBool()); delete object; } @@ -250,7 +251,7 @@ void tst_qqmlcomponent::qmlCreateObjectWithProperties() QObject *testObject1 = object->property("declarativerectangle").value<QObject*>(); QVERIFY(testObject1); - QVERIFY(testObject1->parent() == object); + QCOMPARE(testObject1->parent(), object); QCOMPARE(testObject1->property("x").value<int>(), 17); QCOMPARE(testObject1->property("y").value<int>(), 17); QCOMPARE(testObject1->property("color").value<QColor>(), QColor(255,255,255)); @@ -260,7 +261,7 @@ void tst_qqmlcomponent::qmlCreateObjectWithProperties() QObject *testObject2 = object->property("declarativeitem").value<QObject*>(); QVERIFY(testObject2); - QVERIFY(testObject2->parent() == object); + QCOMPARE(testObject2->parent(), object); //QCOMPARE(testObject2->metaObject()->className(), "QDeclarativeItem_QML_2"); QCOMPARE(testObject2->property("x").value<int>(), 17); QCOMPARE(testObject2->property("y").value<int>(), 17); @@ -371,6 +372,35 @@ void tst_qqmlcomponent::asyncHierarchy() delete root; } +void tst_qqmlcomponent::asyncForceSync() +{ + { + // 1) make sure that HTTP URLs cannot be completed synchronously + TestHTTPServer server; + QVERIFY2(server.listen(), qPrintable(server.errorString())); + server.serveDirectory(dataDirectory()); + + // ensure that the item hierarchy is compiled correctly. + QQmlComponent component(&engine); + component.loadUrl(server.url("/TestComponent.2.qml"), QQmlComponent::Asynchronous); + QCOMPARE(component.status(), QQmlComponent::Loading); + QQmlComponent component2(&engine, server.url("/TestComponent.2.qml"), QQmlComponent::PreferSynchronous); + QCOMPARE(component2.status(), QQmlComponent::Loading); + } + { + // 2) make sure that file:// URL can be completed synchronously + + // ensure that the item hierarchy is compiled correctly. + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("/TestComponent.2.qml"), QQmlComponent::Asynchronous); + QCOMPARE(component.status(), QQmlComponent::Loading); + QQmlComponent component2(&engine, testFileUrl("/TestComponent.2.qml"), QQmlComponent::PreferSynchronous); + QCOMPARE(component2.status(), QQmlComponent::Ready); + QCOMPARE(component.status(), QQmlComponent::Loading); + QTRY_COMPARE_WITH_TIMEOUT(component.status(), QQmlComponent::Ready, 0); + } +} + void tst_qqmlcomponent::componentUrlCanonicalization() { // ensure that url canonicalization succeeds so that type information @@ -418,7 +448,7 @@ void tst_qqmlcomponent::componentUrlCanonicalization() QQmlComponent component(&engine, testFileUrl("componentUrlCanonicalization.5.qml")); QTest::ignoreMessage(QtWarningMsg, QLatin1String("QQmlComponent: Component is not ready").data()); QScopedPointer<QObject> object(component.create()); - QVERIFY(object == 0); + QVERIFY(object.isNull()); } } diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp index 45393bf2f0..e529c74acc 100644 --- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp +++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp @@ -72,7 +72,7 @@ void tst_qqmlconnections::defaultValues() QQmlConnections *item = qobject_cast<QQmlConnections*>(c.create()); QVERIFY(item != 0); - QVERIFY(item->target() == 0); + QVERIFY(!item->target()); delete item; } @@ -86,7 +86,7 @@ void tst_qqmlconnections::properties() QVERIFY(item != 0); QVERIFY(item != 0); - QVERIFY(item->target() == item); + QCOMPARE(item->target(), item); delete item; } @@ -146,7 +146,7 @@ void tst_qqmlconnections::targetChanged() QQuickItem *item2 = item->findChild<QQuickItem*>("item2"); QVERIFY(item2); - QVERIFY(connections->target() == item2); + QCOMPARE(connections->target(), item2); // If we don't crash then we're OK @@ -211,9 +211,9 @@ void tst_qqmlconnections::errors() QQmlEngine engine; QQmlComponent c(&engine, url); - QVERIFY(c.isError() == true); + QVERIFY(c.isError()); QList<QQmlError> errors = c.errors(); - QVERIFY(errors.count() == 1); + QCOMPARE(errors.count(), 1); QCOMPARE(errors.at(0).description(), error); } diff --git a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp index 1ee675a91d..98e3a53b81 100644 --- a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp +++ b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp @@ -47,7 +47,7 @@ private slots: void logging(); void tracing(); void profiling(); - void assert(); + void testAssert(); void exception(); private: @@ -122,7 +122,7 @@ void tst_qqmlconsole::profiling() delete object; } -void tst_qqmlconsole::assert() +void tst_qqmlconsole::testAssert() { QUrl testUrl = testFileUrl("assert.qml"); diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp index 1bd070c2d0..18ef7ac31d 100644 --- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp +++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp @@ -433,12 +433,12 @@ void tst_qqmlcontext::idAsContextProperty() QVERIFY(obj); QVariant a = obj->property("a"); - QVERIFY(a.userType() == QMetaType::QObjectStar); + QCOMPARE(a.userType(), int(QMetaType::QObjectStar)); QVariant ctxt = qmlContext(obj)->contextProperty("myObject"); - QVERIFY(ctxt.userType() == QMetaType::QObjectStar); + QCOMPARE(ctxt.userType(), int(QMetaType::QObjectStar)); - QVERIFY(a == ctxt); + QCOMPARE(a, ctxt); delete obj; } @@ -455,20 +455,20 @@ void tst_qqmlcontext::readOnlyContexts() QQmlContext *context = qmlContext(obj); QVERIFY(context); - QVERIFY(qvariant_cast<QObject*>(context->contextProperty("me")) == obj); - QVERIFY(context->contextObject() == obj); + QCOMPARE(qvariant_cast<QObject*>(context->contextProperty("me")), obj); + QCOMPARE(context->contextObject(), obj); QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set property on internal context."); context->setContextProperty("hello", 12); - QVERIFY(context->contextProperty("hello") == QVariant()); + QCOMPARE(context->contextProperty("hello"), QVariant()); QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set property on internal context."); context->setContextProperty("hello", obj); - QVERIFY(context->contextProperty("hello") == QVariant()); + QCOMPARE(context->contextProperty("hello"), QVariant()); QTest::ignoreMessage(QtWarningMsg, "QQmlContext: Cannot set context object for internal context."); context->setContextObject(0); - QVERIFY(context->contextObject() == obj); + QCOMPARE(context->contextObject(), obj); delete obj; } diff --git a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp index 6b2add309a..6f2febaccf 100644 --- a/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp +++ b/tests/auto/qml/qqmldirparser/tst_qqmldirparser.cpp @@ -73,7 +73,7 @@ namespace { QString toString(const QQmlDirParser::Plugin &p) { - return p.name + "|" + p.path; + return p.name + QLatin1Char('|') + p.path; } QStringList toStringList(const QList<QQmlDirParser::Plugin> &plugins) @@ -88,7 +88,9 @@ namespace { QString toString(const QQmlDirParser::Component &c) { - return c.typeName + "|" + c.fileName + "|" + QString::number(c.majorVersion) + "|" + QString::number(c.minorVersion) + "|" + (c.internal ? "true" : "false"); + return c.typeName + QLatin1Char('|') + c.fileName + QLatin1Char('|') + + QString::number(c.majorVersion) + QLatin1Char('|') + QString::number(c.minorVersion) + + QLatin1Char('|') + (c.internal ? "true" : "false"); } QStringList toStringList(const QQmlDirComponents &components) @@ -104,7 +106,8 @@ namespace { QString toString(const QQmlDirParser::Script &s) { - return s.nameSpace + "|" + s.fileName + "|" + QString::number(s.majorVersion) + "|" + QString::number(s.minorVersion); + return s.nameSpace + QLatin1Char('|') + s.fileName + QLatin1Char('|') + + QString::number(s.majorVersion) + '|' + QString::number(s.minorVersion); } QStringList toStringList(const QList<QQmlDirParser::Script> &scripts) diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_46022.js b/tests/auto/qml/qqmlecmascript/data/qtbug_46022.js new file mode 100644 index 0000000000..385d7f9e97 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_46022.js @@ -0,0 +1,21 @@ +var obj = {} +obj[5289] = 0 +obj[5290] = 0 +obj[5288] = 0 +obj[5287] = 0 +delete obj[5288] + +var a = Object.getOwnPropertyNames(obj) +var test1 = a.every(function(key) { + return obj.hasOwnProperty(key) +}) + +obj = {} +obj[8187] = 0 +obj[8188] = 0 +delete obj[8187] + +var b = Object.getOwnPropertyNames(obj) +var test2 = b.every(function(key) { + return obj.hasOwnProperty(key) +}) diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug_46022.qml b/tests/auto/qml/qqmlecmascript/data/qtbug_46022.qml new file mode 100644 index 0000000000..2d2375de3e --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug_46022.qml @@ -0,0 +1,7 @@ +import "qtbug_46022.js" as Test +import QtQuick 2.0 + +QtObject { + property bool test1: Test.test1 + property bool test2: Test.test2 +} diff --git a/tests/auto/qml/qqmlecmascript/data/singletonTest.qml b/tests/auto/qml/qqmlecmascript/data/singletonTest.qml index 9e41bd4e2c..ca3784322a 100644 --- a/tests/auto/qml/qqmlecmascript/data/singletonTest.qml +++ b/tests/auto/qml/qqmlecmascript/data/singletonTest.qml @@ -45,4 +45,5 @@ Item { property bool qobjectTest: MyInheritedQmlObjectSingleton.isItYouQObject(MyInheritedQmlObjectSingleton) property bool myQmlObjectTest: MyInheritedQmlObjectSingleton.isItYouMyQmlObject(MyInheritedQmlObjectSingleton) property bool myInheritedQmlObjectTest: MyInheritedQmlObjectSingleton.isItYouMyInheritedQmlObject(MyInheritedQmlObjectSingleton) + property int testFoo: TestTypeCppSingleton.foo } diff --git a/tests/auto/qml/qqmlecmascript/data/singletonTest2.qml b/tests/auto/qml/qqmlecmascript/data/singletonTest2.qml index 67654dd81f..ef08745812 100644 --- a/tests/auto/qml/qqmlecmascript/data/singletonTest2.qml +++ b/tests/auto/qml/qqmlecmascript/data/singletonTest2.qml @@ -52,6 +52,7 @@ Item { property bool qobjectTest2: false property bool qobjectTest3: false property bool singletonEqualToItself: true + property int testFoo: -1 Component.onCompleted: { MyInheritedQmlObjectSingleton.myInheritedQmlObjectProperty = MyInheritedQmlObjectSingleton; @@ -70,5 +71,6 @@ Item { qobjectTest3 = MyInheritedQmlObjectSingleton == MyInheritedQmlObjectSingleton.qobjectProperty; singletonEqualToItself = MyInheritedQmlObjectSingleton == MyInheritedQmlObjectSingleton; + testFoo = TestTypeCppSingleton.foo } } diff --git a/tests/auto/qml/qqmlecmascript/testtypes.cpp b/tests/auto/qml/qqmlecmascript/testtypes.cpp index edfd97b750..285158a4ea 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.cpp +++ b/tests/auto/qml/qqmlecmascript/testtypes.cpp @@ -325,6 +325,38 @@ bool MyInheritedQmlObject::isItYouMyInheritedQmlObject(MyInheritedQmlObject *o) return o && o == theSingletonObject; } +class TestTypeCppSingleton : public QObject +{ + Q_OBJECT + Q_PROPERTY(int foo READ foo) + + Q_CLASSINFO("DefaultProperty", "foo") +public: + int foo() { return 0; } + static TestTypeCppSingleton *instance() { + static TestTypeCppSingleton cppSingleton; + return &cppSingleton; + } +private: + TestTypeCppSingleton(){} + ~TestTypeCppSingleton() { + // just to make sure it crashes on double delete + static int a = 0; + static int *ptr = &a; + *ptr = 1; + ptr = 0; + } +}; + +QObject *testTypeCppProvider(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine); + Q_UNUSED(scriptEngine); + TestTypeCppSingleton *o = TestTypeCppSingleton::instance(); + QQmlEngine::setObjectOwnership(o, QQmlEngine::CppOwnership); + return o; +} + static QObject *create_singletonWithEnum(QQmlEngine *, QJSEngine *) { return new SingletonWithEnum; @@ -391,6 +423,7 @@ void registerTypes() qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObjectAlias"); qmlRegisterType<MyQmlObject>("Qt.test", 1,0, "MyQmlObject"); qmlRegisterSingletonType<MyInheritedQmlObject>("Test", 1, 0, "MyInheritedQmlObjectSingleton", inheritedQmlObject_provider); + qmlRegisterSingletonType<TestTypeCppSingleton>("Test", 1, 0, "TestTypeCppSingleton", testTypeCppProvider); qmlRegisterType<MyDeferredObject>("Qt.test", 1,0, "MyDeferredObject"); qmlRegisterType<MyVeryDeferredObject>("Qt.test", 1,0, "MyVeryDeferredObject"); qmlRegisterType<MyQmlContainer>("Qt.test", 1,0, "MyQmlContainer"); diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index bbccf7b94b..eb4a3147d3 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -1253,7 +1253,7 @@ public: Q_INVOKABLE void addReference(QObject *other) { QQmlData *ddata = QQmlData::get(this); - assert(ddata); + Q_ASSERT(ddata); QV4::ExecutionEngine *v4 = ddata->jsWrapper.engine(); Q_ASSERT(v4); QV4::Scope scope(v4); diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index eb25eb70f4..b30dfcbd0b 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -326,6 +326,7 @@ private slots: void readUnregisteredQObjectProperty(); void writeUnregisteredQObjectProperty(); void switchExpression(); + void qtbug_46022(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -521,7 +522,7 @@ void tst_qqmlecmascript::idShortcutInvalidates() QVERIFY(object != 0); QVERIFY(object->objectProperty() != 0); delete object->objectProperty(); - QVERIFY(object->objectProperty() == 0); + QVERIFY(!object->objectProperty()); delete object; } @@ -531,7 +532,7 @@ void tst_qqmlecmascript::idShortcutInvalidates() QVERIFY(object != 0); QVERIFY(object->objectProperty() != 0); delete object->objectProperty(); - QVERIFY(object->objectProperty() == 0); + QVERIFY(!object->objectProperty()); delete object; } } @@ -885,7 +886,7 @@ void tst_qqmlecmascript::deferredProperties() qobject_cast<MyDeferredObject *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->value(), 0); - QVERIFY(object->objectProperty() == 0); + QVERIFY(!object->objectProperty()); QVERIFY(object->objectProperty2() != 0); qmlExecuteDeferred(object); QCOMPARE(object->value(), 10); @@ -908,8 +909,8 @@ void tst_qqmlecmascript::deferredPropertiesErrors() qobject_cast<MyDeferredObject *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->value(), 0); - QVERIFY(object->objectProperty() == 0); - QVERIFY(object->objectProperty2() == 0); + QVERIFY(!object->objectProperty()); + QVERIFY(!object->objectProperty2()); QString warning = component.url().toString() + ":6:21: Unable to assign [undefined] to QObject*"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); @@ -932,7 +933,7 @@ void tst_qqmlecmascript::deferredPropertiesInComponents() MyDeferredObject *defObjectA = qobject_cast<MyDeferredObject *>(object->property("deferredInside").value<QObject*>()); QVERIFY(defObjectA != 0); - QVERIFY(defObjectA->objectProperty() == 0); + QVERIFY(!defObjectA->objectProperty()); qmlExecuteDeferred(defObjectA); QVERIFY(defObjectA->objectProperty() != 0); @@ -941,7 +942,7 @@ void tst_qqmlecmascript::deferredPropertiesInComponents() MyDeferredObject *defObjectB = qobject_cast<MyDeferredObject *>(object->property("deferredOutside").value<QObject*>()); QVERIFY(defObjectB != 0); - QVERIFY(defObjectB->objectProperty() == 0); + QVERIFY(!defObjectB->objectProperty()); qmlExecuteDeferred(defObjectB); QVERIFY(defObjectB->objectProperty() != 0); @@ -995,7 +996,7 @@ void tst_qqmlecmascript::overrideExtensionProperties() qobject_cast<OverrideDefaultPropertyObject *>(component.create()); QVERIFY(object != 0); QVERIFY(object->secondProperty() != 0); - QVERIFY(object->firstProperty() == 0); + QVERIFY(!object->firstProperty()); delete object; } @@ -1459,7 +1460,7 @@ void tst_qqmlecmascript::aliasPropertyReset() QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() != 0); QCOMPARE(object->property("aliasIsUndefined"), QVariant(false)); QMetaObject::invokeMethod(object, "resetAliased"); - QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); + QVERIFY(!object->property("sourceComponentAlias").value<QQmlComponent*>()); QCOMPARE(object->property("aliasIsUndefined"), QVariant(true)); delete object; @@ -1470,7 +1471,7 @@ void tst_qqmlecmascript::aliasPropertyReset() QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() != 0); QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(false)); QMetaObject::invokeMethod(object, "resetAlias"); - QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); + QVERIFY(!object->property("sourceComponentAlias").value<QQmlComponent*>()); QCOMPARE(object->property("loaderSourceComponentIsUndefined"), QVariant(true)); delete object; @@ -1482,7 +1483,7 @@ void tst_qqmlecmascript::aliasPropertyReset() QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(false)); QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false)); QMetaObject::invokeMethod(object, "resetAlias"); - QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); + QVERIFY(!object->property("sourceComponentAlias").value<QQmlComponent*>()); QCOMPARE(object->property("loaderOneSourceComponentIsUndefined"), QVariant(true)); QCOMPARE(object->property("loaderTwoSourceComponentIsUndefined"), QVariant(false)); delete object; @@ -1498,9 +1499,9 @@ void tst_qqmlecmascript::aliasPropertyReset() delete loader; QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); // deletion should have caused value unset. QMetaObject::invokeMethod(object, "resetAlias"); // shouldn't crash. - QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); + QVERIFY(!object->property("sourceComponentAlias").value<QQmlComponent*>()); QMetaObject::invokeMethod(object, "setAlias"); // shouldn't crash, and shouldn't change value (since it's no longer referencing anything). - QVERIFY(object->property("sourceComponentAlias").value<QQmlComponent*>() == 0); + QVERIFY(!object->property("sourceComponentAlias").value<QQmlComponent*>()); delete object; // test that binding an alias property to an undefined value works correctly @@ -1680,7 +1681,7 @@ void tst_qqmlecmascript::dynamicDestruction() QObject *o = component.create(); QVERIFY(o != 0); - QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0); + QVERIFY(!qvariant_cast<QObject*>(o->property("objectProperty"))); QMetaObject::invokeMethod(o, "create"); @@ -1691,7 +1692,7 @@ void tst_qqmlecmascript::dynamicDestruction() QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCoreApplication::processEvents(); - QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0); + QVERIFY(!qvariant_cast<QObject*>(o->property("objectProperty"))); delete o; } @@ -1702,19 +1703,19 @@ void tst_qqmlecmascript::dynamicDestruction() QQmlComponent component(&engine, testFileUrl("dynamicDeletion.3.qml")); QObject *o = component.create(); QVERIFY(o != 0); - QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0); + QVERIFY(!qvariant_cast<QObject*>(o->property("objectProperty"))); QMetaObject::invokeMethod(o, "create"); createdQmlObject = qvariant_cast<QObject*>(o->property("objectProperty")); QVERIFY(createdQmlObject); QMetaObject::invokeMethod(o, "destroy"); - QVERIFY(qvariant_cast<bool>(o->property("test")) == false); + QCOMPARE(qvariant_cast<bool>(o->property("test")), false); for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up QTest::qWait(100); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCoreApplication::processEvents(); } - QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0); - QVERIFY(qvariant_cast<bool>(o->property("test")) == true); + QVERIFY(!qvariant_cast<QObject*>(o->property("objectProperty"))); + QCOMPARE(qvariant_cast<bool>(o->property("test")), true); delete o; } } @@ -1750,9 +1751,9 @@ void tst_qqmlecmascript::objectHasOwnProperty() // test QObjects in QML QMetaObject::invokeMethod(object, "testHasOwnPropertySuccess"); - QVERIFY(object->property("result").value<bool>() == true); + QVERIFY(object->property("result").value<bool>()); QMetaObject::invokeMethod(object, "testHasOwnPropertyFailure"); - QVERIFY(object->property("result").value<bool>() == false); + QVERIFY(!object->property("result").value<bool>()); // now test other types in QML QObject *child = object->findChild<QObject*>("typeObj"); @@ -1846,7 +1847,7 @@ void tst_qqmlecmascript::uncreatableExtendedObjectFailureCheck() QQmlComponent component(&engine, testFileUrl("uncreatableExtendedObjectFailureCheck.qml")); QObject *object = component.create(); - QVERIFY(object == 0); + QVERIFY(!object); } /* @@ -2235,7 +2236,7 @@ void tst_qqmlecmascript::dynamicCreationCrash() QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); QMetaObject::invokeMethod(object, "dontCrash"); QObject *created = object->objectProperty(); - QVERIFY(created == 0); + QVERIFY(!created); delete object; } @@ -2993,7 +2994,7 @@ void tst_qqmlecmascript::listToVariant() QVariant v = object->property("test"); QCOMPARE(v.userType(), qMetaTypeId<QQmlListReference>()); - QVERIFY(qvariant_cast<QQmlListReference>(v).object() == &container); + QCOMPARE(qvariant_cast<QQmlListReference>(v).object(), &container); delete object; } @@ -3260,7 +3261,7 @@ void tst_qqmlecmascript::ownership() QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCoreApplication::processEvents(); - QVERIFY(own.object == 0); + QVERIFY(own.object.isNull()); delete object; } @@ -3319,7 +3320,7 @@ void tst_qqmlecmascript::cppOwnershipReturnValue() QQmlEngine engine; engine.rootContext()->setContextProperty("source", &source); - QVERIFY(source.value == 0); + QVERIFY(source.value.isNull()); QQmlComponent component(&engine); component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.create(); }\n}\n", QUrl()); @@ -3347,7 +3348,7 @@ void tst_qqmlecmascript::ownershipCustomReturnValue() QQmlEngine engine; engine.rootContext()->setContextProperty("source", &source); - QVERIFY(source.value == 0); + QVERIFY(source.value.isNull()); QQmlComponent component(&engine); component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.createQmlObject(); }\n}\n", QUrl()); @@ -3364,7 +3365,7 @@ void tst_qqmlecmascript::ownershipCustomReturnValue() QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCoreApplication::processEvents(); - QVERIFY(source.value == 0); + QVERIFY(source.value.isNull()); } //the return value from getObject will be JS ownership, @@ -3446,7 +3447,7 @@ void tst_qqmlecmascript::ownershipQmlIncubated() QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCoreApplication::processEvents(); - QVERIFY(object->property("incubatedItem").value<QObject*>() == 0); + QVERIFY(!object->property("incubatedItem").value<QObject*>()); delete object; } @@ -3863,7 +3864,7 @@ void tst_qqmlecmascript::singletonType() QObject *object = component.create(); if (!errorMessage.isEmpty()) { - QVERIFY(object == 0); + QVERIFY(!object); } else { QVERIFY(object != 0); for (int i = 0; i < readProperties.size(); ++i) @@ -3920,7 +3921,7 @@ void tst_qqmlecmascript::singletonTypeImportOrder() QQmlComponent component(&engine, testFileUrl("singletontype/singletonTypeImportOrder.qml")); QObject *object = component.create(); QVERIFY(object); - QVERIFY(object->property("v") == 1); + QCOMPARE(object->property("v").toInt(), 1); delete object; } @@ -3929,7 +3930,7 @@ void tst_qqmlecmascript::singletonTypeResolution() QQmlComponent component(&engine, testFileUrl("singletontype/singletonTypeResolution.qml")); QObject *object = component.create(); QVERIFY(object); - QVERIFY(object->property("success") == true); + QVERIFY(object->property("success").toBool()); delete object; } @@ -3941,12 +3942,12 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) { QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); QV4::Scope scope(v4); QV4::ScopedArrayObject scripts(scope, ctxt->importedScripts.value()); - QV4::ScopedValue qml(scope); + QV4::Scoped<QV4::QmlContextWrapper> qml(scope); for (quint32 i = 0; i < scripts->getLength(); ++i) { QQmlContextData *scriptContext, *newContext; qml = scripts->getIndexed(i); - scriptContext = QV4::QmlContextWrapper::getContext(qml); + scriptContext = qml ? qml->getContext() : 0; qml = QV4::Encode::undefined(); { @@ -3957,8 +3958,8 @@ void tst_qqmlecmascript::verifyContextLifetime(QQmlContextData *ctxt) { ctxt->engine->collectGarbage(); qml = scripts->getIndexed(i); - newContext = QV4::QmlContextWrapper::getContext(qml); - QVERIFY(scriptContext == newContext); + newContext = qml ? qml->getContext() : 0; + QCOMPARE(scriptContext, newContext); } } @@ -4202,9 +4203,7 @@ void tst_qqmlecmascript::importScripts() QFETCH(QStringList, propertyNames); QFETCH(QVariantList, propertyValues); - TestHTTPServer server; - QVERIFY2(server.listen(), qPrintable(server.errorString())); - server.serveDirectory(dataDirectory() + "/remote"); + ThreadedTestHTTPServer server(dataDirectory() + "/remote"); QStringList importPathList = engine.importPathList(); @@ -4232,7 +4231,7 @@ void tst_qqmlecmascript::importScripts() QObject *object = component.create(); if (!errorMessage.isEmpty()) { - QVERIFY(object == 0); + QVERIFY(!object); } else { QVERIFY(object != 0); @@ -4685,7 +4684,7 @@ void tst_qqmlecmascript::propertyChangeSlots() QString expectedErrorString = e1.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_nameWithUnderscoreChanged\""); QCOMPARE(e1.errors().at(0).toString(), expectedErrorString); object = e1.create(); - QVERIFY(object == 0); + QVERIFY(!object); delete object; QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); @@ -4693,7 +4692,7 @@ void tst_qqmlecmascript::propertyChangeSlots() expectedErrorString = e2.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on____nameWithUnderscoresChanged\""); QCOMPARE(e2.errors().at(0).toString(), expectedErrorString); object = e2.create(); - QVERIFY(object == 0); + QVERIFY(!object); delete object; QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); @@ -4701,7 +4700,7 @@ void tst_qqmlecmascript::propertyChangeSlots() expectedErrorString = e3.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on$NameWithDollarsignChanged\""); QCOMPARE(e3.errors().at(0).toString(), expectedErrorString); object = e3.create(); - QVERIFY(object == 0); + QVERIFY(!object); delete object; QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready"); @@ -4709,7 +4708,7 @@ void tst_qqmlecmascript::propertyChangeSlots() expectedErrorString = e4.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_6NameWithUnderscoreNumberChanged\""); QCOMPARE(e4.errors().at(0).toString(), expectedErrorString); object = e4.create(); - QVERIFY(object == 0); + QVERIFY(!object); delete object; } @@ -5007,6 +5006,12 @@ void tst_qqmlecmascript::propertyVarCircular() QObject *object = component.create(); QVERIFY(object != 0); QMetaObject::invokeMethod(object, "assignCircular"); // cause assignment and gc + { + QCOMPARE(object->property("canaryInt"), QVariant(5)); + QVariant canaryResourceVariant = object->property("canaryResource"); + QVERIFY(canaryResourceVariant.isValid()); + } + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); // process deleteLater() events from QV8QObjectWrapper. QCoreApplication::processEvents(); QCOMPARE(object->property("canaryInt"), QVariant(5)); @@ -5703,9 +5708,10 @@ void tst_qqmlecmascript::deletedEngine() delete engine; - QCOMPARE(object->property("a").toInt(), 117); + QCOMPARE(object->property("a").toInt(), 0); object->setProperty("b", QVariant(10)); - QCOMPARE(object->property("a").toInt(), 117); + object->setProperty("b", QVariant()); + QCOMPARE(object->property("a").toInt(), 0); delete object; } @@ -5747,10 +5753,10 @@ void tst_qqmlecmascript::variants() QObject *object = component.create(); QVERIFY(object != 0); - QVERIFY(object->property("undefinedVariant").type() == QVariant::Invalid); - QVERIFY(object->property("nullVariant").type() == (int)QMetaType::VoidStar); - QVERIFY(object->property("intVariant").type() == QVariant::Int); - QVERIFY(object->property("doubleVariant").type() == QVariant::Double); + QCOMPARE(object->property("undefinedVariant").type(), QVariant::Invalid); + QCOMPARE(int(object->property("nullVariant").type()), int(QMetaType::VoidStar)); + QCOMPARE(object->property("intVariant").type(), QVariant::Int); + QCOMPARE(object->property("doubleVariant").type(), QVariant::Double); QVariant result; QMetaObject::invokeMethod(object, "checkNull", Q_RETURN_ARG(QVariant, result)); @@ -5801,7 +5807,7 @@ void tst_qqmlecmascript::qtcreatorbug_1289() delete nested; nested = qvariant_cast<QObject *>(o->property("object")); - QVERIFY(nested == 0); + QVERIFY(!nested); // If the bug is present, the next line will crash delete o; @@ -5848,7 +5854,7 @@ void tst_qqmlecmascript::canAssignNullToQObject() o->setProperty("runTest", true); - QVERIFY(o->objectProperty() == 0); + QVERIFY(!o->objectProperty()); delete o; } @@ -5859,7 +5865,7 @@ void tst_qqmlecmascript::canAssignNullToQObject() MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(o != 0); - QVERIFY(o->objectProperty() == 0); + QVERIFY(!o->objectProperty()); delete o; } @@ -6064,7 +6070,7 @@ void tst_qqmlecmascript::include() o->setProperty("serverBaseUrl", server.baseUrl().toString()); component.completeCreate(); - QTRY_VERIFY(o->property("done").toBool() == true); + QTRY_VERIFY(o->property("done").toBool()); QCOMPARE(o->property("test1").toBool(), true); QCOMPARE(o->property("test2").toBool(), true); @@ -6108,8 +6114,8 @@ void tst_qqmlecmascript::includeRemoteSuccess() o->setProperty("serverBaseUrl", server.baseUrl().toString()); component.completeCreate(); - QTRY_VERIFY(o->property("done").toBool() == true); - QTRY_VERIFY(o->property("done2").toBool() == true); + QTRY_VERIFY(o->property("done").toBool()); + QTRY_VERIFY(o->property("done2").toBool()); QCOMPARE(o->property("test1").toBool(), true); QCOMPARE(o->property("test2").toBool(), true); @@ -6132,7 +6138,7 @@ void tst_qqmlecmascript::signalHandlers() QObject *o = component.create(); QVERIFY(o != 0); - QVERIFY(o->property("count").toInt() == 0); + QCOMPARE(o->property("count").toInt(), 0); QMetaObject::invokeMethod(o, "testSignalCall"); QCOMPARE(o->property("count").toInt(), 1); @@ -6140,7 +6146,7 @@ void tst_qqmlecmascript::signalHandlers() QCOMPARE(o->property("count").toInt(), 1); QCOMPARE(o->property("errorString").toString(), QLatin1String("TypeError: Property 'onTestSignal' of object [object Object] is not a function")); - QVERIFY(o->property("funcCount").toInt() == 0); + QCOMPARE(o->property("funcCount").toInt(), 0); QMetaObject::invokeMethod(o, "testSignalConnection"); QCOMPARE(o->property("funcCount").toInt(), 1); @@ -6684,7 +6690,7 @@ void tst_qqmlecmascript::incrDecrSemicolon_error1() { QQmlComponent component(&engine, testFileUrl("incrDecrSemicolon_error1.qml")); QObject *object = component.create(); - QVERIFY(object == 0); + QVERIFY(!object); } void tst_qqmlecmascript::unaryExpression() @@ -7032,7 +7038,7 @@ void tst_qqmlecmascript::invokableWithQObjectDerived() QObject *object = component.create(); QVERIFY(object != 0); - QVERIFY(object->property("result").value<bool>() == true); + QVERIFY(object->property("result").value<bool>()); delete object; } @@ -7111,6 +7117,7 @@ void tst_qqmlecmascript::onDestruction() QObject *obj = c.create(); QVERIFY(obj != 0); delete obj; + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); } { @@ -7122,6 +7129,7 @@ void tst_qqmlecmascript::onDestruction() QQmlComponent c(&engine, testFileUrl("onDestruction.qml")); QObject *obj = c.create(); QVERIFY(obj != 0); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); } } @@ -7320,7 +7328,7 @@ void tst_qqmlecmascript::sequenceSort_data() for (size_t t=0 ; t < sizeof(types)/sizeof(types[0]) ; ++t) { for (size_t s=0 ; s < sizeof(sort)/sizeof(sort[0]) ; ++s) { for (int c=0 ; c < 2 ; ++c) { - QString testName = QLatin1String(types[t]) + QLatin1String("_") + QLatin1String(sort[s]); + QString testName = QLatin1String(types[t]) + QLatin1Char('_') + QLatin1String(sort[s]); QString fnName = QLatin1String("test_") + testName; bool useComparer = c != 0; testName += useComparer ? QLatin1String("[custom]") : QLatin1String("[default]"); @@ -7344,7 +7352,7 @@ void tst_qqmlecmascript::sequenceSort() QVariant q; QMetaObject::invokeMethod(object, function.toAscii().constData(), Q_RETURN_ARG(QVariant, q), Q_ARG(QVariant, useComparer)); - QVERIFY(q.toBool() == true); + QVERIFY(q.toBool()); delete object; } @@ -7360,10 +7368,10 @@ void tst_qqmlecmascript::dateParse() QVariant q; QMetaObject::invokeMethod(object, "test_is_invalid_jsDateTime", Q_RETURN_ARG(QVariant, q)); - QVERIFY(q.toBool() == true); + QVERIFY(q.toBool()); QMetaObject::invokeMethod(object, "test_is_invalid_qtDateTime", Q_RETURN_ARG(QVariant, q)); - QVERIFY(q.toBool() == true); + QVERIFY(q.toBool()); QMetaObject::invokeMethod(object, "test_rfc2822_date", Q_RETURN_ARG(QVariant, q)); QCOMPARE(q.toLongLong(), 1379512851000LL); @@ -7381,7 +7389,7 @@ void tst_qqmlecmascript::utcDate() QVariant q; QVariant val = QString::fromLatin1("2014-07-16T23:30:31"); QMetaObject::invokeMethod(object, "check_utc", Q_RETURN_ARG(QVariant, q), Q_ARG(QVariant, val)); - QVERIFY(q.toBool() == true); + QVERIFY(q.toBool()); } void tst_qqmlecmascript::negativeYear() @@ -7478,7 +7486,7 @@ void tst_qqmlecmascript::stringParsing() file = file.arg(i); QQmlComponent component(&engine, testFileUrl(file)); QObject *object = component.create(); - QVERIFY(object == 0); + QVERIFY(!object); } } @@ -7491,7 +7499,7 @@ void tst_qqmlecmascript::push_and_shift() " array.push(5); array.unshift(5); array.push(5);" "}" "array.length;"; - QVERIFY(e.evaluate(program).toNumber() == 30000); + QCOMPARE(e.evaluate(program).toNumber(), double(30000)); } void tst_qqmlecmascript::qtbug_32801() @@ -7611,13 +7619,13 @@ void tst_qqmlecmascript::miscTypeTest() QVariant q; QMetaObject::invokeMethod(object, "test_invalid_url_equal", Q_RETURN_ARG(QVariant, q)); - QVERIFY(q.toBool() == true); + QVERIFY(q.toBool()); QMetaObject::invokeMethod(object, "test_invalid_url_strictequal", Q_RETURN_ARG(QVariant, q)); - QVERIFY(q.toBool() == true); + QVERIFY(q.toBool()); QMetaObject::invokeMethod(object, "test_valid_url_equal", Q_RETURN_ARG(QVariant, q)); - QVERIFY(q.toBool() == true); + QVERIFY(q.toBool()); QMetaObject::invokeMethod(object, "test_valid_url_strictequal", Q_RETURN_ARG(QVariant, q)); - QVERIFY(q.toBool() == true); + QVERIFY(q.toBool()); delete object; } @@ -7665,7 +7673,7 @@ void tst_qqmlecmascript::singletonWithEnum() qDebug() << component.errors().first().toString(); QVERIFY(!obj.isNull()); QVariant prop = obj->property("testValue"); - QVERIFY(prop.type() == QVariant::Int); + QCOMPARE(prop.type(), QVariant::Int); QCOMPARE(prop.toInt(), int(SingletonWithEnum::TestValue)); } @@ -7677,7 +7685,7 @@ void tst_qqmlecmascript::lazyBindingEvaluation() qDebug() << component.errors().first().toString(); QVERIFY(!obj.isNull()); QVariant prop = obj->property("arrayLength"); - QVERIFY(prop.type() == QVariant::Int); + QCOMPARE(prop.type(), QVariant::Int); QCOMPARE(prop.toInt(), 2); } @@ -7688,7 +7696,7 @@ void tst_qqmlecmascript::varPropertyAccessOnObjectWithInvalidContext() if (obj.isNull()) qDebug() << component.errors().first().toString(); QVERIFY(!obj.isNull()); - QVERIFY(obj->property("success") == true); + QVERIFY(obj->property("success").toBool()); } void tst_qqmlecmascript::importedScriptsAccessOnObjectWithInvalidContext() @@ -7698,7 +7706,7 @@ void tst_qqmlecmascript::importedScriptsAccessOnObjectWithInvalidContext() if (obj.isNull()) qDebug() << component.errors().first().toString(); QVERIFY(!obj.isNull()); - QTRY_VERIFY(obj->property("success") == true); + QTRY_VERIFY(obj->property("success").toBool()); } void tst_qqmlecmascript::importedScriptsWithoutQmlMode() @@ -7708,7 +7716,7 @@ void tst_qqmlecmascript::importedScriptsWithoutQmlMode() if (obj.isNull()) qDebug() << component.errors().first().toString(); QVERIFY(!obj.isNull()); - QTRY_VERIFY(obj->property("success") == true); + QTRY_VERIFY(obj->property("success").toBool()); } void tst_qqmlecmascript::contextObjectOnLazyBindings() @@ -7871,6 +7879,16 @@ void tst_qqmlecmascript::switchExpression() QCOMPARE(v.toBool(), true); } +void tst_qqmlecmascript::qtbug_46022() +{ + QQmlComponent component(&engine, testFileUrl("qtbug_46022.qml")); + + QScopedPointer<QObject> obj(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->property("test1").toBool(), true); + QCOMPARE(obj->property("test2").toBool(), true); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmlengine/data/TypeofQmlProperty.qml b/tests/auto/qml/qqmlengine/data/TypeofQmlProperty.qml new file mode 100644 index 0000000000..2196543dc8 --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/TypeofQmlProperty.qml @@ -0,0 +1,6 @@ +import QtQuick 2.5 + +Item { + property var someProp: 1 + Component.onCompleted: console.log("typeof someProp:", typeof(someProp)); +} diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index eac648ef15..486a0b4e87 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -75,6 +75,8 @@ private slots: void urlInterceptor_data(); void urlInterceptor(); + void qmlContextProperties(); + public slots: QObject *createAQObjectForOwnershipTest () { @@ -90,7 +92,7 @@ void tst_qqmlengine::rootContext() QVERIFY(engine.rootContext()); QCOMPARE(engine.rootContext()->engine(), &engine); - QVERIFY(engine.rootContext()->parentContext() == 0); + QVERIFY(!engine.rootContext()->parentContext()); } class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory @@ -119,8 +121,9 @@ void tst_qqmlengine::networkAccessManager() engine = new QQmlEngine; NetworkAccessManagerFactory factory; engine->setNetworkAccessManagerFactory(&factory); - QVERIFY(engine->networkAccessManagerFactory() == &factory); - QVERIFY(engine->networkAccessManager() == factory.manager); + QCOMPARE(engine->networkAccessManagerFactory(), &factory); + QNetworkAccessManager *engineNam = engine->networkAccessManager(); // calls NetworkAccessManagerFactory::create() + QCOMPARE(engineNam, factory.manager); delete engine; } @@ -184,7 +187,7 @@ void tst_qqmlengine::baseUrl() dir.cdUp(); QVERIFY(dir != QDir::current()); QDir::setCurrent(dir.path()); - QVERIFY(QDir::current() == dir); + QCOMPARE(QDir::current(), dir); QUrl cwd2 = QUrl::fromLocalFile(QDir::currentPath() + QDir::separator()); QCOMPARE(engine.baseUrl(), cwd2); @@ -200,11 +203,11 @@ void tst_qqmlengine::contextForObject() QQmlEngine *engine = new QQmlEngine; // Test null-object - QVERIFY(QQmlEngine::contextForObject(0) == 0); + QVERIFY(!QQmlEngine::contextForObject(0)); // Test an object with no context QObject object; - QVERIFY(QQmlEngine::contextForObject(&object) == 0); + QVERIFY(!QQmlEngine::contextForObject(&object)); // Test setting null-object QQmlEngine::setContextForObject(0, engine->rootContext()); @@ -214,18 +217,18 @@ void tst_qqmlengine::contextForObject() // Test setting context QQmlEngine::setContextForObject(&object, engine->rootContext()); - QVERIFY(QQmlEngine::contextForObject(&object) == engine->rootContext()); + QCOMPARE(QQmlEngine::contextForObject(&object), engine->rootContext()); QQmlContext context(engine->rootContext()); // Try changing context QTest::ignoreMessage(QtWarningMsg, "QQmlEngine::setContextForObject(): Object already has a QQmlContext"); QQmlEngine::setContextForObject(&object, &context); - QVERIFY(QQmlEngine::contextForObject(&object) == engine->rootContext()); + QCOMPARE(QQmlEngine::contextForObject(&object), engine->rootContext()); // Delete context delete engine; engine = 0; - QVERIFY(QQmlEngine::contextForObject(&object) == 0); + QVERIFY(!QQmlEngine::contextForObject(&object)); } void tst_qqmlengine::offlineStoragePath() @@ -446,7 +449,7 @@ void tst_qqmlengine::failedCompilation() QQmlComponent component(&engine, testFileUrl(file)); QVERIFY(!component.isReady()); QScopedPointer<QObject> object(component.create()); - QVERIFY(object == 0); + QVERIFY(object.isNull()); engine.collectGarbage(); engine.trimComponentCache(); @@ -470,7 +473,7 @@ void tst_qqmlengine::outputWarningsToStandardError() QQmlComponent c(&engine); c.setData("import QtQuick 2.0; QtObject { property int a: undefined }", QUrl()); - QVERIFY(c.isReady() == true); + QVERIFY(c.isReady()); QQmlTestMessageHandler messageHandler; @@ -777,6 +780,18 @@ void tst_qqmlengine::urlInterceptor() QCOMPARE(o->property("absoluteUrl").toString(), expectedAbsoluteUrl); } +void tst_qqmlengine::qmlContextProperties() +{ + QQmlEngine e; + + QQmlComponent c(&e, testFileUrl("TypeofQmlProperty.qml")); + QObject *o = c.create(); + if (!o) { + qDebug() << c.errorString(); + } + QVERIFY(o); +} + QTEST_MAIN(tst_qqmlengine) #include "tst_qqmlengine.moc" diff --git a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp index e381976448..d9838a4941 100644 --- a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp +++ b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp @@ -140,7 +140,7 @@ void tst_qqmlexpression::expressionFromDataComponent() QQmlExpression expression(object->scriptString()); QVariant result = expression.evaluate(); - QVERIFY(result.type() == QVariant::String); + QCOMPARE(result.type(), QVariant::String); QCOMPARE(result.toString(), QStringLiteral("success")); } diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp index 26092595d9..2f581e296a 100644 --- a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp +++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp @@ -96,8 +96,8 @@ private: QList<QByteArray> actual; \ for (int ii = 0; ii < errors.count(); ++ii) { \ const QQmlError &error = errors.at(ii); \ - QByteArray errorStr = QByteArray::number(error.line()) + ":" + \ - QByteArray::number(error.column()) + ":" + \ + QByteArray errorStr = QByteArray::number(error.line()) + ':' + \ + QByteArray::number(error.column()) + ':' + \ error.description().toUtf8(); \ actual << errorStr; \ } \ @@ -148,7 +148,7 @@ void tst_qqmlincubator::objectDeleted() component.create(incubator); QCOMPARE(incubator.status(), QQmlIncubator::Loading); - QVERIFY(SelfRegisteringType::me() == 0); + QVERIFY(!SelfRegisteringType::me()); while (SelfRegisteringOuterType::me() == 0 && incubator.isLoading()) { bool b = false; @@ -172,7 +172,7 @@ void tst_qqmlincubator::objectDeleted() QVERIFY(incubator.isError()); VERIFY_ERRORS(incubator, "objectDeleted.errors.txt"); - QVERIFY(incubator.object() == 0); + QVERIFY(!incubator.object()); } QVERIFY(SelfRegisteringOuterType::beenDeleted); } @@ -236,7 +236,7 @@ void tst_qqmlincubator::clear() incubator.clear(); QVERIFY(incubator.isNull()); - QVERIFY(incubator.object() == 0); + QVERIFY(!incubator.object()); QVERIFY(!obj.isNull()); delete obj; @@ -413,7 +413,7 @@ void tst_qqmlincubator::clearDuringCompletion() component.create(incubator); QCOMPARE(incubator.status(), QQmlIncubator::Loading); - QVERIFY(CompletionRegisteringType::me() == 0); + QVERIFY(!CompletionRegisteringType::me()); while (CompletionRegisteringType::me() == 0 && incubator.isLoading()) { bool b = false; @@ -622,7 +622,7 @@ void tst_qqmlincubator::asynchronousIfNested() component.create(incubator); QVERIFY(incubator.isLoading()); - QVERIFY(SelfRegisteringType::me() == 0); + QVERIFY(!SelfRegisteringType::me()); while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { bool b = false; controller.incubateWhile(&b); @@ -741,7 +741,7 @@ void tst_qqmlincubator::chainedAsynchronousIfNested() component.create(incubator); QVERIFY(incubator.isLoading()); - QVERIFY(SelfRegisteringType::me() == 0); + QVERIFY(!SelfRegisteringType::me()); while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { bool b = false; @@ -855,7 +855,7 @@ void tst_qqmlincubator::chainedAsynchronousIfNestedOnCompleted() component.create(incubator); QVERIFY(incubator.isLoading()); - QVERIFY(SelfRegisteringType::me() == 0); + QVERIFY(!SelfRegisteringType::me()); while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { bool b = false; @@ -983,7 +983,7 @@ void tst_qqmlincubator::chainedAsynchronousClear() component.create(incubator); QVERIFY(incubator.isLoading()); - QVERIFY(SelfRegisteringType::me() == 0); + QVERIFY(!SelfRegisteringType::me()); while (SelfRegisteringType::me() == 0 && incubator.isLoading()) { bool b = false; @@ -1106,7 +1106,7 @@ void tst_qqmlincubator::selfDelete() component.create(*incubator); QCOMPARE(incubator->QQmlIncubator::status(), QQmlIncubator::Loading); - QVERIFY(SelfRegisteringType::me() == 0); + QVERIFY(!SelfRegisteringType::me()); while (SelfRegisteringType::me() == 0 && incubator->isLoading()) { bool b = false; diff --git a/tests/auto/qml/qqmllanguage/BLACKLIST b/tests/auto/qml/qqmllanguage/BLACKLIST new file mode 100644 index 0000000000..c1c7e56df9 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/BLACKLIST @@ -0,0 +1,2 @@ +[importsPath] +windows diff --git a/tests/auto/qml/qqmllanguage/data/CompositeTypeWithAttachedProperty.qml b/tests/auto/qml/qqmllanguage/data/CompositeTypeWithAttachedProperty.qml new file mode 100644 index 0000000000..6a14e72a31 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/CompositeTypeWithAttachedProperty.qml @@ -0,0 +1,4 @@ +import Test 1.0 + +MyCompositeBaseType { +} diff --git a/tests/auto/qml/qqmllanguage/data/CompositeTypeWithEnum.qml b/tests/auto/qml/qqmllanguage/data/CompositeTypeWithEnum.qml new file mode 100644 index 0000000000..6a14e72a31 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/CompositeTypeWithEnum.qml @@ -0,0 +1,4 @@ +import Test 1.0 + +MyCompositeBaseType { +} diff --git a/tests/auto/qml/qqmllanguage/data/assignSignalFunctionExpression.qml b/tests/auto/qml/qqmllanguage/data/assignSignalFunctionExpression.qml new file mode 100644 index 0000000000..bf8f8556c1 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/assignSignalFunctionExpression.qml @@ -0,0 +1,5 @@ +import Test 1.0 +MyQmlObject { + onBasicSignal: function() { basicSlot() } + onBasicParameterizedSignal: function(param) { basicSlotWithArgs(param) } +} diff --git a/tests/auto/qml/qqmllanguage/data/registeredCompositeTypeWithAttachedProperty.qml b/tests/auto/qml/qqmllanguage/data/registeredCompositeTypeWithAttachedProperty.qml new file mode 100644 index 0000000000..d34e4650b3 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/registeredCompositeTypeWithAttachedProperty.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +RegisteredCompositeTypeWithAttachedProperty { + RegisteredCompositeTypeWithAttachedProperty.objectName: "test" + property string attachedProperty: RegisteredCompositeTypeWithAttachedProperty.objectName +} diff --git a/tests/auto/qml/qqmllanguage/data/registeredCompositeTypeWithEnum.qml b/tests/auto/qml/qqmllanguage/data/registeredCompositeTypeWithEnum.qml new file mode 100644 index 0000000000..5f8c11e5f6 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/registeredCompositeTypeWithEnum.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +RegisteredCompositeTypeWithEnum { + property int enumValue0: RegisteredCompositeTypeWithEnum.EnumValue0 + property int enumValue42: RegisteredCompositeTypeWithEnum.EnumValue42 +} diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp index 6fc4bae438..95a98788c3 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.cpp +++ b/tests/auto/qml/qqmllanguage/testtypes.cpp @@ -91,6 +91,8 @@ void registerTypes() qmlRegisterCustomExtendedType<SimpleObjectWithCustomParser, SimpleObjectExtension>("Test", 1, 0, "SimpleExtendedObjectWithCustomParser", new SimpleObjectCustomParser); qmlRegisterType<RootObjectInCreationTester>("Test", 1, 0, "RootObjectInCreationTester"); + + qmlRegisterType<MyCompositeBaseType>("Test", 1, 0, "MyCompositeBaseType"); } QVariant myCustomVariantTypeConverter(const QString &data) @@ -121,7 +123,7 @@ void CustomBinding::componentComplete() QQmlContextData *context = QQmlContextData::get(qmlContext(this)); QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this))); - QV4::ScopedValue function(scope, QV4::QmlBindingWrapper::createQmlCallableForFunction(context, m_target, cdata->compilationUnit->runtimeFunctions[bindingId])); + QV4::ScopedValue function(scope, QV4::FunctionObject::createQmlFunction(context, m_target, cdata->compilationUnit->runtimeFunctions[bindingId])); QQmlBinding *qmlBinding = new QQmlBinding(function, m_target, context); QQmlProperty property(m_target, name, qmlContext(this)); diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h index b8792a892f..c64fda5ea1 100644 --- a/tests/auto/qml/qqmllanguage/testtypes.h +++ b/tests/auto/qml/qqmllanguage/testtypes.h @@ -1079,9 +1079,20 @@ class MyEnumDerivedClass : public MyEnum2Class Q_OBJECT }; +class MyCompositeBaseType : public QObject +{ + Q_OBJECT + Q_ENUMS(CompositeEnum) + +public: + enum CompositeEnum { EnumValue0, EnumValue42 = 42 }; + static QObject *qmlAttachedProperties(QObject *parent) { return new QObject(parent); } +}; + Q_DECLARE_METATYPE(MyEnum2Class::EnumB) Q_DECLARE_METATYPE(MyEnum1Class::EnumA) Q_DECLARE_METATYPE(Qt::TextFormat) +Q_DECLARE_METATYPE(MyCompositeBaseType::CompositeEnum) QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered) QML_DECLARE_TYPE(MyRevisionedBaseClassUnregistered) @@ -1089,6 +1100,8 @@ QML_DECLARE_TYPE(MyRevisionedClass) QML_DECLARE_TYPE(MyRevisionedSubclass) QML_DECLARE_TYPE(MySubclass) QML_DECLARE_TYPE(MyReceiversTestObject) +QML_DECLARE_TYPE(MyCompositeBaseType) +QML_DECLARE_TYPEINFO(MyCompositeBaseType, QML_HAS_ATTACHED_PROPERTIES) class CustomBinding : public QObject, public QQmlParserStatus { diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 08da779d90..1f299c0dbb 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -55,6 +55,10 @@ #include "../../shared/util.h" +#if defined(Q_OS_MAC) +#include <unistd.h> +#endif + DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES) static inline bool isCaseSensitiveFileSystem(const QString &path) { @@ -113,6 +117,7 @@ private slots: void idProperty(); void autoNotifyConnection(); void assignSignal(); + void assignSignalFunctionExpression(); void overrideSignal_data(); void overrideSignal(); void dynamicProperties(); @@ -154,6 +159,8 @@ private slots: void readonlyObjectProperties(); void receivers(); void registeredCompositeType(); + void registeredCompositeTypeWithEnum(); + void registeredCompositeTypeWithAttachedProperty(); void implicitImportsLast(); void basicRemote_data(); @@ -240,6 +247,8 @@ private slots: void earlyIdObjectAccess(); + void dataAlignment(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -275,8 +284,8 @@ private: QList<QQmlError> errors = component.errors(); \ for (int ii = 0; ii < errors.count(); ++ii) { \ const QQmlError &error = errors.at(ii); \ - QByteArray errorStr = QByteArray::number(error.line()) + ":" + \ - QByteArray::number(error.column()) + ":" + \ + QByteArray errorStr = QByteArray::number(error.line()) + ':' + \ + QByteArray::number(error.column()) + ':' + \ error.description().toUtf8(); \ actual << errorStr; \ } \ @@ -328,7 +337,7 @@ void tst_qqmllanguage::insertedSemicolon() if(create) { QObject *object = component.create(); - QVERIFY(object == 0); + QVERIFY(!object); } VERIFY_ERRORS(errorFile.toLatin1().constData()); @@ -550,7 +559,7 @@ void tst_qqmllanguage::errors() if (create) { QObject *object = component.create(); - QVERIFY(object == 0); + QVERIFY(!object); } VERIFY_ERRORS(errorFile.toLatin1().constData()); @@ -580,7 +589,7 @@ void tst_qqmllanguage::interfaceProperty() MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create()); QVERIFY(object != 0); QVERIFY(object->interface()); - QVERIFY(object->interface()->id == 913); + QCOMPARE(object->interface()->id, 913); } void tst_qqmllanguage::interfaceQList() @@ -589,9 +598,9 @@ void tst_qqmllanguage::interfaceQList() VERIFY_ERRORS(0); MyContainer *container= qobject_cast<MyContainer*>(component.create()); QVERIFY(container != 0); - QVERIFY(container->getQListInterfaces()->count() == 2); + QCOMPARE(container->getQListInterfaces()->count(), 2); for(int ii = 0; ii < 2; ++ii) - QVERIFY(container->getQListInterfaces()->at(ii)->id == 913); + QCOMPARE(container->getQListInterfaces()->at(ii)->id, 913); } void tst_qqmllanguage::assignObjectToSignal() @@ -630,7 +639,7 @@ void tst_qqmllanguage::assignQmlComponent() VERIFY_ERRORS(0); MyContainer *object = qobject_cast<MyContainer *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->getChildren()->count() == 1); + QCOMPARE(object->getChildren()->count(), 1); QObject *child = object->getChildren()->at(0); QCOMPARE(child->property("x"), QVariant(10)); QCOMPARE(child->property("y"), QVariant(11)); @@ -722,17 +731,17 @@ void tst_qqmllanguage::assignLiteralToVariant() QCOMPARE(object->property("test11").userType(), (int)QVariant::Bool); QCOMPARE(object->property("test12").userType(), (int)QVariant::Vector4D); - QVERIFY(object->property("test1") == QVariant(1)); - QVERIFY(object->property("test2") == QVariant((double)1.7)); + QCOMPARE(object->property("test1"), QVariant(1)); + QCOMPARE(object->property("test2"), QVariant((double)1.7)); QVERIFY(object->property("test3") == QVariant(QString(QLatin1String("Hello world!")))); - QVERIFY(object->property("test4") == QVariant(QColor::fromRgb(0xFF008800))); + QCOMPARE(object->property("test4"), QVariant(QColor::fromRgb(0xFF008800))); QVERIFY(object->property("test5") == QVariant(QRectF(10, 10, 10, 10))); QVERIFY(object->property("test6") == QVariant(QPointF(10, 10))); QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10))); QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100))); - QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800")))); - QVERIFY(object->property("test10") == QVariant(bool(true))); - QVERIFY(object->property("test11") == QVariant(bool(false))); + QCOMPARE(object->property("test9"), QVariant(QString(QLatin1String("#FF008800")))); + QCOMPARE(object->property("test10"), QVariant(bool(true))); + QCOMPARE(object->property("test11"), QVariant(bool(false))); QVERIFY(object->property("test12") == QVariant(QVector4D(100, 100, 100, 100))); delete object; @@ -1170,7 +1179,7 @@ void tst_qqmllanguage::customParserTypes() VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); - QVERIFY(object->property("count") == QVariant(2)); + QCOMPARE(object->property("count"), QVariant(2)); } // Tests that the root item can be a custom component @@ -1259,6 +1268,17 @@ void tst_qqmllanguage::assignSignal() emit object->basicParameterizedSignal(9); } +void tst_qqmllanguage::assignSignalFunctionExpression() +{ + QQmlComponent component(&engine, testFileUrl("assignSignalFunctionExpression.qml")); + VERIFY_ERRORS(0); + MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); + QVERIFY(object != 0); + QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot"); + emit object->basicSignal(); + QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlotWithArgs(9)"); + emit object->basicParameterizedSignal(9); +} void tst_qqmllanguage::overrideSignal_data() { @@ -1352,7 +1372,7 @@ void tst_qqmllanguage::dynamicObjectProperties() QObject *object = component.create(); QVERIFY(object != 0); - QVERIFY(object->property("objectProperty") == qVariantFromValue((QObject*)0)); + QCOMPARE(object->property("objectProperty"), qVariantFromValue((QObject*)0)); QVERIFY(object->property("objectProperty2") != qVariantFromValue((QObject*)0)); } { @@ -1661,7 +1681,7 @@ void tst_qqmllanguage::aliasProperties() v = object->property("otherAlias"); QCOMPARE(v.userType(), qMetaTypeId<MyQmlObject*>()); o = qvariant_cast<MyQmlObject*>(v); - QVERIFY(o == 0); + QVERIFY(!o); delete object; } @@ -1691,7 +1711,7 @@ void tst_qqmllanguage::aliasProperties() QVERIFY(object2 != 0); QObject *alias = qvariant_cast<QObject *>(object->property("aliasedObject")); - QVERIFY(alias == object2); + QCOMPARE(alias, object2); delete object1; @@ -1700,7 +1720,7 @@ void tst_qqmllanguage::aliasProperties() void *a[] = { &alias2, 0, &status }; QMetaObject::metacall(object, QMetaObject::ReadProperty, object->metaObject()->indexOfProperty("aliasedObject"), a); - QVERIFY(alias2 == 0); + QVERIFY(!alias2); } // Simple composite type @@ -2106,50 +2126,50 @@ void tst_qqmllanguage::scriptStringComparison() const qreal n = 12.345; bool ok; - QVERIFY(object2->scriptProperty().stringLiteral() == s); + QCOMPARE(object2->scriptProperty().stringLiteral(), s); QVERIFY(object3->scriptProperty().numberLiteral(&ok) == n && ok); - QVERIFY(object1->scriptProperty() == object1->scriptProperty()); - QVERIFY(object2->scriptProperty() == object2->scriptProperty()); - QVERIFY(object3->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object1->scriptProperty(), object1->scriptProperty()); + QCOMPARE(object2->scriptProperty(), object2->scriptProperty()); + QCOMPARE(object3->scriptProperty(), object3->scriptProperty()); QVERIFY(object2->scriptProperty() != object3->scriptProperty()); QVERIFY(object1->scriptProperty() != object2->scriptProperty()); QVERIFY(object1->scriptProperty() != object3->scriptProperty()); func.callWithInstance(inst2, QJSValueList() << n); - QVERIFY(object2->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object2->scriptProperty(), object3->scriptProperty()); func.callWithInstance(inst2, QJSValueList() << s); QVERIFY(object2->scriptProperty() != object3->scriptProperty()); func.callWithInstance(inst3, QJSValueList() << s); - QVERIFY(object2->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object2->scriptProperty(), object3->scriptProperty()); func.callWithInstance(inst2, QJSValueList() << QJSValue::UndefinedValue); QVERIFY(object2->scriptProperty() != object3->scriptProperty()); func.callWithInstance(inst3, QJSValueList() << QJSValue::UndefinedValue); - QVERIFY(object2->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object2->scriptProperty(), object3->scriptProperty()); func.callWithInstance(inst2, QJSValueList() << QJSValue::NullValue); QVERIFY(object2->scriptProperty() != object3->scriptProperty()); func.callWithInstance(inst3, QJSValueList() << QJSValue::NullValue); - QVERIFY(object2->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object2->scriptProperty(), object3->scriptProperty()); func.callWithInstance(inst2, QJSValueList() << false); QVERIFY(object2->scriptProperty() != object3->scriptProperty()); func.callWithInstance(inst3, QJSValueList() << false); - QVERIFY(object2->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object2->scriptProperty(), object3->scriptProperty()); func.callWithInstance(inst2, QJSValueList() << true); QVERIFY(object2->scriptProperty() != object3->scriptProperty()); func.callWithInstance(inst3, QJSValueList() << true); - QVERIFY(object2->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object2->scriptProperty(), object3->scriptProperty()); QVERIFY(object1->scriptProperty() != object2->scriptProperty()); object2->setScriptProperty(object1->scriptProperty()); - QVERIFY(object1->scriptProperty() == object2->scriptProperty()); + QCOMPARE(object1->scriptProperty(), object2->scriptProperty()); QVERIFY(object1->scriptProperty() != object3->scriptProperty()); func.callWithInstance(inst3, QJSValueList() << engine.toScriptValue(object1->scriptProperty())); - QVERIFY(object1->scriptProperty() == object3->scriptProperty()); + QCOMPARE(object1->scriptProperty(), object3->scriptProperty()); // While this are two instances of the same object they are still considered different // because the (none literal) script string may access variables which have different @@ -2525,9 +2545,7 @@ void tst_qqmllanguage::basicRemote() QFETCH(QString, type); QFETCH(QString, error); - TestHTTPServer server; - QVERIFY2(server.listen(), qPrintable(server.errorString())); - server.serveDirectory(dataDirectory()); + ThreadedTestHTTPServer server(dataDirectory()); url = server.baseUrl().resolved(url); @@ -2572,9 +2590,7 @@ void tst_qqmllanguage::importsRemote() QFETCH(QString, type); QFETCH(QString, error); - TestHTTPServer server; - QVERIFY2(server.listen(), qPrintable(server.errorString())); - server.serveDirectory(dataDirectory()); + ThreadedTestHTTPServer server(dataDirectory()); qml.replace(QStringLiteral("{{ServerBaseUrl}}"), server.baseUrl().toString()); @@ -2667,9 +2683,7 @@ void tst_qqmllanguage::importsInstalledRemote() QFETCH(QString, type); QFETCH(QString, error); - TestHTTPServer server; - QVERIFY2(server.listen(), qPrintable(server.errorString())); - server.serveDirectory(dataDirectory()); + ThreadedTestHTTPServer server(dataDirectory()); QString serverdir = server.urlString("/lib/"); engine.setImportPathList(QStringList(defaultImportPathList) << serverdir); @@ -2734,9 +2748,7 @@ void tst_qqmllanguage::importsPath() QFETCH(QString, qml); QFETCH(QString, value); - TestHTTPServer server; - QVERIFY2(server.listen(), qPrintable(server.errorString())); - server.serveDirectory(dataDirectory()); + ThreadedTestHTTPServer server(dataDirectory()); for (int i = 0; i < importPath.count(); ++i) importPath[i].replace(QStringLiteral("{{ServerBaseUrl}}"), server.baseUrl().toString()); @@ -3158,6 +3170,8 @@ void tst_qqmllanguage::initTestCase() qmlRegisterType(testFileUrl("CompositeType.qml"), "Test", 1, 0, "RegisteredCompositeType"); qmlRegisterType(testFileUrl("CompositeType.DoesNotExist.qml"), "Test", 1, 0, "RegisteredCompositeType2"); qmlRegisterType(testFileUrl("invalidRoot.1.qml"), "Test", 1, 0, "RegisteredCompositeType3"); + qmlRegisterType(testFileUrl("CompositeTypeWithEnum.qml"), "Test", 1, 0, "RegisteredCompositeTypeWithEnum"); + qmlRegisterType(testFileUrl("CompositeTypeWithAttachedProperty.qml"), "Test", 1, 0, "RegisteredCompositeTypeWithAttachedProperty"); // Registering the TestType class in other modules should have no adverse effects qmlRegisterType<TestType>("org.qtproject.TestPre", 1, 0, "Test"); @@ -3250,7 +3264,7 @@ void tst_qqmllanguage::registrationOrder() QObject *o = component.create(); QVERIFY(o != 0); - QVERIFY(o->metaObject() == &MyVersion2Class::staticMetaObject); + QCOMPARE(o->metaObject(), &MyVersion2Class::staticMetaObject); delete o; } @@ -3334,12 +3348,39 @@ void tst_qqmllanguage::registeredCompositeType() delete o; } +// QTBUG-43582 +void tst_qqmllanguage::registeredCompositeTypeWithEnum() +{ + QQmlComponent component(&engine, testFileUrl("registeredCompositeTypeWithEnum.qml")); + + VERIFY_ERRORS(0); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("enumValue0").toInt(), static_cast<int>(MyCompositeBaseType::EnumValue0)); + QCOMPARE(o->property("enumValue42").toInt(), static_cast<int>(MyCompositeBaseType::EnumValue42)); + + delete o; +} + +// QTBUG-43581 +void tst_qqmllanguage::registeredCompositeTypeWithAttachedProperty() +{ + QQmlComponent component(&engine, testFileUrl("registeredCompositeTypeWithAttachedProperty.qml")); + + VERIFY_ERRORS(0); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("attachedProperty").toString(), QStringLiteral("test")); + + delete o; +} + // QTBUG-18268 void tst_qqmllanguage::remoteLoadCrash() { - TestHTTPServer server; - QVERIFY2(server.listen(), qPrintable(server.errorString())); - server.serveDirectory(dataDirectory()); + ThreadedTestHTTPServer server(dataDirectory()); QQmlComponent component(&engine); component.setData("import QtQuick 2.0; Text {}", server.url("/remoteLoadCrash.qml")); @@ -3644,7 +3685,7 @@ void tst_qqmllanguage::compositeSingletonSameEngine() QVERIFY(s2 != 0); QCOMPARE(s2->property("testProp2"), QVariant(13)); - QVERIFY(s1 == s2); + QCOMPARE(s1, s2); } // Checks that the addresses of the composite singletons used in different @@ -3693,7 +3734,7 @@ void tst_qqmllanguage::compositeSingletonQualifiedNamespace() getSingletonInstance(engine, "singletonTest5a.qml", "singletonInstance", &s2); QVERIFY(s2 != 0); - QVERIFY(s1 == s2); + QCOMPARE(s1, s2); } // Loads a singleton from a module @@ -3719,7 +3760,7 @@ void tst_qqmllanguage::compositeSingletonModule() getSingletonInstance(engine, "singletonTest6a.qml", "singletonInstance", &s2); QVERIFY(s2 != 0); - QVERIFY(s1 == s2); + QCOMPARE(s1, s2); } // Loads a singleton from a module with a higher version @@ -3745,7 +3786,7 @@ void tst_qqmllanguage::compositeSingletonModuleVersioned() getSingletonInstance(engine, "singletonTest7a.qml", "singletonInstance", &s2); QVERIFY(s2 != 0); - QVERIFY(s1 == s2); + QCOMPARE(s1, s2); } // Loads a singleton from a module with a qualified namespace @@ -3771,7 +3812,7 @@ void tst_qqmllanguage::compositeSingletonModuleQualified() getSingletonInstance(engine, "singletonTest8a.qml", "singletonInstance", &s2); QVERIFY(s2 != 0); - QVERIFY(s1 == s2); + QCOMPARE(s1, s2); } // Tries to instantiate a type with a pragma Singleton and fails @@ -3828,9 +3869,7 @@ void tst_qqmllanguage::compositeSingletonQmlDirError() // Load a remote composite singleton type via qmldir that defines the type as a singleton void tst_qqmllanguage::compositeSingletonRemote() { - TestHTTPServer server; - QVERIFY2(server.listen(), qPrintable(server.errorString())); - server.serveDirectory(dataDirectory()); + ThreadedTestHTTPServer server(dataDirectory()); QFile f(testFile("singletonTest15.qml")); QVERIFY(f.open(QIODevice::ReadOnly)); @@ -3995,7 +4034,7 @@ void tst_qqmllanguage::propertyCacheInSync() QVERIFY(ddata); QVERIFY(ddata->propertyCache); // Those always have to be in sync and correct. - QVERIFY(ddata->propertyCache == vmemoCache); + QCOMPARE(ddata->propertyCache, vmemoCache); QCOMPARE(anchors->property("margins").toInt(), 50); } @@ -4042,6 +4081,14 @@ void tst_qqmllanguage::earlyIdObjectAccess() QVERIFY(o->property("success").toBool()); } +void tst_qqmllanguage::dataAlignment() +{ + QVERIFY(sizeof(QQmlVMEMetaData) % sizeof(int) == 0); + QVERIFY(sizeof(QQmlVMEMetaData::AliasData) % sizeof(int) == 0); + QVERIFY(sizeof(QQmlVMEMetaData::PropertyData) % sizeof(int) == 0); + QVERIFY(sizeof(QQmlVMEMetaData::MethodData) % sizeof(int) == 0); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 4d76fc4fba..d26c1c584b 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -125,6 +125,7 @@ private slots: void datetime(); void datetime_data(); void about_to_be_signals(); + void modify_through_delegate(); }; bool tst_qqmllistmodel::compareVariantList(const QVariantList &testList, QVariant object) @@ -624,7 +625,7 @@ void tst_qqmllistmodel::enumerate() int expectedStringCount = sizeof(expectedStrings) / sizeof(expectedStrings[0]); - QStringList r = item->property("result").toString().split(":"); + QStringList r = item->property("result").toString().split(QLatin1Char(':')); int matchCount = 0; for (int i=0 ; i < expectedStringCount ; ++i) { @@ -642,7 +643,7 @@ void tst_qqmllistmodel::enumerate() } } - QVERIFY(matchCount == expectedStringCount); + QCOMPARE(matchCount, expectedStringCount); delete item; } @@ -1296,7 +1297,7 @@ void tst_qqmllistmodel::datetime() QQmlExpression e(engine.rootContext(), &model, qml); QVariant result = e.evaluate(); QDateTime dtResult = result.toDateTime(); - QVERIFY(expected == dtResult); + QCOMPARE(expected, dtResult); } class RowTester : public QObject @@ -1427,6 +1428,36 @@ void tst_qqmllistmodel::about_to_be_signals() QCOMPARE(tester.rowsRemovedCount, 0); } +void tst_qqmllistmodel::modify_through_delegate() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData( + "import QtQuick 2.0\n" + "Item {\n" + " ListModel {\n" + " id: testModel\n" + " objectName: \"testModel\"\n" + " ListElement { name: \"Joe\"; age: 22 }\n" + " ListElement { name: \"Doe\"; age: 33 }\n" + " }\n" + " ListView {\n" + " model: testModel\n" + " delegate: Item {\n" + " Component.onCompleted: model.age = 18;\n" + " }\n" + " }\n" + "}\n", QUrl()); + + QObject *scene = component.create(); + QQmlListModel *model = scene->findChild<QQmlListModel*>("testModel"); + + const QHash<int, QByteArray> roleNames = model->roleNames(); + + QCOMPARE(model->data(model->index(0, 0, QModelIndex()), roleNames.key("age")).toInt(), 18); + QCOMPARE(model->data(model->index(1, 0, QModelIndex()), roleNames.key("age")).toInt(), 18); +} + QTEST_MAIN(tst_qqmllistmodel) #include "tst_qqmllistmodel.moc" diff --git a/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp b/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp index 5bf75d41d4..0ad2963265 100644 --- a/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp +++ b/tests/auto/qml/qqmllistmodelworkerscript/tst_qqmllistmodelworkerscript.cpp @@ -647,15 +647,15 @@ void tst_qqmllistmodelworkerscript::worker_sync() QQuickItem *item = createWorkerTest(&eng, &component, &model); QVERIFY(item != 0); - QVERIFY(model.count() == 0); + QCOMPARE(model.count(), 0); QVERIFY(QMetaObject::invokeMethod(item, "addItem0")); - QVERIFY(model.count() == 2); + QCOMPARE(model.count(), 2); QVariant childData = model.data(0, 0); QQmlListModel *childModel = qobject_cast<QQmlListModel *>(childData.value<QObject *>()); QVERIFY(childModel); - QVERIFY(childModel->count() == 1); + QCOMPARE(childModel->count(), 1); QSignalSpy spyModelInserted(&model, SIGNAL(rowsInserted(QModelIndex,int,int))); QSignalSpy spyChildInserted(childModel, SIGNAL(rowsInserted(QModelIndex,int,int))); @@ -663,34 +663,34 @@ void tst_qqmllistmodelworkerscript::worker_sync() QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker")); waitForWorker(item); - QVERIFY(model.count() == 2); - QVERIFY(childModel->count() == 1); - QVERIFY(spyModelInserted.count() == 0); - QVERIFY(spyChildInserted.count() == 0); + QCOMPARE(model.count(), 2); + QCOMPARE(childModel->count(), 1); + QCOMPARE(spyModelInserted.count(), 0); + QCOMPARE(spyChildInserted.count(), 0); QVERIFY(QMetaObject::invokeMethod(item, "doSync")); waitForWorker(item); - QVERIFY(model.count() == 2); - QVERIFY(childModel->count() == 2); - QVERIFY(spyModelInserted.count() == 0); - QVERIFY(spyChildInserted.count() == 1); + QCOMPARE(model.count(), 2); + QCOMPARE(childModel->count(), 2); + QCOMPARE(spyModelInserted.count(), 0); + QCOMPARE(spyChildInserted.count(), 1); QVERIFY(QMetaObject::invokeMethod(item, "addItemViaWorker")); waitForWorker(item); - QVERIFY(model.count() == 2); - QVERIFY(childModel->count() == 2); - QVERIFY(spyModelInserted.count() == 0); - QVERIFY(spyChildInserted.count() == 1); + QCOMPARE(model.count(), 2); + QCOMPARE(childModel->count(), 2); + QCOMPARE(spyModelInserted.count(), 0); + QCOMPARE(spyChildInserted.count(), 1); QVERIFY(QMetaObject::invokeMethod(item, "doSync")); waitForWorker(item); - QVERIFY(model.count() == 2); - QVERIFY(childModel->count() == 3); - QVERIFY(spyModelInserted.count() == 0); - QVERIFY(spyChildInserted.count() == 2); + QCOMPARE(model.count(), 2); + QCOMPARE(childModel->count(), 3); + QCOMPARE(spyModelInserted.count(), 0); + QCOMPARE(spyChildInserted.count(), 2); delete item; qApp->processEvents(); @@ -714,24 +714,24 @@ void tst_qqmllistmodelworkerscript::worker_remove_element() QSignalSpy spyModelRemoved(&model, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QVERIFY(model.count() == 0); - QVERIFY(spyModelRemoved.count() == 0); + QCOMPARE(model.count(), 0); + QCOMPARE(spyModelRemoved.count(), 0); QVERIFY(QMetaObject::invokeMethod(item, "addItem")); - QVERIFY(model.count() == 1); + QCOMPARE(model.count(), 1); QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker")); waitForWorker(item); - QVERIFY(model.count() == 1); - QVERIFY(spyModelRemoved.count() == 0); + QCOMPARE(model.count(), 1); + QCOMPARE(spyModelRemoved.count(), 0); QVERIFY(QMetaObject::invokeMethod(item, "doSync")); waitForWorker(item); - QVERIFY(model.count() == 0); - QVERIFY(spyModelRemoved.count() == 1); + QCOMPARE(model.count(), 0); + QCOMPARE(spyModelRemoved.count(), 1); delete item; qApp->processEvents(); @@ -747,7 +747,7 @@ void tst_qqmllistmodelworkerscript::worker_remove_element() QVERIFY(QMetaObject::invokeMethod(item, "addItem")); - QVERIFY(model->count() == 1); + QCOMPARE(model->count(), 1); QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker")); QVERIFY(QMetaObject::invokeMethod(item, "doSync")); @@ -777,24 +777,24 @@ void tst_qqmllistmodelworkerscript::worker_remove_list() QSignalSpy spyModelRemoved(&model, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QVERIFY(model.count() == 0); - QVERIFY(spyModelRemoved.count() == 0); + QCOMPARE(model.count(), 0); + QCOMPARE(spyModelRemoved.count(), 0); QVERIFY(QMetaObject::invokeMethod(item, "addList")); - QVERIFY(model.count() == 1); + QCOMPARE(model.count(), 1); QVERIFY(QMetaObject::invokeMethod(item, "removeListViaWorker")); waitForWorker(item); - QVERIFY(model.count() == 1); - QVERIFY(spyModelRemoved.count() == 0); + QCOMPARE(model.count(), 1); + QCOMPARE(spyModelRemoved.count(), 0); QVERIFY(QMetaObject::invokeMethod(item, "doSync")); waitForWorker(item); - QVERIFY(model.count() == 0); - QVERIFY(spyModelRemoved.count() == 1); + QCOMPARE(model.count(), 0); + QCOMPARE(spyModelRemoved.count(), 1); delete item; qApp->processEvents(); diff --git a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp index b5963e2f71..274f292c38 100644 --- a/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp +++ b/tests/auto/qml/qqmllistreference/tst_qqmllistreference.cpp @@ -98,7 +98,7 @@ void tst_qqmllistreference::qmllistreference() TestType tt; QQmlListReference r(&tt, "data"); - QVERIFY(r.isValid() == true); + QVERIFY(r.isValid()); QCOMPARE(r.count(), 0); tt.data.append(&tt); @@ -112,52 +112,52 @@ void tst_qqmllistreference::qmllistreference_invalid() // Invalid { QQmlListReference r; - QVERIFY(r.isValid() == false); - QVERIFY(r.object() == 0); - QVERIFY(r.listElementType() == 0); - QVERIFY(r.canAt() == false); - QVERIFY(r.canClear() == false); - QVERIFY(r.canCount() == false); - QVERIFY(r.append(0) == false); - QVERIFY(r.at(10) == 0); - QVERIFY(r.clear() == false); - QVERIFY(r.count() == 0); - QVERIFY(r.isReadable() == false); - QVERIFY(r.isManipulable() == false); + QVERIFY(!r.isValid()); + QVERIFY(!r.object()); + QVERIFY(!r.listElementType()); + QVERIFY(!r.canAt()); + QVERIFY(!r.canClear()); + QVERIFY(!r.canCount()); + QVERIFY(!r.append(0)); + QVERIFY(!r.at(10)); + QVERIFY(!r.clear()); + QCOMPARE(r.count(), 0); + QVERIFY(!r.isReadable()); + QVERIFY(!r.isManipulable()); } // Non-property { QQmlListReference r(&tt, "blah"); - QVERIFY(r.isValid() == false); - QVERIFY(r.object() == 0); - QVERIFY(r.listElementType() == 0); - QVERIFY(r.canAt() == false); - QVERIFY(r.canClear() == false); - QVERIFY(r.canCount() == false); - QVERIFY(r.append(0) == false); - QVERIFY(r.at(10) == 0); - QVERIFY(r.clear() == false); - QVERIFY(r.count() == 0); - QVERIFY(r.isReadable() == false); - QVERIFY(r.isManipulable() == false); + QVERIFY(!r.isValid()); + QVERIFY(!r.object()); + QVERIFY(!r.listElementType()); + QVERIFY(!r.canAt()); + QVERIFY(!r.canClear()); + QVERIFY(!r.canCount()); + QVERIFY(!r.append(0)); + QVERIFY(!r.at(10)); + QVERIFY(!r.clear()); + QCOMPARE(r.count(), 0); + QVERIFY(!r.isReadable()); + QVERIFY(!r.isManipulable()); } // Non-list property { QQmlListReference r(&tt, "intProperty"); - QVERIFY(r.isValid() == false); - QVERIFY(r.object() == 0); - QVERIFY(r.listElementType() == 0); - QVERIFY(r.canAt() == false); - QVERIFY(r.canClear() == false); - QVERIFY(r.canCount() == false); - QVERIFY(r.append(0) == false); - QVERIFY(r.at(10) == 0); - QVERIFY(r.clear() == false); - QVERIFY(r.count() == 0); - QVERIFY(r.isReadable() == false); - QVERIFY(r.isManipulable() == false); + QVERIFY(!r.isValid()); + QVERIFY(!r.object()); + QVERIFY(!r.listElementType()); + QVERIFY(!r.canAt()); + QVERIFY(!r.canClear()); + QVERIFY(!r.canCount()); + QVERIFY(!r.append(0)); + QVERIFY(!r.at(10)); + QVERIFY(!r.clear()); + QCOMPARE(r.count(), 0); + QVERIFY(!r.isReadable()); + QVERIFY(!r.isManipulable()); } } @@ -167,19 +167,19 @@ void tst_qqmllistreference::isValid() { QQmlListReference ref; - QVERIFY(ref.isValid() == false); + QVERIFY(!ref.isValid()); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.isValid() == false); + QVERIFY(!ref.isValid()); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.isValid() == true); + QVERIFY(ref.isValid()); delete tt; - QVERIFY(ref.isValid() == false); + QVERIFY(!ref.isValid()); } } @@ -189,19 +189,19 @@ void tst_qqmllistreference::object() { QQmlListReference ref; - QVERIFY(ref.object() == 0); + QVERIFY(!ref.object()); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.object() == 0); + QVERIFY(!ref.object()); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.object() == tt); + QCOMPARE(ref.object(), tt); delete tt; - QVERIFY(ref.object() == 0); + QVERIFY(!ref.object()); } } @@ -211,19 +211,19 @@ void tst_qqmllistreference::listElementType() { QQmlListReference ref; - QVERIFY(ref.listElementType() == 0); + QVERIFY(!ref.listElementType()); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.listElementType() == 0); + QVERIFY(!ref.listElementType()); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.listElementType() == &TestType::staticMetaObject); + QCOMPARE(ref.listElementType(), &TestType::staticMetaObject); delete tt; - QVERIFY(ref.listElementType() == 0); + QVERIFY(!ref.listElementType()); } } @@ -233,26 +233,26 @@ void tst_qqmllistreference::canAppend() { QQmlListReference ref; - QVERIFY(ref.canAppend() == false); + QVERIFY(!ref.canAppend()); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.canAppend() == false); + QVERIFY(!ref.canAppend()); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.canAppend() == true); + QVERIFY(ref.canAppend()); delete tt; - QVERIFY(ref.canAppend() == false); + QVERIFY(!ref.canAppend()); } { TestType tt; tt.property.append = 0; QQmlListReference ref(&tt, "data"); - QVERIFY(ref.canAppend() == false); + QVERIFY(!ref.canAppend()); } } @@ -262,26 +262,26 @@ void tst_qqmllistreference::canAt() { QQmlListReference ref; - QVERIFY(ref.canAt() == false); + QVERIFY(!ref.canAt()); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.canAt() == false); + QVERIFY(!ref.canAt()); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.canAt() == true); + QVERIFY(ref.canAt()); delete tt; - QVERIFY(ref.canAt() == false); + QVERIFY(!ref.canAt()); } { TestType tt; tt.property.at = 0; QQmlListReference ref(&tt, "data"); - QVERIFY(ref.canAt() == false); + QVERIFY(!ref.canAt()); } } @@ -291,26 +291,26 @@ void tst_qqmllistreference::canClear() { QQmlListReference ref; - QVERIFY(ref.canClear() == false); + QVERIFY(!ref.canClear()); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.canClear() == false); + QVERIFY(!ref.canClear()); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.canClear() == true); + QVERIFY(ref.canClear()); delete tt; - QVERIFY(ref.canClear() == false); + QVERIFY(!ref.canClear()); } { TestType tt; tt.property.clear = 0; QQmlListReference ref(&tt, "data"); - QVERIFY(ref.canClear() == false); + QVERIFY(!ref.canClear()); } } @@ -320,26 +320,26 @@ void tst_qqmllistreference::canCount() { QQmlListReference ref; - QVERIFY(ref.canCount() == false); + QVERIFY(!ref.canCount()); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.canCount() == false); + QVERIFY(!ref.canCount()); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.canCount() == true); + QVERIFY(ref.canCount()); delete tt; - QVERIFY(ref.canCount() == false); + QVERIFY(!ref.canCount()); } { TestType tt; tt.property.count = 0; QQmlListReference ref(&tt, "data"); - QVERIFY(ref.canCount() == false); + QVERIFY(!ref.canCount()); } } @@ -349,26 +349,26 @@ void tst_qqmllistreference::isReadable() { QQmlListReference ref; - QVERIFY(ref.isReadable() == false); + QVERIFY(!ref.isReadable()); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.isReadable() == false); + QVERIFY(!ref.isReadable()); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.isReadable() == true); + QVERIFY(ref.isReadable()); delete tt; - QVERIFY(ref.isReadable() == false); + QVERIFY(!ref.isReadable()); } { TestType tt; tt.property.count = 0; QQmlListReference ref(&tt, "data"); - QVERIFY(ref.isReadable() == false); + QVERIFY(!ref.isReadable()); } } @@ -378,26 +378,26 @@ void tst_qqmllistreference::isManipulable() { QQmlListReference ref; - QVERIFY(ref.isManipulable() == false); + QVERIFY(!ref.isManipulable()); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.isManipulable() == false); + QVERIFY(!ref.isManipulable()); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.isManipulable() == true); + QVERIFY(ref.isManipulable()); delete tt; - QVERIFY(ref.isManipulable() == false); + QVERIFY(!ref.isManipulable()); } { TestType tt; tt.property.count = 0; QQmlListReference ref(&tt, "data"); - QVERIFY(ref.isManipulable() == false); + QVERIFY(!ref.isManipulable()); } } @@ -408,35 +408,35 @@ void tst_qqmllistreference::append() { QQmlListReference ref; - QVERIFY(ref.append(tt) == false); + QVERIFY(!ref.append(tt)); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.append(tt) == false); + QVERIFY(!ref.append(tt)); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.append(tt) == true); - QVERIFY(tt->data.count() == 1); - QVERIFY(tt->data.at(0) == tt); - QVERIFY(ref.append(&object) == false); - QVERIFY(tt->data.count() == 1); - QVERIFY(tt->data.at(0) == tt); - QVERIFY(ref.append(0) == true); - QVERIFY(tt->data.count() == 2); - QVERIFY(tt->data.at(0) == tt); - QVERIFY(tt->data.at(1) == 0); + QVERIFY(ref.append(tt)); + QCOMPARE(tt->data.count(), 1); + QCOMPARE(tt->data.at(0), tt); + QVERIFY(!ref.append(&object)); + QCOMPARE(tt->data.count(), 1); + QCOMPARE(tt->data.at(0), tt); + QVERIFY(ref.append(0)); + QCOMPARE(tt->data.count(), 2); + QCOMPARE(tt->data.at(0), tt); + QVERIFY(!tt->data.at(1)); delete tt; - QVERIFY(ref.append(0) == false); + QVERIFY(!ref.append(0)); } { TestType tt; tt.property.append = 0; QQmlListReference ref(&tt, "data"); - QVERIFY(ref.append(&tt) == false); + QVERIFY(!ref.append(&tt)); } } @@ -449,21 +449,21 @@ void tst_qqmllistreference::at() { QQmlListReference ref; - QVERIFY(ref.at(0) == 0); + QVERIFY(!ref.at(0)); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.at(0) == 0); + QVERIFY(!ref.at(0)); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.at(0) == tt); - QVERIFY(ref.at(1) == 0); - QVERIFY(ref.at(2) == tt); + QCOMPARE(ref.at(0), tt); + QVERIFY(!ref.at(1)); + QCOMPARE(ref.at(2), tt); delete tt; - QVERIFY(ref.at(0) == 0); + QVERIFY(!ref.at(0)); } { @@ -471,7 +471,7 @@ void tst_qqmllistreference::at() tt.data.append(&tt); tt.property.at = 0; QQmlListReference ref(&tt, "data"); - QVERIFY(ref.at(0) == 0); + QVERIFY(!ref.at(0)); } } @@ -484,27 +484,27 @@ void tst_qqmllistreference::clear() { QQmlListReference ref; - QVERIFY(ref.clear() == false); + QVERIFY(!ref.clear()); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.clear() == false); + QVERIFY(!ref.clear()); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.clear() == true); - QVERIFY(tt->data.count() == 0); + QVERIFY(ref.clear()); + QCOMPARE(tt->data.count(), 0); delete tt; - QVERIFY(ref.clear() == false); + QVERIFY(!ref.clear()); } { TestType tt; tt.property.clear = 0; QQmlListReference ref(&tt, "data"); - QVERIFY(ref.clear() == false); + QVERIFY(!ref.clear()); } } @@ -517,21 +517,21 @@ void tst_qqmllistreference::count() { QQmlListReference ref; - QVERIFY(ref.count() == 0); + QCOMPARE(ref.count(), 0); } { QQmlListReference ref(tt, "blah"); - QVERIFY(ref.count() == 0); + QCOMPARE(ref.count(), 0); } { QQmlListReference ref(tt, "data"); - QVERIFY(ref.count() == 3); + QCOMPARE(ref.count(), 3); tt->data.removeAt(1); - QVERIFY(ref.count() == 2); + QCOMPARE(ref.count(), 2); delete tt; - QVERIFY(ref.count() == 0); + QCOMPARE(ref.count(), 0); } { @@ -539,7 +539,7 @@ void tst_qqmllistreference::count() tt.data.append(&tt); tt.property.count = 0; QQmlListReference ref(&tt, "data"); - QVERIFY(ref.count() == 0); + QCOMPARE(ref.count(), 0); } } @@ -551,24 +551,24 @@ void tst_qqmllistreference::copy() tt.data.append(&tt); QQmlListReference *r1 = new QQmlListReference(&tt, "data"); - QVERIFY(r1->count() == 3); + QCOMPARE(r1->count(), 3); QQmlListReference r2(*r1); QQmlListReference r3; r3 = *r1; - QVERIFY(r2.count() == 3); - QVERIFY(r3.count() == 3); + QCOMPARE(r2.count(), 3); + QCOMPARE(r3.count(), 3); delete r1; - QVERIFY(r2.count() == 3); - QVERIFY(r3.count() == 3); + QCOMPARE(r2.count(), 3); + QCOMPARE(r3.count(), 3); tt.data.removeAt(2); - QVERIFY(r2.count() == 2); - QVERIFY(r3.count() == 2); + QCOMPARE(r2.count(), 2); + QCOMPARE(r3.count(), 2); } void tst_qqmllistreference::qmlmetaproperty() @@ -580,10 +580,10 @@ void tst_qqmllistreference::qmlmetaproperty() QQmlProperty prop(&tt, QLatin1String("data")); QVariant v = prop.read(); - QVERIFY(v.userType() == qMetaTypeId<QQmlListReference>()); + QCOMPARE(v.userType(), qMetaTypeId<QQmlListReference>()); QQmlListReference ref = qvariant_cast<QQmlListReference>(v); - QVERIFY(ref.count() == 3); - QVERIFY(ref.listElementType() == &TestType::staticMetaObject); + QCOMPARE(ref.count(), 3); + QCOMPARE(ref.listElementType(), &TestType::staticMetaObject); } void tst_qqmllistreference::engineTypes() @@ -595,14 +595,14 @@ void tst_qqmllistreference::engineTypes() QVERIFY(o); QQmlProperty p1(o, QLatin1String("myList")); - QVERIFY(p1.propertyTypeCategory() == QQmlProperty::List); + QCOMPARE(p1.propertyTypeCategory(), QQmlProperty::List); QQmlProperty p2(o, QLatin1String("myList"), engine.rootContext()); - QVERIFY(p2.propertyTypeCategory() == QQmlProperty::List); + QCOMPARE(p2.propertyTypeCategory(), QQmlProperty::List); QVariant v = p2.read(); - QVERIFY(v.userType() == qMetaTypeId<QQmlListReference>()); + QCOMPARE(v.userType(), qMetaTypeId<QQmlListReference>()); QQmlListReference ref = qvariant_cast<QQmlListReference>(v); - QVERIFY(ref.count() == 2); + QCOMPARE(ref.count(), 2); QVERIFY(ref.listElementType()); QVERIFY(ref.listElementType() != &QObject::staticMetaObject); @@ -617,7 +617,7 @@ void tst_qqmllistreference::variantToList() QObject *o = component.create(); QVERIFY(o); - QVERIFY(o->property("value").userType() == qMetaTypeId<QQmlListReference>()); + QCOMPARE(o->property("value").userType(), qMetaTypeId<QQmlListReference>()); QCOMPARE(o->property("test").toInt(), 1); delete o; diff --git a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp index 011db7b363..030af07a70 100644 --- a/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp +++ b/tests/auto/qml/qqmllocale/tst_qqmllocale.cpp @@ -451,7 +451,7 @@ void tst_qqmllocale::firstDayOfWeek() Q_ARG(QVariant, QVariant(locale))); QVariant val = obj->property("firstDayOfWeek"); - QVERIFY(val.type() == QVariant::Int); + QCOMPARE(val.type(), QVariant::Int); int day = int(QLocale(locale).firstDayOfWeek()); if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday) @@ -486,12 +486,12 @@ void tst_qqmllocale::weekDays() Q_ARG(QVariant, QVariant(locale))); QVariant val = obj->property("weekDays"); - QVERIFY(val.userType() == qMetaTypeId<QJSValue>()); + QCOMPARE(val.userType(), qMetaTypeId<QJSValue>()); QList<QVariant> qmlDays = val.toList(); QList<Qt::DayOfWeek> days = QLocale(locale).weekdays(); - QVERIFY(days.count() == qmlDays.count()); + QCOMPARE(days.count(), qmlDays.count()); for (int i = 0; i < days.count(); ++i) { int day = int(days.at(i)); @@ -528,12 +528,12 @@ void tst_qqmllocale::uiLanguages() Q_ARG(QVariant, QVariant(locale))); QVariant val = obj->property("uiLanguages"); - QVERIFY(val.userType() == qMetaTypeId<QJSValue>()); + QCOMPARE(val.userType(), qMetaTypeId<QJSValue>()); QList<QVariant> qmlLangs = val.toList(); QStringList langs = QLocale(locale).uiLanguages(); - QVERIFY(langs.count() == qmlLangs.count()); + QCOMPARE(langs.count(), qmlLangs.count()); for (int i = 0; i < langs.count(); ++i) { QCOMPARE(langs.at(i), qmlLangs.at(i).toString()); @@ -676,7 +676,7 @@ void tst_qqmllocale::addDateTimeFormatData(const QString &l) int i = 0; while (formats[i]) { QByteArray t(locale); - t += " "; + t += ' '; t += formats[i]; QTest::newRow(t.constData()) << l << QString(formats[i]); ++i; @@ -768,7 +768,7 @@ void tst_qqmllocale::addDateFormatData(const QString &l) int i = 0; while (formats[i]) { QByteArray t(locale); - t += " "; + t += ' '; t += formats[i]; QTest::newRow(t.constData()) << l << QString(formats[i]); ++i; @@ -860,7 +860,7 @@ void tst_qqmllocale::addTimeFormatData(const QString &l) int i = 0; while (formats[i]) { QByteArray t(locale); - t += " "; + t += ' '; t += formats[i]; QTest::newRow(t.constData()) << l << QString(formats[i]); ++i; diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index f5423582b2..27e92f67a3 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -126,7 +126,7 @@ void tst_qqmlmetatype::initTestCase() void tst_qqmlmetatype::qmlParserStatusCast() { - QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0); + QVERIFY(!QQmlMetaType::qmlType(QVariant::Int)); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->parserStatusCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ValueSourceTestType *>()) != 0); @@ -146,7 +146,7 @@ void tst_qqmlmetatype::qmlParserStatusCast() void tst_qqmlmetatype::qmlPropertyValueSourceCast() { - QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0); + QVERIFY(!QQmlMetaType::qmlType(QVariant::Int)); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueSourceCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0); @@ -166,7 +166,7 @@ void tst_qqmlmetatype::qmlPropertyValueSourceCast() void tst_qqmlmetatype::qmlPropertyValueInterceptorCast() { - QVERIFY(QQmlMetaType::qmlType(QVariant::Int) == 0); + QVERIFY(!QQmlMetaType::qmlType(QVariant::Int)); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<TestType *>()) != 0); QCOMPARE(QQmlMetaType::qmlType(qMetaTypeId<TestType *>())->propertyValueInterceptorCast(), -1); QVERIFY(QQmlMetaType::qmlType(qMetaTypeId<ParserStatusTestType *>()) != 0); @@ -224,8 +224,8 @@ void tst_qqmlmetatype::isList() void tst_qqmlmetatype::defaultObject() { - QVERIFY(QQmlMetaType::defaultProperty(&QObject::staticMetaObject).name() == 0); - QVERIFY(QQmlMetaType::defaultProperty(&ParserStatusTestType::staticMetaObject).name() == 0); + QVERIFY(!QQmlMetaType::defaultProperty(&QObject::staticMetaObject).name()); + QVERIFY(!QQmlMetaType::defaultProperty(&ParserStatusTestType::staticMetaObject).name()); QCOMPARE(QString(QQmlMetaType::defaultProperty(&TestType::staticMetaObject).name()), QString("foo")); QObject o; @@ -233,8 +233,8 @@ void tst_qqmlmetatype::defaultObject() ParserStatusTestType p; QVERIFY(QQmlMetaType::defaultProperty((QObject *)0).name() == 0); - QVERIFY(QQmlMetaType::defaultProperty(&o).name() == 0); - QVERIFY(QQmlMetaType::defaultProperty(&p).name() == 0); + QVERIFY(!QQmlMetaType::defaultProperty(&o).name()); + QVERIFY(!QQmlMetaType::defaultProperty(&p).name()); QCOMPARE(QString(QQmlMetaType::defaultProperty(&t).name()), QString("foo")); } @@ -270,8 +270,8 @@ void tst_qqmlmetatype::compositeType() QQmlType *type = QQmlMetaType::qmlType(QString("ImplicitType"), QString(""), 1, 0); QVERIFY(type); - QVERIFY(type->module() == QLatin1String("")); - QVERIFY(type->elementName() == QLatin1String("ImplicitType")); + QVERIFY(type->module().isEmpty()); + QCOMPARE(type->elementName(), QLatin1String("ImplicitType")); QCOMPARE(type->qmlTypeName(), QLatin1String("ImplicitType")); QCOMPARE(type->sourceUrl(), testFileUrl("ImplicitType.qml")); } diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp index 0e326abad9..89477609ca 100644 --- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp @@ -110,8 +110,8 @@ void tst_qqmlmoduleplugin::initTestCase() QList<QByteArray> actual; \ for (int ii = 0; ii < errors.count(); ++ii) { \ const QQmlError &error = errors.at(ii); \ - QByteArray errorStr = QByteArray::number(error.line()) + ":" + \ - QByteArray::number(error.column()) + ":" + \ + QByteArray errorStr = QByteArray::number(error.line()) + ':' + \ + QByteArray::number(error.column()) + ':' + \ error.description().toUtf8(); \ actual << errorStr; \ } \ @@ -202,8 +202,11 @@ void tst_qqmlmoduleplugin::incorrectPluginCase() caseSensitive = false; QString libname = "PluGin.dll"; #endif - if (!caseSensitive) - expectedError = QLatin1String("plugin cannot be loaded for module \"org.qtproject.WrongCase\": File name case mismatch for \"") + QDir(m_importsDirectory).filePath("org/qtproject/WrongCase/" + libname) + QLatin1String("\""); + if (!caseSensitive) { + expectedError = QLatin1String("plugin cannot be loaded for module \"org.qtproject.WrongCase\": File name case mismatch for \"") + + QDir(m_importsDirectory).filePath("org/qtproject/WrongCase/" + libname) + + QLatin1Char('"'); + } #endif QCOMPARE(errors.at(0).description(), expectedError); @@ -236,9 +239,7 @@ void tst_qqmlmoduleplugin::importPluginWithQmlFile() void tst_qqmlmoduleplugin::remoteImportWithQuotedUrl() { - TestHTTPServer server; - QVERIFY2(server.listen(), qPrintable(server.errorString())); - server.serveDirectory(m_dataImportsDirectory); + ThreadedTestHTTPServer server(m_dataImportsDirectory); QQmlEngine engine; QQmlComponent component(&engine); diff --git a/tests/auto/qml/qqmlobjectmodel/qqmlobjectmodel.pro b/tests/auto/qml/qqmlobjectmodel/qqmlobjectmodel.pro new file mode 100644 index 0000000000..f8232f8854 --- /dev/null +++ b/tests/auto/qml/qqmlobjectmodel/qqmlobjectmodel.pro @@ -0,0 +1,10 @@ +CONFIG += testcase +TARGET = tst_qqmlobjectmodel +osx:CONFIG -= app_bundle + +SOURCES += tst_qqmlobjectmodel.cpp + +CONFIG += parallel_test + +QT += qml testlib +QT += core-private qml-private diff --git a/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp b/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp new file mode 100644 index 0000000000..001739e38d --- /dev/null +++ b/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QtQml/private/qqmlobjectmodel_p.h> +#include <QtTest/qsignalspy.h> +#include <QtTest/qtest.h> + +class tst_QQmlObjectModel : public QObject +{ + Q_OBJECT + +private slots: + void changes(); +}; + +static bool compareItems(QQmlObjectModel *model, const QObjectList &items) +{ + for (int i = 0; i < items.count(); ++i) { + if (model->get(i) != items.at(i)) + return false; + } + return true; +} + +void tst_QQmlObjectModel::changes() +{ + QQmlObjectModel model; + + QSignalSpy countSpy(&model, SIGNAL(countChanged())); + QSignalSpy childrenSpy(&model, SIGNAL(childrenChanged())); + + int count = 0; + int countSignals = 0; + int childrenSignals = 0; + + QObjectList items; + QObject item0, item1, item2, item3; + + // append(item0) -> [item0] + model.append(&item0); items.append(&item0); + QCOMPARE(model.count(), ++count); + QVERIFY(compareItems(&model, items)); + QCOMPARE(countSpy.count(), ++countSignals); + QCOMPARE(childrenSpy.count(), ++childrenSignals); + + // insert(0, item1) -> [item1, item0] + model.insert(0, &item1); items.insert(0, &item1); + QCOMPARE(model.count(), ++count); + QVERIFY(compareItems(&model, items)); + QCOMPARE(countSpy.count(), ++countSignals); + QCOMPARE(childrenSpy.count(), ++childrenSignals); + + // append(item2) -> [item1, item0, item2] + model.append(&item2); items.append(&item2); + QCOMPARE(model.count(), ++count); + QVERIFY(compareItems(&model, items)); + QCOMPARE(countSpy.count(), ++countSignals); + QCOMPARE(childrenSpy.count(), ++childrenSignals); + + // insert(2, item3) -> [item1, item0, item3, item2] + model.insert(2, &item3); items.insert(2, &item3); + QCOMPARE(model.count(), ++count); + QVERIFY(compareItems(&model, items)); + QCOMPARE(countSpy.count(), ++countSignals); + QCOMPARE(childrenSpy.count(), ++childrenSignals); + + // move(0, 1) -> [item0, item1, item3, item2] + model.move(0, 1); items.move(0, 1); + QCOMPARE(model.count(), count); + QVERIFY(compareItems(&model, items)); + QCOMPARE(countSpy.count(), countSignals); + QCOMPARE(childrenSpy.count(), ++childrenSignals); + + // move(3, 2) -> [item0, item1, item2, item3] + model.move(3, 2); items.move(3, 2); + QCOMPARE(model.count(), count); + QVERIFY(compareItems(&model, items)); + QCOMPARE(countSpy.count(), countSignals); + QCOMPARE(childrenSpy.count(), ++childrenSignals); + + // remove(0) -> [item1, item2, item3] + model.remove(0); items.removeAt(0); + QCOMPARE(model.count(), --count); + QVERIFY(compareItems(&model, items)); + QCOMPARE(countSpy.count(), ++countSignals); + QCOMPARE(childrenSpy.count(), ++childrenSignals); + + // remove(2) -> [item1, item2] + model.remove(2); items.removeAt(2); + QCOMPARE(model.count(), --count); + QVERIFY(compareItems(&model, items)); + QCOMPARE(countSpy.count(), ++countSignals); + QCOMPARE(childrenSpy.count(), ++childrenSignals); + + // clear() -> [] + model.clear(); items.clear(); + QCOMPARE(model.count(), 0); + QVERIFY(compareItems(&model, items)); + QCOMPARE(countSpy.count(), ++countSignals); + QCOMPARE(childrenSpy.count(), ++childrenSignals); +} + +QTEST_MAIN(tst_QQmlObjectModel) + +#include "tst_qqmlobjectmodel.moc" diff --git a/tests/auto/qml/qqmlopenmetaobject/qqmlopenmetaobject.pro b/tests/auto/qml/qqmlopenmetaobject/qqmlopenmetaobject.pro new file mode 100644 index 0000000000..c81394e77e --- /dev/null +++ b/tests/auto/qml/qqmlopenmetaobject/qqmlopenmetaobject.pro @@ -0,0 +1,9 @@ +CONFIG += testcase +TARGET = tst_qqmlopenmetaobject +osx:CONFIG -= app_bundle + +SOURCES += tst_qqmlopenmetaobject.cpp + +CONFIG += parallel_test +QT += core-private gui-private qml-private testlib +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/qml/qqmlopenmetaobject/tst_qqmlopenmetaobject.cpp b/tests/auto/qml/qqmlopenmetaobject/tst_qqmlopenmetaobject.cpp new file mode 100644 index 0000000000..429f45b875 --- /dev/null +++ b/tests/auto/qml/qqmlopenmetaobject/tst_qqmlopenmetaobject.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qtest.h> +#include <private/qqmlopenmetaobject_p.h> +#include <QtQml/qqmlengine.h> + +class tst_qqmlopenmetaobject : public QObject +{ + Q_OBJECT +public: + tst_qqmlopenmetaobject() {} + +private slots: + void createProperties(); +}; + +class CustomObject: public QObject +{ + Q_OBJECT +public: + CustomObject(QObject *parent = 0) + : QObject(parent) {} +}; + +void tst_qqmlopenmetaobject::createProperties() +{ + QQmlEngine engine; + CustomObject object; + const QQmlRefPointer<QQmlOpenMetaObjectType> mot = new QQmlOpenMetaObjectType(object.metaObject(), &engine); + QQmlOpenMetaObject *const mo = new QQmlOpenMetaObject(&object, mot); + mo->setCached(true); + mot->createProperty("customProperty"); + QVERIFY(true); +} + +QTEST_MAIN(tst_qqmlopenmetaobject) + +#include "tst_qqmlopenmetaobject.moc" diff --git a/tests/auto/qml/qqmlproperty/data/floatToStringPrecision.qml b/tests/auto/qml/qqmlproperty/data/floatToStringPrecision.qml new file mode 100644 index 0000000000..a0429e0cc8 --- /dev/null +++ b/tests/auto/qml/qqmlproperty/data/floatToStringPrecision.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +QtObject { + property double a: 3.4 + property string b: a + + property double c: 0.035003945 + property string d: c +} + diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index a8b06ffa71..6ada14ce79 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -147,6 +147,7 @@ private slots: void registeredCompositeTypeProperty(); void deeplyNestedObject(); void readOnlyDynamicProperties(); + void floatToStringPrecision(); void copy(); private: @@ -159,10 +160,10 @@ void tst_qqmlproperty::qmlmetaproperty() QObject *obj = new QObject; - QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); - QVERIFY(binding != 0); + QQmlAbstractBinding::Ptr binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(obj, QObjectPrivate::get(obj)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); - QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QCOMPARE(prop.name(), QString()); @@ -188,12 +189,12 @@ void tst_qqmlproperty::qmlmetaproperty() QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); - QVERIFY(prop.property().name() == 0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); - QVERIFY(binding == 0); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr) == 0); + QVERIFY(!prop.property().name()); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); + QQmlPropertyPrivate::setBinding(prop, binding.data()); + QVERIFY(binding->ref == 1); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); + QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -255,7 +256,7 @@ void tst_qqmlproperty::registeredCompositeTypeProperty() QQmlProperty p1e(obj, "first", &engine); QQmlProperty p2e(obj, "second", &engine); QQmlProperty p3e(obj, "third", &engine); - QVERIFY(p1.propertyType() == p2.propertyType()); + QCOMPARE(p1.propertyType(), p2.propertyType()); QVERIFY(p1.propertyType() != p3.propertyType()); // check that the values are retrievable from CPP @@ -293,7 +294,7 @@ void tst_qqmlproperty::registeredCompositeTypeProperty() QQmlProperty lp2e(obj, "sclistOne", &engine); QQmlProperty lp3e(obj, "sclistTwo", &engine); QVERIFY(lp1e.propertyType() != lp2e.propertyType()); - QVERIFY(lp2e.propertyType() == lp3e.propertyType()); + QCOMPARE(lp2e.propertyType(), lp3e.propertyType()); // check that the list values are retrievable from CPP QVariant firstList = obj->property("fclist"); @@ -408,10 +409,10 @@ void tst_qqmlproperty::qmlmetaproperty_object() { QQmlProperty prop(&object); - QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); - QVERIFY(binding != 0); + QQmlAbstractBinding::Ptr binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); - QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -439,12 +440,12 @@ void tst_qqmlproperty::qmlmetaproperty_object() QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); - QVERIFY(prop.property().name() == 0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); - QVERIFY(binding == 0); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr) == 0); + QVERIFY(!prop.property().name()); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); + QQmlPropertyPrivate::setBinding(prop, binding.data()); + QVERIFY(binding->ref == 1); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); + QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -455,11 +456,11 @@ void tst_qqmlproperty::qmlmetaproperty_object() { QQmlProperty prop(&dobject); - QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + QQmlAbstractBinding::Ptr binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); - QVERIFY(binding != 0); + QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); - QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -488,13 +489,13 @@ void tst_qqmlproperty::qmlmetaproperty_object() QCOMPARE(prop.propertyType(), (int)QVariant::Int); QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int"); - QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); - QVERIFY(binding != 0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr) == 0); + QQmlPropertyPrivate::setBinding(prop, binding.data()); + QVERIFY(binding); + QCOMPARE(QQmlPropertyPrivate::binding(prop), binding.data()); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); + QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -511,10 +512,10 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&object, QString("defaultProperty")); - QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); - QVERIFY(binding != 0); + QQmlAbstractBinding::Ptr binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); - QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -542,12 +543,12 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); - QVERIFY(prop.property().name() == 0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); - QVERIFY(binding == 0); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr) == 0); + QVERIFY(!prop.property().name()); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); + QQmlPropertyPrivate::setBinding(prop, binding.data()); + QVERIFY(binding->ref == 1); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); + QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -558,11 +559,11 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("defaultProperty")); - QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + QQmlAbstractBinding::Ptr binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); - QVERIFY(binding != 0); + QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); - QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -591,13 +592,13 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QCOMPARE(prop.propertyType(), (int)QVariant::Int); QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int"); - QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); - QVERIFY(binding != 0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr) == 0); + QQmlPropertyPrivate::setBinding(prop, binding.data()); + QVERIFY(binding); + QCOMPARE(QQmlPropertyPrivate::binding(prop), binding.data()); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); + QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -608,11 +609,11 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("onClicked")); - QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + QQmlAbstractBinding::Ptr binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); - QVERIFY(binding != 0); + QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); - QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -641,13 +642,13 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); - QVERIFY(binding == 0); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); + QQmlPropertyPrivate::setBinding(prop, binding.data()); + QVERIFY(binding->ref == 1); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); + QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(!sigExprWatcher.wasDeleted()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == sigExpr); + QCOMPARE(QQmlPropertyPrivate::signalExpression(prop), sigExpr); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -657,11 +658,11 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() { QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged")); - QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + QQmlAbstractBinding::Ptr binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); - QVERIFY(binding != 0); + QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); - QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -690,13 +691,13 @@ void tst_qqmlproperty::qmlmetaproperty_object_string() QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); - QVERIFY(binding == 0); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); + QQmlPropertyPrivate::setBinding(prop, binding.data()); + QVERIFY(binding->ref == 1); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); + QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(!sigExprWatcher.wasDeleted()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == sigExpr); + QCOMPARE(QQmlPropertyPrivate::signalExpression(prop), sigExpr); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -712,10 +713,10 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() { QQmlProperty prop(&object, engine.rootContext()); - QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); - QVERIFY(binding != 0); + QQmlAbstractBinding::Ptr binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); - QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -743,12 +744,12 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); - QVERIFY(prop.property().name() == 0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); - QVERIFY(binding == 0); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr) == 0); + QVERIFY(!prop.property().name()); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); + QQmlPropertyPrivate::setBinding(prop, binding.data()); + QVERIFY(binding->ref == 1); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); + QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -759,11 +760,11 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() { QQmlProperty prop(&dobject, engine.rootContext()); - QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + QQmlAbstractBinding::Ptr binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); - QVERIFY(binding != 0); + QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); - QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -792,13 +793,13 @@ void tst_qqmlproperty::qmlmetaproperty_object_context() QCOMPARE(prop.propertyType(), (int)QVariant::Int); QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int"); - QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); - QVERIFY(binding != 0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr) == 0); + QQmlPropertyPrivate::setBinding(prop, binding.data()); + QVERIFY(binding); + QCOMPARE(QQmlPropertyPrivate::binding(prop), binding.data()); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); + QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -815,10 +816,10 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&object, QString("defaultProperty"), engine.rootContext()); - QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); - QVERIFY(binding != 0); + QQmlAbstractBinding::Ptr binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); + QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&object, QObjectPrivate::get(&object)->signalIndex("destroyed()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); - QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -846,12 +847,12 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.propertyTypeCategory(), QQmlProperty::InvalidCategory); QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); - QVERIFY(prop.property().name() == 0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); - QVERIFY(binding == 0); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr) == 0); + QVERIFY(!prop.property().name()); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); + QQmlPropertyPrivate::setBinding(prop, binding.data()); + QVERIFY(binding->ref == 1); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); + QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), -1); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -862,11 +863,11 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("defaultProperty"), engine.rootContext()); - QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + QQmlAbstractBinding::Ptr binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); - QVERIFY(binding != 0); + QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QObjectPrivate::get(&dobject)->signalIndex("clicked()"), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); - QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -895,13 +896,13 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.propertyType(), (int)QVariant::Int); QCOMPARE(prop.propertyTypeName(), "int"); QCOMPARE(QString(prop.property().name()), QString("defaultProperty")); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Unable to assign null to int"); - QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); - QVERIFY(binding != 0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == binding.data()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr) == 0); + QQmlPropertyPrivate::setBinding(prop, binding.data()); + QVERIFY(binding); + QCOMPARE(QQmlPropertyPrivate::binding(prop), binding.data()); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); + QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(sigExprWatcher.wasDeleted()); QCOMPARE(prop.index(), dobject.metaObject()->indexOfProperty("defaultProperty")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -912,11 +913,11 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("onClicked"), engine.rootContext()); - QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + QQmlAbstractBinding::Ptr binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); - QVERIFY(binding != 0); + QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); - QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -945,13 +946,13 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); - QVERIFY(binding == 0); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); + QQmlPropertyPrivate::setBinding(prop, binding.data()); + QVERIFY(binding->ref == 1); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); + QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(!sigExprWatcher.wasDeleted()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == sigExpr); + QCOMPARE(QQmlPropertyPrivate::signalExpression(prop), sigExpr); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("clicked()")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -961,11 +962,11 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() { QQmlProperty prop(&dobject, QString("onPropertyWithNotifyChanged"), engine.rootContext()); - QWeakPointer<QQmlAbstractBinding> binding(QQmlAbstractBinding::getPointer(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext()))); + QQmlAbstractBinding::Ptr binding(new QQmlBinding(QLatin1String("null"), 0, engine.rootContext())); static_cast<QQmlBinding *>(binding.data())->setTarget(prop); - QVERIFY(binding != 0); + QVERIFY(binding); QQmlBoundSignalExpression *sigExpr = new QQmlBoundSignalExpression(&dobject, QQmlPropertyPrivate::get(prop)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1); - QQmlAbstractExpression::DeleteWatcher sigExprWatcher(sigExpr); + QQmlJavaScriptExpression::DeleteWatcher sigExprWatcher(sigExpr); QVERIFY(sigExpr != 0 && !sigExprWatcher.wasDeleted()); QObject *obj = new QObject; @@ -994,13 +995,13 @@ void tst_qqmlproperty::qmlmetaproperty_object_string_context() QCOMPARE(prop.propertyType(), 0); QCOMPARE(prop.propertyTypeName(), (const char *)0); QCOMPARE(prop.property().name(), (const char *)0); - QVERIFY(QQmlPropertyPrivate::binding(prop) == 0); - QVERIFY(QQmlPropertyPrivate::setBinding(prop, binding.data()) == 0); - QVERIFY(binding == 0); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == 0); - QVERIFY(QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr) == 0); + QVERIFY(!QQmlPropertyPrivate::binding(prop)); + QQmlPropertyPrivate::setBinding(prop, binding.data()); + QVERIFY(binding->ref == 1); + QVERIFY(!QQmlPropertyPrivate::signalExpression(prop)); + QQmlPropertyPrivate::takeSignalExpression(prop, sigExpr); QVERIFY(!sigExprWatcher.wasDeleted()); - QVERIFY(QQmlPropertyPrivate::signalExpression(prop) == sigExpr); + QCOMPARE(QQmlPropertyPrivate::signalExpression(prop), sigExpr); QCOMPARE(prop.index(), dobject.metaObject()->indexOfMethod("oddlyNamedNotifySignal()")); QCOMPARE(QQmlPropertyPrivate::valueTypeCoreIndex(prop), -1); @@ -1146,7 +1147,7 @@ void tst_qqmlproperty::read() QQmlProperty p(&o, "onClicked"); QCOMPARE(p.read(), QVariant()); - QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1))); + QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1)); QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); QCOMPARE(p.read(), QVariant()); @@ -1158,7 +1159,7 @@ void tst_qqmlproperty::read() QQmlProperty p(&o, "onPropertyWithNotifyChanged"); QCOMPARE(p.read(), QVariant()); - QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1))); + QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1)); QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); QCOMPARE(p.read(), QVariant()); @@ -1203,7 +1204,7 @@ void tst_qqmlproperty::read() QCOMPARE(p.propertyTypeCategory(), QQmlProperty::Object); QCOMPARE(p.propertyType(), qMetaTypeId<MyQmlObject*>()); QVariant v = p.read(); - QVERIFY(v.userType() == QMetaType::QObjectStar); + QCOMPARE(v.userType(), int(QMetaType::QObjectStar)); QVERIFY(qvariant_cast<QObject *>(v) == o.qmlObject()); } { @@ -1217,7 +1218,7 @@ void tst_qqmlproperty::read() QVERIFY(p.propertyType() != QMetaType::QObjectStar); QVariant v = p.read(); - QVERIFY(v.userType() == QMetaType::QObjectStar); + QCOMPARE(v.userType(), int(QMetaType::QObjectStar)); QCOMPARE(qvariant_cast<QObject *>(v)->property("a").toInt(), 10); QCOMPARE(qvariant_cast<QObject *>(v)->property("b").toInt(), 19); } @@ -1227,7 +1228,7 @@ void tst_qqmlproperty::read() QVERIFY(object != 0); QVariant v = QQmlProperty::read(object, "test", &engine); - QVERIFY(v.userType() == QMetaType::QObjectStar); + QCOMPARE(v.userType(), int(QMetaType::QObjectStar)); QCOMPARE(qvariant_cast<QObject *>(v)->property("a").toInt(), 10); QCOMPARE(qvariant_cast<QObject *>(v)->property("b").toInt(), 19); } @@ -1337,7 +1338,7 @@ void tst_qqmlproperty::write() QQmlProperty p(&o, "onClicked"); QCOMPARE(p.write(QVariant("console.log(1921)")), false); - QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1))); + QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1)); QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); QCOMPARE(p.write(QVariant("console.log(1921)")), false); @@ -1351,7 +1352,7 @@ void tst_qqmlproperty::write() QQmlProperty p(&o, "onPropertyWithNotifyChanged"); QCOMPARE(p.write(QVariant("console.log(1921)")), false); - QVERIFY(0 == QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1))); + QQmlPropertyPrivate::takeSignalExpression(p, new QQmlBoundSignalExpression(&o, QQmlPropertyPrivate::get(p)->signalIndex(), QQmlContextData::get(engine.rootContext()), 0, QLatin1String("null"), QString(), -1, -1)); QVERIFY(0 != QQmlPropertyPrivate::signalExpression(p)); QCOMPARE(p.write(QVariant("console.log(1921)")), false); @@ -1643,7 +1644,7 @@ void tst_qqmlproperty::writeObjectToList() MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create()); QVERIFY(container != 0); QQmlListReference list(container, "children"); - QVERIFY(list.count() == 1); + QCOMPARE(list.count(), 1); MyQmlObject *object = new MyQmlObject; QQmlProperty prop(container, "children"); @@ -1659,7 +1660,7 @@ void tst_qqmlproperty::writeListToList() MyContainer *container = qobject_cast<MyContainer*>(containerComponent.create()); QVERIFY(container != 0); QQmlListReference list(container, "children"); - QVERIFY(list.count() == 1); + QCOMPARE(list.count(), 1); QList<QObject*> objList; objList << new MyQmlObject() << new MyQmlObject() << new MyQmlObject() << new MyQmlObject(); @@ -2054,6 +2055,27 @@ void tst_qqmlproperty::readOnlyDynamicProperties() delete obj; } +void tst_qqmlproperty::floatToStringPrecision() +{ + QQmlComponent comp(&engine, testFileUrl("floatToStringPrecision.qml")); + QObject *obj = comp.create(); + QVERIFY(obj != 0); + + QCOMPARE(obj->property("a").toDouble(), 3.4); + QEXPECT_FAIL("", "QVariant's double-to-string conversion is worse than V4's.", Continue); + QCOMPARE(obj->property("a").toString(), QLatin1String("3.4")); + QCOMPARE(obj->property("b").toDouble(), 3.4); + QCOMPARE(obj->property("b").toString(), QLatin1String("3.4")); + + QCOMPARE(obj->property("c").toDouble(), 0.035003945); + QEXPECT_FAIL("", "QVariant's double-to-string conversion is worse than V4's.", Continue); + QCOMPARE(obj->property("c").toString(), QLatin1String("0.035003945")); + QCOMPARE(obj->property("d").toDouble(), 0.035003945); + QCOMPARE(obj->property("d").toString(), QLatin1String("0.035003945")); + + delete obj; +} + void tst_qqmlproperty::initTestCase() { QQmlDataTest::initTestCase(); diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp index ce2aab49c3..a5ae27d446 100644 --- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp +++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp @@ -34,6 +34,7 @@ #include <qtest.h> #include <private/qqmlpropertycache_p.h> #include <QtQml/qqmlengine.h> +#include <private/qv8engine_p.h> #include "../../shared/util.h" class tst_qqmlpropertycache : public QObject @@ -102,10 +103,11 @@ QQmlPropertyData *cacheProperty(QQmlPropertyCache *cache, const char *name) void tst_qqmlpropertycache::properties() { QQmlEngine engine; + QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine); DerivedObject object; const QMetaObject *metaObject = object.metaObject(); - QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject)); + QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(v4, metaObject)); QQmlPropertyData *data; QVERIFY(data = cacheProperty(cache, "propertyA")); @@ -124,10 +126,11 @@ void tst_qqmlpropertycache::properties() void tst_qqmlpropertycache::propertiesDerived() { QQmlEngine engine; + QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine); DerivedObject object; const QMetaObject *metaObject = object.metaObject(); - QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject)); + QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(v4, &BaseObject::staticMetaObject)); QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(object.metaObject())); QQmlPropertyData *data; @@ -147,10 +150,11 @@ void tst_qqmlpropertycache::propertiesDerived() void tst_qqmlpropertycache::methods() { QQmlEngine engine; + QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine); DerivedObject object; const QMetaObject *metaObject = object.metaObject(); - QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject)); + QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(v4, metaObject)); QQmlPropertyData *data; QVERIFY(data = cacheProperty(cache, "slotA")); @@ -181,10 +185,11 @@ void tst_qqmlpropertycache::methods() void tst_qqmlpropertycache::methodsDerived() { QQmlEngine engine; + QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine); DerivedObject object; const QMetaObject *metaObject = object.metaObject(); - QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject)); + QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(v4, &BaseObject::staticMetaObject)); QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(object.metaObject())); QQmlPropertyData *data; @@ -216,10 +221,11 @@ void tst_qqmlpropertycache::methodsDerived() void tst_qqmlpropertycache::signalHandlers() { QQmlEngine engine; + QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine); DerivedObject object; const QMetaObject *metaObject = object.metaObject(); - QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject)); + QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(v4, metaObject)); QQmlPropertyData *data; QVERIFY(data = cacheProperty(cache, "onSignalA")); @@ -244,10 +250,11 @@ void tst_qqmlpropertycache::signalHandlers() void tst_qqmlpropertycache::signalHandlersDerived() { QQmlEngine engine; + QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine); DerivedObject object; const QMetaObject *metaObject = object.metaObject(); - QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject)); + QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(v4, &BaseObject::staticMetaObject)); QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(object.metaObject())); QQmlPropertyData *data; diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp index 4860602a45..2f3754e42d 100644 --- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp +++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp @@ -104,7 +104,7 @@ void tst_QQmlPropertyMap::insert() QQmlPropertyMap map; map.insert(QLatin1String("key1"),100); map.insert(QLatin1String("key2"),200); - QVERIFY(map.keys().count() == 2); + QCOMPARE(map.keys().count(), 2); QVERIFY(map.contains(QLatin1String("key1"))); QCOMPARE(map.value(QLatin1String("key1")), QVariant(100)); @@ -117,33 +117,33 @@ void tst_QQmlPropertyMap::insert() //QQmlPropertyMap has an invokable keys() method QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"keys\" is not permitted, conflicts with internal symbols."); map.insert(QLatin1String("keys"), 1); - QVERIFY(map.keys().count() == 2); + QCOMPARE(map.keys().count(), 2); QVERIFY(!map.contains(QLatin1String("keys"))); QVERIFY(map.value(QLatin1String("keys")).isNull()); //QQmlPropertyMap has a deleteLater() slot QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"deleteLater\" is not permitted, conflicts with internal symbols."); map.insert(QLatin1String("deleteLater"), 1); - QVERIFY(map.keys().count() == 2); + QCOMPARE(map.keys().count(), 2); QVERIFY(!map.contains(QLatin1String("deleteLater"))); QVERIFY(map.value(QLatin1String("deleteLater")).isNull()); //QQmlPropertyMap has an valueChanged() signal QTest::ignoreMessage(QtWarningMsg, "Creating property with name \"valueChanged\" is not permitted, conflicts with internal symbols."); map.insert(QLatin1String("valueChanged"), 1); - QVERIFY(map.keys().count() == 2); + QCOMPARE(map.keys().count(), 2); QVERIFY(!map.contains(QLatin1String("valueChanged"))); QVERIFY(map.value(QLatin1String("valueChanged")).isNull()); //but 'valueChange' should be ok map.insert(QLatin1String("valueChange"), 1); - QVERIFY(map.keys().count() == 3); + QCOMPARE(map.keys().count(), 3); QVERIFY(map.contains(QLatin1String("valueChange"))); QCOMPARE(map.value(QLatin1String("valueChange")), QVariant(1)); //'valueCHANGED' should be ok, too map.insert(QLatin1String("valueCHANGED"), 1); - QVERIFY(map.keys().count() == 4); + QCOMPARE(map.keys().count(), 4); QVERIFY(map.contains(QLatin1String("valueCHANGED"))); QCOMPARE(map.value(QLatin1String("valueCHANGED")), QVariant(1)); } @@ -153,7 +153,7 @@ void tst_QQmlPropertyMap::operatorInsert() QQmlPropertyMap map; map[QLatin1String("key1")] = 100; map[QLatin1String("key2")] = 200; - QVERIFY(map.keys().count() == 2); + QCOMPARE(map.keys().count(), 2); QCOMPARE(map.value(QLatin1String("key1")), QVariant(100)); QCOMPARE(map.value(QLatin1String("key2")), QVariant(200)); @@ -167,7 +167,7 @@ void tst_QQmlPropertyMap::operatorValue() QQmlPropertyMap map; map.insert(QLatin1String("key1"),100); map.insert(QLatin1String("key2"),200); - QVERIFY(map.count() == 2); + QCOMPARE(map.count(), 2); QVERIFY(map.contains(QLatin1String("key1"))); const QQmlPropertyMap &constMap = map; @@ -182,12 +182,12 @@ void tst_QQmlPropertyMap::clear() { QQmlPropertyMap map; map.insert(QLatin1String("key1"),100); - QVERIFY(map.keys().count() == 1); + QCOMPARE(map.keys().count(), 1); QCOMPARE(map.value(QLatin1String("key1")), QVariant(100)); map.clear(QLatin1String("key1")); - QVERIFY(map.keys().count() == 1); + QCOMPARE(map.keys().count(), 1); QVERIFY(map.contains(QLatin1String("key1"))); QCOMPARE(map.value(QLatin1String("key1")), QVariant()); } @@ -463,7 +463,7 @@ void tst_QQmlPropertyMap::QTBUG_35906() QScopedPointer<QObject> obj(component.create()); QVERIFY(!obj.isNull()); QVariant value = obj->property("testValue"); - QVERIFY(value.type() == QVariant::Int); + QCOMPARE(value.type(), QVariant::Int); QCOMPARE(value.toInt(), 42); } diff --git a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp index 671f7b5e73..b5bdc3a3b9 100644 --- a/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp +++ b/tests/auto/qml/qqmlqt/tst_qqmlqt.cpp @@ -651,7 +651,7 @@ void tst_qqmlqt::createQmlObject() QQuickItem *item = qobject_cast<QQuickItem *>(object); QVERIFY(item != 0); - QVERIFY(item->childItems().count() == 1); + QCOMPARE(item->childItems().count(), 1); delete object; } diff --git a/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp b/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp index 17083a4c6a..5a98a6bed8 100644 --- a/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp +++ b/tests/auto/qml/qqmltimer/tst_qqmltimer.cpp @@ -134,7 +134,7 @@ void tst_qqmltimer::notRepeating() QCOMPARE(helper.count, 1); consistentWait(200); QCOMPARE(helper.count, 1); - QVERIFY(timer->isRunning() == false); + QVERIFY(!timer->isRunning()); } void tst_qqmltimer::notRepeatingStart() @@ -157,7 +157,7 @@ void tst_qqmltimer::notRepeatingStart() QCOMPARE(helper.count, 1); consistentWait(200); QCOMPARE(helper.count, 1); - QVERIFY(timer->isRunning() == false); + QVERIFY(!timer->isRunning()); delete timer; } @@ -186,8 +186,8 @@ void tst_qqmltimer::repeat() timer->stop(); consistentWait(200); - QVERIFY(helper.count == oldCount); - QVERIFY(timer->isRunning() == false); + QCOMPARE(helper.count, oldCount); + QVERIFY(!timer->isRunning()); QSignalSpy spy(timer, SIGNAL(repeatChanged())); @@ -221,7 +221,7 @@ void tst_qqmltimer::triggeredOnStart() QCOMPARE(helper.count, 2); consistentWait(200); QCOMPARE(helper.count, 2); - QVERIFY(timer->isRunning() == false); + QVERIFY(!timer->isRunning()); QSignalSpy spy(timer, SIGNAL(triggeredOnStartChanged())); diff --git a/tests/auto/qml/qqmltypeloader/data/load_synchronous.qml b/tests/auto/qml/qqmltypeloader/data/load_synchronous.qml new file mode 100644 index 0000000000..5e9c4c2bdc --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/load_synchronous.qml @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQml 2.2 + +QtObject { + id: top + + Component.onCompleted: { + Qt.createQmlObject('QtObject {}', top, 'nonprotocol:'); + } +} diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index 77cdaae9f0..4c5b1f7e63 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -43,6 +43,7 @@ class tst_QQMLTypeLoader : public QQmlDataTest private slots: void testLoadComplete(); + void loadComponentSynchronously(); }; void tst_QQMLTypeLoader::testLoadComplete() @@ -62,6 +63,16 @@ void tst_QQMLTypeLoader::testLoadComplete() delete window; } +void tst_QQMLTypeLoader::loadComponentSynchronously() +{ + QQmlEngine engine; + QTest::ignoreMessage(QtWarningMsg, QRegularExpression( + QLatin1String(".*nonprotocol::1:1: QtObject is not a type.*"))); + QQmlComponent component(&engine, testFileUrl("load_synchronous.qml")); + QObject *o = component.create(); + QVERIFY(o); +} + QTEST_MAIN(tst_QQMLTypeLoader) #include "tst_qqmltypeloader.moc" diff --git a/tests/auto/qml/qqmlvaluetypeproviders/data/changedSignal.qml b/tests/auto/qml/qqmlvaluetypeproviders/data/changedSignal.qml new file mode 100644 index 0000000000..fed4cf4cbc --- /dev/null +++ b/tests/auto/qml/qqmlvaluetypeproviders/data/changedSignal.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2016 basysKom GmbH, opensource@basyskom.com. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + property bool success: false + property bool complete: false + + property vector2d v2: Qt.vector2d(-2, 0) + property vector3d v3: Qt.vector3d(-2, 0, 0) + property vector4d v4: Qt.vector4d(-2, 0, 0, 0) + + property int v2ChangedSignalCount; + property int v3ChangedSignalCount; + property int v4ChangedSignalCount; + + onV2Changed: v2ChangedSignalCount++ + onV3Changed: v3ChangedSignalCount++ + onV4Changed: v4ChangedSignalCount++ + + Component.onCompleted: { + complete = false; + success = true; + + // storing the initial value causes a signal emission + if (v2ChangedSignalCount !== 1) success = false + v2 = Qt.vector2d(-2, 0); + // setting the same value again must not emit a signal + if (v2ChangedSignalCount !== 1) success = false + v2.x++ + if (v2ChangedSignalCount !== 2) success = false + v2.x++ // cycle through 0, 0 which is the default value + if (v2ChangedSignalCount !== 3) success = false + v2.x++ + if (v2ChangedSignalCount !== 4) success = false + + // storing the initial value causes a signal emission + if (v3ChangedSignalCount !== 1) success = false + v3 = Qt.vector3d(-2, 0, 0); + // setting the same value again must not emit a signal + if (v3ChangedSignalCount !== 1) success = false + v3.x++ + if (v3ChangedSignalCount !== 2) success = false + v3.x++ // cycle through 0, 0, 0 which is the default value + if (v3ChangedSignalCount !== 3) success = false + v3.x++ + if (v3ChangedSignalCount !== 4) success = false + + // storing the initial value causes a signal emission + if (v4ChangedSignalCount !== 1) success = false + v4 = Qt.vector4d(-2, 0, 0, 0); + // setting the same value again must not emit a signal + if (v4ChangedSignalCount !== 1) success = false + v4.x++ + if (v4ChangedSignalCount !== 2) success = false + v4.x++ // cycle through 0, 0, 0 which is the default value + if (v4ChangedSignalCount !== 3) success = false + v4.x++ + if (v4ChangedSignalCount !== 4) success = false + + complete = true; + } +} diff --git a/tests/auto/qml/qqmlvaluetypeproviders/data/qtquickValueTypes.qml b/tests/auto/qml/qqmlvaluetypeproviders/data/qtquickValueTypes.qml index f723dc3e2e..d35ec84e23 100644 --- a/tests/auto/qml/qqmlvaluetypeproviders/data/qtquickValueTypes.qml +++ b/tests/auto/qml/qqmlvaluetypeproviders/data/qtquickValueTypes.qml @@ -112,7 +112,7 @@ QtObject { if (m != Qt.matrix4x4(4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7)) qtquickTypeSuccess = false; if (m.toString() != "QMatrix4x4(4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7)") qtquickTypeSuccess = false; c = "blue"; - if (c.toString() != Qt.rgba(0,0,1,0).toString()) qtquickTypeSuccess = false; + if (c.toString() != Qt.rgba(0,0,1,1).toString()) qtquickTypeSuccess = false; if (c.toString() != "#0000FF" && c.toString() != "#0000ff") qtquickTypeSuccess = false; // color string converter is special // no string converter for fonts. } diff --git a/tests/auto/qml/qqmlvaluetypeproviders/tst_qqmlvaluetypeproviders.cpp b/tests/auto/qml/qqmlvaluetypeproviders/tst_qqmlvaluetypeproviders.cpp index 58fca2d9d9..a38dff21fa 100644 --- a/tests/auto/qml/qqmlvaluetypeproviders/tst_qqmlvaluetypeproviders.cpp +++ b/tests/auto/qml/qqmlvaluetypeproviders/tst_qqmlvaluetypeproviders.cpp @@ -36,6 +36,7 @@ #include <QQmlComponent> #include <QQmlContext> #include <QDebug> +#include <QScopedPointer> #include <private/qqmlglobal_p.h> #include <private/qquickvaluetypes_p.h> #include "../../shared/util.h" @@ -66,6 +67,7 @@ private slots: void jsObjectConversion(); void invokableFunctions(); void userType(); + void changedSignal(); }; void tst_qqmlvaluetypeproviders::initTestCase() @@ -291,6 +293,18 @@ void tst_qqmlvaluetypeproviders::userType() QCOMPARE(obj->property("success").toBool(), true); } +void tst_qqmlvaluetypeproviders::changedSignal() +{ + QQmlEngine e; + QQmlComponent component(&e, testFileUrl("changedSignal.qml")); + QVERIFY(!component.isError()); + QVERIFY(component.errors().isEmpty()); + QScopedPointer<QObject> object(component.create()); + QVERIFY(object != 0); + QVERIFY(object->property("complete").toBool()); + QVERIFY(object->property("success").toBool()); +} + QTEST_MAIN(tst_qqmlvaluetypeproviders) #include "tst_qqmlvaluetypeproviders.moc" diff --git a/tests/auto/qml/qqmlvaluetypes/data/color_compare.qml b/tests/auto/qml/qqmlvaluetypes/data/color_compare.qml index 8701dae612..141404b067 100644 --- a/tests/auto/qml/qqmlvaluetypes/data/color_compare.qml +++ b/tests/auto/qml/qqmlvaluetypes/data/color_compare.qml @@ -15,12 +15,12 @@ MyTypeObject { // compare different color.toString()s property bool colorToStringEqualsColorString: (color.toString() == colorToString) // true - property bool colorToStringEqualsDifferentAlphaString: (color.toString() == Qt.rgba(0.2, 0.88, 0.6, 0.44).toString()) // true + property bool colorToStringEqualsDifferentAlphaString: (color.toString() == Qt.rgba(0.2, 0.88, 0.6, 0.34).toString()) // true property bool colorToStringEqualsDifferentRgbaString: (color.toString() == Qt.rgba(0.3, 0.98, 0.7, 0.44).toString()) // false // compare colors to strings property bool colorEqualsColorString: (color == colorToString) // false - property bool colorEqualsDifferentAlphaString: (color == Qt.rgba(0.2, 0.88, 0.6, 0.44).toString()) // false + property bool colorEqualsDifferentAlphaString: (color == Qt.rgba(0.2, 0.88, 0.6, 0.34).toString()) // false property bool colorEqualsDifferentRgbaString: (color == Qt.rgba(0.3, 0.98, 0.7, 0.44).toString()) // false // compare colors to various value types diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index f93190cab6..58755927b5 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -937,7 +937,7 @@ void tst_qqmlvaluetypes::color() QQmlComponent component(&engine, testFileUrl("color_compare.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QString colorString("#33e199"); + QString colorString("#5733e199"); QCOMPARE(object->property("colorToString").toString(), colorString); QCOMPARE(object->property("colorEqualsIdenticalRgba").toBool(), true); QCOMPARE(object->property("colorEqualsDifferentAlpha").toBool(), false); @@ -1221,7 +1221,7 @@ void tst_qqmlvaluetypes::enums() QQmlComponent component(&engine, testFileUrl("enums.1.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->font().capitalization() == QFont::AllUppercase); + QCOMPARE(object->font().capitalization(), QFont::AllUppercase); delete object; } @@ -1229,7 +1229,7 @@ void tst_qqmlvaluetypes::enums() QQmlComponent component(&engine, testFileUrl("enums.2.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->font().capitalization() == QFont::AllUppercase); + QCOMPARE(object->font().capitalization(), QFont::AllUppercase); delete object; } @@ -1237,7 +1237,7 @@ void tst_qqmlvaluetypes::enums() QQmlComponent component(&engine, testFileUrl("enums.3.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->font().capitalization() == QFont::AllUppercase); + QCOMPARE(object->font().capitalization(), QFont::AllUppercase); delete object; } @@ -1245,7 +1245,7 @@ void tst_qqmlvaluetypes::enums() QQmlComponent component(&engine, testFileUrl("enums.4.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->font().capitalization() == QFont::AllUppercase); + QCOMPARE(object->font().capitalization(), QFont::AllUppercase); delete object; } @@ -1253,7 +1253,7 @@ void tst_qqmlvaluetypes::enums() QQmlComponent component(&engine, testFileUrl("enums.5.qml")); MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QVERIFY(object->font().capitalization() == QFont::AllUppercase); + QCOMPARE(object->font().capitalization(), QFont::AllUppercase); delete object; } } diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.collection.allprop.expect b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.collection.allprop.expect new file mode 100644 index 0000000000..f0dc8ed3fd --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.collection.allprop.expect @@ -0,0 +1,14 @@ +PROPFIND /container/ HTTP/1.1 +Depth: 1 +Content-Length: 95 +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +Accept-Language: en-US,* +Content-type:i application/xml; charset="utf-8" +User-Agent: Mozilla/5.0 +Host: {{ServerHostUrl}} + +<?xml version="1.0" encoding="utf-8" ?> +<D:propfind xmlns:D="DAV:"> +<D:allprop/> +</D:propfind> diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.collection.allprop.reply.body b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.collection.allprop.reply.body new file mode 100644 index 0000000000..ef0c38956c --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.collection.allprop.reply.body @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +<D:multistatus xmlns:D="DAV:"> + <D:response> + <D:href>/container/</D:href> + <D:propstat> + <D:prop xmlns:R="http://ns.example.com/boxschema/"> + <R:bigbox><R:BoxType>Box type A</R:BoxType></R:bigbox> + <R:author><R:Name>Hadrian</R:Name></R:author> + <D:creationdate>1997-12-01T17:42:21-08:00</D:creationdate> + <D:displayname>Example collection</D:displayname> + <D:resourcetype><D:collection/></D:resourcetype> + <D:supportedlock> + <D:lockentry> + <D:lockscope><D:exclusive/></D:lockscope> + <D:locktype><D:write/></D:locktype> + </D:lockentry> + <D:lockentry> + <D:lockscope><D:shared/></D:lockscope> + <D:locktype><D:write/></D:locktype> + </D:lockentry> + </D:supportedlock> + </D:prop> + <D:status>HTTP/1.1 200 OK</D:status> + </D:propstat> + </D:response> +/D:multistatus> +--> +<D:multistatus xmlns:D="DAV:"><D:response><D:href>/container/</D:href><D:propstat><D:prop xmlns:R="http://ns.example.com/boxschema/"><R:bigbox><R:BoxType>Box type A</R:BoxType></R:bigbox><R:author><R:Name>Hadrian</R:Name></R:author><D:creationdate>1997-12-01T17:42:21-08:00</D:creationdate><D:displayname>Example collection</D:displayname><D:resourcetype><D:collection/></D:resourcetype><D:supportedlock><D:lockentry><D:lockscope><D:exclusive/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry><D:lockentry><D:lockscope><D:shared/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry></D:supportedlock></D:prop><D:status>HTTP/1.1 200 OK</D:status></D:propstat></D:response></D:multistatus> diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.file.expect b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.file.expect new file mode 100644 index 0000000000..2d14de634d --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.file.expect @@ -0,0 +1,18 @@ +PROPFIND /file HTTP/1.1 +Content-Length: 192 +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +Accept-Language: en-US,* +Content-type: text/xml; charset="utf-8" +User-Agent: Mozilla/5.0 +Host: {{ServerHostUrl}} + +<?xml version="1.0" encoding="utf-8" ?> +<D:propfind xmlns:D="DAV:"> +<D:prop xmlns:R="http://www.foo.bar/boxschema/"> +<R:bigbox/> +<R:author/> +<R:DingALing/> +<R:Random/> +</D:prop> +</D:propfind> diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.file.reply.body b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.file.reply.body new file mode 100644 index 0000000000..9e5028fe01 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.file.reply.body @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +<D:multistatus xmlns:D="DAV:"> + <D:response xmlns:R="http://ns.example.com/boxschema/"> + <D:href>http://www.example.com/file</D:href> + <D:propstat> + <D:prop> + <R:bigbox> + <R:BoxType>Box type A</R:BoxType> + </R:bigbox> + <R:author> + <R:Name>J.J. Johnson</R:Name> + </R:author> + </D:prop> + <D:status>HTTP/1.1 200 OK</D:status> + </D:propstat> + <D:propstat> + <D:prop> + <R:DingALing/> + <R:Random/> + </D:prop> + <D:status>HTTP/1.1 403 Forbidden</D:status> + <D:responsedescription>The user does not have access to the DingALing property.</D:responsedescription> + </D:propstat> + </D:response> + <D:responsedescription>There has been an access violation error.</D:responsedescription> +</D:multistatus> +--> +<D:multistatus xmlns:D="DAV:"><D:response xmlns:R="http://ns.example.com/boxschema/"><D:href>http://www.example.com/file</D:href><D:propstat><D:prop><R:bigbox><R:BoxType>Box type A</R:BoxType></R:bigbox><R:author><R:Name>J.J. Johnson</R:Name></R:author></D:prop><D:status>HTTP/1.1 200 OK</D:status></D:propstat><D:propstat><D:prop><R:DingALing/><R:Random/></D:prop><D:status>HTTP/1.1 403 Forbidden</D:status><D:responsedescription>The user does not have access to the DingALing property.</D:responsedescription></D:propstat></D:response><D:responsedescription>There has been an access violation error.</D:responsedescription></D:multistatus> diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.file.reply.header b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.file.reply.header new file mode 100644 index 0000000000..50fa080ad2 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/propfind.file.reply.header @@ -0,0 +1,2 @@ +HTTP/1.1 207 Multi-Status +Content-Type: text/xml; charset="utf-8" diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/sendPropfind.collection.allprop.qml b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/sendPropfind.collection.allprop.qml new file mode 100644 index 0000000000..2f47a5e62c --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/sendPropfind.collection.allprop.qml @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +QtObject { + property string url + property bool xmlTest: false + property bool typeTest: false + + function checkXML(document) + { + if (document.xmlVersion != "1.0") + return; + + if (document.xmlEncoding != "utf-8") + return; + + if (document.documentElement == null) + return; + + var multistatus = document.documentElement; + if (multistatus.nodeName != "multistatus") + return; + + if (multistatus.namespaceUri != "DAV:") + return; + + var multistatusChildTags = [ "response" ]; + for (var node = 0; node < multistatus.childNodes.length; ++node) { + if (multistatus.childNodes[node].nodeName != multistatusChildTags[node]) + return; + } + + var response = multistatus.childNodes[0]; + var responseChildTags = [ "href", "propstat" ]; + for (var node = 0; node < response.childNodes.length; ++node) { + var nodeName = response.childNodes[node].nodeName; + if (nodeName != responseChildTags[node]) + return; + + var nodeValue = response.childNodes[node].childNodes[0].nodeValue; + if ((nodeName == "href") && (nodeValue != "/container/")) + return; + } + + var propstat = response.childNodes[1]; + var propstatChildTags = ["prop", "status"]; + for (var node = 0; node < propstat.childNodes.length; ++node) { + var nodeName = propstat.childNodes[node].nodeName; + if (nodeName != propstatChildTags[node]) + return; + + var nodeValue = propstat.childNodes[node].childNodes[0].nodeValue; + if ((nodeName == "status") && (nodeValue != "HTTP/1.1 200 OK")) + return; + } + + var prop = propstat.childNodes[0]; + var propChildTags = [ "bigbox", "author", "creationdate", "displayname", "resourcetype", "supportedlock" ]; + for (var node = 0; node < prop.childNodes.length; ++node) { + var nodeName = prop.childNodes[node].nodeName; + if (nodeName != propChildTags[node]) + return; + + if (nodeName == "bigbox") { + if (prop.childNodes[node].childNodes.length != 1) + return; + + var boxType = prop.childNodes[node].childNodes[0]; + if (boxType.nodeName != "BoxType") + return; + if (boxType.childNodes[0].nodeValue != "Box type A") + return; + } + + if (nodeName == "author") { + if (prop.childNodes[node].childNodes.length != 1) + return; + + var boxType = prop.childNodes[node].childNodes[0]; + if (boxType.nodeName != "Name") + return; + if (boxType.childNodes[0].nodeValue != "Hadrian") + return; + } + + if (nodeName == "creationdate") { + if (prop.childNodes[node].childNodes.length != 1) + return; + + if (prop.childNodes[node].childNodes[0].nodeValue != "1997-12-01T17:42:21-08:00") + return; + } + + if (nodeName == "displayname") { + if (prop.childNodes[node].childNodes.length != 1) + return; + + if (prop.childNodes[node].childNodes[0].nodeValue != "Example collection") + return; + } + + if (nodeName == "resourcetpye") { + if (prop.childNodes[node].childNodes.length != 1) + return; + + if (prop.childNodes[node].childNodes[0].nodeValue != "collection") + return; + } + + if (nodeName == "supportedlock") { + if (prop.childNodes[node].childNodes.length != 2) + return; + + var lockEntry1 = prop.childNodes[node].childNodes[0]; + if (lockEntry1.nodeName != "lockentry") + return; + if (lockEntry1.childNodes.length != 2) + return; + if (lockEntry1.childNodes[0].nodeName != "lockscope") + return; + if (lockEntry1.childNodes[0].childNodes[0].nodeName != "exclusive") + return; + if (lockEntry1.childNodes[1].nodeName != "locktype") + return; + if (lockEntry1.childNodes[1].childNodes[0].nodeName != "write") + return; + + var lockEntry2 = prop.childNodes[node].childNodes[1]; + if (lockEntry2.nodeName != "lockentry") + return; + if (lockEntry2.childNodes.length != 2) + return; + if (lockEntry2.childNodes[0].nodeName != "lockscope") + return; + if (lockEntry2.childNodes[0].childNodes[0].nodeName != "shared") + return; + if (lockEntry2.childNodes[1].nodeName != "locktype") + return; + if (lockEntry2.childNodes[1].childNodes[0].nodeName != "write") + return; + } + } + + xmlTest = true; + } + + Component.onCompleted: { + + var request = new XMLHttpRequest(); + request.open("PROPFIND", url); + request.responseType = "document"; + request.setRequestHeader("Depth", "1"); + + request.onreadystatechange = function() { + if (request.readyState == XMLHttpRequest.DONE) { + checkXML(request.response); + typeTest = (request.responseType == "document"); + } + } + + var requestBody = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + + "<D:propfind xmlns:D=\"DAV:\">\n" + + "<D:allprop/>\n" + + "</D:propfind>\n" + request.send(requestBody); + } +} + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/sendPropfind.response.qml b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/sendPropfind.response.qml new file mode 100644 index 0000000000..01353e5e95 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/sendPropfind.response.qml @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +QtObject { + property string url + property bool xmlTest: false + property bool typeTest: false + + function checkXML(document) + { + if (document.xmlVersion != "1.0") + return; + + if (document.xmlEncoding != "utf-8") + return; + + if (document.documentElement == null) + return; + + var multistatus = document.documentElement; + if (multistatus.nodeName != "multistatus") + return; + + if (multistatus.namespaceUri != "DAV:") + return; + + var multistatusChildTags = [ "response", "responsedescription" ]; + for (var node = 0; node < multistatus.childNodes.length; ++node) { + if (multistatus.childNodes[node].nodeName != multistatusChildTags[node]) + return; + } + + var response = multistatus.childNodes[0]; + var responseChildTags = [ "href", "propstat", "propstat" ]; + for (var node = 0; node < response.childNodes.length; ++node) { + var nodeName = response.childNodes[node].nodeName; + if (nodeName != responseChildTags[node]) + return; + + var nodeValue = response.childNodes[node].childNodes[0].nodeValue; + if ((nodeName == "href") && (nodeValue != "http://www.example.com/file")) + return; + } + + if (multistatus.childNodes[1].childNodes[0].nodeValue != "There has been an access violation error.") + return; + + var propstat1 = response.childNodes[1]; + var propstat1ChildTags = ["prop", "status"]; + for (var node = 0; node < propstat1.childNodes.length; ++node) { + var nodeName = propstat1.childNodes[node].nodeName; + if (nodeName != propstat1ChildTags[node]) + return; + + var nodeValue = propstat1.childNodes[node].childNodes[0].nodeValue; + if ((nodeName == "status") && (nodeValue != "HTTP/1.1 200 OK")) + return; + } + + var prop1 = propstat1.childNodes[0]; + var prop1ChildTags = [ "bigbox", "author" ]; + for (var node = 0; node < prop1.childNodes.length; ++node) { + var nodeName = prop1.childNodes[node].nodeName; + if (nodeName != prop1ChildTags[node]) + return; + + if (nodeName == "bigbox") { + if (prop1.childNodes[node].childNodes.length != 1) + return; + + var boxType = prop1.childNodes[node].childNodes[0]; + if (boxType.nodeName != "BoxType") + return; + if (boxType.childNodes[0].nodeValue != "Box type A") + return; + } + } + + var propstat2 = response.childNodes[2]; + var propstat2ChildTags = ["prop", "status", "responsedescription" ]; + for (var node = 0; node < propstat2.childNodes.length; ++node) { + var nodeName = propstat2.childNodes[node].nodeName; + if (nodeName != propstat2ChildTags[node]) + return; + + var nodeValue = propstat2.childNodes[node].childNodes[0].nodeValue; + if ((nodeName == "status") && (nodeValue != "HTTP/1.1 403 Forbidden")) + return; + if ((nodeName == "responsedescription") && (nodeValue != "The user does not have access to the DingALing property.")) + return; + } + + var prop2 = propstat2.childNodes[0]; + var prop2ChildTags = [ "DingALing", "Random" ]; + for (var node = 0; node < prop2.childNodes.length; ++node) { + var nodeName = prop2.childNodes[node].nodeName; + if (nodeName != prop2ChildTags[node]) + return; + } + + xmlTest = true; + } + + Component.onCompleted: { + + var request = new XMLHttpRequest(); + request.open("PROPFIND", url); + request.responseType = "document"; + + request.onreadystatechange = function() { + if (request.readyState == XMLHttpRequest.DONE) { + checkXML(request.response); + typeTest = (request.responseType == "document"); + } + } + + var requestBody = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + + "<D:propfind xmlns:D=\"DAV:\">\n" + + "<D:prop xmlns:R=\"http://www.foo.bar/boxschema/\">\n" + + "<R:bigbox/>\n" + + "<R:author/>\n" + + "<R:DingALing/>\n" + + "<R:Random/>\n" + + "</D:prop>\n" + + "</D:propfind>\n" + request.send(requestBody); + } +} + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/sendPropfind.responseXML.qml b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/sendPropfind.responseXML.qml new file mode 100644 index 0000000000..3b4d1e2c1e --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/WebDAV/sendPropfind.responseXML.qml @@ -0,0 +1,160 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +QtObject { + property string url + property bool xmlTest: false + property bool typeTest: false + + function checkXML(document) + { + if (document.xmlVersion != "1.0") + return; + + if (document.xmlEncoding != "utf-8") + return; + + if (document.documentElement == null) + return; + + var multistatus = document.documentElement; + if (multistatus.nodeName != "multistatus") + return; + + if (multistatus.namespaceUri != "DAV:") + return; + + var multistatusChildTags = [ "response", "responsedescription" ]; + for (var node = 0; node < multistatus.childNodes.length; ++node) { + if (multistatus.childNodes[node].nodeName != multistatusChildTags[node]) + return; + } + + var response = multistatus.childNodes[0]; + var responseChildTags = [ "href", "propstat", "propstat" ]; + for (var node = 0; node < response.childNodes.length; ++node) { + var nodeName = response.childNodes[node].nodeName; + if (nodeName != responseChildTags[node]) + return; + + var nodeValue = response.childNodes[node].childNodes[0].nodeValue; + if ((nodeName == "href") && (nodeValue != "http://www.example.com/file")) + return; + } + + if (multistatus.childNodes[1].childNodes[0].nodeValue != "There has been an access violation error.") + return; + + var propstat1 = response.childNodes[1]; + var propstat1ChildTags = ["prop", "status"]; + for (var node = 0; node < propstat1.childNodes.length; ++node) { + var nodeName = propstat1.childNodes[node].nodeName; + if (nodeName != propstat1ChildTags[node]) + return; + + var nodeValue = propstat1.childNodes[node].childNodes[0].nodeValue; + if ((nodeName == "status") && (nodeValue != "HTTP/1.1 200 OK")) + return; + } + + var prop1 = propstat1.childNodes[0]; + var prop1ChildTags = [ "bigbox", "author" ]; + for (var node = 0; node < prop1.childNodes.length; ++node) { + var nodeName = prop1.childNodes[node].nodeName; + if (nodeName != prop1ChildTags[node]) + return; + + if (nodeName == "bigbox") { + if (prop1.childNodes[node].childNodes.length != 1) + return; + + var boxType = prop1.childNodes[node].childNodes[0]; + if (boxType.nodeName != "BoxType") + return; + if (boxType.childNodes[0].nodeValue != "Box type A") + return; + } + } + + var propstat2 = response.childNodes[2]; + var propstat2ChildTags = ["prop", "status", "responsedescription" ]; + for (var node = 0; node < propstat2.childNodes.length; ++node) { + var nodeName = propstat2.childNodes[node].nodeName; + if (nodeName != propstat2ChildTags[node]) + return; + + var nodeValue = propstat2.childNodes[node].childNodes[0].nodeValue; + if ((nodeName == "status") && (nodeValue != "HTTP/1.1 403 Forbidden")) + return; + if ((nodeName == "responsedescription") && (nodeValue != "The user does not have access to the DingALing property.")) + return; + } + + var prop2 = propstat2.childNodes[0]; + var prop2ChildTags = [ "DingALing", "Random" ]; + for (var node = 0; node < prop2.childNodes.length; ++node) { + var nodeName = prop2.childNodes[node].nodeName; + if (nodeName != prop2ChildTags[node]) + return; + } + + xmlTest = true; + } + + Component.onCompleted: { + + var request = new XMLHttpRequest(); + request.open("PROPFIND", url); + + request.onreadystatechange = function() { + if (request.readyState == XMLHttpRequest.DONE) { + checkXML(request.responseXML); + typeTest = (request.responseType == "document"); + } + } + + var requestBody = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + + "<D:propfind xmlns:D=\"DAV:\">\n" + + "<D:prop xmlns:R=\"http://www.foo.bar/boxschema/\">\n" + + "<R:bigbox/>\n" + + "<R:author/>\n" + + "<R:DingALing/>\n" + + "<R:Random/>\n" + + "</D:prop>\n" + + "</D:propfind>\n" + request.send(requestBody); + } +} + diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/cdata.qml b/tests/auto/qml/qqmlxmlhttprequest/data/cdata.qml index f558fdadc6..e1b690dbf3 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/data/cdata.qml +++ b/tests/auto/qml/qqmlxmlhttprequest/data/cdata.qml @@ -3,6 +3,7 @@ import QtQuick 2.0 QtObject { property bool xmlTest: false property bool dataOK: false + property int status: 0 function checkCData(text, whitespacetext) { @@ -114,12 +115,11 @@ QtObject { // Test to the end x.onreadystatechange = function() { if (x.readyState == XMLHttpRequest.DONE) { - dataOK = true; + status = x.status; if (x.responseXML != null) checkXML(x.responseXML); - } } diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/json.data b/tests/auto/qml/qqmlxmlhttprequest/data/json.data new file mode 100644 index 0000000000..7925375293 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/json.data @@ -0,0 +1,6 @@ +{"widget": { + "debug": "on", + "window": { + "name": "main_window", + "width": 500 +}}} diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/receiveBinaryData.qml b/tests/auto/qml/qqmlxmlhttprequest/data/receiveBinaryData.qml index 234d759284..b9f0ab6e66 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/data/receiveBinaryData.qml +++ b/tests/auto/qml/qqmlxmlhttprequest/data/receiveBinaryData.qml @@ -3,6 +3,7 @@ import QtQuick 2.0 QtObject { property string url property int readSize: 0 + property int status: 0 Component.onCompleted: { @@ -12,6 +13,7 @@ QtObject { request.onreadystatechange = function() { if (request.readyState == XMLHttpRequest.DONE) { + status = request.status; var arrayBuffer = request.response; if (arrayBuffer) { var byteArray = new Uint8Array(arrayBuffer); diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/receiveJsonData.qml b/tests/auto/qml/qqmlxmlhttprequest/data/receiveJsonData.qml new file mode 100644 index 0000000000..3fc116e675 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/receiveJsonData.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +QtObject { + property string url; + property bool result: false + property string correctjsondata : "{\"widget\":{\"debug\":\"on\",\"window\":{\"name\":\"main_window\",\"width\":500}}}" + + Component.onCompleted: { + var request = new XMLHttpRequest(); + request.open("GET", url, true); + request.responseType = "json"; + + request.onreadystatechange = function() { + if (request.readyState == XMLHttpRequest.DONE) { + var jsonData = JSON.stringify(request.response); + result = (correctjsondata == jsonData); + } + } + + request.send(null); + } +} diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/receive_json_data.expect b/tests/auto/qml/qqmlxmlhttprequest/data/receive_json_data.expect new file mode 100644 index 0000000000..97b016f50a --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/receive_json_data.expect @@ -0,0 +1,7 @@ +GET /json.data HTTP/1.1 +Accept-Language: en-US,* +Content-Type: application/jsonrequest +Connection: Keep-Alive +Accept-Encoding: gzip, deflate +User-Agent: Mozilla/5.0 +Host: {{ServerHostUrl}} diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/receive_json_data.reply b/tests/auto/qml/qqmlxmlhttprequest/data/receive_json_data.reply new file mode 100644 index 0000000000..f1ee73d623 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/receive_json_data.reply @@ -0,0 +1,3 @@ +HTTP/1.1 200 OK +Connection: close +Content-Type: application/jsonrequest diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/status.500.reply b/tests/auto/qml/qqmlxmlhttprequest/data/status.500.reply new file mode 100644 index 0000000000..cbe2424f34 --- /dev/null +++ b/tests/auto/qml/qqmlxmlhttprequest/data/status.500.reply @@ -0,0 +1,3 @@ +HTTP/1.0 500 Internal Server Error +Connection: close +Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/text.qml b/tests/auto/qml/qqmlxmlhttprequest/data/text.qml index b79e0bc7b1..972557358b 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/data/text.qml +++ b/tests/auto/qml/qqmlxmlhttprequest/data/text.qml @@ -3,6 +3,7 @@ import QtQuick 2.0 QtObject { property bool xmlTest: false property bool dataOK: false + property int status: 0 function checkText(text, whitespacetext) { @@ -111,12 +112,11 @@ QtObject { // Test to the end x.onreadystatechange = function() { if (x.readyState == XMLHttpRequest.DONE) { - dataOK = true; + status = x.status; if (x.responseXML != null) checkXML(x.responseXML); - } } diff --git a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp index c159dc8420..68f85daacd 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp +++ b/tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp @@ -88,6 +88,7 @@ private slots: void getAllResponseHeaders_sent(); void getAllResponseHeaders_args(); void getBinaryData(); + void getJsonData(); void status(); void status_data(); void statusText(); @@ -100,6 +101,10 @@ private slots: void nonUtf8(); void nonUtf8_data(); + // WebDAV + void sendPropfind(); + void sendPropfind_data(); + // Attributes void document(); void element(); @@ -172,7 +177,7 @@ void tst_qqmlxmlhttprequest::callbackException() object->setProperty("which", which); component.completeCreate(); - QTRY_VERIFY(object->property("threw").toBool() == true); + QTRY_VERIFY(object->property("threw").toBool()); } // Test that the state value properties on the XMLHttpRequest constructor have the correct values. @@ -258,7 +263,7 @@ void tst_qqmlxmlhttprequest::open() QCOMPARE(object->property("responseText").toBool(), true); QCOMPARE(object->property("responseXML").toBool(), true); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); } void tst_qqmlxmlhttprequest::open_data() @@ -371,7 +376,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader() object->setProperty("url", server.urlString("/testdocument.html")); component.completeCreate(); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); } // Test valid setRequestHeader() calls with different header cases @@ -389,7 +394,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader_caseInsensitive() object->setProperty("url", server.urlString("/testdocument.html")); component.completeCreate(); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); } // Test setting headers before open() throws exception void tst_qqmlxmlhttprequest::setRequestHeader_unsent() @@ -454,7 +459,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader_illegalName() QCOMPARE(object->property("responseText").toBool(), true); QCOMPARE(object->property("responseXML").toBool(), true); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); } // Test that attempting to set a header after a request is sent throws an exception @@ -474,7 +479,7 @@ void tst_qqmlxmlhttprequest::setRequestHeader_sent() QCOMPARE(object->property("test").toBool(), true); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); } // Invalid arg count throws exception @@ -505,7 +510,7 @@ void tst_qqmlxmlhttprequest::send_alreadySent() QVERIFY(!object.isNull()); QCOMPARE(object->property("test").toBool(), true); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); } // Test that sends for GET, HEAD and DELETE ignore data @@ -525,7 +530,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData() object->setProperty("url", server.urlString("/testdocument.html")); component.completeCreate(); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); } { @@ -542,7 +547,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData() object->setProperty("url", server.urlString("/testdocument.html")); component.completeCreate(); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); } { @@ -559,7 +564,7 @@ void tst_qqmlxmlhttprequest::send_ignoreData() object->setProperty("url", server.urlString("/testdocument.html")); component.completeCreate(); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); } } @@ -581,7 +586,7 @@ void tst_qqmlxmlhttprequest::send_withdata() object->setProperty("url", server.urlString("/testdocument.html")); component.completeCreate(); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); } void tst_qqmlxmlhttprequest::send_withdata_data() @@ -616,7 +621,7 @@ void tst_qqmlxmlhttprequest::send_options() QVERIFY(!object.isNull()); QString url = server.baseUrl().toString(); if (url_suffix != "/") - url.append("/"); + url.append(QLatin1Char('/')); if (!url_suffix.isEmpty()) url.append(url_suffix); object->setProperty("url", url); @@ -655,7 +660,7 @@ void tst_qqmlxmlhttprequest::abort_unsent() QCOMPARE(object->property("responseText").toBool(), true); QCOMPARE(object->property("responseXML").toBool(), true); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); } // Test abort() cancels an open (but unsent) request @@ -674,7 +679,7 @@ void tst_qqmlxmlhttprequest::abort_opened() QCOMPARE(object->property("responseText").toBool(), true); QCOMPARE(object->property("responseXML").toBool(), true); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); } // Test abort() aborts in progress send @@ -700,7 +705,7 @@ void tst_qqmlxmlhttprequest::abort() QCOMPARE(object->property("didNotSeeUnsent").toBool(), true); QCOMPARE(object->property("endStateUnsent").toBool(), true); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); } void tst_qqmlxmlhttprequest::getResponseHeader() @@ -725,7 +730,7 @@ void tst_qqmlxmlhttprequest::getResponseHeader() QCOMPARE(object->property("readyState").toBool(), true); QCOMPARE(object->property("openedState").toBool(), true); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); QCOMPARE(object->property("headersReceivedState").toBool(), true); QCOMPARE(object->property("headersReceivedNullHeader").toBool(), true); @@ -767,7 +772,7 @@ void tst_qqmlxmlhttprequest::getResponseHeader_args() QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QTRY_VERIFY(object->property("exceptionThrown").toBool() == true); + QTRY_VERIFY(object->property("exceptionThrown").toBool()); } void tst_qqmlxmlhttprequest::getAllResponseHeaders() @@ -791,7 +796,7 @@ void tst_qqmlxmlhttprequest::getAllResponseHeaders() QCOMPARE(object->property("readyState").toBool(), true); QCOMPARE(object->property("openedState").toBool(), true); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); QCOMPARE(object->property("headersReceivedState").toBool(), true); QCOMPARE(object->property("headersReceivedHeader").toBool(), true); @@ -827,7 +832,7 @@ void tst_qqmlxmlhttprequest::getAllResponseHeaders_args() QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QTRY_VERIFY(object->property("exceptionThrown").toBool() == true); + QTRY_VERIFY(object->property("exceptionThrown").toBool()); } void tst_qqmlxmlhttprequest::getBinaryData() @@ -845,7 +850,25 @@ void tst_qqmlxmlhttprequest::getBinaryData() component.completeCreate(); QFileInfo fileInfo("data/qml_logo.png"); - QTRY_VERIFY(object->property("readSize").toInt() == fileInfo.size()); + QTRY_COMPARE(object->property("readSize").toInt(), fileInfo.size()); + QCOMPARE(object->property("status").toInt(), 200); +} + +void tst_qqmlxmlhttprequest::getJsonData() +{ + TestHTTPServer server; + QVERIFY2(server.listen(), qPrintable(server.errorString())); + QVERIFY(server.wait(testFileUrl("receive_json_data.expect"), + testFileUrl("receive_binary_data.reply"), + testFileUrl("json.data"))); + + QQmlComponent component(&engine, testFileUrl("receiveJsonData.qml")); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); + object->setProperty("url", server.urlString("/json.data")); + component.completeCreate(); + + QTRY_VERIFY(object->property("result").toBool()); } void tst_qqmlxmlhttprequest::status() @@ -866,7 +889,7 @@ void tst_qqmlxmlhttprequest::status() object->setProperty("expectedStatus", status); component.completeCreate(); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); QCOMPARE(object->property("unsentException").toBool(), true); QCOMPARE(object->property("openedException").toBool(), true); @@ -905,7 +928,7 @@ void tst_qqmlxmlhttprequest::statusText() object->setProperty("expectedStatus", statusText); component.completeCreate(); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); QCOMPARE(object->property("unsentException").toBool(), true); QCOMPARE(object->property("openedException").toBool(), true); @@ -945,7 +968,7 @@ void tst_qqmlxmlhttprequest::responseText() object->setProperty("expectedText", responseText); component.completeCreate(); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); QCOMPARE(object->property("unsent").toBool(), true); QCOMPARE(object->property("opened").toBool(), true); @@ -966,6 +989,7 @@ void tst_qqmlxmlhttprequest::responseText_data() QTest::newRow("empty body") << testFileUrl("status.200.reply") << QUrl() << ""; QTest::newRow("Not Found") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << "QML Rocks!\n"; QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << testFileUrl("testdocument.html") << "QML Rocks!\n"; + QTest::newRow("Internal server error") << testFileUrl("status.500.reply") << testFileUrl("testdocument.html") << "QML Rocks!\n"; } void tst_qqmlxmlhttprequest::nonUtf8() @@ -981,7 +1005,7 @@ void tst_qqmlxmlhttprequest::nonUtf8() object->setProperty("fileName", fileName); QMetaObject::invokeMethod(object.data(), "startRequest"); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); QCOMPARE(object->property("responseText").toString(), responseText); @@ -1007,6 +1031,46 @@ void tst_qqmlxmlhttprequest::nonUtf8_data() QTest::newRow("responseXML") << "utf16.xml" << "<?xml version=\"1.0\" encoding=\"UTF-16\" standalone='yes'?>\n<root>\n" + uc + "\n</root>\n" << QString('\n' + uc + '\n'); } +void tst_qqmlxmlhttprequest::sendPropfind() +{ + const QString prefix = "WebDAV//"; + + QFETCH(QString, qml); + QFETCH(QString, resource); + QFETCH(QString, expectedFile); + QFETCH(QString, replyHeader); + QFETCH(QString, replyBody); + + TestHTTPServer server; + QVERIFY2(server.listen(), qPrintable(server.errorString())); + + QVERIFY(server.wait(testFileUrl(prefix + expectedFile), + testFileUrl(prefix + replyHeader), + testFileUrl(prefix + replyBody))); + + QQmlComponent component(&engine, testFileUrl(prefix + qml)); + QScopedPointer<QObject> object(component.beginCreate(engine.rootContext())); + QVERIFY(!object.isNull()); + object->setProperty("url", server.urlString(resource)); + component.completeCreate(); + + QTRY_VERIFY(object->property("xmlTest").toBool()); + QCOMPARE(object->property("typeTest").toBool(), true); +} + +void tst_qqmlxmlhttprequest::sendPropfind_data() +{ + QTest::addColumn<QString>("qml"); + QTest::addColumn<QString>("resource"); + QTest::addColumn<QString>("expectedFile"); + QTest::addColumn<QString>("replyHeader"); + QTest::addColumn<QString>("replyBody"); + + QTest::newRow("Send PROPFIND for file (bigbox, author, DingALing, Random properties). Get response with responseXML.") << "sendPropfind.responseXML.qml" << "/file" << "propfind.file.expect" << "propfind.file.reply.header" << "propfind.file.reply.body"; + QTest::newRow("Send PROPFIND for file (bigbox, author, DingALing, Random properties). Get response with response.") << "sendPropfind.response.qml" << "/file" << "propfind.file.expect" << "propfind.file.reply.header" << "propfind.file.reply.body"; + QTest::newRow("Send PROPFIND \"allprop\" request for collection.") << "sendPropfind.collection.allprop.qml" << "/container/" << "propfind.collection.allprop.expect" << "propfind.file.reply.header" << "propfind.collection.allprop.reply.body"; +} + // Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object // throws an exception void tst_qqmlxmlhttprequest::invalidMethodUsage() @@ -1045,7 +1109,7 @@ void tst_qqmlxmlhttprequest::redirects() object->setProperty("expectedText", ""); component.completeCreate(); - QTRY_VERIFY(object->property("done").toBool() == true); + QTRY_VERIFY(object->property("done").toBool()); QCOMPARE(object->property("dataOK").toBool(), true); } @@ -1062,7 +1126,7 @@ void tst_qqmlxmlhttprequest::redirects() object->setProperty("expectedText", ""); component.completeCreate(); - QTRY_VERIFY(object->property("done").toBool() == true); + QTRY_VERIFY(object->property("done").toBool()); QCOMPARE(object->property("dataOK").toBool(), true); } @@ -1083,7 +1147,7 @@ void tst_qqmlxmlhttprequest::redirects() if (object->property("done").toBool()) break; QTest::qWait(50); } - QVERIFY(object->property("done").toBool() == true); + QVERIFY(object->property("done").toBool()); QCOMPARE(object->property("dataOK").toBool(), true); } @@ -1095,7 +1159,7 @@ void tst_qqmlxmlhttprequest::responseXML_invalid() QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); QCOMPARE(object->property("xmlNull").toBool(), true); } @@ -1107,7 +1171,7 @@ void tst_qqmlxmlhttprequest::document() QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); QCOMPARE(object->property("xmlTest").toBool(), true); } @@ -1119,7 +1183,7 @@ void tst_qqmlxmlhttprequest::element() QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); QCOMPARE(object->property("xmlTest").toBool(), true); } @@ -1131,7 +1195,7 @@ void tst_qqmlxmlhttprequest::attr() QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); QCOMPARE(object->property("xmlTest").toBool(), true); } @@ -1143,9 +1207,10 @@ void tst_qqmlxmlhttprequest::text() QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); QCOMPARE(object->property("xmlTest").toBool(), true); + QCOMPARE(object->property("status").toInt(), 200); } // Test the CDataSection DOM element @@ -1155,9 +1220,10 @@ void tst_qqmlxmlhttprequest::cdata() QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QTRY_VERIFY(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool()); QCOMPARE(object->property("xmlTest").toBool(), true); + QCOMPARE(object->property("status").toInt(), 200); } void tst_qqmlxmlhttprequest::stateChangeCallingContext() @@ -1179,7 +1245,7 @@ void tst_qqmlxmlhttprequest::stateChangeCallingContext() object->setProperty("serverBaseUrl", server.baseUrl().toString()); component.completeCreate(); server.sendDelayedItem(); - QTRY_VERIFY(object->property("success").toBool() == true); + QTRY_VERIFY(object->property("success").toBool()); } QTEST_MAIN(tst_qqmlxmlhttprequest) diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp index 59be469d5b..aca809a137 100644 --- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -93,8 +93,8 @@ void tst_qquickfolderlistmodel::checkNoErrors(const QQmlComponent& component) QList<QQmlError> errors = component.errors(); for (int ii = 0; ii < errors.count(); ++ii) { const QQmlError &error = errors.at(ii); - QByteArray errorStr = QByteArray::number(error.line()) + ":" + - QByteArray::number(error.column()) + ":" + + QByteArray errorStr = QByteArray::number(error.line()) + ':' + + QByteArray::number(error.column()) + ':' + error.description().toUtf8(); qWarning() << errorStr; } @@ -295,11 +295,11 @@ void tst_qquickfolderlistmodel::changeDrive() flm->setProperty("folder",QUrl::fromLocalFile(dataDir)); QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(dataDir)); - QTRY_VERIFY(folderChangeSpy.count() == 1); + QTRY_COMPARE(folderChangeSpy.count(), 1); flm->setProperty("folder",QUrl::fromLocalFile("X:/resetfiltering/")); QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile("X:/resetfiltering/")); - QTRY_VERIFY(folderChangeSpy.count() == 2); + QTRY_COMPARE(folderChangeSpy.count(), 2); } #endif diff --git a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp index f4765d0e8d..8ad2b6ba2b 100644 --- a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp +++ b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp @@ -338,19 +338,17 @@ void tst_QQuickWorkerScript::script_global() delete worker; } + qquickworkerscript_lastWarning = QString(); + { + QtMessageHandler previousMsgHandler = qInstallMessageHandler(qquickworkerscript_warningsHandler); + QQmlComponent component(&m_engine, testFileUrl("worker_global2.qml")); QQuickWorkerScript *worker = qobject_cast<QQuickWorkerScript*>(component.create()); QVERIFY(worker != 0); - QString value("Hello"); - - QtMessageHandler previousMsgHandler = qInstallMessageHandler(qquickworkerscript_warningsHandler); - - QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value))); - QTRY_COMPARE(qquickworkerscript_lastWarning, - testFileUrl("script_global.js").toString() + QLatin1String(":2: Invalid write to global property \"world\"")); + testFileUrl("script_global2.js").toString() + QLatin1String(":1: Invalid write to global property \"world\"")); qInstallMessageHandler(previousMsgHandler); diff --git a/tests/auto/qml/qv4debugger/qv4debugger.pro b/tests/auto/qml/qv4debugger/qv4debugger.pro index 2a318955f3..540cab70e6 100644 --- a/tests/auto/qml/qv4debugger/qv4debugger.pro +++ b/tests/auto/qml/qv4debugger/qv4debugger.pro @@ -2,6 +2,14 @@ CONFIG += testcase TARGET = tst_qv4debugger macx:CONFIG -= app_bundle -SOURCES += tst_qv4debugger.cpp +SOURCES += \ + $$PWD/tst_qv4debugger.cpp \ + $$PWD/../../../../src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.cpp + +HEADERS += \ + $$PWD/../../../../src/plugins/qmltooling/qmldbg_debugger/qv4datacollector.h + +INCLUDEPATH += \ + $$PWD/../../../../src/plugins/qmltooling/qmldbg_debugger QT += core-private gui-private qml-private network testlib diff --git a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp index 056b24d167..39a1fbc173 100644 --- a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp @@ -32,12 +32,16 @@ ****************************************************************************/ #include <QtTest/QtTest> +#include "qv4datacollector.h" + #include <QJSEngine> #include <QQmlEngine> #include <QQmlComponent> #include <private/qv4engine_p.h> #include <private/qv4debugging_p.h> #include <private/qv8engine_p.h> +#include <private/qv4objectiterator_p.h> +#include <private/qv4isel_moth_p.h> using namespace QV4; using namespace QV4::Debugging; @@ -85,99 +89,93 @@ public: QV4::ScopedString name(scope, v4->newString(functionName)); QV4::ScopedContext ctx(scope, v4->rootContext()); QV4::ScopedValue function(scope, BuiltinFunction::create(ctx, name, injectedFunction)); - v4->globalObject()->put(name, function); + v4->globalObject->put(name, function); } signals: void evaluateFinished(); }; - -namespace { -class TestCollector: public QV4::Debugging::Debugger::Collector +class TestAgent : public QObject { + Q_OBJECT public: - TestCollector(QV4::ExecutionEngine *engine) - : Collector(engine) - , destination(0) - {} - - virtual ~TestCollector() {} - - void setDestination(QVariantMap *dest) - { destination = dest; } - -protected: - virtual void addUndefined(const QString &name) - { - destination->insert(name, QStringLiteral("undefined")); // TODO: add a user-defined type for this - } - - virtual void addNull(const QString &name) - { - destination->insert(name, QStringLiteral("null")); // TODO: add a user-defined type for this - } - - virtual void addBoolean(const QString &name, bool value) - { - destination->insert(name, value); - } + typedef QV4DataCollector::Refs Refs; + typedef QV4DataCollector::Ref Ref; + struct NamedRefs { + NamedRefs(QV4DataCollector *collector = 0): collector(collector) {} + + QStringList names; + Refs refs; + QV4DataCollector *collector; + + int size() const { + Q_ASSERT(names.size() == refs.size()); + return names.size(); + } - virtual void addString(const QString &name, const QString &value) - { - destination->insert(name, value); - } + bool contains(const QString &name) const { + return names.contains(name); + } - virtual void addObject(const QString &name, const QV4::Value &value) - { - QV4::Scope scope(engine()); - QV4::ScopedObject obj(scope, value.asObject()); +#define DUMP_JSON(x) {\ + QJsonDocument doc(x);\ + qDebug() << #x << "=" << doc.toJson(QJsonDocument::Indented);\ +} - QVariantMap props, *prev = &props; - qSwap(destination, prev); - collect(obj); - qSwap(destination, prev); + QJsonObject rawValue(const QString &name) const { + Q_ASSERT(contains(name)); + return collector->lookupRef(refs.at(names.indexOf(name))); + } - destination->insert(name, props); - } + QJsonValue value(const QString &name) const { + return rawValue(name).value(QStringLiteral("value")); + } - virtual void addInteger(const QString &name, int value) - { - destination->insert(name, QVariant::fromValue<double>(static_cast<double>(value))); - } + QString type(const QString &name) const { + return rawValue(name).value(QStringLiteral("type")).toString(); + } - virtual void addDouble(const QString &name, double value) - { - destination->insert(name, QVariant::fromValue<double>(value)); - } + void dump(const QString &name) const { + if (!contains(name)) { + qDebug() << "no" << name; + return; + } -private: - QVariantMap *destination; -}; -} + QJsonObject o = collector->lookupRef(refs.at(names.indexOf(name))); + QJsonDocument d; + d.setObject(o); + qDebug() << name << "=" << d.toJson(QJsonDocument::Indented); + } + }; -class TestAgent : public QV4::Debugging::DebuggerAgent -{ - Q_OBJECT -public: - TestAgent() + TestAgent(QV4::ExecutionEngine *engine) : m_wasPaused(false) , m_captureContextInfo(false) + , m_thrownValue(-1) + , collector(engine) + , m_debugger(0) { } - virtual void debuggerPaused(Debugger *debugger, PauseReason reason) +public slots: + void debuggerPaused(V4Debugger *debugger, QV4::Debugging::PauseReason reason) { - Q_ASSERT(m_debuggers.count() == 1 && m_debuggers.first() == debugger); + Q_ASSERT(debugger == m_debugger); + Q_ASSERT(debugger->engine() == collector.engine()); m_wasPaused = true; m_pauseReason = reason; m_statesWhenPaused << debugger->currentExecutionState(); - TestCollector collector(debugger->engine()); - QVariantMap tmp; - collector.setDestination(&tmp); - debugger->collectThrownValue(&collector); - m_thrownValue = tmp["exception"]; + if (debugger->state() == V4Debugger::Paused && + debugger->engine()->hasException) { + Refs refs; + RefHolder holder(&collector, &refs); + ExceptionCollectJob job(debugger->engine(), &collector); + debugger->runInEngine(&job); + Q_ASSERT(refs.size() > 0); + m_thrownValue = refs.first(); + } foreach (const TestBreakPoint &bp, m_breakPointsToAddWhenPaused) debugger->addBreakPoint(bp.fileName, bp.lineNumber); @@ -186,28 +184,22 @@ public: m_stackTrace = debugger->stackTrace(); while (!m_expressionRequests.isEmpty()) { + Q_ASSERT(debugger->state() == V4Debugger::Paused); ExpressionRequest request = m_expressionRequests.takeFirst(); - QVariantMap result; - collector.setDestination(&result); - debugger->evaluateExpression(request.frameNr, request.expression, &collector); - m_expressionResults << result[QString::fromLatin1("body")]; + m_expressionResults << Refs(); + RefHolder holder(&collector, &m_expressionResults.last()); + ExpressionEvalJob job(debugger->engine(), request.frameNr, request.expression, + &collector); + debugger->runInEngine(&job); } if (m_captureContextInfo) captureContextInfo(debugger); - debugger->resume(Debugger::FullThrottle); + debugger->resume(V4Debugger::FullThrottle); } - virtual void sourcesCollected(Debugger *debugger, QStringList sources, int requestSequenceNr) - { - Q_UNUSED(debugger); - Q_UNUSED(sources); - Q_UNUSED(requestSequenceNr); - } - - int debuggerCount() const { return m_debuggers.count(); } - +public: struct TestBreakPoint { TestBreakPoint() : lineNumber(-1) {} @@ -217,39 +209,49 @@ public: int lineNumber; }; - void captureContextInfo(Debugger *debugger) + void captureContextInfo(V4Debugger *debugger) { - TestCollector collector(debugger->engine()); - for (int i = 0, ei = m_stackTrace.size(); i != ei; ++i) { - QVariantMap args; - collector.setDestination(&args); - debugger->collectArgumentsInContext(&collector, i); - m_capturedArguments.append(args); - - QVariantMap locals; - collector.setDestination(&locals); - debugger->collectLocalsInContext(&collector, i); - m_capturedLocals.append(locals); + m_capturedArguments.append(NamedRefs(&collector)); + RefHolder argHolder(&collector, &m_capturedArguments.last().refs); + ArgumentCollectJob argumentsJob(debugger->engine(), &collector, + &m_capturedArguments.last().names, i, 0); + debugger->runInEngine(&argumentsJob); + + m_capturedLocals.append(NamedRefs(&collector)); + RefHolder localHolder(&collector, &m_capturedLocals.last().refs); + LocalCollectJob localsJob(debugger->engine(), &collector, + &m_capturedLocals.last().names, i, 0); + debugger->runInEngine(&localsJob); } } + void addDebugger(V4Debugger *debugger) + { + Q_ASSERT(!m_debugger); + m_debugger = debugger; + connect(m_debugger, &V4Debugger::debuggerPaused, + this, &TestAgent::debuggerPaused); + } + bool m_wasPaused; PauseReason m_pauseReason; bool m_captureContextInfo; - QList<Debugger::ExecutionState> m_statesWhenPaused; + QList<V4Debugger::ExecutionState> m_statesWhenPaused; QList<TestBreakPoint> m_breakPointsToAddWhenPaused; QVector<QV4::StackFrame> m_stackTrace; - QList<QVariantMap> m_capturedArguments; - QList<QVariantMap> m_capturedLocals; - QVariant m_thrownValue; + QVector<NamedRefs> m_capturedArguments; + QVector<NamedRefs> m_capturedLocals; + qint64 m_thrownValue; + QV4DataCollector collector; struct ExpressionRequest { QString expression; int frameNr; }; QVector<ExpressionRequest> m_expressionRequests; - QVector<QVariant> m_expressionResults; + QVector<Refs> m_expressionResults; + V4Debugger *m_debugger; // Utility methods: void dumpStackTrace() const @@ -293,6 +295,10 @@ private slots: void evaluateExpression(); private: + V4Debugger *debugger() const + { + return static_cast<V4Debugger *>(m_v4->debugger); + } void evaluateJavaScript(const QString &script, const QString &fileName, int lineNumber = 1) { QMetaObject::invokeMethod(m_engine, "evaluate", Qt::QueuedConnection, @@ -312,11 +318,12 @@ void tst_qv4debugger::init() m_javaScriptThread = new QThread; m_engine = new TestEngine; m_v4 = m_engine->v4Engine(); - m_v4->enableDebugger(); + m_v4->iselFactory.reset(new QV4::Moth::ISelFactory); + m_v4->setDebugger(new V4Debugger(m_v4)); m_engine->moveToThread(m_javaScriptThread); m_javaScriptThread->start(); - m_debuggerAgent = new TestAgent; - m_debuggerAgent->addDebugger(m_v4->debugger); + m_debuggerAgent = new TestAgent(m_v4); + m_debuggerAgent->addDebugger(debugger()); } void tst_qv4debugger::cleanup() @@ -327,7 +334,6 @@ void tst_qv4debugger::cleanup() delete m_javaScriptThread; m_engine = 0; m_v4 = 0; - QCOMPARE(m_debuggerAgent->debuggerCount(), 0); delete m_debuggerAgent; m_debuggerAgent = 0; } @@ -338,7 +344,7 @@ void tst_qv4debugger::breakAnywhere() "var i = 42;\n" "var j = i + 1\n" "var k = i\n"; - m_debuggerAgent->pauseAll(); + debugger()->pause(); evaluateJavaScript(script, "testFile"); QVERIFY(m_debuggerAgent->m_wasPaused); } @@ -349,11 +355,11 @@ void tst_qv4debugger::pendingBreakpoint() "var i = 42;\n" "var j = i + 1\n" "var k = i\n"; - m_debuggerAgent->addBreakPoint("testfile", 2); + debugger()->addBreakPoint("testfile", 2); evaluateJavaScript(script, "testfile"); QVERIFY(m_debuggerAgent->m_wasPaused); QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 1); - QV4::Debugging::Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first(); + V4Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first(); QCOMPARE(state.fileName, QString("testfile")); QCOMPARE(state.lineNumber, 2); } @@ -365,11 +371,11 @@ void tst_qv4debugger::liveBreakPoint() "var j = i + 1\n" "var k = i\n"; m_debuggerAgent->m_breakPointsToAddWhenPaused << TestAgent::TestBreakPoint("liveBreakPoint", 3); - m_debuggerAgent->pauseAll(); + debugger()->pause(); evaluateJavaScript(script, "liveBreakPoint"); QVERIFY(m_debuggerAgent->m_wasPaused); QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 2); - QV4::Debugging::Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.at(1); + V4Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.at(1); QCOMPARE(state.fileName, QString("liveBreakPoint")); QCOMPARE(state.lineNumber, 3); } @@ -380,8 +386,8 @@ void tst_qv4debugger::removePendingBreakPoint() "var i = 42;\n" "var j = i + 1\n" "var k = i\n"; - int id = m_debuggerAgent->addBreakPoint("removePendingBreakPoint", 2); - m_debuggerAgent->removeBreakPoint(id); + debugger()->addBreakPoint("removePendingBreakPoint", 2); + debugger()->removeBreakPoint("removePendingBreakPoint", 2); evaluateJavaScript(script, "removePendingBreakPoint"); QVERIFY(!m_debuggerAgent->m_wasPaused); } @@ -392,13 +398,13 @@ void tst_qv4debugger::addBreakPointWhilePaused() "var i = 42;\n" "var j = i + 1\n" "var k = i\n"; - m_debuggerAgent->addBreakPoint("addBreakPointWhilePaused", 1); + debugger()->addBreakPoint("addBreakPointWhilePaused", 1); m_debuggerAgent->m_breakPointsToAddWhenPaused << TestAgent::TestBreakPoint("addBreakPointWhilePaused", 2); evaluateJavaScript(script, "addBreakPointWhilePaused"); QVERIFY(m_debuggerAgent->m_wasPaused); QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 2); - QV4::Debugging::Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.at(0); + V4Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.at(0); QCOMPARE(state.fileName, QString("addBreakPointWhilePaused")); QCOMPARE(state.lineNumber, 1); @@ -409,7 +415,8 @@ void tst_qv4debugger::addBreakPointWhilePaused() static QV4::ReturnedValue someCall(QV4::CallContext *ctx) { - ctx->d()->engine->debugger->removeBreakPoint("removeBreakPointForNextInstruction", 2); + static_cast<V4Debugger *>(ctx->d()->engine->debugger) + ->removeBreakPoint("removeBreakPointForNextInstruction", 2); return QV4::Encode::undefined(); } @@ -422,7 +429,7 @@ void tst_qv4debugger::removeBreakPointForNextInstruction() QMetaObject::invokeMethod(m_engine, "injectFunction", Qt::BlockingQueuedConnection, Q_ARG(QString, "someCall"), Q_ARG(InjectedFunction, someCall)); - m_debuggerAgent->addBreakPoint("removeBreakPointForNextInstruction", 2); + debugger()->addBreakPoint("removeBreakPointForNextInstruction", 2); evaluateJavaScript(script, "removeBreakPointForNextInstruction"); QVERIFY(!m_debuggerAgent->m_wasPaused); @@ -439,28 +446,33 @@ void tst_qv4debugger::conditionalBreakPoint() "}\n" "test()\n"; - m_debuggerAgent->addBreakPoint("conditionalBreakPoint", 3, /*enabled*/true, QStringLiteral("i > 10")); + debugger()->addBreakPoint("conditionalBreakPoint", 3, QStringLiteral("i > 10")); evaluateJavaScript(script, "conditionalBreakPoint"); QVERIFY(m_debuggerAgent->m_wasPaused); QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 4); - QV4::Debugging::Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first(); + V4Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first(); QCOMPARE(state.fileName, QString("conditionalBreakPoint")); QCOMPARE(state.lineNumber, 3); - QCOMPARE(m_debuggerAgent->m_capturedLocals[0].size(), 2); - QVERIFY(m_debuggerAgent->m_capturedLocals[0].contains(QStringLiteral("i"))); - QCOMPARE(m_debuggerAgent->m_capturedLocals[0]["i"].toInt(), 11); + + QVERIFY(m_debuggerAgent->m_capturedLocals.size() > 1); + const TestAgent::NamedRefs &frame0 = m_debuggerAgent->m_capturedLocals.at(0); + QCOMPARE(frame0.size(), 2); + QVERIFY(frame0.contains("i")); + QCOMPARE(frame0.value("i").toInt(), 11); } void tst_qv4debugger::conditionalBreakPointInQml() { QQmlEngine engine; QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine); - v4->enableDebugger(); + V4Debugger *v4Debugger = new V4Debugger(v4); + v4->iselFactory.reset(new QV4::Moth::ISelFactory); + v4->setDebugger(v4Debugger); QScopedPointer<QThread> debugThread(new QThread); debugThread->start(); - QScopedPointer<TestAgent> debuggerAgent(new TestAgent); - debuggerAgent->addDebugger(v4->debugger); + QScopedPointer<TestAgent> debuggerAgent(new TestAgent(v4)); + debuggerAgent->addDebugger(v4Debugger); debuggerAgent->moveToThread(debugThread.data()); QQmlComponent component(&engine); @@ -474,7 +486,7 @@ void tst_qv4debugger::conditionalBreakPointInQml() " }\n" "}\n", QUrl("test.qml")); - debuggerAgent->addBreakPoint("test.qml", 7, /*enabled*/true, "root.foo == 42"); + v4Debugger->addBreakPoint("test.qml", 7, "root.foo == 42"); QScopedPointer<QObject> obj(component.create()); QCOMPARE(obj->property("success").toBool(), true); @@ -496,16 +508,18 @@ void tst_qv4debugger::readArguments() "}\n" "var four;\n" "f(1, 'two', null, four);\n"; - m_debuggerAgent->addBreakPoint("readArguments", 2); + debugger()->addBreakPoint("readArguments", 2); evaluateJavaScript(script, "readArguments"); QVERIFY(m_debuggerAgent->m_wasPaused); - QCOMPARE(m_debuggerAgent->m_capturedArguments[0].size(), 4); - QVERIFY(m_debuggerAgent->m_capturedArguments[0].contains(QStringLiteral("a"))); - QCOMPARE(m_debuggerAgent->m_capturedArguments[0]["a"].type(), QVariant::Double); - QCOMPARE(m_debuggerAgent->m_capturedArguments[0]["a"].toDouble(), 1.0); - QVERIFY(m_debuggerAgent->m_capturedArguments[0].contains("b")); - QCOMPARE(m_debuggerAgent->m_capturedArguments[0]["b"].type(), QVariant::String); - QCOMPARE(m_debuggerAgent->m_capturedArguments[0]["b"].toString(), QLatin1String("two")); + QVERIFY(m_debuggerAgent->m_capturedArguments.size() > 1); + const TestAgent::NamedRefs &frame0 = m_debuggerAgent->m_capturedArguments.at(0); + QCOMPARE(frame0.size(), 4); + QVERIFY(frame0.contains(QStringLiteral("a"))); + QCOMPARE(frame0.type(QStringLiteral("a")), QStringLiteral("number")); + QCOMPARE(frame0.value(QStringLiteral("a")).toDouble(), 1.0); + QVERIFY(frame0.names.contains("b")); + QCOMPARE(frame0.type(QStringLiteral("b")), QStringLiteral("string")); + QCOMPARE(frame0.value(QStringLiteral("b")).toString(), QStringLiteral("two")); } void tst_qv4debugger::readLocals() @@ -518,15 +532,17 @@ void tst_qv4debugger::readLocals() " return c === d\n" "}\n" "f(1, 2, 3);\n"; - m_debuggerAgent->addBreakPoint("readLocals", 3); + debugger()->addBreakPoint("readLocals", 3); evaluateJavaScript(script, "readLocals"); QVERIFY(m_debuggerAgent->m_wasPaused); - QCOMPARE(m_debuggerAgent->m_capturedLocals[0].size(), 2); - QVERIFY(m_debuggerAgent->m_capturedLocals[0].contains("c")); - QCOMPARE(m_debuggerAgent->m_capturedLocals[0]["c"].type(), QVariant::Double); - QCOMPARE(m_debuggerAgent->m_capturedLocals[0]["c"].toDouble(), 3.0); - QVERIFY(m_debuggerAgent->m_capturedLocals[0].contains("d")); - QCOMPARE(m_debuggerAgent->m_capturedLocals[0]["d"].toString(), QString("undefined")); + QVERIFY(m_debuggerAgent->m_capturedLocals.size() > 1); + const TestAgent::NamedRefs &frame0 = m_debuggerAgent->m_capturedLocals.at(0); + QCOMPARE(frame0.size(), 2); + QVERIFY(frame0.contains("c")); + QCOMPARE(frame0.type("c"), QStringLiteral("number")); + QCOMPARE(frame0.value("c").toDouble(), 3.0); + QVERIFY(frame0.contains("d")); + QCOMPARE(frame0.type("d"), QStringLiteral("undefined")); } void tst_qv4debugger::readObject() @@ -538,26 +554,43 @@ void tst_qv4debugger::readObject() " return b\n" "}\n" "f({head: 1, tail: { head: 'asdf', tail: null }});\n"; - m_debuggerAgent->addBreakPoint("readObject", 3); + debugger()->addBreakPoint("readObject", 3); evaluateJavaScript(script, "readObject"); QVERIFY(m_debuggerAgent->m_wasPaused); - QCOMPARE(m_debuggerAgent->m_capturedLocals[0].size(), 1); - QVERIFY(m_debuggerAgent->m_capturedLocals[0].contains("b")); - QCOMPARE(m_debuggerAgent->m_capturedLocals[0]["b"].type(), QVariant::Map); - - QVariantMap b = m_debuggerAgent->m_capturedLocals[0]["b"].toMap(); - QCOMPARE(b.size(), 2); - QVERIFY(b.contains("head")); - QCOMPARE(b["head"].type(), QVariant::Double); - QCOMPARE(b["head"].toDouble(), 1.0); - QVERIFY(b.contains("tail")); - QCOMPARE(b["tail"].type(), QVariant::Map); - - QVariantMap b_tail = b["tail"].toMap(); - QCOMPARE(b_tail.size(), 2); - QVERIFY(b_tail.contains("head")); - QCOMPARE(b_tail["head"].type(), QVariant::String); - QCOMPARE(b_tail["head"].toString(), QString("asdf")); + QVERIFY(m_debuggerAgent->m_capturedLocals.size() > 1); + const TestAgent::NamedRefs &frame0 = m_debuggerAgent->m_capturedLocals.at(0); + QCOMPARE(frame0.size(), 1); + QVERIFY(frame0.contains("b")); + QCOMPARE(frame0.type("b"), QStringLiteral("object")); + QJsonObject b = frame0.rawValue("b"); + QVERIFY(b.contains(QStringLiteral("properties"))); + QVERIFY(b.value("properties").isArray()); + QJsonArray b_props = b.value("properties").toArray(); + QCOMPARE(b_props.size(), 2); + + QVERIFY(b_props.at(0).isObject()); + QJsonObject b_head = b_props.at(0).toObject(); + QCOMPARE(b_head.value("name").toString(), QStringLiteral("head")); + QCOMPARE(b_head.value("type").toString(), QStringLiteral("number")); + QCOMPARE(b_head.value("value").toDouble(), 1.0); + QVERIFY(b_props.at(1).isObject()); + QJsonObject b_tail = b_props.at(1).toObject(); + QCOMPARE(b_tail.value("name").toString(), QStringLiteral("tail")); + QVERIFY(b_tail.contains("ref")); + + QJsonObject b_tail_value = frame0.collector->lookupRef(b_tail.value("ref").toInt()); + QCOMPARE(b_tail_value.value("type").toString(), QStringLiteral("object")); + QVERIFY(b_tail_value.contains("properties")); + QJsonArray b_tail_props = b_tail_value.value("properties").toArray(); + QCOMPARE(b_tail_props.size(), 2); + QJsonObject b_tail_head = b_tail_props.at(0).toObject(); + QCOMPARE(b_tail_head.value("name").toString(), QStringLiteral("head")); + QCOMPARE(b_tail_head.value("type").toString(), QStringLiteral("string")); + QCOMPARE(b_tail_head.value("value").toString(), QStringLiteral("asdf")); + QJsonObject b_tail_tail = b_tail_props.at(1).toObject(); + QCOMPARE(b_tail_tail.value("name").toString(), QStringLiteral("tail")); + QCOMPARE(b_tail_tail.value("type").toString(), QStringLiteral("null")); + QVERIFY(b_tail_tail.value("value").isNull()); } void tst_qv4debugger::readContextInAllFrames() @@ -573,7 +606,7 @@ void tst_qv4debugger::readContextInAllFrames() " return 1;\n" // breakpoint "}\n" "fact(12);\n"; - m_debuggerAgent->addBreakPoint("readFormalsInAllFrames", 7); + debugger()->addBreakPoint("readFormalsInAllFrames", 7); evaluateJavaScript(script, "readFormalsInAllFrames"); QVERIFY(m_debuggerAgent->m_wasPaused); QCOMPARE(m_debuggerAgent->m_stackTrace.size(), 13); @@ -581,18 +614,20 @@ void tst_qv4debugger::readContextInAllFrames() QCOMPARE(m_debuggerAgent->m_capturedLocals.size(), 13); for (int i = 0; i < 12; ++i) { - QCOMPARE(m_debuggerAgent->m_capturedArguments[i].size(), 1); - QVERIFY(m_debuggerAgent->m_capturedArguments[i].contains("n")); - QCOMPARE(m_debuggerAgent->m_capturedArguments[i]["n"].type(), QVariant::Double); - QCOMPARE(m_debuggerAgent->m_capturedArguments[i]["n"].toDouble(), i + 1.0); - - QCOMPARE(m_debuggerAgent->m_capturedLocals[i].size(), 1); - QVERIFY(m_debuggerAgent->m_capturedLocals[i].contains("n_1")); + const TestAgent::NamedRefs &args = m_debuggerAgent->m_capturedArguments.at(i); + QCOMPARE(args.size(), 1); + QVERIFY(args.contains("n")); + QCOMPARE(args.type("n"), QStringLiteral("number")); + QCOMPARE(args.value("n").toDouble(), i + 1.0); + + const TestAgent::NamedRefs &locals = m_debuggerAgent->m_capturedLocals.at(i); + QCOMPARE(locals.size(), 1); + QVERIFY(locals.contains("n_1")); if (i == 0) { - QCOMPARE(m_debuggerAgent->m_capturedLocals[i]["n_1"].toString(), QString("undefined")); + QCOMPARE(locals.type("n_1"), QStringLiteral("undefined")); } else { - QCOMPARE(m_debuggerAgent->m_capturedLocals[i]["n_1"].type(), QVariant::Double); - QCOMPARE(m_debuggerAgent->m_capturedLocals[i]["n_1"].toInt(), i); + QCOMPARE(locals.type("n_1"), QStringLiteral("number")); + QCOMPARE(locals.value("n_1").toInt(), i); } } QCOMPARE(m_debuggerAgent->m_capturedArguments[12].size(), 0); @@ -606,13 +641,16 @@ void tst_qv4debugger::pauseOnThrow() " throw n\n" "}\n" "die('hard');\n"; - m_debuggerAgent->setBreakOnThrow(true); + debugger()->setBreakOnThrow(true); evaluateJavaScript(script, "pauseOnThrow"); QVERIFY(m_debuggerAgent->m_wasPaused); QCOMPARE(m_debuggerAgent->m_pauseReason, Throwing); QCOMPARE(m_debuggerAgent->m_stackTrace.size(), 2); - QCOMPARE(m_debuggerAgent->m_thrownValue.type(), QVariant::String); - QCOMPARE(m_debuggerAgent->m_thrownValue.toString(), QString("hard")); + QVERIFY(m_debuggerAgent->m_thrownValue >= qint64(0)); + QJsonObject exception = m_debuggerAgent->collector.lookupRef(m_debuggerAgent->m_thrownValue); +// DUMP_JSON(exception); + QCOMPARE(exception.value("type").toString(), QStringLiteral("string")); + QCOMPARE(exception.value("value").toString(), QStringLiteral("hard")); } void tst_qv4debugger::breakInCatch() @@ -624,12 +662,12 @@ void tst_qv4debugger::breakInCatch() " console.log(e, 'me');\n" "}\n"; - m_debuggerAgent->addBreakPoint("breakInCatch", 4); + debugger()->addBreakPoint("breakInCatch", 4); evaluateJavaScript(script, "breakInCatch"); QVERIFY(m_debuggerAgent->m_wasPaused); QCOMPARE(m_debuggerAgent->m_pauseReason, BreakPoint); QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 1); - QV4::Debugging::Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first(); + V4Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first(); QCOMPARE(state.fileName, QString("breakInCatch")); QCOMPARE(state.lineNumber, 4); } @@ -641,12 +679,12 @@ void tst_qv4debugger::breakInWith() " console.log('give the answer');\n" "}\n"; - m_debuggerAgent->addBreakPoint("breakInWith", 2); + debugger()->addBreakPoint("breakInWith", 2); evaluateJavaScript(script, "breakInWith"); QVERIFY(m_debuggerAgent->m_wasPaused); QCOMPARE(m_debuggerAgent->m_pauseReason, BreakPoint); QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 1); - QV4::Debugging::Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first(); + V4Debugger::ExecutionState state = m_debuggerAgent->m_statesWhenPaused.first(); QCOMPARE(state.fileName, QString("breakInWith")); QCOMPARE(state.lineNumber, 2); } @@ -669,13 +707,21 @@ void tst_qv4debugger::evaluateExpression() request.frameNr = 1; m_debuggerAgent->m_expressionRequests << request; - m_debuggerAgent->addBreakPoint("evaluateExpression", 3); + debugger()->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); + QCOMPARE(m_debuggerAgent->m_expressionResults[0].size(), 1); + QJsonObject result0 = + m_debuggerAgent->collector.lookupRef(m_debuggerAgent->m_expressionResults[0].first()); + QCOMPARE(result0.value("type").toString(), QStringLiteral("number")); + QCOMPARE(result0.value("value").toInt(), 10); + QCOMPARE(m_debuggerAgent->m_expressionResults[1].size(), 1); + QJsonObject result1 = + m_debuggerAgent->collector.lookupRef(m_debuggerAgent->m_expressionResults[1].first()); + QCOMPARE(result1.value("type").toString(), QStringLiteral("number")); + QCOMPARE(result1.value("value").toInt(), 20); } QTEST_MAIN(tst_qv4debugger) |