diff options
author | Aurindam Jana <aurindam.jana@nokia.com> | 2012-01-17 12:37:07 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-24 14:11:52 +0100 |
commit | b514fecbeae6a4fed9e593ea6405dbeec7fe7883 (patch) | |
tree | 05c6dd3f6407a715f6ad482eac9f54a2bcc2b507 /tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp | |
parent | 47a5c708bf4e555cb8febef583f32c99f7d8ea1e (diff) |
Console API: Add console.assert
console.assert tests if an expression is true. If it is false,
it writes a message to the console and prints the JavaScript
stack trace at that point.
Change-Id: I5487552cb8a947e1947914166834e0bdedba3354
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp b/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp index f75037786a..9a4a39fa6d 100644 --- a/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp +++ b/tests/auto/declarative/qdeclarativeconsole/tst_qdeclarativeconsole.cpp @@ -54,6 +54,7 @@ private slots: void logging(); void tracing(); void profiling(); + void assert(); private: QDeclarativeEngine engine; @@ -120,6 +121,25 @@ void tst_qdeclarativeconsole::profiling() delete object; } +void tst_qdeclarativeconsole::assert() +{ + QUrl testUrl = testFileUrl("assert.qml"); + + // assert() + QTest::ignoreMessage(QtCriticalMsg, "This will fail"); + QTest::ignoreMessage(QtCriticalMsg, "This will fail too"); + QString trace1 = QString::fromLatin1("onCompleted (%1:%2:%3)\n").arg(testUrl.toString()).arg(54).arg(17); + QString trace2 = QString::fromLatin1("onCompleted (%1:%2:%3)\n").arg(testUrl.toString()).arg(59).arg(9); + QString trace3 = QString::fromLatin1("assertFail (%1:%2:%3)\n").arg(testUrl.toString()).arg(47).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) |