Files
modorganizer-plugin_python/tests/python/test_organizer.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.5 KiB
C++
Raw Normal View History

2022-05-02 17:09:36 +02:00
#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;
2022-05-02 17:09:36 +02:00
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));
2022-05-02 17:09:36 +02:00
ON_CALL(*mock, waitForApplication)
2024-07-09 20:42:56 +02:00
.WillByDefault([&mock, original_handle = handle](HANDLE handle, bool,
LPDWORD exitCode) {
2022-05-02 17:09:36 +02:00
if (handle == original_handle) {
*exitCode = 0;
return true;
}
else {
2024-07-09 20:42:56 +02:00
*exitCode = static_cast<DWORD>(-1);
2022-05-02 17:09:36 +02:00
return false;
}
});
return mock;
},
py::return_value_policy::take_ownership);
}