mirror of
https://github.com/eclipse-openvehicle-api/openvehicle-api.git
synced 2026-08-30 12:15:12 +00:00
connection between 2 systems and bug fixes (#14)
This commit is contained in:
@@ -21,9 +21,11 @@
|
||||
#include "../../../sdv_services/core/toml_parser/character_reader_utf_8.cpp"
|
||||
#include "../../../sdv_services/core/toml_parser/miscellaneous.cpp"
|
||||
#include "../../../sdv_services/core/toml_parser/code_snippet.cpp"
|
||||
#include "../../../sdv_services/core/toml_parser/parser_node_indexer.cpp"
|
||||
#include "../../../sdv_services/core/module_control.cpp"
|
||||
#include "../../../sdv_services/core/module.cpp"
|
||||
#include "../../../sdv_services/core/repository.cpp"
|
||||
#include "../../../sdv_services/core/permission_control.cpp"
|
||||
#include "../../../sdv_services/core/iso_monitor.cpp"
|
||||
#include "../../../sdv_services/core/object_lifetime_control.cpp"
|
||||
#include "../../../sdv_services/core/app_config.cpp"
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define MOCK_H
|
||||
|
||||
#include <interfaces/app.h>
|
||||
#include <interfaces/permission.h>
|
||||
#include <support/component_impl.h>
|
||||
#include "../../../global/exec_dir_helper.h"
|
||||
#include "../../../sdv_services/core/installation_manifest.h"
|
||||
@@ -24,6 +25,7 @@
|
||||
#define APP_CONTROL_H
|
||||
#define LOGGER_H
|
||||
#define LOGGER_CONTROL_H
|
||||
//#define PERMISSION_CONTROL_H
|
||||
|
||||
/**
|
||||
* @brief CAppSettings redefined
|
||||
@@ -45,6 +47,7 @@ public:
|
||||
bool IsConsoleSilent() { return true; }
|
||||
bool IsConsoleVerbose() { return false; }
|
||||
uint32_t GetInstanceID() { return 1000u; }
|
||||
std::filesystem::path GetFrameworkDir() const { return GetExecDirectory(); }
|
||||
std::filesystem::path GetRootDir() const { return GetExecDirectory(); }
|
||||
std::filesystem::path GetInstallDir() const { return GetExecDirectory(); }
|
||||
std::vector<std::filesystem::path> GetSystemConfigPaths() const { return {}; }
|
||||
@@ -105,15 +108,36 @@ inline CLoggerControl& GetLoggerControl()
|
||||
return logger_control;
|
||||
}
|
||||
|
||||
///**
|
||||
// * @brief CPermissionControl redefined
|
||||
// */
|
||||
//class CPermissionControl : public sdv::IInterfaceAccess
|
||||
//{
|
||||
//public:
|
||||
// BEGIN_SDV_INTERFACE_MAP()
|
||||
// END_SDV_INTERFACE_MAP()
|
||||
//
|
||||
// // CPermissionControl mocked functions
|
||||
// virtual sdv::core::EAccessPermission GetCurrentPermission() const { return sdv::core::EAccessPermission::full_access; }
|
||||
//};
|
||||
//
|
||||
///**
|
||||
// * @brief Return the permission control.
|
||||
// * @return Reference to the permission control.
|
||||
// */
|
||||
//inline CPermissionControl& GetPermissionControl()
|
||||
//{
|
||||
// static CPermissionControl control;
|
||||
// return control;
|
||||
//}
|
||||
//
|
||||
#include "../../../sdv_services/core/toml_parser/parser_toml.h"
|
||||
#include "../../../sdv_services/core/toml_parser/parser_node_toml.h"
|
||||
#include "../../../sdv_services/core/module_control.h"
|
||||
#include "../../../sdv_services/core/repository.h"
|
||||
#include "../../../sdv_services/core/permission_control.h"
|
||||
#include "../../../sdv_services/core/app_config.h"
|
||||
|
||||
//inline std::filesystem::path GetCoreDirectoryMock() { return "../../bin"; }
|
||||
//#define GetCoreDirectory GetCoreDirectoryMock
|
||||
|
||||
class CHelper
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
SDV_INTERFACE_ENTRY(sdv::IObjectControl)
|
||||
END_SDV_INTERFACE_MAP()
|
||||
|
||||
virtual void Initialize([[maybe_unused]] const sdv::u8string& ssObjectConfig) override
|
||||
virtual void Initialize([[maybe_unused]] const sdv::SObjectInfo& sObjectInfo) override
|
||||
{
|
||||
FAIL() << "Error: Initialize should not be called by Repo Service!";
|
||||
//m_eObjectState = sdv::EObjectState::initialization_failure;
|
||||
@@ -91,8 +91,8 @@ TEST(RepositoryTest, CreateNonexistentClass)
|
||||
CModuleControl modulectrl;
|
||||
CHelper helper(modulectrl, repository);
|
||||
ASSERT_TRUE(modulectrl.Load((GetExecDirectory() / "UnitTest_Repository_test_module.sdv").generic_u8string()));
|
||||
EXPECT_FALSE(repository.CreateObject2("TestFooBar", nullptr, nullptr));
|
||||
repository.DestroyObject2("TestFooBar");
|
||||
EXPECT_FALSE(repository.CreateObject("TestFooBar", nullptr, nullptr));
|
||||
EXPECT_FALSE(repository.DestroyObject("TestFooBar"));
|
||||
}
|
||||
|
||||
TEST(RepositoryTest, GetNonexistentObject)
|
||||
@@ -100,11 +100,11 @@ TEST(RepositoryTest, GetNonexistentObject)
|
||||
CRepository repository; // Must be created first
|
||||
CModuleControl modulectrl;
|
||||
CHelper helper(modulectrl, repository);
|
||||
auto permission = GetPermissionControl().CreatePermissionObject(sdv::core::EAccessPermission::full_access);
|
||||
ASSERT_TRUE(modulectrl.Load((GetExecDirectory() / "UnitTest_Repository_test_module.sdv").generic_u8string()));
|
||||
bool bRes = repository.CreateObject2("Example_Object", nullptr, nullptr);
|
||||
EXPECT_TRUE(bRes);
|
||||
EXPECT_TRUE(repository.CreateObject("Example_Object", nullptr, nullptr));
|
||||
EXPECT_EQ(nullptr, repository.GetObject("TestFooBar"));
|
||||
repository.DestroyObject2("Example_Object");
|
||||
EXPECT_TRUE(repository.DestroyObject("Example_Object"));
|
||||
}
|
||||
|
||||
TEST(RepositoryTest, InstantiateAndGet)
|
||||
@@ -112,11 +112,12 @@ TEST(RepositoryTest, InstantiateAndGet)
|
||||
CRepository repository; // Must be created first
|
||||
CModuleControl modulectrl;
|
||||
CHelper helper(modulectrl, repository);
|
||||
auto permission = GetPermissionControl().CreatePermissionObject(sdv::core::EAccessPermission::full_access);
|
||||
ASSERT_TRUE(modulectrl.Load((GetExecDirectory() / "UnitTest_Repository_test_module.sdv").generic_u8string()));
|
||||
bool bRes = repository.CreateObject2("Example_Object", nullptr, nullptr);
|
||||
bool bRes = repository.CreateObject("Example_Object", nullptr, nullptr);
|
||||
EXPECT_TRUE(bRes);
|
||||
EXPECT_NE(nullptr, repository.GetObject("Example_Object"));
|
||||
repository.DestroyObject2("Example_Object");
|
||||
EXPECT_TRUE(repository.DestroyObject("Example_Object"));
|
||||
EXPECT_EQ(nullptr, repository.GetObject("Example_Object"));
|
||||
}
|
||||
|
||||
@@ -126,8 +127,7 @@ TEST(RepositoryTest, InstantiateInitFail)
|
||||
CModuleControl modulectrl;
|
||||
CHelper helper(modulectrl, repository);
|
||||
ASSERT_TRUE(modulectrl.Load((GetExecDirectory() / "UnitTest_Repository_test_module.sdv").generic_u8string()));
|
||||
bool bRes = repository.CreateObject2("TestObject_IObjectControlFail", nullptr, nullptr);
|
||||
EXPECT_FALSE(bRes);
|
||||
EXPECT_FALSE(repository.CreateObject("TestObject_IObjectControlFail", nullptr, nullptr));
|
||||
EXPECT_EQ(nullptr, repository.GetObject("TestObject_IObjectControlFail"));
|
||||
repository.DestroyObject2("TestObject_IObjectControlFail");
|
||||
EXPECT_FALSE(repository.DestroyObject("TestObject_IObjectControlFail"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user