diff --git a/application/MissionManager/src/TestMissionState.cpp b/application/MissionManager/src/TestMissionState.cpp new file mode 100644 index 00000000..472ac2b1 --- /dev/null +++ b/application/MissionManager/src/TestMissionState.cpp @@ -0,0 +1,28 @@ +/* + * 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 "TestMissionState.h" +#include "ILog.h" +TestMissionState::TestMissionState() : State("TestMissionState") {} +void TestMissionState::GoInState() +{ + // + LogInfo(" ========== TestMissionState::GoInState.\n"); +} +void TestMissionState::GoOutState() +{ + // + LogInfo(" ========== TestMissionState::GoOutState.\n"); +} +bool TestMissionState::ExecuteStateMsg(VStateMachineData *msg) { return DataProcessing::EventHandle(msg); } \ No newline at end of file diff --git a/application/MissionManager/src/TestMissionState.h b/application/MissionManager/src/TestMissionState.h new file mode 100644 index 00000000..b3804f58 --- /dev/null +++ b/application/MissionManager/src/TestMissionState.h @@ -0,0 +1,28 @@ +/* + * 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 TEST_MISSION_STATE_H +#define TEST_MISSION_STATE_H +#include "DataProcessing.h" +#include "IStateMachine.h" +class TestMissionState : public State, public DataProcessing +{ +public: + TestMissionState(); + virtual ~TestMissionState() = default; + void GoInState() override; + void GoOutState() override; + bool ExecuteStateMsg(VStateMachineData *msg) override; +}; +#endif \ No newline at end of file diff --git a/application/MissionManager/src/TopState.h b/application/MissionManager/src/TopState.h index 7367a2e0..c5954693 100644 --- a/application/MissionManager/src/TopState.h +++ b/application/MissionManager/src/TopState.h @@ -12,8 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef TOPSTATE_H -#define TOPSTATE_H +#ifndef TOP_STATE_H +#define TOP_STATE_H #include "DataProcessing.h" #include "IStateMachine.h" class TopState : public State, public DataProcessing diff --git a/middleware/AppManager/src/IAppManager.cpp b/middleware/AppManager/src/IAppManager.cpp index 1ffb2112..51d8d792 100644 --- a/middleware/AppManager/src/IAppManager.cpp +++ b/middleware/AppManager/src/IAppManager.cpp @@ -14,38 +14,26 @@ */ #include "IAppManager.h" #include "ILog.h" -StatusCode inline VAppMonitor::GetProductInfo(AppGetProductInfo ¶m) +StatusCode VAppMonitor::GetProductInfo(AppGetProductInfo ¶m) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } -StatusCode inline VAppMonitor::GetDeviceAttr(AppGetDeviceAttr ¶m) +StatusCode VAppMonitor::GetDeviceAttr(AppGetDeviceAttr ¶m) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } -StatusCode inline VAppMonitor::GetMediaInfo(AppGetMeidaInfo ¶m) +StatusCode VAppMonitor::GetMediaInfo(AppGetMeidaInfo ¶m) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } +StatusCode VAppMonitor::GetSdCardInfo(AppGetSdCardInfo ¶m) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } -StatusCode inline VAppMonitor::GetSdCardInfo(AppGetSdCardInfo ¶m) -{ - return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); -} -StatusCode inline VAppMonitor::GetBatteryInfo(AppGetBatteryInfo ¶m) -{ - return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); -} -StatusCode inline VAppMonitor::SetDateTime(AppSetDateTime ¶m) -{ - return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); -} -StatusCode inline VAppMonitor::SetTimeZone(const unsigned int &zone) -{ - return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); -} -StatusCode inline VAppMonitor::UploadFile(AppUploadFile ¶m) +StatusCode VAppMonitor::GetBatteryInfo(AppGetBatteryInfo ¶m) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } +StatusCode VAppMonitor::SetDateTime(AppSetDateTime ¶m) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } +StatusCode VAppMonitor::SetTimeZone(const unsigned int &zone) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } +StatusCode VAppMonitor::UploadFile(AppUploadFile ¶m) { return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); } std::shared_ptr &IAppManager::GetInstance(std::shared_ptr *impl) { static auto instance = std::make_shared(); diff --git a/test/application/HunttingCamera/src/HunttingCamera_Test.cpp b/test/application/HunttingCamera/src/HunttingCamera_Test.cpp index e0669717..177ba71b 100644 --- a/test/application/HunttingCamera/src/HunttingCamera_Test.cpp +++ b/test/application/HunttingCamera/src/HunttingCamera_Test.cpp @@ -20,54 +20,4 @@ #include namespace HunttingCameraTest { -class HunttingCameraTest : public testing::Test, public TestManager, public McuManagerTestTool -{ -public: - HunttingCameraTest() {} - virtual ~HunttingCameraTest() {} - static void SetUpTestCase() - { - CreateLogModule(); - ILogInit(LOG_INSTANCE_TYPE_END); - } - static void TearDownTestCase() { ILogUnInit(); } - virtual void SetUp() - { - // CreateAllKeysMcok(); - // HalTestTool::Init(); - // HunttingCameraTestTool::Init(); - // CreateHalCppModule(); - // CreateDeviceManagerModule(); - mLinuxTest = LinuxTest::CreateLinuxTest(); - std::shared_ptr test = mLinuxTest; - LinuxApiMock::GetInstance(&test); - LinuxApiMock::GetInstance()->Init(); - McuManagerTestTool::Init(mLinuxTest); - TestManager::Init(); - } - virtual void TearDown() - { - // HalTestTool::UnInit(); - // HunttingCameraTestTool::UnInit(); - // DestroyDeviceManagerModule(); - // DestroyAllKeysMock(); - TestManager::UnInit(); - LinuxApiMock::GetInstance()->UnInit(); - mLinuxTest = std::make_shared(); - std::shared_ptr test = std::make_shared(); - LinuxApiMock::GetInstance(&test); - McuManagerTestTool::UnInit(); - MainThread::GetInstance()->UnInit(); - } - -public: - std::shared_ptr mLinuxTest; -}; -// ../output_files/test/bin/HunttingCameraTest --gtest_filter=HunttingCameraTest.INTEGRATION_DeviceManager_EXAMPLE_Demo -TEST_F(HunttingCameraTest, INTEGRATION_DeviceManager_EXAMPLE_Demo) -{ - MainThread::GetInstance()->Init(); - TestManager::ResetTimeOut(1000 * 3); - MainThread::GetInstance()->Runing(); -} } // namespace HunttingCameraTest \ No newline at end of file diff --git a/test/application/HunttingCamera/src_mock/HunttingCamera_Mock_Test.cpp b/test/application/HunttingCamera/src_mock/HunttingCamera_Mock_Test.cpp new file mode 100644 index 00000000..e0669717 --- /dev/null +++ b/test/application/HunttingCamera/src_mock/HunttingCamera_Mock_Test.cpp @@ -0,0 +1,73 @@ +/* + * 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 "GtestUsing.h" +#include "ILog.h" +#include "MainThread.h" +#include "McuManagerTestTool.h" +#include "TestManager.h" +#include +namespace HunttingCameraTest +{ +class HunttingCameraTest : public testing::Test, public TestManager, public McuManagerTestTool +{ +public: + HunttingCameraTest() {} + virtual ~HunttingCameraTest() {} + static void SetUpTestCase() + { + CreateLogModule(); + ILogInit(LOG_INSTANCE_TYPE_END); + } + static void TearDownTestCase() { ILogUnInit(); } + virtual void SetUp() + { + // CreateAllKeysMcok(); + // HalTestTool::Init(); + // HunttingCameraTestTool::Init(); + // CreateHalCppModule(); + // CreateDeviceManagerModule(); + mLinuxTest = LinuxTest::CreateLinuxTest(); + std::shared_ptr test = mLinuxTest; + LinuxApiMock::GetInstance(&test); + LinuxApiMock::GetInstance()->Init(); + McuManagerTestTool::Init(mLinuxTest); + TestManager::Init(); + } + virtual void TearDown() + { + // HalTestTool::UnInit(); + // HunttingCameraTestTool::UnInit(); + // DestroyDeviceManagerModule(); + // DestroyAllKeysMock(); + TestManager::UnInit(); + LinuxApiMock::GetInstance()->UnInit(); + mLinuxTest = std::make_shared(); + std::shared_ptr test = std::make_shared(); + LinuxApiMock::GetInstance(&test); + McuManagerTestTool::UnInit(); + MainThread::GetInstance()->UnInit(); + } + +public: + std::shared_ptr mLinuxTest; +}; +// ../output_files/test/bin/HunttingCameraTest --gtest_filter=HunttingCameraTest.INTEGRATION_DeviceManager_EXAMPLE_Demo +TEST_F(HunttingCameraTest, INTEGRATION_DeviceManager_EXAMPLE_Demo) +{ + MainThread::GetInstance()->Init(); + TestManager::ResetTimeOut(1000 * 3); + MainThread::GetInstance()->Runing(); +} +} // namespace HunttingCameraTest \ No newline at end of file