1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
43 #include <QDeclarativeEngine>
44 #include <QDeclarativeComponent>
45 #include "../../shared/util.h"
47 class tst_qdeclarativeconsole : public QDeclarativeDataTest
51 tst_qdeclarativeconsole() {}
61 QDeclarativeEngine engine;
64 void tst_qdeclarativeconsole::logging()
66 QUrl testUrl = testFileUrl("logging.qml");
68 QTest::ignoreMessage(QtDebugMsg, "console.debug");
69 QTest::ignoreMessage(QtDebugMsg, "console.log");
70 QTest::ignoreMessage(QtDebugMsg, "console.info");
71 QTest::ignoreMessage(QtWarningMsg, "console.warn");
72 QTest::ignoreMessage(QtCriticalMsg, "console.error");
74 QTest::ignoreMessage(QtDebugMsg, "console.count: 1");
75 QTest::ignoreMessage(QtDebugMsg, ": 1");
76 QTest::ignoreMessage(QtDebugMsg, "console.count: 2");
77 QTest::ignoreMessage(QtDebugMsg, ": 2");
79 QTest::ignoreMessage(QtDebugMsg, "[1,2]");
80 QTest::ignoreMessage(QtDebugMsg, "Object");
81 QTest::ignoreMessage(QtDebugMsg, "undefined");
82 QTest::ignoreMessage(QtDebugMsg, "12");
83 QTest::ignoreMessage(QtDebugMsg, "function () { return 5;}");
84 QTest::ignoreMessage(QtDebugMsg, "true");
85 QTest::ignoreMessage(QtDebugMsg, "Object");
86 QTest::ignoreMessage(QtDebugMsg, "Object");
87 QTest::ignoreMessage(QtDebugMsg, "1 pong! Object");
88 QTest::ignoreMessage(QtDebugMsg, "1 [ping,pong] Object 2");
90 QDeclarativeComponent component(&engine, testUrl);
91 QObject *object = component.create();
96 void tst_qdeclarativeconsole::tracing()
98 QUrl testUrl = testFileUrl("tracing.qml");
100 QString trace1 = QString::fromLatin1("tracing (%1:%2:%3)\n").arg(testUrl.toString()).arg(50).arg(17);
101 QString trace2 = QString::fromLatin1("onCompleted (%1:%2:%3)\n").arg(testUrl.toString()).arg(54).arg(9);
102 QTest::ignoreMessage(QtDebugMsg, qPrintable(trace1));
103 QTest::ignoreMessage(QtDebugMsg, qPrintable(trace2));
105 QDeclarativeComponent component(&engine, testUrl);
106 QObject *object = component.create();
107 QVERIFY(object != 0);
111 void tst_qdeclarativeconsole::profiling()
113 QUrl testUrl = testFileUrl("profiling.qml");
116 QTest::ignoreMessage(QtDebugMsg, "Profiling started.");
117 QTest::ignoreMessage(QtDebugMsg, "Profiling ended.");
119 QDeclarativeComponent component(&engine, testUrl);
120 QObject *object = component.create();
121 QVERIFY(object != 0);
125 void tst_qdeclarativeconsole::assert()
127 QUrl testUrl = testFileUrl("assert.qml");
130 QTest::ignoreMessage(QtCriticalMsg, "This will fail");
131 QTest::ignoreMessage(QtCriticalMsg, "This will fail too");
132 QString trace1 = QString::fromLatin1("onCompleted (%1:%2:%3)\n").arg(testUrl.toString()).arg(54).arg(17);
133 QString trace2 = QString::fromLatin1("onCompleted (%1:%2:%3)\n").arg(testUrl.toString()).arg(59).arg(9);
134 QString trace3 = QString::fromLatin1("assertFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(47).arg(17);
135 QTest::ignoreMessage(QtDebugMsg, qPrintable(trace1));
136 QTest::ignoreMessage(QtDebugMsg, qPrintable(trace2));
137 QTest::ignoreMessage(QtDebugMsg, qPrintable(trace3));
139 QDeclarativeComponent component(&engine, testUrl);
140 QObject *object = component.create();
141 QVERIFY(object != 0);
145 void tst_qdeclarativeconsole::exception()
147 QUrl testUrl = testFileUrl("exception.qml");
150 QTest::ignoreMessage(QtCriticalMsg, "Exception 1");
151 QTest::ignoreMessage(QtCriticalMsg, "Exception 2");
152 QString trace1 = QString::fromLatin1("onCompleted (%1:%2:%3)\n").arg(testUrl.toString()).arg(51).arg(21);
153 QString trace2 = QString::fromLatin1("onCompleted (%1:%2:%3)\n").arg(testUrl.toString()).arg(56).arg(9);
154 QString trace3 = QString::fromLatin1("exceptionFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(46).arg(17);
155 QTest::ignoreMessage(QtDebugMsg, qPrintable(trace1));
156 QTest::ignoreMessage(QtDebugMsg, qPrintable(trace2));
157 QTest::ignoreMessage(QtDebugMsg, qPrintable(trace3));
159 QDeclarativeComponent component(&engine, testUrl);
160 QObject *object = component.create();
161 QVERIFY(object != 0);
165 QTEST_MAIN(tst_qdeclarativeconsole)
167 #include "tst_qdeclarativeconsole.moc"