From ab1dc4410d093ff1f296b2f0e302283adaba891a Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 6 Dec 2010 10:31:12 +1000 Subject: Add expectFail; remove global data tags --- src/quicktestlib/qdeclarativetestresult.cpp | 76 +++++++---------------------- src/quicktestlib/qdeclarativetestresult_p.h | 10 +--- 2 files changed, 20 insertions(+), 66 deletions(-) (limited to 'src') diff --git a/src/quicktestlib/qdeclarativetestresult.cpp b/src/quicktestlib/qdeclarativetestresult.cpp index 40d2d01..0cc68e9 100644 --- a/src/quicktestlib/qdeclarativetestresult.cpp +++ b/src/quicktestlib/qdeclarativetestresult.cpp @@ -70,7 +70,6 @@ public: QString testCaseName; QString functionName; QSet internedStrings; - QMap globalTags; QTestTable *table; }; @@ -217,8 +216,6 @@ void QDeclarativeTestResult::setFunctionType(FunctionType type) This property defines the tag for the current row in a data-driven test, or an empty string if not a data-driven test. - - \sa globalDataTag */ QString QDeclarativeTestResult::dataTag() const { @@ -240,38 +237,6 @@ void QDeclarativeTestResult::setDataTag(const QString &tag) } } -/*! - \qmlproperty string TestResult::globalDataTag - - This property defines the tag for the current row in the - global data table, or the empty string if the global data - table is not in use. - - \sa dataTag, addGlobalDataTag() -*/ -QString QDeclarativeTestResult::globalDataTag() const -{ - const char *tag = QTestResult::currentGlobalDataTag(); - if (tag) - return QString::fromUtf8(tag); - else - return QString(); -} - -void QDeclarativeTestResult::setGlobalDataTag(const QString &tag) -{ - Q_D(QDeclarativeTestResult); - if (!tag.isEmpty()) { - int index = d->globalTags.value(tag, -1); - Q_ASSERT(index >= 0); - QTestResult::setCurrentGlobalTestData - (QTestTable::globalTestTable()->testData(index)); - } else { - QTestResult::setCurrentGlobalTestData(0); - } - emit globalDataTagChanged(); -} - /*! \qmlproperty bool TestResult::failed @@ -400,29 +365,6 @@ void QDeclarativeTestResult::stopLogging() QTestResult::setCurrentTestObject(saved); } -void QDeclarativeTestResult::initGlobalTestTable() -{ - Q_D(QDeclarativeTestResult); - d->globalTags.clear(); - QTestTable::clearGlobalTestTable(); - QTestTable::globalTestTable(); - Q_ASSERT(QTestTable::currentTestTable() == QTestTable::globalTestTable()); -} - -void QDeclarativeTestResult::clearGlobalTestTable() -{ - QTestTable::clearGlobalTestTable(); -} - -void QDeclarativeTestResult::addGlobalDataTag(const QString &tag) -{ - Q_D(QDeclarativeTestResult); - Q_ASSERT(!tag.isEmpty()); - if (!d->globalTags.contains(tag)) - d->globalTags.insert(tag, d->globalTags.count()); - QTest::newRow(tag.toUtf8().constData()); -} - void QDeclarativeTestResult::initTestTable() { Q_D(QDeclarativeTestResult); @@ -481,6 +423,24 @@ void QDeclarativeTestResult::skipAll(const QString &message) QTestResult::setSkipCurrentTest(true); } +bool QDeclarativeTestResult::expectFail + (const QString &tag, const QString &comment) +{ + return QTestResult::expectFail + (tag.toLatin1().constData(), + QTest::toString(comment.toLatin1().constData()), + QTest::Abort, "", 0); +} + +bool QDeclarativeTestResult::expectFailContinue + (const QString &tag, const QString &comment) +{ + return QTestResult::expectFail + (tag.toLatin1().constData(), + QTest::toString(comment.toLatin1().constData()), + QTest::Continue, "", 0); +} + void QDeclarativeTestResult::warn(const QString &message) { QTestLog::warn(message.toLatin1().constData()); diff --git a/src/quicktestlib/qdeclarativetestresult_p.h b/src/quicktestlib/qdeclarativetestresult_p.h index 2cc0822..c6720e0 100644 --- a/src/quicktestlib/qdeclarativetestresult_p.h +++ b/src/quicktestlib/qdeclarativetestresult_p.h @@ -60,7 +60,6 @@ class Q_TEST_QUICK_EXPORT QDeclarativeTestResult : public QObject Q_PROPERTY(QString functionName READ functionName WRITE setFunctionName NOTIFY functionNameChanged) Q_PROPERTY(FunctionType functionType READ functionType WRITE setFunctionType NOTIFY functionTypeChanged) Q_PROPERTY(QString dataTag READ dataTag WRITE setDataTag NOTIFY dataTagChanged) - Q_PROPERTY(QString globalDataTag READ globalDataTag WRITE setGlobalDataTag NOTIFY globalDataTagChanged) Q_PROPERTY(bool failed READ isFailed) Q_PROPERTY(bool dataFailed READ isDataFailed) Q_PROPERTY(bool skipped READ isSkipped WRITE setSkipped NOTIFY skippedChanged) @@ -96,9 +95,6 @@ public: QString dataTag() const; void setDataTag(const QString &tag); - QString globalDataTag() const; - void setGlobalDataTag(const QString &tag); - bool isFailed() const; bool isDataFailed() const; @@ -115,10 +111,6 @@ public Q_SLOTS: void startLogging(); void stopLogging(); - void initGlobalTestTable(); - void clearGlobalTestTable(); - void addGlobalDataTag(const QString &tag); - void initTestTable(); void clearTestTable(); @@ -130,6 +122,8 @@ public Q_SLOTS: const QString &val1, const QString &val2); void skipSingle(const QString &message); void skipAll(const QString &message); + bool expectFail(const QString &tag, const QString &comment); + bool expectFailContinue(const QString &tag, const QString &comment); void warn(const QString &message); Q_SIGNALS: -- cgit v1.2.3