diff options
Diffstat (limited to 'tests/auto')
26 files changed, 374 insertions, 456 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 0ea9b91c2e..425e88b983 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -2,7 +2,6 @@ TEMPLATE=subdirs SUBDIRS=\ qml \ quick \ - headersclean \ particles \ qmltest \ qmldevtools \ @@ -16,4 +15,3 @@ qmldevtools.CONFIG = host_build installed_cmake.depends = cmake -testcocoon: SUBDIRS -= headersclean diff --git a/tests/auto/headersclean/headersclean.pro b/tests/auto/headersclean/headersclean.pro deleted file mode 100644 index 2698d67124..0000000000 --- a/tests/auto/headersclean/headersclean.pro +++ /dev/null @@ -1,2 +0,0 @@ -QT = qml quick qmltest -load(qt_headersclean) diff --git a/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro b/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro index 3070d33631..48e7303f86 100644 --- a/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro +++ b/tests/auto/particles/qquickcustomparticle/qquickcustomparticle.pro @@ -10,6 +10,3 @@ TESTDATA = data/* QT += core-private gui-private qml-private quick-private quickparticles-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 - -# Skip until fix from qtbase 5.4.0 reached dev. -win32: CONFIG += insignificant_test diff --git a/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro b/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro index 1f957c23ff..1cb792eff2 100644 --- a/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro +++ b/tests/auto/particles/qquicktrailemitter/qquicktrailemitter.pro @@ -3,8 +3,6 @@ TARGET = tst_qquicktrailemitter SOURCES += tst_qquicktrailemitter.cpp macx:CONFIG -= app_bundle -win32-msvc2012:CONFIG += insignificant_test # QTBUG-33421 - include (../../shared/util.pri) TESTDATA = data/* diff --git a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro index d4ce36dc4a..eb5f17a55d 100644 --- a/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro +++ b/tests/auto/qml/debugger/qqmldebugjs/qqmldebugjs.pro @@ -22,5 +22,3 @@ OTHER_FILES += data/test.qml data/test.js \ data/breakpointRelocation.qml \ data/createComponent.qml DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 - -mac:CONFIG+=insignificant_test # QTBUG-28263 diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index d34860ff62..094bf43549 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -43,6 +43,9 @@ struct QQmlProfilerData { + QQmlProfilerData(int messageType = 0, int detailType = 0, const QString &detailData = QString()) + : messageType(messageType), detailType(detailType), detailData(detailData) {} + qint64 time; int messageType; int detailType; @@ -174,9 +177,29 @@ private: QQmlDebugConnection *m_connection; QQmlProfilerClient *m_client; + enum MessageListType { + MessageListQML, + MessageListJavaScript, + MessageListJsHeap, + MessageListAsynchronous, + MessageListPixmap + }; + + enum CheckType { + CheckMessageType = 1 << 0, + CheckDetailType = 1 << 1, + CheckLine = 1 << 2, + CheckColumn = 1 << 3, + CheckDataEndsWith = 1 << 4, + + CheckAll = CheckMessageType | CheckDetailType | CheckLine | CheckColumn | CheckDataEndsWith + }; + void connect(bool block, const QString &testFile); void checkTraceReceived(); void checkJsHeap(); + bool verify(MessageListType type, int expectedPosition, const QQmlProfilerData &expected, + quint32 checks); private slots: void cleanup(); @@ -192,6 +215,8 @@ private slots: void javascript(); }; +#define VERIFY(type, position, expected, checks) QVERIFY(verify(type, position, expected, checks)) + void QQmlProfilerClient::messageReceived(const QByteArray &message) { QByteArray msg = message; @@ -355,15 +380,15 @@ void tst_QQmlProfilerService::connect(bool block, const QString &testFile) void tst_QQmlProfilerService::checkTraceReceived() { QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time."); - QVERIFY(m_client->asynchronousMessages.count()); // must start with "StartTrace" - QCOMPARE(m_client->asynchronousMessages.first().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->asynchronousMessages.first().detailType, (int)QQmlProfilerClient::StartTrace); + QQmlProfilerData expected(QQmlProfilerClient::Event, QQmlProfilerClient::StartTrace); + VERIFY(MessageListAsynchronous, 0, expected, CheckMessageType | CheckDetailType); // must end with "EndTrace" - QCOMPARE(m_client->asynchronousMessages.last().messageType, (int)QQmlProfilerClient::Event); - QCOMPARE(m_client->asynchronousMessages.last().detailType, (int)QQmlProfilerClient::EndTrace); + expected.detailType = QQmlProfilerClient::EndTrace; + VERIFY(MessageListAsynchronous, m_client->asynchronousMessages.length() - 1, expected, + CheckMessageType | CheckDetailType); } void tst_QQmlProfilerService::checkJsHeap() @@ -375,6 +400,7 @@ void tst_QQmlProfilerService::checkJsHeap() bool seen_large = false; qint64 allocated = 0; qint64 used = 0; + qint64 lastTimestamp = -1; foreach (const QQmlProfilerData &message, m_client->jsHeapMessages) { switch (message.detailType) { case QQmlProfilerClient::HeapPage: @@ -392,6 +418,17 @@ void tst_QQmlProfilerService::checkJsHeap() break; } + QVERIFY(message.time >= lastTimestamp); + // The heap will only be consistent after all events of the same timestamp are processed. + if (lastTimestamp == -1) { + lastTimestamp = message.time; + continue; + } else if (message.time == lastTimestamp) { + continue; + } + + lastTimestamp = message.time; + QVERIFY2(used >= 0, QString::fromLatin1("Negative memory usage seen: %1") .arg(used).toUtf8().constData()); @@ -408,6 +445,68 @@ void tst_QQmlProfilerService::checkJsHeap() QVERIFY2(seen_large, "No large item seen"); } +bool tst_QQmlProfilerService::verify(tst_QQmlProfilerService::MessageListType type, + int expectedPosition, const QQmlProfilerData &expected, + quint32 checks) +{ + QList<QQmlProfilerData> *target = 0; + switch (type) { + case MessageListQML: target = &(m_client->qmlMessages); break; + case MessageListJavaScript: target = &(m_client->javascriptMessages); break; + case MessageListJsHeap: target = &(m_client->jsHeapMessages); break; + case MessageListAsynchronous: target = &(m_client->asynchronousMessages); break; + case MessageListPixmap: target = &(m_client->pixmapMessages); break; + } + + if (target->length() <= expectedPosition) { + qWarning() << "Not enough events. expected position:" << expectedPosition + << "length:" << target->length(); + return false; + } + + uint position = expectedPosition; + qint64 timestamp = target->at(expectedPosition).time; + while (position > 0 && target->at(position - 1).time == timestamp) + --position; + + QStringList warnings; + + do { + const QQmlProfilerData &actual = target->at(position); + if ((checks & CheckMessageType) && actual.messageType != expected.messageType) { + warnings << QString::fromLatin1("%1: unexpected messageType. actual: %2 - expected: %3") + .arg(position).arg(actual.messageType).arg(expected.messageType); + continue; + } + if ((checks & CheckDetailType) && actual.detailType != expected.detailType) { + warnings << QString::fromLatin1("%1: unexpected detailType. actual: %2 - expected: %3") + .arg(position).arg(actual.detailType).arg(expected.detailType); + continue; + } + if ((checks & CheckLine) && actual.line != expected.line) { + warnings << QString::fromLatin1("%1: unexpected line. actual: %2 - expected: %3") + .arg(position).arg(actual.line).arg(expected.line); + continue; + } + if ((checks & CheckColumn) && actual.column != expected.column) { + warnings << QString::fromLatin1("%1: unexpected column. actual: %2 - expected: %3") + .arg(position).arg(actual.column).arg(expected.column); + continue; + } + if ((checks & CheckDataEndsWith) && !actual.detailData.endsWith(expected.detailData)) { + warnings << QString::fromLatin1("%1: unexpected detailData. actual: %2 - expected: %3") + .arg(position).arg(actual.detailData).arg(expected.detailData); + continue; + } + return true; + } while (target->at(++position).time == timestamp); + + foreach (const QString &message, warnings) + qWarning() << message.toLocal8Bit().constData(); + + return false; +} + void tst_QQmlProfilerService::cleanup() { if (QTest::currentTestFailed()) { @@ -512,27 +611,26 @@ void tst_QQmlProfilerService::pixmapCacheData() checkTraceReceived(); checkJsHeap(); - QVERIFY2(m_client->pixmapMessages.count() >= 4, - QString::number(m_client->pixmapMessages.count()).toUtf8().constData()); + + QQmlProfilerData expected(QQmlProfilerClient::PixmapCacheEvent); // image starting to load - QCOMPARE(m_client->pixmapMessages[0].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); - QCOMPARE(m_client->pixmapMessages[0].detailType, (int)QQmlProfilerClient::PixmapLoadingStarted); + expected.detailType = QQmlProfilerClient::PixmapLoadingStarted; + VERIFY(MessageListPixmap, 0, expected, CheckMessageType | CheckDetailType); // image size - QCOMPARE(m_client->pixmapMessages[1].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); - QCOMPARE(m_client->pixmapMessages[1].detailType, (int)QQmlProfilerClient::PixmapSizeKnown); - QCOMPARE(m_client->pixmapMessages[1].line, 2); // width - QCOMPARE(m_client->pixmapMessages[1].column, 2); // height + expected.detailType = QQmlProfilerClient::PixmapSizeKnown; + expected.line = expected.column = 2; // width and height, in fact + VERIFY(MessageListPixmap, 1, expected, + CheckMessageType | CheckDetailType | CheckLine | CheckColumn); // image loaded - QCOMPARE(m_client->pixmapMessages[2].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); - QCOMPARE(m_client->pixmapMessages[2].detailType, (int)QQmlProfilerClient::PixmapLoadingFinished); + expected.detailType = QQmlProfilerClient::PixmapLoadingFinished; + VERIFY(MessageListPixmap, 2, expected, CheckMessageType | CheckDetailType); // cache size - QCOMPARE(m_client->pixmapMessages[3].messageType, (int)QQmlProfilerClient::PixmapCacheEvent); - QCOMPARE(m_client->pixmapMessages[3].detailType, (int)QQmlProfilerClient::PixmapCacheCountChanged); - + expected.detailType = QQmlProfilerClient::PixmapCacheCountChanged; + VERIFY(MessageListPixmap, 3, expected, CheckMessageType | CheckDetailType); } void tst_QQmlProfilerService::scenegraphData() @@ -554,19 +652,39 @@ void tst_QQmlProfilerService::scenegraphData() // there should be a SGPolishAndSync + SGRendererFrame + SGRenderLoopFrame sequence // (though we can't be sure to get the SGRenderLoopFrame in the threaded renderer) // - // since the rendering happens in a different thread, there could be other unrelated events interleaved - int loopcheck = 0; + // since the rendering happens in a different thread, there could be other unrelated events + // interleaved. Also, events could carry the same time stamps and be sorted in an unexpected way + // if the clocks are acting up. + qint64 contextFrameTime = -1; + qint64 renderFrameTime = -1; + foreach (const QQmlProfilerData &msg, m_client->asynchronousMessages) { if (msg.messageType == QQmlProfilerClient::SceneGraphFrame) { - if (loopcheck == 0 && msg.detailType == QQmlProfilerClient::SceneGraphContextFrame) - loopcheck = 1; - else if (loopcheck == 1 && msg.detailType == QQmlProfilerClient::SceneGraphRendererFrame) - loopcheck = 2; - else if (loopcheck == 2 && msg.detailType == QQmlProfilerClient::SceneGraphRenderLoopFrame) - loopcheck = 3; + if (msg.detailType == QQmlProfilerClient::SceneGraphContextFrame) { + contextFrameTime = msg.time; + break; + } + } + } + + QVERIFY(contextFrameTime != -1); + + foreach (const QQmlProfilerData &msg, m_client->asynchronousMessages) { + if (msg.detailType == QQmlProfilerClient::SceneGraphRendererFrame) { + QVERIFY(msg.time >= contextFrameTime); + renderFrameTime = msg.time; + break; + } + } + + QVERIFY(renderFrameTime != -1); + + foreach (const QQmlProfilerData &msg, m_client->asynchronousMessages) { + if (msg.detailType == QQmlProfilerClient::SceneGraphRenderLoopFrame) { + QVERIFY(msg.time >= renderFrameTime); + break; } } - QVERIFY(loopcheck >= 2); } void tst_QQmlProfilerService::profileOnExit() @@ -605,22 +723,16 @@ void tst_QQmlProfilerService::signalSourceLocation() checkTraceReceived(); checkJsHeap(); - QVERIFY2(m_client->qmlMessages.count() >= 16, - QString::number(m_client->qmlMessages.count()).toUtf8().constData()); - - QCOMPARE(m_client->qmlMessages[13].messageType, (int)QQmlProfilerClient::RangeLocation); - QCOMPARE(m_client->qmlMessages[13].detailType, (int)QQmlProfilerClient::HandlingSignal); - QVERIFY2(m_client->qmlMessages[13].detailData.endsWith("signalSourceLocation.qml"), - m_client->qmlMessages[13].detailData.toUtf8().constData()); - QCOMPARE(m_client->qmlMessages[13].line, 8); - QCOMPARE(m_client->qmlMessages[13].column, 28); - - QCOMPARE(m_client->qmlMessages[15].messageType, (int)QQmlProfilerClient::RangeLocation); - QCOMPARE(m_client->qmlMessages[15].detailType, (int)QQmlProfilerClient::HandlingSignal); - QVERIFY2(m_client->qmlMessages[15].detailData.endsWith("signalSourceLocation.qml"), - m_client->qmlMessages[15].detailData.toUtf8().constData()); - QCOMPARE(m_client->qmlMessages[15].line, 7); - QCOMPARE(m_client->qmlMessages[15].column, 21); + QQmlProfilerData expected(QQmlProfilerClient::RangeLocation, + QQmlProfilerClient::HandlingSignal, + QLatin1String("signalSourceLocation.qml")); + expected.line = 8; + expected.column = 28; + VERIFY(MessageListQML, 13, expected, CheckAll); + + expected.line = 7; + expected.column = 21; + VERIFY(MessageListQML, 15, expected, CheckAll); } void tst_QQmlProfilerService::javascript() @@ -636,26 +748,22 @@ void tst_QQmlProfilerService::javascript() checkTraceReceived(); checkJsHeap(); - QVERIFY2(m_client->javascriptMessages.count() >= 22, - QString::number(m_client->javascriptMessages.count()).toUtf8().constData()); - - QCOMPARE(m_client->javascriptMessages[6].messageType, (int)QQmlProfilerClient::RangeStart); - QCOMPARE(m_client->javascriptMessages[6].detailType, (int)QQmlProfilerClient::Javascript); + QQmlProfilerData expected(QQmlProfilerClient::RangeStart, QQmlProfilerClient::Javascript); + VERIFY(MessageListJavaScript, 6, expected, CheckMessageType | CheckDetailType); - QCOMPARE(m_client->javascriptMessages[7].messageType, (int)QQmlProfilerClient::RangeLocation); - QCOMPARE(m_client->javascriptMessages[7].detailType, (int)QQmlProfilerClient::Javascript); - QVERIFY2(m_client->javascriptMessages[7].detailData.endsWith("javascript.qml"), - m_client->javascriptMessages[7].detailData.toUtf8().constData()); - QCOMPARE(m_client->javascriptMessages[7].line, 4); - QCOMPARE(m_client->javascriptMessages[7].column, 5); + expected.messageType = QQmlProfilerClient::RangeLocation; + expected.detailData = QLatin1String("javascript.qml"); + expected.line = 4; + expected.column = 5; + VERIFY(MessageListJavaScript, 7, expected, CheckAll); - QCOMPARE(m_client->javascriptMessages[8].messageType, (int)QQmlProfilerClient::RangeData); - QCOMPARE(m_client->javascriptMessages[8].detailType, (int)QQmlProfilerClient::Javascript); - QVERIFY2(m_client->javascriptMessages[8].detailData == "something", - m_client->javascriptMessages[8].detailData.toUtf8().constData()); + expected.messageType = QQmlProfilerClient::RangeData; + expected.detailData = QLatin1String("something"); + VERIFY(MessageListJavaScript, 8, expected, + CheckMessageType | CheckDetailType | CheckDataEndsWith); - QCOMPARE(m_client->javascriptMessages[21].messageType, (int)QQmlProfilerClient::RangeEnd); - QCOMPARE(m_client->javascriptMessages[21].detailType, (int)QQmlProfilerClient::Javascript); + expected.messageType = QQmlProfilerClient::RangeEnd; + VERIFY(MessageListJavaScript, 21, expected, CheckMessageType | CheckDetailType); } QTEST_MAIN(tst_QQmlProfilerService) diff --git a/tests/auto/qml/debugger/qv4profilerservice/data/console.qml b/tests/auto/qml/debugger/qv4profilerservice/data/console.qml deleted file mode 100644 index c23c820216..0000000000 --- a/tests/auto/qml/debugger/qv4profilerservice/data/console.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 2.0 - - -Item { - function f() - { - } - - Component.onCompleted: { - console.profile(); - f(); - console.profileEnd(); - } -} diff --git a/tests/auto/qml/debugger/qv4profilerservice/data/exit.qml b/tests/auto/qml/debugger/qv4profilerservice/data/exit.qml deleted file mode 100644 index 604265354c..0000000000 --- a/tests/auto/qml/debugger/qv4profilerservice/data/exit.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Item { - Timer { - running: true - interval: 1 - onTriggered: { - Qt.quit(); - } - } -} diff --git a/tests/auto/qml/debugger/qv4profilerservice/data/test.qml b/tests/auto/qml/debugger/qv4profilerservice/data/test.qml deleted file mode 100644 index 9c36e13c5b..0000000000 --- a/tests/auto/qml/debugger/qv4profilerservice/data/test.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 2.0 - -Item { - -} diff --git a/tests/auto/qml/debugger/qv4profilerservice/qv4profilerservice.pro b/tests/auto/qml/debugger/qv4profilerservice/qv4profilerservice.pro deleted file mode 100644 index 459f931f94..0000000000 --- a/tests/auto/qml/debugger/qv4profilerservice/qv4profilerservice.pro +++ /dev/null @@ -1,16 +0,0 @@ -CONFIG += testcase -TARGET = tst_qv4profilerservice -macx:CONFIG -= app_bundle - -SOURCES += tst_qv4profilerservice.cpp - -INCLUDEPATH += ../shared -include(../../../shared/util.pri) -include(../shared/debugutil.pri) - -TESTDATA = data/* - -QT += qml testlib gui-private - -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 -CONFIG+=insignificant_test diff --git a/tests/auto/qml/debugger/qv4profilerservice/tst_qv4profilerservice.cpp b/tests/auto/qml/debugger/qv4profilerservice/tst_qv4profilerservice.cpp deleted file mode 100644 index 47c2ffe74f..0000000000 --- a/tests/auto/qml/debugger/qv4profilerservice/tst_qv4profilerservice.cpp +++ /dev/null @@ -1,326 +0,0 @@ -/**************************************************************************** -** -** 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 <QLibraryInfo> - -#include "debugutil_p.h" -#include "qqmldebugclient.h" -#include "../../../shared/util.h" - -#define STR_PORT_FROM "13774" -#define STR_PORT_TO "13790" - -struct QV4ProfilerData -{ - int messageType; - QString filename; - QString functionname; - int lineNumber; - double totalTime; - double selfTime; - int treeLevel; - - QByteArray toByteArray() const; -}; - -class QV4ProfilerClient : public QQmlDebugClient -{ - Q_OBJECT - -public: - enum MessageType { - V4Entry, - V4Complete, - V4SnapshotChunk, - V4SnapshotComplete, - V4Started, - - V4MaximumMessage - }; - - enum ServiceState { NotRunning, Running } serviceState; - - QV4ProfilerClient(QQmlDebugConnection *connection) - : QQmlDebugClient(QLatin1String("V8Profiler"), connection) - , serviceState(NotRunning) - { - } - - void startProfiling(const QString &name) { - QByteArray message; - QDataStream stream(&message, QIODevice::WriteOnly); - stream << QByteArray("V8PROFILER") << QByteArray("start") << name; - sendMessage(message); - } - - void stopProfiling(const QString &name) { - QByteArray message; - QDataStream stream(&message, QIODevice::WriteOnly); - stream << QByteArray("V8PROFILER") << QByteArray("stop") << name; - sendMessage(message); - } - - void takeSnapshot() { - QByteArray message; - QDataStream stream(&message, QIODevice::WriteOnly); - stream << QByteArray("V8SNAPSHOT") << QByteArray("full"); - sendMessage(message); - } - - void deleteSnapshots() { - QByteArray message; - QDataStream stream(&message, QIODevice::WriteOnly); - stream << QByteArray("V8SNAPSHOT") << QByteArray("delete"); - sendMessage(message); - } - - QList<QV4ProfilerData> traceMessages; - QList<QByteArray> snapshotMessages; - -signals: - void started(); - void complete(); - void snapshot(); - -protected: - void messageReceived(const QByteArray &message); -}; - -class tst_QV4ProfilerService : public QQmlDataTest -{ - Q_OBJECT - -public: - tst_QV4ProfilerService() - : m_process(0) - , m_connection(0) - , m_client(0) - { - } - -private: - QQmlDebugProcess *m_process; - QQmlDebugConnection *m_connection; - QV4ProfilerClient *m_client; - - bool connect(bool block, const QString &testFile, QString *error); - -private slots: - void cleanup(); - - void blockingConnectWithTraceEnabled(); - void blockingConnectWithTraceDisabled(); - void nonBlockingConnect(); - void snapshot(); - void profileOnExit(); - void console(); -}; - -void QV4ProfilerClient::messageReceived(const QByteArray &message) -{ - QByteArray msg = message; - QDataStream stream(&msg, QIODevice::ReadOnly); - - int messageType; - stream >> messageType; - - QVERIFY(messageType >= 0); - QVERIFY(messageType < QV4ProfilerClient::V4MaximumMessage); - - switch (messageType) { - case QV4ProfilerClient::V4Entry: { - QCOMPARE(serviceState, Running); - QV4ProfilerData entry; - stream >> entry.filename >> entry.functionname >> entry.lineNumber >> entry.totalTime >> entry.selfTime >> entry.treeLevel; - traceMessages.append(entry); - break; - } - case QV4ProfilerClient::V4Complete: - QCOMPARE(serviceState, Running); - serviceState = NotRunning; - emit complete(); - break; - case QV4ProfilerClient::V4SnapshotChunk: { - QByteArray json; - stream >> json; - snapshotMessages.append(json); - break; - } - case QV4ProfilerClient::V4SnapshotComplete: - emit snapshot(); - break; - case QV4ProfilerClient::V4Started: - QCOMPARE(serviceState, NotRunning); - serviceState = Running; - emit started(); - break; - default: - QString failMessage = QString("Unknown message type: %1").arg(messageType); - QFAIL(qPrintable(failMessage)); - } - - QVERIFY(stream.atEnd()); -} - -bool tst_QV4ProfilerService::connect(bool block, const QString &testFile, - QString *error) -{ - const QString executable = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qml"; - 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); - - m_connection = new QQmlDebugConnection(); - m_client = new QV4ProfilerClient(m_connection); - - m_process = new QQmlDebugProcess(executable); - m_process->start(QStringList() << arguments); - if (!m_process->waitForSessionStart()) { - *error = QLatin1String("Could not launch application, or did not get 'Waiting for connection'."); - return false; - } - - m_connection->connectToHost(QLatin1String("127.0.0.1"), m_process->debugPort()); - if (!m_connection->waitForConnected()) { - *error = QLatin1String("Could not connect to debugger port."); - return false; - } - return true; -} - -void tst_QV4ProfilerService::cleanup() -{ - if (QTest::currentTestFailed()) { - qDebug() << "Process State:" << m_process->state(); - qDebug() << "Application Output:" << m_process->output(); - } - delete m_client; - delete m_process; - delete m_connection; -} - -void tst_QV4ProfilerService::blockingConnectWithTraceEnabled() -{ - QString error; - if (!connect(true, "test.qml", &error)) - QFAIL(qPrintable(error)); - - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); - - m_client->startProfiling(""); - m_client->stopProfiling(""); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), - "No trace received in time."); -} - -void tst_QV4ProfilerService::blockingConnectWithTraceDisabled() -{ - QString error; - if (!connect(true, "test.qml", &error)) - QFAIL(qPrintable(error)); - - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); - - m_client->stopProfiling(""); - QVERIFY2(!QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete()), 1000), - "Unexpected trace received."); - m_client->startProfiling(""); - m_client->stopProfiling(""); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), - "No trace received in time."); -} - -void tst_QV4ProfilerService::nonBlockingConnect() -{ - QString error; - if (!connect(false, "test.qml", &error)) - QFAIL(qPrintable(error)); - - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); - - m_client->startProfiling(""); - m_client->stopProfiling(""); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), - "No trace received in time."); -} - -void tst_QV4ProfilerService::snapshot() -{ - QString error; - if (!connect(false, "test.qml", &error)) - QFAIL(qPrintable(error)); - - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); - - m_client->takeSnapshot(); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(snapshot())), - "No trace received in time."); -} - -void tst_QV4ProfilerService::profileOnExit() -{ - QString error; - if (!connect(true, "exit.qml", &error)) - QFAIL(qPrintable(error)); - - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); - - m_client->startProfiling(""); - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), - "No trace received in time."); -} - -void tst_QV4ProfilerService::console() -{ - QString error; - if (!connect(true, "console.qml", &error)) - QFAIL(qPrintable(error)); - - QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled); - - m_client->stopProfiling(""); - - QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), - "No trace received in time."); - QVERIFY(!m_client->traceMessages.isEmpty()); -} - -QTEST_MAIN(tst_QV4ProfilerService) - -#include "tst_qv4profilerservice.moc" diff --git a/tests/auto/quick/qquickanimations/BLACKLIST b/tests/auto/quick/qquickanimations/BLACKLIST new file mode 100644 index 0000000000..e45c141d17 --- /dev/null +++ b/tests/auto/quick/qquickanimations/BLACKLIST @@ -0,0 +1,40 @@ +# QTBUG-45466 QTBUG-29062 +[simpleProperty] +osx-10.9 developer-build +[badTypes] +windows msvc-2010 32bit developer-build +[mixedTypes] +windows msvc-2010 32bit developer-build +[properties] +windows msvc-2010 32bit developer-build +[propertiesTransition] +windows msvc-2010 32bit developer-build +[pathTransition] +windows msvc-2010 32bit developer-build +[disabledTransition] +windows msvc-2010 32bit developer-build +[rotation] +windows msvc-2010 32bit developer-build +[startStopSignals] +windows msvc-2010 32bit developer-build +[runningTrueBug] +windows msvc-2010 32bit developer-build +[nonTransitionBug] +windows msvc-2010 32bit developer-build +[registrationBug] +windows msvc-2010 32bit developer-build +[alwaysRunToEndRestartBug] +windows msvc-2010 32bit developer-build +[loopingBug] +windows msvc-2010 32bit developer-build +[pathAnimationInOutBackBug] +windows msvc-2010 32bit developer-build +[reparent] +windows msvc-2012 64bit developer-build +windows msvc-2010 32bit developer-build +[simpleAnchor] +windows msvc-2010 32bit developer-build +[simplePath] +windows gcc developer-build +windows msvc-2010 32bit developer-build + diff --git a/tests/auto/quick/qquickanimations/qquickanimations.pro b/tests/auto/quick/qquickanimations/qquickanimations.pro index f3e1cd082f..dc8f471259 100644 --- a/tests/auto/quick/qquickanimations/qquickanimations.pro +++ b/tests/auto/quick/qquickanimations/qquickanimations.pro @@ -1,5 +1,4 @@ CONFIG += testcase -win32-g++|mac:CONFIG+=insignificant_test # QTBUG-29062 TARGET = tst_qquickanimations SOURCES += tst_qquickanimations.cpp diff --git a/tests/auto/quick/qquickflickable/BLACKLIST b/tests/auto/quick/qquickflickable/BLACKLIST new file mode 100644 index 0000000000..92ed8708de --- /dev/null +++ b/tests/auto/quick/qquickflickable/BLACKLIST @@ -0,0 +1,19 @@ +# QTBUG-36804 +osx-10.10 +[rebound] +osx-10.10 +[movingAndFlicking:vertical] +osx-10.10 +[movingAndFlicking:both] +osx-10.10 +[movingAndFlicking:horizontal] +osx-10.10 +[stopAtBounds] +osx-10.10 +windows 32bit developer-build +[returnToBounds] +osx +[pressWhileFlicking] +osx-10.10 +[flickVelocity] +osx-10.10 diff --git a/tests/auto/quick/qquickflickable/qquickflickable.pro b/tests/auto/quick/qquickflickable/qquickflickable.pro index 81b2b1a00c..88dc2fbc2a 100644 --- a/tests/auto/quick/qquickflickable/qquickflickable.pro +++ b/tests/auto/quick/qquickflickable/qquickflickable.pro @@ -11,4 +11,3 @@ TESTDATA = data/* QT += core-private gui-private qml-private quick-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 -macx:CONFIG+=insignificant_test diff --git a/tests/auto/quick/qquickgridview/qquickgridview.pro b/tests/auto/quick/qquickgridview/qquickgridview.pro index 40b43fa2c0..3b98ed4dea 100644 --- a/tests/auto/quick/qquickgridview/qquickgridview.pro +++ b/tests/auto/quick/qquickgridview/qquickgridview.pro @@ -12,7 +12,4 @@ TESTDATA = data/* QT += core-private gui-private qml-private quick-private testlib -win32:CONFIG += insignificant_test # QTBUG-33017 -macx:CONFIG += insignificant_test # QTBUG-33017 - DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/quick/qquickitem/data/contains.qml b/tests/auto/quick/qquickitem/data/contains.qml new file mode 100644 index 0000000000..72fd8bdc91 --- /dev/null +++ b/tests/auto/quick/qquickitem/data/contains.qml @@ -0,0 +1,26 @@ +import QtQuick 2.3 + +Item { + id: root + width: 300 + height: 300 + + function childContainsViaMapToItem(x, y) { + var childLocalPos = root.mapToItem(child, x, y); + return child.contains(childLocalPos); + } + + function childContainsViaMapFromItem(x, y) { + var childLocalPos = child.mapFromItem(root, x, y); + return child.contains(childLocalPos); + } + + Item { + id: child + x: 50 + y: 50 + width: 50 + height: 50 + } +} + diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index 832cbab971..c79af91747 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -169,6 +169,9 @@ private slots: void objectChildTransform(); + void contains_data(); + void contains(); + private: enum PaintOrderOp { @@ -1927,6 +1930,48 @@ void tst_qquickitem::objectChildTransform() // Shouldn't crash. } +void tst_qquickitem::contains_data() +{ + QTest::addColumn<int>("x"); + QTest::addColumn<int>("y"); + QTest::addColumn<bool>("contains"); + + QTest::newRow("(0, 0) = false") << 0 << 0 << false; + QTest::newRow("(50, 0) = false") << 50 << 0 << false; + QTest::newRow("(0, 50) = false") << 0 << 50 << false; + QTest::newRow("(50, 50) = true") << 50 << 50 << true; + QTest::newRow("(100, 100) = true") << 100 << 100 << true; + QTest::newRow("(150, 150) = false") << 150 << 150 << false; +} + +void tst_qquickitem::contains() +{ + // Tests that contains works, but also checks that mapToItem/mapFromItem + // return the correct type (point or rect, not a JS object with those properties), + // as this is a common combination of calls. + + QFETCH(int, x); + QFETCH(int, y); + QFETCH(bool, contains); + + QQuickView view; + view.setSource(testFileUrl("contains.qml")); + + QQuickItem *root = qobject_cast<QQuickItem*>(view.rootObject()); + QVERIFY(root); + + QVariant result = false; + QVERIFY(QMetaObject::invokeMethod(root, "childContainsViaMapToItem", + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, qreal(x)), Q_ARG(QVariant, qreal(y)))); + QCOMPARE(result.toBool(), contains); + + result = false; + QVERIFY(QMetaObject::invokeMethod(root, "childContainsViaMapFromItem", + Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, qreal(x)), Q_ARG(QVariant, qreal(y)))); + QCOMPARE(result.toBool(), contains); +} + + QTEST_MAIN(tst_qquickitem) #include "tst_qquickitem.moc" diff --git a/tests/auto/quick/qquickloader/qquickloader.pro b/tests/auto/quick/qquickloader/qquickloader.pro index 88de3c4c60..567917877c 100644 --- a/tests/auto/quick/qquickloader/qquickloader.pro +++ b/tests/auto/quick/qquickloader/qquickloader.pro @@ -14,4 +14,3 @@ TESTDATA = data/* QT += core-private gui-private qml-private quick-private network testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 -CONFIG+=insignificant_test # QTBUG-30721 diff --git a/tests/auto/quick/qquickpathview/qquickpathview.pro b/tests/auto/quick/qquickpathview/qquickpathview.pro index 8d729fd7c4..e6cf9a488f 100644 --- a/tests/auto/quick/qquickpathview/qquickpathview.pro +++ b/tests/auto/quick/qquickpathview/qquickpathview.pro @@ -12,5 +12,3 @@ TESTDATA = data/* QT += core-private gui-private qml-private quick-private testlib qtHaveModule(widgets): QT += widgets DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 - -macx:CONFIG += insignificant_test # QTBUG-27740 diff --git a/tests/auto/quick/qquickstates/data/revertListMemoryLeak.qml b/tests/auto/quick/qquickstates/data/revertListMemoryLeak.qml new file mode 100644 index 0000000000..b49487c895 --- /dev/null +++ b/tests/auto/quick/qquickstates/data/revertListMemoryLeak.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Item { + id: rect + width: 40; + property real boundHeight: 42 + height: boundHeight; + + states: [ + State { + objectName: "testState" + name: "testState" + PropertyChanges { target: rect; height: 60; } + } + ] +} diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp index 51fe9b4c96..6c42a7a0ee 100644 --- a/tests/auto/quick/qquickstates/tst_qquickstates.cpp +++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp @@ -141,6 +141,7 @@ private slots: void avoidFastForward(); void revertListBug(); void QTBUG_38492(); + void revertListMemoryLeak(); }; void tst_qquickstates::initTestCase() @@ -1634,6 +1635,30 @@ void tst_qquickstates::QTBUG_38492() delete item; } +void tst_qquickstates::revertListMemoryLeak() +{ + QWeakPointer<QQmlAbstractBinding> weakPtr; + { + QQmlEngine engine; + + QQmlComponent c(&engine, testFileUrl("revertListMemoryLeak.qml")); + QQuickItem *item = qobject_cast<QQuickItem *>(c.create()); + QVERIFY(item); + QQuickState *state = item->findChild<QQuickState*>("testState"); + QVERIFY(state); + + item->setState("testState"); + + QQmlAbstractBinding *binding = state->bindingInRevertList(item, "height"); + QVERIFY(binding); + weakPtr = QQmlAbstractBinding::getPointer(binding); + QVERIFY(!weakPtr.toStrongRef().isNull()); + + delete item; + } + QVERIFY(weakPtr.toStrongRef().isNull()); +} + QTEST_MAIN(tst_qquickstates) #include "tst_qquickstates.moc" diff --git a/tests/auto/quick/qquicktext/qquicktext.pro b/tests/auto/quick/qquicktext/qquicktext.pro index c25a27b745..ee0a9be776 100644 --- a/tests/auto/quick/qquicktext/qquicktext.pro +++ b/tests/auto/quick/qquicktext/qquicktext.pro @@ -14,5 +14,3 @@ TESTDATA = data/* QT += core-private gui-private qml-private quick-private network testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 - -mac:CONFIG += insignificant_test # QTBUG-27740 diff --git a/tests/auto/quick/qquicktextedit/qquicktextedit.pro b/tests/auto/quick/qquicktextedit/qquicktextedit.pro index 2386d713a7..2a6d753536 100644 --- a/tests/auto/quick/qquicktextedit/qquicktextedit.pro +++ b/tests/auto/quick/qquicktextedit/qquicktextedit.pro @@ -14,6 +14,3 @@ TESTDATA = data/* QT += core-private gui-private qml-private quick-private network-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 - -mac:CONFIG += insignificant_test # QTBUG-27740 -win32:CONFIG += insignificant_test # QTBUG-32540 diff --git a/tests/auto/quick/qquickwindow/BLACKLIST b/tests/auto/quick/qquickwindow/BLACKLIST index 331f736013..8a19a679a3 100644 --- a/tests/auto/quick/qquickwindow/BLACKLIST +++ b/tests/auto/quick/qquickwindow/BLACKLIST @@ -1,2 +1,4 @@ [cursor] * +[testWindowVisibilityOrder] +osx diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index 1d9e40011d..3da920ca27 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -58,6 +58,7 @@ private slots: void errors(); void engine(); void readback(); + void renderingSignals(); }; @@ -259,6 +260,38 @@ void tst_qquickwidget::readback() QCOMPARE(pix, qRgb(255, 0, 0)); } +void tst_qquickwidget::renderingSignals() +{ + QQuickWidget widget; + QQuickWindow *window = widget.quickWindow(); + QVERIFY(window); + + QSignalSpy beforeRenderingSpy(window, &QQuickWindow::beforeRendering); + QSignalSpy beforeSyncSpy(window, &QQuickWindow::beforeSynchronizing); + QSignalSpy afterRenderingSpy(window, &QQuickWindow::afterRendering); + + QVERIFY(beforeRenderingSpy.isValid()); + QVERIFY(beforeSyncSpy.isValid()); + QVERIFY(afterRenderingSpy.isValid()); + + QCOMPARE(beforeRenderingSpy.size(), 0); + QCOMPARE(beforeSyncSpy.size(), 0); + QCOMPARE(afterRenderingSpy.size(), 0); + + widget.setSource(testFileUrl("rectangle.qml")); + + QCOMPARE(beforeRenderingSpy.size(), 0); + QCOMPARE(beforeSyncSpy.size(), 0); + QCOMPARE(afterRenderingSpy.size(), 0); + + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget, 5000)); + + QTRY_VERIFY(beforeRenderingSpy.size() > 0); + QTRY_VERIFY(beforeSyncSpy.size() > 0); + QTRY_VERIFY(afterRenderingSpy.size() > 0); +} + QTEST_MAIN(tst_qquickwidget) #include "tst_qquickwidget.moc" |