[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui/tests
From: Stephen Kelly <steveire () gmail ! com>
Date: 2010-03-22 13:30:59
Message-ID: 20100322133059.673A8AC873 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1106317 by skelly:
Implement some new tests and verify that emitted tests had a response.
M +6 -0 kselectionproxymodeltest.cpp
M +71 -2 proxymodeltestsuite/modelcommander.cpp
M +29 -0 proxymodeltestsuite/proxymodeltest.cpp
M +23 -5 proxymodeltestsuite/proxymodeltest.h
--- trunk/KDE/kdelibs/kdeui/tests/kselectionproxymodeltest.cpp #1106316:1106317
@@ -87,6 +87,12 @@
newInsertTest("insert10", indexFinder, 0, 4, 10);
newInsertTest("insert11", indexFinder, 10, 14, 10);
newInsertTest("insert12", indexFinder, 4, 8, 10);
+ noopTest("insert13");
+ noopTest("insert14");
+ noopTest("insert15");
+ noopTest("insert16");
+ noopTest("insert17");
+ noopTest("insert18");
}
template<>
--- trunk/KDE/kdelibs/kdeui/tests/proxymodeltestsuite/modelcommander.cpp \
#1106316:1106317 @@ -35,6 +35,9 @@
<< "insert02"
<< "insert03";
+ if(dataTag.isEmpty())
+ return testData;
+
if (dataTag == testData.at(0))
{
// Insert a single item at the top.
@@ -58,7 +61,7 @@
" - - 9"
);
} else {
- qDebug() << dataTag;
+ kDebug() << dataTag;
return testData;
}
execute(ins);
@@ -181,8 +184,16 @@
<< "insert09"
<< "insert10"
<< "insert11"
- << "insert12";
+ << "insert12"
+ << "insert13"
+ << "insert14"
+ << "insert15"
+ << "insert16"
+ << "insert17"
+ << "insert18";
+ if(dataTag.isEmpty())
+ return testData;
ModelInsertCommand *ins = new ModelInsertCommand(m_model, this);
if (dataTag == testData.at(0))
@@ -311,6 +322,64 @@
" - 9"
" - - 10"
);
+ } else if (dataTag == testData.at(12))
+ {
+ // Insert 5 items, some of which are parents in the middle
+ ins->setAncestorRowNumbers(rowAncestors << 0);
+ ins->setStartRow(0);
+ ins->setEndRow(0);
+ } else if (dataTag == testData.at(13))
+ {
+ // Insert 5 items, some of which are parents in the middle
+ ins->setAncestorRowNumbers(rowAncestors << 0);
+ ins->setStartRow(0);
+ ins->setEndRow(9);
+ } else if (dataTag == testData.at(14))
+ {
+ // Insert 5 items, some of which are parents in the middle
+ ins->setAncestorRowNumbers(rowAncestors << 0);
+ ins->setStartRow(0);
+ ins->interpret(
+ " - 1"
+ " - - 2"
+ " - 3"
+ " - 4"
+ " - - 5"
+ " - - 6"
+ " - - - 7"
+ " - 8"
+ " - 9"
+ " - - 10"
+ );
+ } else if (dataTag == testData.at(15))
+ {
+ // Insert 5 items, some of which are parents in the middle
+ ins->setAncestorRowNumbers(rowAncestors << 9);
+ ins->setStartRow(0);
+ ins->setEndRow(0);
+ } else if (dataTag == testData.at(16))
+ {
+ // Insert 5 items, some of which are parents in the middle
+ ins->setAncestorRowNumbers(rowAncestors << 9);
+ ins->setStartRow(0);
+ ins->setEndRow(9);
+ } else if (dataTag == testData.at(17))
+ {
+ // Insert 5 items, some of which are parents in the middle
+ ins->setAncestorRowNumbers(rowAncestors << 9);
+ ins->setStartRow(0);
+ ins->interpret(
+ " - 1"
+ " - - 2"
+ " - 3"
+ " - 4"
+ " - - 5"
+ " - - 6"
+ " - - - 7"
+ " - 8"
+ " - 9"
+ " - - 10"
+ );
} else {
kDebug() << dataTag;
delete ins;
--- trunk/KDE/kdelibs/kdeui/tests/proxymodeltestsuite/proxymodeltest.cpp \
#1106316:1106317 @@ -59,6 +59,23 @@
QMetaObject::invokeMethod(m_modelCommander, QString("init_" + \
currentTest).toAscii(), Q_ARG(QString, currentTag)); }
+void ProxyModelTest::verifyExecutedTests()
+{
+ QSet<QString> unimplemented = \
m_modelCommanderTags.toSet().subtract(m_dataTags.toSet()); + QString \
unimplementedTestsString("("); + foreach(const QString &test, unimplemented)
+ unimplementedTestsString.append(test + ",");
+ unimplementedTestsString.append(")");
+
+ if (!unimplemented.isEmpty())
+ {
+ QString failString = QString("Some tests in %1 were not implemented: \
%2").arg(m_currentTest, unimplementedTestsString); + m_dataTags.clear();
+ m_currentTest = QTest::currentTestFunction();
+ QFAIL(failString.toAscii());
+ }
+}
+
void ProxyModelTest::init()
{
QVERIFY(m_modelSpy->isEmpty());
@@ -80,6 +97,16 @@
// Get the model into the state it is expected to be in.
m_modelSpy->startSpying();
QVERIFY(m_modelSpy->isEmpty());
+
+ if (m_currentTest != currentTest)
+ {
+ verifyExecutedTests();
+ m_dataTags.clear();
+ QString metaMethod = QString("execute_" + QLatin1String(currentTest));
+ QMetaObject::invokeMethod(m_modelCommander, metaMethod.toAscii(), \
Q_RETURN_ARG(QStringList, m_modelCommanderTags), Q_ARG(QString, QString())); + \
m_currentTest = currentTest; + }
+ m_dataTags.append(currentTag);
}
void ProxyModelTest::cleanup()
@@ -95,6 +122,8 @@
void ProxyModelTest::cleanupTestCase()
{
+ verifyExecutedTests();
+ m_modelCommanderTags.clear();
if (!m_intermediateProxyModel)
return;
--- trunk/KDE/kdelibs/kdeui/tests/proxymodeltestsuite/proxymodeltest.h \
#1106316:1106317 @@ -124,16 +124,16 @@
void testSourceReset();
void testDestroyModel();
- void testInsertWhenEmpty_data() { clearDataTags(); testInsertWhenEmptyData(); }
+ void testInsertWhenEmpty_data() { testInsertWhenEmptyData(); }
void testInsertWhenEmpty() { doTest(); }
- void testInsertInRoot_data() { clearDataTags(); testInsertInRootData(); }
+ void testInsertInRoot_data() { testInsertInRootData(); }
void testInsertInRoot() { doTest(); }
- void testInsertInTopLevel_data() { clearDataTags(); testInsertInTopLevelData(); }
+ void testInsertInTopLevel_data() { testInsertInTopLevelData(); }
void testInsertInTopLevel() { doTest(); }
- void testInsertInSecondLevel_data() { clearDataTags(); \
testInsertInSecondLevelData(); } + void testInsertInSecondLevel_data() { \
testInsertInSecondLevelData(); } void testInsertInSecondLevel() { doTest(); }
protected:
@@ -148,8 +148,8 @@
void handleSignal(QVariantList expected);
QVariantList getResultSignal();
int getChange(bool sameParent, int start, int end, int currentPosition, int \
destinationStart);
- void clearDataTags() { m_dataTags.clear(); }
QStringList dataTags() const { return m_dataTags; }
+ void verifyExecutedTests();
private:
DynamicTreeModel *m_rootModel;
@@ -159,6 +159,8 @@
ModelSpy *m_modelSpy;
ModelCommander *m_modelCommander;
QStringList m_dataTags;
+ QStringList m_modelCommanderTags;
+ QString m_currentTest;
};
class ProxyModelTestData : public QObject, BuiltinTestDataInterface
@@ -219,6 +221,16 @@
newInsertTest("insert10", indexFinder, 0, 4, 10);
newInsertTest("insert11", indexFinder, 10, 14, 10);
newInsertTest("insert12", indexFinder, 4, 8, 10);
+ QList<int> rows = indexFinder.rows();
+ rows.append(0);
+ newInsertTest("insert13", rows, 0, 0, 0);
+ newInsertTest("insert14", rows, 0, 9, 0);
+ newInsertTest("insert15", rows, 0, 4, 0);
+ rows = indexFinder.rows();
+ rows.append(9);
+ newInsertTest("insert16", rows, 0, 0, 0);
+ newInsertTest("insert17", rows, 0, 9, 0);
+ newInsertTest("insert18", rows, 0, 4, 0);
}
void newInsertTest(const QString &name, const IndexFinder &indexFinder, int start, \
int end, int rowCount) @@ -266,6 +278,12 @@
noopTest("insert10");
noopTest("insert11");
noopTest("insert12");
+ noopTest("insert13");
+ noopTest("insert14");
+ noopTest("insert15");
+ noopTest("insert16");
+ noopTest("insert17");
+ noopTest("insert18");
}
void noop_testInsertInTopLevelData()
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic