diff --git a/README_zh.md b/README_zh.md index f00ba01c13cb9bab8a486b5de02df823acc02e57..0a16f17ce9639b0883afaf465a76728d897f4565 100644 --- a/README_zh.md +++ b/README_zh.md @@ -1,8 +1,13 @@ -# samgr组件 +# 系统服务管理部件 ## 简介 samgr组件是OpenHarmony的核心组件,提供OpenHarmony系统服务启动、注册、查询等功能。 +## 系统架构 + +**图 1** 系统服务管理系统架构图 + + ![](figures/zh-cn_image_0000001115820566.png) ## 目录 diff --git a/figures/en-us_image_0000001115820566.png b/figures/en-us_image_0000001115820566.png index 5565883f26bdc780a78ab7b1b6f6fb799525f704..826d579fdce32aa57080e14141153f7dda7035f7 100644 Binary files a/figures/en-us_image_0000001115820566.png and b/figures/en-us_image_0000001115820566.png differ diff --git a/figures/zh-cn_image_0000001115820566.png b/figures/zh-cn_image_0000001115820566.png index c40b07116c06dd275da47df579d8664c6bd52abc..eb084e6dc92931583b1cee2b6b504dad9e9e5d9b 100644 Binary files a/figures/zh-cn_image_0000001115820566.png and b/figures/zh-cn_image_0000001115820566.png differ diff --git a/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp b/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp index 681a412f9fa727ba8210a84329d0253fac9fa632..e8ebcd4f4ca1e1e4bf8090fd9bf3a72f2249d050 100644 --- a/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp +++ b/services/samgr/native/test/unittest/src/system_ability_mgr_stub_test.cpp @@ -911,4 +911,236 @@ HWTEST_F(SystemAbilityMgrStubTest, LoadRemoteSystemAbilityInner004, TestSize.Lev int32_t result = saMgr->LoadRemoteSystemAbilityInner(data, reply); EXPECT_EQ(result, ERR_OK); } -} \ No newline at end of file + +/** + * @tc.name: Init001 + * @tc.desc: test Init! + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, Init001, TestSize.Level3) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + saMgr->workHandler_ = nullptr; + saMgr->Init(); + EXPECT_NE(saMgr, nullptr); +} + +/** + * @tc.name: Init002 + * @tc.desc: test Init! + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, Init002, TestSize.Level1) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + auto runner = AppExecFwk::EventRunner::Create("workHandler"); + saMgr->workHandler_ = make_shared(runner); + saMgr->Init(); + EXPECT_NE(saMgr, nullptr); +} + +/** + * @tc.name: InitSaProfile001 + * @tc.desc: test InitSaProfile! InitSaProfile. + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, InitSaProfile001, TestSize.Level1) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + auto runner = AppExecFwk::EventRunner::Create("workHandler"); + saMgr->workHandler_ = make_shared(runner); + saMgr->InitSaProfile(); + EXPECT_NE(saMgr->workHandler_, nullptr); +} + +/** + * @tc.name: InitSaProfile002 + * @tc.desc: test InitSaProfile! parseHandler_ not init! + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, InitSaProfile002, TestSize.Level3) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + saMgr->workHandler_ = nullptr; + saMgr->InitSaProfile(); + EXPECT_EQ(saMgr->workHandler_, nullptr); +} + +/** + * @tc.name: GetSaProfile001 + * @tc.desc: test GetSaProfile! return true + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, GetSaProfile001, TestSize.Level3) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + SaProfile saProfilein; + SaProfile SaProfileout; + saMgr->saProfileMap_[SAID] = saProfilein; + bool res = saMgr->GetSaProfile(SAID, SaProfileout); + EXPECT_EQ(res, true); +} + +/** + * @tc.name: GetSystemAbility001 + * @tc.desc: test GetSystemAbility! return nullptr + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbility001, TestSize.Level3) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + sptr res = saMgr->GetSystemAbility(INVALID_SAID); + EXPECT_EQ(res, nullptr); +} + +/** + * @tc.name: GetSystemAbility002 + * @tc.desc: test GetSystemAbility! return nullptr + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbility002, TestSize.Level3) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + string deviceId = "test"; + sptr res = saMgr->GetSystemAbility(SAID, deviceId); + EXPECT_EQ(res, nullptr); +} + +/** + * @tc.name: GetSystemAbilityFromRemote001 + * @tc.desc: test GetSystemAbilityFromRemote! GetSystemAbilityFromRemote invalid! + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbilityFromRemote001, TestSize.Level3) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + sptr res = saMgr->GetSystemAbilityFromRemote(INVALID_SAID); + EXPECT_EQ(res, nullptr); +} + +/** + * @tc.name: GetSystemAbilityFromRemote002 + * @tc.desc: test GetSystemAbilityFromRemote! not found service! + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbilityFromRemote002, TestSize.Level3) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + sptr res = saMgr->GetSystemAbilityFromRemote(SAID); + EXPECT_EQ(res, nullptr); +} + +/** + * @tc.name: GetSystemAbilityFromRemote003 + * @tc.desc: test GetSystemAbilityFromRemote! service not distributed! + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbilityFromRemote003, TestSize.Level3) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + SAInfo saInfo; + saInfo.isDistributed = false; + saMgr->abilityMap_[SAID] = saInfo; + sptr res = saMgr->GetSystemAbilityFromRemote(SAID); + EXPECT_EQ(res, nullptr); +} + +/** + * @tc.name: GetSystemAbilityFromRemote004 + * @tc.desc: test GetSystemAbilityFromRemote! GetSystemAbilityFromRemote found service! + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, GetSystemAbilityFromRemote004, TestSize.Level3) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + SAInfo saInfo; + saInfo.isDistributed = true; + saInfo.remoteObj = saMgr; + saMgr->abilityMap_[SAID] = saInfo; + sptr res = saMgr->GetSystemAbilityFromRemote(SAID); + EXPECT_NE(res, nullptr); +} + +/** + * @tc.name: CheckSystemAbility001 + * @tc.desc: test CheckSystemAbility! CheckSystemAbility invalid! + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbility001, TestSize.Level3) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + sptr res = saMgr->CheckSystemAbility(INVALID_SAID); + EXPECT_EQ(res, nullptr); +} + +/** + * @tc.name: CheckSystemAbility002 + * @tc.desc: test CheckSystemAbility! found service! + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, CheckSystemAbility002, TestSize.Level3) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + SAInfo saInfo; + saInfo.remoteObj = saMgr; + saMgr->abilityMap_[SAID] = saInfo; + sptr res = saMgr->CheckSystemAbility(SAID); + EXPECT_NE(res, nullptr); +} + +/** + * @tc.name: CheckDistributedPermission001 + * @tc.desc: test CheckDistributedPermission! return true! + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, CheckDistributedPermission001, TestSize.Level1) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + bool res = saMgr->CheckDistributedPermission(); + EXPECT_EQ(res, true); +} + +/** + * @tc.name: NotifySystemAbilityChanged001 + * @tc.desc: test NotifySystemAbilityChanged! listener null pointer!! + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, NotifySystemAbilityChanged001, TestSize.Level3) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + string deviceId = "test"; + code = 1; + bool res = saMgr->NotifySystemAbilityChanged(SAID, deviceId, code, nullptr); + EXPECT_NE(saMgr, nullptr); +} + +/** + * @tc.name: NotifySystemAbilityChanged002 + * @tc.desc: test NotifySystemAbilityChanged! + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, NotifySystemAbilityChanged002, TestSize.Level1) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + sptr testAbility(new SaStatusChangeMock()); + string deviceId = "test"; + code = 1; + bool res = saMgr->NotifySystemAbilityChanged(SAID, deviceId, code, testAbility); + EXPECT_NE(saMgr, nullptr); +} + +/** + * @tc.name: FindSystemAbilityNotify001 + * @tc.desc: test FindSystemAbilityNotify! + * @tc.type: FUNC + */ +HWTEST_F(SystemAbilityMgrStubTest, NotifySystemAbilityChanged002, TestSize.Level1) +{ + sptr saMgr = SystemAbilityManager::GetInstance(); + sptr testAbility(new SaStatusChangeMock()); + string deviceId = "test"; + code = 1; + bool res = saMgr->NotifySystemAbilityChanged(SAID, deviceId, code, testAbility); + EXPECT_NE(saMgr, nullptr); +} +}