diff options
-rw-r--r-- | QtTest/QtTest.pro | 12 | ||||
-rw-r--r-- | QtTest/testlogger.js | 135 | ||||
-rw-r--r-- | doc/testcases.txt | 16 | ||||
-rw-r--r-- | qtest-qml.pro | 3 | ||||
-rw-r--r-- | src/imports/imports.pro | 3 | ||||
-rw-r--r-- | src/imports/testlib/TestCase.qml (renamed from QtTest/TestCase.qml) | 81 | ||||
-rw-r--r-- | src/imports/testlib/main.cpp | 62 | ||||
-rw-r--r-- | src/imports/testlib/qmldir (renamed from QtTest/qmldir) | 1 | ||||
-rw-r--r-- | src/imports/testlib/testlib.pro | 35 | ||||
-rw-r--r-- | src/imports/testlib/testlogger.js | 164 | ||||
-rw-r--r-- | src/quicktestlib/qdeclarativetestreport.cpp | 168 | ||||
-rw-r--r-- | src/quicktestlib/qdeclarativetestreport.h | 75 | ||||
-rw-r--r-- | src/quicktestlib/quicktestglobal.h | 73 | ||||
-rw-r--r-- | src/quicktestlib/quicktestlib.pro | 60 | ||||
-rw-r--r-- | src/src.pro | 3 |
15 files changed, 735 insertions, 156 deletions
diff --git a/QtTest/QtTest.pro b/QtTest/QtTest.pro deleted file mode 100644 index 88db644..0000000 --- a/QtTest/QtTest.pro +++ /dev/null @@ -1,12 +0,0 @@ -# No C++ sources to build, so use the "subdirs" template without -# any SUBDIRS to disable trying to build a C++ app, lib, or plugin. -TEMPLATE = subdirs - -qdeclarativesources.files += \ - qmldir \ - TestCase.qml \ - testlogger.js - -qdeclarativesources.path += $$[QT_INSTALL_IMPORTS]/QtTest - -INSTALLS += qdeclarativesources diff --git a/QtTest/testlogger.js b/QtTest/testlogger.js deleted file mode 100644 index 7f360f1..0000000 --- a/QtTest/testlogger.js +++ /dev/null @@ -1,135 +0,0 @@ - -.pragma library - -// We need a global place to store the results that can be -// shared between multiple TestCase instances. Because QML -// creates a separate scope for every inclusion of this file, -// we hijack the global "Qt" object to store our data. -function log_init_results() -{ - if (!Qt.testResults) { - Qt.testResults = { - suiteName: "", - reportedStart: false, - numPassed: 0, - numFailed: 0, - numSkipped: 0, - nextId: 0, - testCases: [] - } - } -} - -function log_fail(testcase, msg) -{ - if (!msg) - msg = "" - console.log("FAIL! : " + testcase + " " + msg) - ++Qt.testResults.numFailed -} - -function log_expect_fail(testcase, expectmsg, msg) -{ - if (!msg) - msg = "" - if (expectmsg) - console.log("XFAIL : " + testcase + " " + expectmsg + " " + msg) - else - console.log("XFAIL : " + testcase + " " + msg) - ++Qt.testResults.numPassed -} - -function log_expect_fail_pass(testcase) -{ - console.log("XPASS : " + testcase) - ++Qt.testResults.numFailed -} - -function log_skip(testcase, msg) -{ - if (!msg) - msg = "" - console.log("SKIP : " + testcase + " " + msg) - ++Qt.testResults.numSkipped -} - -function log_pass(testcase) -{ - console.log("PASS : " + testcase) - ++Qt.testResults.numPassed -} - -function log_message(msg) -{ - console.log(msg) -} - -function log_print_totals() -{ - console.log("Totals: " + Qt.testResults.numPassed + " passed, " + - Qt.testResults.numFailed + " failed, " + - Qt.testResults.numSkipped + " skipped"); -} - -function log_register_test(name) -{ - log_init_results() - if (name && !Qt.testResults.suiteName) - Qt.testResults.suiteName = name - var testId = Qt.testResults.nextId++ - Qt.testResults.testCases.push(testId) - return testId -} - -function log_optional_test(testId) -{ - log_init_results() - var index = Qt.testResults.testCases.indexOf(testId) - if (index >= 0) - Qt.testResults.testCases.splice(index, 1) -} - -function log_mandatory_test(testId) -{ - log_init_results() - var index = Qt.testResults.testCases.indexOf(testId) - if (index == -1) - Qt.testResults.testCases.push(testId) -} - -function log_start_test() -{ - log_init_results() - if (Qt.testResults.reportedStart) - return - if (Qt.testResults.suiteName) - console.log("********* Start testing of " + Qt.testResults.suiteName + " *********") - else - console.log("********* Start testing *********") - Qt.testResults.reportedStart = true -} - -function log_complete_test(testId) -{ - var index = Qt.testResults.testCases.indexOf(testId) - if (index >= 0) - Qt.testResults.testCases.splice(index, 1) - if (!Qt.testResults.testCases.length) { - log_print_totals() - if (Qt.testResults.suiteName) - console.log("********* Finished testing of " + Qt.testResults.suiteName + " *********") - else - console.log("********* Finished testing *********") - Qt.quit() // XXX - how do we set the exit value? - } -} - -function log_prefixed_name(name, funcname) -{ - if (!name) - name = Qt.testResults.suiteName - if (name) - return name + "::" + funcname + "()" - else - return funcname + "()" -} diff --git a/doc/testcases.txt b/doc/testcases.txt index 5e38935..0461ff7 100644 --- a/doc/testcases.txt +++ b/doc/testcases.txt @@ -1,4 +1,12 @@ +Organization of QML/3D test cases +================================= + +All of the test cases are in subdirectories under "tests/auto/qml3d". +The "tst_qml3d" program searches for files in these subdirectories +that match the pattern "tst_*.qml". Other *.qml files may appear +for auxillary QML components that are used by the test. + Basic test cases ================ @@ -15,7 +23,7 @@ TestCase { compare(2 + 2, 4, "2 + 2 = 4") } - function test_math_fail() { + function test_fail() { compare(2 + 2, 5, "2 + 2 = 5") } } @@ -25,13 +33,15 @@ Functions that start with "test_" are treated as test cases to be executed. The "name" is used to prefix the functions in the output: ********* Start testing of MathTests ********* -FAIL! : MathTests::test_math_fail() 2 + 2 = 5: actual: 4, expected: 5 +FAIL! : MathTests::test_fail() 2 + 2 = 5: actual: 4, expected: 5 PASS : MathTests::test_math() Totals: 1 passed, 1 failed, 0 skipped ********* Finished testing of MathTests ********* Because of the way JavaScript properties work, the order in which the -test functions are run is undefined. +test functions are found is unpredictable. To assist with predictability, +the test framework will sort the functions on ascending order of name. +This can help when there are two tests that must be run in order. A number of helper functions are available to assist with writing tests: diff --git a/qtest-qml.pro b/qtest-qml.pro index bede5ce..a7403e7 100644 --- a/qtest-qml.pro +++ b/qtest-qml.pro @@ -1,2 +1,3 @@ TEMPLATE = subdirs -SUBDIRS = QtTest +SUBDIRS = src +CONFIG += ordered diff --git a/src/imports/imports.pro b/src/imports/imports.pro new file mode 100644 index 0000000..8f369d3 --- /dev/null +++ b/src/imports/imports.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = testlib +CONFIG += ordered diff --git a/QtTest/TestCase.qml b/src/imports/testlib/TestCase.qml index 3f28490..61a2ff9 100644 --- a/QtTest/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -1,4 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + import Qt 4.7 +import QtTest 1.0 import "testlogger.js" as TestLogger Item { @@ -28,6 +70,8 @@ Item { property bool prevWhen: true property int testId: -1 + TestReport { id: reporter } + function fail(msg) { if (!msg) msg = ""; @@ -56,9 +100,25 @@ Item { if (typeof actual == "number" && typeof expected == "number") { // Use a fuzzy compare if the two values are floats if (Math.abs(actual - expected) <= 0.00001) - return; + return + } else if (typeof actual == "object" && typeof expected == "object") { + // Does the expected value look like a vector3d? + if ("x" in expected && "y" in expected && "z" in expected) { + if (Math.abs(actual.x - expected.x) <= 0.00001 && + Math.abs(actual.y - expected.y) <= 0.00001 && + Math.abs(actual.z - expected.z) <= 0.00001) + return + fail2(msg, "actual: Qt.vector3d(" + + actual.x + ", " + actual.y + ", " + actual.z + + "), expected: Qt.vector3d(" + + expected.x + ", " + expected.y + ", " + expected.z + + ")") + return + } + if (actual == expected) + return } else if (actual == expected) { - return; + return } fail2(msg, "actual: " + actual + ", expected: " + expected) } @@ -91,22 +151,33 @@ Item { } } catch (e) { testCaseResult = [] - if (e.message == "QtTest::fail") + if (e.message == "QtTest::fail") { success = false + } else if (e.message.indexOf("QtTest::") != 0) { + // Test threw an unrecognized exception - fail. + TestLogger.log_fail(currentTestCase, e.message) + success = false + } } return success } function run() { - TestLogger.log_start_test() + TestLogger.log_start_test(reporter) var success = true running = true + var testList = [] for (var prop in testCase) { if (prop.indexOf("test_") != 0) continue var tail = prop.lastIndexOf("_data"); if (tail != -1 && tail == (prop.length - 5)) continue + testList.push(prop) + } + testList.sort() + for (var index in testList) { + var prop = testList[index] var datafunc = prop + "_data" if (datafunc in testCase) { if (runInternal(datafunc, true)) { @@ -141,7 +212,7 @@ Item { currentTestCase = "" running = false completed = true - TestLogger.log_complete_test(testId) + TestLogger.log_complete_test(testId, reporter) return success } diff --git a/src/imports/testlib/main.cpp b/src/imports/testlib/main.cpp new file mode 100644 index 0000000..8a9bb57 --- /dev/null +++ b/src/imports/testlib/main.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtDeclarative/qdeclarativeextensionplugin.h> +#include "qdeclarativetestreport.h" + +QT_BEGIN_NAMESPACE + +class QTestQmlModule : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + virtual void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == QLatin1String("QtTest")); + qmlRegisterType<QDeclarativeTestReport>(uri,1,0,"TestReport"); + } +}; + +QT_END_NAMESPACE + +#include "main.moc" + +Q_EXPORT_PLUGIN2(qmltestplugin, QT_PREPEND_NAMESPACE(QTestQmlModule)); diff --git a/QtTest/qmldir b/src/imports/testlib/qmldir index 56f9177..7df32c0 100644 --- a/QtTest/qmldir +++ b/src/imports/testlib/qmldir @@ -1 +1,2 @@ +plugin qmltestplugin TestCase 1.0 TestCase.qml diff --git a/src/imports/testlib/testlib.pro b/src/imports/testlib/testlib.pro new file mode 100644 index 0000000..341d576 --- /dev/null +++ b/src/imports/testlib/testlib.pro @@ -0,0 +1,35 @@ +TEMPLATE = lib +TARGET = qmltestplugin +CONFIG += qt plugin + +symbian { + CONFIG += epocallowdlldata + contains(QT_EDITION, OpenSource) { + TARGET.CAPABILITY = LocalServices NetworkServices ReadUserData UserEnvironment WriteUserData + } else { + TARGET.CAPABILITY = All -Tcb + } +} + +QT += declarative + +INCLUDEPATH += $$PWD/../../quicktestlib + +SOURCES += main.cpp +HEADERS += + +qdeclarativesources.files += \ + qmldir \ + TestCase.qml \ + testlogger.js + +qdeclarativesources.path += $$[QT_INSTALL_IMPORTS]/QtTest +target.path += $$[QT_INSTALL_IMPORTS]/QtTest +INSTALLS += qdeclarativesources target + +LIBS += -L../../../lib -L../../../bin +win32:CONFIG(debug, debug|release) { + LIBS += -lQtTestQuick$${QT_LIBINFIX}d +} else { + LIBS += -lQtTestQuick$${QT_LIBINFIX} +} diff --git a/src/imports/testlib/testlogger.js b/src/imports/testlib/testlogger.js new file mode 100644 index 0000000..f556497 --- /dev/null +++ b/src/imports/testlib/testlogger.js @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +.pragma library + +// We need a global place to store the results that can be +// shared between multiple TestCase instances. Because QML +// creates a separate scope for every inclusion of this file, +// we hijack the global "Qt" object to store our data. +function log_init_results() +{ + if (!Qt.testResults) { + Qt.testResults = { + suiteName: "", + reportedStart: false, + numPassed: 0, + numFailed: 0, + numSkipped: 0, + nextId: 0, + testCases: [], + reporter: null + } + } +} + +function log_fail(testcase, msg) +{ + if (!msg) + msg = "" + Qt.testResults.reporter.log_fail(testcase, msg); + ++Qt.testResults.numFailed +} + +function log_expect_fail(testcase, expectmsg, msg) +{ + if (!msg) + msg = "" + if (expectmsg) + Qt.testResults.reporter.log_expect_fail(testcase, expectmsg + " " + msg); + else + Qt.testResults.reporter.log_expect_fail(testcase, msg); + ++Qt.testResults.numPassed +} + +function log_expect_fail_pass(testcase) +{ + Qt.testResults.reporter.log_expect_fail_pass(testcase); + ++Qt.testResults.numFailed +} + +function log_skip(testcase, msg) +{ + if (!msg) + msg = "" + Qt.testResults.reporter.log_skip(testcase, msg); + ++Qt.testResults.numSkipped +} + +function log_pass(testcase) +{ + Qt.testResults.reporter.log_pass(testcase); + ++Qt.testResults.numPassed +} + +function log_message(msg) +{ + Qt.testResults.reporter.log_message(msg); +} + +function log_register_test(name) +{ + log_init_results() + if (name && !Qt.testResults.suiteName) + Qt.testResults.suiteName = name + var testId = Qt.testResults.nextId++ + Qt.testResults.testCases.push(testId) + return testId +} + +function log_optional_test(testId) +{ + log_init_results() + var index = Qt.testResults.testCases.indexOf(testId) + if (index >= 0) + Qt.testResults.testCases.splice(index, 1) +} + +function log_mandatory_test(testId) +{ + log_init_results() + var index = Qt.testResults.testCases.indexOf(testId) + if (index == -1) + Qt.testResults.testCases.push(testId) +} + +function log_start_test(reporter) +{ + log_init_results() + Qt.testResults.reporter = reporter + if (Qt.testResults.reportedStart) + return + Qt.testResults.reportedStart = true +} + +function log_complete_test(testId, reporter) +{ + var index = Qt.testResults.testCases.indexOf(testId) + if (index >= 0) + Qt.testResults.testCases.splice(index, 1) + if (!Qt.testResults.testCases.length) { + reporter.report(Qt.testResults.numPassed, + Qt.testResults.numFailed, + Qt.testResults.numSkipped) + Qt.quit() + } +} + +function log_prefixed_name(name, funcname) +{ + if (!name) + name = Qt.testResults.suiteName + if (name) + return name + "::" + funcname + "()" + else + return funcname + "()" +} diff --git a/src/quicktestlib/qdeclarativetestreport.cpp b/src/quicktestlib/qdeclarativetestreport.cpp new file mode 100644 index 0000000..7930405 --- /dev/null +++ b/src/quicktestlib/qdeclarativetestreport.cpp @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qdeclarativetestreport.h" +#include <QtGui/qtextdocument.h> +#include <stdio.h> + +QT_BEGIN_NAMESPACE + +static bool xmlOutput = false; +static int passed = 0; +static int failed = 0; +static int skipped = 0; +static FILE *stream = 0; + +void QDeclarativeTestReport::report(int pass, int fail, int skip) +{ + passed += pass; + failed += fail; + skipped += skip; +} + +void QDeclarativeTestReport::log_fail(const QString &testCase, const QString &message) +{ + if (!stream) + stream = stdout; + if (xmlOutput) { + log_incident("fail", testCase, message); + } else if (!message.isEmpty()) { + fprintf(stream, "FAIL! : %s %s\n", + testCase.toLatin1().constData(), + message.toLatin1().constData()); + } else { + fprintf(stream, "FAIL! : %s\n", testCase.toLatin1().constData()); + } +} + +void QDeclarativeTestReport::log_expect_fail + (const QString &testCase, const QString &message) +{ + if (!stream) + stream = stdout; + if (xmlOutput) { + log_incident("xfail", testCase, message); + } else if (!message.isEmpty()) { + fprintf(stream, "XFAIL : %s %s\n", + testCase.toLatin1().constData(), + message.toLatin1().constData()); + } else { + fprintf(stream, "XFAIL : %s\n", testCase.toLatin1().constData()); + } +} + +void QDeclarativeTestReport::log_expect_fail_pass(const QString &testCase) +{ + if (!stream) + stream = stdout; + if (xmlOutput) + log_incident("xpass", testCase, QString()); + else + fprintf(stream, "XPASS : %s\n", testCase.toLatin1().constData()); +} + +void QDeclarativeTestReport::log_skip(const QString &testCase, const QString &message) +{ + if (!stream) + stream = stdout; + if (xmlOutput) { + log_incident("skip", testCase, message); + } else if (!message.isEmpty()) { + fprintf(stream, "SKIP : %s %s\n", + testCase.toLatin1().constData(), + message.toLatin1().constData()); + } else { + fprintf(stream, "SKIP : %s\n", testCase.toLatin1().constData()); + } +} + +void QDeclarativeTestReport::log_pass(const QString &testCase) +{ + if (!stream) + stream = stdout; + if (xmlOutput) + log_incident("pass", testCase, QString()); + else + fprintf(stream, "PASS : %s\n", testCase.toLatin1().constData()); +} + +void QDeclarativeTestReport::log_message(const QString &message) +{ + if (!stream) + stream = stdout; + if (!xmlOutput) + fprintf(stream, "%s\n", message.toLatin1().constData()); +} + +void QDeclarativeTestReport::log_incident + (const char *type, const QString &testCase, const QString &message) +{ + QString name(testCase); + QString tag; + name.replace(QLatin1String("()"), QLatin1String("")); + name.replace(QLatin1String("::"), QLatin1String("__")); + int tagIndex = name.indexOf(QLatin1String(" [")); + if (tagIndex >= 0) { + tag = name.mid(tagIndex + 2); + if (tag.endsWith(QLatin1String("]"))) + tag = tag.left(tag.length() - 1); + name = name.left(tagIndex); + } + fprintf(stream, "<TestFunction name=\"%s\">\n", + Qt::escape(name).toLatin1().constData()); + if (message.isEmpty() && tag.isEmpty()) { + fprintf(stream, "<Incident type=\"%s\" file=\"\" line=\"0\" />\n", type); + } else { + fprintf(stream, "<Incident type=\"%s\" file=\"\" line=\"0\">\n", type); + if (!tag.isEmpty()) { + fprintf(stream, " <DataTag>%s</DataTag>\n", + Qt::escape(tag).toLatin1().constData()); + } + if (!message.isEmpty()) { + fprintf(stream, " <Description>%s</Description>\n", + Qt::escape(message).toLatin1().constData()); + } + fprintf(stream, "</Incident>\n"); + } + fprintf(stream, "</TestFunction>\n"); +} + +QT_END_NAMESPACE diff --git a/src/quicktestlib/qdeclarativetestreport.h b/src/quicktestlib/qdeclarativetestreport.h new file mode 100644 index 0000000..a505de4 --- /dev/null +++ b/src/quicktestlib/qdeclarativetestreport.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVETESTREPORT_H +#define QDECLARATIVETESTREPORT_H + +#include "quicktestglobal.h" +#include <QtCore/qobject.h> +#include <QtCore/qstring.h> +#include <QtDeclarative/qdeclarative.h> + +QT_BEGIN_NAMESPACE + +class Q_TEST_QUICK_EXPORT QDeclarativeTestReport : public QObject +{ + Q_OBJECT +public: + QDeclarativeTestReport(QObject *parent = 0) : QObject(parent) {} + +public Q_SLOTS: + void report(int pass, int fail, int skip); + void log_fail(const QString &testCase, const QString &message); + void log_expect_fail + (const QString &testCase, const QString &message); + void log_expect_fail_pass(const QString &testCase); + void log_skip(const QString &testCase, const QString &message); + void log_pass(const QString &testCase); + void log_message(const QString &message); + +private: + void log_incident(const char *type, const QString &testCase, + const QString &message); +}; + +QML_DECLARE_TYPE(QDeclarativeTestReport) + +#endif diff --git a/src/quicktestlib/quicktestglobal.h b/src/quicktestlib/quicktestglobal.h new file mode 100644 index 0000000..cfdad78 --- /dev/null +++ b/src/quicktestlib/quicktestglobal.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TESTQUICKGLOBAL_H +#define TESTQUICKGLOBAL_H + +#include <QtCore/qglobal.h> + +QT_LICENSED_MODULE(QtTestQuick) +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) +# if defined(QT_NODLL) +# undef QT_MAKEDLL +# undef QT_DLL +# elif defined(QT_MAKEDLL) /* create a Qt DLL library */ +# if defined(QT_DLL) +# undef QT_DLL +# endif +# if defined(QT_BUILD_TEST_QUICK_LIB) +# define Q_TEST_QUICK_EXPORT Q_DECL_EXPORT +# else +# define Q_TEST_QUICK_EXPORT Q_DECL_IMPORT +# endif +# elif defined(QT_DLL) /* use a Qt DLL library */ +# define Q_TEST_QUICK_EXPORT Q_DECL_IMPORT +# endif +#endif +#if !defined(Q_TEST_QUICK_EXPORT) +# if defined(QT_SHARED) +# define Q_TEST_QUICK_EXPORT Q_DECL_EXPORT +# else +# define Q_TEST_QUICK_EXPORT +# endif +#endif + +#endif diff --git a/src/quicktestlib/quicktestlib.pro b/src/quicktestlib/quicktestlib.pro new file mode 100644 index 0000000..e35913f --- /dev/null +++ b/src/quicktestlib/quicktestlib.pro @@ -0,0 +1,60 @@ +TEMPLATE = lib +TARGET = QtTestQuick$${QT_LIBINFIX} +CONFIG += dll warn_on +QT += declarative testlib +DESTDIR = ../../lib + +win32 { + CONFIG += debug_and_release debug_and_release_config build_all + DLLDESTDIR = ../../bin + !static:DEFINES += QT_MAKEDLL + + CONFIG(debug, debug|release) { + TARGET = $$member(TARGET, 0)d + } +} + +symbian { + DEFINES += QT_MAKEDLL + CONFIG += epocallowdlldata + contains(QT_EDITION, OpenSource) { + TARGET.CAPABILITY = LocalServices NetworkServices ReadUserData UserEnvironment WriteUserData + } else { + TARGET.CAPABILITY = All -Tcb + } +} + +SOURCES += \ + qdeclarativetestreport.cpp +HEADERS += \ + quicktestglobal.h \ + qdeclarativetestreport.h + +PUBLIC_HEADERS += $$HEADERS + +DEFINES += QT_BUILD_TEST_QUICK_LIB + +!symbian { + target.path += $$[QT_INSTALL_LIBS] + INSTALLS += target + + install_headers.path = $$[QT_INSTALL_HEADERS]/QtTestQuick + install_headers.files = $$PUBLIC_HEADERS + INSTALLS += install_headers +} else { + load(data_caging_paths) + + quicktestMwHeaders = *.h + for(api, quicktestMwHeaders) { + entries=$$files($$api); + #files() attaches a ';' at the end which needs to be removed + entries=$$replace(entries, ;,) + for(entry, entries) { + exists($$entry) { + contains(PUBLIC_HEADERS, $$basename(entry)) { + BLD_INF_RULES.prj_exports += "$$entry $$MW_LAYER_PUBLIC_EXPORT_PATH(QtTestQuick/$$basename(entry))" + } + } + } + } +} diff --git a/src/src.pro b/src/src.pro new file mode 100644 index 0000000..e323dcf --- /dev/null +++ b/src/src.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = quicktestlib imports +CONFIG += ordered |