aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2012-01-16 15:40:27 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-24 07:01:22 +0100
commit398e27f8907362b598fe1dfe2ecbf76bcbe530c4 (patch)
treee9e2e5d6aa117e7b5eabd8241cabc5799ec962e4 /tests/auto/declarative
parentecab027748352b2529902ba3e8bd01550e0c53c3 (diff)
Console API: Add console.count
console.count can be handy to check how often code snippets are executed. Change-Id: I0eaf17ab893c76e7b8956122aa31e218745e92bf Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml1
-rw-r--r--tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp48
-rw-r--r--tests/auto/declarative/qdeclarativeconsole/data/logging.qml9
-rw-r--r--tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp6
4 files changed, 54 insertions, 10 deletions
diff --git a/tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml b/tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml
index e8c9d6b197..4a61f3291a 100644
--- a/tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml
+++ b/tests/auto/declarative/debugger/qdebugmessageservice/data/test.qml
@@ -46,5 +46,6 @@ Item {
height: 360
Component.onCompleted: {
console.log("console.log")
+ console.count("console.count");
}
}
diff --git a/tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp b/tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
index fa83422490..15fd0c597d 100644
--- a/tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
+++ b/tests/auto/declarative/debugger/qdebugmessageservice/tst_qdebugmessageservice.cpp
@@ -59,14 +59,16 @@ class tst_QDebugMessageService : public QDeclarativeDataTest
public:
tst_QDebugMessageService();
+ void init(bool extendedOutput);
+
private slots:
void initTestCase();
void cleanupTestCase();
- void init();
void cleanup();
void retrieveDebugOutput();
+ void retrieveDebugOutputExtended();
private:
QDeclarativeDebugProcess *m_process;
@@ -158,13 +160,14 @@ void tst_QDebugMessageService::cleanupTestCase()
delete m_connection;
}
-void tst_QDebugMessageService::init()
+void tst_QDebugMessageService::init(bool extendedOutput)
{
m_connection = new QDeclarativeDebugConnection();
m_process = new QDeclarativeDebugProcess(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene");
m_client = new QDeclarativeDebugMsgClient(m_connection);
- m_process->setEnvironment(QProcess::systemEnvironment() << "QML_CONSOLE_EXTENDED=1");
+ if (extendedOutput)
+ m_process->setEnvironment(QProcess::systemEnvironment() << "QML_CONSOLE_EXTENDED=1");
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());
@@ -196,15 +199,42 @@ void tst_QDebugMessageService::cleanup()
void tst_QDebugMessageService::retrieveDebugOutput()
{
- if (m_client->logBuffer.isEmpty())
+ init(false);
+
+ int maxTries = 2;
+ while ((m_client->logBuffer.size() < 2)
+ && (maxTries-- > 0))
+ QVERIFY(QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(debugOutput())));
+
+ QCOMPARE(m_client->logBuffer.size(), 2);
+
+ QCOMPARE(m_client->logBuffer.at(0).toString(),
+ LogEntry(QtDebugMsg, QLatin1String("console.log")).toString());
+ QCOMPARE(m_client->logBuffer.at(1).toString(),
+ LogEntry(QtDebugMsg, QLatin1String("console.count: 1")).toString());
+}
+
+void tst_QDebugMessageService::retrieveDebugOutputExtended()
+{
+ init(true);
+
+ int maxTries = 2;
+ while ((m_client->logBuffer.size() < 2)
+ && (maxTries-- > 0))
QDeclarativeDebugTest::waitForSignal(m_client, SIGNAL(debugOutput()));
- QVERIFY(!m_client->logBuffer.isEmpty());
+ QCOMPARE(m_client->logBuffer.size(), 2);
+
+ const QString path =
+ QUrl::fromLocalFile(QDeclarativeDataTest::instance()->testFile(QMLFILE)).toString();
+
+ QString logMsg = QString::fromLatin1("console.log (%1:%2)").arg(path).arg(48);
+ QString countMsg = QString::fromLatin1("console.count: 1 (%1:%2)").arg(path).arg(49);
- QString msg = QString::fromLatin1("console.log (%1:%2)").arg(
- QUrl::fromLocalFile(QDeclarativeDataTest::instance()->testFile(QMLFILE)).toString()).arg(48);
- QCOMPARE(m_client->logBuffer.last().toString(),
- LogEntry(QtDebugMsg, msg).toString());
+ QCOMPARE(m_client->logBuffer.at(0).toString(),
+ LogEntry(QtDebugMsg, logMsg).toString());
+ QCOMPARE(m_client->logBuffer.at(1).toString(),
+ LogEntry(QtDebugMsg, countMsg).toString());
}
QTEST_MAIN(tst_QDebugMessageService)
diff --git a/tests/auto/declarative/qdeclarativeconsole/data/logging.qml b/tests/auto/declarative/qdeclarativeconsole/data/logging.qml
index 716cb41e5e..05c8be0096 100644
--- a/tests/auto/declarative/qdeclarativeconsole/data/logging.qml
+++ b/tests/auto/declarative/qdeclarativeconsole/data/logging.qml
@@ -44,6 +44,12 @@ import QtQuick 2.0
QtObject {
id:root
+
+ function consoleCount() {
+ console.count("console.count", "Ignore additonal argument");
+ console.count();
+ }
+
Component.onCompleted: {
console.debug("console.debug");
console.log("console.log");
@@ -51,6 +57,9 @@ QtObject {
console.warn("console.warn");
console.error("console.error");
+ consoleCount();
+ consoleCount();
+
var a = [1, 2];
var b = {a: "hello", d: 1 };
var c
diff --git a/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp b/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp
index 9737b3a360..f75037786a 100644
--- a/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp
+++ b/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp
@@ -69,6 +69,11 @@ void tst_qdeclarativeconsole::logging()
QTest::ignoreMessage(QtWarningMsg, "console.warn");
QTest::ignoreMessage(QtCriticalMsg, "console.error");
+ QTest::ignoreMessage(QtDebugMsg, "console.count: 1");
+ QTest::ignoreMessage(QtDebugMsg, ": 1");
+ QTest::ignoreMessage(QtDebugMsg, "console.count: 2");
+ QTest::ignoreMessage(QtDebugMsg, ": 2");
+
QTest::ignoreMessage(QtDebugMsg, "[1,2]");
QTest::ignoreMessage(QtDebugMsg, "Object");
QTest::ignoreMessage(QtDebugMsg, "undefined");
@@ -80,7 +85,6 @@ void tst_qdeclarativeconsole::logging()
QTest::ignoreMessage(QtDebugMsg, "1 pong! Object");
QTest::ignoreMessage(QtDebugMsg, "1 [ping,pong] Object 2");
-
QDeclarativeComponent component(&engine, testUrl);
QObject *object = component.create();
QVERIFY(object != 0);