-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtestrunner.h
78 lines (53 loc) · 1.69 KB
/
testrunner.h
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
77
78
#ifndef TESTRUNNER_H
#define TESTRUNNER_H
#include <QObject>
#include <QQmlEngine>
#include <functional>
/// Multiple test case runner
class TestRunner
{
public:
TestRunner();
~TestRunner();
/// Add a QObject test suite
void add(QObject* object);
/// Add Qt Quick test suite
void add(const QString& path);
/// Add a QObject test suite
template <typename T> void add();
/// Execute test case with arguments
bool exec(QStringList arguments);
/// Add a import path for Qt Quick Test suite
void addImportPath(const QString& path);
/// Return no. of test objects added
int count() const;
/// The current arguments
QStringList arguments() const;
/// Get the default instance of TestRunner (The first declared TestRunner)
static TestRunner* defaultInstance();
QVariantMap config() const;
/// Set config variables that will be passed to QML application via TestRunner singleton object
void setConfig(const QVariantMap &config);
/// Set a callback to be invoked when a QQmlEngine start
void setEngineHook(std::function<void(QQmlEngine*)> func);
protected:
virtual void execEngineHook(QQmlEngine* engine);
private:
void add(QVariant value);
// Run QTest
bool run(QObject* object, const QStringList& arguments);
// Run Qt Quick Tests
bool run(QString path, const QStringList& arguments);
bool runGallery(const QStringList& arguments);
QVariantList m_testObjects;
QStringList m_importPaths;
QStringList m_arguments;
QVariantMap m_config;
std::function<void(QQmlEngine*)> m_engineHook;
};
template <typename T>
void TestRunner::add()
{
add(new T());
}
#endif // TESTRUNNER_H