/* * 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 "HalTestTool.h" #include "IAppManager.h" #include "ILog.h" #include #include #include namespace AppManagerTest { class AppManagerTest : public testing::Test, public AppManagerTestTool, public HalTestTool { public: AppManagerTest() : mAppParam(APP_MANAGER_DEVICE_IP, APP_MANAGER_HTTP_SERVER_PORT, APP_MANAGER_TCP_SERVER_PORT) { } virtual ~AppManagerTest() { } static void SetUpTestCase() { CreateLogModule(); ILogInit(LOG_INSTANCE_TYPE_END); } static void TearDownTestCase() { ILogUnInit(); DestroyLogModule(); } virtual void SetUp() { HalTestTool::Init(); AppManagerTestTool::Init(); CreateHalCppModule(); CreateAppManagerModule(); } virtual void TearDown() { AppManagerTestTool::UnInit(); HalTestTool::UnInit(); DestroyAppManagerModule(); DestroyHalCppModule(); } protected: const AppParam mAppParam; }; // ../output_files/test/bin/AppManagerTest --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_Demo0 TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_Demo0) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); 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(); } // ../output_files/test/bin/AppManagerTest --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_Demo TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_Demo) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); AppManagerTestTool::MockGetProductInfo(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_Upload TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_Upload) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockUploadFiles(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_GetDeviceAttr TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_GetDeviceAttr) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); AppManagerTestTool::MockGetDeviceAttr(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_GetMediaInfo TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_GetMediaInfo) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); AppManagerTestTool::MockGetMediaInfo(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_GetSdCardInfo TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_GetSdCardInfo) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); AppManagerTestTool::MockGetSdCardInfo(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_GetBatteryInfo TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_GetBatteryInfo) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); AppManagerTestTool::MockGetBatteryInfo(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_SetDateTime TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_SetDateTime) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockSetDateTime(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_SetTimeZone TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_SetTimeZone) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockSetTimeZone(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_GetParamValue TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_GetParamValue) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); AppManagerTestTool::MockGetParamValue("all"); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_GetParamValue2 TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_GetParamValue2) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); AppManagerTestTool::MockGetParamValue("rec"); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_GetParamItems TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_GetParamItems) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); AppManagerTestTool::MockGetParamItems("all"); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_GetParamItems2 TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_GetParamItems2) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); AppManagerTestTool::MockGetParamItems("mic"); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_GetCapability TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_GetCapability) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); AppManagerTestTool::MockGetCapability(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_GetLockVideoStatus TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_GetLockVideoStatus) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); AppManagerTestTool::MockGetLockVideoStatus(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_GetStorageInfo TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_GetStorageInfo) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); AppManagerTestTool::MockGetStorageInfo(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_GetStorageFileList TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_GetStorageFileList) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); AppManagerTestTool::MockGetStorageFileList(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_SetParamValue TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_SetParamValue) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockSetParamValue("mic", "1"); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_EnterRecorder TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_EnterRecorder) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockEnterRecorder(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_AppPlayback TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_AppPlayback) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockAppPlayback(); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_SetRecordingStatus TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_SetRecordingStatus) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); 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(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_SetMicrophoneStatus TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_SetMicrophoneStatus) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockAppClientConnect(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockSetMicrophoneStatus(MicrophoneStatus::ON); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_SetBatteryStatus TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_SetBatteryStatus) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockAppClientConnect(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockSetBatteryStatus(BatteryStatus::CHARGING, 20); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_SetSdCardStatus TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_SetSdCardStatus) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockAppClientConnect(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockSetSdCardStatus(SdCardStatus::NOT_INSERTED); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_DeletedFileMessage TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_DeletedFileMessage) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockAppClientConnect(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockDeletedFileMessage("file_name", StorageFileType::VIDEO); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); IAppManager::GetInstance()->UnInit(); } // ../output_files/test/bin/AppManagerTest // --gtest_filter=AppManagerTest.INTEGRATION_AppManager_EXAMPLE_AUTO_CreatedFileMessage TEST_F(AppManagerTest, INTEGRATION_AppManager_EXAMPLE_AUTO_CreatedFileMessage) { std::shared_ptr monitor = AppManagerTestTool::MakeMonitorMock(); IAppManager::GetInstance()->Init(mAppParam); IAppManager::GetInstance()->SetAppMonitor(monitor); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockAppClientConnect(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); MockCreatedFileMessage("file_name", StorageFileType::VIDEO); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); IAppManager::GetInstance()->UnInit(); } } // namespace AppManagerTest