-
-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathtftest.h
More file actions
76 lines (69 loc) · 5.57 KB
/
Copy pathtftest.h
File metadata and controls
76 lines (69 loc) · 5.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#pragma once
#include "tkvsdatabasepool.h"
#include "turlroute.h"
#include <QByteArray>
#include <QEventLoop>
#include <QObject>
#include <QtTest/QtTest>
#include <TAppSettings>
#include <TSystemGlobal>
#include <TStdErrSystemLogger>
#include <TWebApplication>
#ifdef QT_SQL_LIB
#include "tsqldatabasepool.h"
#include <TActionThread>
#endif
#ifdef Q_OS_LINUX
#include <TMultiplexingServer>
#endif
#define TF_TEST_MAIN(TestObject) TF_TEST_SQL_MAIN(TestObject, true);
#define TF_TEST_SQL_MAIN(TestObject, EnableTransactions) \
int main(int argc, char *argv[]) \
{ \
class Thread : public TActionThread { \
public: \
Thread() : TActionThread(0), returnCode(0) { } \
volatile int returnCode; \
protected: \
virtual void run() \
{ \
setTransactionEnabled(EnableTransactions); \
TestObject obj; \
returnCode = QTest::qExec(&obj, QCoreApplication::arguments()); \
commitTransactions(); \
for (QMap<int, TSqlTransaction>::iterator it = sqlDatabases.begin(); it != sqlDatabases.end(); ++it) { \
it.value().database().close(); /* close SQL database */ \
} \
for (QMap<int, TKvsDatabase>::iterator it = kvsDatabases.begin(); it != kvsDatabases.end(); ++it) { \
it.value().close(); /* close KVS database */ \
} \
QEventLoop eventLoop; \
while (eventLoop.processEvents()) { \
} \
} \
}; \
TWebApplication app(argc, argv); \
Tf::setupSystemLogger(new TStdErrSystemLogger); \
app.setDatabaseEnvironment("test"); \
TUrlRoute::instance(); \
TSqlDatabasePool::instance(); \
TKvsDatabasePool::instance(); \
INIT_MULTIPLEXING_SERVER(); \
Thread thread; \
thread.start(); \
thread.wait(); \
return thread.returnCode; \
}
#define TF_TEST_SQLLESS_MAIN(TestObject) \
int main(int argc, char *argv[]) \
{ \
TWebApplication app(argc, argv); \
Tf::setupSystemLogger(new TStdErrSystemLogger); \
TestObject tc; \
return QTest::qExec(&tc, argc, argv); \
}
#ifdef Q_OS_LINUX
#define INIT_MULTIPLEXING_SERVER() TMultiplexingServer::instantiate(0)
#else
#define INIT_MULTIPLEXING_SERVER()
#endif