From 2b4130595b438e92d85ddfa0d3a8756c2ff2b094 Mon Sep 17 00:00:00 2001 From: Fancy code <258828110.@qq.com> Date: Wed, 6 Mar 2024 18:00:02 -0800 Subject: [PATCH] Backup:test code. --- hal/src/HalCpp.cpp | 1 + hal/src/HalCpp.h | 1 + middleware/AppManager/CMakeLists.txt | 2 +- middleware/AppManager/src/AppManager.cpp | 2 +- .../application/HunttingCamera/CMakeLists.txt | 4 +- .../src_mock/HunttingCamera_Mock_Test.cpp | 9 ++- .../MissionManager/tool/CMakeLists.txt | 1 + .../tool/include/MissionManagerTestTool.h | 4 +- .../tool/src/MissionManagerMakePtrTest.cpp | 63 +++++++++++++++++++ .../tool/src/MissionManagerMakePtrTest.h | 32 ++++++++++ .../tool/src/MissionManagerMock.cpp | 40 ++++++++++++ .../tool/src/MissionManagerMock.h | 36 +++++++++++ .../tool/src/MissionManagerTestTool.cpp | 12 ++-- test/hal/tool/src/HalCppMock.cpp | 24 +++++-- test/hal/tool/src/HalCppMock.h | 3 + test/hal/tool/src/HalTestTool.cpp | 4 ++ test/hal/tool/src/WifiHalMock.cpp | 44 +++++++++++++ test/hal/tool/src/WifiHalMock.h | 39 ++++++++++++ 18 files changed, 303 insertions(+), 18 deletions(-) create mode 100644 test/application/MissionManager/tool/src/MissionManagerMakePtrTest.cpp create mode 100644 test/application/MissionManager/tool/src/MissionManagerMakePtrTest.h create mode 100644 test/application/MissionManager/tool/src/MissionManagerMock.cpp create mode 100644 test/application/MissionManager/tool/src/MissionManagerMock.h create mode 100644 test/hal/tool/src/WifiHalMock.cpp create mode 100644 test/hal/tool/src/WifiHalMock.h diff --git a/hal/src/HalCpp.cpp b/hal/src/HalCpp.cpp index ba77430d..09f21bcd 100644 --- a/hal/src/HalCpp.cpp +++ b/hal/src/HalCpp.cpp @@ -24,3 +24,4 @@ StatusCode HalCpp::UnInit(void) LogInfo("HalCpp::UnInit\n"); return CreateStatusCode(STATUS_CODE_OK); } +StatusCode HalCpp::GetWifiHal(std::shared_ptr &wifi) { return CreateStatusCode(STATUS_CODE_OK); } diff --git a/hal/src/HalCpp.h b/hal/src/HalCpp.h index fb28a87d..701ddaef 100644 --- a/hal/src/HalCpp.h +++ b/hal/src/HalCpp.h @@ -22,6 +22,7 @@ public: virtual ~HalCpp() = default; StatusCode Init(void) override; StatusCode UnInit(void) override; + StatusCode GetWifiHal(std::shared_ptr &wifi) override; private: std::vector> mLedHals; diff --git a/middleware/AppManager/CMakeLists.txt b/middleware/AppManager/CMakeLists.txt index 6698f8e7..7584464a 100644 --- a/middleware/AppManager/CMakeLists.txt +++ b/middleware/AppManager/CMakeLists.txt @@ -24,7 +24,7 @@ aux_source_directory(./src/Protocol/SixFrame SRC_FILES) set(TARGET_NAME AppManager) add_library(${TARGET_NAME} STATIC ${SRC_FILES}) -target_link_libraries(${TARGET_NAME} WebServer cjson-static StatusCode Log) +target_link_libraries(${TARGET_NAME} WebServer Hal cjson-static StatusCode Log) if ("${CLANG_TIDY_SUPPORT}" MATCHES "true") add_custom_target( diff --git a/middleware/AppManager/src/AppManager.cpp b/middleware/AppManager/src/AppManager.cpp index 634bbebf..6736920d 100644 --- a/middleware/AppManager/src/AppManager.cpp +++ b/middleware/AppManager/src/AppManager.cpp @@ -36,7 +36,7 @@ const StatusCode AppManager::Init(const AppParam ¶m) HttpServerStart(param); return CreateStatusCode(STATUS_CODE_OK); } -const StatusCode AppManager::UnInit(void) +const StatusCode AppManager::UnInit(void) { HttpServerStop(); mProtocolHandle.reset(); diff --git a/test/application/HunttingCamera/CMakeLists.txt b/test/application/HunttingCamera/CMakeLists.txt index 3eeea30b..9d0b9f94 100644 --- a/test/application/HunttingCamera/CMakeLists.txt +++ b/test/application/HunttingCamera/CMakeLists.txt @@ -11,6 +11,7 @@ include_directories( ${MIDDLEWARE_SOURCE_PATH}/McuManager/src ${UTILS_SOURCE_PATH}/McuProtocol/include ${UTILS_SOURCE_PATH}/UartDevice/include + ${UTILS_SOURCE_PATH}/LedControl/include ${TEST_SOURCE_PATH} ${TEST_SOURCE_PATH}/middleware/McuManager/tool/include ${TEST_SOURCE_PATH}/middleware/AppManager/tool/include @@ -18,6 +19,7 @@ include_directories( ${TEST_SOURCE_PATH}/utils/TestManager/include ${TEST_SOURCE_PATH}/utils/McuProtocol/tool/include ${TEST_SOURCE_PATH}/utils/UartDevice/tool/include + ${TEST_SOURCE_PATH}/hal/tool/include ${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include ${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googlemock/include ) @@ -35,7 +37,7 @@ endif() set(TARGET_NAME HunttingCameraTest) add_executable(${TARGET_NAME} ${SRC_FILES_MAIN} ${SRC_FILES}) -target_link_libraries(${TARGET_NAME} HunttingMainLib McuManagerTestTool McuAskBaseTestTool AppManagerTestTool TestManager gtest gmock pthread) +target_link_libraries(${TARGET_NAME} HunttingMainLib McuManagerTestTool McuAskBaseTestTool AppManagerTestTool HalTestTool TestManager gtest gmock pthread) if(${TEST_COVERAGE} MATCHES "true") target_link_libraries(${TARGET_NAME} gcov) endif() diff --git a/test/application/HunttingCamera/src_mock/HunttingCamera_Mock_Test.cpp b/test/application/HunttingCamera/src_mock/HunttingCamera_Mock_Test.cpp index 73f56d91..1fbd1fe5 100644 --- a/test/application/HunttingCamera/src_mock/HunttingCamera_Mock_Test.cpp +++ b/test/application/HunttingCamera/src_mock/HunttingCamera_Mock_Test.cpp @@ -14,6 +14,7 @@ */ #include "AppManagerTestTool.h" #include "GtestUsing.h" +#include "HalTestTool.h" #include "ILog.h" #include "MainThread.h" #include "McuManagerTestTool.h" @@ -24,7 +25,9 @@ namespace HunttingCameraTest class HunttingCameraTest : public testing::Test, public TestManager, public McuManagerTestTool, - public AppManagerTestTool + public AppManagerTestTool, + public HalTestTool + { public: HunttingCameraTest() {} @@ -38,7 +41,7 @@ public: virtual void SetUp() { // CreateAllKeysMcok(); - // HalTestTool::Init(); + HalTestTool::Init(); // HunttingCameraTestTool::Init(); // CreateHalCppModule(); // CreateDeviceManagerModule(); @@ -51,11 +54,11 @@ public: } virtual void TearDown() { - // HalTestTool::UnInit(); // HunttingCameraTestTool::UnInit(); // DestroyDeviceManagerModule(); // DestroyAllKeysMock(); TestManager::UnInit(); + HalTestTool::UnInit(); LinuxApiMock::GetInstance()->UnInit(); mLinuxTest = std::make_shared(); std::shared_ptr test = std::make_shared(); diff --git a/test/application/MissionManager/tool/CMakeLists.txt b/test/application/MissionManager/tool/CMakeLists.txt index d917c25a..be86ad65 100644 --- a/test/application/MissionManager/tool/CMakeLists.txt +++ b/test/application/MissionManager/tool/CMakeLists.txt @@ -11,6 +11,7 @@ include_directories( ${APPLICATION_SOURCE_PATH}/MissionManager/src ${MIDDLEWARE_SOURCE_PATH}/AppManager/include ${MIDDLEWARE_SOURCE_PATH}/StateMachine/include + ${MIDDLEWARE_SOURCE_PATH}/McuManager/include ${TEST_SOURCE_PATH} ${TEST_SOURCE_PATH}/middleware/AppManager/tool/include ${TEST_SOURCE_PATH}/middleware/AppManager/tool/src diff --git a/test/application/MissionManager/tool/include/MissionManagerTestTool.h b/test/application/MissionManager/tool/include/MissionManagerTestTool.h index 0f65e86c..26c32d95 100644 --- a/test/application/MissionManager/tool/include/MissionManagerTestTool.h +++ b/test/application/MissionManager/tool/include/MissionManagerTestTool.h @@ -28,8 +28,8 @@ public: private: // void MissionManagerMockInit(std::shared_ptr &vMock); - // private: - // std::shared_ptr mMissionManagerMock; +private: + std::shared_ptr mMissionManagerMock; // std::shared_ptr mAppMonitorMock; // public: diff --git a/test/application/MissionManager/tool/src/MissionManagerMakePtrTest.cpp b/test/application/MissionManager/tool/src/MissionManagerMakePtrTest.cpp new file mode 100644 index 00000000..af324535 --- /dev/null +++ b/test/application/MissionManager/tool/src/MissionManagerMakePtrTest.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023 Fancy Code. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "MissionManagerMakePtrTest.h" +#include "ILog.h" +#include "TestMissionStateMock.h" +void OverrideMissionManagerMakePtrObject(std::shared_ptr &appManagerMock) +{ + std::shared_ptr impl = std::make_shared(); + std::shared_ptr test = std::dynamic_pointer_cast(impl); + if (test) { + test->mMissionManagerMock = appManagerMock; + } + MissionManagerMakePtr::GetInstance(&impl); +} +void CancelOverrideMissionManagerMakePtrObject(void) +{ + std::shared_ptr tmp = MissionManagerMakePtr::GetInstance(); + std::shared_ptr test = std::dynamic_pointer_cast(tmp); + if (test) { + test->mMissionManagerMock.reset(); + } + tmp.reset(); + test.reset(); + std::shared_ptr impl = std::make_shared(); + MissionManagerMakePtr::GetInstance(&impl); +} +MissionManagerMakePtrTest::MissionManagerMakePtrTest() +{ + // +} +MissionManagerMakePtrTest::~MissionManagerMakePtrTest() +{ + // + mMissionManagerMock.reset(); +} +// const StatusCode MissionManagerMakePtrTest::CreateMissionManager(std::shared_ptr &impl) +// { +// if (mMissionManagerMock) { +// LogInfo("CreateMissionManager mMissionManagerMock\n"); +// impl = mMissionManagerMock; +// } +// else { +// LogWarning("CreateMcuManager failed:mMissionManagerMock is nullptr.\n"); +// } +// return CreateStatusCode(STATUS_CODE_OK); +// } +std::shared_ptr MissionManagerMakePtrTest::CreateMissionState(const IpcMission &mission) +{ + std::shared_ptr state = std::make_shared(); + return state; +} \ No newline at end of file diff --git a/test/application/MissionManager/tool/src/MissionManagerMakePtrTest.h b/test/application/MissionManager/tool/src/MissionManagerMakePtrTest.h new file mode 100644 index 00000000..bf27c678 --- /dev/null +++ b/test/application/MissionManager/tool/src/MissionManagerMakePtrTest.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Fancy Code. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef MISSION_MANAGER_MAKE_PTR_TEST_H +#define MISSION_MANAGER_MAKE_PTR_TEST_H +#include "MissionManagerMakePtr.h" +#include "MissionManagerMock.h" +#include "MissionManagerTestTool.h" +void OverrideMissionManagerMakePtrObject(std::shared_ptr &appManagerMock); +void CancelOverrideMissionManagerMakePtrObject(void); +class MissionManagerMakePtrTest : public MissionManagerMakePtr +{ +public: + MissionManagerMakePtrTest(); + virtual ~MissionManagerMakePtrTest(); + std::shared_ptr CreateMissionState(const IpcMission &mission) override; + +public: + std::shared_ptr mMissionManagerMock; +}; +#endif \ No newline at end of file diff --git a/test/application/MissionManager/tool/src/MissionManagerMock.cpp b/test/application/MissionManager/tool/src/MissionManagerMock.cpp new file mode 100644 index 00000000..278c86a7 --- /dev/null +++ b/test/application/MissionManager/tool/src/MissionManagerMock.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023 Fancy Code. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "MissionManagerMock.h" +#include "ILog.h" +// const StatusCode MissionManagerTest::SetAppMonitor(std::shared_ptr &monitor) +// { +// LogInfo("MissionManagerTest::SetAppMonitor\n"); +// StatusCode code = SetAppMonitorTrace(monitor); +// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) { +// return MissionManager::SetAppMonitor(monitor); +// } +// return code; +// } +// const StatusCode MissionManagerTest::SetAppMonitorTrace(std::shared_ptr &monitor) +// { +// LogInfo("MissionManagerTest::SetAppMonitorTrace\n"); +// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); +// } +// StatusCode MissionManagerTest::GetAllLedsTrace(std::map> &allLeds) +// { +// LogInfo("MissionManagerTest::GetAllLedsTrace\n"); +// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); +// } +// StatusCode MissionManagerTest::GetAllKeysTrace(std::map> &allKeys) +// { +// LogInfo("MissionManagerTest::GetAllKeysTrace\n"); +// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); +// } \ No newline at end of file diff --git a/test/application/MissionManager/tool/src/MissionManagerMock.h b/test/application/MissionManager/tool/src/MissionManagerMock.h new file mode 100644 index 00000000..e9a4ee48 --- /dev/null +++ b/test/application/MissionManager/tool/src/MissionManagerMock.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Fancy Code. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef MISSION_MANAGER_MOCK_H +#define MISSION_MANAGER_MOCK_H +#include "MissionManager.h" +#include "MissionManagerTestTool.h" +class MissionManagerTest : public MissionManager +{ +public: + MissionManagerTest() = default; + virtual ~MissionManagerTest() = default; + // const StatusCode SetAppMonitor(std::shared_ptr &monitor) override; + +protected: + // virtual const StatusCode SetAppMonitorTrace(std::shared_ptr &monitor); +}; +class MissionManagerMock : public MissionManagerTest +{ +public: + MissionManagerMock() = default; + virtual ~MissionManagerMock() = default; + // MOCK_METHOD1(SetAppMonitorTrace, const StatusCode(std::shared_ptr &)); +}; +#endif \ No newline at end of file diff --git a/test/application/MissionManager/tool/src/MissionManagerTestTool.cpp b/test/application/MissionManager/tool/src/MissionManagerTestTool.cpp index c0e989c0..d13048e0 100644 --- a/test/application/MissionManager/tool/src/MissionManagerTestTool.cpp +++ b/test/application/MissionManager/tool/src/MissionManagerTestTool.cpp @@ -13,18 +13,20 @@ * limitations under the License. */ #include "MissionManagerTestTool.h" +#include "MissionManagerMakePtrTest.h" +#include "MissionManagerMock.h" void MissionManagerTestTool::Init(void) { // ServersMock::GetInstance()->Init(); - // mMissionManagerMock = std::make_shared(); + mMissionManagerMock = std::make_shared(); // MissionManagerMockInit(mMissionManagerMock); - // std::shared_ptr mock = std::dynamic_pointer_cast(mMissionManagerMock); - // OverrideMissionManagerMakePtrObject(mock); + std::shared_ptr mock = std::dynamic_pointer_cast(mMissionManagerMock); + OverrideMissionManagerMakePtrObject(mock); } void MissionManagerTestTool::UnInit(void) { // ServersMock::GetInstance()->UnInit(); - // mMissionManagerMock.reset(); + mMissionManagerMock.reset(); // mAppMonitorMock.reset(); - // CancelOverrideMissionManagerMakePtrObject(); + CancelOverrideMissionManagerMakePtrObject(); } \ No newline at end of file diff --git a/test/hal/tool/src/HalCppMock.cpp b/test/hal/tool/src/HalCppMock.cpp index 855a65c4..ed43ae9f 100644 --- a/test/hal/tool/src/HalCppMock.cpp +++ b/test/hal/tool/src/HalCppMock.cpp @@ -23,6 +23,11 @@ StatusCode HalCppTest::GetAllLeds(std::map } return code; } +StatusCode HalCppTest::GetAllLedsTrace(std::map> &allLeds) +{ + LogInfo("HalCppTest::GetAllLedsTrace\n"); + return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); +} StatusCode HalCppTest::GetAllKeys(std::map> &allKeys) { LogInfo("HalCppTest::GetAllKeys\n"); @@ -32,13 +37,22 @@ StatusCode HalCppTest::GetAllKeys(std::map } return code; } -StatusCode HalCppTest::GetAllLedsTrace(std::map> &allLeds) -{ - LogInfo("HalCppTest::GetAllLedsTrace\n"); - return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); -} StatusCode HalCppTest::GetAllKeysTrace(std::map> &allKeys) { LogInfo("HalCppTest::GetAllKeysTrace\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); +} +StatusCode HalCppTest::GetWifiHal(std::shared_ptr &wifi) +{ + LogInfo("HalCppTest::GetAllKeys\n"); + StatusCode code = GetWifiHalTrace(wifi); + if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) { + return HalCpp::GetWifiHal(wifi); + } + return code; +} +StatusCode HalCppTest::GetWifiHalTrace(std::shared_ptr &wifi) +{ + LogInfo("HalCppTest::GetWifiHalTrace\n"); + return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } \ No newline at end of file diff --git a/test/hal/tool/src/HalCppMock.h b/test/hal/tool/src/HalCppMock.h index 864b2af0..2521c467 100644 --- a/test/hal/tool/src/HalCppMock.h +++ b/test/hal/tool/src/HalCppMock.h @@ -23,10 +23,12 @@ public: virtual ~HalCppTest() = default; StatusCode GetAllLeds(std::map> &allLeds) override; StatusCode GetAllKeys(std::map> &allKeys) override; + StatusCode GetWifiHal(std::shared_ptr &wifi) override; protected: virtual StatusCode GetAllLedsTrace(std::map> &allLeds); virtual StatusCode GetAllKeysTrace(std::map> &allKeys); + virtual StatusCode GetWifiHalTrace(std::shared_ptr &wifi); }; class HalCppMock : public HalCppTest { @@ -35,5 +37,6 @@ public: virtual ~HalCppMock() = default; MOCK_METHOD1(GetAllLedsTrace, StatusCode(std::map> &)); MOCK_METHOD1(GetAllKeysTrace, StatusCode(std::map> &)); + MOCK_METHOD1(GetWifiHalTrace, StatusCode(std::shared_ptr &)); }; #endif \ No newline at end of file diff --git a/test/hal/tool/src/HalTestTool.cpp b/test/hal/tool/src/HalTestTool.cpp index 1a9701e1..c678f81d 100644 --- a/test/hal/tool/src/HalTestTool.cpp +++ b/test/hal/tool/src/HalTestTool.cpp @@ -19,6 +19,7 @@ #include "KeyControl.h" #include "KeyControlMock.h" #include "LedControlMock.h" +#include "WifiHalMock.h" #include void HalTestTool::Init(void) { @@ -158,6 +159,9 @@ void HalTestTool::HalMockInit(std::shared_ptr &vMock) .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION)))); EXPECT_CALL(*mock.get(), GetAllKeysTrace(_)) .WillRepeatedly(DoAll(Return(CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION)))); + std::shared_ptr wifiHal = std::make_shared(); + EXPECT_CALL(*mock.get(), GetWifiHalTrace(_)) + .WillRepeatedly(DoAll(SetArgReferee<0>(wifiHal), Return(CreateStatusCode(STATUS_CODE_OK)))); } void HalTestTool::SetAllKeysResult(std::shared_ptr &vMock, std::map> &allKeys) diff --git a/test/hal/tool/src/WifiHalMock.cpp b/test/hal/tool/src/WifiHalMock.cpp new file mode 100644 index 00000000..54632263 --- /dev/null +++ b/test/hal/tool/src/WifiHalMock.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023 Fancy Code. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "HalCppMock.h" +#include "ILog.h" +// StatusCode WifiHalTest::GetAllLeds(std::map> &allLeds) +// { +// LogInfo("WifiHalTest::GetAllLeds\n"); +// StatusCode code = GetAllLedsTrace(allLeds); +// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) { +// return HalCpp::GetAllLeds(allLeds); +// } +// return code; +// } +// StatusCode WifiHalTest::GetAllKeys(std::map> &allKeys) +// { +// LogInfo("WifiHalTest::GetAllKeys\n"); +// StatusCode code = GetAllKeysTrace(allKeys); +// if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) { +// return HalCpp::GetAllKeys(allKeys); +// } +// return code; +// } +// StatusCode WifiHalTest::GetAllLedsTrace(std::map> &allLeds) +// { +// LogInfo("WifiHalTest::GetAllLedsTrace\n"); +// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); +// } +// StatusCode WifiHalTest::GetAllKeysTrace(std::map> &allKeys) +// { +// LogInfo("WifiHalTest::GetAllKeysTrace\n"); +// return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); +// } \ No newline at end of file diff --git a/test/hal/tool/src/WifiHalMock.h b/test/hal/tool/src/WifiHalMock.h new file mode 100644 index 00000000..529b5421 --- /dev/null +++ b/test/hal/tool/src/WifiHalMock.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Fancy Code. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef WIFI_HAL_MOCK_H +#define WIFI_HAL_MOCK_H +#include "HalCpp.h" +#include "HalTestTool.h" +class WifiHalTest : public VWifiHal +{ +public: + WifiHalTest() = default; + virtual ~WifiHalTest() = default; + // StatusCode GetAllLeds(std::map> &allLeds) override; + // StatusCode GetAllKeys(std::map> &allKeys) override; + +protected: + // virtual StatusCode GetAllLedsTrace(std::map> &allLeds); + // virtual StatusCode GetAllKeysTrace(std::map> &allKeys); +}; +class WifiHalMock : public WifiHalTest +{ +public: + WifiHalMock() = default; + virtual ~WifiHalMock() = default; + // MOCK_METHOD1(GetAllLedsTrace, StatusCode(std::map> &)); + // MOCK_METHOD1(GetAllKeysTrace, StatusCode(std::map> &)); +}; +#endif \ No newline at end of file