diff options
Diffstat (limited to 'tests/auto/qml')
75 files changed, 2306 insertions, 1011 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..5a08418be1 100644 --- a/tests/auto/qml/debugger/debugger.pro +++ b/tests/auto/qml/debugger/debugger.pro @@ -12,6 +12,7 @@ PUBLICTESTS += \ 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/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/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/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/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 5a9d6d20eb..4c7dba9f90 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -336,7 +336,7 @@ void tst_QJSEngine::constructWithParent() QJSEngine *engine = new QJSEngine(&obj); ptr = engine; } - QVERIFY(ptr == 0); + QVERIFY(ptr.isNull()); } void tst_QJSEngine::newObject() @@ -631,7 +631,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 +641,7 @@ void tst_QJSEngine::newQObject_ownership() } QObject *before = ptr; eng.collectGarbage(); - QVERIFY(ptr == before); + QCOMPARE(ptr.data(), before); delete ptr; } { @@ -662,7 +662,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 +1258,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 +1273,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 +1285,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 +1472,7 @@ void tst_QJSEngine::collectGarbage() eng.collectGarbage(); if (ptr) QGuiApplication::sendPostedEvents(ptr, QEvent::DeferredDelete); - QVERIFY(ptr == 0); + QVERIFY(ptr.isNull()); } void tst_QJSEngine::gcWithNestedDataStructure() diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index d608379d52..bea44cb6e3 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); @@ -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 430a90b800..b61eca730f 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,7 @@ qtHaveModule(widgets) { SUBDIRS += $$PUBLICTESTS SUBDIRS += $$METATYPETESTS -!winrt: SUBDIRS += debugger # no QProcess on winrt +!winrt:!contains(QT_CONFIG, no-qml-debug): SUBDIRS += debugger # no QProcess on winrt contains(QT_CONFIG, private_tests) { SUBDIRS += $$PRIVATETESTS 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/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..222e594d1a 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -521,7 +521,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 +531,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 +885,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 +908,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 +932,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 +941,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 +995,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 +1459,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 +1470,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 +1482,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 +1498,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 +1680,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 +1691,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 +1702,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 +1750,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 +1846,7 @@ void tst_qqmlecmascript::uncreatableExtendedObjectFailureCheck() QQmlComponent component(&engine, testFileUrl("uncreatableExtendedObjectFailureCheck.qml")); QObject *object = component.create(); - QVERIFY(object == 0); + QVERIFY(!object); } /* @@ -2235,7 +2235,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 +2993,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 +3260,7 @@ void tst_qqmlecmascript::ownership() QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCoreApplication::processEvents(); - QVERIFY(own.object == 0); + QVERIFY(own.object.isNull()); delete object; } @@ -3319,7 +3319,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 +3347,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 +3364,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 +3446,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 +3863,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 +3920,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 +3929,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 +3941,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 +3957,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); } } @@ -4232,7 +4232,7 @@ void tst_qqmlecmascript::importScripts() QObject *object = component.create(); if (!errorMessage.isEmpty()) { - QVERIFY(object == 0); + QVERIFY(!object); } else { QVERIFY(object != 0); @@ -4685,7 +4685,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 +4693,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 +4701,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 +4709,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 +5007,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 +5709,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 +5754,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 +5808,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 +5855,7 @@ void tst_qqmlecmascript::canAssignNullToQObject() o->setProperty("runTest", true); - QVERIFY(o->objectProperty() == 0); + QVERIFY(!o->objectProperty()); delete o; } @@ -5859,7 +5866,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 +6071,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 +6115,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 +6139,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 +6147,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 +6691,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 +7039,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; } @@ -7344,7 +7351,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 +7367,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 +7388,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 +7485,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 +7498,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 +7618,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 +7672,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 +7684,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 +7695,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 +7705,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 +7715,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() diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index eac648ef15..cb911d0115 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -90,7 +90,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 +119,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 +185,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 +201,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 +215,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 +447,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 +471,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; 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..4f559b0d33 100644 --- a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp +++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp @@ -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/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/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 08da779d90..97501118dd 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(); @@ -328,7 +333,7 @@ void tst_qqmllanguage::insertedSemicolon() if(create) { QObject *object = component.create(); - QVERIFY(object == 0); + QVERIFY(!object); } VERIFY_ERRORS(errorFile.toLatin1().constData()); @@ -550,7 +555,7 @@ void tst_qqmllanguage::errors() if (create) { QObject *object = component.create(); - QVERIFY(object == 0); + QVERIFY(!object); } VERIFY_ERRORS(errorFile.toLatin1().constData()); @@ -580,7 +585,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 +594,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 +635,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 +727,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 +1175,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 +1264,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 +1368,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 +1677,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 +1707,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 +1716,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 +2122,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 @@ -3250,7 +3266,7 @@ void tst_qqmllanguage::registrationOrder() QObject *o = component.create(); QVERIFY(o != 0); - QVERIFY(o->metaObject() == &MyVersion2Class::staticMetaObject); + QCOMPARE(o->metaObject(), &MyVersion2Class::staticMetaObject); delete o; } @@ -3644,7 +3660,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 +3709,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 +3735,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 +3761,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 +3787,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 @@ -3995,7 +4011,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); } diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 4d76fc4fba..5c252013ea 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -642,7 +642,7 @@ void tst_qqmllistmodel::enumerate() } } - QVERIFY(matchCount == expectedStringCount); + QCOMPARE(matchCount, expectedStringCount); delete item; } @@ -1296,7 +1296,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 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..ba3f72f2c1 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()); 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/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/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index a8b06ffa71..d6b1c86b88 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -159,10 +159,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 +188,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 +255,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 +293,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 +408,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 +439,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 +455,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 +488,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 +511,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 +542,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 +558,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 +591,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 +608,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 +641,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 +657,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 +690,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 +712,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 +743,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 +759,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 +792,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 +815,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 +846,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 +862,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 +895,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 +912,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 +945,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 +961,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 +994,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 +1146,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 +1158,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 +1203,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 +1217,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 +1227,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 +1337,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 +1351,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 +1643,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 +1659,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(); 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/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index f93190cab6..c8107e58bf 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -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..47bf151a37 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() @@ -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..dc6e2fa561 100644 --- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -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..7772d16234 100644 --- a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp @@ -32,12 +32,15 @@ ****************************************************************************/ #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> using namespace QV4; using namespace QV4::Debugging; @@ -85,99 +88,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(QV4::Debugging::Debugger *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() == QV4::Debugging::Debugger::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,11 +183,13 @@ public: m_stackTrace = debugger->stackTrace(); while (!m_expressionRequests.isEmpty()) { + Q_ASSERT(debugger->state() == QV4::Debugging::Debugger::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) @@ -199,15 +198,7 @@ public: debugger->resume(Debugger::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) {} @@ -219,37 +210,49 @@ public: void captureContextInfo(Debugger *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(QV4::Debugging::Debugger *debugger) + { + Q_ASSERT(!m_debugger); + m_debugger = debugger; + connect(m_debugger, + SIGNAL(debuggerPaused(QV4::Debugging::Debugger*,QV4::Debugging::PauseReason)), + this, + SLOT(debuggerPaused(QV4::Debugging::Debugger*,QV4::Debugging::PauseReason))); + } + bool m_wasPaused; PauseReason m_pauseReason; bool m_captureContextInfo; QList<Debugger::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; + QV4::Debugging::Debugger *m_debugger; // Utility methods: void dumpStackTrace() const @@ -315,7 +318,7 @@ void tst_qv4debugger::init() m_v4->enableDebugger(); m_engine->moveToThread(m_javaScriptThread); m_javaScriptThread->start(); - m_debuggerAgent = new TestAgent; + m_debuggerAgent = new TestAgent(m_v4); m_debuggerAgent->addDebugger(m_v4->debugger); } @@ -327,7 +330,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 +340,7 @@ void tst_qv4debugger::breakAnywhere() "var i = 42;\n" "var j = i + 1\n" "var k = i\n"; - m_debuggerAgent->pauseAll(); + m_v4->debugger->pause(); evaluateJavaScript(script, "testFile"); QVERIFY(m_debuggerAgent->m_wasPaused); } @@ -349,7 +351,7 @@ void tst_qv4debugger::pendingBreakpoint() "var i = 42;\n" "var j = i + 1\n" "var k = i\n"; - m_debuggerAgent->addBreakPoint("testfile", 2); + m_v4->debugger->addBreakPoint("testfile", 2); evaluateJavaScript(script, "testfile"); QVERIFY(m_debuggerAgent->m_wasPaused); QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 1); @@ -365,7 +367,7 @@ void tst_qv4debugger::liveBreakPoint() "var j = i + 1\n" "var k = i\n"; m_debuggerAgent->m_breakPointsToAddWhenPaused << TestAgent::TestBreakPoint("liveBreakPoint", 3); - m_debuggerAgent->pauseAll(); + m_v4->debugger->pause(); evaluateJavaScript(script, "liveBreakPoint"); QVERIFY(m_debuggerAgent->m_wasPaused); QCOMPARE(m_debuggerAgent->m_statesWhenPaused.count(), 2); @@ -380,8 +382,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); + m_v4->debugger->addBreakPoint("removePendingBreakPoint", 2); + m_v4->debugger->removeBreakPoint("removePendingBreakPoint", 2); evaluateJavaScript(script, "removePendingBreakPoint"); QVERIFY(!m_debuggerAgent->m_wasPaused); } @@ -392,7 +394,7 @@ void tst_qv4debugger::addBreakPointWhilePaused() "var i = 42;\n" "var j = i + 1\n" "var k = i\n"; - m_debuggerAgent->addBreakPoint("addBreakPointWhilePaused", 1); + m_v4->debugger->addBreakPoint("addBreakPointWhilePaused", 1); m_debuggerAgent->m_breakPointsToAddWhenPaused << TestAgent::TestBreakPoint("addBreakPointWhilePaused", 2); evaluateJavaScript(script, "addBreakPointWhilePaused"); QVERIFY(m_debuggerAgent->m_wasPaused); @@ -422,7 +424,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); + m_v4->debugger->addBreakPoint("removeBreakPointForNextInstruction", 2); evaluateJavaScript(script, "removeBreakPointForNextInstruction"); QVERIFY(!m_debuggerAgent->m_wasPaused); @@ -439,16 +441,19 @@ void tst_qv4debugger::conditionalBreakPoint() "}\n" "test()\n"; - m_debuggerAgent->addBreakPoint("conditionalBreakPoint", 3, /*enabled*/true, QStringLiteral("i > 10")); + m_v4->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(); 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() @@ -459,7 +464,7 @@ void tst_qv4debugger::conditionalBreakPointInQml() QScopedPointer<QThread> debugThread(new QThread); debugThread->start(); - QScopedPointer<TestAgent> debuggerAgent(new TestAgent); + QScopedPointer<TestAgent> debuggerAgent(new TestAgent(v4)); debuggerAgent->addDebugger(v4->debugger); debuggerAgent->moveToThread(debugThread.data()); @@ -474,7 +479,7 @@ void tst_qv4debugger::conditionalBreakPointInQml() " }\n" "}\n", QUrl("test.qml")); - debuggerAgent->addBreakPoint("test.qml", 7, /*enabled*/true, "root.foo == 42"); + v4->debugger->addBreakPoint("test.qml", 7, "root.foo == 42"); QScopedPointer<QObject> obj(component.create()); QCOMPARE(obj->property("success").toBool(), true); @@ -496,16 +501,18 @@ void tst_qv4debugger::readArguments() "}\n" "var four;\n" "f(1, 'two', null, four);\n"; - m_debuggerAgent->addBreakPoint("readArguments", 2); + m_v4->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 +525,17 @@ void tst_qv4debugger::readLocals() " return c === d\n" "}\n" "f(1, 2, 3);\n"; - m_debuggerAgent->addBreakPoint("readLocals", 3); + m_v4->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 +547,43 @@ void tst_qv4debugger::readObject() " return b\n" "}\n" "f({head: 1, tail: { head: 'asdf', tail: null }});\n"; - m_debuggerAgent->addBreakPoint("readObject", 3); + m_v4->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 +599,7 @@ void tst_qv4debugger::readContextInAllFrames() " return 1;\n" // breakpoint "}\n" "fact(12);\n"; - m_debuggerAgent->addBreakPoint("readFormalsInAllFrames", 7); + m_v4->debugger->addBreakPoint("readFormalsInAllFrames", 7); evaluateJavaScript(script, "readFormalsInAllFrames"); QVERIFY(m_debuggerAgent->m_wasPaused); QCOMPARE(m_debuggerAgent->m_stackTrace.size(), 13); @@ -581,18 +607,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 +634,16 @@ void tst_qv4debugger::pauseOnThrow() " throw n\n" "}\n" "die('hard');\n"; - m_debuggerAgent->setBreakOnThrow(true); + m_v4->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,7 +655,7 @@ void tst_qv4debugger::breakInCatch() " console.log(e, 'me');\n" "}\n"; - m_debuggerAgent->addBreakPoint("breakInCatch", 4); + m_v4->debugger->addBreakPoint("breakInCatch", 4); evaluateJavaScript(script, "breakInCatch"); QVERIFY(m_debuggerAgent->m_wasPaused); QCOMPARE(m_debuggerAgent->m_pauseReason, BreakPoint); @@ -641,7 +672,7 @@ void tst_qv4debugger::breakInWith() " console.log('give the answer');\n" "}\n"; - m_debuggerAgent->addBreakPoint("breakInWith", 2); + m_v4->debugger->addBreakPoint("breakInWith", 2); evaluateJavaScript(script, "breakInWith"); QVERIFY(m_debuggerAgent->m_wasPaused); QCOMPARE(m_debuggerAgent->m_pauseReason, BreakPoint); @@ -669,13 +700,21 @@ void tst_qv4debugger::evaluateExpression() request.frameNr = 1; m_debuggerAgent->m_expressionRequests << request; - m_debuggerAgent->addBreakPoint("evaluateExpression", 3); + m_v4->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) |