Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Aug 9, 2024
1 parent 66fdd12 commit 5fbebcd
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions tests/python/test_organizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,32 @@ PYBIND11_MODULE(organizer, m)
using ::testing::Eq;
using ::testing::Return;

m.def(
"organizer",
[]() -> IOrganizer* {
MockOrganizer* mock = new NiceMock<MockOrganizer>();
ON_CALL(*mock, profileName).WillByDefault([&mock]() {
return "profile";
::testing::InitGoogleTest();

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};
ON_CALL(*mock, startApplication)
.WillByDefault([handle](const auto& name, auto&&... args) {
return name == "valid.exe" ? handle : INVALID_HANDLE_VALUE;
});
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,
LPDWORD exitCode) {
if (handle == original_handle) {
*exitCode = 0;
return true;
}
else {
*exitCode = static_cast<DWORD>(-1);
return false;
}
});

return mock;
},
py::return_value_policy::take_ownership);
ON_CALL(*mock, waitForApplication)
.WillByDefault([&mock, original_handle = handle](HANDLE handle, bool,
LPDWORD exitCode) {
if (handle == original_handle) {
*exitCode = 0;
return true;
}
else {
*exitCode = static_cast<DWORD>(-1);
return false;
}
});

return mock;
});
}

0 comments on commit 5fbebcd

Please sign in to comment.