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 1cd777e8ad3d48a43ca9e3867bac196e5ab8dcb7..705f2ea630424fdba8ea7d61b9417e993eac3b9b 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 @@ -87,7 +87,9 @@ void SystemAbilityMgrLoadTest::SetUp() void SystemAbilityMgrLoadTest::TearDown() { - sptr saMgr = SystemAbilityManager::GetInstance(); + sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); + InitSaMgr(saMgr); saMgr->CleanFfrt(); DTEST_LOG << "TearDown" << std::endl; } @@ -102,6 +104,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_NE(saMgr, nullptr); InitSaMgr(saMgr); int32_t result = saMgr->LoadSystemAbility(systemAbilityId, nullptr); EXPECT_TRUE(result != ERR_OK); @@ -118,6 +121,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_NE(saMgr, nullptr); InitSaMgr(saMgr); int32_t result = saMgr->LoadSystemAbility(systemAbilityId, nullptr); EXPECT_TRUE(result != ERR_OK); @@ -134,6 +138,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_NE(saMgr, nullptr); InitSaMgr(saMgr); int32_t result = saMgr->LoadSystemAbility(systemAbilityId, nullptr); EXPECT_TRUE(result != ERR_OK); @@ -150,6 +155,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_NE(saMgr, nullptr); InitSaMgr(saMgr); sptr callback = new SystemAbilityLoadCallbackMock(); int32_t result = saMgr->LoadSystemAbility(systemAbilityId, callback); @@ -166,6 +172,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility005, TestSize.Level1) { DTEST_LOG << "LoadSystemAbility005 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); MessageParcel data; MessageParcel reply; MessageOption option; @@ -184,6 +191,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility006, TestSize.Level1) { DTEST_LOG << "LoadSystemAbility006 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); MessageParcel data; data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN); MessageParcel reply; @@ -203,6 +211,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility007, TestSize.Level1) { DTEST_LOG << "LoadSystemAbility007 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); MessageParcel data; data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN); data.WriteInt32(TEST_EXCEPTION_HIGH_SA_ID); @@ -223,6 +232,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility008, TestSize.Level1) { DTEST_LOG << "LoadSystemAbility008 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); MessageParcel data; data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN); data.WriteInt32(DISTRIBUTED_SCHED_TEST_SO_ID); @@ -243,6 +253,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility009, TestSize.Level1) { DTEST_LOG << "LoadSystemAbility009 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); MessageParcel data; data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN); data.WriteInt32(DISTRIBUTED_SCHED_TEST_SO_ID); @@ -266,6 +277,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility010, TestSize.Level3) { DTEST_LOG << "LoadSystemAbility010 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); sptr callback = new SystemAbilityLoadCallbackMock(); int32_t ret = saMgr->LoadSystemAbility(SAID, callback); @@ -283,6 +295,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbility011, TestSize.Level3) { DTEST_LOG << "LoadSystemAbility011 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); sptr callback = new SystemAbilityLoadCallbackMock(); int32_t ret = saMgr->LoadSystemAbility(-1, callback); @@ -299,6 +312,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, OnLoadSystemAbilitySuccess001, TestSize.Level { DTEST_LOG << "OnLoadSystemAbilitySuccess001 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); sptr callback = new SystemAbilityLoadCallbackMock(); saMgr->NotifySystemAbilityLoaded(DISTRIBUTED_SCHED_TEST_SO_ID, nullptr, nullptr); @@ -315,6 +329,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, OnLoadSystemAbilitySuccess002, TestSize.Level { DTEST_LOG << "OnLoadSystemAbilitySuccess002 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); saMgr->Init(); sptr callback = new SystemAbilityLoadCallbackMock(); saMgr->NotifySystemAbilityLoaded(DISTRIBUTED_SCHED_TEST_SO_ID, nullptr, callback); @@ -332,6 +347,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, OnLoadSystemAbilitySuccess003, TestSize.Level { DTEST_LOG << "OnLoadSystemAbilitySuccess003 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); sptr callback = new SystemAbilityLoadCallbackMock(); sptr remoteObject = new TestTransactionService(); @@ -350,6 +366,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, OnLoadSystemAbilitySuccess004, TestSize.Level { DTEST_LOG << " OnLoadSystemAbilitySuccess004 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); sptr callback = new SystemAbilityLoadCallbackMock(); saMgr->NotifySystemAbilityLoaded(DISTRIBUTED_SCHED_TEST_SO_ID, nullptr, nullptr); @@ -366,6 +383,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, ReportLoadSAOverflow001, TestSize.Level1) { DTEST_LOG << "ReportLoadSAOverflow001 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); for (int i = 0; i < OVERFLOW_TIME; ++i) { sptr callback = new SystemAbilityLoadCallbackMock(); @@ -510,6 +528,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbilityFromRpc001, TestSize.Level2) { DTEST_LOG << "LoadSystemAbilityFromRpc001 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::string deviceId = ""; int32_t systemAbilityId = -1; @@ -529,6 +548,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbilityFromRpc002, TestSize.Level2) { DTEST_LOG << "LoadSystemAbilityFromRpc002 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::string deviceId = ""; int32_t systemAbilityId = 0; @@ -548,6 +568,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbilityFromRpc003, TestSize.Level2) { DTEST_LOG << "LoadSystemAbilityFromRpc003 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::string deviceId = ""; int32_t systemAbilityId = 0; @@ -566,6 +587,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbilityFromRpc004, TestSize.Level2) { DTEST_LOG << "LoadSystemAbilityFromRpc004 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::string deviceId = "1111111"; int32_t systemAbilityId = 0; @@ -584,6 +606,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbilityFromRpc005, TestSize.Level2) { DTEST_LOG << " LoadSystemAbilityFromRpc005 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::string deviceId = "2222222"; int32_t systemAbilityId = 1; @@ -602,6 +625,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbilityFromRpc006, TestSize.Level2) { DTEST_LOG << "LoadSystemAbilityFromRpc006 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::string deviceId = "2222222"; int32_t systemAbilityId = 1; @@ -622,6 +646,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbilityFromRpc007, TestSize.Level2) { DTEST_LOG << "LoadSystemAbilityFromRpc007 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::string deviceId = "2222222"; int32_t systemAbilityId = 1; @@ -644,6 +669,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbilityFromRpc008, TestSize.Level2) { DTEST_LOG << "LoadSystemAbilityFromRpc008 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::string deviceId = "2222222"; int32_t systemAbilityId = 1; @@ -664,6 +690,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, LoadSystemAbilityFromRpc009, TestSize.Level1) { DTEST_LOG << "LoadSystemAbilityFromRpc009 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); const std::string srcDeviceId; CommonSaProfile saProfile = {u"test", TEST_OVERFLOW_SAID}; @@ -686,6 +713,7 @@ HWTEST_F(SystemAbilityMgrLoadTest, UnloadSystemAbility001, TestSize.Level3) { DTEST_LOG << "UnloadSystemAbility001 begin" << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t systemAbilityId = 1; int32_t result = saMgr->UnloadSystemAbility(systemAbilityId); @@ -704,6 +732,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 +755,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 +777,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 +795,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 +813,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 +834,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 +856,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 +879,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 +906,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 +936,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 +963,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 +981,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 +1000,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 7153d541c87541540f8f452c236508889c986c79..b99c9619827b7567c8cb1caa4758d7edebd8b654 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,7 @@ void SystemAbilityMgrNewTest::TearDown() HWTEST_F(SystemAbilityMgrNewTest, GetLocalNodeId001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); string ret = saMgr->GetLocalNodeId(); EXPECT_EQ(ret, ""); } @@ -200,6 +201,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetLocalNodeId001, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, ReportGetSAPeriodically001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); 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_NE(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_NE(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_NE(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_NE(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_NE(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_NE(saMgr, nullptr); InitSaMgr(saMgr); SAInfo saInfo; saInfo.isDistributed = true; @@ -317,6 +325,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetSystemAbilityFromRemote004, TestSize.Level3 HWTEST_F(SystemAbilityMgrNewTest, GetDBinder001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); sptr result = saMgr->GetDBinder(); EXPECT_TRUE(result == nullptr); } @@ -331,6 +340,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetDBinder001, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, NotifyRpcLoadCompleted001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); saMgr->InitDbinderService(); sptr testAbility = new TestTransactionService(); @@ -348,6 +358,7 @@ HWTEST_F(SystemAbilityMgrNewTest, NotifyRpcLoadCompleted001, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, NotifyRpcLoadCompleted002, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); sptr testAbility = new TestTransactionService(); saMgr->NotifyRpcLoadCompleted("", 1, testAbility); @@ -362,6 +373,7 @@ HWTEST_F(SystemAbilityMgrNewTest, NotifyRpcLoadCompleted002, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, NotifyRpcLoadCompleted003, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); saMgr->InitDbinderService(); sptr testAbility = new TestTransactionService(); @@ -379,6 +391,7 @@ HWTEST_F(SystemAbilityMgrNewTest, Dump001, TestSize.Level3) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); saMgr->abilityStateScheduler_ = std::make_shared(); vector args; args.push_back(u"test_name"); @@ -397,6 +410,7 @@ HWTEST_F(SystemAbilityMgrNewTest, Dump002, TestSize.Level3) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); saMgr->abilityStateScheduler_ = std::make_shared(); vector args; vector argsWithStr8; @@ -417,6 +431,7 @@ HWTEST_F(SystemAbilityMgrNewTest, Dump003, TestSize.Level3) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); saMgr->abilityStateScheduler_ = std::make_shared(); vector args; args.push_back(u"--ipc"); @@ -436,6 +451,7 @@ HWTEST_F(SystemAbilityMgrNewTest, Dump004, TestSize.Level3) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); saMgr->abilityStateScheduler_ = std::make_shared(); vector args; args.push_back(u"--ffrt"); @@ -454,6 +470,7 @@ HWTEST_F(SystemAbilityMgrNewTest, Dump004, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, AddSamgrToAbilityMap001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); saMgr->AddSamgrToAbilityMap(); vector args; args.push_back(u"test_name"); @@ -470,6 +487,7 @@ HWTEST_F(SystemAbilityMgrNewTest, AddSamgrToAbilityMap001, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, GetCommonEventExtraIdList001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); sptr commonEventCollect = new CommonEventCollect(saMgr->collectManager_); commonEventCollect->workHandler_ = std::make_shared(commonEventCollect); @@ -517,6 +535,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetCommonEventExtraIdList001, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, RemoveWhiteCommonEvent001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); saMgr->workHandler_ = make_shared("workHandler"); saMgr->CleanFfrt(); saMgr->collectManager_ = sptr(new DeviceStatusCollectManager()); @@ -539,6 +558,7 @@ HWTEST_F(SystemAbilityMgrNewTest, RemoveWhiteCommonEvent001, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, SetFfrt001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); saMgr->SetFfrt(); EXPECT_NE(saMgr->collectManager_, nullptr); @@ -554,6 +574,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetRunningSaExtensionInfoList001, TestSize.Lev { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); const int32_t maxLoop = 4; map saProfileMapTmp; @@ -583,6 +604,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetRunningSaExtensionInfoList002, TestSize.Lev { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); const int32_t maxLoop = 4; map saProfileMapTmp; @@ -623,6 +645,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetRunningSaExtensionInfoList002, TestSize.Lev HWTEST_F(SystemAbilityMgrNewTest, CheckSystemAbility006, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); int32_t systemAbilityId = -1; bool isExist; sptr ret = saMgr->CheckSystemAbility(systemAbilityId, isExist); @@ -638,6 +661,7 @@ HWTEST_F(SystemAbilityMgrNewTest, CheckSystemAbility006, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, RemoveSystemAbility005, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); const sptr ability = nullptr; int32_t ret = saMgr->RemoveSystemAbility(ability); @@ -652,6 +676,7 @@ HWTEST_F(SystemAbilityMgrNewTest, RemoveSystemAbility005, TestSize.Level3) HWTEST_F(SystemAbilityMgrNewTest, AddSystemAbility006, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); int32_t systemAbilityId = -1; const sptr ability; @@ -668,6 +693,7 @@ HWTEST_F(SystemAbilityMgrNewTest, AddSystemAbility006, TestSize.Level1) HWTEST_F(SystemAbilityMgrNewTest, AddSystemAbility007, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); int32_t systemAbilityId = -1; const sptr ability; @@ -685,6 +711,7 @@ HWTEST_F(SystemAbilityMgrNewTest, AddSystemAbility007, TestSize.Level1) HWTEST_F(SystemAbilityMgrNewTest, GetSystemProcess001, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); std::u16string procName; sptr ret = saMgr->GetSystemProcess(procName); EXPECT_EQ(ret, nullptr); @@ -698,6 +725,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetSystemProcess001, TestSize.Level1) HWTEST_F(SystemAbilityMgrNewTest, GetSystemProcessInfo003, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); int32_t systemAbilityId = 0; SystemProcessInfo systemProcessInfo; int32_t ret = saMgr->GetSystemProcessInfo(systemAbilityId, systemProcessInfo); @@ -712,6 +740,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetSystemProcessInfo003, TestSize.Level1) HWTEST_F(SystemAbilityMgrNewTest, IsModuleUpdate001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); bool ret = saMgr->IsModuleUpdate(SAID); EXPECT_FALSE(ret); } @@ -724,6 +753,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IsModuleUpdate001, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IsModuleUpdate002, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); CommonSaProfile saprofile; saMgr->saProfileMap_[saprofile.saId] = saprofile; bool ret = saMgr->IsModuleUpdate(saprofile.saId); @@ -738,6 +768,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IsModuleUpdate002, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IsModuleUpdate003, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); CommonSaProfile saprofile; saprofile.moduleUpdate = true; saMgr->saProfileMap_[saprofile.saId] = saprofile; @@ -754,6 +785,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetExtensionSaIdsInner001, TestSize.Level3) { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); MessageParcel data; MessageParcel reply; @@ -770,6 +802,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetExtensionSaIdsInner002, TestSize.Level3) { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); MessageParcel data; MessageParcel reply; @@ -794,6 +827,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetExtensionSaIdsInner003, TestSize.Level3) { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); const int32_t maxLoop = 4; map saProfileMapTmp; @@ -826,6 +860,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetExtensionRunningSaListInner001, TestSize.Le { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); MessageParcel data; MessageParcel reply; @@ -842,6 +877,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetExtensionRunningSaListInner002, TestSize.Le { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); MessageParcel data; MessageParcel reply; @@ -866,6 +902,7 @@ HWTEST_F(SystemAbilityMgrNewTest, GetExtensionRunningSaListInner003, TestSize.Le { DTEST_LOG << __func__ << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); InitSaMgr(saMgr); const int32_t maxLoop = 4; map saProfileMapTmp; @@ -901,6 +938,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpProc001, TestSize.Level2) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); int32_t cmd = -1; int32_t fd = 1; std::vector args; @@ -919,6 +957,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpProc002, TestSize.Level2) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); int32_t cmd = -1; int32_t fd = 1; std::vector args; @@ -938,6 +977,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpProc003, TestSize.Level2) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); int32_t cmd = -1; int32_t fd = 1; std::vector args; @@ -957,6 +997,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpProc004, TestSize.Level2) { SamMockPermission::MockProcess("hidumper_service"); sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); int32_t cmd = -1; int32_t fd = 1; std::vector args; @@ -975,6 +1016,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpProc004, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IpcStatSamgrProc001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); int32_t cmd = IPC_STAT_CMD_START - 1; int32_t fd = 1; bool ret = saMgr->IpcStatSamgrProc(fd, cmd); @@ -992,6 +1034,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcStatSamgrProc001, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IpcStatSamgrProc002, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); int32_t cmd = IPC_STAT_CMD_START; int32_t dmd = IPC_STAT_CMD_STOP; int32_t emd = IPC_STAT_CMD_GET; @@ -1014,6 +1057,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcStatSamgrProc002, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IpcDumpAllProcess001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); int32_t cmd = IPC_STAT_CMD_START; int32_t fd = 1; bool ret = true; @@ -1029,6 +1073,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpAllProcess001, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IpcDumpSamgrProcess001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); int32_t cmd = 4; int32_t fd = 1; bool ret = true; @@ -1045,6 +1090,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpSamgrProcess001, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IpcDumpSingleProcess001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); int32_t cmd = IPC_STAT_CMD_START; int32_t fd = 1; bool ret = true; @@ -1066,6 +1112,7 @@ HWTEST_F(SystemAbilityMgrNewTest, IpcDumpSingleProcess001, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, DoLoadForPerf001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); saMgr->abilityStateScheduler_ = std::make_shared(); CommonSaProfile saProfile; saProfile.process = u"memmgrservice"; @@ -1083,6 +1130,7 @@ HWTEST_F(SystemAbilityMgrNewTest, DoLoadForPerf001, TestSize.Level2) HWTEST_F(SystemAbilityMgrNewTest, IsDistributedSystemAbility001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); bool res = saMgr->IsDistributedSystemAbility(-1); EXPECT_FALSE(res); CommonSaProfile saProfile; diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_test.cpp index 6974325439c445376116ee88f6151aa8d8bbf3b7..f3664eafc7e6da0156e601c5146350abaf2684a3 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_test.cpp @@ -131,6 +131,7 @@ void SystemAbilityMgrTest::TearDown() HWTEST_F(SystemAbilityMgrTest, AddSystemAbility001, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); ISystemAbilityManager::SAExtraProp extraProp(false, DUMP_FLAG_PRIORITY_DEFAULT, u"", u""); int32_t result = saMgr->AddSystemAbility(DISTRIBUTED_SCHED_TEST_TT_ID, nullptr, extraProp); @@ -146,6 +147,7 @@ HWTEST_F(SystemAbilityMgrTest, AddSystemAbility001, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, AddSystemAbility002, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + InitSaMgr(saMgr); sptr testAbility = new TestTransactionService(); ISystemAbilityManager::SAExtraProp extraProp(false, DUMP_FLAG_PRIORITY_DEFAULT, u"", u""); @@ -162,6 +164,7 @@ HWTEST_F(SystemAbilityMgrTest, AddSystemAbility002, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, AddSystemAbility003, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr testAbility = new TestTransactionService(); ISystemAbilityManager::SAExtraProp extraProp(false, DUMP_FLAG_PRIORITY_DEFAULT, u"", u""); @@ -179,6 +182,7 @@ HWTEST_F(SystemAbilityMgrTest, AddSystemAbility003, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, AddSystemAbility004, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t systemAbilityId = DISTRIBUTED_SCHED_TEST_TT_ID; ISystemAbilityManager::SAExtraProp saExtraProp(false, ISystemAbilityManager::DUMP_FLAG_PRIORITY_DEFAULT, @@ -195,6 +199,7 @@ HWTEST_F(SystemAbilityMgrTest, AddSystemAbility004, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, AddSystemAbility005, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t systemAbilityId = DISTRIBUTED_SCHED_TEST_SO_ID; std::u16string capability = u"{\"Capabilities\":{\"aaa\":\"[10.4, 20.5]\",\"bbb\":\"[11, 55]\",\ @@ -213,6 +218,7 @@ HWTEST_F(SystemAbilityMgrTest, AddSystemAbility005, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, RemoveSystemAbility001, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t result = saMgr->RemoveSystemAbility(-1); EXPECT_TRUE(result != ERR_OK); @@ -226,6 +232,7 @@ HWTEST_F(SystemAbilityMgrTest, RemoveSystemAbility001, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, RemoveSystemAbility002, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr testAbility = new TestTransactionService(); ISystemAbilityManager::SAExtraProp extraProp(false, DUMP_FLAG_PRIORITY_DEFAULT, u"", u""); @@ -243,6 +250,7 @@ HWTEST_F(SystemAbilityMgrTest, RemoveSystemAbility002, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, RemoveSystemAbility003, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); saMgr->abilityStateScheduler_ = nullptr; sptr testAbility = new TestTransactionService(); @@ -260,6 +268,7 @@ HWTEST_F(SystemAbilityMgrTest, RemoveSystemAbility003, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, RemoveSystemAbility004, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t result = saMgr->RemoveSystemAbility(-1); EXPECT_TRUE(result != ERR_OK); @@ -274,6 +283,7 @@ HWTEST_F(SystemAbilityMgrTest, RemoveSystemAbility004, TestSize.Level3) HWTEST_F(SystemAbilityMgrTest, RemoveSystemAbility006, TestSize.Level0) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr testAbility = new TestTransactionService(); ISystemAbilityManager::SAExtraProp saExtraProp; @@ -293,6 +303,7 @@ HWTEST_F(SystemAbilityMgrTest, RemoveSystemAbility006, TestSize.Level0) HWTEST_F(SystemAbilityMgrTest, RemoveSystemAbility007, TestSize.Level0) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr testAbility = new TestTransactionService(); ISystemAbilityManager::SAExtraProp saExtraProp; @@ -312,6 +323,7 @@ HWTEST_F(SystemAbilityMgrTest, RemoveSystemAbility007, TestSize.Level0) HWTEST_F(SystemAbilityMgrTest, GetSystemAbility001, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); auto ability = saMgr->GetSystemAbility(DISTRIBUTED_SCHED_TEST_TT_ID); EXPECT_EQ(ability, nullptr); @@ -325,6 +337,7 @@ HWTEST_F(SystemAbilityMgrTest, GetSystemAbility001, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, GetSystemAbility002, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr testAbility = new TestTransactionService(); ISystemAbilityManager::SAExtraProp extraProp(false, DUMP_FLAG_PRIORITY_DEFAULT, u"", u""); @@ -341,6 +354,7 @@ HWTEST_F(SystemAbilityMgrTest, GetSystemAbility002, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, GetSystemAbility003, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr testAbility = new TestTransactionService(); ISystemAbilityManager::SAExtraProp extraProp(false, DUMP_FLAG_PRIORITY_DEFAULT, u"", u""); @@ -363,6 +377,7 @@ HWTEST_F(SystemAbilityMgrTest, GetSystemAbility003, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, GetSystemAbility004, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); ISystemAbilityManager::SAExtraProp extraProp(false, DUMP_FLAG_PRIORITY_DEFAULT, u"", u""); for (int32_t i = 0; i < REPEAT; ++i) { @@ -385,6 +400,7 @@ HWTEST_F(SystemAbilityMgrTest, GetSystemAbility004, TestSize.Level2) HWTEST_F(SystemAbilityMgrTest, GetSystemAbility005, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); string fakeDeviceId = "fake_dev"; auto abilityObj = saMgr->GetSystemAbility(DISTRIBUTED_SCHED_TEST_TT_ID, fakeDeviceId); @@ -399,6 +415,7 @@ HWTEST_F(SystemAbilityMgrTest, GetSystemAbility005, TestSize.Level2) HWTEST_F(SystemAbilityMgrTest, CheckSystemAbility001, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t systemAbilityId = DISTRIBUTED_SCHED_TEST_TT_ID; sptr testAbility = new TestTransactionService(); @@ -417,6 +434,7 @@ HWTEST_F(SystemAbilityMgrTest, CheckSystemAbility001, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, CheckSystemAbility002, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); saMgr->abilityStateScheduler_ = nullptr; int32_t systemAbilityId = DISTRIBUTED_SCHED_TEST_TT_ID; @@ -434,6 +452,7 @@ HWTEST_F(SystemAbilityMgrTest, CheckSystemAbility002, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, CheckSystemAbility003, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); saMgr->abilityStateScheduler_ = nullptr; bool isExist = true; @@ -450,6 +469,7 @@ HWTEST_F(SystemAbilityMgrTest, CheckSystemAbility003, TestSize.Level3) HWTEST_F(SystemAbilityMgrTest, CheckSystemAbility004, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::shared_ptr systemAbilityContext = std::make_shared(); std::shared_ptr systemProcessContext = std::make_shared(); @@ -471,6 +491,7 @@ HWTEST_F(SystemAbilityMgrTest, CheckSystemAbility005, TestSize.Level3) { DTEST_LOG << " CheckSystemAbility005 " << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t systemAbilityId = DISTRIBUTED_SCHED_TEST_TT_ID; bool isExist = true; @@ -488,6 +509,7 @@ HWTEST_F(SystemAbilityMgrTest, ListSystemAbility001, TestSize.Level1) { int32_t systemAbilityId = DISTRIBUTED_SCHED_TEST_TT_ID; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); ISystemAbilityManager::SAExtraProp extraProp(false, DUMP_FLAG_PRIORITY_DEFAULT, u"", u""); saMgr->AddSystemAbility(systemAbilityId, new TestTransactionService(), extraProp); @@ -505,6 +527,7 @@ HWTEST_F(SystemAbilityMgrTest, ListSystemAbility001, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, OnRemoteDied001, TestSize.Level1) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr callback = new SystemAbilityLoadCallbackMock(); saMgr->OnAbilityCallbackDied(callback->AsObject()); @@ -520,6 +543,7 @@ HWTEST_F(SystemAbilityMgrTest, OnRemoteDied001, TestSize.Level1) HWTEST_F(SystemAbilityMgrTest, DoMakeRemoteBinder001, TestSize.Level2) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); saMgr->dBinderService_ = DBinderService::GetInstance(); std::string deviceId = "1111111"; @@ -538,6 +562,7 @@ HWTEST_F(SystemAbilityMgrTest, DoMakeRemoteBinder002, TestSize.Level2) { DTEST_LOG << " DoMakeRemoteBinder002 " << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); saMgr->dBinderService_ = DBinderService::GetInstance(); std::string deviceId = "2222222"; @@ -560,6 +585,7 @@ HWTEST_F(SystemAbilityMgrTest, startingAbilityMapTest001, TestSize.Level1) * @tc.expected: step1. init startingAbilityMap_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); sptr mockLoadCallback2 = new SystemAbilityLoadCallbackMock(); @@ -609,6 +635,7 @@ HWTEST_F(SystemAbilityMgrTest, startingAbilityMapTest002, TestSize.Level1) * @tc.expected: step1. init startingAbilityMap_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -639,6 +666,7 @@ HWTEST_F(SystemAbilityMgrTest, startingAbilityMapTest003, TestSize.Level1) * @tc.expected: step1. init startingAbilityMap_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -671,6 +699,7 @@ HWTEST_F(SystemAbilityMgrTest, startingAbilityMapTest004, TestSize.Level1) * @tc.expected: step1. init startingAbilityMap_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -703,6 +732,7 @@ HWTEST_F(SystemAbilityMgrTest, startingAbilityMapTest005, TestSize.Level1) * @tc.expected: step1. init startingAbilityMap_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -736,6 +766,7 @@ HWTEST_F(SystemAbilityMgrTest, startingAbilityMapTest006, TestSize.Level1) * @tc.expected: step1. init startingAbilityMap_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -768,6 +799,7 @@ HWTEST_F(SystemAbilityMgrTest, startingAbilityMapTest007, TestSize.Level1) * @tc.expected: step1. init startingAbilityMap_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -800,6 +832,7 @@ HWTEST_F(SystemAbilityMgrTest, startingAbilityMapTest008, TestSize.Level1) * @tc.expected: step1. init startingAbilityMap_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -834,6 +867,7 @@ HWTEST_F(SystemAbilityMgrTest, startingAbilityMapTest009, TestSize.Level1) * @tc.expected: step1. init startingAbilityMap_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -867,6 +901,7 @@ HWTEST_F(SystemAbilityMgrTest, startingAbilityMapTest010, TestSize.Level1) * @tc.expected: step1. init startingAbilityMap_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -908,6 +943,7 @@ HWTEST_F(SystemAbilityMgrTest, startingAbilityMapTest011, TestSize.Level1) * @tc.expected: step1. init startingAbilityMap_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -950,6 +986,7 @@ HWTEST_F(SystemAbilityMgrTest, startingAbilityMapTest012, TestSize.Level1) * @tc.expected: step1. init startingAbilityMap_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -993,6 +1030,7 @@ HWTEST_F(SystemAbilityMgrTest, OnRemoteCallbackDied001, TestSize.Level1) * @tc.expected: step1. init remoteCallbacks_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -1022,6 +1060,7 @@ HWTEST_F(SystemAbilityMgrTest, OnRemoteCallbackDied002, TestSize.Level1) * @tc.expected: step1. init remoteCallbacks_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); saMgr->remoteCallbacks_ = { @@ -1049,6 +1088,7 @@ HWTEST_F(SystemAbilityMgrTest, OnRemoteCallbackDied003, TestSize.Level1) * @tc.expected: step1. init remoteCallbacks_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); sptr mockLoadCallback2 = new SystemAbilityLoadCallbackMock(); @@ -1077,6 +1117,7 @@ HWTEST_F(SystemAbilityMgrTest, OnRemoteCallbackDied004, TestSize.Level1) * @tc.expected: step1. init remoteCallbacks_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); sptr mockLoadCallback2 = new SystemAbilityLoadCallbackMock(); @@ -1107,6 +1148,7 @@ HWTEST_F(SystemAbilityMgrTest, OnRemoteCallbackDied005, TestSize.Level1) * @tc.expected: step1. init remoteCallbacks_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); sptr mockLoadCallback2 = new SystemAbilityLoadCallbackMock(); @@ -1137,6 +1179,7 @@ HWTEST_F(SystemAbilityMgrTest, OnRemoteCallbackDied006, TestSize.Level1) * @tc.expected: step1. init remoteCallbacks_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); sptr mockLoadCallback2 = new SystemAbilityLoadCallbackMock(); @@ -1168,6 +1211,7 @@ HWTEST_F(SystemAbilityMgrTest, OnRemoteCallbackDied007, TestSize.Level1) * @tc.expected: step1. init remoteCallbacks_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); sptr mockLoadCallback2 = new SystemAbilityLoadCallbackMock(); @@ -1198,6 +1242,7 @@ HWTEST_F(SystemAbilityMgrTest, OnRemoteCallbackDied008, TestSize.Level1) * @tc.expected: step1. init remoteCallbacks_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -1228,6 +1273,7 @@ HWTEST_F(SystemAbilityMgrTest, DoLoadRemoteSystemAbility001, TestSize.Level1) * @tc.expected: step1. init remoteCallbacks_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -1260,6 +1306,7 @@ HWTEST_F(SystemAbilityMgrTest, DoLoadRemoteSystemAbility002, TestSize.Level1) * @tc.expected: step1. init remoteCallbacks_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback2 = new SystemAbilityLoadCallbackMock(); @@ -1289,6 +1336,7 @@ HWTEST_F(SystemAbilityMgrTest, DoLoadRemoteSystemAbility003, TestSize.Level1) * @tc.expected: step1. init remoteCallbacks_ */ sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr mockLoadCallback1 = new SystemAbilityLoadCallbackMock(); @@ -1316,6 +1364,7 @@ HWTEST_F(SystemAbilityMgrTest, DoLoadRemoteSystemAbility004, TestSize.Level1) { DTEST_LOG << " DoLoadRemoteSystemAbility004 start " << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); saMgr->DoLoadRemoteSystemAbility(11111, 0, 0, "222", nullptr); ASSERT_EQ(saMgr->remoteCallbacks_.size(), 0); @@ -1369,6 +1418,7 @@ HWTEST_F(SystemAbilityMgrTest, ReportGetSAFre002, TestSize.Level3) { DTEST_LOG << " ReportGetSAFre002 start " << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t uid = 1; int32_t count = saMgr->UpdateSaFreMap(uid, TEST_SYSTEM_ABILITY1); @@ -1387,6 +1437,7 @@ HWTEST_F(SystemAbilityMgrTest, ReportGetSAFre003, TestSize.Level3) { DTEST_LOG << " ReportGetSAFre003 start " << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t uid = -1; int32_t count = saMgr->UpdateSaFreMap(uid, TEST_SYSTEM_ABILITY1); @@ -1404,6 +1455,7 @@ HWTEST_F(SystemAbilityMgrTest, ReportGetSAFre004, TestSize.Level3) { DTEST_LOG << " ReportGetSAFre004 start " << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); int32_t uid = 1; uint64_t key = SamgrUtil::GenerateFreKey(uid, TEST_SYSTEM_ABILITY1); @@ -1422,6 +1474,7 @@ HWTEST_F(SystemAbilityMgrTest, GetSystemProcessInfo001, TestSize.Level3) { DTEST_LOG << " GetSystemProcessInfo001 " << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); SystemProcessInfo ProcessInfo; int32_t ret = saMgr->GetSystemProcessInfo(SAID, ProcessInfo); @@ -1438,6 +1491,7 @@ HWTEST_F(SystemAbilityMgrTest, GetSystemProcessInfo002, TestSize.Level3) { DTEST_LOG << " GetSystemProcessInfo002 " << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); SystemProcessInfo ProcessInfo; saMgr->abilityStateScheduler_ = nullptr; @@ -1455,6 +1509,7 @@ HWTEST_F(SystemAbilityMgrTest, GetRunningSystemProcess001, TestSize.Level3) { DTEST_LOG << " GetRunningSystemProcess001 " << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::list systemProcessInfos; int32_t ret = saMgr->GetRunningSystemProcess(systemProcessInfos); @@ -1471,6 +1526,7 @@ HWTEST_F(SystemAbilityMgrTest, GetRunningSystemProcess002, TestSize.Level3) { DTEST_LOG << " GetRunningSystemProcess002 " << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::list systemProcessInfos; saMgr->abilityStateScheduler_ = nullptr; @@ -1487,6 +1543,7 @@ HWTEST_F(SystemAbilityMgrTest, GetRunningSystemProcess002, TestSize.Level3) HWTEST_F(SystemAbilityMgrTest, GetRunningSystemProcess003, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); saMgr->abilityStateScheduler_ = nullptr; std::list systemProcessInfos; @@ -1504,6 +1561,7 @@ HWTEST_F(SystemAbilityMgrTest, WatchDogInit001, TestSize.Level3) { DTEST_LOG << " WatchDogInit001 " << std::endl; sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); EXPECT_NE(saMgr, nullptr); } @@ -1517,6 +1575,7 @@ HWTEST_F(SystemAbilityMgrTest, WatchDogInit001, TestSize.Level3) HWTEST_F(SystemAbilityMgrTest, AddSystemProcess001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); std::u16string procName = u"test"; sptr testAbility = new TestTransactionService(); @@ -1534,6 +1593,7 @@ HWTEST_F(SystemAbilityMgrTest, AddSystemProcess001, TestSize.Level3) HWTEST_F(SystemAbilityMgrTest, RemoveSystemProcess001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr testAbility = new TestTransactionService(); saMgr->abilityStateScheduler_ = nullptr; @@ -1559,6 +1619,7 @@ HWTEST_F(SystemAbilityMgrTest, RemoveSystemProcess001, TestSize.Level3) HWTEST_F(SystemAbilityMgrTest, RemoveSystemProcess002, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); sptr testAbility = new TestTransactionService(); saMgr->abilityStateScheduler_ = nullptr; @@ -1576,6 +1637,7 @@ HWTEST_F(SystemAbilityMgrTest, RemoveSystemProcess002, TestSize.Level3) HWTEST_F(SystemAbilityMgrTest, SetDeviceName001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); saMgr->SetDeviceName(DEVICE_NAME); EXPECT_EQ(saMgr->deviceName_, DEVICE_NAME); } @@ -1589,6 +1651,7 @@ HWTEST_F(SystemAbilityMgrTest, SetDeviceName001, TestSize.Level3) HWTEST_F(SystemAbilityMgrTest, GetDeviceName001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); saMgr->SetDeviceName(DEVICE_NAME); auto ret = saMgr->GetDeviceName(); EXPECT_EQ(ret, DEVICE_NAME); @@ -1603,6 +1666,7 @@ HWTEST_F(SystemAbilityMgrTest, GetDeviceName001, TestSize.Level3) HWTEST_F(SystemAbilityMgrTest, OnAbilityCallbackDied001, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_TRUE(saMgr != nullptr); InitSaMgr(saMgr); saMgr->OnAbilityCallbackDied(nullptr); EXPECT_TRUE(saMgr->startingAbilityMap_.empty()); diff --git a/services/samgr/native/test/unittest/src/system_ability_state_scheduler_test.cpp b/services/samgr/native/test/unittest/src/system_ability_state_scheduler_test.cpp index aa39eee42fca974133cd6fcd631fdc225c970fbe..7c6860051e409db9e4560ada1ce23894109af57c 100644 --- a/services/samgr/native/test/unittest/src/system_ability_state_scheduler_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_state_scheduler_test.cpp @@ -198,6 +198,7 @@ HWTEST_F(SystemAbilityStateSchedulerTest, GetSystemAbilityContext004, TestSize.L HWTEST_F(SystemAbilityStateSchedulerTest, GetSystemAbilityContext005, TestSize.Level3) { sptr saMgr = new SystemAbilityManager; + EXPECT_NE(saMgr, nullptr); for (int i = 0; i < 100; i++) { saMgr->abilityStateScheduler_ = std::make_shared(); std::shared_ptr systemAbilityContext = std::make_shared();