179a732c7Sopenharmony_ci/* 279a732c7Sopenharmony_ci * Copyright (c) 2022-2023 Huawei Device Co., Ltd. 379a732c7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 479a732c7Sopenharmony_ci * you may not use this file except in compliance with the License. 579a732c7Sopenharmony_ci * You may obtain a copy of the License at 679a732c7Sopenharmony_ci * 779a732c7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 879a732c7Sopenharmony_ci * 979a732c7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1079a732c7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1179a732c7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1279a732c7Sopenharmony_ci * See the License for the specific language governing permissions and 1379a732c7Sopenharmony_ci * limitations under the License. 1479a732c7Sopenharmony_ci */ 1579a732c7Sopenharmony_ci 1679a732c7Sopenharmony_ci#include "UTTest_device_manager_notify.h" 1779a732c7Sopenharmony_ci#include "device_manager_notify.h" 1879a732c7Sopenharmony_ci#include "dm_device_info.h" 1979a732c7Sopenharmony_ci#include "ipc_remote_broker.h" 2079a732c7Sopenharmony_ci#include "iremote_object.h" 2179a732c7Sopenharmony_ci#include "iservice_registry.h" 2279a732c7Sopenharmony_ci#include "system_ability_definition.h" 2379a732c7Sopenharmony_ci#include "ipc_client_manager.h" 2479a732c7Sopenharmony_ci#include "ipc_set_useroperation_req.h" 2579a732c7Sopenharmony_ci#include "ipc_rsp.h" 2679a732c7Sopenharmony_ci#include "ipc_def.h" 2779a732c7Sopenharmony_ci 2879a732c7Sopenharmony_ci#include <unistd.h> 2979a732c7Sopenharmony_ci 3079a732c7Sopenharmony_cinamespace OHOS { 3179a732c7Sopenharmony_cinamespace DistributedHardware { 3279a732c7Sopenharmony_civoid DeviceManagerNotifyTest::SetUp() {} 3379a732c7Sopenharmony_ci 3479a732c7Sopenharmony_civoid DeviceManagerNotifyTest::TearDown() {} 3579a732c7Sopenharmony_ci 3679a732c7Sopenharmony_civoid DeviceManagerNotifyTest::SetUpTestCase() {} 3779a732c7Sopenharmony_ci 3879a732c7Sopenharmony_civoid DeviceManagerNotifyTest::TearDownTestCase() {} 3979a732c7Sopenharmony_cinamespace { 4079a732c7Sopenharmony_ci/** 4179a732c7Sopenharmony_ci * @tc.name: RegisterDeathRecipientCallback_001 4279a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 4379a732c7Sopenharmony_ci * set dmInitCallback not null 4479a732c7Sopenharmony_ci * 2. set checkMap null 4579a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 4679a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 4779a732c7Sopenharmony_ci * 5. check checkMap not null 4879a732c7Sopenharmony_ci * deviceTypeId 4979a732c7Sopenharmony_ci * @tc.type: FUNC 5079a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 5179a732c7Sopenharmony_ci */ 5279a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDeathRecipientCallback_001, testing::ext::TestSize.Level0) 5379a732c7Sopenharmony_ci{ 5479a732c7Sopenharmony_ci // 1. set pkgName not null 5579a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 5679a732c7Sopenharmony_ci // set dmInitCallback not null 5779a732c7Sopenharmony_ci int count = 0; 5879a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = std::make_shared<DmInitCallbackTest>(count); 5979a732c7Sopenharmony_ci // 2. set checkMap null 6079a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 6179a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 6279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 6379a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 6479a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 6579a732c7Sopenharmony_ci // 5. check checkMap not null 6679a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 6779a732c7Sopenharmony_ci} 6879a732c7Sopenharmony_ci 6979a732c7Sopenharmony_ci/** 7079a732c7Sopenharmony_ci * @tc.name: RegisterDeathRecipientCallback_002 7179a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 7279a732c7Sopenharmony_ci * set dmInitCallback null 7379a732c7Sopenharmony_ci * 2. set checkMap null 7479a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 7579a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 7679a732c7Sopenharmony_ci * 5. check checkMap not null 7779a732c7Sopenharmony_ci * deviceTypeId 7879a732c7Sopenharmony_ci * @tc.type: FUNC 7979a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 8079a732c7Sopenharmony_ci */ 8179a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDeathRecipientCallback_002, testing::ext::TestSize.Level0) 8279a732c7Sopenharmony_ci{ 8379a732c7Sopenharmony_ci // 1. set pkgName not null 8479a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 8579a732c7Sopenharmony_ci // set dmInitCallback not null 8679a732c7Sopenharmony_ci int count = 0; 8779a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = std::make_shared<DmInitCallbackTest>(count); 8879a732c7Sopenharmony_ci // 2. set checkMap not null 8979a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 9079a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 9179a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 9279a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 9379a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 9479a732c7Sopenharmony_ci // 5. check checkMap null 9579a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 9679a732c7Sopenharmony_ci} 9779a732c7Sopenharmony_ci 9879a732c7Sopenharmony_ci/** 9979a732c7Sopenharmony_ci * @tc.name: RegisterDeathRecipientCallback_003 10079a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 10179a732c7Sopenharmony_ci * set dmInitCallback not null 10279a732c7Sopenharmony_ci * 2. set checkMap null 10379a732c7Sopenharmony_ci * 3. set testpkcName com.ohos.test1 10479a732c7Sopenharmony_ci * 4. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 10579a732c7Sopenharmony_ci * 5. Get checkMap from DeviceManagerNotify with testpkcName 10679a732c7Sopenharmony_ci * 6. check checkMap null 10779a732c7Sopenharmony_ci * deviceTypeId 10879a732c7Sopenharmony_ci * @tc.type: FUNC 10979a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 11079a732c7Sopenharmony_ci */ 11179a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDeathRecipientCallback_003, testing::ext::TestSize.Level0) 11279a732c7Sopenharmony_ci{ 11379a732c7Sopenharmony_ci // 1. set pkgName com.ohos.test 11479a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 11579a732c7Sopenharmony_ci // set dmInitCallback not null 11679a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = nullptr; 11779a732c7Sopenharmony_ci // 2. set checkMap null 11879a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 11979a732c7Sopenharmony_ci // 3. set testpkcName com.ohos.test1 12079a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 12179a732c7Sopenharmony_ci // 4. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 12279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 12379a732c7Sopenharmony_ci // 5. Get checkMap from DeviceManagerNotify with testpkcName 12479a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[testPkgName]; 12579a732c7Sopenharmony_ci // 6. check checkMap not null 12679a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 12779a732c7Sopenharmony_ci} 12879a732c7Sopenharmony_ci 12979a732c7Sopenharmony_ci/** 13079a732c7Sopenharmony_ci * @tc.name: RegisterDeathRecipientCallback_004 13179a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 13279a732c7Sopenharmony_ci * set dmInitCallback not null 13379a732c7Sopenharmony_ci * 2. set checkMap null 13479a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 13579a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 13679a732c7Sopenharmony_ci * 5. check checkMap not null 13779a732c7Sopenharmony_ci * 6. call checkMap OnRemoteDied 13879a732c7Sopenharmony_ci * 7. check count is 1 13979a732c7Sopenharmony_ci * deviceTypeId 14079a732c7Sopenharmony_ci * @tc.type: FUNC 14179a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 14279a732c7Sopenharmony_ci */ 14379a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDeathRecipientCallback_004, testing::ext::TestSize.Level0) 14479a732c7Sopenharmony_ci{ 14579a732c7Sopenharmony_ci // 1. set pkgName not null 14679a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 14779a732c7Sopenharmony_ci // set dmInitCallback not null 14879a732c7Sopenharmony_ci int count = 0; 14979a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = std::make_shared<DmInitCallbackTest>(count); 15079a732c7Sopenharmony_ci // 2. set checkMap null 15179a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 15279a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 15379a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 15479a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 15579a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 15679a732c7Sopenharmony_ci // 5. check checkMap not null 15779a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 15879a732c7Sopenharmony_ci // 6. call checkMap OnRemoteDied 15979a732c7Sopenharmony_ci if (checkMap != nullptr) { 16079a732c7Sopenharmony_ci checkMap->OnRemoteDied(); 16179a732c7Sopenharmony_ci } 16279a732c7Sopenharmony_ci // 7. check count is 1 16379a732c7Sopenharmony_ci ASSERT_EQ(count, 1); 16479a732c7Sopenharmony_ci} 16579a732c7Sopenharmony_ci 16679a732c7Sopenharmony_ci/** 16779a732c7Sopenharmony_ci * @tc.name: RegisterDeathRecipientCallback_005 16879a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 16979a732c7Sopenharmony_ci * set dmInitCallback not null 17079a732c7Sopenharmony_ci * 2. set checkMap null 17179a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 17279a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 17379a732c7Sopenharmony_ci * 5. check checkMap not null 17479a732c7Sopenharmony_ci * 6. call checkMap OnRemoteDied 17579a732c7Sopenharmony_ci * 7. check count is 1 17679a732c7Sopenharmony_ci * deviceTypeId 17779a732c7Sopenharmony_ci * @tc.type: FUNC 17879a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 17979a732c7Sopenharmony_ci */ 18079a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDeathRecipientCallback_005, testing::ext::TestSize.Level0) 18179a732c7Sopenharmony_ci{ 18279a732c7Sopenharmony_ci // 1. set pkgName not null 18379a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 18479a732c7Sopenharmony_ci // set dmInitCallback not null 18579a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = nullptr; 18679a732c7Sopenharmony_ci // 2. set checkMap null 18779a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 18879a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 18979a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 19079a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 19179a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 19279a732c7Sopenharmony_ci // 5. check checkMap not null 19379a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 19479a732c7Sopenharmony_ci} 19579a732c7Sopenharmony_ci 19679a732c7Sopenharmony_ci/** 19779a732c7Sopenharmony_ci * @tc.name: RegisterDeathRecipientCallback_005 19879a732c7Sopenharmony_ci * @tc.type: FUNC 19979a732c7Sopenharmony_ci */ 20079a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDeathRecipientCallback_006, testing::ext::TestSize.Level0) 20179a732c7Sopenharmony_ci{ 20279a732c7Sopenharmony_ci std::string pkgName; 20379a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = nullptr; 20479a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 20579a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 20679a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 20779a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 20879a732c7Sopenharmony_ci} 20979a732c7Sopenharmony_ci 21079a732c7Sopenharmony_ci/** 21179a732c7Sopenharmony_ci * @tc.name: UnRegisterDeathRecipientCallback_001 21279a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 21379a732c7Sopenharmony_ci * set dmInitCallback not null 21479a732c7Sopenharmony_ci * 2. set checkMap null 21579a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 21679a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 21779a732c7Sopenharmony_ci * 5. check checkMap not null 21879a732c7Sopenharmony_ci * 6. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with parameter 21979a732c7Sopenharmony_ci * 7. Get checkMap from DeviceManagerNotify 22079a732c7Sopenharmony_ci * 8. check checkMap null 22179a732c7Sopenharmony_ci * deviceTypeId 22279a732c7Sopenharmony_ci * @tc.type: FUNC 22379a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 22479a732c7Sopenharmony_ci */ 22579a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDeathRecipientCallback_001, testing::ext::TestSize.Level0) 22679a732c7Sopenharmony_ci{ 22779a732c7Sopenharmony_ci // 1. set pkgName not null 22879a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 22979a732c7Sopenharmony_ci // set dmInitCallback not null 23079a732c7Sopenharmony_ci int count = 0; 23179a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = std::make_shared<DmInitCallbackTest>(count); 23279a732c7Sopenharmony_ci // 2. set checkMap null 23379a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 23479a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 23579a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 23679a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback 23779a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 23879a732c7Sopenharmony_ci // 5. check checkMap not null 23979a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 24079a732c7Sopenharmony_ci // 6. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with parameter 24179a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDeathRecipientCallback(pkgName); 24279a732c7Sopenharmony_ci // 7. Get checkMap from DeviceManagerNotify 24379a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 24479a732c7Sopenharmony_ci // 8 check checkMap null 24579a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 24679a732c7Sopenharmony_ci} 24779a732c7Sopenharmony_ci 24879a732c7Sopenharmony_ci/** 24979a732c7Sopenharmony_ci * @tc.name: UnRegisterDeathRecipientCallback_002 25079a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 25179a732c7Sopenharmony_ci * set dmInitCallback not null 25279a732c7Sopenharmony_ci * 2. set checkMap null 25379a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 25479a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 25579a732c7Sopenharmony_ci * 5. check checkMap not null 25679a732c7Sopenharmony_ci * 6. set testpkcName com.ohos.test1 25779a732c7Sopenharmony_ci * 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName 25879a732c7Sopenharmony_ci * 8. Get checkMap from DeviceManagerNotify 25979a732c7Sopenharmony_ci * 9. check checkMap not null 26079a732c7Sopenharmony_ci * deviceTypeId 26179a732c7Sopenharmony_ci * @tc.type: FUNC 26279a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 26379a732c7Sopenharmony_ci */ 26479a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDeathRecipientCallback_002, testing::ext::TestSize.Level0) 26579a732c7Sopenharmony_ci{ 26679a732c7Sopenharmony_ci // 1. set pkgName not null 26779a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 26879a732c7Sopenharmony_ci // set dmInitCallback not null 26979a732c7Sopenharmony_ci int count = 0; 27079a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = std::make_shared<DmInitCallbackTest>(count); 27179a732c7Sopenharmony_ci // 2. set checkMap null 27279a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 27379a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 27479a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 27579a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback 27679a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 27779a732c7Sopenharmony_ci // 5. check checkMap not null 27879a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 27979a732c7Sopenharmony_ci // 6. set testpkcName com.ohos.test1 28079a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 28179a732c7Sopenharmony_ci // 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName 28279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDeathRecipientCallback(testPkgName); 28379a732c7Sopenharmony_ci // 8. Get checkMap from DeviceManagerNotify 28479a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 28579a732c7Sopenharmony_ci // 8 check checkMap not null 28679a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 28779a732c7Sopenharmony_ci} 28879a732c7Sopenharmony_ci 28979a732c7Sopenharmony_ci/** 29079a732c7Sopenharmony_ci * @tc.name: UnRegisterDeathRecipientCallback_003 29179a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 29279a732c7Sopenharmony_ci * set dmInitCallback not null 29379a732c7Sopenharmony_ci * 2. set checkMap null 29479a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 29579a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 29679a732c7Sopenharmony_ci * 5. check checkMap not null 29779a732c7Sopenharmony_ci * 6. set testpkcName com.ohos.test1 29879a732c7Sopenharmony_ci * 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName 29979a732c7Sopenharmony_ci * 8. Get checkMap from DeviceManagerNotify 30079a732c7Sopenharmony_ci * 9. call checkMap OnRemoteDied 30179a732c7Sopenharmony_ci * 10. check count is 1 30279a732c7Sopenharmony_ci * deviceTypeId 30379a732c7Sopenharmony_ci * @tc.type: FUNC 30479a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 30579a732c7Sopenharmony_ci */ 30679a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDeathRecipientCallback_003, testing::ext::TestSize.Level0) 30779a732c7Sopenharmony_ci{ 30879a732c7Sopenharmony_ci // 1. set pkgName not null 30979a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 31079a732c7Sopenharmony_ci // set dmInitCallback not null 31179a732c7Sopenharmony_ci int count = 0; 31279a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = std::make_shared<DmInitCallbackTest>(count); 31379a732c7Sopenharmony_ci // 2. set checkMap null 31479a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 31579a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 31679a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 31779a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback 31879a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 31979a732c7Sopenharmony_ci // 5. check checkMap not null 32079a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 32179a732c7Sopenharmony_ci // 6. set testpkcName com.ohos.test1 32279a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 32379a732c7Sopenharmony_ci // 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName 32479a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDeathRecipientCallback(testPkgName); 32579a732c7Sopenharmony_ci // 8. Get checkMap from DeviceManagerNotify 32679a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 32779a732c7Sopenharmony_ci // 9. call checkMap OnRemoteDied 32879a732c7Sopenharmony_ci if (checkMap != nullptr) { 32979a732c7Sopenharmony_ci checkMap->OnRemoteDied(); 33079a732c7Sopenharmony_ci } 33179a732c7Sopenharmony_ci // 10. check count is 1 33279a732c7Sopenharmony_ci ASSERT_EQ(count, 1); 33379a732c7Sopenharmony_ci} 33479a732c7Sopenharmony_ci 33579a732c7Sopenharmony_ci/** 33679a732c7Sopenharmony_ci * @tc.name: UnRegisterDeathRecipientCallback_004 33779a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 33879a732c7Sopenharmony_ci * set dmInitCallback not null 33979a732c7Sopenharmony_ci * 2. set checkMap null 34079a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 34179a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 34279a732c7Sopenharmony_ci * 5. check checkMap not null 34379a732c7Sopenharmony_ci * 6. set testpkcName com.ohos.test1 34479a732c7Sopenharmony_ci * 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName 34579a732c7Sopenharmony_ci * 8. Get checkMap from DeviceManagerNotify 34679a732c7Sopenharmony_ci * 9. check checkMap not null 34779a732c7Sopenharmony_ci * deviceTypeId 34879a732c7Sopenharmony_ci * @tc.type: FUNC 34979a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 35079a732c7Sopenharmony_ci */ 35179a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDeathRecipientCallback_004, testing::ext::TestSize.Level0) 35279a732c7Sopenharmony_ci{ 35379a732c7Sopenharmony_ci // 1. set pkgName not null 35479a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 35579a732c7Sopenharmony_ci // set dmInitCallback not null 35679a732c7Sopenharmony_ci int count = 0; 35779a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = std::make_shared<DmInitCallbackTest>(count); 35879a732c7Sopenharmony_ci // 2. set checkMap null 35979a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 36079a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 36179a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 36279a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback 36379a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 36479a732c7Sopenharmony_ci // 5. check checkMap not null 36579a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 36679a732c7Sopenharmony_ci // 6. set testpkcName com.ohos.test1 36779a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 36879a732c7Sopenharmony_ci // 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName 36979a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDeathRecipientCallback(testPkgName); 37079a732c7Sopenharmony_ci // 8. Get checkMap from DeviceManagerNotify 37179a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 37279a732c7Sopenharmony_ci // 9. check checkMap not null 37379a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 37479a732c7Sopenharmony_ci} 37579a732c7Sopenharmony_ci 37679a732c7Sopenharmony_ci/** 37779a732c7Sopenharmony_ci * @tc.name: UnRegisterDeathRecipientCallback_005 37879a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 37979a732c7Sopenharmony_ci * set dmInitCallback not null 38079a732c7Sopenharmony_ci * 2. set checkMap null 38179a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 38279a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 38379a732c7Sopenharmony_ci * 5. check checkMap not null 38479a732c7Sopenharmony_ci * 6. set testpkcName com.ohos.test1 38579a732c7Sopenharmony_ci * 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName 38679a732c7Sopenharmony_ci * 8. Get checkMap from DeviceManagerNotify 38779a732c7Sopenharmony_ci * 9. check checkMap not null 38879a732c7Sopenharmony_ci * deviceTypeId 38979a732c7Sopenharmony_ci * @tc.type: FUNC 39079a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 39179a732c7Sopenharmony_ci */ 39279a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDeathRecipientCallback_005, testing::ext::TestSize.Level0) 39379a732c7Sopenharmony_ci{ 39479a732c7Sopenharmony_ci // 1. set pkgName not null 39579a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 39679a732c7Sopenharmony_ci // set dmInitCallback not null 39779a732c7Sopenharmony_ci int count = 0; 39879a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = std::make_shared<DmInitCallbackTest>(count); 39979a732c7Sopenharmony_ci // 2. set checkMap null 40079a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 40179a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 40279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 40379a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback 40479a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 40579a732c7Sopenharmony_ci // 5. check checkMap not null 40679a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 40779a732c7Sopenharmony_ci // 6. set testpkcName nullptr 40879a732c7Sopenharmony_ci std::string testPkgName = ""; 40979a732c7Sopenharmony_ci // 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName 41079a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDeathRecipientCallback(testPkgName); 41179a732c7Sopenharmony_ci // 8. Get checkMap from DeviceManagerNotify 41279a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 41379a732c7Sopenharmony_ci // 8 check checkMap not null 41479a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 41579a732c7Sopenharmony_ci} 41679a732c7Sopenharmony_ci 41779a732c7Sopenharmony_ci/** 41879a732c7Sopenharmony_ci * @tc.name: RegisterDeviceStateCallback_001 41979a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 42079a732c7Sopenharmony_ci * set Callback not null 42179a732c7Sopenharmony_ci * 2. set checkMap null 42279a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 42379a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 42479a732c7Sopenharmony_ci * 5. check checkMap not null 42579a732c7Sopenharmony_ci * deviceTypeId 42679a732c7Sopenharmony_ci * @tc.type: FUNC 42779a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 42879a732c7Sopenharmony_ci */ 42979a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDeviceStateCallback_001, testing::ext::TestSize.Level0) 43079a732c7Sopenharmony_ci{ 43179a732c7Sopenharmony_ci // 1. set pkgName not null 43279a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 43379a732c7Sopenharmony_ci // set Callback not null 43479a732c7Sopenharmony_ci int count = 0; 43579a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> callback = std::make_shared<DeviceStateCallbackTest>(count); 43679a732c7Sopenharmony_ci // 2. set checkMap null 43779a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap = nullptr; 43879a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 43979a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); 44079a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 44179a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 44279a732c7Sopenharmony_ci // 5. check checkMap not null 44379a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 44479a732c7Sopenharmony_ci} 44579a732c7Sopenharmony_ci 44679a732c7Sopenharmony_ci/** 44779a732c7Sopenharmony_ci * @tc.name: RegisterDeviceStateCallback_002 44879a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 44979a732c7Sopenharmony_ci * set Callback not null 45079a732c7Sopenharmony_ci * 2. set checkMap null 45179a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 45279a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 45379a732c7Sopenharmony_ci * 5. check checkMap not null 45479a732c7Sopenharmony_ci * @tc.type: FUNC 45579a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 45679a732c7Sopenharmony_ci */ 45779a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDeviceStateCallback_002, testing::ext::TestSize.Level0) 45879a732c7Sopenharmony_ci{ 45979a732c7Sopenharmony_ci // 1. set pkgName not null 46079a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 46179a732c7Sopenharmony_ci // set dmInitCallback not null 46279a732c7Sopenharmony_ci int count = 0; 46379a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> callback = std::make_shared<DeviceStateCallbackTest>(count); 46479a732c7Sopenharmony_ci // 2. set checkMap null 46579a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap = nullptr; 46679a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 46779a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); 46879a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 46979a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 47079a732c7Sopenharmony_ci // 5. check checkMap null 47179a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 47279a732c7Sopenharmony_ci} 47379a732c7Sopenharmony_ci 47479a732c7Sopenharmony_ci/** 47579a732c7Sopenharmony_ci * @tc.name: RegisterDeviceStateCallback_003 47679a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 47779a732c7Sopenharmony_ci * set Callback not null 47879a732c7Sopenharmony_ci * 2. set checkMap null 47979a732c7Sopenharmony_ci * 3. set testpkcName com.ohos.test1 48079a732c7Sopenharmony_ci * 4. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 48179a732c7Sopenharmony_ci * 5. Get checkMap from DeviceManagerNotify with testpkcName 48279a732c7Sopenharmony_ci * 6. check checkMap null 48379a732c7Sopenharmony_ci * @tc.type: FUNC 48479a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 48579a732c7Sopenharmony_ci */ 48679a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDeviceStateCallback_003, testing::ext::TestSize.Level0) 48779a732c7Sopenharmony_ci{ 48879a732c7Sopenharmony_ci // 1. set pkgName com.ohos.test 48979a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 49079a732c7Sopenharmony_ci // set dmInitCallback not null 49179a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> callback = nullptr; 49279a732c7Sopenharmony_ci // 2. set checkMap null 49379a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap = nullptr; 49479a732c7Sopenharmony_ci // 3. set testpkcName com.ohos.test1 49579a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 49679a732c7Sopenharmony_ci // 4. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 49779a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); 49879a732c7Sopenharmony_ci // 5. Get checkMap from DeviceManagerNotify with testpkcName 49979a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[testPkgName]; 50079a732c7Sopenharmony_ci // 6. check checkMap not null 50179a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 50279a732c7Sopenharmony_ci} 50379a732c7Sopenharmony_ci 50479a732c7Sopenharmony_ci/** 50579a732c7Sopenharmony_ci * @tc.name: RegisterDeviceStateCallback_004 50679a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 50779a732c7Sopenharmony_ci * set Callback not null 50879a732c7Sopenharmony_ci * 2. set checkMap null 50979a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 51079a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 51179a732c7Sopenharmony_ci * 5. check checkMap not null 51279a732c7Sopenharmony_ci * 6. call checkMap OnDeviceOnline 51379a732c7Sopenharmony_ci * 7. check count is 1 51479a732c7Sopenharmony_ci * @tc.type: FUNC 51579a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 51679a732c7Sopenharmony_ci */ 51779a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDeviceStateCallback_004, testing::ext::TestSize.Level0) 51879a732c7Sopenharmony_ci{ 51979a732c7Sopenharmony_ci // 1. set pkgName not null 52079a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 52179a732c7Sopenharmony_ci // set Callback not null 52279a732c7Sopenharmony_ci int count = 0; 52379a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> callback = std::make_shared<DeviceStateCallbackTest>(count); 52479a732c7Sopenharmony_ci // 2. set checkMap null 52579a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap = nullptr; 52679a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 52779a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); 52879a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 52979a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 53079a732c7Sopenharmony_ci // 5. check checkMap not null 53179a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 53279a732c7Sopenharmony_ci // 6. call checkMap OnDeviceOnline 53379a732c7Sopenharmony_ci DmDeviceInfo deviceInfo; 53479a732c7Sopenharmony_ci if (checkMap != nullptr) { 53579a732c7Sopenharmony_ci checkMap->OnDeviceOnline(deviceInfo); 53679a732c7Sopenharmony_ci } 53779a732c7Sopenharmony_ci // 7. check count is 1 53879a732c7Sopenharmony_ci ASSERT_EQ(count, 1); 53979a732c7Sopenharmony_ci} 54079a732c7Sopenharmony_ci 54179a732c7Sopenharmony_ci/** 54279a732c7Sopenharmony_ci * @tc.name: RegisterDeviceStateCallback_005 54379a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 54479a732c7Sopenharmony_ci * set Callback not null 54579a732c7Sopenharmony_ci * 2. set checkMap null 54679a732c7Sopenharmony_ci * 3. set testpkcName com.ohos.test1 54779a732c7Sopenharmony_ci * 4. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 54879a732c7Sopenharmony_ci * 5. Get checkMap from DeviceManagerNotify with testpkcName 54979a732c7Sopenharmony_ci * 6. check checkMap null 55079a732c7Sopenharmony_ci * @tc.type: FUNC 55179a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 55279a732c7Sopenharmony_ci */ 55379a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDeviceStateCallback_005, testing::ext::TestSize.Level0) 55479a732c7Sopenharmony_ci{ 55579a732c7Sopenharmony_ci // 1. set pkgName com.ohos.test 55679a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 55779a732c7Sopenharmony_ci int count = 0; 55879a732c7Sopenharmony_ci // set dmInitCallback not null 55979a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> callback = std::make_shared<DeviceStateCallbackTest>(count); 56079a732c7Sopenharmony_ci // 2. set checkMap null 56179a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap = nullptr; 56279a732c7Sopenharmony_ci // 3. set testpkcName com.ohos.test1 56379a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 56479a732c7Sopenharmony_ci // 4. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 56579a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); 56679a732c7Sopenharmony_ci // 5. Get checkMap from DeviceManagerNotify with testpkcName 56779a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[testPkgName]; 56879a732c7Sopenharmony_ci // 6. check checkMap not null 56979a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 57079a732c7Sopenharmony_ci} 57179a732c7Sopenharmony_ci 57279a732c7Sopenharmony_ci/** 57379a732c7Sopenharmony_ci * @tc.name: UnRegisterDeviceStateCallback_001 57479a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 57579a732c7Sopenharmony_ci * set Callback not null 57679a732c7Sopenharmony_ci * 2. set checkMap null 57779a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 57879a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 57979a732c7Sopenharmony_ci * 5. check checkMap not null 58079a732c7Sopenharmony_ci * 6. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with parameter 58179a732c7Sopenharmony_ci * 7. Get checkMap from DeviceManagerNotify 58279a732c7Sopenharmony_ci * 8. check checkMap null 58379a732c7Sopenharmony_ci * @tc.type: FUNC 58479a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 58579a732c7Sopenharmony_ci */ 58679a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceStateCallback_001, testing::ext::TestSize.Level0) 58779a732c7Sopenharmony_ci{ 58879a732c7Sopenharmony_ci // 1. set pkgName not null 58979a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 59079a732c7Sopenharmony_ci // set dmInitCallback not null 59179a732c7Sopenharmony_ci int count = 0; 59279a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> callback = std::make_shared<DeviceStateCallbackTest>(count); 59379a732c7Sopenharmony_ci // 2. set checkMap null 59479a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap = nullptr; 59579a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 59679a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); 59779a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback 59879a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 59979a732c7Sopenharmony_ci // 5. check checkMap not null 60079a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 60179a732c7Sopenharmony_ci // 6. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with parameter 60279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(pkgName); 60379a732c7Sopenharmony_ci // 7. Get checkMap from DeviceManagerNotify 60479a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 60579a732c7Sopenharmony_ci // 8 check checkMap null 60679a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 60779a732c7Sopenharmony_ci} 60879a732c7Sopenharmony_ci 60979a732c7Sopenharmony_ci/** 61079a732c7Sopenharmony_ci * @tc.name: UnRegisterDeviceStateCallback_002 61179a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 61279a732c7Sopenharmony_ci * set Callback not null 61379a732c7Sopenharmony_ci * 2. set checkMap null 61479a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 61579a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 61679a732c7Sopenharmony_ci * 5. check checkMap not null 61779a732c7Sopenharmony_ci * 6. set testpkcName com.ohos.test1 61879a732c7Sopenharmony_ci * 7. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with testpkcName 61979a732c7Sopenharmony_ci * 8. Get checkMap from DeviceManagerNotify 62079a732c7Sopenharmony_ci * 9. check checkMap not null 62179a732c7Sopenharmony_ci * @tc.type: FUNC 62279a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 62379a732c7Sopenharmony_ci */ 62479a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceStateCallback_002, testing::ext::TestSize.Level0) 62579a732c7Sopenharmony_ci{ 62679a732c7Sopenharmony_ci // 1. set pkgName not null 62779a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 62879a732c7Sopenharmony_ci // set dmInitCallback not null 62979a732c7Sopenharmony_ci int count = 0; 63079a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> callback = std::make_shared<DeviceStateCallbackTest>(count); 63179a732c7Sopenharmony_ci // 2. set checkMap null 63279a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap = nullptr; 63379a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 63479a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); 63579a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback 63679a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 63779a732c7Sopenharmony_ci // 5. check checkMap not null 63879a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 63979a732c7Sopenharmony_ci // 6. set testpkcName com.ohos.test1 64079a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 64179a732c7Sopenharmony_ci // 7. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with testpkcName 64279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(testPkgName); 64379a732c7Sopenharmony_ci // 8. Get checkMap from DeviceManagerNotify 64479a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 64579a732c7Sopenharmony_ci // 8 check checkMap not null 64679a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 64779a732c7Sopenharmony_ci} 64879a732c7Sopenharmony_ci 64979a732c7Sopenharmony_ci/** 65079a732c7Sopenharmony_ci * @tc.name: UnRegisterDeviceStateCallback_003 65179a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 65279a732c7Sopenharmony_ci * set Callback not null 65379a732c7Sopenharmony_ci * 2. set checkMap null 65479a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 65579a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 65679a732c7Sopenharmony_ci * 5. check checkMap not null 65779a732c7Sopenharmony_ci * 6. set testpkcName com.ohos.test1 65879a732c7Sopenharmony_ci * 7. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with testpkcName 65979a732c7Sopenharmony_ci * 8. Get checkMap from DeviceManagerNotify 66079a732c7Sopenharmony_ci * 9. check checkMap not null 66179a732c7Sopenharmony_ci * @tc.type: FUNC 66279a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 66379a732c7Sopenharmony_ci */ 66479a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceStateCallback_003, testing::ext::TestSize.Level0) 66579a732c7Sopenharmony_ci{ 66679a732c7Sopenharmony_ci // 1. set pkgName not null 66779a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 66879a732c7Sopenharmony_ci // set dmInitCallback not null 66979a732c7Sopenharmony_ci int count = 0; 67079a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> callback = std::make_shared<DeviceStateCallbackTest>(count); 67179a732c7Sopenharmony_ci // 2. set checkMap null 67279a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap = nullptr; 67379a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 67479a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); 67579a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback 67679a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 67779a732c7Sopenharmony_ci // 5. check checkMap not null 67879a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 67979a732c7Sopenharmony_ci // 6. set testpkcName com.ohos.test1 68079a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 68179a732c7Sopenharmony_ci // 7. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with testpkcName 68279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(testPkgName); 68379a732c7Sopenharmony_ci // 8. Get checkMap from DeviceManagerNotify 68479a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 68579a732c7Sopenharmony_ci // 8 check checkMap not null 68679a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 68779a732c7Sopenharmony_ci // 9. call checkMap OnDeviceOnline 68879a732c7Sopenharmony_ci DmDeviceInfo deviceInfo; 68979a732c7Sopenharmony_ci if (checkMap != nullptr) { 69079a732c7Sopenharmony_ci checkMap->OnDeviceOnline(deviceInfo); 69179a732c7Sopenharmony_ci } 69279a732c7Sopenharmony_ci // 10. check count is 1 69379a732c7Sopenharmony_ci ASSERT_EQ(count, 1); 69479a732c7Sopenharmony_ci} 69579a732c7Sopenharmony_ci 69679a732c7Sopenharmony_ci/** 69779a732c7Sopenharmony_ci * @tc.name: UnRegisterDeviceStateCallback_004 69879a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 69979a732c7Sopenharmony_ci * set Callback not null 70079a732c7Sopenharmony_ci * 2. set checkMap null 70179a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 70279a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 70379a732c7Sopenharmony_ci * 5. check checkMap not null 70479a732c7Sopenharmony_ci * 6. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with parameter 70579a732c7Sopenharmony_ci * 7. Get checkMap from DeviceManagerNotify 70679a732c7Sopenharmony_ci * 8. check checkMap null 70779a732c7Sopenharmony_ci * @tc.type: FUNC 70879a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 70979a732c7Sopenharmony_ci */ 71079a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceStateCallback_004, testing::ext::TestSize.Level0) 71179a732c7Sopenharmony_ci{ 71279a732c7Sopenharmony_ci // 1. set pkgName not null 71379a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 71479a732c7Sopenharmony_ci // set dmInitCallback not null 71579a732c7Sopenharmony_ci int count = 0; 71679a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> callback = std::make_shared<DeviceStateCallbackTest>(count); 71779a732c7Sopenharmony_ci // 2. set checkMap null 71879a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap = nullptr; 71979a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 72079a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); 72179a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback 72279a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 72379a732c7Sopenharmony_ci // 5. check checkMap not null 72479a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 72579a732c7Sopenharmony_ci // 6. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with parameter 72679a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(pkgName); 72779a732c7Sopenharmony_ci // 7. Get checkMap from DeviceManagerNotify 72879a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 72979a732c7Sopenharmony_ci // 8 check checkMap null 73079a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 73179a732c7Sopenharmony_ci} 73279a732c7Sopenharmony_ci 73379a732c7Sopenharmony_ci/** 73479a732c7Sopenharmony_ci * @tc.name: UnRegisterDeviceStateCallback_005 73579a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 73679a732c7Sopenharmony_ci * set Callback not null 73779a732c7Sopenharmony_ci * 2. set checkMap null 73879a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 73979a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 74079a732c7Sopenharmony_ci * 5. check checkMap not null 74179a732c7Sopenharmony_ci * 6. set testpkcName com.ohos.test1 74279a732c7Sopenharmony_ci * 7. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with testpkcName 74379a732c7Sopenharmony_ci * 8. Get checkMap from DeviceManagerNotify 74479a732c7Sopenharmony_ci * 9. check checkMap not null 74579a732c7Sopenharmony_ci * @tc.type: FUNC 74679a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 74779a732c7Sopenharmony_ci */ 74879a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceStateCallback_005, testing::ext::TestSize.Level0) 74979a732c7Sopenharmony_ci{ 75079a732c7Sopenharmony_ci // 1. set pkgName not null 75179a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 75279a732c7Sopenharmony_ci // set dmInitCallback not null 75379a732c7Sopenharmony_ci int count = 0; 75479a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> callback = std::make_shared<DeviceStateCallbackTest>(count); 75579a732c7Sopenharmony_ci // 2. set checkMap null 75679a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap = nullptr; 75779a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter 75879a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); 75979a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback 76079a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 76179a732c7Sopenharmony_ci // 5. check checkMap not null 76279a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 76379a732c7Sopenharmony_ci // 6. set testpkcName com.ohos.test1 76479a732c7Sopenharmony_ci std::string testPkgName = ""; 76579a732c7Sopenharmony_ci // 7. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with testpkcName 76679a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(testPkgName); 76779a732c7Sopenharmony_ci // 8. Get checkMap from DeviceManagerNotify 76879a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 76979a732c7Sopenharmony_ci // 8 check checkMap not null 77079a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 77179a732c7Sopenharmony_ci // 9. call checkMap OnDeviceOnline 77279a732c7Sopenharmony_ci DmDeviceInfo deviceInfo; 77379a732c7Sopenharmony_ci if (checkMap != nullptr) { 77479a732c7Sopenharmony_ci checkMap->OnDeviceOnline(deviceInfo); 77579a732c7Sopenharmony_ci } 77679a732c7Sopenharmony_ci // 10. check count is 1 77779a732c7Sopenharmony_ci ASSERT_EQ(count, 1); 77879a732c7Sopenharmony_ci} 77979a732c7Sopenharmony_ci 78079a732c7Sopenharmony_ci/** 78179a732c7Sopenharmony_ci * @tc.name: RegisterDiscoverCallback_001 78279a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 78379a732c7Sopenharmony_ci * set Callback not null 78479a732c7Sopenharmony_ci * set subscribeId not null 78579a732c7Sopenharmony_ci * 2. set checkMap null 78679a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 78779a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 78879a732c7Sopenharmony_ci * 5. check checkMap not null 78979a732c7Sopenharmony_ci * @tc.type: FUNC 79079a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 79179a732c7Sopenharmony_ci */ 79279a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDiscoveryCallback_001, testing::ext::TestSize.Level0) 79379a732c7Sopenharmony_ci{ 79479a732c7Sopenharmony_ci // 1. set pkgName not null 79579a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 79679a732c7Sopenharmony_ci // set dmInitCallback not null 79779a732c7Sopenharmony_ci int count = 0; 79879a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> callback = std::make_shared<DiscoveryCallbackTest>(count); 79979a732c7Sopenharmony_ci // set subscribeId not null 80079a732c7Sopenharmony_ci uint16_t subscribeId = 0; 80179a732c7Sopenharmony_ci // 2. set checkMap null 80279a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap = nullptr; 80379a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 80479a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); 80579a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 80679a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 80779a732c7Sopenharmony_ci // 5. check checkMap not null 80879a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 80979a732c7Sopenharmony_ci} 81079a732c7Sopenharmony_ci 81179a732c7Sopenharmony_ci/** 81279a732c7Sopenharmony_ci * @tc.name: RegisterDiscoverCallback_002 81379a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 81479a732c7Sopenharmony_ci * set Callback null 81579a732c7Sopenharmony_ci * set subscribeId not null 81679a732c7Sopenharmony_ci * 2. set checkMap null 81779a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 81879a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 81979a732c7Sopenharmony_ci * 5. check checkMap mot null 82079a732c7Sopenharmony_ci * @tc.type: FUNC 82179a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 82279a732c7Sopenharmony_ci */ 82379a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDiscoveryCallback_002, testing::ext::TestSize.Level0) 82479a732c7Sopenharmony_ci{ 82579a732c7Sopenharmony_ci // 1. set pkgName not null 82679a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 82779a732c7Sopenharmony_ci // set dmInitCallback not null 82879a732c7Sopenharmony_ci int count = 0; 82979a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> callback = std::make_shared<DiscoveryCallbackTest>(count); 83079a732c7Sopenharmony_ci // set subscribeId not null 83179a732c7Sopenharmony_ci uint16_t subscribeId = 0; 83279a732c7Sopenharmony_ci // 2. set checkMap not null 83379a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap = nullptr; 83479a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 83579a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); 83679a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 83779a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 83879a732c7Sopenharmony_ci // 5. check checkMap null 83979a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 84079a732c7Sopenharmony_ci} 84179a732c7Sopenharmony_ci 84279a732c7Sopenharmony_ci/** 84379a732c7Sopenharmony_ci * @tc.name: RegisterDiscoverCallback_003 84479a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 84579a732c7Sopenharmony_ci * set Callback not null 84679a732c7Sopenharmony_ci * set subscribeId not null 84779a732c7Sopenharmony_ci * 2. set checkMap null 84879a732c7Sopenharmony_ci * 3. set testpkcName com.ohos.test1 84979a732c7Sopenharmony_ci * 4. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 85079a732c7Sopenharmony_ci * 5. Get checkMap from DeviceManagerNotify with testpkcName 85179a732c7Sopenharmony_ci * 6. check checkMap null 85279a732c7Sopenharmony_ci * @tc.type: FUNC 85379a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 85479a732c7Sopenharmony_ci */ 85579a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDiscoveryCallback_003, testing::ext::TestSize.Level0) 85679a732c7Sopenharmony_ci{ 85779a732c7Sopenharmony_ci // 1. set pkgName com.ohos.test 85879a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 85979a732c7Sopenharmony_ci // set dmInitCallback not null 86079a732c7Sopenharmony_ci int count = 0; 86179a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> callback = std::make_shared<DiscoveryCallbackTest>(count); 86279a732c7Sopenharmony_ci // set subscribeId not null 86379a732c7Sopenharmony_ci uint16_t subscribeId = 0; 86479a732c7Sopenharmony_ci // 2. set checkMap null 86579a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap = nullptr; 86679a732c7Sopenharmony_ci // 3. set testpkcName com.ohos.test1 86779a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 86879a732c7Sopenharmony_ci // 4. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 86979a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); 87079a732c7Sopenharmony_ci // 5. Get checkMap from DeviceManagerNotify with testpkcName 87179a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 87279a732c7Sopenharmony_ci // 6. check checkMap not null 87379a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 87479a732c7Sopenharmony_ci} 87579a732c7Sopenharmony_ci 87679a732c7Sopenharmony_ci/** 87779a732c7Sopenharmony_ci * @tc.name: RegisterDiscoverCallback_004 87879a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 87979a732c7Sopenharmony_ci * set Callback not null 88079a732c7Sopenharmony_ci * set subscribeId not null 88179a732c7Sopenharmony_ci * 2. set checkMap null 88279a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 88379a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 88479a732c7Sopenharmony_ci * 5. check checkMap not null 88579a732c7Sopenharmony_ci * 6. call checkMap OnDiscoverySuccess 88679a732c7Sopenharmony_ci * 7. check count is 1 88779a732c7Sopenharmony_ci * @tc.type: FUNC 88879a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 88979a732c7Sopenharmony_ci */ 89079a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDiscoveryCallback_004, testing::ext::TestSize.Level0) 89179a732c7Sopenharmony_ci{ 89279a732c7Sopenharmony_ci // 1. set pkgName not null 89379a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 89479a732c7Sopenharmony_ci // set dmInitCallback not null 89579a732c7Sopenharmony_ci int count = 0; 89679a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> callback = std::make_shared<DiscoveryCallbackTest>(count); 89779a732c7Sopenharmony_ci // set subscribeId not null 89879a732c7Sopenharmony_ci uint16_t subscribeId = 0; 89979a732c7Sopenharmony_ci // 2. set checkMap null 90079a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap = nullptr; 90179a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter 90279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); 90379a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 90479a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 90579a732c7Sopenharmony_ci // 5. check checkMap not null 90679a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 90779a732c7Sopenharmony_ci // 6. call checkMap OnDiscoverySuccess 90879a732c7Sopenharmony_ci if (checkMap != nullptr) { 90979a732c7Sopenharmony_ci checkMap->OnDiscoverySuccess(subscribeId); 91079a732c7Sopenharmony_ci } 91179a732c7Sopenharmony_ci // 7. check count is 1 91279a732c7Sopenharmony_ci ASSERT_EQ(count, 1); 91379a732c7Sopenharmony_ci} 91479a732c7Sopenharmony_ci 91579a732c7Sopenharmony_ci/** 91679a732c7Sopenharmony_ci * @tc.name: RegisterDiscoverCallback_005 91779a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 91879a732c7Sopenharmony_ci * set Callback not null 91979a732c7Sopenharmony_ci * set subscribeId not null 92079a732c7Sopenharmony_ci * 2. set checkMap null 92179a732c7Sopenharmony_ci * 3. set testpkcName com.ohos.test1 92279a732c7Sopenharmony_ci * 4. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 92379a732c7Sopenharmony_ci * 5. Get checkMap from DeviceManagerNotify with testpkcName 92479a732c7Sopenharmony_ci * 6. check checkMap null 92579a732c7Sopenharmony_ci * @tc.type: FUNC 92679a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 92779a732c7Sopenharmony_ci */ 92879a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDiscoveryCallback_005, testing::ext::TestSize.Level0) 92979a732c7Sopenharmony_ci{ 93079a732c7Sopenharmony_ci // 1. set pkgName com.ohos.test 93179a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 93279a732c7Sopenharmony_ci int count = 0; 93379a732c7Sopenharmony_ci // set dmInitCallback not null 93479a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> callback = std::make_shared<DiscoveryCallbackTest>(count); 93579a732c7Sopenharmony_ci uint16_t subscribeId = 0; 93679a732c7Sopenharmony_ci // 2. set checkMap null 93779a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap = nullptr; 93879a732c7Sopenharmony_ci // 4. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 93979a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); 94079a732c7Sopenharmony_ci // 5. Get checkMap from DeviceManagerNotify with testpkcName 94179a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 94279a732c7Sopenharmony_ci // 6. check checkMap not null 94379a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 94479a732c7Sopenharmony_ci} 94579a732c7Sopenharmony_ci 94679a732c7Sopenharmony_ci/** 94779a732c7Sopenharmony_ci * @tc.name: RegisterDiscoverCallback_006 94879a732c7Sopenharmony_ci * @tc.type: FUNC 94979a732c7Sopenharmony_ci */ 95079a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterDiscoveryCallback_006, testing::ext::TestSize.Level0) 95179a732c7Sopenharmony_ci{ 95279a732c7Sopenharmony_ci std::string pkgName; 95379a732c7Sopenharmony_ci int count = 0; 95479a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> callback = std::make_shared<DiscoveryCallbackTest>(count); 95579a732c7Sopenharmony_ci uint16_t subscribeId = 0; 95679a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); 95779a732c7Sopenharmony_ci EXPECT_EQ(DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_.count(pkgName), 0); 95879a732c7Sopenharmony_ci} 95979a732c7Sopenharmony_ci 96079a732c7Sopenharmony_ci/** 96179a732c7Sopenharmony_ci * @tc.name: UnRegisterDiscoverCallback_001 96279a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 96379a732c7Sopenharmony_ci * set callback not null 96479a732c7Sopenharmony_ci * set subscribeId not null 96579a732c7Sopenharmony_ci * 2. set checkMap null 96679a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 96779a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 96879a732c7Sopenharmony_ci * 5. check checkMap not null 96979a732c7Sopenharmony_ci * 6. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with parameter 97079a732c7Sopenharmony_ci * 7. Get checkMap from DeviceManagerNotify 97179a732c7Sopenharmony_ci * 8. check checkMap null 97279a732c7Sopenharmony_ci * @tc.type: FUNC 97379a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 97479a732c7Sopenharmony_ci */ 97579a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDiscoveryCallback_001, testing::ext::TestSize.Level0) 97679a732c7Sopenharmony_ci{ 97779a732c7Sopenharmony_ci // 1. set pkgName not null 97879a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 97979a732c7Sopenharmony_ci // set dmInitCallback not null 98079a732c7Sopenharmony_ci int count = 0; 98179a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> callback = std::make_shared<DiscoveryCallbackTest>(count); 98279a732c7Sopenharmony_ci // set subscribeId not null 98379a732c7Sopenharmony_ci uint16_t subscribeId = 0; 98479a732c7Sopenharmony_ci // 2. set checkMap null 98579a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap = nullptr; 98679a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 98779a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); 98879a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback 98979a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 99079a732c7Sopenharmony_ci // 5. check checkMap not null 99179a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 99279a732c7Sopenharmony_ci // 6. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with parameter 99379a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(pkgName, subscribeId); 99479a732c7Sopenharmony_ci // 7. Get checkMap from DeviceManagerNotify 99579a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 99679a732c7Sopenharmony_ci // 8 check checkMap null 99779a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 99879a732c7Sopenharmony_ci} 99979a732c7Sopenharmony_ci 100079a732c7Sopenharmony_ci/** 100179a732c7Sopenharmony_ci * @tc.name: UnRegisterDiscoverCallback_002 100279a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 100379a732c7Sopenharmony_ci * set dmInitCallback not null 100479a732c7Sopenharmony_ci * set subscribeId not null 100579a732c7Sopenharmony_ci * 2. set checkMap null 100679a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 100779a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 100879a732c7Sopenharmony_ci * 5. check checkMap not null 100979a732c7Sopenharmony_ci * 6. set testpkcName com.ohos.test1 101079a732c7Sopenharmony_ci * 7. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with testpkcName 101179a732c7Sopenharmony_ci * 8. Get checkMap from DeviceManagerNotify 101279a732c7Sopenharmony_ci * 9. check checkMap not null 101379a732c7Sopenharmony_ci * @tc.type: FUNC 101479a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 101579a732c7Sopenharmony_ci */ 101679a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDiscoveryCallback_002, testing::ext::TestSize.Level0) 101779a732c7Sopenharmony_ci{ 101879a732c7Sopenharmony_ci // 1. set pkgName not null 101979a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 102079a732c7Sopenharmony_ci // set dmInitCallback not null 102179a732c7Sopenharmony_ci int count = 0; 102279a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> callback = std::make_shared<DiscoveryCallbackTest>(count); 102379a732c7Sopenharmony_ci // set subscribeId not null 102479a732c7Sopenharmony_ci uint16_t subscribeId = 0; 102579a732c7Sopenharmony_ci // 2. set checkMap null 102679a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap = nullptr; 102779a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 102879a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); 102979a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 103079a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 103179a732c7Sopenharmony_ci // 5. check checkMap not null 103279a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 103379a732c7Sopenharmony_ci // 6. set testpkcName com.ohos.test1 103479a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 103579a732c7Sopenharmony_ci // 7. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with testpkcName 103679a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(testPkgName, subscribeId); 103779a732c7Sopenharmony_ci // 8. Get checkMap from DeviceManagerNotify 103879a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 103979a732c7Sopenharmony_ci // 8 check checkMap not null 104079a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 104179a732c7Sopenharmony_ci} 104279a732c7Sopenharmony_ci 104379a732c7Sopenharmony_ci/** 104479a732c7Sopenharmony_ci * @tc.name: UnRegisterDiscoverCallback_003 104579a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 104679a732c7Sopenharmony_ci * set dmInitCallback not null 104779a732c7Sopenharmony_ci * set subscribeId not null 104879a732c7Sopenharmony_ci * 2. set checkMap null 104979a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 105079a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 105179a732c7Sopenharmony_ci * 5. check checkMap not null 105279a732c7Sopenharmony_ci * 6. set testpkcName com.ohos.test1 105379a732c7Sopenharmony_ci * 7. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with testpkcName 105479a732c7Sopenharmony_ci * 8. Get checkMap from DeviceManagerNotify 105579a732c7Sopenharmony_ci * 9. check checkMap not null 105679a732c7Sopenharmony_ci * 10. call checkMap OnDiscoverySuccess 105779a732c7Sopenharmony_ci * 11. check count is 1 105879a732c7Sopenharmony_ci * @tc.type: FUNC 105979a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 106079a732c7Sopenharmony_ci */ 106179a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDiscoveryCallback_003, testing::ext::TestSize.Level0) 106279a732c7Sopenharmony_ci{ 106379a732c7Sopenharmony_ci // 1. set pkgName not null 106479a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 106579a732c7Sopenharmony_ci // set dmInitCallback not null 106679a732c7Sopenharmony_ci int count = 0; 106779a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> callback = std::make_shared<DiscoveryCallbackTest>(count); 106879a732c7Sopenharmony_ci // set subscribeId not null 106979a732c7Sopenharmony_ci uint16_t subscribeId = 0; 107079a732c7Sopenharmony_ci // 2. set checkMap null 107179a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap = nullptr; 107279a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 107379a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); 107479a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 107579a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 107679a732c7Sopenharmony_ci // 5. check checkMap not null 107779a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 107879a732c7Sopenharmony_ci // 6. set testpkcName com.ohos.test1 107979a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 108079a732c7Sopenharmony_ci // 7. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with testpkcName 108179a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(testPkgName, subscribeId); 108279a732c7Sopenharmony_ci // 8. Get checkMap from DeviceManagerNotify 108379a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 108479a732c7Sopenharmony_ci // 9 check checkMap not null 108579a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 108679a732c7Sopenharmony_ci // 10. call checkMap OnDiscoverySuccess 108779a732c7Sopenharmony_ci if (checkMap != nullptr) { 108879a732c7Sopenharmony_ci checkMap->OnDiscoverySuccess(subscribeId); 108979a732c7Sopenharmony_ci } 109079a732c7Sopenharmony_ci // 11. check count is 1 109179a732c7Sopenharmony_ci ASSERT_EQ(count, 1); 109279a732c7Sopenharmony_ci} 109379a732c7Sopenharmony_ci 109479a732c7Sopenharmony_ci/** 109579a732c7Sopenharmony_ci * @tc.name: UnRegisterDiscoverCallback_004 109679a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 109779a732c7Sopenharmony_ci * set callback not null 109879a732c7Sopenharmony_ci * set subscribeId not null 109979a732c7Sopenharmony_ci * 2. set checkMap null 110079a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 110179a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 110279a732c7Sopenharmony_ci * 5. check checkMap not null 110379a732c7Sopenharmony_ci * 6. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with parameter 110479a732c7Sopenharmony_ci * 7. Get checkMap from DeviceManagerNotify 110579a732c7Sopenharmony_ci * 8. check checkMap null 110679a732c7Sopenharmony_ci * @tc.type: FUNC 110779a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 110879a732c7Sopenharmony_ci */ 110979a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDiscoveryCallback_004, testing::ext::TestSize.Level0) 111079a732c7Sopenharmony_ci{ 111179a732c7Sopenharmony_ci // 1. set pkgName not null 111279a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 111379a732c7Sopenharmony_ci // set dmInitCallback not null 111479a732c7Sopenharmony_ci int count = 0; 111579a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> callback = std::make_shared<DiscoveryCallbackTest>(count); 111679a732c7Sopenharmony_ci // set subscribeId not null 111779a732c7Sopenharmony_ci uint16_t subscribeId = 0; 111879a732c7Sopenharmony_ci // 2. set checkMap null 111979a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap = nullptr; 112079a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 112179a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); 112279a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback 112379a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 112479a732c7Sopenharmony_ci // 5. check checkMap not null 112579a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 112679a732c7Sopenharmony_ci // 6. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with parameter 112779a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(pkgName, subscribeId); 112879a732c7Sopenharmony_ci // 7. Get checkMap from DeviceManagerNotify 112979a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 113079a732c7Sopenharmony_ci // 8 check checkMap null 113179a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 113279a732c7Sopenharmony_ci} 113379a732c7Sopenharmony_ci 113479a732c7Sopenharmony_ci/** 113579a732c7Sopenharmony_ci * @tc.name: UnRegisterDiscoverCallback_005 113679a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 113779a732c7Sopenharmony_ci * set dmInitCallback not null 113879a732c7Sopenharmony_ci * set subscribeId not null 113979a732c7Sopenharmony_ci * 2. set checkMap null 114079a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 114179a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 114279a732c7Sopenharmony_ci * 5. check checkMap not null 114379a732c7Sopenharmony_ci * 6. set testpkcName com.ohos.test1 114479a732c7Sopenharmony_ci * 7. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with testpkcName 114579a732c7Sopenharmony_ci * 8. Get checkMap from DeviceManagerNotify 114679a732c7Sopenharmony_ci * 9. check checkMap not null 114779a732c7Sopenharmony_ci * 10. call checkMap OnDiscoverySuccess 114879a732c7Sopenharmony_ci * 11. check count is 1 114979a732c7Sopenharmony_ci * @tc.type: FUNC 115079a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 115179a732c7Sopenharmony_ci */ 115279a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterDiscoveryCallback_005, testing::ext::TestSize.Level0) 115379a732c7Sopenharmony_ci{ 115479a732c7Sopenharmony_ci // 1. set pkgName not null 115579a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 115679a732c7Sopenharmony_ci // set dmInitCallback not null 115779a732c7Sopenharmony_ci int count = 0; 115879a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> callback = std::make_shared<DiscoveryCallbackTest>(count); 115979a732c7Sopenharmony_ci // set subscribeId not null 116079a732c7Sopenharmony_ci uint16_t subscribeId = 0; 116179a732c7Sopenharmony_ci // 2. set checkMap null 116279a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap = nullptr; 116379a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter 116479a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); 116579a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 116679a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 116779a732c7Sopenharmony_ci // 5. check checkMap not null 116879a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 116979a732c7Sopenharmony_ci // 6. set testpkcName com.ohos.test1 117079a732c7Sopenharmony_ci std::string testPkgName = ""; 117179a732c7Sopenharmony_ci // 7. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with testpkcName 117279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(testPkgName, subscribeId); 117379a732c7Sopenharmony_ci // 8. Get checkMap from DeviceManagerNotify 117479a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 117579a732c7Sopenharmony_ci // 9 check checkMap not null 117679a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 117779a732c7Sopenharmony_ci // 10. call checkMap OnDiscoverySuccess 117879a732c7Sopenharmony_ci if (checkMap != nullptr) { 117979a732c7Sopenharmony_ci checkMap->OnDiscoverySuccess(subscribeId); 118079a732c7Sopenharmony_ci } 118179a732c7Sopenharmony_ci // 11. check count is 1 118279a732c7Sopenharmony_ci ASSERT_EQ(count, 1); 118379a732c7Sopenharmony_ci} 118479a732c7Sopenharmony_ci 118579a732c7Sopenharmony_ci/** 118679a732c7Sopenharmony_ci * @tc.name: RegisterAuthenticateCallback_001 118779a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 118879a732c7Sopenharmony_ci * set Callback not null 118979a732c7Sopenharmony_ci * set deviceId not null 119079a732c7Sopenharmony_ci * 2. set checkMap null 119179a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 119279a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 119379a732c7Sopenharmony_ci * 5. check checkMap not null 119479a732c7Sopenharmony_ci * @tc.type: FUNC 119579a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 119679a732c7Sopenharmony_ci */ 119779a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterAuthenticateCallback_001, testing::ext::TestSize.Level0) 119879a732c7Sopenharmony_ci{ 119979a732c7Sopenharmony_ci // 1. set pkgName not null 120079a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 120179a732c7Sopenharmony_ci // set dmInitCallback not null 120279a732c7Sopenharmony_ci int count = 0; 120379a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count); 120479a732c7Sopenharmony_ci // set subscribeId not null 120579a732c7Sopenharmony_ci std::string deviceId = "1"; 120679a732c7Sopenharmony_ci // 2. set checkMap null 120779a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap = nullptr; 120879a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 120979a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); 121079a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 121179a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 121279a732c7Sopenharmony_ci // 5. check checkMap not null 121379a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 121479a732c7Sopenharmony_ci} 121579a732c7Sopenharmony_ci 121679a732c7Sopenharmony_ci/** 121779a732c7Sopenharmony_ci * @tc.name: RegisterAuthenticateCallback_002 121879a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 121979a732c7Sopenharmony_ci * set Callback null 122079a732c7Sopenharmony_ci * set deviceId not null 122179a732c7Sopenharmony_ci * 2. set checkMap null 122279a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 122379a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 122479a732c7Sopenharmony_ci * 5. check checkMap null 122579a732c7Sopenharmony_ci * @tc.type: FUNC 122679a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 122779a732c7Sopenharmony_ci */ 122879a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterAuthenticateCallback_002, testing::ext::TestSize.Level0) 122979a732c7Sopenharmony_ci{ 123079a732c7Sopenharmony_ci // 1. set pkgName not null 123179a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 123279a732c7Sopenharmony_ci // set dmInitCallback not null 123379a732c7Sopenharmony_ci int count = 0; 123479a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count); 123579a732c7Sopenharmony_ci // set subscribeId not null 123679a732c7Sopenharmony_ci std::string deviceId = "1"; 123779a732c7Sopenharmony_ci // 2. set checkMap not null 123879a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap = nullptr; 123979a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 124079a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); 124179a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 124279a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 124379a732c7Sopenharmony_ci // 5. check checkMap null 124479a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 124579a732c7Sopenharmony_ci} 124679a732c7Sopenharmony_ci 124779a732c7Sopenharmony_ci/** 124879a732c7Sopenharmony_ci * @tc.name: RegisterAuthenticateCallback_003 124979a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 125079a732c7Sopenharmony_ci * set Callback not null 125179a732c7Sopenharmony_ci * set deviceId not null 125279a732c7Sopenharmony_ci * 2. set checkMap null 125379a732c7Sopenharmony_ci * 3. set testpkcName com.ohos.test1 125479a732c7Sopenharmony_ci * 4. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 125579a732c7Sopenharmony_ci * 5. Get checkMap from DeviceManagerNotify with testpkcName 125679a732c7Sopenharmony_ci * 6. check checkMap null 125779a732c7Sopenharmony_ci * @tc.type: FUNC 125879a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 125979a732c7Sopenharmony_ci */ 126079a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterAuthenticateCallback_003, testing::ext::TestSize.Level0) 126179a732c7Sopenharmony_ci{ 126279a732c7Sopenharmony_ci // 1. set pkgName com.ohos.test 126379a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 126479a732c7Sopenharmony_ci // set dmInitCallback not null 126579a732c7Sopenharmony_ci int count = 0; 126679a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count); 126779a732c7Sopenharmony_ci // set subscribeId not null 126879a732c7Sopenharmony_ci std::string deviceId = "1"; 126979a732c7Sopenharmony_ci // 2. set checkMap null 127079a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap = nullptr; 127179a732c7Sopenharmony_ci // 3. set testpkcName com.ohos.test1 127279a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 127379a732c7Sopenharmony_ci // 4. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 127479a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); 127579a732c7Sopenharmony_ci // 5. Get checkMap from DeviceManagerNotify with testpkcName 127679a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 127779a732c7Sopenharmony_ci // 6. check checkMap not null 127879a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 127979a732c7Sopenharmony_ci} 128079a732c7Sopenharmony_ci 128179a732c7Sopenharmony_ci/** 128279a732c7Sopenharmony_ci * @tc.name: RegisterAuthenticateCallback_004 128379a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 128479a732c7Sopenharmony_ci * set Callback not null 128579a732c7Sopenharmony_ci * set deviceId not null 128679a732c7Sopenharmony_ci * 2. set checkMap null 128779a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 128879a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 128979a732c7Sopenharmony_ci * 5. check checkMap not null 129079a732c7Sopenharmony_ci * @tc.type: FUNC 129179a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 129279a732c7Sopenharmony_ci */ 129379a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterAuthenticateCallback_004, testing::ext::TestSize.Level0) 129479a732c7Sopenharmony_ci{ 129579a732c7Sopenharmony_ci // 1. set pkgName not null 129679a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 129779a732c7Sopenharmony_ci // set dmInitCallback not null 129879a732c7Sopenharmony_ci int count = 0; 129979a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count); 130079a732c7Sopenharmony_ci // set subscribeId not null 130179a732c7Sopenharmony_ci std::string deviceId = "1"; 130279a732c7Sopenharmony_ci // 2. set checkMap null 130379a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap = nullptr; 130479a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 130579a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); 130679a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 130779a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 130879a732c7Sopenharmony_ci // 5. check checkMap not null 130979a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 131079a732c7Sopenharmony_ci // 6. call checkMap OnAuthResult 131179a732c7Sopenharmony_ci std::string token = "1"; 131279a732c7Sopenharmony_ci int32_t status = 1; 131379a732c7Sopenharmony_ci int32_t reason = 1; 131479a732c7Sopenharmony_ci if (checkMap != nullptr) { 131579a732c7Sopenharmony_ci checkMap->OnAuthResult(deviceId, token, status, reason); 131679a732c7Sopenharmony_ci } 131779a732c7Sopenharmony_ci // 7. check count is 1 131879a732c7Sopenharmony_ci ASSERT_EQ(count, 1); 131979a732c7Sopenharmony_ci} 132079a732c7Sopenharmony_ci 132179a732c7Sopenharmony_ci/** 132279a732c7Sopenharmony_ci * @tc.name: RegisterAuthenticateCallback_005 132379a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 132479a732c7Sopenharmony_ci * set Callback not null 132579a732c7Sopenharmony_ci * set deviceId not null 132679a732c7Sopenharmony_ci * 2. set checkMap null 132779a732c7Sopenharmony_ci * 3. set testpkcName com.ohos.test1 132879a732c7Sopenharmony_ci * 4. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 132979a732c7Sopenharmony_ci * 5. Get checkMap from DeviceManagerNotify with testpkcName 133079a732c7Sopenharmony_ci * 6. check checkMap null 133179a732c7Sopenharmony_ci * @tc.type: FUNC 133279a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 133379a732c7Sopenharmony_ci */ 133479a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, RegisterAuthenticateCallback_005, testing::ext::TestSize.Level0) 133579a732c7Sopenharmony_ci{ 133679a732c7Sopenharmony_ci // 1. set pkgName com.ohos.test 133779a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 133879a732c7Sopenharmony_ci int count = 0; 133979a732c7Sopenharmony_ci // set dmInitCallback not null 134079a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count); 134179a732c7Sopenharmony_ci // set subscribeId not null 134279a732c7Sopenharmony_ci std::string deviceId = "1"; 134379a732c7Sopenharmony_ci // 2. set checkMap null 134479a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap = nullptr; 134579a732c7Sopenharmony_ci // 3. set testpkcName com.ohos.test1 134679a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 134779a732c7Sopenharmony_ci // 4. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 134879a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); 134979a732c7Sopenharmony_ci // 5. Get checkMap from DeviceManagerNotify with testpkcName 135079a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 135179a732c7Sopenharmony_ci // 6. check checkMap not null 135279a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 135379a732c7Sopenharmony_ci} 135479a732c7Sopenharmony_ci 135579a732c7Sopenharmony_ci/** 135679a732c7Sopenharmony_ci * @tc.name: UnRegisterAuthenticateCallback_001 135779a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 135879a732c7Sopenharmony_ci * set callback not null 135979a732c7Sopenharmony_ci * set deviceId not null 136079a732c7Sopenharmony_ci * 2. set checkMap null 136179a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 136279a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 136379a732c7Sopenharmony_ci * 5. check checkMap not null 136479a732c7Sopenharmony_ci * 6. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with parameter 136579a732c7Sopenharmony_ci * 7. Get checkMap from DeviceManagerNotify 136679a732c7Sopenharmony_ci * 8. check checkMap null 136779a732c7Sopenharmony_ci * @tc.type: FUNC 136879a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 136979a732c7Sopenharmony_ci */ 137079a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterAuthenticateCallback_001, testing::ext::TestSize.Level0) 137179a732c7Sopenharmony_ci{ 137279a732c7Sopenharmony_ci // 1. set pkgName not null 137379a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 137479a732c7Sopenharmony_ci // set dmInitCallback not null 137579a732c7Sopenharmony_ci int count = 0; 137679a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count); 137779a732c7Sopenharmony_ci // set subscribeId not null 137879a732c7Sopenharmony_ci std::string deviceId = "1"; 137979a732c7Sopenharmony_ci // 2. set checkMap null 138079a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap = nullptr; 138179a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 138279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); 138379a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback 138479a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 138579a732c7Sopenharmony_ci // 5. check checkMap not null 138679a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 138779a732c7Sopenharmony_ci // 6. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with parameter 138879a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterAuthenticateCallback(pkgName, deviceId); 138979a732c7Sopenharmony_ci // 7. Get checkMap from DeviceManagerNotify 139079a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 139179a732c7Sopenharmony_ci // 8 check checkMap null 139279a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 139379a732c7Sopenharmony_ci} 139479a732c7Sopenharmony_ci 139579a732c7Sopenharmony_ci/** 139679a732c7Sopenharmony_ci * @tc.name: UnRegisterAuthenticateCallback_002 139779a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 139879a732c7Sopenharmony_ci * set dmInitCallback not null 139979a732c7Sopenharmony_ci * set subscribeId not null 140079a732c7Sopenharmony_ci * 2. set checkMap null 140179a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 140279a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 140379a732c7Sopenharmony_ci * 5. check checkMap not null 140479a732c7Sopenharmony_ci * 6. set testpkcName com.ohos.test1 140579a732c7Sopenharmony_ci * 7. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with testpkcName 140679a732c7Sopenharmony_ci * 8. Get checkMap from DeviceManagerNotify 140779a732c7Sopenharmony_ci * 9. check checkMap not null 140879a732c7Sopenharmony_ci * @tc.type: FUNC 140979a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 141079a732c7Sopenharmony_ci */ 141179a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterAuthenticateCallback_002, testing::ext::TestSize.Level0) 141279a732c7Sopenharmony_ci{ 141379a732c7Sopenharmony_ci // 1. set pkgName not null 141479a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 141579a732c7Sopenharmony_ci // set dmInitCallback not null 141679a732c7Sopenharmony_ci int count = 0; 141779a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count); 141879a732c7Sopenharmony_ci // set subscribeId not null 141979a732c7Sopenharmony_ci std::string deviceId = "1"; 142079a732c7Sopenharmony_ci // 2. set checkMap null 142179a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap = nullptr; 142279a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 142379a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); 142479a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 142579a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 142679a732c7Sopenharmony_ci // 5. check checkMap not null 142779a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 142879a732c7Sopenharmony_ci // 6. set testpkcName com.ohos.test1 142979a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 143079a732c7Sopenharmony_ci // 7. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with testpkcName 143179a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterAuthenticateCallback(testPkgName, deviceId); 143279a732c7Sopenharmony_ci // 8. Get checkMap from DeviceManagerNotify 143379a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 143479a732c7Sopenharmony_ci // 8 check checkMap not null 143579a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 143679a732c7Sopenharmony_ci} 143779a732c7Sopenharmony_ci 143879a732c7Sopenharmony_ci/** 143979a732c7Sopenharmony_ci * @tc.name: UnRegisterAuthenticateCallback_003 144079a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 144179a732c7Sopenharmony_ci * set dmInitCallback not null 144279a732c7Sopenharmony_ci * set subscribeId not null 144379a732c7Sopenharmony_ci * 2. set checkMap null 144479a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 144579a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 144679a732c7Sopenharmony_ci * 5. check checkMap not null 144779a732c7Sopenharmony_ci * 6. set testpkcName com.ohos.test1 144879a732c7Sopenharmony_ci * 7. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with testpkcName 144979a732c7Sopenharmony_ci * 8. Get checkMap from DeviceManagerNotify 145079a732c7Sopenharmony_ci * 9. check checkMap not null 145179a732c7Sopenharmony_ci * 10. call checkMap OnAuthResult 145279a732c7Sopenharmony_ci * 11. check count is 1 145379a732c7Sopenharmony_ci * @tc.type: FUNC 145479a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 145579a732c7Sopenharmony_ci */ 145679a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterAuthenticateCallback_003, testing::ext::TestSize.Level0) 145779a732c7Sopenharmony_ci{ 145879a732c7Sopenharmony_ci // 1. set pkgName not null 145979a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 146079a732c7Sopenharmony_ci // set dmInitCallback not null 146179a732c7Sopenharmony_ci int count = 0; 146279a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count); 146379a732c7Sopenharmony_ci // set subscribeId not null 146479a732c7Sopenharmony_ci std::string deviceId = "1"; 146579a732c7Sopenharmony_ci // 2. set checkMap null 146679a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap = nullptr; 146779a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 146879a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); 146979a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 147079a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 147179a732c7Sopenharmony_ci // 5. check checkMap not null 147279a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 147379a732c7Sopenharmony_ci // 6. set testpkcName com.ohos.test1 147479a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 147579a732c7Sopenharmony_ci // 7. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with testpkcName 147679a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterAuthenticateCallback(testPkgName, deviceId); 147779a732c7Sopenharmony_ci // 8. Get checkMap from DeviceManagerNotify 147879a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 147979a732c7Sopenharmony_ci // 9 check checkMap not null 148079a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 148179a732c7Sopenharmony_ci // 10. call checkMap OnAuthResult 148279a732c7Sopenharmony_ci std::string token = "1"; 148379a732c7Sopenharmony_ci int32_t status = 1; 148479a732c7Sopenharmony_ci int32_t reason = 1; 148579a732c7Sopenharmony_ci if (checkMap != nullptr) { 148679a732c7Sopenharmony_ci checkMap->OnAuthResult(deviceId, token, status, reason); 148779a732c7Sopenharmony_ci } 148879a732c7Sopenharmony_ci // 11. check count is 1 148979a732c7Sopenharmony_ci ASSERT_EQ(count, 1); 149079a732c7Sopenharmony_ci} 149179a732c7Sopenharmony_ci 149279a732c7Sopenharmony_ci/** 149379a732c7Sopenharmony_ci * @tc.name: UnRegisterAuthenticateCallback_004 149479a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName not null 149579a732c7Sopenharmony_ci * set callback not null 149679a732c7Sopenharmony_ci * set deviceId not null 149779a732c7Sopenharmony_ci * 2. set checkMap null 149879a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 149979a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 150079a732c7Sopenharmony_ci * 5. check checkMap not null 150179a732c7Sopenharmony_ci * 6. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with parameter 150279a732c7Sopenharmony_ci * 7. Get checkMap from DeviceManagerNotify 150379a732c7Sopenharmony_ci * 8. check checkMap null 150479a732c7Sopenharmony_ci * @tc.type: FUNC 150579a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 150679a732c7Sopenharmony_ci */ 150779a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterAuthenticateCallback_004, testing::ext::TestSize.Level0) 150879a732c7Sopenharmony_ci{ 150979a732c7Sopenharmony_ci // 1. set pkgName not null 151079a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 151179a732c7Sopenharmony_ci // set dmInitCallback not null 151279a732c7Sopenharmony_ci int count = 0; 151379a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count); 151479a732c7Sopenharmony_ci // set subscribeId not null 151579a732c7Sopenharmony_ci std::string deviceId = "1"; 151679a732c7Sopenharmony_ci // 2. set checkMap null 151779a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap = nullptr; 151879a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 151979a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); 152079a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback 152179a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 152279a732c7Sopenharmony_ci // 5. check checkMap not null 152379a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 152479a732c7Sopenharmony_ci // 6. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with parameter 152579a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterAuthenticateCallback(pkgName, deviceId); 152679a732c7Sopenharmony_ci // 7. Get checkMap from DeviceManagerNotify 152779a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 152879a732c7Sopenharmony_ci // 8. check checkMap not null 152979a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 153079a732c7Sopenharmony_ci} 153179a732c7Sopenharmony_ci 153279a732c7Sopenharmony_ci/** 153379a732c7Sopenharmony_ci * @tc.name: UnRegisterAuthenticateCallback_005 153479a732c7Sopenharmony_ci * @tc.desc: 1. set pkgName com.ohos.test 153579a732c7Sopenharmony_ci * set dmInitCallback not null 153679a732c7Sopenharmony_ci * set subscribeId not null 153779a732c7Sopenharmony_ci * 2. set checkMap null 153879a732c7Sopenharmony_ci * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 153979a732c7Sopenharmony_ci * 4. Get checkMap from DeviceManagerNotify 154079a732c7Sopenharmony_ci * 5. check checkMap not null 154179a732c7Sopenharmony_ci * 6. set testpkcName com.ohos.test1 154279a732c7Sopenharmony_ci * 7. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with testpkcName 154379a732c7Sopenharmony_ci * 8. Get checkMap from DeviceManagerNotify 154479a732c7Sopenharmony_ci * 9. check checkMap not null 154579a732c7Sopenharmony_ci * @tc.type: FUNC 154679a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 154779a732c7Sopenharmony_ci */ 154879a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterAuthenticateCallback_005, testing::ext::TestSize.Level0) 154979a732c7Sopenharmony_ci{ 155079a732c7Sopenharmony_ci // 1. set pkgName not null 155179a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 155279a732c7Sopenharmony_ci // set dmInitCallback not null 155379a732c7Sopenharmony_ci int count = 0; 155479a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> callback = std::make_shared<AuthenticateCallbackTest>(count); 155579a732c7Sopenharmony_ci // set subscribeId not null 155679a732c7Sopenharmony_ci std::string deviceId = "1"; 155779a732c7Sopenharmony_ci // 2. set checkMap null 155879a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap = nullptr; 155979a732c7Sopenharmony_ci // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter 156079a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); 156179a732c7Sopenharmony_ci // 4. Get checkMap from DeviceManagerNotify 156279a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 156379a732c7Sopenharmony_ci // 5. check checkMap not null 156479a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 156579a732c7Sopenharmony_ci // 6. set testpkcName com.ohos.test1 156679a732c7Sopenharmony_ci std::string testPkgName = ""; 156779a732c7Sopenharmony_ci // 7. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with testpkcName 156879a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterAuthenticateCallback(testPkgName, deviceId); 156979a732c7Sopenharmony_ci // 8. Get checkMap from DeviceManagerNotify 157079a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 157179a732c7Sopenharmony_ci // 8 check checkMap not null 157279a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 157379a732c7Sopenharmony_ci} 157479a732c7Sopenharmony_ci 157579a732c7Sopenharmony_ci/** 157679a732c7Sopenharmony_ci * @tc.name: UnRegisterPackageCallback_001 157779a732c7Sopenharmony_ci * @tc.desc: 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback 157879a732c7Sopenharmony_ci * 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback 157979a732c7Sopenharmony_ci * 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId 158079a732c7Sopenharmony_ci * 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback 158179a732c7Sopenharmony_ci * 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId 158279a732c7Sopenharmony_ci * 6. call DeviceManagerNotify UnRegisterPackageCallback with PkgName 158379a732c7Sopenharmony_ci * 7. check if checkMap checkMap1 checkMap2 checkMap3 is null 158479a732c7Sopenharmony_ci * @tc.type: FUNC 158579a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 158679a732c7Sopenharmony_ci */ 158779a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterPackageCallback_001, testing::ext::TestSize.Level0) 158879a732c7Sopenharmony_ci{ 158979a732c7Sopenharmony_ci // 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback 159079a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 159179a732c7Sopenharmony_ci int count = 0; 159279a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = std::make_shared<DmInitCallbackTest>(count); 159379a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 159479a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 159579a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 159679a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 159779a732c7Sopenharmony_ci // 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback 159879a732c7Sopenharmony_ci int count1 = 0; 159979a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> deviceStateCallback = std::make_shared<DeviceStateCallbackTest>(count1); 160079a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap1 = nullptr; 160179a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, deviceStateCallback); 160279a732c7Sopenharmony_ci checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 160379a732c7Sopenharmony_ci ASSERT_NE(checkMap1, nullptr); 160479a732c7Sopenharmony_ci // 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId 160579a732c7Sopenharmony_ci int count2 = 0; 160679a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> deviceDiscoveryCallback = std::make_shared<DiscoveryCallbackTest>(count2); 160779a732c7Sopenharmony_ci uint16_t subscribeId = 0; 160879a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap2 = nullptr; 160979a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, deviceDiscoveryCallback); 161079a732c7Sopenharmony_ci checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 161179a732c7Sopenharmony_ci ASSERT_NE(checkMap2, nullptr); 161279a732c7Sopenharmony_ci // 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback 161379a732c7Sopenharmony_ci int count3 = 0; 161479a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> authenticateCallback = std::make_shared<AuthenticateCallbackTest>(count3); 161579a732c7Sopenharmony_ci std::string deviceId = "1"; 161679a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap3 = nullptr; 161779a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, authenticateCallback); 161879a732c7Sopenharmony_ci checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 161979a732c7Sopenharmony_ci ASSERT_NE(checkMap3, nullptr); 162079a732c7Sopenharmony_ci // 5. RegisterPublishCallback with pkgName and deviceStateCallback and subscribeId 162179a732c7Sopenharmony_ci int count4 = 0; 162279a732c7Sopenharmony_ci std::shared_ptr<PublishCallback> devicePublishCallback = std::make_shared<PublishCallbackTest>(count4); 162379a732c7Sopenharmony_ci int32_t publishId = 0; 162479a732c7Sopenharmony_ci std::shared_ptr<PublishCallback> checkMap4 = nullptr; 162579a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, devicePublishCallback); 162679a732c7Sopenharmony_ci checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; 162779a732c7Sopenharmony_ci ASSERT_NE(checkMap4, nullptr); 162879a732c7Sopenharmony_ci // 6. call DeviceManagerNotify UnRegisterPackageCallback with PkgName 162979a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(pkgName); 163079a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 163179a732c7Sopenharmony_ci checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 163279a732c7Sopenharmony_ci checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 163379a732c7Sopenharmony_ci checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 163479a732c7Sopenharmony_ci checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; 163579a732c7Sopenharmony_ci // 7. check if checkMap checkMap1 checkMap2 checkMap3 is null 163679a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 163779a732c7Sopenharmony_ci ASSERT_EQ(checkMap1, nullptr); 163879a732c7Sopenharmony_ci ASSERT_EQ(checkMap2, nullptr); 163979a732c7Sopenharmony_ci ASSERT_EQ(checkMap3, nullptr); 164079a732c7Sopenharmony_ci ASSERT_EQ(checkMap4, nullptr); 164179a732c7Sopenharmony_ci} 164279a732c7Sopenharmony_ci 164379a732c7Sopenharmony_ci/** 164479a732c7Sopenharmony_ci * @tc.name: UnRegisterPackageCallback_002 164579a732c7Sopenharmony_ci * @tc.desc: 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback 164679a732c7Sopenharmony_ci * 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback 164779a732c7Sopenharmony_ci * 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId 164879a732c7Sopenharmony_ci * 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback 164979a732c7Sopenharmony_ci * 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId 165079a732c7Sopenharmony_ci * 6. call DeviceManagerNotify UnRegisterPackageCallback with testPkgName 165179a732c7Sopenharmony_ci * 7. check if checkMap checkMap1 checkMap2 checkMap3 is not null 165279a732c7Sopenharmony_ci * @tc.type: FUNC 165379a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 165479a732c7Sopenharmony_ci */ 165579a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterPackageCallback_002, testing::ext::TestSize.Level0) 165679a732c7Sopenharmony_ci{ 165779a732c7Sopenharmony_ci // 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback 165879a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 165979a732c7Sopenharmony_ci int count = 0; 166079a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = std::make_shared<DmInitCallbackTest>(count); 166179a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 166279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 166379a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 166479a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 166579a732c7Sopenharmony_ci // 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback 166679a732c7Sopenharmony_ci int count1 = 0; 166779a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> deviceStateCallback = std::make_shared<DeviceStateCallbackTest>(count1); 166879a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap1 = nullptr; 166979a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, deviceStateCallback); 167079a732c7Sopenharmony_ci checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 167179a732c7Sopenharmony_ci ASSERT_NE(checkMap1, nullptr); 167279a732c7Sopenharmony_ci // 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId 167379a732c7Sopenharmony_ci int count2 = 0; 167479a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> deviceDiscoveryCallback = std::make_shared<DiscoveryCallbackTest>(count2); 167579a732c7Sopenharmony_ci uint16_t subscribeId = 0; 167679a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap2 = nullptr; 167779a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, deviceDiscoveryCallback); 167879a732c7Sopenharmony_ci checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 167979a732c7Sopenharmony_ci ASSERT_NE(checkMap2, nullptr); 168079a732c7Sopenharmony_ci // 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback 168179a732c7Sopenharmony_ci int count3 = 0; 168279a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> authenticateCallback = std::make_shared<AuthenticateCallbackTest>(count3); 168379a732c7Sopenharmony_ci std::string deviceId = "1"; 168479a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap3 = nullptr; 168579a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, authenticateCallback); 168679a732c7Sopenharmony_ci checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 168779a732c7Sopenharmony_ci ASSERT_NE(checkMap3, nullptr); 168879a732c7Sopenharmony_ci // 5. RegisterPublishCallback with pkgName and deviceStateCallback and publishId 168979a732c7Sopenharmony_ci int count4 = 0; 169079a732c7Sopenharmony_ci std::shared_ptr<PublishCallback> devicePublishCallback = std::make_shared<PublishCallbackTest>(count4); 169179a732c7Sopenharmony_ci int32_t publishId = 0; 169279a732c7Sopenharmony_ci std::shared_ptr<PublishCallback> checkMap4 = nullptr; 169379a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, devicePublishCallback); 169479a732c7Sopenharmony_ci checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; 169579a732c7Sopenharmony_ci ASSERT_NE(checkMap4, nullptr); 169679a732c7Sopenharmony_ci // 6. call DeviceManagerNotify UnRegisterPackageCallback with testPkgName 169779a732c7Sopenharmony_ci std::string testPkgName = "com.ohos.test1"; 169879a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(testPkgName); 169979a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 170079a732c7Sopenharmony_ci checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 170179a732c7Sopenharmony_ci checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 170279a732c7Sopenharmony_ci checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 170379a732c7Sopenharmony_ci checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; 170479a732c7Sopenharmony_ci // 7. check if checkMap checkMap1 checkMap2 checkMap3 is null 170579a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 170679a732c7Sopenharmony_ci ASSERT_NE(checkMap1, nullptr); 170779a732c7Sopenharmony_ci ASSERT_NE(checkMap2, nullptr); 170879a732c7Sopenharmony_ci ASSERT_NE(checkMap3, nullptr); 170979a732c7Sopenharmony_ci ASSERT_NE(checkMap4, nullptr); 171079a732c7Sopenharmony_ci} 171179a732c7Sopenharmony_ci 171279a732c7Sopenharmony_ci/** 171379a732c7Sopenharmony_ci * @tc.name: UnRegisterPackageCallback_003 171479a732c7Sopenharmony_ci * @tc.desc: 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback 171579a732c7Sopenharmony_ci * 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback 171679a732c7Sopenharmony_ci * 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId 171779a732c7Sopenharmony_ci * 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback 171879a732c7Sopenharmony_ci * 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId 171979a732c7Sopenharmony_ci * 6. call DeviceManagerNotify UnRegisterPackageCallback with testPkgName 172079a732c7Sopenharmony_ci * 7. check if checkMap checkMap1 checkMap2 checkMap3 is not null 172179a732c7Sopenharmony_ci * @tc.type: FUNC 172279a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 172379a732c7Sopenharmony_ci */ 172479a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterPackageCallback_003, testing::ext::TestSize.Level0) 172579a732c7Sopenharmony_ci{ 172679a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 172779a732c7Sopenharmony_ci int count[5] = {0, 0, 0, 0, 0}; 172879a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = std::make_shared<DmInitCallbackTest>(count[0]); 172979a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 173079a732c7Sopenharmony_ci ASSERT_NE(DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName], nullptr); 173179a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> deviceStateCallback = std::make_shared<DeviceStateCallbackTest>(count[1]); 173279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, deviceStateCallback); 173379a732c7Sopenharmony_ci ASSERT_NE(DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName], nullptr); 173479a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> deviceDiscoveryCallback = std::make_shared<DiscoveryCallbackTest>(count[2]); 173579a732c7Sopenharmony_ci uint16_t subscribeId = 0; 173679a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, deviceDiscoveryCallback); 173779a732c7Sopenharmony_ci ASSERT_NE(DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId], nullptr); 173879a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> authenticateCallback = std::make_shared<AuthenticateCallbackTest>(count[3]); 173979a732c7Sopenharmony_ci std::string deviceId = "1"; 174079a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, authenticateCallback); 174179a732c7Sopenharmony_ci ASSERT_NE(DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId], nullptr); 174279a732c7Sopenharmony_ci std::shared_ptr<PublishCallback> devicePublishCallback = std::make_shared<PublishCallbackTest>(count[4]); 174379a732c7Sopenharmony_ci int32_t publishId = 0; 174479a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, devicePublishCallback); 174579a732c7Sopenharmony_ci ASSERT_NE(DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId], nullptr); 174679a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterPackageCallback("com.ohos.test1"); 174779a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 174879a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 174979a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap2 = 175079a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 175179a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap3 = 175279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 175379a732c7Sopenharmony_ci std::shared_ptr<PublishCallback> checkMap4 = 175479a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; 175579a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 175679a732c7Sopenharmony_ci ASSERT_NE(checkMap1, nullptr); 175779a732c7Sopenharmony_ci ASSERT_NE(checkMap2, nullptr); 175879a732c7Sopenharmony_ci ASSERT_NE(checkMap3, nullptr); 175979a732c7Sopenharmony_ci ASSERT_NE(checkMap4, nullptr); 176079a732c7Sopenharmony_ci} 176179a732c7Sopenharmony_ci 176279a732c7Sopenharmony_ci/** 176379a732c7Sopenharmony_ci * @tc.name: UnRegisterPackageCallback_004 176479a732c7Sopenharmony_ci * @tc.desc: 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback 176579a732c7Sopenharmony_ci * 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback 176679a732c7Sopenharmony_ci * 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId 176779a732c7Sopenharmony_ci * 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback 176879a732c7Sopenharmony_ci * 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId 176979a732c7Sopenharmony_ci * 6. call DeviceManagerNotify UnRegisterPackageCallback with PkgName 177079a732c7Sopenharmony_ci * 7. check if checkMap checkMap1 checkMap2 checkMap3 is null 177179a732c7Sopenharmony_ci * @tc.type: FUNC 177279a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 177379a732c7Sopenharmony_ci */ 177479a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterPackageCallback_004, testing::ext::TestSize.Level0) 177579a732c7Sopenharmony_ci{ 177679a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 177779a732c7Sopenharmony_ci int count[5] = {0, 0, 0, 0, 0}; 177879a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = std::make_shared<DmInitCallbackTest>(count[0]); 177979a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 178079a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 178179a732c7Sopenharmony_ci ASSERT_NE(DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName], nullptr); 178279a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> deviceStateCallback = std::make_shared<DeviceStateCallbackTest>(count[1]); 178379a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap1 = nullptr; 178479a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, deviceStateCallback); 178579a732c7Sopenharmony_ci ASSERT_NE(DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName], nullptr); 178679a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> deviceDiscoveryCallback = std::make_shared<DiscoveryCallbackTest>(count[2]); 178779a732c7Sopenharmony_ci uint16_t subscribeId = 0; 178879a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap2 = nullptr; 178979a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, deviceDiscoveryCallback); 179079a732c7Sopenharmony_ci ASSERT_NE(DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId], nullptr); 179179a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> authenticateCallback = std::make_shared<AuthenticateCallbackTest>(count[3]); 179279a732c7Sopenharmony_ci std::string deviceId = "1"; 179379a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap3 = nullptr; 179479a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, authenticateCallback); 179579a732c7Sopenharmony_ci ASSERT_NE(DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId], nullptr); 179679a732c7Sopenharmony_ci std::shared_ptr<PublishCallback> devicePublishCallback = std::make_shared<PublishCallbackTest>(count[4]); 179779a732c7Sopenharmony_ci int32_t publishId = 0; 179879a732c7Sopenharmony_ci std::shared_ptr<PublishCallback> checkMap4 = nullptr; 179979a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, devicePublishCallback); 180079a732c7Sopenharmony_ci ASSERT_NE(DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId], nullptr); 180179a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(pkgName); 180279a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 180379a732c7Sopenharmony_ci checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 180479a732c7Sopenharmony_ci checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 180579a732c7Sopenharmony_ci checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 180679a732c7Sopenharmony_ci checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; 180779a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 180879a732c7Sopenharmony_ci ASSERT_EQ(checkMap1, nullptr); 180979a732c7Sopenharmony_ci ASSERT_EQ(checkMap2, nullptr); 181079a732c7Sopenharmony_ci ASSERT_EQ(checkMap3, nullptr); 181179a732c7Sopenharmony_ci ASSERT_EQ(checkMap4, nullptr); 181279a732c7Sopenharmony_ci} 181379a732c7Sopenharmony_ci 181479a732c7Sopenharmony_ci/** 181579a732c7Sopenharmony_ci * @tc.name: UnRegisterPackageCallback_005 181679a732c7Sopenharmony_ci * @tc.desc: 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback 181779a732c7Sopenharmony_ci * 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback 181879a732c7Sopenharmony_ci * 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId 181979a732c7Sopenharmony_ci * 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback 182079a732c7Sopenharmony_ci * 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId 182179a732c7Sopenharmony_ci * 6. call DeviceManagerNotify UnRegisterPackageCallback with testPkgName 182279a732c7Sopenharmony_ci * 7. check if checkMap checkMap1 checkMap2 checkMap3 is not null 182379a732c7Sopenharmony_ci * @tc.type: FUNC 182479a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 182579a732c7Sopenharmony_ci */ 182679a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterPackageCallback_005, testing::ext::TestSize.Level0) 182779a732c7Sopenharmony_ci{ 182879a732c7Sopenharmony_ci std::string pkgName = "com.ohos.test"; 182979a732c7Sopenharmony_ci int count = 0; 183079a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = std::make_shared<DmInitCallbackTest>(count); 183179a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 183279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 183379a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 183479a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 183579a732c7Sopenharmony_ci int count1 = 0; 183679a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> deviceStateCallback = std::make_shared<DeviceStateCallbackTest>(count1); 183779a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap1 = nullptr; 183879a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, deviceStateCallback); 183979a732c7Sopenharmony_ci checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 184079a732c7Sopenharmony_ci ASSERT_NE(checkMap1, nullptr); 184179a732c7Sopenharmony_ci int count2 = 0; 184279a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> deviceDiscoveryCallback = std::make_shared<DiscoveryCallbackTest>(count2); 184379a732c7Sopenharmony_ci uint16_t subscribeId = 0; 184479a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap2 = nullptr; 184579a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, deviceDiscoveryCallback); 184679a732c7Sopenharmony_ci checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 184779a732c7Sopenharmony_ci ASSERT_NE(checkMap2, nullptr); 184879a732c7Sopenharmony_ci int count3 = 0; 184979a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> authenticateCallback = std::make_shared<AuthenticateCallbackTest>(count3); 185079a732c7Sopenharmony_ci std::string deviceId = "1"; 185179a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap3 = nullptr; 185279a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, authenticateCallback); 185379a732c7Sopenharmony_ci checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 185479a732c7Sopenharmony_ci ASSERT_NE(checkMap3, nullptr); 185579a732c7Sopenharmony_ci int count4 = 0; 185679a732c7Sopenharmony_ci std::shared_ptr<PublishCallback> devicePublishCallback = std::make_shared<PublishCallbackTest>(count4); 185779a732c7Sopenharmony_ci int32_t publishId = 0; 185879a732c7Sopenharmony_ci std::shared_ptr<PublishCallback> checkMap4 = nullptr; 185979a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, devicePublishCallback); 186079a732c7Sopenharmony_ci checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][subscribeId]; 186179a732c7Sopenharmony_ci ASSERT_NE(checkMap4, nullptr); 186279a732c7Sopenharmony_ci std::string testPkgName = ""; 186379a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(testPkgName); 186479a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 186579a732c7Sopenharmony_ci checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 186679a732c7Sopenharmony_ci checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 186779a732c7Sopenharmony_ci checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 186879a732c7Sopenharmony_ci checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; 186979a732c7Sopenharmony_ci ASSERT_NE(checkMap, nullptr); 187079a732c7Sopenharmony_ci ASSERT_NE(checkMap1, nullptr); 187179a732c7Sopenharmony_ci ASSERT_NE(checkMap2, nullptr); 187279a732c7Sopenharmony_ci ASSERT_NE(checkMap3, nullptr); 187379a732c7Sopenharmony_ci ASSERT_NE(checkMap4, nullptr); 187479a732c7Sopenharmony_ci} 187579a732c7Sopenharmony_ci 187679a732c7Sopenharmony_ci/** 187779a732c7Sopenharmony_ci * @tc.name: UnRegisterPackageCallback_005 187879a732c7Sopenharmony_ci * @tc.desc: 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback 187979a732c7Sopenharmony_ci * 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback 188079a732c7Sopenharmony_ci * 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId 188179a732c7Sopenharmony_ci * 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback 188279a732c7Sopenharmony_ci * 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId 188379a732c7Sopenharmony_ci * 6. call DeviceManagerNotify UnRegisterPackageCallback with testPkgName 188479a732c7Sopenharmony_ci * 7. check if checkMap checkMap1 checkMap2 checkMap3 is not null 188579a732c7Sopenharmony_ci * @tc.type: FUNC 188679a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 188779a732c7Sopenharmony_ci */ 188879a732c7Sopenharmony_ciHWTEST_F(DeviceManagerNotifyTest, UnRegisterPackageCallback_006, testing::ext::TestSize.Level0) 188979a732c7Sopenharmony_ci{ 189079a732c7Sopenharmony_ci std::string pkgName; 189179a732c7Sopenharmony_ci int count = 0; 189279a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> dmInitCallback = std::make_shared<DmInitCallbackTest>(count); 189379a732c7Sopenharmony_ci std::shared_ptr<DmInitCallback> checkMap = nullptr; 189479a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); 189579a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 189679a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 189779a732c7Sopenharmony_ci int count1 = 0; 189879a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> deviceStateCallback = std::make_shared<DeviceStateCallbackTest>(count1); 189979a732c7Sopenharmony_ci std::shared_ptr<DeviceStateCallback> checkMap1 = nullptr; 190079a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, deviceStateCallback); 190179a732c7Sopenharmony_ci checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 190279a732c7Sopenharmony_ci ASSERT_EQ(checkMap1, nullptr); 190379a732c7Sopenharmony_ci int count2 = 0; 190479a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> deviceDiscoveryCallback = std::make_shared<DiscoveryCallbackTest>(count2); 190579a732c7Sopenharmony_ci uint16_t subscribeId = 0; 190679a732c7Sopenharmony_ci std::shared_ptr<DiscoveryCallback> checkMap2 = nullptr; 190779a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, deviceDiscoveryCallback); 190879a732c7Sopenharmony_ci checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 190979a732c7Sopenharmony_ci ASSERT_EQ(checkMap2, nullptr); 191079a732c7Sopenharmony_ci int count3 = 0; 191179a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> authenticateCallback = std::make_shared<AuthenticateCallbackTest>(count3); 191279a732c7Sopenharmony_ci std::string deviceId = "1"; 191379a732c7Sopenharmony_ci std::shared_ptr<AuthenticateCallback> checkMap3 = nullptr; 191479a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, authenticateCallback); 191579a732c7Sopenharmony_ci checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 191679a732c7Sopenharmony_ci ASSERT_EQ(checkMap3, nullptr); 191779a732c7Sopenharmony_ci int count4 = 0; 191879a732c7Sopenharmony_ci std::shared_ptr<PublishCallback> devicePublishCallback = std::make_shared<PublishCallbackTest>(count4); 191979a732c7Sopenharmony_ci int32_t publishId = 0; 192079a732c7Sopenharmony_ci std::shared_ptr<PublishCallback> checkMap4 = nullptr; 192179a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, devicePublishCallback); 192279a732c7Sopenharmony_ci checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][subscribeId]; 192379a732c7Sopenharmony_ci ASSERT_EQ(checkMap4, nullptr); 192479a732c7Sopenharmony_ci std::string testPkgName = ""; 192579a732c7Sopenharmony_ci DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(testPkgName); 192679a732c7Sopenharmony_ci checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; 192779a732c7Sopenharmony_ci checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; 192879a732c7Sopenharmony_ci checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; 192979a732c7Sopenharmony_ci checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; 193079a732c7Sopenharmony_ci checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; 193179a732c7Sopenharmony_ci ASSERT_EQ(checkMap, nullptr); 193279a732c7Sopenharmony_ci ASSERT_EQ(checkMap1, nullptr); 193379a732c7Sopenharmony_ci ASSERT_EQ(checkMap2, nullptr); 193479a732c7Sopenharmony_ci ASSERT_EQ(checkMap3, nullptr); 193579a732c7Sopenharmony_ci ASSERT_EQ(checkMap4, nullptr); 193679a732c7Sopenharmony_ci} 193779a732c7Sopenharmony_ci} 193879a732c7Sopenharmony_ci} // namespace DistributedHardware 193979a732c7Sopenharmony_ci} // namespace OHOS 1940