From e5b13e6eae3782163dc3414bd87158797d5af6e0 Mon Sep 17 00:00:00 2001 From: Charles Yin Date: Fri, 2 Sep 2011 15:44:47 +1000 Subject: [PATCH] make the testcase name the same in both plain text and xml/xunit logs for qmltest Change-Id: I911b3c7ba698b6c94aaa712eeaa917301c651e64 Reviewed-on: http://codereview.qt-project.org/4112 Reviewed-by: Qt Sanity Bot Reviewed-by: Rohan McGovern Reviewed-by: Jason McDonald --- src/qmltest/quicktestresult.cpp | 40 +++----------------------------------- tests/auto/qmltest/tst_qmltest.cpp | 2 +- 2 files changed, 4 insertions(+), 38 deletions(-) diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp index 80c3f8b..40b7d9b 100644 --- a/src/qmltest/quicktestresult.cpp +++ b/src/qmltest/quicktestresult.cpp @@ -78,7 +78,6 @@ public: } QByteArray intern(const QString &str); - void updateTestObjectName(); QString testCaseName; QString functionName; @@ -96,25 +95,6 @@ QByteArray QuickTestResultPrivate::intern(const QString &str) return *(internedStrings.insert(bstr)); } -void QuickTestResultPrivate::updateTestObjectName() -{ - // In plain logging mode we use the TestCase name as the - // class name so that multiple TestCase elements will report - // results with "testCase::function". In XML logging mode, - // we use the program name as the class name and report test - // functions as "testCase__function". - if (QTestLog::logMode() == QTestLog::Plain) { - if (testCaseName.isEmpty()) { - QTestResult::setCurrentTestObject(globalProgramName); - } else if (QTestLog::logMode() == QTestLog::Plain) { - QTestResult::setCurrentTestObject - (intern(testCaseName).constData()); - } - } else { - QTestResult::setCurrentTestObject(globalProgramName); - } -} - QuickTestResult::QuickTestResult(QObject *parent) : QObject(parent), d_ptr(new QuickTestResultPrivate) { @@ -144,7 +124,6 @@ void QuickTestResult::setTestCaseName(const QString &name) { Q_D(QuickTestResult); d->testCaseName = name; - d->updateTestObjectName(); emit testCaseNameChanged(); } @@ -167,15 +146,11 @@ void QuickTestResult::setFunctionName(const QString &name) { Q_D(QuickTestResult); if (!name.isEmpty()) { - // In plain logging mode, we use the function name directly. - // In XML logging mode, we use "testCase__functionName" as the - // program name is acting as the class name. - if (QTestLog::logMode() == QTestLog::Plain || - d->testCaseName.isEmpty()) { + if (d->testCaseName.isEmpty()) { QTestResult::setCurrentTestFunction (d->intern(name).constData()); } else { - QString fullName = d->testCaseName + QLatin1String("__") + name; + QString fullName = d->testCaseName + QLatin1String("::") + name; QTestResult::setCurrentTestFunction (d->intern(fullName).constData()); } @@ -342,15 +317,7 @@ void QuickTestResult::startLogging() Q_D(QuickTestResult); if (loggingStarted) return; - const char *saved = QTestResult::currentTestObjectName(); - if (globalProgramName) { - QTestResult::setCurrentTestObject(globalProgramName); - } else { - QTestResult::setCurrentTestObject - (d->intern(d->testCaseName).constData()); - } QTestLog::startLogging(); - QTestResult::setCurrentTestObject(saved); loggingStarted = true; } @@ -366,10 +333,8 @@ void QuickTestResult::stopLogging() Q_D(QuickTestResult); if (globalProgramName) return; // Logging will be stopped by setProgramName(0). - const char *saved = QTestResult::currentTestObjectName(); QTestResult::setCurrentTestObject(d->intern(d->testCaseName).constData()); QTestLog::stopLogging(); - QTestResult::setCurrentTestObject(saved); } void QuickTestResult::initTestTable() @@ -614,6 +579,7 @@ void QuickTestResult::setProgramName(const char *name) QTestResult::setCurrentTestObject(0); } globalProgramName = name; + QTestResult::setCurrentTestObject(globalProgramName); } int QuickTestResult::exitCode() diff --git a/tests/auto/qmltest/tst_qmltest.cpp b/tests/auto/qmltest/tst_qmltest.cpp index e1bad75..a1e8c03 100644 --- a/tests/auto/qmltest/tst_qmltest.cpp +++ b/tests/auto/qmltest/tst_qmltest.cpp @@ -40,4 +40,4 @@ ****************************************************************************/ #include -QUICK_TEST_MAIN(qmlauto) +QUICK_TEST_MAIN(qmltest) \ No newline at end of file -- 2.7.4