-
Notifications
You must be signed in to change notification settings - Fork 10
/
test_organizer.cpp
48 lines (41 loc) · 1.46 KB
/
test_organizer.cpp
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
#include "pybind11_qt/pybind11_qt.h"
#include <pybind11/pybind11.h>
#include <QMap>
#include <QWidget>
#include "MockOrganizer.h"
namespace py = pybind11;
using namespace pybind11::literals;
using ::testing::NiceMock;
PYBIND11_MODULE(organizer, m)
{
using ::testing::_;
using ::testing::Eq;
using ::testing::Return;
m.def(
"organizer",
[]() -> IOrganizer* {
MockOrganizer* mock = new NiceMock<MockOrganizer>();
ON_CALL(*mock, profileName).WillByDefault([&mock]() {
return "profile";
});
const auto handle = (HANDLE)std::uintptr_t{4654};
EXPECT_CALL(*mock, startApplication(Eq("valid.exe"), _, _, _, _, _))
.WillRepeatedly(Return(handle));
EXPECT_CALL(*mock, startApplication(Eq("invalid.exe"), _, _, _, _, _))
.WillRepeatedly(Return(INVALID_HANDLE_VALUE));
ON_CALL(*mock, waitForApplication)
.WillByDefault([&mock, original_handle = handle](
HANDLE handle, bool refresh, LPDWORD exitCode) {
if (handle == original_handle) {
*exitCode = 0;
return true;
}
else {
*exitCode = -1;
return false;
}
});
return mock;
},
py::return_value_policy::take_ownership);
}