aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAurindam Jana <aurindam.jana@nokia.com>2011-11-08 11:47:33 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-09 16:18:51 +0100
commitf161773a0221393192b20bab25c62a8645e6cdd4 (patch)
treec516d38849de8c9f88a93f7a1720856f4fec2de2 /tests
parent88bce0425979f80439d03862d49ef81a9422c5cf (diff)
QDeclarativeDebug: Add a debug message service.
QDeclarativeDebugMsgService installs a QtMsgHandler which forwards debug output to a client defined port only if the service is Enabled. It also forwards the debug output to the previous message handler. Effectively, this service just eavesdrop on debug output, forwarding it to a port only if a client is connected. Change-Id: Ie0ee7bab57ef8f03a2de34d91921f054a7ec147f Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/debugger/debugger.pro3
-rw-r--r--tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml51
-rw-r--r--tests/auto/declarative/debugger/qdebugmessageservice/qdebugmessageservice.pro21
-rw-r--r--tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp186
4 files changed, 260 insertions, 1 deletions
diff --git a/tests/auto/declarative/debugger/debugger.pro b/tests/auto/declarative/debugger/debugger.pro
index bdcb528c07..6d7548cec8 100644
--- a/tests/auto/declarative/debugger/debugger.pro
+++ b/tests/auto/declarative/debugger/debugger.pro
@@ -8,7 +8,8 @@ PRIVATETESTS += \
qdeclarativeinspector \
qdeclarativedebugtrace \
qpacketprotocol \
- qv8profilerservice
+ qv8profilerservice \
+ qdebugmessageservice
contains(QT_CONFIG, private_tests) {
SUBDIRS += $$PRIVATETESTS
diff --git a/tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml b/tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml
new file mode 100644
index 0000000000..7377d4584c
--- /dev/null
+++ b/tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ width: 360
+ height: 360
+ Timer {
+ interval: 100; running: true; repeat: true
+ onTriggered: console.log("Timer")
+ }
+}
diff --git a/tests/auto/declarative/debugger/qdebugmessageservice/qdebugmessageservice.pro b/tests/auto/declarative/debugger/qdebugmessageservice/qdebugmessageservice.pro
new file mode 100644
index 0000000000..698e9604f0
--- /dev/null
+++ b/tests/auto/declarative/debugger/qdebugmessageservice/qdebugmessageservice.pro
@@ -0,0 +1,21 @@
+CONFIG += testcase
+TARGET = tst_qdebugmessageservice
+QT += network declarative-private testlib
+macx:CONFIG -= app_bundle
+
+HEADERS += ../shared/debugutil_p.h
+
+SOURCES += tst_qdebugmessageservice.cpp \
+ ../shared/debugutil.cpp
+
+INCLUDEPATH += ../shared
+
+include(../../../shared/util.pri)
+
+testDataFiles.files = data
+testDataFiles.path = .
+DEPLOYMENT += testDataFiles
+
+CONFIG += parallel_test
+
+OTHER_FILES += data/test.qml
diff --git a/tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp b/tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
new file mode 100644
index 0000000000..62f89e9540
--- /dev/null
+++ b/tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtDeclarative/private/qdeclarativedebugclient_p.h>
+
+//QDeclarativeDebugTest
+#include "../shared/debugutil_p.h"
+#include "../../../shared/util.h"
+
+#include <QtCore/QString>
+#include <QtTest/QtTest>
+
+const char *NORMALMODE = "-qmljsdebugger=port:3777";
+const char *QMLFILE = "test.qml";
+
+class QDeclarativeDebugMsgClient;
+class tst_QDebugMessageService : public QDeclarativeDataTest
+{
+ Q_OBJECT
+
+public:
+ tst_QDebugMessageService();
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+
+ void init();
+ void cleanup();
+
+ void retrieveDebugOutput();
+
+private:
+ QDeclarativeDebugProcess *m_process;
+ QDeclarativeDebugMsgClient *m_client;
+ QDeclarativeDebugConnection *m_connection;
+};
+
+class QDeclarativeDebugMsgClient : public QDeclarativeDebugClient
+{
+ Q_OBJECT
+public:
+ QDeclarativeDebugMsgClient(QDeclarativeDebugConnection *connection)
+ : QDeclarativeDebugClient(QLatin1String("DebugMessages"), connection)
+ {
+ }
+
+protected:
+ //inherited from QDeclarativeDebugClient
+ void statusChanged(Status status);
+ void messageReceived(const QByteArray &data);
+
+signals:
+ void enabled();
+ void debugOutput();
+
+public:
+ QByteArray debugMessage;
+};
+
+void QDeclarativeDebugMsgClient::statusChanged(Status status)
+{
+ if (status == Enabled) {
+ emit enabled();
+ }
+}
+
+void QDeclarativeDebugMsgClient::messageReceived(const QByteArray &data)
+{
+ QDataStream ds(data);
+ QByteArray command;
+ ds >> command;
+
+ if (command == "MESSAGE") {
+ int type;
+ ds >> type >> debugMessage;
+ emit debugOutput();
+ }
+}
+
+tst_QDebugMessageService::tst_QDebugMessageService()
+{
+}
+
+void tst_QDebugMessageService::initTestCase()
+{
+ QDeclarativeDataTest::initTestCase();
+ m_process = 0;
+ m_client = 0;
+ m_connection = 0;
+}
+
+void tst_QDebugMessageService::cleanupTestCase()
+{
+ if (m_process)
+ delete m_process;
+
+ if (m_client)
+ delete m_client;
+
+ if (m_connection)
+ delete m_connection;
+}
+
+void tst_QDebugMessageService::init()
+{
+ m_connection = new QDeclarativeDebugConnection();
+ m_process = new QDeclarativeDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene");
+ m_client = new QDeclarativeDebugMsgClient(m_connection);
+
+ m_process->start(QStringList() << QLatin1String(NORMALMODE) << QDeclarativeDataTest::instance()->testFile(QMLFILE));
+ if (!m_process->waitForSessionStart()) {
+ QFAIL(QString("Could not launch app. Application output: \n%1").arg(m_process->output()).toAscii());
+ }
+
+ m_connection->connectToHost("127.0.0.1", 3777);
+ QVERIFY(m_connection->waitForConnected());
+
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(enabled())));
+}
+
+void tst_QDebugMessageService::cleanup()
+{
+ if (QTest::currentTestFailed())
+ qDebug() << m_process->output();
+ if (m_process)
+ delete m_process;
+
+ if (m_client)
+ delete m_client;
+
+ if (m_connection)
+ delete m_connection;
+
+ m_process = 0;
+ m_client = 0;
+ m_connection = 0;
+}
+
+void tst_QDebugMessageService::retrieveDebugOutput()
+{
+ if (m_client->debugMessage.isEmpty())
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(debugOutput())));
+}
+
+QTEST_MAIN(tst_QDebugMessageService)
+
+#include "tst_qdebugmessageservice.moc"