summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWater-Team <water@pad.test.qt.nokia.com>2011-07-26 23:00:12 (GMT)
committerWater-Team <water@pad.test.qt.nokia.com>2011-07-26 23:00:12 (GMT)
commita92f10160c94af56bdcbc1f40784a28273563b5c (patch)
tree7277454c7d563a6d67a31e2cded502639a011794 /src
parenta9f3783e9402354f7211c9c293627b34f1080251 (diff)
parentaa19362a14ce20bde2ada61edf7b946019845ed2 (diff)
downloadQt-a92f10160c94af56bdcbc1f40784a28273563b5c.zip
Qt-a92f10160c94af56bdcbc1f40784a28273563b5c.tar.gz
Qt-a92f10160c94af56bdcbc1f40784a28273563b5c.tar.bz2
Merge branch '4.8-upstream' into master-water
Diffstat (limited to 'src')
-rw-r--r--src/testlib/qtestcase.cpp68
-rw-r--r--src/testlib/qtestlog.cpp11
2 files changed, 79 insertions, 0 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 023df89..d2ea988 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1015,6 +1015,7 @@ static bool isValidSlot(const QMetaMethod &sl)
}
Q_TESTLIB_EXPORT bool printAvailableFunctions = false;
+Q_TESTLIB_EXPORT bool printAvailableTags = false;
Q_TESTLIB_EXPORT QStringList testFunctions;
Q_TESTLIB_EXPORT QStringList testTags;
@@ -1027,6 +1028,65 @@ static void qPrintTestSlots()
}
}
+static void qPrintDataTags()
+{
+ // Get global data tags:
+ QTestTable::globalTestTable();
+ invokeMethod(QTest::currentTestObject, "initTestCase_data()");
+ const QTestTable *gTable = QTestTable::globalTestTable();
+
+ const QMetaObject *currTestMetaObj = QTest::currentTestObject->metaObject();
+
+ // Process test functions:
+ for (int i = 0; i < currTestMetaObj->methodCount(); ++i) {
+ QMetaMethod tf = currTestMetaObj->method(i);
+ if (isValidSlot(tf)) {
+ // Retrieve local tags:
+ QStringList localTags;
+ QTestTable table;
+ char member[512];
+ char *slot = qstrdup(tf.signature());
+ slot[strlen(slot) - 2] = '\0';
+ QTest::qt_snprintf(member, 512, "%s_data()", slot);
+ invokeMethod(QTest::currentTestObject, member);
+ for (int j = 0; j < table.dataCount(); ++j)
+ localTags << QLatin1String(table.testData(j)->dataTag());
+
+ // Print all tag combinations:
+ if (gTable->dataCount() == 0) {
+ if (localTags.count() == 0) {
+ // No tags at all, so just print the test function:
+ printf("%s %s\n", currTestMetaObj->className(), slot);
+ } else {
+ // Only local tags, so print each of them:
+ for (int k = 0; k < localTags.size(); ++k)
+ printf(
+ "%s %s %s\n",
+ currTestMetaObj->className(), slot, localTags.at(k).toLatin1().data());
+ }
+ } else {
+ for (int j = 0; j < gTable->dataCount(); ++j) {
+ if (localTags.count() == 0) {
+ // Only global tags, so print the current one:
+ printf(
+ "%s %s __global__ %s\n",
+ currTestMetaObj->className(), slot, gTable->testData(j)->dataTag());
+ } else {
+ // Local and global tags, so print each of the local ones and
+ // the current global one:
+ for (int k = 0; k < localTags.size(); ++k)
+ printf(
+ "%s %s %s __global__ %s\n", currTestMetaObj->className(), slot,
+ localTags.at(k).toLatin1().data(), gTable->testData(j)->dataTag());
+ }
+ }
+ }
+
+ delete[] slot;
+ }
+ }
+}
+
static int qToInt(char *str)
{
char *pEnd;
@@ -1043,6 +1103,8 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
const char *testOptions =
" options:\n"
" -functions : Returns a list of current testfunctions\n"
+ " -datatags : Returns a list of current data tags.\n"
+ " A global data tag is preceded by ' __global__ '.\n"
" -xunitxml : Outputs results as XML XUnit document\n"
" -xml : Outputs results as XML document\n"
" -lightxml : Outputs results as stream of XML tags\n"
@@ -1094,6 +1156,12 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
qPrintTestSlots();
exit(0);
}
+ } else if (strcmp(argv[i], "-datatags") == 0) {
+ QTest::printAvailableTags = true;
+ if (!qml) {
+ qPrintDataTags();
+ exit(0);
+ }
} else if(strcmp(argv[i], "-xunitxml") == 0){
QTestLog::setLogMode(QTestLog::XunitXML);
} else if (strcmp(argv[i], "-xml") == 0) {
diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp
index 8a2d559..03fafe0 100644
--- a/src/testlib/qtestlog.cpp
+++ b/src/testlib/qtestlog.cpp
@@ -191,6 +191,8 @@ void initLogger()
}
}
+extern Q_TESTLIB_EXPORT bool printAvailableTags;
+
}
QTestLog::QTestLog()
@@ -203,6 +205,9 @@ QTestLog::~QTestLog()
void QTestLog::enterTestFunction(const char* function)
{
+ if (QTest::printAvailableTags)
+ return;
+
QTEST_ASSERT(QTest::testLogger);
QTEST_ASSERT(function);
@@ -222,6 +227,9 @@ int QTestLog::unhandledIgnoreMessages()
void QTestLog::leaveTestFunction()
{
+ if (QTest::printAvailableTags)
+ return;
+
QTEST_ASSERT(QTest::testLogger);
QTest::IgnoreResultList::clearList(QTest::ignoreResultList);
@@ -244,6 +252,9 @@ void QTestLog::printUnhandledIgnoreMessages()
void QTestLog::addPass(const char *msg)
{
+ if (QTest::printAvailableTags)
+ return;
+
QTEST_ASSERT(QTest::testLogger);
QTEST_ASSERT(msg);