From d1c97fb8a3b206345b8a6ed48f53f0601d0f0a1f Mon Sep 17 00:00:00 2001 From: wuminjie Date: Wed, 6 Aug 2025 10:02:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=B7=AE=E5=BC=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wuminjie --- .../src/system_ability_mgr_load_test.cpp | 36 +++++++++- .../src/system_ability_mgr_new_test.cpp | 72 ++++++++++++++++++- .../src/system_ability_mgr_stub_load_test.cpp | 11 +++ ...stem_ability_state_scheduler_proc_test.cpp | 11 +++ 4 files changed, 127 insertions(+), 3 deletions(-) diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_load_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_load_test.cpp index 5c7f8e70..ab171cd9 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_load_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_load_test.cpp @@ -102,6 +102,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility001, TestSize.Level0) DTEST_LOG << "LoadSystemAbility001 begin" << std::endl; int32_t systemAbilityId = TEST_EXCEPTION_LOW_SA_ID; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t result = saMgr->LoadSystemAbility(systemAbilityId, nullptr); EXPECT_TRUE(result != ERR_OK); @@ -118,6 +119,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility002, TestSize.Level0) DTEST_LOG << "LoadSystemAbility002 begin" << std::endl; int32_t systemAbilityId = TEST_EXCEPTION_HIGH_SA_ID; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t result = saMgr->LoadSystemAbility(systemAbilityId, nullptr); EXPECT_TRUE(result != ERR_OK); @@ -134,6 +136,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility003, TestSize.Level0) DTEST_LOG << "LoadSystemAbility003 begin" << std::endl; int32_t systemAbilityId = DISTRIBUTED_SCHED_TEST_SO_ID; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t result = saMgr->LoadSystemAbility(systemAbilityId, nullptr); EXPECT_TRUE(result != ERR_OK); @@ -150,6 +153,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility004, TestSize.Level0) DTEST_LOG << "LoadSystemAbility004 begin" << std::endl; int32_t systemAbilityId = DISTRIBUTED_SCHED_TEST_SO_ID; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr callback = new SystemAbilityLoadCallbackMock(); int32_t result = saMgr->LoadSystemAbility(systemAbilityId, callback); @@ -166,6 +170,8 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility005, TestSize.Level1) { DTEST_LOG << "LoadSystemAbility005 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); MessageParcel data; MessageParcel reply; MessageOption option; @@ -184,6 +190,8 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility006, TestSize.Level1) { DTEST_LOG << "LoadSystemAbility006 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); MessageParcel data; data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN); MessageParcel reply; @@ -203,6 +211,8 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility007, TestSize.Level1) { DTEST_LOG << "LoadSystemAbility007 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); MessageParcel data; data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN); data.WriteInt32(TEST_EXCEPTION_HIGH_SA_ID); @@ -223,6 +233,8 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility008, TestSize.Level1) { DTEST_LOG << "LoadSystemAbility008 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); MessageParcel data; data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN); data.WriteInt32(DISTRIBUTED_SCHED_TEST_SO_ID); @@ -243,6 +255,8 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility009, TestSize.Level1) { DTEST_LOG << "LoadSystemAbility009 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); MessageParcel data; data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN); data.WriteInt32(DISTRIBUTED_SCHED_TEST_SO_ID); @@ -267,6 +281,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility010, TestSize.Level3) DTEST_LOG << "LoadSystemAbility010 begin" << std::endl; sptr saMgr = new SystemAbilityManager; InitSaMgr(saMgr); + saMgr->saProfileMap_.clear(); sptr callback = new SystemAbilityLoadCallbackMock(); int32_t ret = saMgr->LoadSystemAbility(SAID, callback); EXPECT_EQ(ret, PROFILE_NOT_EXIST); @@ -283,6 +298,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility011, TestSize.Level3) { DTEST_LOG << "LoadSystemAbility011 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr callback = new SystemAbilityLoadCallbackMock(); int32_t ret = saMgr->LoadSystemAbility(-1, callback); @@ -299,6 +315,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, OnLoadSystemAbilitySuccess001, TestSize.Level { DTEST_LOG << "OnLoadSystemAbilitySuccess001 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr callback = new SystemAbilityLoadCallbackMock(); saMgr->NotifySystemAbilityLoaded(DISTRIBUTED_SCHED_TEST_SO_ID, nullptr, nullptr); @@ -315,7 +332,8 @@ HWTEST_F(SystemAbilityMgrLoadTest, OnLoadSystemAbilitySuccess002, TestSize.Level { DTEST_LOG << "OnLoadSystemAbilitySuccess002 begin" << std::endl; sptr saMgr = new SystemAbilityManager; - saMgr->Init(); + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); sptr callback = new SystemAbilityLoadCallbackMock(); saMgr->NotifySystemAbilityLoaded(DISTRIBUTED_SCHED_TEST_SO_ID, nullptr, callback); EXPECT_TRUE(callback->GetSystemAbilityId() == DISTRIBUTED_SCHED_TEST_SO_ID); @@ -332,6 +350,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, OnLoadSystemAbilitySuccess003, TestSize.Level { DTEST_LOG << "OnLoadSystemAbilitySuccess003 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr callback = new SystemAbilityLoadCallbackMock(); sptr remoteObject = new TestTransactionService(); @@ -350,6 +369,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, OnLoadSystemAbilitySuccess004, TestSize.Level { DTEST_LOG << " OnLoadSystemAbilitySuccess004 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr callback = new SystemAbilityLoadCallbackMock(); saMgr->NotifySystemAbilityLoaded(DISTRIBUTED_SCHED_TEST_SO_ID, nullptr, nullptr); @@ -366,6 +386,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, ReportLoadSAOverflow001, TestSize.Level1) { DTEST_LOG << "ReportLoadSAOverflow001 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + ASSERT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); for (int i = 0; i < OVERFLOW_TIME; ++i) { sptr callback = new SystemAbilityLoadCallbackMock(); @@ -704,6 +725,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, UnloadSystemAbility002, TestSize.Level3) { DTEST_LOG << "UnloadSystemAbility002 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t systemAbilityId = 1; CommonSaProfile saProfile; @@ -726,6 +748,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, UnloadSystemAbility003, TestSize.Level3) DTEST_LOG << " UnloadSystemAbility003 begin" << std::endl; SamMockPermission::MockProcess("memmgrservice"); sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); CommonSaProfile saProfile; saProfile.process = u"memmgrservice"; @@ -747,6 +770,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, CancelUnloadSystemAbility001, TestSize.Level3 { DTEST_LOG << " CancelUnloadSystemAbility001 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t systemAbilityId = -1; int32_t ret = saMgr->CancelUnloadSystemAbility(systemAbilityId); @@ -764,6 +788,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, CancelUnloadSystemAbility002, TestSize.Level3 { DTEST_LOG << " CancelUnloadSystemAbility002 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t systemAbilityId = 1; int32_t ret = saMgr->CancelUnloadSystemAbility(systemAbilityId); @@ -781,6 +806,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, CancelUnloadSystemAbility003, TestSize.Level3 { DTEST_LOG << " CancelUnloadSystemAbility003 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); CommonSaProfile saProfile; saMgr->saProfileMap_[1] = saProfile; @@ -801,6 +827,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, CancelUnloadSystemAbility004, TestSize.Level3 DTEST_LOG << " CancelUnloadSystemAbility004 begin" << std::endl; SamMockPermission::MockProcess("mockProcess"); sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); CommonSaProfile saProfile; saProfile.process = u"mockProcess"; @@ -822,6 +849,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, CancelUnloadSystemAbility005, TestSize.Level3 DTEST_LOG << " CancelUnloadSystemAbility005 begin" << std::endl; SamMockPermission::MockProcess("mockProcess"); sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); CommonSaProfile saProfile; saProfile.process = u"mockProcess"; @@ -844,6 +872,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, CancelUnloadSystemAbility006, TestSize.Level3 { DTEST_LOG << " CancelUnloadSystemAbility006 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); uint32_t accessToken = IPCSkeleton::GetCallingTokenID(); Security::AccessToken::NativeTokenInfo nativeTokenInfo; @@ -870,6 +899,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, DoUnloadSystemAbility001, TestSize.Level3) { DTEST_LOG << "DoUnloadSystemAbility001 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::u16string procName = u"foundation"; int32_t said = 401; @@ -899,6 +929,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, DoUnloadSystemAbility002, TestSize.Level3) { DTEST_LOG << "DoUnloadSystemAbility002 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); ISystemAbilityManager::SAExtraProp saExtraProp(false, 0, u"", u""); int32_t systemAbilityId = DISTRIBUTED_SCHED_TEST_TT_ID; @@ -925,6 +956,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, UnloadAllIdleSystemAbility001, TestSize.Level DTEST_LOG << "UnloadAllIdleSystemAbility001 begin" << std::endl; SamMockPermission::MockProcess("memmgrservice"); sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t ret = saMgr->UnloadAllIdleSystemAbility(); EXPECT_EQ(ret, ERR_OK); @@ -942,6 +974,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, UnloadAllIdleSystemAbility002, TestSize.Level DTEST_LOG << "UnloadAllIdleSystemAbility002 begin" << std::endl; SamMockPermission::MockProcess("memmgrservice"); sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); saMgr->abilityStateScheduler_ = nullptr; int32_t ret = saMgr->UnloadAllIdleSystemAbility(); @@ -960,6 +993,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, UnloadAllIdleSystemAbility003, TestSize.Level { DTEST_LOG << "UnloadAllIdleSystemAbility003 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t ret = saMgr->UnloadAllIdleSystemAbility(); EXPECT_EQ(ret, ERR_PERMISSION_DENIED); diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_new_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_new_test.cpp index 9fcf2cba..b07689d7 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_new_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_new_test.cpp @@ -200,6 +200,8 @@ HWTEST_F(SystemAbilityMgrNewTest, GetLocalNodeId001, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, ReportGetSAPeriodically001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); uint64_t pid_said = 123; int32_t count = 1; saMgr->saFrequencyMap_[pid_said] = count; @@ -216,6 +218,7 @@ HWTEST_F(SystemAbilityMgrNewTest, StartDynamicSystemProcess001, TestSize.Level3) { cout << "begin StartDynamicSystemProcess001 "<< endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::u16string invalidProcess = u"1234567890123456789012345678901234567890123456789" "01234567890123456789012345678901234567890123456"; @@ -233,6 +236,7 @@ HWTEST_F(SystemAbilityMgrNewTest, StartDynamicSystemProcess001, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, GetSystemAbilityWithDevice001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::string deviceId = ""; auto ability = saMgr->GetSystemAbility(TEST_EXCEPTION_LOW_SA_ID, deviceId); @@ -256,6 +260,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetSystemAbilityWithDevice001, TestSize.Level3 HWTEST_F(SystemAbilityMgrNewTest, GetSystemAbilityFromRemote001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); auto ability = saMgr->GetSystemAbilityFromRemote(TEST_EXCEPTION_LOW_SA_ID); EXPECT_EQ(ability, nullptr); @@ -269,6 +274,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetSystemAbilityFromRemote001, TestSize.Level3 HWTEST_F(SystemAbilityMgrNewTest, GetSystemAbilityFromRemote002, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); auto ability = saMgr->GetSystemAbilityFromRemote(TEST_SYSTEM_ABILITY1); EXPECT_EQ(ability, nullptr); @@ -282,6 +288,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetSystemAbilityFromRemote002, TestSize.Level3 HWTEST_F(SystemAbilityMgrNewTest, GetSystemAbilityFromRemote003, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); SAInfo saInfo; saMgr->abilityMap_[1] = saInfo; @@ -298,6 +305,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetSystemAbilityFromRemote003, TestSize.Level3 HWTEST_F(SystemAbilityMgrNewTest, GetSystemAbilityFromRemote004, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); SAInfo saInfo; saInfo.isDistributed = true; @@ -317,6 +325,8 @@ HWTEST_F(SystemAbilityMgrNewTest, GetSystemAbilityFromRemote004, TestSize.Level3 HWTEST_F(SystemAbilityMgrNewTest, GetDBinder001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); sptr result = saMgr->GetDBinder(); EXPECT_TRUE(result == nullptr); } @@ -350,6 +360,7 @@ HWTEST_F(SystemAbilityMgrNewTest, NotifyRpcLoadCompleted001, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, NotifyRpcLoadCompleted002, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr testAbility = new TestTransactionService(); saMgr->NotifyRpcLoadCompleted("", 1, testAbility); @@ -383,7 +394,8 @@ HWTEST_F(SystemAbilityMgrNewTest, Dump001, TestSize.Level3) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; - saMgr->abilityStateScheduler_ = std::make_shared(); + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); vector args; args.push_back(u"test_name"); int32_t result = saMgr->Dump(1, args); @@ -401,7 +413,8 @@ HWTEST_F(SystemAbilityMgrNewTest, Dump002, TestSize.Level3) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; - saMgr->abilityStateScheduler_ = std::make_shared(); + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); vector args; vector argsWithStr8; args.push_back(u"test_name"); @@ -421,6 +434,8 @@ HWTEST_F(SystemAbilityMgrNewTest, Dump003, TestSize.Level3) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); saMgr->abilityStateScheduler_ = std::make_shared(); vector args; args.push_back(u"--ipc"); @@ -440,6 +455,8 @@ HWTEST_F(SystemAbilityMgrNewTest, Dump004, TestSize.Level3) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); saMgr->abilityStateScheduler_ = std::make_shared(); vector args; args.push_back(u"--ffrt"); @@ -458,6 +475,8 @@ HWTEST_F(SystemAbilityMgrNewTest, Dump004, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, AddSamgrToAbilityMap001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); saMgr->AddSamgrToAbilityMap(); vector args; args.push_back(u"test_name"); @@ -474,6 +493,7 @@ HWTEST_F(SystemAbilityMgrNewTest, AddSamgrToAbilityMap001, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, GetCommonEventExtraIdList001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr commonEventCollect = new CommonEventCollect(saMgr->collectManager_); commonEventCollect->workHandler_ = std::make_shared(commonEventCollect); @@ -521,6 +541,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetCommonEventExtraIdList001, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, RemoveWhiteCommonEvent001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); saMgr->workHandler_ = make_shared("workHandler"); saMgr->CleanFfrt(); saMgr->collectManager_ = sptr(new DeviceStatusCollectManager()); @@ -543,6 +564,7 @@ HWTEST_F(SystemAbilityMgrNewTest, RemoveWhiteCommonEvent001, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, SetFfrt001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); saMgr->SetFfrt(); EXPECT_NE(saMgr->collectManager_, nullptr); @@ -558,6 +580,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetRunningSaExtensionInfoList001, TestSize.Lev { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); const int32_t maxLoop = 4; map saProfileMapTmp; @@ -587,6 +610,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetRunningSaExtensionInfoList002, TestSize.Lev { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); const int32_t maxLoop = 4; map saProfileMapTmp; @@ -627,6 +651,8 @@ HWTEST_F(SystemAbilityMgrNewTest, GetRunningSaExtensionInfoList002, TestSize.Lev HWTEST_F(SystemAbilityMgrNewTest, CheckSystemAbility006, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); int32_t systemAbilityId = -1; bool isExist; sptr ret = saMgr->CheckSystemAbility(systemAbilityId, isExist); @@ -642,6 +668,7 @@ HWTEST_F(SystemAbilityMgrNewTest, CheckSystemAbility006, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, RemoveSystemAbility005, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); const sptr ability = nullptr; int32_t ret = saMgr->RemoveSystemAbility(ability); @@ -656,6 +683,7 @@ HWTEST_F(SystemAbilityMgrNewTest, RemoveSystemAbility005, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, AddSystemAbility006, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t systemAbilityId = -1; const sptr ability; @@ -672,6 +700,7 @@ HWTEST_F(SystemAbilityMgrNewTest, AddSystemAbility006, TestSize.Level1) HWTEST_F(SystemAbilityMgrNewTest, AddSystemAbility007, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t systemAbilityId = -1; const sptr ability; @@ -689,6 +718,8 @@ HWTEST_F(SystemAbilityMgrNewTest, AddSystemAbility007, TestSize.Level1) HWTEST_F(SystemAbilityMgrNewTest, GetSystemProcess001, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); std::u16string procName; sptr ret = saMgr->GetSystemProcess(procName); EXPECT_EQ(ret, nullptr); @@ -702,6 +733,8 @@ HWTEST_F(SystemAbilityMgrNewTest, GetSystemProcess001, TestSize.Level1) HWTEST_F(SystemAbilityMgrNewTest, GetSystemProcessInfo003, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); int32_t systemAbilityId = 0; SystemProcessInfo systemProcessInfo; int32_t ret = saMgr->GetSystemProcessInfo(systemAbilityId, systemProcessInfo); @@ -716,6 +749,8 @@ HWTEST_F(SystemAbilityMgrNewTest, GetSystemProcessInfo003, TestSize.Level1) HWTEST_F(SystemAbilityMgrNewTest, IsModuleUpdate001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); bool ret = saMgr->IsModuleUpdate(SAID); EXPECT_FALSE(ret); } @@ -728,6 +763,8 @@ HWTEST_F(SystemAbilityMgrNewTest, IsModuleUpdate001, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IsModuleUpdate002, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); CommonSaProfile saprofile; saMgr->saProfileMap_[saprofile.saId] = saprofile; bool ret = saMgr->IsModuleUpdate(saprofile.saId); @@ -742,6 +779,8 @@ HWTEST_F(SystemAbilityMgrNewTest, IsModuleUpdate002, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IsModuleUpdate003, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); CommonSaProfile saprofile; saprofile.moduleUpdate = true; saMgr->saProfileMap_[saprofile.saId] = saprofile; @@ -758,6 +797,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetExtensionSaIdsInner001, TestSize.Level3) { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); MessageParcel data; MessageParcel reply; @@ -774,6 +814,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetExtensionSaIdsInner002, TestSize.Level3) { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); MessageParcel data; MessageParcel reply; @@ -798,6 +839,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetExtensionSaIdsInner003, TestSize.Level3) { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); const int32_t maxLoop = 4; map saProfileMapTmp; @@ -830,6 +872,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetExtensionRunningSaListInner001, TestSize.Le { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); MessageParcel data; MessageParcel reply; @@ -846,6 +889,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetExtensionRunningSaListInner002, TestSize.Le { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); MessageParcel data; MessageParcel reply; @@ -870,6 +914,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetExtensionRunningSaListInner003, TestSize.Le { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); const int32_t maxLoop = 4; map saProfileMapTmp; @@ -905,6 +950,8 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpProc001, TestSize.Level2) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); int32_t cmd = -1; int32_t fd = 1; std::vector args; @@ -923,6 +970,8 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpProc002, TestSize.Level2) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); int32_t cmd = -1; int32_t fd = 1; std::vector args; @@ -942,6 +991,8 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpProc003, TestSize.Level2) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); int32_t cmd = -1; int32_t fd = 1; std::vector args; @@ -961,6 +1012,8 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpProc004, TestSize.Level2) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); int32_t cmd = -1; int32_t fd = 1; std::vector args; @@ -979,6 +1032,8 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpProc004, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IpcStatSamgrProc001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); int32_t cmd = IPC_STAT_CMD_START - 1; int32_t fd = 1; bool ret = saMgr->IpcStatSamgrProc(fd, cmd); @@ -996,6 +1051,8 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcStatSamgrProc001, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IpcStatSamgrProc002, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); int32_t cmd = IPC_STAT_CMD_START; int32_t dmd = IPC_STAT_CMD_STOP; int32_t emd = IPC_STAT_CMD_GET; @@ -1018,6 +1075,8 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcStatSamgrProc002, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IpcDumpAllProcess001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); int32_t cmd = IPC_STAT_CMD_START; int32_t fd = 1; bool ret = true; @@ -1033,6 +1092,8 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpAllProcess001, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IpcDumpSamgrProcess001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); int32_t cmd = 4; int32_t fd = 1; bool ret = true; @@ -1049,6 +1110,8 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpSamgrProcess001, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IpcDumpSingleProcess001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); int32_t cmd = IPC_STAT_CMD_START; int32_t fd = 1; bool ret = true; @@ -1070,6 +1133,8 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpSingleProcess001, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, DoLoadForPerf001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); saMgr->abilityStateScheduler_ = std::make_shared(); CommonSaProfile saProfile; saProfile.process = u"memmgrservice"; @@ -1087,6 +1152,8 @@ HWTEST_F(SystemAbilityMgrNewTest, DoLoadForPerf001, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IsDistributedSystemAbility001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); bool res = saMgr->IsDistributedSystemAbility(-1); EXPECT_FALSE(res); CommonSaProfile saProfile; @@ -1109,6 +1176,7 @@ HWTEST_F(SystemAbilityMgrNewTest, RegisterDistribute001, TestSize.Level2) DTEST_LOG<<"RegisterDistribute001 BEGIN"< saMgr = new SystemAbilityManager(); EXPECT_FALSE(saMgr == nullptr); + InitSaMgr(saMgr); saMgr->Init(); saMgr->isDbinderServiceInit_ = false; saMgr->distributedSaList_.push_back(softBusServerSaID); diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_stub_load_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_stub_load_test.cpp index 7435eddd..bb43b9c5 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_stub_load_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_stub_load_test.cpp @@ -41,6 +41,17 @@ const string DEFAULT_LOAD_NAME = "loadevent"; constexpr uint32_t SAID = 1499; constexpr int64_t DEFAULT_EVENTID = 0; constexpr int32_t INVALID_SAID = -1; +void InitSaMgr(sptr& saMgr) +{ + saMgr->abilityDeath_ = sptr(new AbilityDeathRecipient()); + saMgr->systemProcessDeath_ = sptr(new SystemProcessDeathRecipient()); + saMgr->abilityStatusDeath_ = sptr(new AbilityStatusDeathRecipient()); + saMgr->abilityCallbackDeath_ = sptr(new AbilityCallbackDeathRecipient()); + saMgr->remoteCallbackDeath_ = sptr(new RemoteCallbackDeathRecipient()); + saMgr->workHandler_ = make_shared("workHandler"); + saMgr->collectManager_ = sptr(new DeviceStatusCollectManager()); + saMgr->abilityStateScheduler_ = std::make_shared(); +} } void SystemAbilityMgrStubLoadTest::SetUpTestCase() diff --git a/services/samgr/native/test/unittest/src/system_ability_state_scheduler_proc_test.cpp b/services/samgr/native/test/unittest/src/system_ability_state_scheduler_proc_test.cpp index 67b7555a..c55ace60 100644 --- a/services/samgr/native/test/unittest/src/system_ability_state_scheduler_proc_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_state_scheduler_proc_test.cpp @@ -39,6 +39,17 @@ constexpr int32_t STATENUMS = 1; const std::u16string process = u"test"; const std::u16string process_invalid = u"test_invalid"; const std::string LOCAL_DEVICE = "local"; +void InitSaMgr(sptr& saMgr) +{ + saMgr->abilityDeath_ = sptr(new AbilityDeathRecipient()); + saMgr->systemProcessDeath_ = sptr(new SystemProcessDeathRecipient()); + saMgr->abilityStatusDeath_ = sptr(new AbilityStatusDeathRecipient()); + saMgr->abilityCallbackDeath_ = sptr(new AbilityCallbackDeathRecipient()); + saMgr->remoteCallbackDeath_ = sptr(new RemoteCallbackDeathRecipient()); + saMgr->workHandler_ = make_shared("workHandler"); + saMgr->collectManager_ = sptr(new DeviceStatusCollectManager()); + saMgr->abilityStateScheduler_ = std::make_shared(); +} } void SystemAbilityStateSchedulerProcTest::SetUpTestCase() -- Gitee From 97fd624d834330accae34fb655858168c019f413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=95=8F=E6=9D=B0?= Date: Wed, 6 Aug 2025 08:17:29 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BB=A3=E7=A2=BC=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 吴敏杰 --- .../src/system_ability_mgr_load_test.cpp | 6 ------ .../src/system_ability_mgr_new_test.cpp | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_load_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_load_test.cpp index ab171cd9..a9a10949 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_load_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_load_test.cpp @@ -171,7 +171,6 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility005, TestSize.Level1) DTEST_LOG << "LoadSystemAbility005 begin" << std::endl; sptr saMgr = new SystemAbilityManager; EXPECT_TRUE(saMgr != nullptr); - InitSaMgr(saMgr); MessageParcel data; MessageParcel reply; MessageOption option; @@ -191,7 +190,6 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility006, TestSize.Level1) DTEST_LOG << "LoadSystemAbility006 begin" << std::endl; sptr saMgr = new SystemAbilityManager; EXPECT_TRUE(saMgr != nullptr); - InitSaMgr(saMgr); MessageParcel data; data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN); MessageParcel reply; @@ -212,7 +210,6 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility007, TestSize.Level1) DTEST_LOG << "LoadSystemAbility007 begin" << std::endl; sptr saMgr = new SystemAbilityManager; EXPECT_TRUE(saMgr != nullptr); - InitSaMgr(saMgr); MessageParcel data; data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN); data.WriteInt32(TEST_EXCEPTION_HIGH_SA_ID); @@ -234,7 +231,6 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility008, TestSize.Level1) DTEST_LOG << "LoadSystemAbility008 begin" << std::endl; sptr saMgr = new SystemAbilityManager; EXPECT_TRUE(saMgr != nullptr); - InitSaMgr(saMgr); MessageParcel data; data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN); data.WriteInt32(DISTRIBUTED_SCHED_TEST_SO_ID); @@ -256,7 +252,6 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility009, TestSize.Level1) DTEST_LOG << "LoadSystemAbility009 begin" << std::endl; sptr saMgr = new SystemAbilityManager; EXPECT_TRUE(saMgr != nullptr); - InitSaMgr(saMgr); MessageParcel data; data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN); data.WriteInt32(DISTRIBUTED_SCHED_TEST_SO_ID); @@ -298,7 +293,6 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility011, TestSize.Level3) { DTEST_LOG << "LoadSystemAbility011 begin" << std::endl; sptr saMgr = new SystemAbilityManager; - EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr callback = new SystemAbilityLoadCallbackMock(); int32_t ret = saMgr->LoadSystemAbility(-1, callback); diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_new_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_new_test.cpp index b07689d7..153125a3 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_new_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_new_test.cpp @@ -187,6 +187,8 @@ void SystemAbilityMgrNewTest::TearDown() HWTEST_F(SystemAbilityMgrNewTest, GetLocalNodeId001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); string ret = saMgr->GetLocalNodeId(); EXPECT_EQ(ret, ""); } @@ -261,7 +263,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetSystemAbilityFromRemote001, TestSize.Level3 { sptr saMgr = new SystemAbilityManager; EXPECT_TRUE(saMgr != nullptr); - InitSaMgr(saMgr); + saMgr->Init(); auto ability = saMgr->GetSystemAbilityFromRemote(TEST_EXCEPTION_LOW_SA_ID); EXPECT_EQ(ability, nullptr); } @@ -341,6 +343,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetDBinder001, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, NotifyRpcLoadCompleted001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); #ifdef SAMGR_ENABLE_DELAY_DBINDER saMgr->InitDbinderService(); @@ -348,6 +351,7 @@ HWTEST_F(SystemAbilityMgrNewTest, NotifyRpcLoadCompleted001, TestSize.Level3) sptr testAbility = new TestTransactionService(); saMgr->workHandler_ = nullptr; saMgr->NotifyRpcLoadCompleted("", 1, testAbility); + EXPECT_TRUE(saMgr != nullptr); } /** @@ -375,12 +379,14 @@ HWTEST_F(SystemAbilityMgrNewTest, NotifyRpcLoadCompleted002, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, NotifyRpcLoadCompleted003, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); #ifdef SAMGR_ENABLE_DELAY_DBINDER saMgr->InitDbinderService(); #endif sptr testAbility = new TestTransactionService(); saMgr->NotifyRpcLoadCompleted("", 1, testAbility); + EXPECT_TRUE(saMgr != nullptr); } /** @@ -436,7 +442,6 @@ HWTEST_F(SystemAbilityMgrNewTest, Dump003, TestSize.Level3) sptr saMgr = new SystemAbilityManager; EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); - saMgr->abilityStateScheduler_ = std::make_shared(); vector args; args.push_back(u"--ipc"); args.push_back(u"all"); @@ -457,7 +462,6 @@ HWTEST_F(SystemAbilityMgrNewTest, Dump004, TestSize.Level3) sptr saMgr = new SystemAbilityManager; EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); - saMgr->abilityStateScheduler_ = std::make_shared(); vector args; args.push_back(u"--ffrt"); args.push_back(u"99999"); @@ -542,13 +546,13 @@ HWTEST_F(SystemAbilityMgrNewTest, RemoveWhiteCommonEvent001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; EXPECT_TRUE(saMgr != nullptr); + InitSaMgr(saMgr); saMgr->workHandler_ = make_shared("workHandler"); saMgr->CleanFfrt(); saMgr->collectManager_ = sptr(new DeviceStatusCollectManager()); saMgr->CleanFfrt(); saMgr->abilityStateScheduler_ = std::make_shared(); saMgr->CleanFfrt(); - InitSaMgr(saMgr); const std::u16string name; saMgr->NotifyRemoteSaDied(name); saMgr->RemoveWhiteCommonEvent(); @@ -734,7 +738,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetSystemProcessInfo003, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; EXPECT_TRUE(saMgr != nullptr); - InitSaMgr(saMgr); + saMgr->abilityStateScheduler_ = nullptr; int32_t systemAbilityId = 0; SystemProcessInfo systemProcessInfo; int32_t ret = saMgr->GetSystemProcessInfo(systemAbilityId, systemProcessInfo); @@ -751,6 +755,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IsModuleUpdate001, TestSize.Level2) sptr saMgr = new SystemAbilityManager; EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); + saMgr->saProfileMap_.clear(); bool ret = saMgr->IsModuleUpdate(SAID); EXPECT_FALSE(ret); } @@ -765,6 +770,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IsModuleUpdate002, TestSize.Level2) sptr saMgr = new SystemAbilityManager; EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); + saMgr->saProfileMap_.clear(); CommonSaProfile saprofile; saMgr->saProfileMap_[saprofile.saId] = saprofile; bool ret = saMgr->IsModuleUpdate(saprofile.saId); @@ -781,6 +787,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IsModuleUpdate003, TestSize.Level2) sptr saMgr = new SystemAbilityManager; EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); + saMgr->saProfileMap_.clear(); CommonSaProfile saprofile; saprofile.moduleUpdate = true; saMgr->saProfileMap_[saprofile.saId] = saprofile; -- Gitee