From a17cc5e307f5e93967fd801c66488dcc4c75bdf1 Mon Sep 17 00:00:00 2001 From: Fancy code <258828110.@qq.com> Date: Tue, 18 Jun 2024 19:51:27 +0800 Subject: [PATCH] Backup. --- test/application/HuntingCamera/CMakeLists.txt | 6 -- test/middleware/AppManager/CMakeLists.txt | 6 -- test/middleware/HuntingUpgrade/CMakeLists.txt | 6 -- test/middleware/IpcConfig/CMakeLists.txt | 6 -- test/middleware/McuManager/CMakeLists.txt | 6 -- test/middleware/MediaManager/CMakeLists.txt | 6 -- .../MediaManager/src/MediaManagerTest.cpp | 49 +++++++++++++++ .../MediaManager/src/MediaManagerTest.h | 46 ++++++++++++++ .../MediaManager/src/MediaManager_Test.cpp | 60 +------------------ .../tool/src/MediaManagerMock.cpp | 6 +- .../MediaManager/tool/src/MediaManagerMock.h | 9 ++- utils/MediaBase/src/IMediaBase.cpp | 5 ++ utils/MediaBase/src/MediaBase.cpp | 4 ++ utils/MediaBase/src/MediaBaseImpl.cpp | 15 ++++- utils/MediaBase/src/MediaBaseMakePtr.cpp | 2 + 15 files changed, 129 insertions(+), 103 deletions(-) create mode 100644 test/middleware/MediaManager/src/MediaManagerTest.cpp create mode 100644 test/middleware/MediaManager/src/MediaManagerTest.h diff --git a/test/application/HuntingCamera/CMakeLists.txt b/test/application/HuntingCamera/CMakeLists.txt index 3762933e..75cc4c27 100644 --- a/test/application/HuntingCamera/CMakeLists.txt +++ b/test/application/HuntingCamera/CMakeLists.txt @@ -62,12 +62,6 @@ add_custom_target( -p ${PLATFORM_PATH}/cmake-shell WORKING_DIRECTORY ${TEST_SOURCE_PATH}/application/HuntingCamera ) -add_custom_command( - TARGET ${TARGET_NAME} - PRE_BUILD - COMMAND make HuntingCameraTest_code_check - WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ -) file(GLOB_RECURSE HEADER_FILES *.h) add_custom_target( diff --git a/test/middleware/AppManager/CMakeLists.txt b/test/middleware/AppManager/CMakeLists.txt index 42ef2722..65467702 100644 --- a/test/middleware/AppManager/CMakeLists.txt +++ b/test/middleware/AppManager/CMakeLists.txt @@ -53,12 +53,6 @@ add_custom_target( -p ${PLATFORM_PATH}/cmake-shell WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/AppManager ) -add_custom_command( - TARGET ${TARGET_NAME} - PRE_BUILD - COMMAND make AppManagerTest_code_check - WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ -) file(GLOB_RECURSE HEADER_FILES *.h) add_custom_target( diff --git a/test/middleware/HuntingUpgrade/CMakeLists.txt b/test/middleware/HuntingUpgrade/CMakeLists.txt index 85d7478f..77999f0b 100644 --- a/test/middleware/HuntingUpgrade/CMakeLists.txt +++ b/test/middleware/HuntingUpgrade/CMakeLists.txt @@ -50,12 +50,6 @@ add_custom_target( -p ${PLATFORM_PATH}/cmake-shell WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/HuntingUpgrade ) -add_custom_command( - TARGET ${TARGET_NAME} - PRE_BUILD - COMMAND make HuntingUpgradeTest_code_check - WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ -) file(GLOB_RECURSE HEADER_FILES *.h) add_custom_target( diff --git a/test/middleware/IpcConfig/CMakeLists.txt b/test/middleware/IpcConfig/CMakeLists.txt index 97e7ffd8..8d64a7eb 100644 --- a/test/middleware/IpcConfig/CMakeLists.txt +++ b/test/middleware/IpcConfig/CMakeLists.txt @@ -51,12 +51,6 @@ add_custom_target( -p ${PLATFORM_PATH}/cmake-shell WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/IpcConfig ) -add_custom_command( - TARGET ${TARGET_NAME} - PRE_BUILD - COMMAND make IpcConfigTest_code_check - WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ -) file(GLOB_RECURSE HEADER_FILES *.h) add_custom_target( diff --git a/test/middleware/McuManager/CMakeLists.txt b/test/middleware/McuManager/CMakeLists.txt index 408458d0..47470dc1 100644 --- a/test/middleware/McuManager/CMakeLists.txt +++ b/test/middleware/McuManager/CMakeLists.txt @@ -59,12 +59,6 @@ add_custom_target( -p ${PLATFORM_PATH}/cmake-shell WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/McuManager ) -add_custom_command( - TARGET ${TARGET_NAME} - PRE_BUILD - COMMAND make McuManagerTest_code_check - WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ -) file(GLOB_RECURSE HEADER_FILES *.h) add_custom_target( diff --git a/test/middleware/MediaManager/CMakeLists.txt b/test/middleware/MediaManager/CMakeLists.txt index 647cba23..29196dc9 100644 --- a/test/middleware/MediaManager/CMakeLists.txt +++ b/test/middleware/MediaManager/CMakeLists.txt @@ -52,12 +52,6 @@ add_custom_target( -p ${PLATFORM_PATH}/cmake-shell WORKING_DIRECTORY ${TEST_SOURCE_PATH}/middleware/MediaManager ) -add_custom_command( - TARGET ${TARGET_NAME} - PRE_BUILD - COMMAND make MediaManagerTest_code_check - WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/ -) file(GLOB_RECURSE HEADER_FILES *.h) add_custom_target( diff --git a/test/middleware/MediaManager/src/MediaManagerTest.cpp b/test/middleware/MediaManager/src/MediaManagerTest.cpp new file mode 100644 index 00000000..5c294802 --- /dev/null +++ b/test/middleware/MediaManager/src/MediaManagerTest.cpp @@ -0,0 +1,49 @@ +/* + * 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 "MediaManagerTest.h" +void MediaManagerTest::SetUpTestCase() +{ + CreateLogModule(); + ILogInit(LOG_INSTANCE_TYPE_END); +} +void MediaManagerTest::TearDownTestCase() +{ + ILogUnInit(); +} +void MediaManagerTest::SetUp() +{ + CreateAllCamerasMcok(); + HalTestTool::Init(); + MediaManagerTestTool::Init(); + CreateHalCppModule(); + CreateMediaManagerModule(); +} +void MediaManagerTest::TearDown() +{ + MediaManagerTestTool::UnInit(); + HalTestTool::UnInit(); + DestroyMediaManagerModule(); + DestroyHalCppModule(); + DestroyAllCamerasMock(); +} +void MediaManagerTest::CreateAllCamerasMcok(void) +{ + std::shared_ptr camera = HalTestTool::MakeCameraHalTest(CameraType::MAIN_CAMERA); + mAllCamerasMock[CameraType::MAIN_CAMERA] = camera; +} +void MediaManagerTest::DestroyAllCamerasMock(void) +{ + mAllCamerasMock.clear(); +} \ No newline at end of file diff --git a/test/middleware/MediaManager/src/MediaManagerTest.h b/test/middleware/MediaManager/src/MediaManagerTest.h new file mode 100644 index 00000000..d2985b7c --- /dev/null +++ b/test/middleware/MediaManager/src/MediaManagerTest.h @@ -0,0 +1,46 @@ +/* + * 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 MEDIA_MANAGER_TEST_H +#define MEDIA_MANAGER_TEST_H +#include "GtestUsing.h" +#include "HalTestTool.h" +#include "ILog.h" +#include "IMediaManager.h" +#include "MediaManagerTestTool.h" +#include +#include +#include +class MediaManagerTest : public testing::Test, public MediaManagerTestTool, public HalTestTool +{ +public: + MediaManagerTest() + { + } + virtual ~MediaManagerTest() + { + } + static void SetUpTestCase(); + static void TearDownTestCase(); + virtual void SetUp(); + virtual void TearDown(); + +private: + void CreateAllCamerasMcok(void); + void DestroyAllCamerasMock(void); + +protected: + std::map> mAllCamerasMock; +}; +#endif \ No newline at end of file diff --git a/test/middleware/MediaManager/src/MediaManager_Test.cpp b/test/middleware/MediaManager/src/MediaManager_Test.cpp index 720b9ecf..ff3c19dc 100644 --- a/test/middleware/MediaManager/src/MediaManager_Test.cpp +++ b/test/middleware/MediaManager/src/MediaManager_Test.cpp @@ -16,62 +16,13 @@ #include "HalTestTool.h" #include "ILog.h" #include "IMediaManager.h" +#include "MediaManagerTest.h" #include "MediaManagerTestTool.h" #include #include #include -namespace MediaManagerTest +namespace MediaManager_Test { -class MediaManagerTest : public testing::Test, public MediaManagerTestTool, public HalTestTool -{ -public: - MediaManagerTest() - { - } - virtual ~MediaManagerTest() - { - } - static void SetUpTestCase() - { - CreateLogModule(); - ILogInit(LOG_INSTANCE_TYPE_END); - } - static void TearDownTestCase() - { - ILogUnInit(); - } - virtual void SetUp() - { - CreateAllCamerasMcok(); - HalTestTool::Init(); - MediaManagerTestTool::Init(); - CreateHalCppModule(); - CreateMediaManagerModule(); - } - virtual void TearDown() - { - MediaManagerTestTool::UnInit(); - HalTestTool::UnInit(); - DestroyMediaManagerModule(); - DestroyHalCppModule(); - DestroyAllCamerasMock(); - } - -private: - void CreateAllCamerasMcok(void) - { - std::shared_ptr camera = HalTestTool::MakeCameraHalTest(CameraType::MAIN_CAMERA); - mAllCamerasMock[CameraType::MAIN_CAMERA] = camera; - } - void DestroyAllCamerasMock(void) - { - mAllCamerasMock.clear(); - } - -protected: - // const AppParam mAppParam; - std::map> mAllCamerasMock; -}; // ../output_files/test/bin/MediaManagerTest --gtest_filter=MediaManagerTest.INTEGRATION_MediaManager_EXAMPLE_Demo0 TEST_F(MediaManagerTest, INTEGRATION_MediaManager_EXAMPLE_Demo0) { @@ -81,11 +32,6 @@ TEST_F(MediaManagerTest, INTEGRATION_MediaManager_EXAMPLE_Demo0) IMediaManager::GetInstance()->SetMediaMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockReportCameraEvent("test name", CameraType::MAIN_CAMERA); - // MockAppClientConnect(); - // std::this_thread::sleep_for(std::chrono::milliseconds(100)); - // MockSetRecordingStatus(RecordingStatus::RECORDING_START); - // std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - // IAppManager::GetInstance()->UnInit(); IMediaManager::GetInstance()->UnInit(); } -} // namespace MediaManagerTest \ No newline at end of file +} // namespace MediaManager_Test \ No newline at end of file diff --git a/test/middleware/MediaManager/tool/src/MediaManagerMock.cpp b/test/middleware/MediaManager/tool/src/MediaManagerMock.cpp index da8e84e1..fab0fb5b 100644 --- a/test/middleware/MediaManager/tool/src/MediaManagerMock.cpp +++ b/test/middleware/MediaManager/tool/src/MediaManagerMock.cpp @@ -14,16 +14,16 @@ */ #include "MediaManagerMock.h" #include "ILog.h" -StatusCode MediaManagerTest::SetMediaMonitor(std::shared_ptr &monitor) +StatusCode MediaManagerMockBase::SetMediaMonitor(std::shared_ptr &monitor) { - LogInfo("MediaManagerTest::SetMediaMonitor\n"); + LogInfo("MediaManagerMockBase::SetMediaMonitor\n"); StatusCode code = SetMediaMonitorTrace(monitor); if (StatusCodeEqual(code, "STATUS_CODE_VIRTUAL_FUNCTION")) { return MediaManagerImpl::SetMediaMonitor(monitor); } return code; } -const StatusCode MediaManagerTest::SetMediaMonitorTrace(std::shared_ptr &monitor) +const StatusCode MediaManagerMockBase::SetMediaMonitorTrace(std::shared_ptr &monitor) { LogInfo("SetMediaMonitorTrace::SetMediaMonitorTrace\n"); return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION); diff --git a/test/middleware/MediaManager/tool/src/MediaManagerMock.h b/test/middleware/MediaManager/tool/src/MediaManagerMock.h index 6b6fcd9f..83ea285f 100644 --- a/test/middleware/MediaManager/tool/src/MediaManagerMock.h +++ b/test/middleware/MediaManager/tool/src/MediaManagerMock.h @@ -16,18 +16,17 @@ #define MEDIA_MANAGER_MOCK_H #include "MediaManagerImpl.h" #include "MediaManagerTestTool.h" -class MediaManagerTest : public MediaManagerImpl +class MediaManagerMockBase : public MediaManagerImpl { public: - MediaManagerTest() = default; - virtual ~MediaManagerTest() = default; - // const StatusCode SetMediaMonitor(std::shared_ptr &monitor) override; + MediaManagerMockBase() = default; + virtual ~MediaManagerMockBase() = default; StatusCode SetMediaMonitor(std::shared_ptr &monitor) override; protected: virtual const StatusCode SetMediaMonitorTrace(std::shared_ptr &monitor); }; -class MediaManagerMock : public MediaManagerTest +class MediaManagerMock : public MediaManagerMockBase { public: MediaManagerMock() = default; diff --git a/utils/MediaBase/src/IMediaBase.cpp b/utils/MediaBase/src/IMediaBase.cpp index 7996ecb7..2ff8e4ea 100644 --- a/utils/MediaBase/src/IMediaBase.cpp +++ b/utils/MediaBase/src/IMediaBase.cpp @@ -14,8 +14,13 @@ */ #include "IMediaBase.h" #include "ILog.h" +#include "MediaBase.h" #include "MediaBaseMakePtr.h" +#include "StatusCode.h" +#include +#include #include +#include StatusCode IMediaBase::StartReadFile(const std::string &path) { LogWarning("STATUS_CODE_VIRTUAL_FUNCTION\n"); diff --git a/utils/MediaBase/src/MediaBase.cpp b/utils/MediaBase/src/MediaBase.cpp index cdf31fab..1fe934e9 100644 --- a/utils/MediaBase/src/MediaBase.cpp +++ b/utils/MediaBase/src/MediaBase.cpp @@ -15,6 +15,10 @@ #include "MediaBase.h" #include "ILog.h" #include "IMediaBase.h" +#include "StatusCode.h" +#include +#include +#include void *ICreateMediaBase(const MediaHandleType type) { return NewIMediaBase(type); diff --git a/utils/MediaBase/src/MediaBaseImpl.cpp b/utils/MediaBase/src/MediaBaseImpl.cpp index 360b965c..81af7b7d 100644 --- a/utils/MediaBase/src/MediaBaseImpl.cpp +++ b/utils/MediaBase/src/MediaBaseImpl.cpp @@ -14,12 +14,17 @@ */ #include "MediaBaseImpl.h" #include "ILog.h" +#include "StatusCode.h" +#include +#include #ifdef __cplusplus extern "C" { #endif -#include +// #include +#include #include -#include +#include +// #include #ifdef __cplusplus } #endif @@ -32,6 +37,12 @@ StatusCode MediaBaseImpl::StartReadFile(const std::string &path) LogError("Couldn't open file: %s, result=%d\n", path.c_str(), result); return CreateStatusCode(STATUS_CODE_NOT_OK); } + // LogInfo("File: %s\n", pFormatCtx->filename); + // LogInfo("File format: %s\n", pFormatCtx->iformat->name); + // LogInfo("Duration: %ld\n", pFormatCtx->duration); + // for (int i = 0; i < pFormatCtx->nb_streams; i++) { + // LogInfo("stream codec_type = %d\n", pFormatCtx->streams[i]->codecpar->codec_type); + // } if (avformat_find_stream_info(pFormatCtx, nullptr) < 0) { LogError("Couldn't find stream information.\n"); return CreateStatusCode(STATUS_CODE_NOT_OK); diff --git a/utils/MediaBase/src/MediaBaseMakePtr.cpp b/utils/MediaBase/src/MediaBaseMakePtr.cpp index 4c14267e..5c3bf7e0 100644 --- a/utils/MediaBase/src/MediaBaseMakePtr.cpp +++ b/utils/MediaBase/src/MediaBaseMakePtr.cpp @@ -14,7 +14,9 @@ */ #include "MediaBaseMakePtr.h" #include "ILog.h" +#include "IMediaBase.h" #include "MediaBaseImpl.h" +#include std::shared_ptr &MediaBaseMakePtr::GetInstance(std::shared_ptr *impl) { static auto instance = std::make_shared();