/
gtest_qapp_main.cc
45 lines (41 loc) · 972 Bytes
/
gtest_qapp_main.cc
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
#include <QApplication>
#include <QThread>
#include <stdio.h>
#include "gtest/gtest.h"
#if defined _WIN32 || defined __CYGWIN__
#define TFW_PUBLIC __declspec(dllexport)
#define TFW_LOCAL
#else
#define TFW_PUBLIC
#define TFW_LOCAL __declspec(dllimport)
#endif
class TFW_PUBLIC Thread : public QThread
{
private:
int mArgc;
char ** mArgv;
public:
Thread(int& argc, char ** argv)
{
mArgc = argc;
mArgv = argv;
result = 0;
}
int result;
void run() {
printf("Running main() from testframework/gtest_qtapp_main.cc\n");
testing::InitGoogleTest(&mArgc, mArgv);
result = RUN_ALL_TESTS();
}
}; // class Thread
int TFW_PUBLIC main(int argc, char **argv) {
QApplication app(argc, argv);
int result = 0;
Thread thread(argc, argv);
thread.start();
app.connect(&thread
, SIGNAL(finished())
, SLOT(quit()));
result = app.exec();
return result + thread.result;
}