summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2010-12-06 10:31:12 +1000
committerRhys Weatherley <rhys.weatherley@nokia.com>2010-12-06 10:31:12 +1000
commitab1dc4410d093ff1f296b2f0e302283adaba891a (patch)
tree88cbb1cdd6c609d8a2b8daf93b1e1bc77915323f /src
parenta6ccb850072f50278e673cbcbf6946769592ec40 (diff)
Add expectFail; remove global data tags
Diffstat (limited to 'src')
-rw-r--r--src/quicktestlib/qdeclarativetestresult.cpp76
-rw-r--r--src/quicktestlib/qdeclarativetestresult_p.h10
2 files changed, 20 insertions, 66 deletions
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<QByteArray> internedStrings;
- QMap<QString, int> 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
{
@@ -241,38 +238,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
This property returns true if the current test function has
@@ -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: