diff --git a/application/HunttingCamera/build/huntting_camera.cmake b/application/HunttingCamera/build/huntting_camera.cmake index c24b79e..c8621b2 100644 --- a/application/HunttingCamera/build/huntting_camera.cmake +++ b/application/HunttingCamera/build/huntting_camera.cmake @@ -1,9 +1,9 @@ - set(HUNTTING_MAIN_INCLUDE_PATH "${APPLICATION_SOURCE_PATH}/HunttingCamera/src") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${APPLICATION_SOURCE_PATH}/MissionManager/include") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/StateMachine/include") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/McuManager/include") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/AppManager/include") +set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/MediaManager/include") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${UTILS_SOURCE_PATH}/StatusCode/include") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${UTILS_SOURCE_PATH}/Log/include") set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${HAL_SOURCE_PATH}/include") diff --git a/application/HunttingCamera/src/MainThread.cpp b/application/HunttingCamera/src/MainThread.cpp index 6aea94f..df20353 100644 --- a/application/HunttingCamera/src/MainThread.cpp +++ b/application/HunttingCamera/src/MainThread.cpp @@ -17,6 +17,7 @@ #include "IHalCpp.h" #include "ILog.h" #include "IMcuManager.h" +#include "IMediaManager.h" #include "IMissionManager.h" #include "IStateMachine.h" #include @@ -61,12 +62,14 @@ StatusCode MainThread::Init(void) CreateAllModules(); IHalCpp::GetInstance()->Init(); IMcuManager::GetInstance()->Init(); + IMediaManager::GetInstance()->Init(); IMissionManager::GetInstance()->Init(); return CreateStatusCode(STATUS_CODE_OK); } StatusCode MainThread::UnInit(void) { IMissionManager::GetInstance()->UnInit(); + IMediaManager::GetInstance()->UnInit(); IMcuManager::GetInstance()->UnInit(); IHalCpp::GetInstance()->UnInit(); DestoryAllModules(); @@ -80,10 +83,12 @@ StatusCode MainThread::CreateAllModules(void) CreateMissionManagerModule(); CreateStateMachine(); CreateAppManagerModule(); + CreateMediaManagerModule(); return CreateStatusCode(STATUS_CODE_OK); } void MainThread::DestoryAllModules(void) { + DestroyMediaManagerModule(); DestroyAppManagerModule(); DestroyStateMachine(); DestroyMissionManagerModule(); diff --git a/application/MissionManager/CMakeLists.txt b/application/MissionManager/CMakeLists.txt index 2efa8aa..8e62687 100644 --- a/application/MissionManager/CMakeLists.txt +++ b/application/MissionManager/CMakeLists.txt @@ -11,7 +11,7 @@ include_directories( ${UTILS_SOURCE_PATH}/Log/include ${MIDDLEWARE_SOURCE_PATH}/StateMachine/include ${MIDDLEWARE_SOURCE_PATH}/AppManager/include - # ${MIDDLEWARE_SOURCE_PATH}/DeviceManager/include + ${MIDDLEWARE_SOURCE_PATH}/MediaManager/include ${MIDDLEWARE_SOURCE_PATH}/McuManager/include ${MIDDLEWARE_SOURCE_PATH}/McuAskBase/include ) @@ -24,7 +24,7 @@ aux_source_directory(./src SRC_FILES) set(TARGET_NAME MissionManager) add_library(${TARGET_NAME} STATIC ${SRC_FILES}) -target_link_libraries(${TARGET_NAME} McuAskBase StateMachine StatusCode Log) +target_link_libraries(${TARGET_NAME} McuAskBase StateMachine MediaManager StatusCode Log) if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true") add_custom_target( diff --git a/application/MissionManager/src/TopState.cpp b/application/MissionManager/src/TopState.cpp index 9469049..41b49df 100644 --- a/application/MissionManager/src/TopState.cpp +++ b/application/MissionManager/src/TopState.cpp @@ -14,22 +14,28 @@ */ #include "TopState.h" #include "ILog.h" +#include "IMediaManager.h" #include "MissionStateMachine.h" TopState::TopState() : State("TopState") { } void TopState::GoInState() { - // LogInfo(" ========== opState::GoInState.\n"); + std::shared_ptr monitor = std::dynamic_pointer_cast(shared_from_this()); + IMediaManager::GetInstance()->SetMediaMonitor(monitor); MissionStateMachine::GetInstance()->SwitchState(MissionState::MISSION_STATE); } void TopState::GoOutState() { - // LogInfo(" ========== opState::GoOutState.\n"); } bool TopState::ExecuteStateMsg(VStateMachineData *msg) { return DataProcessing::EventHandle(msg); +} +StatusCode TopState::ReportEvent(const MediaReportEvent &event) +{ + LogInfo("sssssssssssssssssssssssssssssssssssssssssssssssssssssssss\n"); + return CreateStatusCode(STATUS_CODE_OK); } \ No newline at end of file diff --git a/application/MissionManager/src/TopState.h b/application/MissionManager/src/TopState.h index c595469..a509334 100644 --- a/application/MissionManager/src/TopState.h +++ b/application/MissionManager/src/TopState.h @@ -15,8 +15,12 @@ #ifndef TOP_STATE_H #define TOP_STATE_H #include "DataProcessing.h" +#include "IMediaManager.h" #include "IStateMachine.h" -class TopState : public State, public DataProcessing +class TopState : public State, + public DataProcessing, + public VMediaMonitor, + public std::enable_shared_from_this { public: TopState(); @@ -24,5 +28,8 @@ public: void GoInState() override; void GoOutState() override; bool ExecuteStateMsg(VStateMachineData *msg) override; + +private: // About VMediaMonitor + StatusCode ReportEvent(const MediaReportEvent &event) override; }; #endif \ No newline at end of file diff --git a/middleware/MediaManager/include/IMediaManager.h b/middleware/MediaManager/include/IMediaManager.h index c3e90d6..749ec0d 100644 --- a/middleware/MediaManager/include/IMediaManager.h +++ b/middleware/MediaManager/include/IMediaManager.h @@ -33,6 +33,15 @@ enum class MediaTaskType MONITOR, END }; +typedef struct media_report_event +{ + media_report_event(const std::string &fileName, const std::string &filePath, const MediaTaskType &eventType, + const MediaChannel &mediaChannedl); + const std::string mFileName; + const std::string mFilePath; + const MediaTaskType mEventType; + const MediaChannel mMediaChannedl; +} MediaReportEvent; class MediaTaskResponse { public: @@ -55,6 +64,7 @@ class VMediaMonitor public: VMediaMonitor() = default; virtual ~VMediaMonitor() = default; + virtual StatusCode ReportEvent(const MediaReportEvent &event); }; class VMediaHandle { @@ -68,8 +78,8 @@ public: IMediaManager() = default; virtual ~IMediaManager() = default; static std::shared_ptr &GetInstance(std::shared_ptr *impl = nullptr); - virtual const StatusCode Init(void); - virtual const StatusCode UnInit(void); + virtual StatusCode Init(void); + virtual StatusCode UnInit(void); virtual StatusCode SetMediaMonitor(std::shared_ptr &monitor); }; #endif \ No newline at end of file diff --git a/middleware/MediaManager/src/IMediaManager.cpp b/middleware/MediaManager/src/IMediaManager.cpp index af6467d..7bd9943 100644 --- a/middleware/MediaManager/src/IMediaManager.cpp +++ b/middleware/MediaManager/src/IMediaManager.cpp @@ -14,6 +14,11 @@ */ #include "IMediaManager.h" #include "ILog.h" +media_report_event::media_report_event(const std::string &fileName, const std::string &filePath, + const MediaTaskType &eventType, const MediaChannel &mediaChannedl) + : mFileName(fileName), mFilePath(filePath), mEventType(eventType), mMediaChannedl(mediaChannedl) +{ +} const MediaTaskType VMediaTask::GetTaskType(void) { return MediaTaskType::END; @@ -33,6 +38,10 @@ const unsigned int VMediaTask::GetIsMultShot(void) { return false; } +StatusCode VMediaMonitor::ReportEvent(const MediaReportEvent &event) +{ + return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); +} std::shared_ptr &IMediaManager::GetInstance(std::shared_ptr *impl) { static auto instance = std::make_shared(); @@ -47,11 +56,11 @@ std::shared_ptr &IMediaManager::GetInstance(std::shared_ptrGetCameraHal(mAllCameras); SetCamerasMonitor(); return CreateStatusCode(STATUS_CODE_OK); } -const StatusCode MediaManagerImpl::UnInit(void) +StatusCode MediaManagerImpl::UnInit(void) { return CreateStatusCode(STATUS_CODE_OK); } @@ -29,6 +29,21 @@ StatusCode MediaManagerImpl::SetMediaMonitor(std::shared_ptr &mon mMediaMonitor = monitor; return CreateStatusCode(STATUS_CODE_OK); } +void MediaManagerImpl::ReportEvent(const CameraReportEvent &event) +{ + LogInfo("ReportEvent.\n"); + LogInfo("ReportEvent. file: %s, path: %s.\n", event.mFileName.c_str(), event.mFilePath.c_str()); + MediaReportEvent reprot(event.mFileName, + event.mFilePath, + static_cast(event.mEventType), + static_cast(event.mCameraType)); + auto monitor = mMediaMonitor.lock(); + if (mMediaMonitor.expired()) + { + return; + } + monitor->ReportEvent(reprot); +} void MediaManagerImpl::SetCamerasMonitor(void) { std::shared_ptr moniter = shared_from_this(); diff --git a/middleware/MediaManager/src/MediaManagerImpl.h b/middleware/MediaManager/src/MediaManagerImpl.h index 67ac5a3..a349d35 100644 --- a/middleware/MediaManager/src/MediaManagerImpl.h +++ b/middleware/MediaManager/src/MediaManagerImpl.h @@ -24,15 +24,16 @@ class MediaManagerImpl : public IMediaManager, public: MediaManagerImpl() = default; virtual ~MediaManagerImpl() = default; - const StatusCode Init(void) override; - const StatusCode UnInit(void) override; + StatusCode Init(void) override; + StatusCode UnInit(void) override; StatusCode SetMediaMonitor(std::shared_ptr &monitor) override; + void ReportEvent(const CameraReportEvent &event) override; private: void SetCamerasMonitor(void); private: std::map> mAllCameras; - std::shared_ptr mMediaMonitor; + std::weak_ptr mMediaMonitor; }; #endif \ No newline at end of file diff --git a/test/application/HunttingCamera/src_mock/HunttingCamera_Mock_Test.cpp b/test/application/HunttingCamera/src_mock/AppMonitor_Mock_Test.cpp similarity index 78% rename from test/application/HunttingCamera/src_mock/HunttingCamera_Mock_Test.cpp rename to test/application/HunttingCamera/src_mock/AppMonitor_Mock_Test.cpp index 68ada70..4f84f10 100644 --- a/test/application/HunttingCamera/src_mock/HunttingCamera_Mock_Test.cpp +++ b/test/application/HunttingCamera/src_mock/AppMonitor_Mock_Test.cpp @@ -15,88 +15,15 @@ #include "AppManagerTestTool.h" #include "GtestUsing.h" #include "HalTestTool.h" +#include "HunttingCameraTest.h" #include "ILog.h" #include "MainThread.h" #include "McuManagerTestTool.h" #include "MissionManagerTestTool.h" #include "TestManager.h" #include -namespace HunttingCameraTest +namespace AppMonitor_Mock_Test { -class MainThreadTest : public MainThread -{ -public: - MainThreadTest() = default; - virtual ~MainThreadTest() = default; - void CustomizationInit(void) override - { - // Do nothing here to make sure test tool work. - } -}; -class HunttingCameraTest : public testing::Test, - public TestManager, - public MissionManagerTestTool, - public McuManagerTestTool, - public AppManagerTestTool, - public HalTestTool - -{ -public: - HunttingCameraTest() - { - } - virtual ~HunttingCameraTest() - { - } - static void SetUpTestCase() - { - CreateLogModule(); - ILogInit(LOG_INSTANCE_TYPE_END); - } - static void TearDownTestCase() - { - ILogUnInit(); - } - virtual void SetUp() - { - std::shared_ptr mainThread = std::make_shared(); - MainThread::GetInstance(&mainThread); - // CreateAllKeysMcok(); - HalTestTool::Init(); - AppManagerTestTool::Init(); - MissionManagerTestTool::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() - { - // HunttingCameraTestTool::UnInit(); - // DestroyDeviceManagerModule(); - // DestroyAllKeysMock(); - TestManager::UnInit(); - MissionManagerTestTool::UnInit(); - AppManagerTestTool::UnInit(); - HalTestTool::UnInit(); - LinuxApiMock::GetInstance()->UnInit(); - mLinuxTest = std::make_shared(); - std::shared_ptr test = std::make_shared(); - LinuxApiMock::GetInstance(&test); - McuManagerTestTool::UnInit(); - MainThread::GetInstance()->UnInit(); - std::shared_ptr mainThread = std::make_shared(); - MainThread::GetInstance(&mainThread); - } - -public: - std::shared_ptr mLinuxTest; -}; // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetProductInfo TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetProductInfo) @@ -276,4 +203,4 @@ TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_AppPlayback) MockAppPlayback(); MainThread::GetInstance()->Runing(); } -} // namespace HunttingCameraTest \ No newline at end of file +} // namespace AppMonitor_Mock_Test \ No newline at end of file diff --git a/test/application/HunttingCamera/src_mock/HunttingCameraTest.cpp b/test/application/HunttingCamera/src_mock/HunttingCameraTest.cpp new file mode 100644 index 0000000..b16495a --- /dev/null +++ b/test/application/HunttingCamera/src_mock/HunttingCameraTest.cpp @@ -0,0 +1,78 @@ +/* + * 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 "HunttingCameraTest.h" +#include "GtestUsing.h" +#include "ILog.h" +#include "MainThread.h" +#include +void MainThreadTest::CustomizationInit(void) +{ + // Do nothing here to make sure test tool work. +} +HunttingCameraTest::HunttingCameraTest() +{ +} +HunttingCameraTest::~HunttingCameraTest() +{ +} +void HunttingCameraTest::SetUpTestCase() +{ + CreateLogModule(); + ILogInit(LOG_INSTANCE_TYPE_END); +} +void HunttingCameraTest::TearDownTestCase() +{ + ILogUnInit(); +} +void HunttingCameraTest::SetUp() +{ + CreateAllCamerasMcok(); + std::shared_ptr mainThread = std::make_shared(); + MainThread::GetInstance(&mainThread); + HalTestTool::Init(); + AppManagerTestTool::Init(); + MissionManagerTestTool::Init(); + mLinuxTest = LinuxTest::CreateLinuxTest(); + std::shared_ptr test = mLinuxTest; + LinuxApiMock::GetInstance(&test); + LinuxApiMock::GetInstance()->Init(); + McuManagerTestTool::Init(mLinuxTest); + TestManager::Init(); +} +void HunttingCameraTest::TearDown() +{ + TestManager::UnInit(); + MissionManagerTestTool::UnInit(); + AppManagerTestTool::UnInit(); + HalTestTool::UnInit(); + LinuxApiMock::GetInstance()->UnInit(); + mLinuxTest = std::make_shared(); + std::shared_ptr test = std::make_shared(); + LinuxApiMock::GetInstance(&test); + McuManagerTestTool::UnInit(); + MainThread::GetInstance()->UnInit(); + std::shared_ptr mainThread = std::make_shared(); + MainThread::GetInstance(&mainThread); + DestroyAllCamerasMock(); +} +void HunttingCameraTest::CreateAllCamerasMcok(void) +{ + std::shared_ptr camera = HalTestTool::MakeCameraHalTest(CameraType::MAIN_CAMERA); + mAllCamerasMock[CameraType::MAIN_CAMERA] = camera; +} +void HunttingCameraTest::DestroyAllCamerasMock(void) +{ + mAllCamerasMock.clear(); +} \ No newline at end of file diff --git a/test/application/HunttingCamera/src_mock/HunttingCameraTest.h b/test/application/HunttingCamera/src_mock/HunttingCameraTest.h new file mode 100644 index 0000000..f63d0c4 --- /dev/null +++ b/test/application/HunttingCamera/src_mock/HunttingCameraTest.h @@ -0,0 +1,57 @@ +/* + * 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 HUNTTING_CAMERA_TEST_H +#define HUNTTING_CAMERA_TEST_H +#include "AppManagerTestTool.h" +#include "GtestUsing.h" +#include "HalTestTool.h" +#include "LinuxApiMock.h" +#include "MainThread.h" +#include "McuManagerTestTool.h" +#include "MissionManagerTestTool.h" +#include "TestManager.h" +#include +class MainThreadTest : public MainThread +{ +public: + MainThreadTest() = default; + virtual ~MainThreadTest() = default; + void CustomizationInit(void) override; +}; +class HunttingCameraTest : public testing::Test, + public TestManager, + public MissionManagerTestTool, + public McuManagerTestTool, + public AppManagerTestTool, + public HalTestTool +{ +public: + HunttingCameraTest(); + virtual ~HunttingCameraTest(); + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; + +private: + void CreateAllCamerasMcok(void); + void DestroyAllCamerasMock(void); + +protected: + std::shared_ptr mLinuxTest; + std::map> mAllCamerasMock; +}; + +#endif \ No newline at end of file diff --git a/test/application/HunttingCamera/src_mock/MediaManager_Mock_Test.cpp b/test/application/HunttingCamera/src_mock/MediaManager_Mock_Test.cpp new file mode 100644 index 0000000..87d9a89 --- /dev/null +++ b/test/application/HunttingCamera/src_mock/MediaManager_Mock_Test.cpp @@ -0,0 +1,41 @@ +/* + * 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 "AppManagerTestTool.h" +#include "GtestUsing.h" +#include "HalTestTool.h" +#include "HunttingCameraTest.h" +#include "ILog.h" +#include "MainThread.h" +#include "McuManagerTestTool.h" +#include "MissionManagerTestTool.h" +#include "TestManager.h" +#include +namespace MediaManager_Mock_Test +{ +// ../output_files/test/bin/HunttingCameraTest +// --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_EXAMPLE_MediaReprot +TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_EXAMPLE_MediaReprot) +{ + SetAllCamerasResult(mAllCamerasMock); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + // McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); + MainThread::GetInstance()->Init(); + TestManager::ResetTimeOut(1000 * 3); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + MockReportCameraEvent("test name", "test path", CameraEvent::PICTIRUE, CameraType::MAIN_CAMERA); + // MockAppPlayback(); + MainThread::GetInstance()->Runing(); +} +} // namespace MediaManager_Mock_Test \ No newline at end of file diff --git a/test/application/MissionManager/tool/CMakeLists.txt b/test/application/MissionManager/tool/CMakeLists.txt index 600143d..0759236 100644 --- a/test/application/MissionManager/tool/CMakeLists.txt +++ b/test/application/MissionManager/tool/CMakeLists.txt @@ -10,11 +10,14 @@ include_directories( ${APPLICATION_SOURCE_PATH}/MissionManager/include ${APPLICATION_SOURCE_PATH}/MissionManager/src ${MIDDLEWARE_SOURCE_PATH}/AppManager/include + ${MIDDLEWARE_SOURCE_PATH}/MediaManager/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 + ${TEST_SOURCE_PATH}/middleware/MediaManager/tool/include + ${TEST_SOURCE_PATH}/middleware/MediaManager/tool/src ${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googletest/include ${EXTERNAL_SOURCE_PATH}/gtest/googletest-release-1.11.0/googlemock/include ) @@ -25,7 +28,7 @@ include_directories( aux_source_directory(./src TEST_TOOL_SRC_FILES) set(TEST_TOOL_TARGET MissionManagerTestTool) add_library(${TEST_TOOL_TARGET} STATIC ${TEST_TOOL_SRC_FILES}) -target_link_libraries(${TEST_TOOL_TARGET} MissionManager AppManagerTestTool Log) +target_link_libraries(${TEST_TOOL_TARGET} MissionManager AppManagerTestTool MediaManagerTestTool Log) if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true") add_custom_target( diff --git a/test/application/MissionManager/tool/src/MissionManagerMakePtrTest.cpp b/test/application/MissionManager/tool/src/MissionManagerMakePtrTest.cpp index af32453..e2b71c1 100644 --- a/test/application/MissionManager/tool/src/MissionManagerMakePtrTest.cpp +++ b/test/application/MissionManager/tool/src/MissionManagerMakePtrTest.cpp @@ -15,6 +15,7 @@ #include "MissionManagerMakePtrTest.h" #include "ILog.h" #include "TestMissionStateMock.h" +#include "TopStateMock.h" void OverrideMissionManagerMakePtrObject(std::shared_ptr &appManagerMock) { std::shared_ptr impl = std::make_shared(); @@ -38,24 +39,16 @@ void CancelOverrideMissionManagerMakePtrObject(void) } 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::CreateTopState(void) +{ + std::shared_ptr state = std::make_shared(); + return state; +} std::shared_ptr MissionManagerMakePtrTest::CreateMissionState(const IpcMission &mission) { std::shared_ptr state = std::make_shared(); diff --git a/test/application/MissionManager/tool/src/MissionManagerMakePtrTest.h b/test/application/MissionManager/tool/src/MissionManagerMakePtrTest.h index bf27c67..2587029 100644 --- a/test/application/MissionManager/tool/src/MissionManagerMakePtrTest.h +++ b/test/application/MissionManager/tool/src/MissionManagerMakePtrTest.h @@ -24,6 +24,7 @@ class MissionManagerMakePtrTest : public MissionManagerMakePtr public: MissionManagerMakePtrTest(); virtual ~MissionManagerMakePtrTest(); + std::shared_ptr CreateTopState(void) override; std::shared_ptr CreateMissionState(const IpcMission &mission) override; public: diff --git a/test/application/MissionManager/tool/src/TopStateMock.cpp b/test/application/MissionManager/tool/src/TopStateMock.cpp new file mode 100644 index 0000000..183ca74 --- /dev/null +++ b/test/application/MissionManager/tool/src/TopStateMock.cpp @@ -0,0 +1,15 @@ +/* + * 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 "TopStateMock.h" \ No newline at end of file diff --git a/test/application/MissionManager/tool/src/TopStateMock.h b/test/application/MissionManager/tool/src/TopStateMock.h new file mode 100644 index 0000000..8dfb5bc --- /dev/null +++ b/test/application/MissionManager/tool/src/TopStateMock.h @@ -0,0 +1,50 @@ +/* + * 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 TOP_STATE_MOCK_H +#define TOP_STATE_MOCK_H +#include "MediaMonitorMock.h" +#include "MissionManagerTestTool.h" +#include "TopState.h" +class TopStateTest : public TopState, virtual public MediaMonitorTrace +{ +public: + TopStateTest() = default; + virtual ~TopStateTest() = default; + // StatusCode GetProductInfo(AppGetProductInfo ¶m) override; + // StatusCode GetDeviceAttr(AppGetDeviceAttr ¶m) override; + // StatusCode GetMediaInfo(AppGetMeidaInfo ¶m) override; + // StatusCode GetSdCardInfo(AppGetSdCardInfo ¶m) override; + // StatusCode GetBatteryInfo(AppGetBatteryInfo ¶m) override; + // StatusCode GetParamValue(AppParamValue ¶m) override; + // StatusCode GetCapability(AppGetCapability ¶m) override; + // StatusCode GetLockVideoStatus(LockVideoStatus ¶m) override; + // StatusCode GetStorageInfo(std::vector ¶m) override; + // StatusCode GetStorageFileList(const AppGetFileInfo &fileInfo, std::vector ¶m) override; + // StatusCode SetDateTime(const AppSetDateTime ¶m) override; + // StatusCode SetTimeZone(const unsigned int &zone) override; + // StatusCode SetParamValue(const AppSetParamValue ¶m) override; + // StatusCode EnterRecorder(void) override; + // StatusCode AppPlayback(const PlayBackEvent &event) override; + // StatusCode UploadFile(AppUploadFile ¶m) override; + +protected: +}; +class TopStateMock : public MediaMonitorMock, public TopStateTest +{ +public: + TopStateMock() = default; + virtual ~TopStateMock() = default; +}; +#endif \ No newline at end of file diff --git a/test/hal/tool/src/HalTestTool.cpp b/test/hal/tool/src/HalTestTool.cpp index 42b88ca..d20bf2c 100644 --- a/test/hal/tool/src/HalTestTool.cpp +++ b/test/hal/tool/src/HalTestTool.cpp @@ -93,7 +93,7 @@ void HalTestTool::MockReportCameraEvent(const std::string &fileName, const std:: { std::shared_ptr camera = SearchCamera(cameraType); if (!camera) { - LogError("Can't mock camera event, key not found.\n"); + LogError("Can't mock camera event, camera not found.\n"); return; } std::shared_ptr cameraMock = std::dynamic_pointer_cast(camera); diff --git a/test/middleware/AppManager/tool/include/AppManagerTestTool.h b/test/middleware/AppManager/tool/include/AppManagerTestTool.h index 92c821e..da36e22 100644 --- a/test/middleware/AppManager/tool/include/AppManagerTestTool.h +++ b/test/middleware/AppManager/tool/include/AppManagerTestTool.h @@ -20,7 +20,7 @@ class AppManagerTestTool { public: - AppManagerTestTool() = default; + AppManagerTestTool(); virtual ~AppManagerTestTool() = default; void Init(void); void UnInit(void); diff --git a/test/middleware/AppManager/tool/src/AppManagerTestTool.cpp b/test/middleware/AppManager/tool/src/AppManagerTestTool.cpp index 7d5816d..b1f5fee 100644 --- a/test/middleware/AppManager/tool/src/AppManagerTestTool.cpp +++ b/test/middleware/AppManager/tool/src/AppManagerTestTool.cpp @@ -20,6 +20,10 @@ #include "ServersMock.h" #include "TcpModule.h" constexpr int ONLY_BE_CALLED_ONCE = 1; +AppManagerTestTool::AppManagerTestTool() +{ + mAppClientTool = nullptr; +} void AppManagerTestTool::Init(void) { ServersMock::GetInstance()->Init(); diff --git a/test/middleware/AppManager/tool/src/ServersMock.cpp b/test/middleware/AppManager/tool/src/ServersMock.cpp index ccc90ba..2d2bd71 100644 --- a/test/middleware/AppManager/tool/src/ServersMock.cpp +++ b/test/middleware/AppManager/tool/src/ServersMock.cpp @@ -48,7 +48,6 @@ std::shared_ptr &ServersMock::GetInstance(std::shared_ptr *)object)->UnInit(); (*(std::shared_ptr *)object).reset(); - free(((char *)object) - sizeof(ITcpClientHeader)); // TODO: bug? + free(((char *)object) - sizeof(ITcpClientHeader)); } } ssize_t TcpClientWrite(void *object, const void *buf, const size_t bufLenght)