aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAurindam Jana <aurindam.jana@nokia.com>2012-01-17 14:38:06 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-24 14:11:52 +0100
commitb77ecde410ace1545ac6fdad7466e64e4fc635da (patch)
tree791e9501a6f40a97879afa3a70e4b54bffb2663b /tests/auto
parentb514fecbeae6a4fed9e593ea6405dbeec7fe7883 (diff)
Console API: Add console.exception
console.exception writes a message to the console and prints the JavaScript stack trace at the point where it is called. Change-Id: Idd2ff5982826accae0895db44c7ecf6130338cc7 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/declarative/qdeclarativeconsole/data/exception.qml58
-rw-r--r--tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp21
2 files changed, 79 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeconsole/data/exception.qml b/tests/auto/declarative/qdeclarativeconsole/data/exception.qml
new file mode 100644
index 0000000000..d1a32be6bc
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconsole/data/exception.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** 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
+
+QtObject {
+ function exceptionFail() {
+ console.exception("Exception 2")
+ }
+
+ Component.onCompleted: {
+ try {
+ console.exception("Exception 1")
+ } catch (e) {
+ console.log(e);
+ }
+
+ exceptionFail();
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp b/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp
index 9a4a39fa6d..34b0f6582f 100644
--- a/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp
+++ b/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp
@@ -55,6 +55,7 @@ private slots:
void tracing();
void profiling();
void assert();
+ void exception();
private:
QDeclarativeEngine engine;
@@ -141,6 +142,26 @@ void tst_qdeclarativeconsole::assert()
delete object;
}
+void tst_qdeclarativeconsole::exception()
+{
+ QUrl testUrl = testFileUrl("exception.qml");
+
+ // exception()
+ QTest::ignoreMessage(QtCriticalMsg, "Exception 1");
+ QTest::ignoreMessage(QtCriticalMsg, "Exception 2");
+ QString trace1 = QString::fromLatin1("onCompleted (%1:%2:%3)\n").arg(testUrl.toString()).arg(51).arg(21);
+ QString trace2 = QString::fromLatin1("onCompleted (%1:%2:%3)\n").arg(testUrl.toString()).arg(56).arg(9);
+ QString trace3 = QString::fromLatin1("exceptionFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(46).arg(17);
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(trace1));
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(trace2));
+ QTest::ignoreMessage(QtDebugMsg, qPrintable(trace3));
+
+ QDeclarativeComponent component(&engine, testUrl);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ delete object;
+}
+
QTEST_MAIN(tst_qdeclarativeconsole)
#include "tst_qdeclarativeconsole.moc"