[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:48
Message-ID: 20100322133048.AC9A2AC880 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1106312 by skelly:
Add macros for test generation.
M +40 -0 kselectionproxymodeltestsuite.h
M +67 -1 proxymodeltestsuite/proxymodeltest.h
--- trunk/KDE/kdelibs/kdeui/tests/kselectionproxymodeltestsuite.h #1106311:1106312
@@ -129,6 +129,46 @@
*/
typedef ImmediateSelectionStrategy<0, 0, 0, 0, 0> NoSelectionStrategy;
+#define SELECTIONPROXYTESTDATA(SelectionStrategy, num1, num2, num3, num4, num5, \
Type) \ + new TestData<SelectionStrategy<num1, num2, num3, num4, num5>, \
Type>(proxyModelTestClass)
+#define SELECTIONPROXYTESTCONFIG(SelectionStrategy, num1, num2, num3, num4, num5, \
Type) \ + << " FilterBehavior: " << #Type << "\n" \
+ << " SelectionStrategy: " << #SelectionStrategy << (num1 > 0 ? #num1 : "") \
+ << (num2 > 0 ? #num2 : "") \
+ << (num3 > 0 ? #num3 : "") \
+ << (num4 > 0 ? #num4 : "") \
+ << (num5 > 0 ? #num5 : "") << \
"\n"; \
+#define SELECTIONPROXYMODELTEST(SelectionStrategy, num1, num2, num3, num4, num5, \
Type, IntermediateProxy, LazyPersistence) \ + \
PROXYMODELTEST_CUSTOM(SELECTIONPROXYTESTDATA(SelectionStrategy, num1, num2, num3, \
num4, num5, Type), IntermediateProxy, LazyPersistence, \
SELECTIONPROXYTESTCONFIG(SelectionStrategy, num1, num2, num3, num4, num5, Type)) +
+// #define SELECTIONCOMPLETETEST(SelectionStrategy, num1, num2, num3, num4, num5, \
Type) \ +// SELECTIONPROXYMODELTEST(SelectionStrategy, num1, num2, num3, num4, \
num5, Type, DynamicTree, ImmediatePersistence) \ +// \
SELECTIONPROXYMODELTEST(SelectionStrategy, num1, num2, num3, num4, num5, Type, \
IntermediateProxy, ImmediatePersistence) \ +// \
SELECTIONPROXYMODELTEST(SelectionStrategy, num1, num2, num3, num4, num5, Type, \
DynamicTree, LazyPersistence) \ +// SELECTIONPROXYMODELTEST(SelectionStrategy, \
num1, num2, num3, num4, num5, Type, IntermediateProxy, LazyPersistence) \ +
+#define SELECTIONCOMPLETETEST(SelectionStrategy, num1, num2, num3, num4, num5, Type) \
\ + SELECTIONPROXYMODELTEST(SelectionStrategy, num1, num2, num3, num4, num5, Type, \
DynamicTree, ImmediatePersistence) \ + SELECTIONPROXYMODELTEST(SelectionStrategy, \
num1, num2, num3, num4, num5, Type, DynamicTree, LazyPersistence) \ +
+#define SIMPLETESTDATA(SelectionStrategy, Type) \
+ new TestData<SelectionStrategy, Type>(proxyModelTestClass)
+
+#define SELECTIONPROXYMODELSIMPLETEST(SelectionStrategy, Type) \
+PROXYMODELTEST_CUSTOM(SIMPLETESTDATA(SelectionStrategy, Type), DynamicTree, \
LazyPersistence, SELECTIONPROXYTESTCONFIG(SelectionStrategy, 0, 0, 0, 0, 0, Type)) +
+#define SELECTIONCOMPLETETEST1(SelectionStrategy, num1, Type) \
+ SELECTIONCOMPLETETEST(SelectionStrategy, num1, 0, 0, 0, 0, Type) \
+
+#define SELECTIONCOMPLETETEST2(SelectionStrategy, num1, num2, Type) \
+ SELECTIONCOMPLETETEST(SelectionStrategy, num1, num2, 0, 0, 0, Type) \
+
+#define SELECTIONCOMPLETETEST3(SelectionStrategy, num1, num2, num3, Type) \
+ SELECTIONCOMPLETETEST(SelectionStrategy, num1, num2, num3, 0, 0, Type) \
+
+#define SELECTIONCOMPLETETEST4(SelectionStrategy, num1, num2, num3, num4, Type) \
+ SELECTIONCOMPLETETEST(SelectionStrategy, num1, num2, num3, num4, 0, Type) \
+
#endif
--- trunk/KDE/kdelibs/kdeui/tests/proxymodeltestsuite/proxymodeltest.h \
#1106311:1106312 @@ -22,7 +22,6 @@
#include <QtTest>
#include <QtCore>
-#include <qtest_kde.h>
#include <qtestevent.h>
#include <QItemSelectionRange>
#include <QAbstractProxyModel>
@@ -285,5 +284,72 @@
QSet<QString> m_testNames;
};
+#define PROXYMODELTEST(TestData, TemplateArg, IntermediateProxy, LazyPersistence, \
Config) \ + if (testObjects.isEmpty() || testObjects.contains(testNum)) { \
+ proxyModelTestClass->setTestData(new \
TestData<TemplateArg>(proxyModelTestClass)); \ + \
proxyModelTestClass->setUseIntermediateProxy(IntermediateProxy); \ + \
proxyModelTestClass->setLazyPersistence(LazyPersistence); \ + qDebug() << "\n \
Running" << proxyModelTestClass->objectName().toAscii() << testNum << ":\n" \ + \
<< " Source Model: " << #IntermediateProxy << "\n" \ + << " \
Persistence: " << #LazyPersistence << "\n" \ + Config; \
+ result = QTest::qExec(proxyModelTestClass, arguments); \
+ if (result != 0) \
+ return result; \
+ } \
+ ++testNum; \
+#define PROXYMODELTEST_CUSTOM(TestData, IntermediateProxy, LazyPersistence, Config) \
\ + if (testObjects.isEmpty() || testObjects.contains(testNum)) { \
+ proxyModelTestClass->setTestData(TestData); \
+ proxyModelTestClass->setUseIntermediateProxy(IntermediateProxy); \
+ proxyModelTestClass->setLazyPersistence(LazyPersistence); \
+ qDebug() << "\n Running" << proxyModelTestClass->objectName().toAscii() << \
testNum << ":\n" \ + << " Source Model: " << #IntermediateProxy << \
"\n" \ + << " Persistence: " << #LazyPersistence << "\n" \
+ Config; \
+ result = QTest::qExec(proxyModelTestClass, arguments); \
+ if (result != 0) \
+ return result; \
+ } \
+ ++testNum; \
+
+// The DynamicTreeModel uses a unique internalId for the first column of each row.
+// In the QSortFilterProxyModel the internalId is shared between all rows of the \
same parent. +// We test the proxy on top of both so that we know it is not using the \
internalId of its source model +// which will be different each time the test is run.
+#define COMPLETETEST(TestData, TemplateArg, Config) \
+ PROXYMODELTEST(TestData, TemplateArg, DynamicTree, ImmediatePersistence, Config) \
+ PROXYMODELTEST(TestData, TemplateArg, IntermediateProxy, ImmediatePersistence, \
Config) \ + PROXYMODELTEST(TestData, TemplateArg, DynamicTree, LazyPersistence, \
Config) \ + PROXYMODELTEST(TestData, TemplateArg, IntermediateProxy, \
LazyPersistence, Config) \ +
+#define PROXYMODELTEST_MAIN(TestClass, Body) \
+ int main(int argc, char *argv[]) \
+ { \
+ QApplication app(argc, argv); \
+ QList<int> testObjects; \
+ QStringList arguments; \
+ bool ok; \
+ foreach(const QString &arg, app.arguments()) \
+ { \
+ int testObject = arg.toInt(&ok); \
+ if (!ok) \
+ { \
+ arguments.append(arg); \
+ continue; \
+ } \
+ testObjects.append(testObject); \
+ } \
+ TestClass *proxyModelTestClass = new TestClass(); \
+ proxyModelTestClass->setObjectName( #TestClass ); \
+ int result = 0; \
+ int testNum = 1; \
+ \
+ Body \
+ \
+ delete proxyModelTestClass; \
+ return result; \
+ } \
+
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic