/* * 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 "ILog.h" #include "MainThread.h" #include "McuManagerTestTool.h" #include "MissionManagerTestTool.h" #include "TestManager.h" #include namespace HunttingCameraTest { 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) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockGetProductInfo(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetDeviceAttr TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetDeviceAttr) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockGetDeviceAttr(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetMediaInfo TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetMediaInfo) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockGetMediaInfo(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetSdCardInfo TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetSdCardInfo) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockGetSdCardInfo(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetBatteryInfo TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetBatteryInfo) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockGetBatteryInfo(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_SetDateTime TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_SetDateTime) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockSetDateTime(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_SetTimeZone TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_SetTimeZone) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockSetTimeZone(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_MockUploadFiles TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_MockUploadFiles) { MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockUploadFiles(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_McuOpenFailed TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_McuOpenFailed) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); // MockUploadFiles(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetParamValue TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetParamValue) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockGetParamValue(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetCapability TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetCapability) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockGetCapability(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetLockVideoStatus TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetLockVideoStatus) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockGetLockVideoStatus(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetStorageInfo TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageInfo) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockGetStorageInfo(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_GetStorageFileList TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_GetStorageFileList) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockGetStorageFileList(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_SetParamValue TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_SetParamValue) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockSetParamValue(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_EnterRecorder TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_EnterRecorder) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockEnterRecorder(); MainThread::GetInstance()->Runing(); } // ../output_files/test/bin/HunttingCameraTest // --gtest_filter=HunttingCameraTest.INTEGRATION_HunttingCamera_AUTO_AppPlayback TEST_F(HunttingCameraTest, INTEGRATION_HunttingCamera_AUTO_AppPlayback) { McuManagerTestTool::MockMcuDeviceOpenFailed(mLinuxTest); MainThread::GetInstance()->Init(); TestManager::ResetTimeOut(1000 * 3); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockAppPlayback(); MainThread::GetInstance()->Runing(); } } // namespace HunttingCameraTest