mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Switch VersionInfo -> Version for ModOrganizer2. (#132)
This commit is contained in:
@@ -14,6 +14,7 @@ public:
|
||||
MOCK_METHOD(QString, basePath, (), (const, override));
|
||||
MOCK_METHOD(QString, modsPath, (), (const, override));
|
||||
MOCK_METHOD(VersionInfo, appVersion, (), (const, override));
|
||||
MOCK_METHOD(Version, version, (), (const, override));
|
||||
MOCK_METHOD(IModInterface*, createMod, (GuessedValue<QString> &name), (override));
|
||||
MOCK_METHOD(IPluginGame*, getGame, (const QString &gameName), (const, override));
|
||||
MOCK_METHOD(void, modDataChanged, (IModInterface *mod), (override));
|
||||
|
||||
@@ -53,6 +53,7 @@ foreach (test_file ${test_files})
|
||||
pybind11_add_module(${target} EXCLUDE_FROM_ALL THIN_LTO ${test_file})
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
CXX_STANDARD 20
|
||||
OUTPUT_NAME ${pymodule}
|
||||
FOLDER tests/python
|
||||
LIBRARY_OUTPUT_DIRECTORY "${PYLIB_DIR}/mobase_tests")
|
||||
|
||||
@@ -17,32 +17,30 @@ 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";
|
||||
});
|
||||
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;
|
||||
}
|
||||
});
|
||||
m.def("organizer", []() -> IOrganizer* {
|
||||
MockOrganizer* mock = new NiceMock<MockOrganizer>();
|
||||
ON_CALL(*mock, profileName).WillByDefault([&mock]() {
|
||||
return "profile";
|
||||
});
|
||||
|
||||
return mock;
|
||||
},
|
||||
py::return_value_policy::take_ownership);
|
||||
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;
|
||||
});
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user