-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathobs-setup.cpp
More file actions
68 lines (61 loc) · 1.76 KB
/
Copy pathobs-setup.cpp
File metadata and controls
68 lines (61 loc) · 1.76 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
#include <catch2/catch_test_macros.hpp>
#include "nodeobs_api.h"
#include "osn-error.hpp"
#include <obs.h>
#include "shared.hpp"
#include <string>
#include "obs-setup.hpp"
#include <vector>
namespace osn::tests {
void setWorkingFolder(const std::string &wd)
{
std::vector<ipc::value> args = {ipc::value(wd)};
std::vector<ipc::value> response;
OBS_API::SetWorkingDirectory(nullptr, 0, args, response);
REQUIRE(response.size() >= 2);
ErrorCode error = (ErrorCode)response[0].value_union.ui64;
CHECK(error == ErrorCode::Ok);
}
void setupApi()
{
#if defined(__APPLE__)
if (g_util_osx) {
delete g_util_osx;
g_util_osx = nullptr;
}
g_util_osx = new UtilInt();
g_util_osx->init();
// Workaround normal app startup where "browser_source" plugin is initialized
CHECK(!g_util_osx->hasInitApi());
g_util_osx->nextState();
CHECK(g_util_osx->hasInitApi());
#endif
const std::string appPath = std::string(OSN_SOURCE_DIR) + "/tests/osn-tests/osnData/slobs-client";
std::vector<ipc::value> args = {ipc::value(appPath), ipc::value("en-US"), ipc::value("0.00.00-preview.0"), ipc::value("")};
std::vector<ipc::value> response;
OBS_API::OBS_API_initAPI(nullptr, 0, args, response);
REQUIRE(response.size() >= 2);
ErrorCode error = (ErrorCode)response[0].value_union.ui64;
CHECK(error == ErrorCode::Ok);
}
ObsSetup::ObsSetup()
{
setWorkingFolder(OSN_TEST_WD);
setupApi();
}
ObsSetup::~ObsSetup()
{
std::vector<ipc::value> args = {};
std::vector<ipc::value> response;
OBS_API::OBS_API_destroyOBS_API(nullptr, 0, args, response);
CHECK(response.size() >= 1);
if (response.size() >= 1) {
ErrorCode error = (ErrorCode)response[0].value_union.ui64;
CHECK(error == ErrorCode::Ok);
}
#if defined(__APPLE__)
delete g_util_osx;
g_util_osx = nullptr;
#endif
}
} // namespace osn::tests