-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathmixxxtest.h
More file actions
79 lines (59 loc) · 2.04 KB
/
mixxxtest.h
File metadata and controls
79 lines (59 loc) · 2.04 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
77
78
79
#pragma once
#include <gtest/gtest.h>
#include <QDir>
#include <QScopedPointer>
#include <QTemporaryDir>
#include "mixxxapplication.h"
#include "preferences/usersettings.h"
#define EXPECT_QSTRING_EQ(expected, test) EXPECT_STREQ(qPrintable(expected), qPrintable(test))
#define ASSERT_QSTRING_EQ(expected, test) ASSERT_STREQ(qPrintable(expected), qPrintable(test))
namespace {
// We assume that the test folder is a sibling to the res folder
const QString kTestPath = QStringLiteral("../src/test");
} // namespace
class MixxxTest : public testing::Test {
public:
MixxxTest();
~MixxxTest() override;
// ApplicationScope creates QApplication as a singleton and keeps
// it alive during all tests. This prevents issues with creating
// and destroying the QApplication multiple times in the same process.
// http://stackoverflow.com/questions/14243858/qapplication-segfaults-in-googletest
class ApplicationScope final {
public:
ApplicationScope(int& argc, char** argv);
~ApplicationScope();
};
friend class ApplicationScope;
static const QDir& getOrInitTestDir() {
if (s_TestDir.path() == ".") {
s_TestDir.setPath(
QDir::cleanPath(ConfigObject<ConfigValue>::computeResourcePath() + kTestPath));
}
return s_TestDir;
}
protected:
static QApplication* application() {
return s_pApplication.data();
}
UserSettingsPointer config() const {
return m_pConfig;
}
// Simulate restarting Mixxx by saving and reloading the UserSettings.
void saveAndReloadConfig();
QDir getTestDataDir() const {
return m_testDataDir.path();
}
const QDir& getTestDir() const {
return getOrInitTestDir();
}
private:
static QScopedPointer<MixxxApplication> s_pApplication;
static QDir s_TestDir;
const QTemporaryDir m_testDataDir;
protected:
UserSettingsPointer m_pConfig;
};
namespace mixxxtest {
void copyFile(const QString& srcFileName, const QString& dstFileName);
} // namespace mixxxtest