diff --git a/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp b/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp index 2535fc1a2f..f362712d47 100644 --- a/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp +++ b/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp @@ -1502,6 +1502,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_TerminateAbilityResultLocked HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_GetOrCreateServiceRecord_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); AbilityRequest abilityRequest; bool isCreatedByConnect = false; std::shared_ptr targetService = nullptr; @@ -1522,6 +1523,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_GetOrCreateServiceRecord_001 HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_ConnectAbilityLocked_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); auto handler = std::make_shared(EventRunner::Create()); connectManager->SetEventHandler(handler); std::shared_ptr abilityRecord = serviceRecord_; @@ -1581,6 +1583,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_AttachAbilityThreadLocked_00 HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_OnAppStateChanged_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; AppInfo info; std::string bundleName = "bundleName"; @@ -1606,6 +1609,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_OnAppStateChanged_001, TestS HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_OnAppStateChanged_002, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; AppInfo info; std::string bundleName = "bundleName"; @@ -1864,6 +1868,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_LoadAbility_002, TestSize.Le HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_PostTimeOutTask_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; uint32_t messageId = 2; connectManager->PostTimeOutTask(abilityRecord, messageId); @@ -1880,6 +1885,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_PostTimeOutTask_001, TestSiz HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleStartTimeoutTask_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; int resultCode = LOAD_ABILITY_TIMEOUT; abilityRecord->abilityInfo_.name = "abilityName"; @@ -1897,6 +1903,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleStartTimeoutTask_001, HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleStartTimeoutTask_002, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; int resultCode = LOAD_ABILITY_TIMEOUT; abilityRecord->abilityInfo_.name = AbilityConfig::LAUNCHER_ABILITY_NAME; @@ -1914,6 +1921,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleStartTimeoutTask_002, HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleStartTimeoutTask_003, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; int resultCode = CONNECTION_TIMEOUT; abilityRecord->abilityInfo_.name = AbilityConfig::LAUNCHER_ABILITY_NAME; @@ -1931,6 +1939,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleStartTimeoutTask_003, HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleCommandTimeoutTask_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; abilityRecord->abilityInfo_.name = AbilityConfig::LAUNCHER_ABILITY_NAME; connectManager->HandleCommandTimeoutTask(abilityRecord); @@ -1949,6 +1958,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleCommandTimeoutTask_001 HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleTerminateDisconnectTask_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); OHOS::sptr callback = new AbilityConnectCallback(); std::shared_ptr connection = std::make_shared(nullptr, nullptr, callback); @@ -2008,6 +2018,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_DispatchTerminate_001, TestS HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_CommandAbility_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; connectManager->SetEventHandler(nullptr); connectManager->CommandAbility(abilityRecord); @@ -2024,6 +2035,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_CommandAbility_001, TestSize HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_TerminateDone_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; abilityRecord->SetAbilityState(AbilityState::TERMINATING); connectManager->TerminateDone(abilityRecord); @@ -2064,6 +2076,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_IsAbilityConnected_001, Test HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_RemoveServiceAbility_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; AbilityInfo abilityInfo; abilityRecord->abilityInfo_ = abilityInfo; @@ -2082,6 +2095,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_RemoveServiceAbility_001, Te HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_OnCallBackDied_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; wptr remote{ abilityRecord->GetToken() }; connectManager->SetEventHandler(nullptr); @@ -2099,6 +2113,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_OnCallBackDied_001, TestSize HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleCallBackDiedTask_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; sptr connect = abilityRecord->GetToken(); connectManager->connectMap_.clear(); @@ -2116,6 +2131,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleCallBackDiedTask_001, HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_OnAbilityDied_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; int32_t currentUserId = 0; abilityRecord->abilityInfo_.type = AbilityType::PAGE; @@ -2136,6 +2152,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_OnAbilityDied_001, TestSize. HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_OnTimeOut_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; uint32_t msgId = 2; connectManager->serviceMap_.emplace("first", abilityRecord); @@ -2156,6 +2173,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_OnTimeOut_001, TestSize.Leve HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleInactiveTimeout_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; abilityRecord->abilityInfo_.name = AbilityConfig::LAUNCHER_ABILITY_NAME; connectManager->HandleInactiveTimeout(abilityRecord); @@ -2174,6 +2192,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleInactiveTimeout_001, T HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleAbilityDiedTask_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; int32_t currentUserId = 0; connectManager->serviceMap_.clear(); @@ -2191,6 +2210,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_HandleAbilityDiedTask_001, T HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_RestartAbility_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; int32_t currentUserId = 0; connectManager->userId_ = 1; @@ -2211,6 +2231,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_RestartAbility_001, TestSize HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_RestartAbility_002, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; int32_t currentUserId = 0; connectManager->userId_ = currentUserId; @@ -2230,6 +2251,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_RestartAbility_002, TestSize HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_DumpState_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; std::vector info; bool isClient = false; @@ -2253,6 +2275,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_DumpState_001, TestSize.Leve HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_DumpStateByUri_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; std::vector info; bool isClient = false; @@ -2275,6 +2298,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_DumpStateByUri_001, TestSize HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_GetExtensionRunningInfos_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; int upperLimit = 1; std::vector info; @@ -2297,6 +2321,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_GetExtensionRunningInfos_001 HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_GetExtensionRunningInfo_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = serviceRecord_; OHOS::sptr callback = new AbilityConnectCallback(); std::shared_ptr connection = @@ -2324,6 +2349,7 @@ HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_GetExtensionRunningInfo_001, HWTEST_F(AbilityConnectManagerTest, AAFwk_AbilityMS_StopAllExtensions_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(0); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord1 = serviceRecord_; std::shared_ptr abilityRecord2 = serviceRecord_; abilityRecord1->abilityInfo_.type = AbilityType::EXTENSION; @@ -2599,6 +2625,7 @@ HWTEST_F(AbilityConnectManagerTest, MinimizeUIExtensionAbilityLocked_003, TestSi HWTEST_F(AbilityConnectManagerTest, MoveToBackground_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord; connectManager->MoveToBackground(abilityRecord); connectManager.reset(); @@ -2615,6 +2642,7 @@ HWTEST_F(AbilityConnectManagerTest, MoveToBackground_001, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, MoveToBackground_002, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); abilityRecord->lifeCycleStateInfo_.sceneFlag = 1; connectManager->MoveToBackground(abilityRecord); @@ -2632,6 +2660,7 @@ HWTEST_F(AbilityConnectManagerTest, MoveToBackground_002, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, MoveToBackground_003, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); abilityRecord->lifeCycleStateInfo_.sceneFlag = 2; abilityRecord->SetClearMissionFlag(true); @@ -2651,6 +2680,7 @@ HWTEST_F(AbilityConnectManagerTest, MoveToBackground_003, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, CompleteBackground_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); abilityRecord->currentState_ = AbilityState::FOREGROUND; connectManager->CompleteBackground(abilityRecord); @@ -2668,6 +2698,7 @@ HWTEST_F(AbilityConnectManagerTest, CompleteBackground_001, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, CompleteBackground_002, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); abilityRecord->currentState_ = AbilityState::BACKGROUNDING; abilityRecord->SetPendingState(AbilityState::FOREGROUND); @@ -2687,6 +2718,7 @@ HWTEST_F(AbilityConnectManagerTest, CompleteBackground_002, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, CompleteBackground_003, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); abilityRecord->currentState_ = AbilityState::BACKGROUNDING; abilityRecord->SetPendingState(AbilityState::BACKGROUND); @@ -2709,6 +2741,7 @@ HWTEST_F(AbilityConnectManagerTest, CompleteBackground_003, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, CompleteBackground_004, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); std::shared_ptr abilityRecord2 = InitAbilityRecord(); abilityRecord->currentState_ = AbilityState::BACKGROUNDING; @@ -2733,6 +2766,7 @@ HWTEST_F(AbilityConnectManagerTest, CompleteBackground_004, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, CompleteBackground_005, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); std::shared_ptr abilityRecord2 = InitAbilityRecord(); abilityRecord->currentState_ = AbilityState::BACKGROUNDING; @@ -2757,6 +2791,7 @@ HWTEST_F(AbilityConnectManagerTest, CompleteBackground_005, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, CompleteBackground_006, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); std::shared_ptr abilityRecord2 = InitAbilityRecord(); abilityRecord->currentState_ = AbilityState::BACKGROUNDING; @@ -2781,6 +2816,7 @@ HWTEST_F(AbilityConnectManagerTest, CompleteBackground_006, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_001, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); uint32_t msgId = 0; connectManager->PrintTimeOutLog(nullptr, msgId); connectManager.reset(); @@ -2797,6 +2833,7 @@ HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_001, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_002, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); uint32_t msgId = 0; connectManager->PrintTimeOutLog(abilityRecord, msgId); @@ -2814,6 +2851,7 @@ HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_002, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_003, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); uint32_t msgId = 1; connectManager->PrintTimeOutLog(abilityRecord, msgId); @@ -2831,6 +2869,7 @@ HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_003, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_004, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); uint32_t msgId = 2; connectManager->PrintTimeOutLog(abilityRecord, msgId); @@ -2848,6 +2887,7 @@ HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_004, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_005, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); uint32_t msgId = 4; connectManager->PrintTimeOutLog(abilityRecord, msgId); @@ -2865,6 +2905,7 @@ HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_005, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_006, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); uint32_t msgId = 5; connectManager->PrintTimeOutLog(abilityRecord, msgId); @@ -2882,6 +2923,7 @@ HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_006, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_007, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); uint32_t msgId = 6; connectManager->PrintTimeOutLog(abilityRecord, msgId); @@ -2899,6 +2941,7 @@ HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_007, TestSize.Level1) HWTEST_F(AbilityConnectManagerTest, PrintTimeOutLog_008, TestSize.Level1) { std::shared_ptr connectManager = std::make_shared(3); + ASSERT_NE(connectManager, nullptr); std::shared_ptr abilityRecord = InitAbilityRecord(); uint32_t msgId = 3; connectManager->PrintTimeOutLog(abilityRecord, msgId); diff --git a/test/unittest/ability_manager_service_test/ability_manager_service_test.cpp b/test/unittest/ability_manager_service_test/ability_manager_service_test.cpp index 28b10a24ae..33b804c835 100755 --- a/test/unittest/ability_manager_service_test/ability_manager_service_test.cpp +++ b/test/unittest/ability_manager_service_test/ability_manager_service_test.cpp @@ -904,6 +904,7 @@ HWTEST_F(AbilityManagerServiceTest, NotifyCompleteContinuation_001, TestSize.Lev { HILOG_INFO("AbilityManagerServiceTest NotifyCompleteContinuation_001 start"); std::string deviceId = "test"; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->NotifyCompleteContinuation(deviceId, 1, true); HILOG_INFO("AbilityManagerServiceTest NotifyCompleteContinuation_001 end"); } @@ -1105,6 +1106,7 @@ HWTEST_F(AbilityManagerServiceTest, SendWantSender_001, TestSize.Level1) HWTEST_F(AbilityManagerServiceTest, CancelWantSender_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest CancelWantSender_001 start"); + ASSERT_NE(abilityMs_, nullptr); abilityMs_->CancelWantSender(nullptr); HILOG_INFO("AbilityManagerServiceTest CancelWantSender_001 end"); } @@ -1203,6 +1205,7 @@ HWTEST_F(AbilityManagerServiceTest, GetPendingWantType_001, TestSize.Level1) HWTEST_F(AbilityManagerServiceTest, RegisterCancelListener_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest RegisterCancelListener_001 start"); + ASSERT_NE(abilityMs_, nullptr); abilityMs_->RegisterCancelListener(nullptr, nullptr); HILOG_INFO("AbilityManagerServiceTest RegisterCancelListener_001 end"); } @@ -1216,6 +1219,7 @@ HWTEST_F(AbilityManagerServiceTest, RegisterCancelListener_001, TestSize.Level1) HWTEST_F(AbilityManagerServiceTest, UnregisterCancelListener_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest UnregisterCancelListener_001 start"); + ASSERT_NE(abilityMs_, nullptr); abilityMs_->UnregisterCancelListener(nullptr, nullptr); HILOG_INFO("AbilityManagerServiceTest UnregisterCancelListener_001 end"); } @@ -1466,6 +1470,7 @@ HWTEST_F(AbilityManagerServiceTest, DumpInner_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest DumpInner_001 start"); std::vector info; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->DumpInner("", info); HILOG_INFO("AbilityManagerServiceTest DumpInner_001 end"); } @@ -1480,6 +1485,7 @@ HWTEST_F(AbilityManagerServiceTest, DumpMissionListInner_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest DumpMissionListInner_001 start"); std::vector info; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->DumpMissionListInner("", info); HILOG_INFO("AbilityManagerServiceTest DumpMissionListInner_001 end"); } @@ -1494,6 +1500,7 @@ HWTEST_F(AbilityManagerServiceTest, DumpMissionInfosInner_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest DumpMissionInfosInner_001 start"); std::vector info; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->DumpMissionInfosInner("", info); HILOG_INFO("AbilityManagerServiceTest DumpMissionInfosInner_001 end"); } @@ -1508,6 +1515,7 @@ HWTEST_F(AbilityManagerServiceTest, DumpMissionInner_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest DumpMissionInner_001 start"); std::vector info; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->DumpMissionInner("", info); HILOG_INFO("AbilityManagerServiceTest DumpMissionInner_001 end"); } @@ -1522,6 +1530,7 @@ HWTEST_F(AbilityManagerServiceTest, DumpStateInner_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest DumpStateInner_001 start"); std::vector info; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->DumpStateInner("", info); HILOG_INFO("AbilityManagerServiceTest DumpStateInner_001 end"); } @@ -1536,6 +1545,7 @@ HWTEST_F(AbilityManagerServiceTest, DataDumpStateInner_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest DataDumpStateInner_001 start"); std::vector info; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->DataDumpStateInner("", info); HILOG_INFO("AbilityManagerServiceTest DataDumpStateInner_001 end"); } @@ -1550,6 +1560,7 @@ HWTEST_F(AbilityManagerServiceTest, DumpState_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest DumpState_001 start"); std::vector info; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->DumpState("", info); HILOG_INFO("AbilityManagerServiceTest DumpState_001 end"); } @@ -1564,6 +1575,7 @@ HWTEST_F(AbilityManagerServiceTest, DumpSysState_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest DumpSysState_001 start"); std::vector info; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->DumpSysState("", info, true, true, 100); HILOG_INFO("AbilityManagerServiceTest DumpSysState_001 end"); } @@ -1619,6 +1631,7 @@ HWTEST_F(AbilityManagerServiceTest, ScheduleCommandAbilityDone_001, TestSize.Lev HWTEST_F(AbilityManagerServiceTest, OnAbilityRequestDone_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest OnAbilityRequestDone_001 start"); + ASSERT_NE(abilityMs_, nullptr); abilityMs_->OnAbilityRequestDone(nullptr, 1); abilityMs_->OnAbilityRequestDone(MockToken(AbilityType::DATA), 1); abilityMs_->OnAbilityRequestDone(MockToken(AbilityType::UNKNOWN), 1); @@ -1635,6 +1648,7 @@ HWTEST_F(AbilityManagerServiceTest, OnAppStateChanged_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest OnAppStateChanged_001 start"); AppInfo info; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->OnAppStateChanged(info); HILOG_INFO("AbilityManagerServiceTest OnAppStateChanged_001 end"); } @@ -1648,6 +1662,7 @@ HWTEST_F(AbilityManagerServiceTest, OnAppStateChanged_001, TestSize.Level1) HWTEST_F(AbilityManagerServiceTest, GetEventHandler_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest GetEventHandler_001 start"); + ASSERT_NE(abilityMs_, nullptr); EXPECT_NE(abilityMs_->GetEventHandler(), nullptr); HILOG_INFO("AbilityManagerServiceTest GetEventHandler_001 end"); } @@ -1661,6 +1676,7 @@ HWTEST_F(AbilityManagerServiceTest, GetEventHandler_001, TestSize.Level1) HWTEST_F(AbilityManagerServiceTest, InitMissionListManager_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest InitMissionListManager_001 start"); + ASSERT_NE(abilityMs_, nullptr); abilityMs_->InitMissionListManager(100, false); HILOG_INFO("AbilityManagerServiceTest InitMissionListManager_001 end"); } @@ -1745,6 +1761,7 @@ HWTEST_F(AbilityManagerServiceTest, GetMaxRestartNum_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest GetMaxRestartNum_001 start"); int max = 0; + ASSERT_NE(abilityMs_, nullptr); max = AmsConfigurationParameter::GetInstance().GetMaxRestartNum(true); HILOG_INFO("AbilityManagerServiceTest GetMaxRestartNum_001 end"); } @@ -1843,6 +1860,7 @@ HWTEST_F(AbilityManagerServiceTest, IsSystemUI_001, TestSize.Level1) HWTEST_F(AbilityManagerServiceTest, HandleActiveTimeOut_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest HandleActiveTimeOut_001 start"); + ASSERT_NE(abilityMs_, nullptr); abilityMs_->HandleActiveTimeOut(100); HILOG_INFO("AbilityManagerServiceTest HandleActiveTimeOut_001 end"); } @@ -1856,6 +1874,7 @@ HWTEST_F(AbilityManagerServiceTest, HandleActiveTimeOut_001, TestSize.Level1) HWTEST_F(AbilityManagerServiceTest, HandleInactiveTimeOut_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest HandleInactiveTimeOut_001 start"); + ASSERT_NE(abilityMs_, nullptr); abilityMs_->HandleInactiveTimeOut(100); HILOG_INFO("AbilityManagerServiceTest HandleInactiveTimeOut_001 end"); } @@ -1970,6 +1989,7 @@ HWTEST_F(AbilityManagerServiceTest, GetDataAbilityManagerByToken_001, TestSize.L HWTEST_F(AbilityManagerServiceTest, StartResidentApps_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest StartResidentApps_001 start"); + ASSERT_NE(abilityMs_, nullptr); abilityMs_->StartResidentApps(); HILOG_INFO("AbilityManagerServiceTest StartResidentApps_001 end"); } @@ -1983,6 +2003,7 @@ HWTEST_F(AbilityManagerServiceTest, StartResidentApps_001, TestSize.Level1) HWTEST_F(AbilityManagerServiceTest, ConnectBmsService_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest ConnectBmsService_001 start"); + ASSERT_NE(abilityMs_, nullptr); abilityMs_->ConnectBmsService(); HILOG_INFO("AbilityManagerServiceTest ConnectBmsService_001 end"); } @@ -2144,6 +2165,7 @@ HWTEST_F(AbilityManagerServiceTest, OnAcceptWantResponse_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest OnAcceptWantResponse_001 start"); AAFwk::Want want; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->OnAcceptWantResponse(want, "test"); auto temp = abilityMs_->currentMissionListManager_; @@ -2163,6 +2185,7 @@ HWTEST_F(AbilityManagerServiceTest, OnStartSpecifiedAbilityTimeoutResponse_001, { HILOG_INFO("AbilityManagerServiceTest OnStartSpecifiedAbilityTimeoutResponse_001 start"); AAFwk::Want want; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->OnStartSpecifiedAbilityTimeoutResponse(want); auto temp = abilityMs_->currentMissionListManager_; @@ -2257,6 +2280,7 @@ HWTEST_F(AbilityManagerServiceTest, GetProcessRunningInfosByUserId_001, TestSize HWTEST_F(AbilityManagerServiceTest, ClearUserData_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest ClearUserData_001 start"); + ASSERT_NE(abilityMs_, nullptr); abilityMs_->ClearUserData(100); HILOG_INFO("AbilityManagerServiceTest ClearUserData_001 end"); } @@ -2296,6 +2320,7 @@ HWTEST_F(AbilityManagerServiceTest, CallRequestDone_001, TestSize.Level1) HILOG_INFO("AbilityManagerServiceTest CallRequestDone_001 start"); sptr token = nullptr; sptr callStub = nullptr; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->CallRequestDone(token, callStub); HILOG_INFO("AbilityManagerServiceTest CallRequestDone_001 end"); } @@ -2333,6 +2358,7 @@ HWTEST_F(AbilityManagerServiceTest, UpdateMissionSnapShot_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest UpdateMissionSnapShot_001 start"); MissionSnapshot missionSnapshot; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->UpdateMissionSnapShot(nullptr); MyFlag::flag_ = 1; @@ -2350,6 +2376,7 @@ HWTEST_F(AbilityManagerServiceTest, UpdateMissionSnapShot_001, TestSize.Level1) HWTEST_F(AbilityManagerServiceTest, EnableRecoverAbility_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest EnableRecoverAbility_001 start"); + ASSERT_NE(abilityMs_, nullptr); abilityMs_->EnableRecoverAbility(nullptr); abilityMs_->EnableRecoverAbility(MockToken(AbilityType::PAGE)); HILOG_INFO("AbilityManagerServiceTest EnableRecoverAbility_001 end"); @@ -2365,6 +2392,7 @@ HWTEST_F(AbilityManagerServiceTest, RecoverAbilityRestart_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest RecoverAbilityRestart_001 start"); Want want; + ASSERT_NE(abilityMs_, nullptr); abilityMs_->RecoverAbilityRestart(want); HILOG_INFO("AbilityManagerServiceTest RecoverAbilityRestart_001 end"); } @@ -2378,6 +2406,7 @@ HWTEST_F(AbilityManagerServiceTest, RecoverAbilityRestart_001, TestSize.Level1) HWTEST_F(AbilityManagerServiceTest, ScheduleRecoverAbility_001, TestSize.Level1) { HILOG_INFO("AbilityManagerServiceTest ScheduleRecoverAbility_001 start"); + ASSERT_NE(abilityMs_, nullptr); abilityMs_->ScheduleRecoverAbility(nullptr, 1); sptr token = MockToken(AbilityType::SERVICE); abilityMs_->ScheduleRecoverAbility(token, 1); @@ -2658,6 +2687,7 @@ HWTEST_F(AbilityManagerServiceTest, UpdateCallerInfo_001, TestSize.Level1) HILOG_INFO("AbilityManagerServiceTest UpdateCallerInfo_001 start"); Want want; sptr callerToken = MockToken(AbilityType::PAGE); + ASSERT_NE(abilityMs_, nullptr); abilityMs_->UpdateCallerInfo(want, callerToken); HILOG_INFO("AbilityManagerServiceTest UpdateCallerInfo_001 end"); } diff --git a/test/unittest/ams_mgr_scheduler_test/BUILD.gn b/test/unittest/ams_mgr_scheduler_test/BUILD.gn index 45818b4779..dc8c37d49c 100644 --- a/test/unittest/ams_mgr_scheduler_test/BUILD.gn +++ b/test/unittest/ams_mgr_scheduler_test/BUILD.gn @@ -24,8 +24,10 @@ ohos_unittest("ams_mgr_scheduler_test") { "${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include", ] - sources = - [ "${ability_runtime_services_path}/appmgr/src/ams_mgr_scheduler.cpp" ] + sources = [ + "${ability_runtime_services_path}/appmgr/src/ams_mgr_scheduler.cpp", + "${ability_runtime_test_path}/mock/services_appmgr_test/src/mock_bundle_manager.cpp", + ] sources += [ "ams_mgr_scheduler_test.cpp" ] diff --git a/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp b/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp index e00697a3b0..9bdb5c6aa7 100644 --- a/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp +++ b/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp @@ -23,6 +23,7 @@ #include "hilog_wrapper.h" #include "mock_ability_token.h" #include "mock_app_mgr_service_inner.h" +#include "mock_bundle_manager.h" #include "application_state_observer_stub.h" using namespace testing; @@ -106,6 +107,7 @@ HWTEST_F(AmsMgrSchedulerTest, AmsMgrScheduler_001, TestSize.Level1) auto amsEventHandler = GetAmsEventHandler(); std::unique_ptr amsMgrScheduler = std::make_unique(mockAppMgrServiceInner, amsEventHandler); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = new MockAbilityToken(); sptr preToken = new MockAbilityToken(); @@ -139,6 +141,7 @@ HWTEST_F(AmsMgrSchedulerTest, AmsMgrScheduler_002, TestSize.Level1) auto amsEventHandler = std::make_shared(eventRunner, mockAppMgrServiceInner); std::unique_ptr amsMgrScheduler = std::make_unique(mockAppMgrServiceInner, amsEventHandler); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = new MockAbilityToken(); sptr preToken = new MockAbilityToken(); @@ -174,6 +177,7 @@ HWTEST_F(AmsMgrSchedulerTest, AmsMgrScheduler_003, TestSize.Level1) auto amsEventHandler = GetAmsEventHandler(); std::unique_ptr amsMgrScheduler = std::make_unique(mockAppMgrServiceInner, amsEventHandler); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = new MockAbilityToken(); AbilityState abilityState = AbilityState::ABILITY_STATE_CREATE; @@ -202,6 +206,7 @@ HWTEST_F(AmsMgrSchedulerTest, AmsMgrScheduler_004, TestSize.Level1) auto amsEventHandler = GetAmsEventHandler(); std::unique_ptr amsMgrScheduler = std::make_unique(mockAppMgrServiceInner, amsEventHandler); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = new MockAbilityToken(); bool clearMissionFlag = true; EXPECT_CALL(*mockAppMgrServiceInner, TerminateAbility(_, _)) @@ -228,6 +233,7 @@ HWTEST_F(AmsMgrSchedulerTest, AmsMgrScheduler_005, TestSize.Level1) auto amsEventHandler = GetAmsEventHandler(); std::unique_ptr amsMgrScheduler = std::make_unique(mockAppMgrServiceInner, amsEventHandler); + ASSERT_NE(amsMgrScheduler, nullptr); sptr appStateCallbackHost = new AppStateCallbackHost(); EXPECT_CALL(*mockAppMgrServiceInner, RegisterAppStateCallback(_)) @@ -429,6 +435,7 @@ HWTEST_F(AmsMgrSchedulerTest, UnregisterApplicationStateObserver_001, TestSize.L HWTEST_F(AmsMgrSchedulerTest, LoadAbility_001, TestSize.Level0) { auto amsMgrScheduler = std::make_shared(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = nullptr; sptr preToken = nullptr; std::shared_ptr abilityInfo = nullptr; @@ -448,6 +455,7 @@ HWTEST_F(AmsMgrSchedulerTest, LoadAbility_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, LoadAbility_002, TestSize.Level0) { auto amsMgrScheduler = std::make_shared(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = nullptr; sptr preToken = nullptr; std::shared_ptr abilityInfo = std::make_shared(); @@ -467,6 +475,7 @@ HWTEST_F(AmsMgrSchedulerTest, LoadAbility_002, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, LoadAbility_003, TestSize.Level0) { auto amsMgrScheduler = std::make_shared(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = nullptr; sptr preToken = nullptr; std::shared_ptr abilityInfo = std::make_shared(); @@ -489,6 +498,7 @@ HWTEST_F(AmsMgrSchedulerTest, LoadAbility_004, TestSize.Level0) auto amsEventHandler = GetAmsEventHandler(); std::unique_ptr amsMgrScheduler = std::make_unique(mockAppMgrServiceInner, amsEventHandler); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = nullptr; sptr preToken = nullptr; std::shared_ptr abilityInfo = std::make_shared(); @@ -508,6 +518,7 @@ HWTEST_F(AmsMgrSchedulerTest, LoadAbility_004, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, UpdateAbilityState_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = nullptr; AbilityState state = AbilityState::ABILITY_STATE_READY; amsMgrScheduler->UpdateAbilityState(token, state); @@ -527,6 +538,7 @@ HWTEST_F(AmsMgrSchedulerTest, UpdateAbilityState_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, UpdateExtensionState_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = nullptr; ExtensionState state = ExtensionState::EXTENSION_STATE_READY; amsMgrScheduler->UpdateExtensionState(token, state); @@ -546,6 +558,7 @@ HWTEST_F(AmsMgrSchedulerTest, UpdateExtensionState_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, TerminateAbility_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = nullptr; bool clearMissionFlag = true; amsMgrScheduler->TerminateAbility(token, clearMissionFlag); @@ -565,6 +578,7 @@ HWTEST_F(AmsMgrSchedulerTest, TerminateAbility_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, RegisterAppStateCallback_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); sptr callback = nullptr; amsMgrScheduler->RegisterAppStateCallback(callback); amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); @@ -583,6 +597,7 @@ HWTEST_F(AmsMgrSchedulerTest, RegisterAppStateCallback_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, AbilityBehaviorAnalysis_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = nullptr; sptr preToken = nullptr; int32_t visibility = 0; @@ -605,6 +620,7 @@ HWTEST_F(AmsMgrSchedulerTest, AbilityBehaviorAnalysis_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, KillProcessesByUserId_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); int32_t userId = 0; amsMgrScheduler->KillProcessesByUserId(userId); } @@ -620,6 +636,7 @@ HWTEST_F(AmsMgrSchedulerTest, KillProcessesByUserId_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, KillProcessWithAccount_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); std::string bundleName = "bundleName"; int accountId = 0; int32_t res1 = amsMgrScheduler->KillProcessWithAccount(bundleName, accountId); @@ -641,6 +658,7 @@ HWTEST_F(AmsMgrSchedulerTest, KillProcessWithAccount_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, AbilityAttachTimeOut_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = nullptr; amsMgrScheduler->AbilityAttachTimeOut(token); amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); @@ -659,6 +677,7 @@ HWTEST_F(AmsMgrSchedulerTest, AbilityAttachTimeOut_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, PrepareTerminate_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = nullptr; amsMgrScheduler->PrepareTerminate(token); amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); @@ -677,6 +696,7 @@ HWTEST_F(AmsMgrSchedulerTest, PrepareTerminate_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, KillApplication_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); std::string bundleName = "bundleName"; amsMgrScheduler->KillApplication(bundleName); amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); @@ -695,6 +715,7 @@ HWTEST_F(AmsMgrSchedulerTest, KillApplication_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, KillApplicationByUid_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); std::string bundleName = "bundleName"; int uid = 0; amsMgrScheduler->KillApplicationByUid(bundleName, uid); @@ -714,6 +735,7 @@ HWTEST_F(AmsMgrSchedulerTest, KillApplicationByUid_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, KillApplicationSelf_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); amsMgrScheduler->KillApplicationSelf(); amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); amsMgrScheduler->amsHandler_ = GetAmsEventHandler(); @@ -731,6 +753,7 @@ HWTEST_F(AmsMgrSchedulerTest, KillApplicationSelf_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, GetRunningProcessInfoByToken_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); sptr token = nullptr; RunningProcessInfo info; amsMgrScheduler->GetRunningProcessInfoByToken(token, info); @@ -750,6 +773,7 @@ HWTEST_F(AmsMgrSchedulerTest, GetRunningProcessInfoByToken_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, GetRunningProcessInfoByPid_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); pid_t pid = 0; RunningProcessInfo info; amsMgrScheduler->GetRunningProcessInfoByPid(pid, info); @@ -768,7 +792,13 @@ HWTEST_F(AmsMgrSchedulerTest, GetRunningProcessInfoByPid_001, TestSize.Level0) */ HWTEST_F(AmsMgrSchedulerTest, StartSpecifiedAbility_001, TestSize.Level0) { - auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + auto mockBundleMgr = new (std::nothrow) BundleMgrService(); + auto remoteClientManager = std::make_shared(); + remoteClientManager->SetBundleManager(mockBundleMgr); + auto amsMgrServiceInner = std::make_shared(); + amsMgrServiceInner->remoteClientManager_ = remoteClientManager; + auto amsMgrScheduler = std::make_unique(amsMgrServiceInner, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); Want want; AbilityInfo abilityInfo; amsMgrScheduler->StartSpecifiedAbility(want, abilityInfo); @@ -788,6 +818,7 @@ HWTEST_F(AmsMgrSchedulerTest, StartSpecifiedAbility_001, TestSize.Level0) HWTEST_F(AmsMgrSchedulerTest, RegisterStartSpecifiedAbilityResponse_001, TestSize.Level0) { auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); sptr response = nullptr; amsMgrScheduler->RegisterStartSpecifiedAbilityResponse(response); amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index 703964582b..32e0ff5828 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -59,6 +59,7 @@ void AppMgrServiceTest::TearDown() HWTEST_F(AppMgrServiceTest, OnStop_001, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); appMgrService->appMgrServiceInner_ = nullptr; appMgrService->OnStop(); } @@ -107,6 +108,7 @@ HWTEST_F(AppMgrServiceTest, Init_001, TestSize.Level0) HWTEST_F(AppMgrServiceTest, AttachApplication_001, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); sptr app = nullptr; appMgrService->SetInnerService(nullptr); appMgrService->AttachApplication(app); @@ -123,6 +125,7 @@ HWTEST_F(AppMgrServiceTest, AttachApplication_001, TestSize.Level0) HWTEST_F(AppMgrServiceTest, AttachApplication_002, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); sptr app = nullptr; appMgrService->SetInnerService(std::make_shared()); appMgrService->handler_ = std::make_shared(runner_, appMgrService->appMgrServiceInner_); @@ -140,6 +143,7 @@ HWTEST_F(AppMgrServiceTest, AttachApplication_002, TestSize.Level0) HWTEST_F(AppMgrServiceTest, ApplicationForegrounded_001, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); int32_t recordId = 1; appMgrService->SetInnerService(nullptr); appMgrService->ApplicationForegrounded(recordId); @@ -156,6 +160,7 @@ HWTEST_F(AppMgrServiceTest, ApplicationForegrounded_001, TestSize.Level0) HWTEST_F(AppMgrServiceTest, ApplicationBackgrounded_001, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); int32_t recordId = 1; appMgrService->SetInnerService(nullptr); appMgrService->ApplicationBackgrounded(recordId); @@ -172,6 +177,7 @@ HWTEST_F(AppMgrServiceTest, ApplicationBackgrounded_001, TestSize.Level0) HWTEST_F(AppMgrServiceTest, ApplicationTerminated_001, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); int32_t recordId = 1; appMgrService->SetInnerService(nullptr); appMgrService->ApplicationTerminated(recordId); @@ -188,6 +194,7 @@ HWTEST_F(AppMgrServiceTest, ApplicationTerminated_001, TestSize.Level0) HWTEST_F(AppMgrServiceTest, AbilityCleaned_001, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); appMgrService->SetInnerService(nullptr); appMgrService->AbilityCleaned(nullptr); } @@ -203,6 +210,7 @@ HWTEST_F(AppMgrServiceTest, AbilityCleaned_001, TestSize.Level0) HWTEST_F(AppMgrServiceTest, AbilityCleaned_002, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); appMgrService->SetInnerService(std::make_shared()); appMgrService->handler_ = std::make_shared(runner_, appMgrService->appMgrServiceInner_); appMgrService->AbilityCleaned(nullptr); @@ -219,6 +227,7 @@ HWTEST_F(AppMgrServiceTest, AbilityCleaned_002, TestSize.Level0) HWTEST_F(AppMgrServiceTest, AddAppDeathRecipient_001, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); pid_t pid = 1; appMgrService->SetInnerService(nullptr); appMgrService->AddAppDeathRecipient(pid); @@ -235,6 +244,7 @@ HWTEST_F(AppMgrServiceTest, AddAppDeathRecipient_001, TestSize.Level0) HWTEST_F(AppMgrServiceTest, AddAppDeathRecipient_002, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); pid_t pid = 1; appMgrService->SetInnerService(std::make_shared()); appMgrService->handler_ = std::make_shared(runner_, appMgrService->appMgrServiceInner_); @@ -252,6 +262,7 @@ HWTEST_F(AppMgrServiceTest, AddAppDeathRecipient_002, TestSize.Level0) HWTEST_F(AppMgrServiceTest, StartupResidentProcess_001, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); std::vector bundleInfos; appMgrService->SetInnerService(nullptr); appMgrService->StartupResidentProcess(bundleInfos); @@ -268,6 +279,7 @@ HWTEST_F(AppMgrServiceTest, StartupResidentProcess_001, TestSize.Level0) HWTEST_F(AppMgrServiceTest, StartupResidentProcess_002, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); std::vector bundleInfos; appMgrService->SetInnerService(std::make_shared()); appMgrService->handler_ = std::make_shared(runner_, appMgrService->appMgrServiceInner_); @@ -391,6 +403,7 @@ HWTEST_F(AppMgrServiceTest, NotifyMemoryLevel_002, TestSize.Level0) HWTEST_F(AppMgrServiceTest, AddAbilityStageDone_001, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); int32_t recordId = 1; appMgrService->SetInnerService(nullptr); appMgrService->AddAbilityStageDone(recordId); @@ -407,6 +420,7 @@ HWTEST_F(AppMgrServiceTest, AddAbilityStageDone_001, TestSize.Level0) HWTEST_F(AppMgrServiceTest, AddAbilityStageDone_002, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); int32_t recordId = 1; appMgrService->SetInnerService(std::make_shared()); appMgrService->handler_ = std::make_shared(runner_, appMgrService->appMgrServiceInner_); @@ -575,6 +589,7 @@ HWTEST_F(AppMgrServiceTest, FinishUserTest_002, TestSize.Level0) HWTEST_F(AppMgrServiceTest, ScheduleAcceptWantDone_001, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); int32_t recordId = 1; Want want; std::string flag = "flag"; @@ -593,6 +608,7 @@ HWTEST_F(AppMgrServiceTest, ScheduleAcceptWantDone_001, TestSize.Level0) HWTEST_F(AppMgrServiceTest, ScheduleAcceptWantDone_002, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); int32_t recordId = 1; Want want; std::string flag = "flag"; @@ -724,6 +740,7 @@ HWTEST_F(AppMgrServiceTest, StartRenderProcess_002, TestSize.Level0) HWTEST_F(AppMgrServiceTest, AttachRenderProcess_001, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); sptr scheduler = nullptr; appMgrService->SetInnerService(nullptr); appMgrService->AttachRenderProcess(scheduler); @@ -740,6 +757,7 @@ HWTEST_F(AppMgrServiceTest, AttachRenderProcess_001, TestSize.Level0) HWTEST_F(AppMgrServiceTest, AttachRenderProcess_002, TestSize.Level0) { auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); sptr scheduler = nullptr; appMgrService->SetInnerService(std::make_shared()); appMgrService->handler_ = std::make_shared(runner_, appMgrService->appMgrServiceInner_); diff --git a/test/unittest/app_scheduler_test/app_scheduler_test.cpp b/test/unittest/app_scheduler_test/app_scheduler_test.cpp index 475dfc2664..52e16872a8 100644 --- a/test/unittest/app_scheduler_test/app_scheduler_test.cpp +++ b/test/unittest/app_scheduler_test/app_scheduler_test.cpp @@ -337,6 +337,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_008, TestSize.Level1) auto abilityReq = GenerateAbilityRequest(deviceName, abilityName, appName, bundleName); auto record = AbilityRecord::CreateAbilityRecord(abilityReq); auto token = record->GetToken(); + ASSERT_NE(token, nullptr); DelayedSingleton::GetInstance()->MoveToForeground(token); } @@ -360,6 +361,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_009, TestSize.Level1) auto abilityReq = GenerateAbilityRequest(deviceName, abilityName, appName, bundleName); auto record = AbilityRecord::CreateAbilityRecord(abilityReq); auto token = record->GetToken(); + ASSERT_NE(token, nullptr); DelayedSingleton::GetInstance()->MoveToForeground(token); } @@ -383,6 +385,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_010, TestSize.Level1) auto abilityReq = GenerateAbilityRequest(deviceName, abilityName, appName, bundleName); auto record = AbilityRecord::CreateAbilityRecord(abilityReq); auto token = record->GetToken(); + ASSERT_NE(token, nullptr); DelayedSingleton::GetInstance()->MoveToBackground(token); } @@ -467,6 +470,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_014, TestSize.Level1) auto abilityReq = GenerateAbilityRequest(deviceName, abilityName, appName, bundleName); auto record = AbilityRecord::CreateAbilityRecord(abilityReq); auto token = record->GetToken(); + ASSERT_NE(token, nullptr); const int32_t visibility = 1; const int32_t perceptibility = 1; const int32_t connectionState = 1; @@ -510,6 +514,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_015, TestSize.Level1) auto abilityReq = GenerateAbilityRequest(deviceName, abilityName, appName, bundleName); auto record = AbilityRecord::CreateAbilityRecord(abilityReq); auto token = record->GetToken(); + ASSERT_NE(token, nullptr); const int32_t visibility = 0; const int32_t perceptibility = 1; const int32_t connectionState = 1; @@ -537,6 +542,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_016, TestSize.Level1) auto abilityReq = GenerateAbilityRequest(deviceName, abilityName, appName, bundleName); auto record = AbilityRecord::CreateAbilityRecord(abilityReq); auto token = record->GetToken(); + ASSERT_NE(token, nullptr); DelayedSingleton::GetInstance()->KillProcessByAbilityToken(token); } @@ -560,6 +566,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_017, TestSize.Level1) auto abilityReq = GenerateAbilityRequest(deviceName, abilityName, appName, bundleName); auto record = AbilityRecord::CreateAbilityRecord(abilityReq); auto token = record->GetToken(); + ASSERT_NE(token, nullptr); DelayedSingleton::GetInstance()->KillProcessByAbilityToken(token); } @@ -575,6 +582,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_017, TestSize.Level1) HWTEST_F(AppSchedulerTest, AppScheduler_UpdateAbilityState_001, TestSize.Level1) { DelayedSingleton::GetInstance()->appMgrClient_ = std::make_unique(); + ASSERT_NE(DelayedSingleton::GetInstance()->appMgrClient_, nullptr); sptr token = nullptr; AppExecFwk::AbilityState state = AppExecFwk::AbilityState::ABILITY_STATE_CREATE; DelayedSingleton::GetInstance()->UpdateAbilityState(token, state); @@ -593,6 +601,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_UpdateExtensionState_001, TestSize.Level EXPECT_CALL(*clientMock_, UpdateExtensionState(_, _)).Times(1) .WillOnce(Return(AppMgrResultCode::RESULT_OK)); DelayedSingleton::GetInstance()->appMgrClient_ = std::move(clientMock_); + ASSERT_NE(DelayedSingleton::GetInstance()->appMgrClient_, nullptr); sptr token = nullptr; AppExecFwk::ExtensionState state = AppExecFwk::ExtensionState::EXTENSION_STATE_READY; DelayedSingleton::GetInstance()->UpdateExtensionState(token, state); @@ -609,6 +618,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_UpdateExtensionState_001, TestSize.Level HWTEST_F(AppSchedulerTest, AppScheduler_KillProcessesByUserId_001, TestSize.Level1) { DelayedSingleton::GetInstance()->appMgrClient_ = std::make_unique(); + ASSERT_NE(DelayedSingleton::GetInstance()->appMgrClient_, nullptr); int32_t userId = 0; DelayedSingleton::GetInstance()->KillProcessesByUserId(userId); } @@ -625,6 +635,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_OnAbilityRequestDone_001, TestSize.Level { sptr token = nullptr; AppExecFwk::AbilityState state = AppExecFwk::AbilityState::ABILITY_STATE_CREATE; + ASSERT_NE(appStateMock_, nullptr); DelayedSingleton::GetInstance()->callback_ = appStateMock_; DelayedSingleton::GetInstance()->OnAbilityRequestDone(token, state); } @@ -751,6 +762,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_PrepareTerminate_001, TestSize.Level1) { sptr token = nullptr; DelayedSingleton::GetInstance()->appMgrClient_ = std::make_unique(); + ASSERT_NE(DelayedSingleton::GetInstance()->appMgrClient_, nullptr); DelayedSingleton::GetInstance()->PrepareTerminate(token); } @@ -765,6 +777,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_PrepareTerminate_001, TestSize.Level1) HWTEST_F(AppSchedulerTest, AppScheduler_OnAppStateChanged_001, TestSize.Level1) { AppExecFwk::AppProcessData appData; + ASSERT_NE(DelayedSingleton::GetInstance(), nullptr); DelayedSingleton::GetInstance()->OnAppStateChanged(appData); } @@ -780,6 +793,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_GetRunningProcessInfoByToken_001, TestSi { sptr token; AppExecFwk::RunningProcessInfo info; + ASSERT_NE(DelayedSingleton::GetInstance(), nullptr); DelayedSingleton::GetInstance()->GetRunningProcessInfoByToken(token, info); } @@ -795,6 +809,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_GetRunningProcessInfoByPid_001, TestSize { pid_t pid = 0; AppExecFwk::RunningProcessInfo info; + ASSERT_NE(DelayedSingleton::GetInstance(), nullptr); DelayedSingleton::GetInstance()->GetRunningProcessInfoByPid(pid, info); } @@ -810,6 +825,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_StartupResidentProcess_001, TestSize.Lev { EXPECT_CALL(*clientMock_, StartupResidentProcess(_)).Times(1); DelayedSingleton::GetInstance()->appMgrClient_ = std::move(clientMock_); + ASSERT_NE(DelayedSingleton::GetInstance()->appMgrClient_, nullptr); std::vector bundleInfos; DelayedSingleton::GetInstance()->StartupResidentProcess(bundleInfos); } @@ -826,6 +842,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_StartSpecifiedAbility_001, TestSize.Leve { EXPECT_CALL(*clientMock_, StartSpecifiedAbility(_, _)).Times(1); DelayedSingleton::GetInstance()->appMgrClient_ = std::move(clientMock_); + ASSERT_NE(DelayedSingleton::GetInstance()->appMgrClient_, nullptr); AAFwk::Want want; AppExecFwk::AbilityInfo abilityInfo; DelayedSingleton::GetInstance()->StartSpecifiedAbility(want, abilityInfo); @@ -843,6 +860,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_GetProcessRunningInfos_001, TestSize.Lev { EXPECT_CALL(*clientMock_, GetAllRunningProcesses(_)).Times(1); DelayedSingleton::GetInstance()->appMgrClient_ = std::move(clientMock_); + ASSERT_NE(DelayedSingleton::GetInstance()->appMgrClient_, nullptr); std::vector info; DelayedSingleton::GetInstance()->GetProcessRunningInfos(info); } @@ -859,6 +877,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_GetProcessRunningInfosByUserId_001, Test { EXPECT_CALL(*clientMock_, GetProcessRunningInfosByUserId(_, _)).Times(1); DelayedSingleton::GetInstance()->appMgrClient_ = std::move(clientMock_); + ASSERT_NE(DelayedSingleton::GetInstance()->appMgrClient_, nullptr); std::vector info; int32_t userId = 0; DelayedSingleton::GetInstance()->GetProcessRunningInfosByUserId(info, userId); @@ -875,6 +894,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_GetProcessRunningInfosByUserId_001, Test HWTEST_F(AppSchedulerTest, AppScheduler_ConvertAppState_001, TestSize.Level1) { AppState state = AppState::BEGIN; + ASSERT_NE(DelayedSingleton::GetInstance(), nullptr); DelayedSingleton::GetInstance()->ConvertAppState(state); } diff --git a/test/unittest/app_state_observer_manager_test/app_state_observer_manager_test.cpp b/test/unittest/app_state_observer_manager_test/app_state_observer_manager_test.cpp index 7e619d4f26..5f2fa298fa 100644 --- a/test/unittest/app_state_observer_manager_test/app_state_observer_manager_test.cpp +++ b/test/unittest/app_state_observer_manager_test/app_state_observer_manager_test.cpp @@ -157,6 +157,7 @@ HWTEST_F(AppSpawnSocketTest, UnregisterApplicationStateObserver_001, TestSize.Le HWTEST_F(AppSpawnSocketTest, OnAppStateChanged_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::shared_ptr appRecord; ApplicationState state = ApplicationState::APP_STATE_CREATE; bool needNotifyApp = false; @@ -174,6 +175,7 @@ HWTEST_F(AppSpawnSocketTest, OnAppStateChanged_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, OnAppStateChanged_002, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::shared_ptr appRecord; ApplicationState state = ApplicationState::APP_STATE_CREATE; bool needNotifyApp = false; @@ -192,6 +194,7 @@ HWTEST_F(AppSpawnSocketTest, OnAppStateChanged_002, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, OnProcessDied_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::shared_ptr appRecord; manager->OnProcessDied(appRecord); manager->Init(); @@ -209,6 +212,7 @@ HWTEST_F(AppSpawnSocketTest, OnProcessDied_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, OnRenderProcessDied_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::shared_ptr renderRecord; manager->OnRenderProcessDied(renderRecord); manager->Init(); @@ -226,6 +230,7 @@ HWTEST_F(AppSpawnSocketTest, OnRenderProcessDied_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, OnProcessStateChanged_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::shared_ptr appRecord; manager->OnProcessStateChanged(appRecord); manager->Init(); @@ -243,6 +248,7 @@ HWTEST_F(AppSpawnSocketTest, OnProcessStateChanged_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, OnProcessCreated_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::shared_ptr appRecord; manager->OnProcessCreated(appRecord); manager->Init(); @@ -260,6 +266,7 @@ HWTEST_F(AppSpawnSocketTest, OnProcessCreated_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, OnRenderProcessCreated_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::shared_ptr renderRecord; manager->OnRenderProcessCreated(renderRecord); manager->Init(); @@ -277,6 +284,7 @@ HWTEST_F(AppSpawnSocketTest, OnRenderProcessCreated_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, StateChangedNotifyObserver_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); AbilityStateData abilityStateData; bool isAbility = false; manager->StateChangedNotifyObserver(abilityStateData, isAbility); @@ -295,6 +303,7 @@ HWTEST_F(AppSpawnSocketTest, StateChangedNotifyObserver_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::vector bundleNameList; std::shared_ptr appRecord = MockAppRecord(); ApplicationState state = ApplicationState::APP_STATE_FOREGROUND; @@ -317,6 +326,7 @@ HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_002, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::vector bundleNameList; std::shared_ptr appRecord = MockAppRecord(); ApplicationState state = ApplicationState::APP_STATE_BACKGROUND; @@ -339,6 +349,7 @@ HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_002, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_003, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::vector bundleNameList; std::shared_ptr appRecord = MockAppRecord(); ApplicationState state = ApplicationState::APP_STATE_BACKGROUND; @@ -360,6 +371,7 @@ HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_003, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_004, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::vector bundleNameList; std::shared_ptr appRecord = MockAppRecord(); ApplicationState state = ApplicationState::APP_STATE_CREATE; @@ -381,6 +393,7 @@ HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_004, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_005, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::vector bundleNameList; std::shared_ptr appRecord = MockAppRecord(); ApplicationState state = ApplicationState::APP_STATE_TERMINATED; @@ -403,6 +416,7 @@ HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_005, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_006, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::vector bundleNameList; std::shared_ptr appRecord = MockAppRecord(); ApplicationState state = ApplicationState::APP_STATE_CREATE; @@ -426,6 +440,7 @@ HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_006, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_007, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::vector bundleNameList; std::shared_ptr appRecord = MockAppRecord(); ApplicationState state = ApplicationState::APP_STATE_CREATE; @@ -447,6 +462,7 @@ HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_007, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_008, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::vector bundleNameList; std::shared_ptr appRecord = MockAppRecord(); ApplicationState state = ApplicationState::APP_STATE_END; @@ -465,6 +481,7 @@ HWTEST_F(AppSpawnSocketTest, HandleAppStateChanged_008, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleStateChangedNotifyObserver_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); AbilityStateData abilityStateData; bool isAbility = true; std::vector bundleNameList; @@ -486,6 +503,7 @@ HWTEST_F(AppSpawnSocketTest, HandleStateChangedNotifyObserver_001, TestSize.Leve HWTEST_F(AppSpawnSocketTest, HandleStateChangedNotifyObserver_002, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); AbilityStateData abilityStateData; bool isAbility = false; std::vector bundleNameList; @@ -506,6 +524,7 @@ HWTEST_F(AppSpawnSocketTest, HandleStateChangedNotifyObserver_002, TestSize.Leve HWTEST_F(AppSpawnSocketTest, HandleStateChangedNotifyObserver_003, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); AbilityStateData abilityStateData; bool isAbility = false; std::vector bundleNameList; @@ -528,6 +547,7 @@ HWTEST_F(AppSpawnSocketTest, HandleStateChangedNotifyObserver_003, TestSize.Leve HWTEST_F(AppSpawnSocketTest, HandleStateChangedNotifyObserver_004, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); AbilityStateData abilityStateData; bool isAbility = false; std::vector bundleNameList; @@ -549,6 +569,7 @@ HWTEST_F(AppSpawnSocketTest, HandleStateChangedNotifyObserver_004, TestSize.Leve HWTEST_F(AppSpawnSocketTest, HandleOnAppProcessCreated_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); manager->HandleOnAppProcessCreated(nullptr); std::shared_ptr appRecord = MockAppRecord(); manager->HandleOnAppProcessCreated(appRecord); @@ -565,6 +586,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnAppProcessCreated_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnRenderProcessCreated_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); manager->HandleOnRenderProcessCreated(nullptr); std::shared_ptr appRecord = MockAppRecord(); std::shared_ptr renderRecord = @@ -584,6 +606,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnRenderProcessCreated_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnProcessCreated_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); ProcessData data; std::vector bundleNameList; std::string bundleName = "com.ohos.unittest"; @@ -603,6 +626,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnProcessCreated_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnProcessCreated_002, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); ProcessData data; std::vector bundleNameList; std::string bundleName = "com.ohos.unittest"; @@ -623,6 +647,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnProcessCreated_002, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnProcessCreated_003, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); ProcessData data; std::vector bundleNameList; std::string bundleName1 = "com.ohos.unittest"; @@ -644,6 +669,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnProcessCreated_003, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnProcessCreated_004, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); ProcessData data; std::vector bundleNameList; std::string bundleName = "com.ohos.unittest"; @@ -664,6 +690,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnProcessCreated_004, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnProcessStateChanged_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); manager->HandleOnProcessStateChanged(nullptr); } @@ -678,6 +705,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnProcessStateChanged_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnProcessStateChanged_002, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::shared_ptr appRecord = MockAppRecord(); std::vector bundleNameList; std::string bundleName = "com.ohos.unittest"; @@ -698,6 +726,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnProcessStateChanged_002, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnProcessStateChanged_003, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::shared_ptr appRecord = MockAppRecord(); std::vector bundleNameList; std::string bundleName = "com.ohos.unittest"; @@ -717,6 +746,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnProcessStateChanged_003, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnProcessStateChanged_004, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::shared_ptr appRecord = MockAppRecord(); std::vector bundleNameList; std::string bundleName1 = "com.ohos.unittest1"; @@ -738,6 +768,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnProcessStateChanged_004, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnProcessStateChanged_005, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::shared_ptr appRecord = MockAppRecord(); std::vector bundleNameList; std::string bundleName = "com.ohos.unittest"; @@ -758,6 +789,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnProcessStateChanged_005, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnAppProcessDied_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::shared_ptr appRecord = MockAppRecord(); manager->HandleOnAppProcessDied(nullptr); manager->HandleOnAppProcessDied(appRecord); @@ -774,6 +806,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnAppProcessDied_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnRenderProcessDied_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); std::shared_ptr appRecord = MockAppRecord(); std::shared_ptr renderRecord = std::make_shared(1, "param", 1, 1, 1, appRecord); @@ -793,6 +826,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnRenderProcessDied_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnProcessDied_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); ProcessData data; std::vector bundleNameList; std::string bundleName = "com.ohos.unittest"; @@ -812,6 +846,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnProcessDied_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnProcessDied_002, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); ProcessData data; std::vector bundleNameList; std::string bundleName = "com.ohos.unittest"; @@ -832,6 +867,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnProcessDied_002, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnProcessDied_003, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); ProcessData data; std::vector bundleNameList; std::string bundleName1 = "com.ohos.unittest1"; @@ -853,6 +889,7 @@ HWTEST_F(AppSpawnSocketTest, HandleOnProcessDied_003, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, HandleOnProcessDied_004, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); ProcessData data; std::vector bundleNameList; std::string bundleName1 = "com.ohos.unittest1"; @@ -907,6 +944,7 @@ HWTEST_F(AppSpawnSocketTest, ObserverExist_002, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, AddObserverDeathRecipient_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); manager->AddObserverDeathRecipient(nullptr); manager->AddObserverDeathRecipient(observer_); } @@ -922,6 +960,7 @@ HWTEST_F(AppSpawnSocketTest, AddObserverDeathRecipient_001, TestSize.Level0) HWTEST_F(AppSpawnSocketTest, RemoveObserverDeathRecipient_001, TestSize.Level0) { auto manager = std::make_shared(); + ASSERT_NE(manager, nullptr); manager->RemoveObserverDeathRecipient(nullptr); manager->AddObserverDeathRecipient(observer_); } diff --git a/test/unittest/appkit/main_thread_test/main_thread_test.cpp b/test/unittest/appkit/main_thread_test/main_thread_test.cpp index 3ee481f295..6082d936e3 100644 --- a/test/unittest/appkit/main_thread_test/main_thread_test.cpp +++ b/test/unittest/appkit/main_thread_test/main_thread_test.cpp @@ -720,6 +720,7 @@ HWTEST_F(MainThreadTest, CheckAbilityItem_0300, TestSize.Level1) HWTEST_F(MainThreadTest, HandleTerminateApplicationLocal_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->application_ = nullptr; mainThread_->HandleTerminateApplicationLocal(); HILOG_INFO("%{public}s end.", __func__); @@ -734,6 +735,7 @@ HWTEST_F(MainThreadTest, HandleTerminateApplicationLocal_0100, TestSize.Level1) HWTEST_F(MainThreadTest, HandleTerminateApplicationLocal_0200, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->signalHandler_->SetEventRunner(nullptr); mainThread_->HandleTerminateApplicationLocal(); HILOG_INFO("%{public}s end.", __func__); @@ -748,6 +750,7 @@ HWTEST_F(MainThreadTest, HandleTerminateApplicationLocal_0200, TestSize.Level1) HWTEST_F(MainThreadTest, HandleTerminateApplicationLocal_0300, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->mainHandler_->SetEventRunner(nullptr); mainThread_->HandleTerminateApplicationLocal(); HILOG_INFO("%{public}s end.", __func__); @@ -762,6 +765,7 @@ HWTEST_F(MainThreadTest, HandleTerminateApplicationLocal_0300, TestSize.Level1) HWTEST_F(MainThreadTest, HandleTerminateApplicationLocal_0400, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->watchdog_ = nullptr; mainThread_->HandleTerminateApplicationLocal(); HILOG_INFO("%{public}s end.", __func__); @@ -776,6 +780,7 @@ HWTEST_F(MainThreadTest, HandleTerminateApplicationLocal_0400, TestSize.Level1) HWTEST_F(MainThreadTest, HandleProcessSecurityExit_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->abilityRecordMgr_ = nullptr; mainThread_->HandleProcessSecurityExit(); @@ -797,6 +802,7 @@ HWTEST_F(MainThreadTest, HandleProcessSecurityExit_0100, TestSize.Level1) HWTEST_F(MainThreadTest, HandleProcessSecurityExit_0200, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->HandleProcessSecurityExit(); HILOG_INFO("%{public}s end.", __func__); } @@ -869,6 +875,7 @@ HWTEST_F(MainThreadTest, CheckForHandleLaunchApplication_0300, TestSize.Level1) HWTEST_F(MainThreadTest, HandleAbilityStage_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); HapModuleInfo info; mainThread_->HandleAbilityStage(info); HILOG_INFO("%{public}s end.", __func__); @@ -883,6 +890,7 @@ HWTEST_F(MainThreadTest, HandleAbilityStage_0100, TestSize.Level1) HWTEST_F(MainThreadTest, HandleAbilityStage_0200, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->application_ = nullptr; HapModuleInfo info; mainThread_->HandleAbilityStage(info); @@ -898,6 +906,7 @@ HWTEST_F(MainThreadTest, HandleAbilityStage_0200, TestSize.Level1) HWTEST_F(MainThreadTest, HandleAbilityStage_0300, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->appMgr_ = nullptr; HapModuleInfo info; mainThread_->HandleAbilityStage(info); @@ -913,6 +922,7 @@ HWTEST_F(MainThreadTest, HandleAbilityStage_0300, TestSize.Level1) HWTEST_F(MainThreadTest, HandleAbilityStage_0400, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->applicationImpl_ = nullptr; HapModuleInfo info; mainThread_->HandleAbilityStage(info); @@ -997,6 +1007,7 @@ HWTEST_F(MainThreadTest, HandleLaunchAbility_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); std::shared_ptr abilityRecord = std::make_shared(nullptr, nullptr); + ASSERT_NE(abilityRecord, nullptr); mainThread_->HandleLaunchAbility(abilityRecord); HILOG_INFO("%{public}s end.", __func__); } @@ -1010,6 +1021,7 @@ HWTEST_F(MainThreadTest, HandleLaunchAbility_0100, TestSize.Level1) HWTEST_F(MainThreadTest, HandleCleanAbilityLocal_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->application_ = nullptr; mainThread_->HandleCleanAbilityLocal(nullptr); HILOG_INFO("%{public}s end.", __func__); @@ -1024,6 +1036,7 @@ HWTEST_F(MainThreadTest, HandleCleanAbilityLocal_0100, TestSize.Level1) HWTEST_F(MainThreadTest, HandleCleanAbilityLocal_0200, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->HandleCleanAbilityLocal(nullptr); HILOG_INFO("%{public}s end.", __func__); } @@ -1037,6 +1050,7 @@ HWTEST_F(MainThreadTest, HandleCleanAbilityLocal_0200, TestSize.Level1) HWTEST_F(MainThreadTest, HandleForegroundApplication_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->HandleForegroundApplication(); HILOG_INFO("%{public}s end.", __func__); } @@ -1050,6 +1064,7 @@ HWTEST_F(MainThreadTest, HandleForegroundApplication_0100, TestSize.Level1) HWTEST_F(MainThreadTest, HandleForegroundApplication_0200, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->application_ = nullptr; mainThread_->HandleForegroundApplication(); HILOG_INFO("%{public}s end.", __func__); @@ -1064,6 +1079,7 @@ HWTEST_F(MainThreadTest, HandleForegroundApplication_0200, TestSize.Level1) HWTEST_F(MainThreadTest, HandleForegroundApplication_0300, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->appMgr_ = nullptr; mainThread_->HandleForegroundApplication(); HILOG_INFO("%{public}s end.", __func__); @@ -1078,6 +1094,7 @@ HWTEST_F(MainThreadTest, HandleForegroundApplication_0300, TestSize.Level1) HWTEST_F(MainThreadTest, HandleBackgroundApplication_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->HandleBackgroundApplication(); HILOG_INFO("%{public}s end.", __func__); } @@ -1091,6 +1108,7 @@ HWTEST_F(MainThreadTest, HandleBackgroundApplication_0100, TestSize.Level1) HWTEST_F(MainThreadTest, HandleBackgroundApplication_0200, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->application_ = nullptr; mainThread_->HandleBackgroundApplication(); HILOG_INFO("%{public}s end.", __func__); @@ -1105,6 +1123,7 @@ HWTEST_F(MainThreadTest, HandleBackgroundApplication_0200, TestSize.Level1) HWTEST_F(MainThreadTest, HandleBackgroundApplication_0300, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->appMgr_ = nullptr; mainThread_->HandleBackgroundApplication(); HILOG_INFO("%{public}s end.", __func__); @@ -1119,6 +1138,7 @@ HWTEST_F(MainThreadTest, HandleBackgroundApplication_0300, TestSize.Level1) HWTEST_F(MainThreadTest, HandleTerminateApplication_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->HandleTerminateApplication(); HILOG_INFO("%{public}s end.", __func__); } @@ -1132,6 +1152,7 @@ HWTEST_F(MainThreadTest, HandleTerminateApplication_0100, TestSize.Level1) HWTEST_F(MainThreadTest, HandleTerminateApplication_0200, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->application_ = nullptr; mainThread_->HandleTerminateApplication(); HILOG_INFO("%{public}s end.", __func__); @@ -1146,6 +1167,7 @@ HWTEST_F(MainThreadTest, HandleTerminateApplication_0200, TestSize.Level1) HWTEST_F(MainThreadTest, HandleTerminateApplication_0300, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->appMgr_ = nullptr; mainThread_->HandleTerminateApplication(); HILOG_INFO("%{public}s end.", __func__); @@ -1160,6 +1182,7 @@ HWTEST_F(MainThreadTest, HandleTerminateApplication_0300, TestSize.Level1) HWTEST_F(MainThreadTest, HandleTerminateApplication_0400, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->signalHandler_->SetEventRunner(nullptr); mainThread_->HandleTerminateApplication(); HILOG_INFO("%{public}s end.", __func__); @@ -1174,6 +1197,7 @@ HWTEST_F(MainThreadTest, HandleTerminateApplication_0400, TestSize.Level1) HWTEST_F(MainThreadTest, HandleTerminateApplication_0500, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->mainHandler_->SetEventRunner(nullptr); mainThread_->HandleTerminateApplication(); HILOG_INFO("%{public}s end.", __func__); @@ -1188,6 +1212,7 @@ HWTEST_F(MainThreadTest, HandleTerminateApplication_0500, TestSize.Level1) HWTEST_F(MainThreadTest, HandleTerminateApplication_0600, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->watchdog_ = nullptr; mainThread_->HandleTerminateApplication(); HILOG_INFO("%{public}s end.", __func__); @@ -1202,6 +1227,7 @@ HWTEST_F(MainThreadTest, HandleTerminateApplication_0600, TestSize.Level1) HWTEST_F(MainThreadTest, HandleShrinkMemory_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->HandleShrinkMemory(1); HILOG_INFO("%{public}s end.", __func__); } @@ -1215,6 +1241,7 @@ HWTEST_F(MainThreadTest, HandleShrinkMemory_0100, TestSize.Level1) HWTEST_F(MainThreadTest, HandleShrinkMemory_0200, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->applicationImpl_ = nullptr; mainThread_->HandleShrinkMemory(1); HILOG_INFO("%{public}s end.", __func__); @@ -1229,6 +1256,7 @@ HWTEST_F(MainThreadTest, HandleShrinkMemory_0200, TestSize.Level1) HWTEST_F(MainThreadTest, HandleMemoryLevel_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->HandleMemoryLevel(1); HILOG_INFO("%{public}s end.", __func__); } @@ -1242,6 +1270,7 @@ HWTEST_F(MainThreadTest, HandleMemoryLevel_0100, TestSize.Level1) HWTEST_F(MainThreadTest, HandleMemoryLevel_0200, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->application_ = nullptr; mainThread_->HandleMemoryLevel(1); HILOG_INFO("%{public}s end.", __func__); @@ -1256,6 +1285,7 @@ HWTEST_F(MainThreadTest, HandleMemoryLevel_0200, TestSize.Level1) HWTEST_F(MainThreadTest, HandleConfigurationUpdated_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); Configuration config; mainThread_->HandleConfigurationUpdated(config); HILOG_INFO("%{public}s end.", __func__); @@ -1270,6 +1300,7 @@ HWTEST_F(MainThreadTest, HandleConfigurationUpdated_0100, TestSize.Level1) HWTEST_F(MainThreadTest, HandleConfigurationUpdated_0200, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->applicationImpl_ = nullptr; Configuration config; mainThread_->HandleConfigurationUpdated(config); @@ -1285,6 +1316,7 @@ HWTEST_F(MainThreadTest, HandleConfigurationUpdated_0200, TestSize.Level1) HWTEST_F(MainThreadTest, HandleSignal_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); constexpr int SIGNAL_JS_HEAP = 39; mainThread_->HandleSignal(SIGNAL_JS_HEAP); HILOG_INFO("%{public}s end.", __func__); @@ -1299,6 +1331,7 @@ HWTEST_F(MainThreadTest, HandleSignal_0100, TestSize.Level1) HWTEST_F(MainThreadTest, HandleSignal_0200, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); constexpr int SIGNAL_JS_HEAP_PRIV = 40; mainThread_->HandleSignal(SIGNAL_JS_HEAP_PRIV); HILOG_INFO("%{public}s end.", __func__); @@ -1313,6 +1346,7 @@ HWTEST_F(MainThreadTest, HandleSignal_0200, TestSize.Level1) HWTEST_F(MainThreadTest, HandleSignal_0300, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->HandleSignal(-1); HILOG_INFO("%{public}s end.", __func__); } @@ -1418,6 +1452,7 @@ HWTEST_F(MainThreadTest, HandleScheduleAcceptWant_0100, TestSize.Level1) HILOG_INFO("%{public}s start.", __func__); Want want; std::string moduleName; + ASSERT_NE(mainThread_, nullptr); mainThread_->HandleScheduleAcceptWant(want, moduleName); HILOG_INFO("%{public}s end.", __func__); } @@ -1434,6 +1469,7 @@ HWTEST_F(MainThreadTest, HandleScheduleAcceptWant_0200, TestSize.Level1) mainThread_->application_ = nullptr; Want want; std::string moduleName; + ASSERT_NE(mainThread_, nullptr); mainThread_->HandleScheduleAcceptWant(want, moduleName); HILOG_INFO("%{public}s end.", __func__); } @@ -1450,6 +1486,7 @@ HWTEST_F(MainThreadTest, HandleScheduleAcceptWant_0300, TestSize.Level1) mainThread_->appMgr_ = nullptr; Want want; std::string moduleName; + ASSERT_NE(mainThread_, nullptr); mainThread_->HandleScheduleAcceptWant(want, moduleName); HILOG_INFO("%{public}s end.", __func__); } @@ -1466,6 +1503,7 @@ HWTEST_F(MainThreadTest, HandleScheduleAcceptWant_0400, TestSize.Level1) mainThread_->applicationImpl_ = nullptr; Want want; std::string moduleName; + ASSERT_NE(mainThread_, nullptr); mainThread_->HandleScheduleAcceptWant(want, moduleName); HILOG_INFO("%{public}s end.", __func__); } @@ -1483,6 +1521,7 @@ HWTEST_F(MainThreadTest, LoadNativeLiabrary_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); std::string nativeLibraryPath = ""; + ASSERT_NE(mainThread_, nullptr); mainThread_->LoadNativeLiabrary(nativeLibraryPath); nativeLibraryPath = "test/"; @@ -1502,6 +1541,7 @@ HWTEST_F(MainThreadTest, LoadNativeLiabrary_0100, TestSize.Level1) HWTEST_F(MainThreadTest, TaskTimeoutDetected_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); + ASSERT_NE(mainThread_, nullptr); mainThread_->TaskTimeoutDetected(nullptr); std::shared_ptr runner = EventRunner::GetMainEventRunner(); @@ -1524,6 +1564,7 @@ HWTEST_F(MainThreadTest, HandleDumpHeap_0100, TestSize.Level1) { HILOG_INFO("%{public}s start.", __func__); bool isPrivate = false; + ASSERT_NE(mainThread_, nullptr); mainThread_->HandleDumpHeap(isPrivate); mainThread_->mainHandler_ = nullptr; diff --git a/test/unittest/connection_observer_controller_test/connection_observer_controller_test.cpp b/test/unittest/connection_observer_controller_test/connection_observer_controller_test.cpp index 0fc0e866f1..30974d3832 100755 --- a/test/unittest/connection_observer_controller_test/connection_observer_controller_test.cpp +++ b/test/unittest/connection_observer_controller_test/connection_observer_controller_test.cpp @@ -69,6 +69,7 @@ HWTEST_F(ConnectionObserverControllerTest, AddObserver_001, TestSize.Level1) HWTEST_F(ConnectionObserverControllerTest, RemoveObserver_001, TestSize.Level1) { auto connectionObserverController = std::make_shared(); + ASSERT_NE(connectionObserverController, nullptr); sptr observer = nullptr; connectionObserverController->RemoveObserver(observer); } @@ -84,6 +85,7 @@ HWTEST_F(ConnectionObserverControllerTest, RemoveObserver_001, TestSize.Level1) HWTEST_F(ConnectionObserverControllerTest, NotifyExtensionConnected_001, TestSize.Level1) { auto connectionObserverController = std::make_shared(); + ASSERT_NE(connectionObserverController, nullptr); ConnectionData data; connectionObserverController->NotifyExtensionConnected(data); } @@ -99,6 +101,7 @@ HWTEST_F(ConnectionObserverControllerTest, NotifyExtensionConnected_001, TestSiz HWTEST_F(ConnectionObserverControllerTest, NotifyExtensionDisconnected_001, TestSize.Level1) { auto connectionObserverController = std::make_shared(); + ASSERT_NE(connectionObserverController, nullptr); ConnectionData data; connectionObserverController->NotifyExtensionDisconnected(data); } @@ -114,6 +117,7 @@ HWTEST_F(ConnectionObserverControllerTest, NotifyExtensionDisconnected_001, Test HWTEST_F(ConnectionObserverControllerTest, NotifyDlpAbilityOpened_001, TestSize.Level1) { auto connectionObserverController = std::make_shared(); + ASSERT_NE(connectionObserverController, nullptr); DlpStateData data; connectionObserverController->NotifyDlpAbilityOpened(data); } @@ -129,6 +133,7 @@ HWTEST_F(ConnectionObserverControllerTest, NotifyDlpAbilityOpened_001, TestSize. HWTEST_F(ConnectionObserverControllerTest, NotifyDlpAbilityClosed_001, TestSize.Level1) { auto connectionObserverController = std::make_shared(); + ASSERT_NE(connectionObserverController, nullptr); DlpStateData data; connectionObserverController->NotifyDlpAbilityClosed(data); } @@ -160,6 +165,7 @@ HWTEST_F(ConnectionObserverControllerTest, GetObservers_001, TestSize.Level1) HWTEST_F(ConnectionObserverControllerTest, HandleRemoteDied_001, TestSize.Level1) { auto connectionObserverController = std::make_shared(); + ASSERT_NE(connectionObserverController, nullptr); wptr remote; connectionObserverController->HandleRemoteDied(remote); } @@ -175,6 +181,7 @@ HWTEST_F(ConnectionObserverControllerTest, HandleRemoteDied_001, TestSize.Level1 HWTEST_F(ConnectionObserverControllerTest, OnRemoteDied_001, TestSize.Level1) { auto connectionObserverController = std::make_shared(); + ASSERT_NE(connectionObserverController, nullptr); ConnectionObserverController::ObserverDeathRecipient::ObserverDeathHandler handler; auto observerDeathRecipient = std::make_shared(handler); wptr remote; diff --git a/test/unittest/data_ability_manager_test/data_ability_manager_test.cpp b/test/unittest/data_ability_manager_test/data_ability_manager_test.cpp index bfc12fa352..607f66884b 100644 --- a/test/unittest/data_ability_manager_test/data_ability_manager_test.cpp +++ b/test/unittest/data_ability_manager_test/data_ability_manager_test.cpp @@ -756,6 +756,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_AbilityTransitionDone_ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_OnAbilityDied_001, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); AbilityRequest abilityRequest; abilityRequest.abilityInfo.type = AppExecFwk::AbilityType::DATA; abilityRequest.abilityInfo.bundleName = "bundleName"; @@ -778,6 +779,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_OnAbilityDied_001, Tes HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_OnAbilityDied_002, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); AbilityRequest abilityRequest; abilityRequest.abilityInfo.type = AppExecFwk::AbilityType::DATA; abilityRequest.abilityInfo.bundleName = "bundleName"; @@ -800,6 +802,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_OnAbilityDied_002, Tes HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_OnAbilityDied_003, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); AbilityRequest abilityRequest; abilityRequest.abilityInfo.type = AppExecFwk::AbilityType::PAGE; abilityRequest.abilityInfo.bundleName = "bundleName"; @@ -822,6 +825,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_OnAbilityDied_003, Tes HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_OnAppStateChanged_001, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); AppInfo info; std::string processName = "processName"; std::string appName = "appName"; @@ -1057,6 +1061,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_LoadLocked_002, TestSi HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpLocked_001, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); const char func[1] = ""; int line = 0; dataAbilityManager->dataAbilityRecordsLoaded_["a"] = nullptr; @@ -1075,6 +1080,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpLocked_001, TestSi HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpLocked_002, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); const char func[2] = "a"; int line = 0; AbilityRequest abilityRequest; @@ -1100,6 +1106,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpLocked_002, TestSi HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpLocked_003, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); const char func[2] = "a"; int line = -1; dataAbilityManager->dataAbilityRecordsLoaded_.clear(); @@ -1118,6 +1125,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpLocked_003, TestSi HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpState_001, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; std::string args = "args"; AbilityRequest abilityRequest; @@ -1144,6 +1152,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpState_001, TestSiz HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpState_002, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; std::string args = "args"; dataAbilityManager->dataAbilityRecordsLoaded_.clear(); @@ -1161,6 +1170,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpState_002, TestSiz HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpState_003, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; std::string args = ""; AbilityRequest abilityRequest; @@ -1186,6 +1196,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpState_003, TestSiz HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_001, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isClient = true; std::string args = "args"; @@ -1213,6 +1224,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_001, Test HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_002, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isClient = true; std::string args = "args"; @@ -1240,6 +1252,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_002, Test HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_003, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isClient = true; std::string args = "args"; @@ -1265,6 +1278,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_003, Test HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_004, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isClient = true; std::string args = "args"; @@ -1290,6 +1304,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_004, Test HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_005, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isClient = true; std::string args = "args"; @@ -1308,6 +1323,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_005, Test HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_006, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isClient = false; std::string args = "args"; @@ -1326,6 +1342,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_006, Test HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_007, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isClient = false; std::string args = "args"; @@ -1344,6 +1361,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_007, Test HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_008, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isClient = true; std::string args = ""; @@ -1371,6 +1389,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_008, Test HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_009, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isClient = true; std::string args = ""; @@ -1398,6 +1417,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_009, Test HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_010, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isClient = true; std::string args = ""; @@ -1423,6 +1443,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_010, Test HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_011, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isClient = true; std::string args = ""; @@ -1447,6 +1468,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_011, Test HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_012, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isClient = true; std::string args = ""; @@ -1465,6 +1487,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_012, Test HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_013, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isClient = false; std::string args = ""; @@ -1483,6 +1506,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_DumpSysState_013, Test HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_GetAbilityRunningInfos_001, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isPerm = true; dataAbilityManager->dataAbilityRecordsLoaded_["a"] = nullptr; @@ -1500,6 +1524,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_GetAbilityRunningInfos HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_GetAbilityRunningInfos_002, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isPerm = true; AbilityRequest abilityRequest; @@ -1523,6 +1548,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_GetAbilityRunningInfos HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_GetAbilityRunningInfos_003, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isPerm = false; AbilityRequest abilityRequest; @@ -1548,6 +1574,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_GetAbilityRunningInfos HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_GetAbilityRunningInfos_004, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; bool isPerm = false; AbilityRequest abilityRequest; @@ -1573,6 +1600,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_GetAbilityRunningInfos HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_RestartDataAbility_001, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); std::vector info; AbilityRequest abilityRequest; abilityRequest.abilityInfo.type = AppExecFwk::AbilityType::DATA; @@ -1593,6 +1621,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_RestartDataAbility_001 HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_ReportDataAbilityAcquired_001, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); bool isNotHap = true; AbilityRequest abilityRequest; abilityRequest.abilityInfo.type = AppExecFwk::AbilityType::DATA; @@ -1615,6 +1644,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_ReportDataAbilityAcqui HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_ReportDataAbilityAcquired_002, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); bool isNotHap = true; AbilityRequest abilityRequest; abilityRequest.abilityInfo.type = AppExecFwk::AbilityType::DATA; @@ -1635,6 +1665,7 @@ HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_ReportDataAbilityAcqui HWTEST_F(DataAbilityManagerTest, AaFwk_DataAbilityManager_ReportDataAbilityReleased_001, TestSize.Level1) { std::unique_ptr dataAbilityManager = std::make_unique(); + ASSERT_NE(dataAbilityManager, nullptr); bool isNotHap = true; AbilityRequest abilityRequest; abilityRequest.abilityInfo.type = AppExecFwk::AbilityType::DATA; diff --git a/test/unittest/dataobs_mgr_inner_test/dataobs_mgr_inner_test.cpp b/test/unittest/dataobs_mgr_inner_test/dataobs_mgr_inner_test.cpp index 8d5dbd94d8..d964dab037 100644 --- a/test/unittest/dataobs_mgr_inner_test/dataobs_mgr_inner_test.cpp +++ b/test/unittest/dataobs_mgr_inner_test/dataobs_mgr_inner_test.cpp @@ -326,6 +326,7 @@ HWTEST_F(DataObsMgrInnerTest, DataObsMgrInner_AddRemove_ObsDeathRecipient_0100, HWTEST_F(DataObsMgrInnerTest, DataObsMgrInner_RemoveObs_0100, TestSize.Level1) { std::shared_ptr dataObsMgrInner = std::make_shared(); + ASSERT_NE(dataObsMgrInner, nullptr); std::string uri1 = "uri1"; std::string uri2 = "uri2"; sptr observer(new (std::nothrow) MockDataAbilityObserverStub()); diff --git a/test/unittest/event_report_test/event_report_test.cpp b/test/unittest/event_report_test/event_report_test.cpp index 80531d1f9c..aeb6b2f088 100755 --- a/test/unittest/event_report_test/event_report_test.cpp +++ b/test/unittest/event_report_test/event_report_test.cpp @@ -14,7 +14,9 @@ */ #include +#define private public #include "event_report.h" +#undef private using namespace testing; using namespace testing::ext; @@ -47,6 +49,8 @@ void EventReportTest::TearDown() HWTEST_F(EventReportTest, SendAbilityEvent_0100, TestSize.Level0) { EventName eventName = EventName::ABILITY_ONACTIVE; + std::string name = "ABILITY_ONACTIVE"; + EXPECT_EQ(EventReport::ConvertEventName(eventName), name); HiSysEventType type = HiSysEventType::BEHAVIOR; EventInfo eventInfo; EventReport::SendAbilityEvent(eventName, type, eventInfo); @@ -61,6 +65,8 @@ HWTEST_F(EventReportTest, SendAbilityEvent_0100, TestSize.Level0) HWTEST_F(EventReportTest, SendAbilityEvent_0200, TestSize.Level0) { EventName eventName = EventName::ABILITY_ONINACTIVE; + std::string name = "ABILITY_ONINACTIVE"; + EXPECT_EQ(EventReport::ConvertEventName(eventName), name); HiSysEventType type = HiSysEventType::BEHAVIOR; EventInfo eventInfo; EventReport::SendAbilityEvent(eventName, type, eventInfo); diff --git a/test/unittest/frameworks_kits_ability_native_test/ability_context_interface1_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ability_context_interface1_test.cpp index 5ad21fd6f6..2879705890 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ability_context_interface1_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ability_context_interface1_test.cpp @@ -175,6 +175,7 @@ HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_SetTheme_0100, Functi std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); std::shared_ptr contextDeal = std::make_shared(); std::shared_ptr abilityContext = std::make_shared(); + ASSERT_NE(abilityContext, nullptr); resourceManager->SetThemeById(testValue, testList); contextDeal->initResourceManager(resourceManager); abilityContext->AttachBaseContext(contextDeal); @@ -194,6 +195,7 @@ HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_SetTheme_0200, Functi std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); std::shared_ptr contextDeal = std::make_shared(); std::shared_ptr abilityContext = std::make_shared(); + ASSERT_NE(abilityContext, nullptr); abilityContext->SetTheme(testValue); abilityContext->AttachBaseContext(contextDeal); abilityContext->SetTheme(testValue); @@ -280,6 +282,7 @@ HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetTheme_0100, Functi std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); std::shared_ptr contextDeal = std::make_shared(); std::shared_ptr abilityContext = std::make_shared(); + ASSERT_NE(abilityContext, nullptr); resourceManager->SetThemeById(testValue, testList); contextDeal->initResourceManager(resourceManager); abilityContext->AttachBaseContext(contextDeal); @@ -318,6 +321,7 @@ HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetString_ByIdAndForm std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); std::shared_ptr contextDeal = std::make_shared(); std::shared_ptr abilityContext = std::make_shared(); + ASSERT_NE(abilityContext, nullptr); std::string testByName = ""; GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetString_ByIdAndFormat_0100 end"; } @@ -458,6 +462,7 @@ HWTEST_F(AbilityContextInterfaceTest, AaFwk_AbilityContext_GetThemeId_0100, Func GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetThemeId_0100 start"; std::shared_ptr contextDeal = std::make_shared(); std::shared_ptr abilityContext = std::make_shared(); + ASSERT_NE(abilityContext, nullptr); abilityContext->AttachBaseContext(contextDeal); GTEST_LOG_(INFO) << "AaFwk_AbilityContext_GetThemeId_0100 end"; } diff --git a/test/unittest/frameworks_kits_ability_native_test/ability_impl_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ability_impl_test.cpp index 4750d2d6ac..7a54261fa0 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ability_impl_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ability_impl_test.cpp @@ -1097,6 +1097,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_DoKeyDown_001, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_DoKeyDown_001 start"; auto keyEvent = MMI::KeyEvent::Create(); + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->DoKeyDown(keyEvent); GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_DoKeyDown_001 end"; } @@ -1113,6 +1114,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_DoKeyUp_001, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_DoKeyUp_001 start"; auto keyEvent = MMI::KeyEvent::Create(); + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->DoKeyUp(keyEvent); GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_DoKeyUp_001 end"; } @@ -1129,6 +1131,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_DoTouchEvent_001, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_DoTouchEvent_001 start"; auto pointerEvent = MMI::PointerEvent::Create(); + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->DoPointerEvent(pointerEvent); GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_DoTouchEvent_001 end"; } @@ -2181,6 +2184,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_HandleAbilityTransaction_0100, TestS GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_HandleAbilityTransaction_0100 start"; Want want; AAFwk::LifeCycleStateInfo targetState; + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->HandleAbilityTransaction(want, targetState); GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_HandleAbilityTransaction_0100 end"; } @@ -2194,6 +2198,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AbilityTransactionCallback_0100, Tes { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_AbilityTransactionCallback_0100 start"; AAFwk::AbilityLifeCycleState state = AAFwk::ABILITY_STATE_INITIAL; + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->AbilityTransactionCallback(state); GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_AbilityTransactionCallback_0100 end"; } @@ -2222,6 +2227,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ConnectAbility_0100, TestSize.Level1 HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_DisconnectAbility_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_DisconnectAbility_0100 start"; + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->ability_ = nullptr; Want want; AbilityImpl_->DisconnectAbility(want); @@ -2240,6 +2246,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_DisconnectAbility_0200, TestSize.Lev std::shared_ptr ability = pMocKPageAbility; std::shared_ptr abilityInfo = std::make_shared(); std::shared_ptr contextDeal = std::make_shared(); + ASSERT_NE(contextDeal, nullptr); contextDeal->SetAbilityInfo(abilityInfo); ability->AttachBaseContext(contextDeal); AbilityImpl_->ability_ = ability; @@ -2275,6 +2282,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_CommandAbility_0100, TestSize.Level1 HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_SendResult_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_SendResult_0100 start"; + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->ability_ = nullptr; int32_t requestCode = 0; int32_t resultCode = 0; @@ -2291,6 +2299,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_SendResult_0100, TestSize.Level1) HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_NewWant_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_NewWant_0100 start"; + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->ability_ = nullptr; Want want; AbilityImpl_->NewWant(want); @@ -2405,6 +2414,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_SerUriString_0100, TestSize.Level1) HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_SerUriString_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_SerUriString_0200 start"; + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->contextDeal_ = nullptr; std::string uri = "abc"; AbilityImpl_->SerUriString(uri); @@ -2444,6 +2454,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_SetLifeCycleStateInfo_0100, TestSize HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_SetLifeCycleStateInfo_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_SetLifeCycleStateInfo_0200 start"; + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->contextDeal_ = nullptr; AAFwk::LifeCycleStateInfo info; info.isNewWant = true; @@ -2593,6 +2604,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_DenormalizeUri_0100, TestSize.Level1 HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ScheduleUpdateConfiguration_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_ScheduleUpdateConfiguration_0100 start"; + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->ability_ = nullptr; Configuration config; AbilityImpl_->ScheduleUpdateConfiguration(config); @@ -2638,6 +2650,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ExecuteBatch_0100, TestSize.Level1) HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ContinueAbility_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_ContinueAbility_0100 start"; + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->ability_ = nullptr; std::string deviceId = "deviceId"; uint32_t versionCode = 0; @@ -2657,6 +2670,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ContinueAbility_0200, TestSize.Level std::shared_ptr ability = pMocKPageAbility; std::shared_ptr abilityInfo = std::make_shared(); std::shared_ptr contextDeal = std::make_shared(); + ASSERT_NE(contextDeal, nullptr); contextDeal->SetAbilityInfo(abilityInfo); ability->AttachBaseContext(contextDeal); AbilityImpl_->ability_ = ability; @@ -2675,6 +2689,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ContinueAbility_0200, TestSize.Level HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_NotifyContinuationResult_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_NotifyContinuationResult_0100 start"; + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->ability_ = nullptr; int32_t result = 0; AbilityImpl_->NotifyContinuationResult(result); @@ -2693,6 +2708,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_NotifyContinuationResult_0200, TestS std::shared_ptr ability = pMocKPageAbility; std::shared_ptr abilityInfo = std::make_shared(); std::shared_ptr contextDeal = std::make_shared(); + ASSERT_NE(contextDeal, nullptr); contextDeal->SetAbilityInfo(abilityInfo); ability->AttachBaseContext(contextDeal); AbilityImpl_->ability_ = ability; @@ -2710,6 +2726,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_NotifyContinuationResult_0200, TestS HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_NotifyMemoryLevel_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_NotifyMemoryLevel_0100 start"; + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->ability_ = nullptr; int32_t level = 0; AbilityImpl_->NotifyMemoryLevel(level); @@ -2728,6 +2745,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_NotifyMemoryLevel_0200, TestSize.Lev std::shared_ptr ability = pMocKPageAbility; std::shared_ptr abilityInfo = std::make_shared(); std::shared_ptr contextDeal = std::make_shared(); + ASSERT_NE(contextDeal, nullptr); contextDeal->SetAbilityInfo(abilityInfo); ability->AttachBaseContext(contextDeal); AbilityImpl_->ability_ = ability; @@ -2745,6 +2763,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_NotifyMemoryLevel_0200, TestSize.Lev HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterUnFocused_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_AfterUnFocused_0100 start"; + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->AfterUnFocused(); GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_AfterUnFocused_0100 end"; } @@ -2757,6 +2776,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterUnFocused_0100, TestSize.Level1 HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterFocused_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_AfterFocused_0100 start"; + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->AfterFocused(); GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_AfterFocused_0100 end"; } @@ -2769,6 +2789,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterFocused_0100, TestSize.Level1) HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterFocusedCommon_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_AfterFocusedCommon_0100 start"; + ASSERT_NE(AbilityImpl_, nullptr); AbilityImpl_->AfterFocusedCommon(true); AbilityImpl_->AfterFocusedCommon(false); GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_AfterFocusedCommon_0100 end"; @@ -2784,6 +2805,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterFocusedCommon_0200, TestSize.Le GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_AfterFocusedCommon_0200 start"; std::shared_ptr pMocKPageAbility = std::make_shared(); std::shared_ptr ability = pMocKPageAbility; + ASSERT_NE(ability, nullptr); AbilityImpl_->ability_ = ability; AbilityImpl_->AfterFocusedCommon(true); GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_AfterFocusedCommon_0200 end"; @@ -2801,6 +2823,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterFocusedCommon_0300, TestSize.Le std::shared_ptr ability = pMocKPageAbility; std::shared_ptr abilityInfo = std::make_shared(); std::shared_ptr contextDeal = std::make_shared(); + ASSERT_NE(contextDeal, nullptr); contextDeal->SetAbilityInfo(abilityInfo); ability->AttachBaseContext(contextDeal); AbilityImpl_->ability_ = ability; @@ -2820,6 +2843,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterFocusedCommon_0400, TestSize.Le std::shared_ptr ability = pMocKPageAbility; auto abilityInfo = std::make_shared(); auto contextDeal = std::make_shared(); + ASSERT_NE(contextDeal, nullptr); contextDeal->SetAbilityInfo(abilityInfo); ability->AttachBaseContext(contextDeal); AbilityImpl_->ability_ = ability; @@ -2842,6 +2866,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterFocusedCommon_0500, TestSize.Le auto abilityInfo = std::make_shared(); abilityInfo->isStageBasedModel = true; auto contextDeal = std::make_shared(); + ASSERT_NE(contextDeal, nullptr); contextDeal->SetAbilityInfo(abilityInfo); ability->AttachBaseContext(contextDeal); AbilityImpl_->ability_ = ability; @@ -2868,6 +2893,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterFocusedCommon_0600, TestSize.Le auto abilityInfo = std::make_shared(); abilityInfo->isStageBasedModel = false; auto contextDeal = std::make_shared(); + ASSERT_NE(contextDeal, nullptr); contextDeal->SetAbilityInfo(abilityInfo); ability->AttachBaseContext(contextDeal); AbilityImpl_->ability_ = ability; @@ -2931,6 +2957,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterForeground_0300, TestSize.Level sptr token = sptr(new (std::nothrow) MockAbilityToken()); sptr impl = new (std::nothrow) AbilityImpl::WindowLifeCycleImpl(token, nullptr); + ASSERT_NE(impl, nullptr); impl->AfterForeground(); auto abilityImpl = std::make_shared(); @@ -2955,6 +2982,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterBackground_0100, TestSize.Level sptr impl = new (std::nothrow) AbilityImpl::WindowLifeCycleImpl(token, nullptr); impl->AfterBackground(); + ASSERT_NE(impl, nullptr); auto abilityImpl = std::make_shared(); abilityImpl->isStageBasedModel_ = false; @@ -2976,6 +3004,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterBackground_0200, TestSize.Level GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_AfterBackground_0200 start"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); auto abilityImpl = std::make_shared(); + ASSERT_NE(abilityImpl, nullptr); abilityImpl->isStageBasedModel_ = true; abilityImpl->notifyForegroundByAbility_ = false; abilityImpl->notifyForegroundByWindow_ = false; @@ -2995,6 +3024,7 @@ HWTEST_F(AbilityImplTest, AaFwk_WindowLifeCycleImpl_0100, TestSize.Level1) GTEST_LOG_(INFO) << "AaFwk_WindowLifeCycleImpl_0100 start"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); auto abilityImpl = std::make_shared(); + ASSERT_NE(abilityImpl, nullptr); sptr impl = new (std::nothrow) AbilityImpl::WindowLifeCycleImpl(token, abilityImpl); impl->AfterFocused(); @@ -3012,6 +3042,7 @@ HWTEST_F(AbilityImplTest, AaFwk_WindowLifeCycleImpl_0200, TestSize.Level1) sptr token = sptr(new (std::nothrow) MockAbilityToken()); sptr impl = new (std::nothrow) AbilityImpl::WindowLifeCycleImpl(token, nullptr); + ASSERT_NE(impl, nullptr); impl->AfterFocused(); GTEST_LOG_(INFO) << "AaFwk_WindowLifeCycleImpl_0200 end"; } @@ -3027,6 +3058,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterUnfocused_0100, TestSize.Level1 sptr token = sptr(new (std::nothrow) MockAbilityToken()); sptr impl = new (std::nothrow) AbilityImpl::WindowLifeCycleImpl(token, nullptr); + ASSERT_NE(impl, nullptr); impl->AfterUnfocused(); GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_AfterUnfocused_0100 end"; } @@ -3043,6 +3075,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_AfterUnfocused_0200, TestSize.Level1 auto abilityImpl = std::make_shared(); sptr impl = new (std::nothrow) AbilityImpl::WindowLifeCycleImpl(token, abilityImpl); + ASSERT_NE(impl, nullptr); impl->AfterUnfocused(); GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_AfterUnfocused_0200 end"; } @@ -3059,6 +3092,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ForegroundFailed_0100, TestSize.Leve auto abilityImpl = std::make_shared(); sptr impl = new (std::nothrow) AbilityImpl::WindowLifeCycleImpl(token, abilityImpl); + ASSERT_NE(impl, nullptr); auto wmErrNoMem = 2; impl->ForegroundFailed(wmErrNoMem); GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_ForegroundFailed_0100 end"; @@ -3075,6 +3109,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ForegroundFailed_0200, TestSize.Leve sptr token = sptr(new (std::nothrow) MockAbilityToken()); sptr impl = new (std::nothrow) AbilityImpl::WindowLifeCycleImpl(token, nullptr); + ASSERT_NE(impl, nullptr); auto wmErrInvalidWindowModeOrSize = 5; impl->ForegroundFailed(wmErrInvalidWindowModeOrSize); @@ -3099,6 +3134,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ForegroundFailed_0300, TestSize.Leve abilityImpl->isStageBasedModel_ = true; sptr impl = new (std::nothrow) AbilityImpl::WindowLifeCycleImpl(token, abilityImpl); + ASSERT_NE(impl, nullptr); auto wmErrInvalidWindowModeOrSize = 5; impl->ForegroundFailed(wmErrInvalidWindowModeOrSize); GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_ForegroundFailed_0300 end"; @@ -3114,6 +3150,7 @@ HWTEST_F(AbilityImplTest, AaFwk_InputEventConsumerImpl_0100, TestSize.Level1) GTEST_LOG_(INFO) << "AaFwk_InputEventConsumerImpl_0100 start"; auto abilityImpl = std::make_shared(); auto impl = std::make_shared(abilityImpl); + ASSERT_NE(impl, nullptr); auto keyEvent = MMI::KeyEvent::Create(); impl->OnInputEvent(keyEvent); GTEST_LOG_(INFO) << "AaFwk_InputEventConsumerImpl_0100 end"; @@ -3129,6 +3166,7 @@ HWTEST_F(AbilityImplTest, AaFwk_InputEventConsumerImpl_0200, TestSize.Level1) GTEST_LOG_(INFO) << "AaFwk_InputEventConsumerImpl_0200 start"; auto abilityImpl = std::make_shared(); auto impl = std::make_shared(abilityImpl); + ASSERT_NE(impl, nullptr); std::shared_ptr pointerEvent; impl->OnInputEvent(pointerEvent); GTEST_LOG_(INFO) << "AaFwk_InputEventConsumerImpl_0200 end"; diff --git a/test/unittest/frameworks_kits_ability_native_test/ability_lifecycle_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ability_lifecycle_test.cpp index f4aef35c6c..d0e9fbe3ca 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ability_lifecycle_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ability_lifecycle_test.cpp @@ -77,6 +77,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_GetLifecycleState_0100, Function | Mediu HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_AddObserver_0100, Function | MediumTest | Level3) { GTEST_LOG_(INFO) << "AaFwk_LifeCycle_AddObserver_0100 start"; + ASSERT_NE(lifeCycle_, nullptr); lifeCycle_->AddObserver(nullptr); @@ -93,6 +94,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_AddObserver_0200, Function | MediumTest GTEST_LOG_(INFO) << "AaFwk_LifeCycle_AddObserver_0200 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_ACTIVE); @@ -109,6 +111,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_RemoveObserver_0100, Function | MediumTe GTEST_LOG_(INFO) << "AaFwk_LifeCycle_RemoveObserver_0100 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_ACTIVE); lifeCycle_->RemoveObserver(nullptr); @@ -126,6 +129,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_RemoveObserver_0200, Function | MediumTe GTEST_LOG_(INFO) << "AaFwk_LifeCycle_RemoveObserver_0200 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_ACTIVE); lifeCycle_->RemoveObserver(observer); @@ -144,6 +148,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_DispatchLifecycle_event_want_0100, Funct GTEST_LOG_(INFO) << "AaFwk_LifeCycle_DispatchLifecycle_event_want_0100 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); Want want; lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::UNDEFINED, want); @@ -161,6 +166,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_DispatchLifecycle_event_want_0200, Funct GTEST_LOG_(INFO) << "AaFwk_LifeCycle_DispatchLifecycle_event_want_0200 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); Want want; lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_ACTIVE, want); @@ -178,6 +184,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_DispatchLifecycle_event_want_0300, Funct GTEST_LOG_(INFO) << "AaFwk_LifeCycle_DispatchLifecycle_event_want_0300 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); Want want; lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_BACKGROUND, want); @@ -195,6 +202,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_DispatchLifecycle_event_want_0400, Funct GTEST_LOG_(INFO) << "AaFwk_LifeCycle_DispatchLifecycle_event_want_0400 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); Want want; lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_FOREGROUND, want); @@ -212,6 +220,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_DispatchLifecycle_event_want_0500, Funct GTEST_LOG_(INFO) << "AaFwk_LifeCycle_DispatchLifecycle_event_want_0500 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); Want want; lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_INACTIVE, want); @@ -229,6 +238,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_DispatchLifecycle_event_want_0600, Funct GTEST_LOG_(INFO) << "AaFwk_LifeCycle_DispatchLifecycle_event_want_0600 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); Want want; lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_START, want); @@ -246,6 +256,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_DispatchLifecycle_event_want_0700, Funct GTEST_LOG_(INFO) << "AaFwk_LifeCycle_DispatchLifecycle_event_want_0700 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); Want want; lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_STOP, want); @@ -263,6 +274,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_DispatchLifecycle_event_0100, Function | GTEST_LOG_(INFO) << "AaFwk_LifeCycle_DispatchLifecycle_event_0100 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::UNDEFINED); @@ -279,6 +291,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_DispatchLifecycle_event_0200, Function | GTEST_LOG_(INFO) << "AaFwk_LifeCycle_DispatchLifecycle_event_0200 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_ACTIVE); @@ -295,6 +308,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_DispatchLifecycle_event_0300, Function | GTEST_LOG_(INFO) << "AaFwk_LifeCycle_DispatchLifecycle_event_0300 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_BACKGROUND); @@ -311,6 +325,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_DispatchLifecycle_event_0400, Function | GTEST_LOG_(INFO) << "AaFwk_LifeCycle_DispatchLifecycle_event_0400 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_FOREGROUND); @@ -327,6 +342,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_DispatchLifecycle_event_0500, Function | GTEST_LOG_(INFO) << "AaFwk_LifeCycle_DispatchLifecycle_event_0500 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_INACTIVE); @@ -343,6 +359,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_DispatchLifecycle_event_0600, Function | GTEST_LOG_(INFO) << "AaFwk_LifeCycle_DispatchLifecycle_event_0600 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_START); @@ -359,6 +376,7 @@ HWTEST_F(LifeCycleTest, AaFwk_LifeCycle_DispatchLifecycle_event_0700, Function | GTEST_LOG_(INFO) << "AaFwk_LifeCycle_DispatchLifecycle_event_0700 start"; std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); lifeCycle_->AddObserver(observer); lifeCycle_->DispatchLifecycle(LifeCycle::Event::ON_STOP); diff --git a/test/unittest/frameworks_kits_ability_native_test/ability_window_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ability_window_test.cpp index 687f81097b..faa79be10c 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ability_window_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ability_window_test.cpp @@ -123,6 +123,7 @@ HWTEST_F(AbilityWindowTest, Ability_Window_InitWindow_0200, TestSize.Level1) HWTEST_F(AbilityWindowTest, Ability_Window_OnPostAbilityBackground_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "Ability_Window_OnPostAbilityBackground_0100 start"; + ASSERT_NE(abilityWindow_, nullptr); abilityWindow_->windowScene_ = std::make_shared(); uint32_t sceneFlag = 0; abilityWindow_->OnPostAbilityBackground(sceneFlag); @@ -137,6 +138,7 @@ HWTEST_F(AbilityWindowTest, Ability_Window_OnPostAbilityBackground_0100, TestSiz HWTEST_F(AbilityWindowTest, Ability_Window_OnPostAbilityBackground_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "Ability_Window_OnPostAbilityBackground_0200 start"; + ASSERT_NE(abilityWindow_, nullptr); abilityWindow_->isWindowAttached = true; uint32_t sceneFlag = 0; abilityWindow_->OnPostAbilityBackground(sceneFlag); @@ -153,6 +155,7 @@ HWTEST_F(AbilityWindowTest, Ability_Window_OnPostAbilityBackground_0200, TestSiz HWTEST_F(AbilityWindowTest, Ability_Window_OnPostAbilityForeground_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "Ability_Window_OnPostAbilityForeground_0100 start"; + ASSERT_NE(abilityWindow_, nullptr); abilityWindow_->windowScene_ = std::make_shared(); uint32_t sceneFlag = 0; abilityWindow_->OnPostAbilityForeground(sceneFlag); @@ -167,6 +170,7 @@ HWTEST_F(AbilityWindowTest, Ability_Window_OnPostAbilityForeground_0100, TestSiz HWTEST_F(AbilityWindowTest, Ability_Window_OnPostAbilityForeground_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "Ability_Window_OnPostAbilityForeground_0200 start"; + ASSERT_NE(abilityWindow_, nullptr); abilityWindow_->isWindowAttached = true; uint32_t sceneFlag = 0; abilityWindow_->OnPostAbilityForeground(sceneFlag); diff --git a/test/unittest/frameworks_kits_ability_native_test/data_ability_operation_test.cpp b/test/unittest/frameworks_kits_ability_native_test/data_ability_operation_test.cpp index a0d92bc357..81e90d6908 100644 --- a/test/unittest/frameworks_kits_ability_native_test/data_ability_operation_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/data_ability_operation_test.cpp @@ -905,8 +905,9 @@ HWTEST_F(DataAbilityOperationTest, DataAbilityOperationTest_0600, Level1) { GTEST_LOG_(INFO) << "DataAbilityOperationTest_0600 start"; Parcel parcel; - DataAbilityOperation dataAbilityOperation; - dataAbilityOperation.PutMap(parcel); + std::shared_ptr dataAbilityOperation = std::make_shared(); + ASSERT_NE(dataAbilityOperation, nullptr); + dataAbilityOperation->PutMap(parcel); GTEST_LOG_(INFO) << "DataAbilityOperationTest_0600 end"; } } // namespace AppExecFwk diff --git a/test/unittest/frameworks_kits_ability_native_test/form_ability_test.cpp b/test/unittest/frameworks_kits_ability_native_test/form_ability_test.cpp index 28e5df23df..b89e4e88b5 100644 --- a/test/unittest/frameworks_kits_ability_native_test/form_ability_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/form_ability_test.cpp @@ -844,6 +844,7 @@ HWTEST_F(FormAbilityTest, AaFwk_Ability_NotifyInvisibleForms_0100, Function | Me { GTEST_LOG_(INFO) << "AaFwk_Ability_NotifyInvisibleForms_0100 start"; std::vector formIds; + ASSERT_NE(ability_, nullptr); ability_->NotifyInvisibleForms(formIds); GTEST_LOG_(INFO) << "AaFwk_Ability_NotifyInvisibleForms_0100 end"; } @@ -859,6 +860,7 @@ HWTEST_F(FormAbilityTest, AaFwk_Ability_NotifyInvisibleForms_0200, Function | Me std::vector formIds; formIds.push_back(1); FormMgr::SetRecoverStatus(Constants::IN_RECOVERING); + ASSERT_NE(ability_, nullptr); ability_->NotifyInvisibleForms(formIds); GTEST_LOG_(INFO) << "AaFwk_Ability_NotifyInvisibleForms_0200 end"; } @@ -874,6 +876,7 @@ HWTEST_F(FormAbilityTest, AaFwk_Ability_NotifyInvisibleForms_0300, Function | Me std::vector formIds; formIds.push_back(1); FormMgr::SetRecoverStatus(Constants::NOT_IN_RECOVERY); + ASSERT_NE(ability_, nullptr); ability_->NotifyInvisibleForms(formIds); GTEST_LOG_(INFO) << "AaFwk_Ability_NotifyInvisibleForms_0300 end"; } @@ -890,6 +893,7 @@ HWTEST_F(FormAbilityTest, AaFwk_Ability_NotifyInvisibleForms_0400, Function | Me formIds.push_back(1); formIds.push_back(2); FormMgr::SetRecoverStatus(Constants::NOT_IN_RECOVERY); + ASSERT_NE(ability_, nullptr); ability_->NotifyInvisibleForms(formIds); GTEST_LOG_(INFO) << "AaFwk_Ability_NotifyInvisibleForms_0400 end"; } @@ -907,6 +911,7 @@ HWTEST_F(FormAbilityTest, AaFwk_Ability_NotifyVisibleForms_0100, Function | Medi abilityInfo->type = AbilityType::PAGE; std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); + ASSERT_NE(ability_, nullptr); ability_->Init(abilityInfo, nullptr, handler, nullptr); @@ -931,6 +936,7 @@ HWTEST_F(FormAbilityTest, AaFwk_Ability_NotifyVisibleForms_0200, Function | Medi abilityInfo->type = AbilityType::PAGE; std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); + ASSERT_NE(ability_, nullptr); ability_->Init(abilityInfo, nullptr, handler, nullptr); @@ -952,6 +958,7 @@ HWTEST_F(FormAbilityTest, AaFwk_Ability_NotifyVisibleForms_0300, Function | Medi abilityInfo->type = AbilityType::PAGE; std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); + ASSERT_NE(ability_, nullptr); ability_->Init(abilityInfo, nullptr, handler, nullptr); @@ -977,6 +984,7 @@ HWTEST_F(FormAbilityTest, AaFwk_Ability_NotifyVisibleForms_0400, Function | Medi abilityInfo->type = AbilityType::PAGE; std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); + ASSERT_NE(ability_, nullptr); ability_->Init(abilityInfo, nullptr, handler, nullptr); @@ -1002,6 +1010,7 @@ HWTEST_F(FormAbilityTest, AaFwk_Ability_FmsDeathCallback_OnDeathReceived_0100, F abilityInfo->type = AbilityType::PAGE; std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); std::shared_ptr handler = std::make_shared(eventRunner); + ASSERT_NE(ability_, nullptr); ability_->Init(abilityInfo, nullptr, handler, nullptr); diff --git a/test/unittest/frameworks_kits_ability_native_test/form_extension_provider_client_test.cpp b/test/unittest/frameworks_kits_ability_native_test/form_extension_provider_client_test.cpp index b63b02c22e..259af67a94 100644 --- a/test/unittest/frameworks_kits_ability_native_test/form_extension_provider_client_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/form_extension_provider_client_test.cpp @@ -97,8 +97,10 @@ HWTEST_F(FormExtensionProviderClientTest, formExtensionProviderClient_0100, Func int64_t formId = 723L; const sptr callerToken = nullptr; - AbilityRuntime::FormExtensionProviderClient formExtensionProviderClient; - formExtensionProviderClient.NotifyFormExtensionDelete(formId, want, callerToken); + std::shared_ptr formExtensionProviderClient = + std::make_shared(); + ASSERT_NE(formExtensionProviderClient, nullptr); + formExtensionProviderClient->NotifyFormExtensionDelete(formId, want, callerToken); GTEST_LOG_(INFO) << "formExtensionProviderClient_0100 end"; } @@ -120,8 +122,10 @@ HWTEST_F(FormExtensionProviderClientTest, formExtensionProviderClient_0200, Func want.SetParam(Constants::PARAM_FORM_HOST_TOKEN, callerToken); int64_t formId = 723L; - AbilityRuntime::FormExtensionProviderClient formExtensionProviderClient; - formExtensionProviderClient.NotifyFormExtensionDelete(formId, want, callerToken); + std::shared_ptr formExtensionProviderClient = + std::make_shared(); + ASSERT_NE(formExtensionProviderClient, nullptr); + formExtensionProviderClient->NotifyFormExtensionDelete(formId, want, callerToken); GTEST_LOG_(INFO) << "formExtensionProviderClient_0200 end"; } @@ -141,8 +145,10 @@ HWTEST_F(FormExtensionProviderClientTest, formExtensionProviderClient_0300, Func int64_t formId = 723L; const sptr callerToken = nullptr; - AbilityRuntime::FormExtensionProviderClient formExtensionProviderClient; - formExtensionProviderClient.NotifyFormExtensionUpdate(formId, want, callerToken); + std::shared_ptr formExtensionProviderClient = + std::make_shared(); + ASSERT_NE(formExtensionProviderClient, nullptr); + formExtensionProviderClient->NotifyFormExtensionUpdate(formId, want, callerToken); GTEST_LOG_(INFO) << "formExtensionProviderClient_0300 end"; } @@ -162,8 +168,10 @@ HWTEST_F(FormExtensionProviderClientTest, formExtensionProviderClient_0400, Func int64_t formId = 723L; const sptr callerToken = nullptr; - AbilityRuntime::FormExtensionProviderClient formExtensionProviderClient; - formExtensionProviderClient.NotifyFormExtensionUpdate(formId, want, callerToken); + std::shared_ptr formExtensionProviderClient = + std::make_shared(); + ASSERT_NE(formExtensionProviderClient, nullptr); + formExtensionProviderClient->NotifyFormExtensionUpdate(formId, want, callerToken); GTEST_LOG_(INFO) << "formExtensionProviderClient_0400 end"; } @@ -184,8 +192,10 @@ HWTEST_F(FormExtensionProviderClientTest, formExtensionProviderClient_0500, Func int64_t formId = 723L; std::string message = "event message"; const sptr callerToken = nullptr; - AbilityRuntime::FormExtensionProviderClient formExtensionProviderClient; - formExtensionProviderClient.FireFormExtensionEvent(formId, message, want, callerToken); + std::shared_ptr formExtensionProviderClient = + std::make_shared(); + ASSERT_NE(formExtensionProviderClient, nullptr); + formExtensionProviderClient->FireFormExtensionEvent(formId, message, want, callerToken); GTEST_LOG_(INFO) << "formExtensionProviderClient_0500 end"; } @@ -206,8 +216,10 @@ HWTEST_F(FormExtensionProviderClientTest, formExtensionProviderClient_0600, Func int64_t formId = 723L; std::string message = "event message"; const sptr callerToken = nullptr; - AbilityRuntime::FormExtensionProviderClient formExtensionProviderClient; - formExtensionProviderClient.FireFormExtensionEvent(formId, message, want, callerToken); + std::shared_ptr formExtensionProviderClient = + std::make_shared(); + ASSERT_NE(formExtensionProviderClient, nullptr); + formExtensionProviderClient->FireFormExtensionEvent(formId, message, want, callerToken); GTEST_LOG_(INFO) << "formExtensionProviderClient_0600 end"; } diff --git a/test/unittest/frameworks_kits_ability_native_test/form_extension_test.cpp b/test/unittest/frameworks_kits_ability_native_test/form_extension_test.cpp index c92e6559d6..0fb55b294a 100644 --- a/test/unittest/frameworks_kits_ability_native_test/form_extension_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/form_extension_test.cpp @@ -179,6 +179,7 @@ HWTEST_F(FormExtensionTest, AaFwk_Form_Extension_0700, Function | MediumTest | L GTEST_LOG_(INFO) << "AaFwk_Form_Extension_0700 start"; AbilityRuntime::Runtime::Options options; std::unique_ptr runtime = AbilityRuntime::Runtime::Create(options); + ASSERT_NE(runtime, nullptr); auto formExtension = AbilityRuntime::FormExtension::Create(runtime); int64_t formId = 0; formExtension->OnDestroy(formId); @@ -195,6 +196,7 @@ HWTEST_F(FormExtensionTest, AaFwk_Form_Extension_0800, Function | MediumTest | L GTEST_LOG_(INFO) << "AaFwk_Form_Extension_0800 start"; AbilityRuntime::Runtime::Options options; std::unique_ptr runtime = AbilityRuntime::Runtime::Create(options); + ASSERT_NE(runtime, nullptr); auto formExtension = AbilityRuntime::FormExtension::Create(runtime); int64_t formId = 0; std::string message; @@ -212,6 +214,7 @@ HWTEST_F(FormExtensionTest, AaFwk_Form_Extension_0900, Function | MediumTest | L GTEST_LOG_(INFO) << "AaFwk_Form_Extension_0900 start"; AbilityRuntime::Runtime::Options options; std::unique_ptr runtime = AbilityRuntime::Runtime::Create(options); + ASSERT_NE(runtime, nullptr); auto formExtension = AbilityRuntime::FormExtension::Create(runtime); int64_t formId = 0; formExtension->OnUpdate(formId); @@ -228,6 +231,7 @@ HWTEST_F(FormExtensionTest, AaFwk_Form_Extension_1000, Function | MediumTest | L GTEST_LOG_(INFO) << "AaFwk_Form_Extension_1000 start"; AbilityRuntime::Runtime::Options options; std::unique_ptr runtime = AbilityRuntime::Runtime::Create(options); + ASSERT_NE(runtime, nullptr); auto formExtension = AbilityRuntime::FormExtension::Create(runtime); int64_t formId = 0; formExtension->OnCastToNormal(formId); @@ -244,6 +248,7 @@ HWTEST_F(FormExtensionTest, AaFwk_Form_Extension_1100, Function | MediumTest | L GTEST_LOG_(INFO) << "AaFwk_Form_Extension_1100 start"; AbilityRuntime::Runtime::Options options; std::unique_ptr runtime = AbilityRuntime::Runtime::Create(options); + ASSERT_NE(runtime, nullptr); auto formExtension = AbilityRuntime::FormExtension::Create(runtime); std::map formEventsMap; formExtension->OnVisibilityChange(formEventsMap); diff --git a/test/unittest/frameworks_kits_ability_native_test/form_host_client_test.cpp b/test/unittest/frameworks_kits_ability_native_test/form_host_client_test.cpp index 169b10df5c..513ff49075 100644 --- a/test/unittest/frameworks_kits_ability_native_test/form_host_client_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/form_host_client_test.cpp @@ -16,7 +16,9 @@ #include #include "form_callback_interface.h" +#define private public #include "form_host_client.h" +#undef private namespace OHOS { namespace AppExecFwk { @@ -76,6 +78,7 @@ HWTEST_F(FormHostClientTest, AaFwk_formHostClientAddForm_0100, Function | Medium { GTEST_LOG_(INFO) << "AaFwk_FormHostClient_AddForm_0100 start"; std::shared_ptr callback = std::make_shared(); + ASSERT_NE(callback, nullptr); FormJsInfo formJsInfo; formJsInfo.formId = 0; instance_->AddForm(callback, formJsInfo); @@ -96,6 +99,7 @@ HWTEST_F(FormHostClientTest, AaFwk_FormHostClient_RemoveForm_0100, Function | Me { GTEST_LOG_(INFO) << "AaFwk_FormHostClient_RemoveForm_0100 start"; std::shared_ptr callback = std::make_shared(); + ASSERT_NE(callback, nullptr); FormJsInfo formJsInfo; formJsInfo.formId = 0; instance_->RemoveForm(callback, formJsInfo.formId); @@ -116,6 +120,7 @@ HWTEST_F(FormHostClientTest, AaFwk_FormHostClient_ContainsForm_0100, Function | int64_t formId = 0; EXPECT_EQ(false, instance_->ContainsForm(formId)); std::shared_ptr callback = std::make_shared(); + ASSERT_NE(callback, nullptr); FormJsInfo formJsInfo; formJsInfo.formId = 1; instance_->AddForm(callback, formJsInfo); @@ -137,6 +142,7 @@ HWTEST_F(FormHostClientTest, AaFwk_FormHostClient_OnAcquired_0100, Function | Me instance_->OnAcquired(formInfo, nullptr); formInfo.formId = -1; std::shared_ptr callback = std::make_shared(); + ASSERT_NE(callback, nullptr); instance_->AddForm(callback, formInfo); formInfo.formId = 1; formInfo.jsFormCodePath = "/data/test"; @@ -159,6 +165,7 @@ HWTEST_F(FormHostClientTest, AaFwk_FormHostClient_OnUpdate_0100, Function | Medi instance_->OnUpdate(formInfo); formInfo.formId = 1; std::shared_ptr callback = std::make_shared(); + ASSERT_NE(callback, nullptr); instance_->AddForm(callback, formInfo); formInfo.formId = 1; instance_->OnUpdate(formInfo); @@ -203,8 +210,10 @@ HWTEST_F(FormHostClientTest, AaFwk_FormHostClient_RemoveShareFormCallback_0100, GTEST_LOG_(INFO) << "AaFwk_FormHostClient_RemoveShareFormCallback_0100 start"; std::shared_ptr shareFormCallback; FormHostClient formhostclient; + formhostclient.shareFormCallbackMap_.clear(); formhostclient.AddShareFormCallback(shareFormCallback, 0); formhostclient.AddShareFormCallback(shareFormCallback, 1); + EXPECT_EQ(formhostclient.shareFormCallbackMap_.size(), 2); formhostclient.RemoveShareFormCallback(1); formhostclient.RemoveShareFormCallback(0); GTEST_LOG_(INFO) << "AaFwk_FormHostClient_RemoveShareFormCallback_0100 end"; diff --git a/test/unittest/frameworks_kits_ability_native_test/form_provider_client_test.cpp b/test/unittest/frameworks_kits_ability_native_test/form_provider_client_test.cpp index 63ec75a808..3dbde027e8 100644 --- a/test/unittest/frameworks_kits_ability_native_test/form_provider_client_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/form_provider_client_test.cpp @@ -83,6 +83,7 @@ HWTEST_F(FormProviderClientTest, AaFwk_FormProviderClient_AcquireProviderFormInf GTEST_LOG_(INFO) << "AaFwk_FormProviderClient_AcquireProviderFormInfo_0100 start"; const std::shared_ptr ability = std::make_shared(); + ASSERT_NE(ability, nullptr); instance_->SetOwner(ability); const sptr callerToken = MockFormSupplyCallback::GetInstance(); @@ -111,6 +112,7 @@ HWTEST_F(FormProviderClientTest, AaFwk_FormProviderClient_AcquireProviderFormInf instance_->SetOwner(nullptr); const sptr callerToken = MockFormSupplyCallback::GetInstance(); + ASSERT_NE(callerToken, nullptr); Want want; want.SetParam(Constants::PARAM_FORM_MANAGER_SERVICE_BUNDLENAME_KEY, FORM_MANAGER_SERVICE_BUNDLE_NAME) .SetParam(Constants::ACQUIRE_TYPE, 200) @@ -135,6 +137,7 @@ HWTEST_F(FormProviderClientTest, AaFwk_FormProviderClient_AcquireProviderFormInf GTEST_LOG_(INFO) << "AaFwk_FormProviderClient_AcquireProviderFormInfo_0300 start"; const std::shared_ptr ability = std::make_shared(); + ASSERT_NE(ability, nullptr); instance_->SetOwner(ability); const sptr callerToken = MockFormSupplyCallback::GetInstance(); @@ -161,6 +164,7 @@ HWTEST_F(FormProviderClientTest, AaFwk_FormProviderClient_AcquireProviderFormInf GTEST_LOG_(INFO) << "AaFwk_FormProviderClient_AcquireProviderFormInfo_0400 start"; const std::shared_ptr ability = std::make_shared(); + ASSERT_NE(ability, nullptr); instance_->SetOwner(ability); instance_->ClearOwner(ability); diff --git a/test/unittest/frameworks_kits_ability_native_test/pac_map_test.cpp b/test/unittest/frameworks_kits_ability_native_test/pac_map_test.cpp index f258ddec3e..232f64616c 100644 --- a/test/unittest/frameworks_kits_ability_native_test/pac_map_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/pac_map_test.cpp @@ -911,6 +911,7 @@ HWTEST_F(PacMapTest, AppExecFwk_PacMap_InnerPutObject_0100, Function | MediumTes std::shared_ptr value = nullptr; PacMapList mapList; std::string key = "this is key"; + ASSERT_NE(pacmap_, nullptr); pacmap_->InnerPutObject(mapList, key, value); GTEST_LOG_(INFO) << "AppExecFwk_PacMap_InnerPutObject_0100 end"; @@ -1108,6 +1109,7 @@ HWTEST_F(PacMapTest, AppExecFwk_PacMap_GetPacMap_0100, Function | MediumTest | L GTEST_LOG_(INFO) << "AppExecFwk_PacMap_GetPacMap_0100 start"; std::string key = "this is key"; + ASSERT_NE(pacmap_, nullptr); pacmap_->GetPacMap(key); std::string key1 = ""; pacmap_->GetPacMap(key1); diff --git a/test/unittest/frameworks_kits_ability_native_test/page_ability_impl_test.cpp b/test/unittest/frameworks_kits_ability_native_test/page_ability_impl_test.cpp index 06a5ba9872..695d406dd7 100644 --- a/test/unittest/frameworks_kits_ability_native_test/page_ability_impl_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/page_ability_impl_test.cpp @@ -103,6 +103,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DoKeyDown_0200, Function | M GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_DoKeyDown_0200 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -134,6 +135,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DoKeyUp_0100, Function | Med GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_DoKeyUp_0100 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -166,6 +168,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DoKeyUp_0200, Function | Med GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_DoKeyUp_0200 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -198,6 +201,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DoTouchEvent_0100, Function GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_DoTouchEvent_0100 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -230,6 +234,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DoTouchEvent_0200, Function GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_DoTouchEvent_0200 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -296,6 +301,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_020 GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_HandleAbilityTransaction_0200 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -327,6 +333,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_030 GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_HandleAbilityTransaction_0300 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -358,6 +365,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_040 GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_HandleAbilityTransaction_0400 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -389,6 +397,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_050 GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_HandleAbilityTransaction_0500 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -422,6 +431,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_060 GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_HandleAbilityTransaction_0600 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -456,6 +466,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_070 GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_HandleAbilityTransaction_0700 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -492,6 +503,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_080 GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_HandleAbilityTransaction_0800 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -527,6 +539,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_HandleAbilityTransaction_090 GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_HandleAbilityTransaction_0900 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -564,6 +577,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DispatchSaveAbilityState_010 GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_DispatchSaveAbilityState_0100 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -594,6 +608,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DispatchRestoreAbilityState_ GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_DispatchRestoreAbilityState_0100 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -623,6 +638,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_SendResult_0100, Function | GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_SendResult_0100 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -654,6 +670,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_NewWant_0100, Function | Med GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_NewWant_0100 start"; std::shared_ptr application = std::make_shared(); + ASSERT_NE(application, nullptr); std::shared_ptr abilityInfo = std::make_shared(); abilityInfo->name = "pageAbility"; sptr token = sptr(new (std::nothrow) MockAbilityToken()); @@ -914,6 +931,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DoKeyDown_0300, Function | M { GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_DoKeyDown_0300 start"; auto keyEvent = MMI::KeyEvent::Create(); + ASSERT_NE(pageAbilityImpl_, nullptr); pageAbilityImpl_->ability_ = nullptr; pageAbilityImpl_->DoKeyDown(keyEvent); GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_DoKeyDown_0300 end"; @@ -928,6 +946,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DoKeyUp_0300, Function | Med { GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_DoKeyUp_0300 start"; auto keyEvent = MMI::KeyEvent::Create(); + ASSERT_NE(pageAbilityImpl_, nullptr); pageAbilityImpl_->ability_ = nullptr; pageAbilityImpl_->DoKeyUp(keyEvent); GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_DoKeyUp_0300 end"; @@ -942,6 +961,7 @@ HWTEST_F(PageAbilityImplTest, AaFwk_PageAbilityImpl_DoTouchEvent_0300, Function { GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_DoTouchEvent_0300 start"; auto pointerEvent = MMI::PointerEvent::Create(); + ASSERT_NE(pageAbilityImpl_, nullptr); pageAbilityImpl_->ability_ = nullptr; pageAbilityImpl_->DoPointerEvent(pointerEvent); GTEST_LOG_(INFO) << "AaFwk_PageAbilityImpl_DoTouchEvent_0300 end"; diff --git a/test/unittest/frameworks_kits_appkit_native_test/context_container_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/context_container_test.cpp index 1a58ad1971..30d0ac2264 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/context_container_test.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/context_container_test.cpp @@ -765,6 +765,7 @@ HWTEST_F(ContextContainerTest, VerifySelfPermission_0200, Function | MediumTest */ HWTEST_F(ContextContainerTest, UnauthUriPermission_0100, Function | MediumTest | Level1) { + ASSERT_NE(context_, nullptr); context_->AttachBaseContext(contextDeal_); std::string permission = "test_permission"; Uri uri(""); @@ -779,6 +780,7 @@ HWTEST_F(ContextContainerTest, UnauthUriPermission_0100, Function | MediumTest | */ HWTEST_F(ContextContainerTest, UnauthUriPermission_0200, Function | MediumTest | Level1) { + ASSERT_NE(context_, nullptr); context_->AttachBaseContext(nullptr); std::string permission = "test_permission"; Uri uri(""); @@ -843,6 +845,7 @@ HWTEST_F(ContextContainerTest, GetDistributedDir_0200, Function | MediumTest | L */ HWTEST_F(ContextContainerTest, SetPattern_0100, Function | MediumTest | Level1) { + ASSERT_NE(context_, nullptr); context_->AttachBaseContext(contextDeal_); int patternId = 0; context_->SetPattern(patternId); @@ -855,6 +858,7 @@ HWTEST_F(ContextContainerTest, SetPattern_0100, Function | MediumTest | Level1) */ HWTEST_F(ContextContainerTest, SetPattern_0200, Function | MediumTest | Level1) { + ASSERT_NE(context_, nullptr); context_->AttachBaseContext(nullptr); int patternId = 0; context_->SetPattern(patternId); @@ -889,6 +893,7 @@ HWTEST_F(ContextContainerTest, GetAbilityPackageContext_0200, Function | MediumT */ HWTEST_F(ContextContainerTest, RequestPermissionsFromUser_0100, Function | MediumTest | Level1) { + ASSERT_NE(context_, nullptr); context_->AttachBaseContext(contextDeal_); std::vector permissions; std::vector permissionsState; @@ -903,6 +908,7 @@ HWTEST_F(ContextContainerTest, RequestPermissionsFromUser_0100, Function | Mediu */ HWTEST_F(ContextContainerTest, RequestPermissionsFromUser_0200, Function | MediumTest | Level1) { + ASSERT_NE(context_, nullptr); context_->AttachBaseContext(nullptr); std::vector permissions; std::vector permissionsState; @@ -1047,6 +1053,7 @@ HWTEST_F(ContextContainerTest, GetTheme_0200, Function | MediumTest | Level1) */ HWTEST_F(ContextContainerTest, SetTheme_0100, Function | MediumTest | Level1) { + ASSERT_NE(context_, nullptr); context_->AttachBaseContext(contextDeal_); context_->SetTheme(1); } @@ -1058,6 +1065,7 @@ HWTEST_F(ContextContainerTest, SetTheme_0100, Function | MediumTest | Level1) */ HWTEST_F(ContextContainerTest, SetTheme_0200, Function | MediumTest | Level1) { + ASSERT_NE(context_, nullptr); context_->AttachBaseContext(nullptr); context_->SetTheme(1); } @@ -1157,6 +1165,7 @@ HWTEST_F(ContextContainerTest, GetPreferencesDir_0200, Function | MediumTest | L */ HWTEST_F(ContextContainerTest, SetColorMode_0100, Function | MediumTest | Level1) { + ASSERT_NE(context_, nullptr); context_->AttachBaseContext(contextDeal_); context_->SetColorMode(1); } @@ -1168,6 +1177,7 @@ HWTEST_F(ContextContainerTest, SetColorMode_0100, Function | MediumTest | Level1 */ HWTEST_F(ContextContainerTest, SetColorMode_0200, Function | MediumTest | Level1) { + ASSERT_NE(context_, nullptr); context_->AttachBaseContext(nullptr); context_->SetColorMode(1); } @@ -1406,6 +1416,7 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_UnauthUriPermission_0 { std::shared_ptr ability = std::make_shared(); std::shared_ptr context(ability); + ASSERT_NE(context, nullptr); contextDeal_->SetContext(context); context_->AttachBaseContext(contextDeal_); @@ -1420,6 +1431,7 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_UnauthUriPermission_0 */ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_UnauthUriPermission_0200, Function | MediumTest | Level3) { + ASSERT_NE(context_, nullptr); Uri urivalue(""); context_->UnauthUriPermission("permission", urivalue, 0); } @@ -1658,6 +1670,7 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_SetTheme_0100, Functi { std::shared_ptr ability = std::make_shared(); std::shared_ptr context(ability); + ASSERT_NE(context, nullptr); contextDeal_->SetContext(context); context_->AttachBaseContext(contextDeal_); context_->SetTheme(0); @@ -1670,6 +1683,7 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_SetTheme_0100, Functi */ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_SetTheme_0200, Function | MediumTest | Level3) { + ASSERT_NE(context_, nullptr); context_->SetTheme(0); } @@ -1711,6 +1725,7 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_SetPattern_0100, Func { std::shared_ptr ability = std::make_shared(); std::shared_ptr context(ability); + ASSERT_NE(context, nullptr); contextDeal_->SetContext(context); context_->AttachBaseContext(contextDeal_); @@ -1724,6 +1739,7 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_SetPattern_0100, Func */ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_SetPattern_0200, Function | MediumTest | Level3) { + ASSERT_NE(context_, nullptr); context_->SetPattern(0); } @@ -1737,6 +1753,7 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetColor_0100, Functi { std::shared_ptr ability = std::make_shared(); std::shared_ptr context(ability); + ASSERT_NE(context, nullptr); contextDeal_->SetContext(context); context_->AttachBaseContext(contextDeal_); @@ -1764,6 +1781,7 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetThemeId_0100, Func { std::shared_ptr ability = std::make_shared(); std::shared_ptr context(ability); + ASSERT_NE(context, nullptr); contextDeal_->SetContext(context); context_->AttachBaseContext(contextDeal_); diff --git a/test/unittest/frameworks_kits_appkit_native_test/context_deal_interface1_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/context_deal_interface1_test.cpp index 0143a000a8..fd64b3648f 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/context_deal_interface1_test.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/context_deal_interface1_test.cpp @@ -128,6 +128,7 @@ HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_SetTheme_0100, Functio {"Pattern1", "PatternA"}, {"Pattern2", "PatternB"}, {"Pattern3", "PatternC"} }; std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); std::shared_ptr contextDeal = std::make_shared(); + ASSERT_NE(contextDeal, nullptr); resourceManager->SetThemeById(testValue, testList); contextDeal->initResourceManager(resourceManager); contextDeal->SetTheme(testValue); @@ -144,6 +145,7 @@ HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_SetTheme_0200, Functio GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_SetTheme_0200 start"; int testValue = 1; std::shared_ptr contextDeal = std::make_shared(); + ASSERT_NE(contextDeal, nullptr); contextDeal->SetTheme(testValue); GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_SetTheme_0200 end"; } @@ -243,6 +245,7 @@ HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetTheme_0100, Functio std::map testList = { {"Theme1", "ThemeA"}, {"Theme2", "ThemeB"}, {"Theme3", "ThemeC"} }; std::shared_ptr resourceManager(Global::Resource::CreateResourceManager2()); std::shared_ptr contextDeal = std::make_shared(); + ASSERT_NE(contextDeal, nullptr); resourceManager->SetThemeById(testValue, testList); contextDeal->initResourceManager(resourceManager); std::map retVal = contextDeal->GetTheme(); @@ -268,17 +271,6 @@ HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetString_ById_0100, F GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetString_ById_0100 end"; } -/** - * @tc.number: AppExecFwk_ContextDeal_GetString_ByIdAndFormat_0100 - * @tc.name: GetString - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetString is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetString_ByIdAndFormat_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetString_ByIdAndFormat_0100 start"; - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetString_ByIdAndFormat_0100 end"; -} - /** * @tc.number: AppExecFwk_ContextDeal_GetStringArray_0100 * @tc.name: GetStringArray @@ -393,17 +385,6 @@ HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetColor_0200, Functio GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetColor_0200 end"; } -/** - * @tc.number: AppExecFwk_ContextDeal_GetThemeId_0100 - * @tc.name: GetThemeId - * @tc.desc: Test the attachbasecontext call to verify that the return value of GetThemeId is correct. - */ -HWTEST_F(ContextDealInterfaceTest, AppExecFwk_ContextDeal_GetThemeId_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetThemeId_0100 start"; - GTEST_LOG_(INFO) << "AppExecFwk_ContextDeal_GetThemeId_0100 end"; -} - /** * @tc.number: AppExecFwk_ContextDeal_GetDisplayOrientation_0100 * @tc.name: GetDisplayOrientation diff --git a/test/unittest/mission_list_test/mission_list_test.cpp b/test/unittest/mission_list_test/mission_list_test.cpp index 81b2cc3592..08f6baf1eb 100644 --- a/test/unittest/mission_list_test/mission_list_test.cpp +++ b/test/unittest/mission_list_test/mission_list_test.cpp @@ -837,6 +837,7 @@ HWTEST_F(MissionListTest, mission_list_handle_uninstall_app_001, TestSize.Level1 abilityRecord->SetAbilityState(AbilityState::INITIAL); auto mission = std::make_shared(1, abilityRecord, "name"); auto missionList = std::make_shared(); + ASSERT_NE(missionList, nullptr); missionList->missions_.push_front(mission); missionList->HandleUnInstallApp("bundle", 0); } @@ -919,6 +920,7 @@ HWTEST_F(MissionListTest, mission_list_dump_state_by_record_id_001, TestSize.Lev auto mission1 = std::make_shared(1, abilityRecord, "name"); auto mission2 = std::make_shared(1, nullptr, "name"); auto missionList = std::make_shared(); + ASSERT_NE(missionList, nullptr); std::vector info; bool isClient = false; int32_t abilityRecordId = 1; @@ -941,6 +943,7 @@ HWTEST_F(MissionListTest, mission_list_dump_list_001, TestSize.Level1) { auto mission = std::make_shared(1, nullptr, "name"); auto missionList = std::make_shared(); + ASSERT_NE(missionList, nullptr); std::vector info; bool isClient = false; missionList->missions_.push_front(nullptr); @@ -967,6 +970,7 @@ HWTEST_F(MissionListTest, mission_block_ability_by_record_id_001, TestSize.Level auto mission1 = std::make_shared(1, abilityRecord, "name"); auto mission2 = std::make_shared(1, nullptr, "name"); auto missionList = std::make_shared(); + ASSERT_NE(missionList, nullptr); std::vector info; bool isClient = false; std::vector params; diff --git a/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp b/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp index 311f810de6..1979fa1e96 100755 --- a/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp +++ b/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp @@ -55,6 +55,7 @@ void UriPermissionImplTest::TearDown() {} HWTEST_F(UriPermissionImplTest, Upms_GrantUriPermission_001, TestSize.Level1) { auto upms = std::make_shared(); + ASSERT_NE(upms, nullptr); auto uriStr = "file://com.example.test/data/storage/el2/base/haps/entry/files/test_A.txt"; Uri uri(uriStr); unsigned int flag = 0; @@ -72,6 +73,7 @@ HWTEST_F(UriPermissionImplTest, Upms_GrantUriPermission_001, TestSize.Level1) HWTEST_F(UriPermissionImplTest, Upms_GrantUriPermission_002, TestSize.Level1) { auto upms = std::make_shared(); + ASSERT_NE(upms, nullptr); auto uriStr = "file://com.example.test/data/storage/el2/base/haps/entry/files/test_A.txt"; Uri uri(uriStr); unsigned int flag = 1; @@ -89,6 +91,7 @@ HWTEST_F(UriPermissionImplTest, Upms_GrantUriPermission_002, TestSize.Level1) HWTEST_F(UriPermissionImplTest, Upms_GrantUriPermission_003, TestSize.Level1) { auto upms = std::make_shared(); + ASSERT_NE(upms, nullptr); auto uriStr = "file://com.example.test/data/storage/el2/base/haps/entry/files/test_A.txt"; Uri uri(uriStr); unsigned int flag = 2; @@ -108,6 +111,7 @@ HWTEST_F(UriPermissionImplTest, Upms_GrantUriPermission_003, TestSize.Level1) HWTEST_F(UriPermissionImplTest, Upms_GrantUriPermission_004, TestSize.Level1) { auto upms = std::make_shared(); + ASSERT_NE(upms, nullptr); auto uriStr = "file://com.example.test/data/storage/el2/base/haps/entry/files/test_A.txt"; Uri uri(uriStr); unsigned int flag = 2; @@ -129,6 +133,7 @@ HWTEST_F(UriPermissionImplTest, Upms_GrantUriPermission_004, TestSize.Level1) HWTEST_F(UriPermissionImplTest, Upms_GrantUriPermission_005, TestSize.Level1) { auto upms = std::make_shared(); + ASSERT_NE(upms, nullptr); unsigned int tmpFlag = 1; uint32_t fromTokenId = 2; uint32_t targetTokenId = 3; @@ -153,6 +158,7 @@ HWTEST_F(UriPermissionImplTest, Upms_GrantUriPermission_005, TestSize.Level1) HWTEST_F(UriPermissionImplTest, Upms_GrantUriPermission_006, TestSize.Level1) { auto upms = std::make_shared(); + ASSERT_NE(upms, nullptr); unsigned int tmpFlag = 1; uint32_t fromTokenId = 2; uint32_t targetTokenId = 3; @@ -178,6 +184,7 @@ HWTEST_F(UriPermissionImplTest, Upms_GrantUriPermission_006, TestSize.Level1) HWTEST_F(UriPermissionImplTest, Upms_GrantUriPermission_007, TestSize.Level1) { auto upms = std::make_shared(); + ASSERT_NE(upms, nullptr); unsigned int tmpFlag = 1; uint32_t fromTokenId = 2; uint32_t targetTokenId = 3; @@ -203,6 +210,7 @@ HWTEST_F(UriPermissionImplTest, Upms_GrantUriPermission_007, TestSize.Level1) HWTEST_F(UriPermissionImplTest, Upms_RevokeUriPermission_001, TestSize.Level1) { auto upms = std::make_shared(); + ASSERT_NE(upms, nullptr); unsigned int tmpFlag = 1; uint32_t fromTokenId = 2; uint32_t targetTokenId = 3; @@ -222,6 +230,7 @@ HWTEST_F(UriPermissionImplTest, Upms_RevokeUriPermission_001, TestSize.Level1) HWTEST_F(UriPermissionImplTest, Upms_RevokeUriPermission_002, TestSize.Level1) { auto upms = std::make_shared(); + ASSERT_NE(upms, nullptr); unsigned int tmpFlag = 1; uint32_t fromTokenId = 2; uint32_t targetTokenId = 3; @@ -242,6 +251,7 @@ HWTEST_F(UriPermissionImplTest, Upms_RevokeUriPermission_002, TestSize.Level1) HWTEST_F(UriPermissionImplTest, Upms_ConnectBundleManager_001, TestSize.Level1) { auto upms = std::make_shared(); + ASSERT_NE(upms, nullptr); SystemAbilityManagerClient::nullptrFlag = true; (void)upms->ConnectBundleManager(); SystemAbilityManagerClient::nullptrFlag = false; @@ -256,6 +266,7 @@ HWTEST_F(UriPermissionImplTest, Upms_ConnectBundleManager_001, TestSize.Level1) HWTEST_F(UriPermissionImplTest, Upms_ConnectBundleManager_002, TestSize.Level1) { auto upms = std::make_shared(); + ASSERT_NE(upms, nullptr); (void)upms->ConnectBundleManager(); } @@ -268,6 +279,7 @@ HWTEST_F(UriPermissionImplTest, Upms_ConnectBundleManager_002, TestSize.Level1) HWTEST_F(UriPermissionImplTest, Upms_ConnectStorageManager_001, TestSize.Level1) { auto upms = std::make_shared(); + ASSERT_NE(upms, nullptr); SystemAbilityManagerClient::nullptrFlag = true; (void)upms->ConnectStorageManager(); SystemAbilityManagerClient::nullptrFlag = false; @@ -282,6 +294,7 @@ HWTEST_F(UriPermissionImplTest, Upms_ConnectStorageManager_001, TestSize.Level1) HWTEST_F(UriPermissionImplTest, Upms_ConnectStorageManager_002, TestSize.Level1) { auto upms = std::make_shared(); + ASSERT_NE(upms, nullptr); (void)upms->ConnectStorageManager(); } } // namespace AAFwk diff --git a/tools/test/unittest/ability_delegator/shell_command_executor_test.cpp b/tools/test/unittest/ability_delegator/shell_command_executor_test.cpp index 3702bf63d0..5586417869 100644 --- a/tools/test/unittest/ability_delegator/shell_command_executor_test.cpp +++ b/tools/test/unittest/ability_delegator/shell_command_executor_test.cpp @@ -86,6 +86,7 @@ HWTEST_F(ShellCommandExecutorTest, ShellCommandExecutor_DoWork_0300, TestSize.Le { GTEST_LOG_(INFO) << "ShellCommandExecutor_DoWork_0300 start"; std::shared_ptr handler_ = std::make_shared(); + ASSERT_NE(handler_, nullptr); auto task = []() { GTEST_LOG_(INFO) << "ShellCommandExecutor_DoWork_0300 task called"; }; handler_->PostTask(task, 1000); Command_->cmd_ = CMD; @@ -102,6 +103,7 @@ HWTEST_F(ShellCommandExecutorTest, ShellCommandExecutor_DoWork_0400, TestSize.Le { GTEST_LOG_(INFO) << "ShellCommandExecutor_DoWork_0400 start"; std::shared_ptr handler_ = std::make_shared(); + ASSERT_NE(handler_, nullptr); auto task = []() { GTEST_LOG_(INFO) << "ShellCommandExecutor_DoWork_0400 task called"; }; handler_->PostTask(task, 1000); Command_->cmd_ = "CMD12"; diff --git a/tools/test/unittest/ability_delegator/test_observer_proxy_test.cpp b/tools/test/unittest/ability_delegator/test_observer_proxy_test.cpp index 38f1166aec..c77de31340 100644 --- a/tools/test/unittest/ability_delegator/test_observer_proxy_test.cpp +++ b/tools/test/unittest/ability_delegator/test_observer_proxy_test.cpp @@ -144,6 +144,7 @@ HWTEST_F(TestObserverProxyTest, Test_Observer_Proxy_Test_0200, TestSize.Level1) { HILOG_INFO("Test_Observer_Proxy_Test_0200 start"); OHOS::sptr object = new OHOS::MockIRemoteObject(); + ASSERT_NE(object, nullptr); TestObserverProxy testObserverProxy(object); testObserverProxy.TestStatus(CMD.c_str(), 0); HILOG_INFO("Test_Observer_Proxy_Test_0200 end"); @@ -158,6 +159,7 @@ HWTEST_F(TestObserverProxyTest, Test_Observer_Proxy_Test_0300, TestSize.Level1) { HILOG_INFO("Test_Observer_Proxy_Test_0300 start"); OHOS::sptr object = new OHOS::MockIRemoteObject(); + ASSERT_NE(object, nullptr); TestObserverProxy testObserverProxy(object); testObserverProxy.TestFinished(CMD.c_str(), 0); HILOG_INFO("Test_Observer_Proxy_Test_0300 end"); diff --git a/tools/test/unittest/ability_delegator/test_observer_test.cpp b/tools/test/unittest/ability_delegator/test_observer_test.cpp index 963b06ef9f..16c767d5ea 100644 --- a/tools/test/unittest/ability_delegator/test_observer_test.cpp +++ b/tools/test/unittest/ability_delegator/test_observer_test.cpp @@ -133,6 +133,7 @@ HWTEST_F(TestObserverTest, Test_Observer_Test_0400, Function | MediumTest | Leve HWTEST_F(TestObserverTest, Test_Observer_Test_0500, Function | MediumTest | Level1) { HILOG_INFO("Test_Observer_Test_0500 is called"); - TestObserver observer; - observer.TestStatus(MSG.c_str(), RESULT_CODE); + std::shared_ptr observer = std::make_shared(); + ASSERT_NE(observer, nullptr); + observer->TestStatus(MSG.c_str(), RESULT_CODE); }