Switch VersionInfo -> Version for ModOrganizer2. (#132)

This commit is contained in:
Mikaël Capelle
2024-08-09 21:55:34 +02:00
committed by GitHub
parent 7cca7018b3
commit 2d151d0f66
4 changed files with 101 additions and 28 deletions
+1
View File
@@ -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));
+1
View File
@@ -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")
+25 -27
View File
@@ -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;
});
}