/* * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "UTTest_device_manager_notify.h" #include "device_manager_notify.h" #include "dm_device_info.h" #include "ipc_remote_broker.h" #include "iremote_object.h" #include "iservice_registry.h" #include "system_ability_definition.h" #include "ipc_client_manager.h" #include "ipc_set_useroperation_req.h" #include "ipc_rsp.h" #include "ipc_def.h" #include namespace OHOS { namespace DistributedHardware { void DeviceManagerNotifyTest::SetUp() { } void DeviceManagerNotifyTest::TearDown() { } void DeviceManagerNotifyTest::SetUpTestCase() { } void DeviceManagerNotifyTest::TearDownTestCase() { } namespace { /** * @tc.name: RegisterDeathRecipientCallback_001 * @tc.desc: 1. set pkgName not null * set dmInitCallback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeathRecipientCallback_001, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr dmInitCallback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); } /** * @tc.name: RegisterDeathRecipientCallback_002 * @tc.desc: 1. set pkgName not null * set dmInitCallback null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap null * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeathRecipientCallback_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback null std::shared_ptr dmInitCallback = nullptr; // 2. set checkMap not null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 5. check checkMap null ASSERT_EQ(checkMap, nullptr); } /** * @tc.name: RegisterDeathRecipientCallback_003 * @tc.desc: 1. set pkgName com.ohos.test * set dmInitCallback not null * 2. set checkMap null * 3. set testpkcName com.ohos.test1 * 4. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter * 5. Get checkMap from DeviceManagerNotify with testpkcName * 6. check checkMap null * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeathRecipientCallback_003, testing::ext::TestSize.Level0) { // 1. set pkgName com.ohos.test std::string pkgName = "com.ohos.test"; // set dmInitCallback not null std::shared_ptr dmInitCallback = nullptr; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 4. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); // 5. Get checkMap from DeviceManagerNotify with testpkcName checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[testPkgName]; // 6. check checkMap not null ASSERT_EQ(checkMap, nullptr); } /** * @tc.name: RegisterDeathRecipientCallback_004 * @tc.desc: 1. set pkgName not null * set dmInitCallback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call checkMap OnRemoteDied * 7. check count is 1 * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeathRecipientCallback_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr dmInitCallback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call checkMap OnRemoteDied checkMap->OnRemoteDied(); // 7. check count is 1 ASSERT_EQ(count, 1); } /** * @tc.name: RegisterDeathRecipientCallback_005 * @tc.desc: 1. set pkgName not null * set dmInitCallback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call checkMap OnRemoteDied * 7. check count is 1 * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeathRecipientCallback_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr dmInitCallback = nullptr; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 5. check checkMap not null if (checkMap == nullptr) { ASSERT_NE(count, 1); return; } ASSERT_NE(checkMap, nullptr); } /** * @tc.name: RegisterDeathRecipientCallback_005 * @tc.type: FUNC */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeathRecipientCallback_006, testing::ext::TestSize.Level0) { std::string pkgName; int count = 0; std::shared_ptr dmInitCallback = nullptr; std::shared_ptr checkMap = nullptr; DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; if (checkMap == nullptr) { ASSERT_NE(count, 1); return; } ASSERT_NE(checkMap, nullptr); } /** * @tc.name: UnRegisterDeathRecipientCallback_001 * @tc.desc: 1. set pkgName not null * set dmInitCallback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with parameter * 7. Get checkMap from DeviceManagerNotify * 8. check checkMap null * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeathRecipientCallback_001, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr dmInitCallback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with parameter DeviceManagerNotify::GetInstance().UnRegisterDeathRecipientCallback(pkgName); // 7. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 8 check checkMap null ASSERT_EQ(checkMap, nullptr); } /** * @tc.name: UnRegisterDeathRecipientCallback_002 * @tc.desc: 1. set pkgName com.ohos.test * set dmInitCallback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeathRecipientCallback_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr dmInitCallback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterDeathRecipientCallback(testPkgName); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 8 check checkMap not null ASSERT_NE(checkMap, nullptr); } /** * @tc.name: UnRegisterDeathRecipientCallback_003 * @tc.desc: 1. set pkgName com.ohos.test * set dmInitCallback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. call checkMap OnRemoteDied * 10. check count is 1 * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeathRecipientCallback_003, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr dmInitCallback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterDeathRecipientCallback(testPkgName); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 9. call checkMap OnRemoteDied checkMap->OnRemoteDied(); // 10. check count is 1 ASSERT_EQ(count, 1); } /** * @tc.name: UnRegisterDeathRecipientCallback_004 * @tc.desc: 1. set pkgName com.ohos.test * set dmInitCallback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeathRecipientCallback_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr dmInitCallback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterDeathRecipientCallback(testPkgName); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 9. check checkMap not null if (checkMap == nullptr) { ASSERT_NE(count, 1); return; } ASSERT_NE(checkMap, nullptr); } /** * @tc.name: UnRegisterDeathRecipientCallback_005 * @tc.desc: 1. set pkgName com.ohos.test * set dmInitCallback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeathRecipientCallback_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr dmInitCallback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName nullptr std::string testPkgName = ""; // 7. call DeviceManagerNotifyTest UnRegisterDeathRecipientCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterDeathRecipientCallback(testPkgName); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 8 check checkMap not null ASSERT_NE(checkMap, nullptr); } /** * @tc.name: RegisterDeviceStateCallback_001 * @tc.desc: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * deviceTypeId * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeviceStateCallback_001, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); } /** * @tc.name: RegisterDeviceStateCallback_002 * @tc.desc: 1. set pkgName not null * set Callback null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeviceStateCallback_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback null std::shared_ptr callback = nullptr; // 2. set checkMap not null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap null ASSERT_EQ(checkMap, nullptr); } /** * @tc.name: RegisterDeviceStateCallback_003 * @tc.desc: 1. set pkgName com.ohos.test * set Callback not null * 2. set checkMap null * 3. set testpkcName com.ohos.test1 * 4. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 5. Get checkMap from DeviceManagerNotify with testpkcName * 6. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeviceStateCallback_003, testing::ext::TestSize.Level0) { // 1. set pkgName com.ohos.test std::string pkgName = "com.ohos.test"; // set dmInitCallback not null std::shared_ptr callback = nullptr; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 4. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 5. Get checkMap from DeviceManagerNotify with testpkcName checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[testPkgName]; // 6. check checkMap not null ASSERT_EQ(checkMap, nullptr); } /** * @tc.name: RegisterDeviceStateCallback_004 * @tc.desc: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call checkMap OnDeviceOnline * 7. check count is 1 * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeviceStateCallback_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call checkMap OnDeviceOnline DmDeviceInfo deviceInfo; checkMap->OnDeviceOnline(deviceInfo); // 7. check count is 1 ASSERT_EQ(count, 1); } /** * @tc.name: RegisterDeviceStateCallback_005 * @tc.desc: 1. set pkgName com.ohos.test * set Callback not null * 2. set checkMap null * 3. set testpkcName com.ohos.test1 * 4. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 5. Get checkMap from DeviceManagerNotify with testpkcName * 6. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeviceStateCallback_005, testing::ext::TestSize.Level0) { // 1. set pkgName com.ohos.test std::string pkgName = "com.ohos.test"; int count = 0; // set dmInitCallback not null std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 4. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 5. Get checkMap from DeviceManagerNotify with testpkcName checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[testPkgName]; // 6. check checkMap not null if (checkMap == nullptr) { ASSERT_NE(count, 1); return; } ASSERT_NE(checkMap, nullptr); } /** * @tc.name: UnRegisterDeviceStateCallback_001 * @tc.desc: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with parameter * 7. Get checkMap from DeviceManagerNotify * 8. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceStateCallback_001, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(pkgName); // 7. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 8 check checkMap null ASSERT_EQ(checkMap, nullptr); } /** * @tc.name: UnRegisterDeviceStateCallback_002 * @tc.desc: 1. set pkgName com.ohos.test * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceStateCallback_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 7. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(testPkgName); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 8 check checkMap not null ASSERT_NE(checkMap, nullptr); } /** * @tc.name: UnRegisterDeviceStateCallback_003 * @tc.desc: 1. set pkgName com.ohos.test * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceStateCallback_003, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 7. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(testPkgName); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 8 check checkMap not null ASSERT_NE(checkMap, nullptr); // 9. call checkMap OnDeviceOnline DmDeviceInfo deviceInfo; checkMap->OnDeviceOnline(deviceInfo); // 10. check count is 1 ASSERT_EQ(count, 1); } /** * @tc.name: UnRegisterDeviceStateCallback_004 * @tc.desc: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with parameter * 7. Get checkMap from DeviceManagerNotify * 8. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceStateCallback_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(pkgName); // 7. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 8 check checkMap null if (checkMap == nullptr) { ASSERT_NE(count, 1); return; } ASSERT_NE(checkMap, nullptr); } /** * @tc.name: UnRegisterDeviceStateCallback_005 * @tc.desc: 1. set pkgName com.ohos.test * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceStateCallback_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = ""; // 7. call DeviceManagerNotifyTest UnRegisterDeviceStateCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(testPkgName); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 8 check checkMap not null ASSERT_NE(checkMap, nullptr); // 9. call checkMap OnDeviceOnline DmDeviceInfo deviceInfo; checkMap->OnDeviceOnline(deviceInfo); // 10. check count is 1 ASSERT_EQ(count, 1); } /** * @tc.name: RegisterDiscoverCallback_001 * @tc.desc: 1. set pkgName not null * set Callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDiscoveryCallback_001, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); } /** * @tc.name: RegisterDiscoverCallback_002 * @tc.desc: 1. set pkgName not null * set Callback null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDiscoveryCallback_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback null std::shared_ptr callback = nullptr; // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap not null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap null ASSERT_EQ(checkMap, nullptr); } /** * @tc.name: RegisterDiscoverCallback_003 * @tc.desc: 1. set pkgName com.ohos.test * set Callback not null * set subscribeId not null * 2. set checkMap null * 3. set testpkcName com.ohos.test1 * 4. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 5. Get checkMap from DeviceManagerNotify with testpkcName * 6. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDiscoveryCallback_003, testing::ext::TestSize.Level0) { // 1. set pkgName com.ohos.test std::string pkgName = "com.ohos.test"; // set dmInitCallback not null std::shared_ptr callback = nullptr; // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 4. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 5. Get checkMap from DeviceManagerNotify with testpkcName checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 6. check checkMap not null ASSERT_EQ(checkMap, nullptr); } /** * @tc.name: RegisterDiscoverCallback_004 * @tc.desc: 1. set pkgName not null * set Callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call checkMap OnDiscoverySuccess * 7. check count is 1 * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDiscoveryCallback_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call checkMap OnDiscoverySuccess checkMap->OnDiscoverySuccess(subscribeId); // 7. check count is 1 ASSERT_EQ(count, 1); } /** * @tc.name: RegisterDiscoverCallback_005 * @tc.desc: 1. set pkgName com.ohos.test * set Callback not null * set subscribeId not null * 2. set checkMap null * 3. set testpkcName com.ohos.test1 * 4. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 5. Get checkMap from DeviceManagerNotify with testpkcName * 6. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterDiscoveryCallback_005, testing::ext::TestSize.Level0) { // 1. set pkgName com.ohos.test std::string pkgName = "com.ohos.test"; int count = 0; // set dmInitCallback not null std::shared_ptr callback = std::make_shared(count); uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 4. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 5. Get checkMap from DeviceManagerNotify with testpkcName checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 6. check checkMap not null if (checkMap == nullptr) { ASSERT_NE(count, 1); return; } ASSERT_NE(checkMap, nullptr); } /** * @tc.name: RegisterDiscoverCallback_006 * @tc.type: FUNC */ HWTEST_F(DeviceManagerNotifyTest, RegisterDiscoveryCallback_006, testing::ext::TestSize.Level0) { std::string pkgName; int count = 0; std::shared_ptr callback = std::make_shared(count); uint16_t subscribeId = 0; DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); } /** * @tc.name: UnRegisterDiscoverCallback_001 * @tc.desc: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with parameter * 7. Get checkMap from DeviceManagerNotify * 8. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDiscoveryCallback_001, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(pkgName, subscribeId); // 7. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 8 check checkMap null ASSERT_EQ(checkMap, nullptr); } /** * @tc.name: UnRegisterDiscoverCallback_002 * @tc.desc: 1. set pkgName com.ohos.test * set dmInitCallback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDiscoveryCallback_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 7. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(testPkgName, subscribeId); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 8 check checkMap not null ASSERT_NE(checkMap, nullptr); } /** * @tc.name: UnRegisterDiscoverCallback_003 * @tc.desc: 1. set pkgName com.ohos.test * set dmInitCallback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null * 10. call checkMap OnDiscoverySuccess * 11. check count is 1 * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDiscoveryCallback_003, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 7. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(testPkgName, subscribeId); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 9 check checkMap not null ASSERT_NE(checkMap, nullptr); // 10. call checkMap OnDiscoverySuccess checkMap->OnDiscoverySuccess(subscribeId); // 11. check count is 1 ASSERT_EQ(count, 1); } /** * @tc.name: UnRegisterDiscoverCallback_004 * @tc.desc: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with parameter * 7. Get checkMap from DeviceManagerNotify * 8. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDiscoveryCallback_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(pkgName, subscribeId); // 7. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 8 check checkMap null if (checkMap == nullptr) { ASSERT_NE(count, 1); return; } ASSERT_NE(checkMap, nullptr); } /** * @tc.name: UnRegisterDiscoverCallback_005 * @tc.desc: 1. set pkgName com.ohos.test * set dmInitCallback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null * 10. call checkMap OnDiscoverySuccess * 11. check count is 1 * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDiscoveryCallback_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = ""; // 7. call DeviceManagerNotifyTest UnRegisterDiscoverCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(testPkgName, subscribeId); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 9 check checkMap not null ASSERT_NE(checkMap, nullptr); // 10. call checkMap OnDiscoverySuccess checkMap->OnDiscoverySuccess(subscribeId); // 11. check count is 1 ASSERT_EQ(count, 1); } /** * @tc.name: RegisterAuthenticateCallback_001 * @tc.desc: 1. set pkgName not null * set Callback not null * set deviceId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterAuthenticateCallback_001, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); } /** * @tc.name: RegisterAuthenticateCallback_002 * @tc.desc: 1. set pkgName not null * set Callback null * set deviceId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterAuthenticateCallback_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback null std::shared_ptr callback = nullptr; // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap not null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap null ASSERT_EQ(checkMap, nullptr); } /** * @tc.name: RegisterAuthenticateCallback_003 * @tc.desc: 1. set pkgName com.ohos.test * set Callback not null * set deviceId not null * 2. set checkMap null * 3. set testpkcName com.ohos.test1 * 4. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 5. Get checkMap from DeviceManagerNotify with testpkcName * 6. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterAuthenticateCallback_003, testing::ext::TestSize.Level0) { // 1. set pkgName com.ohos.test std::string pkgName = "com.ohos.test"; // set dmInitCallback not null std::shared_ptr callback = nullptr; // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 4. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 5. Get checkMap from DeviceManagerNotify with testpkcName checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 6. check checkMap not null ASSERT_EQ(checkMap, nullptr); } /** * @tc.name: RegisterAuthenticateCallback_004 * @tc.desc: 1. set pkgName not null * set Callback not null * set deviceId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterAuthenticateCallback_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call checkMap OnAuthResult std::string token ="1"; int32_t status = 1; int32_t reason = 1; checkMap->OnAuthResult(deviceId, token, status, reason); // 7. check count is 1 ASSERT_EQ(count, 1); } /** * @tc.name: RegisterAuthenticateCallback_005 * @tc.desc: 1. set pkgName com.ohos.test * set Callback not null * set deviceId not null * 2. set checkMap null * 3. set testpkcName com.ohos.test1 * 4. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 5. Get checkMap from DeviceManagerNotify with testpkcName * 6. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, RegisterAuthenticateCallback_005, testing::ext::TestSize.Level0) { // 1. set pkgName com.ohos.test std::string pkgName = "com.ohos.test"; int count = 0; // set dmInitCallback not null std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 4. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 5. Get checkMap from DeviceManagerNotify with testpkcName checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 6. check checkMap not null if (checkMap == nullptr) { ASSERT_NE(count, 1); return; } ASSERT_NE(checkMap, nullptr); } /** * @tc.name: UnRegisterAuthenticateCallback_001 * @tc.desc: 1. set pkgName not null * set callback not null * set deviceId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with parameter * 7. Get checkMap from DeviceManagerNotify * 8. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterAuthenticateCallback_001, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().UnRegisterAuthenticateCallback(pkgName, deviceId); // 7. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 8 check checkMap null ASSERT_EQ(checkMap, nullptr); } /** * @tc.name: UnRegisterAuthenticateCallback_002 * @tc.desc: 1. set pkgName com.ohos.test * set dmInitCallback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterAuthenticateCallback_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 7. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterAuthenticateCallback(testPkgName, deviceId); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 8 check checkMap not null ASSERT_NE(checkMap, nullptr); } /** * @tc.name: UnRegisterAuthenticateCallback_003 * @tc.desc: 1. set pkgName com.ohos.test * set dmInitCallback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null * 10. call checkMap OnAuthResult * 11. check count is 1 * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterAuthenticateCallback_003, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 7. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterAuthenticateCallback(testPkgName, deviceId); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 9 check checkMap not null ASSERT_NE(checkMap, nullptr); // 10. call checkMap OnAuthResult std::string token ="1"; int32_t status = 1; int32_t reason = 1; checkMap->OnAuthResult(deviceId, token, status, reason); // 11. check count is 1 ASSERT_EQ(count, 1); } /** * @tc.name: UnRegisterAuthenticateCallback_004 * @tc.desc: 1. set pkgName not null * set callback not null * set deviceId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with parameter * 7. Get checkMap from DeviceManagerNotify * 8. check checkMap null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterAuthenticateCallback_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().UnRegisterAuthenticateCallback(pkgName, deviceId); // 7. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 8. check checkMap not null if (checkMap == nullptr) { ASSERT_NE(count, 1); return; } ASSERT_NE(checkMap, nullptr); } /** * @tc.name: UnRegisterAuthenticateCallback_005 * @tc.desc: 1. set pkgName com.ohos.test * set dmInitCallback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterAuthenticateCallback_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = ""; // 7. call DeviceManagerNotifyTest UnRegisterAuthenticateCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterAuthenticateCallback(testPkgName, deviceId); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 8 check checkMap not null ASSERT_NE(checkMap, nullptr); } /** * @tc.name: UnRegisterPackageCallback_001 * @tc.desc: 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback * 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback * 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId * 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback * 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId * 6. call DeviceManagerNotify UnRegisterPackageCallback with PkgName * 7. check if checkMap checkMap1 checkMap2 checkMap3 is null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterPackageCallback_001, testing::ext::TestSize.Level0) { // 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback std::string pkgName = "com.ohos.test"; int count = 0; std::shared_ptr dmInitCallback = std::make_shared(count); std::shared_ptr checkMap = nullptr; DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; ASSERT_NE(checkMap, nullptr); // 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback int count1 = 0; std::shared_ptr deviceStateCallback = std::make_shared(count1); std::shared_ptr checkMap1 = nullptr; DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, deviceStateCallback); checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; ASSERT_NE(checkMap1, nullptr); // 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId int count2 = 0; std::shared_ptr deviceDiscoveryCallback = std::make_shared(count2); uint16_t subscribeId = 0; std::shared_ptr checkMap2 = nullptr; DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, deviceDiscoveryCallback); checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; ASSERT_NE(checkMap2, nullptr); // 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback int count3 = 0; std::shared_ptr authenticateCallback = std::make_shared(count3); std::string deviceId = "1"; std::shared_ptr checkMap3 = nullptr; DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, authenticateCallback); checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; ASSERT_NE(checkMap3, nullptr); // 5. RegisterPublishCallback with pkgName and deviceStateCallback and subscribeId int count4 = 0; std::shared_ptr devicePublishCallback = std::make_shared(count4); int32_t publishId = 0; std::shared_ptr checkMap4 = nullptr; DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, devicePublishCallback); checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; ASSERT_NE(checkMap4, nullptr); // 6. call DeviceManagerNotify UnRegisterPackageCallback with PkgName DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(pkgName); checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 7. check if checkMap checkMap1 checkMap2 checkMap3 is null ASSERT_EQ(checkMap, nullptr); ASSERT_EQ(checkMap1, nullptr); ASSERT_EQ(checkMap2, nullptr); ASSERT_EQ(checkMap3, nullptr); ASSERT_EQ(checkMap4, nullptr); } /** * @tc.name: UnRegisterPackageCallback_002 * @tc.desc: 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback * 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback * 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId * 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback * 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId * 6. call DeviceManagerNotify UnRegisterPackageCallback with testPkgName * 7. check if checkMap checkMap1 checkMap2 checkMap3 is not null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterPackageCallback_002, testing::ext::TestSize.Level0) { // 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback std::string pkgName = "com.ohos.test"; int count = 0; std::shared_ptr dmInitCallback = std::make_shared(count); std::shared_ptr checkMap = nullptr; DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; ASSERT_NE(checkMap, nullptr); // 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback int count1 = 0; std::shared_ptr deviceStateCallback = std::make_shared(count1); std::shared_ptr checkMap1 = nullptr; DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, deviceStateCallback); checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; ASSERT_NE(checkMap1, nullptr); // 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId int count2 = 0; std::shared_ptr deviceDiscoveryCallback = std::make_shared(count2); uint16_t subscribeId = 0; std::shared_ptr checkMap2 = nullptr; DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, deviceDiscoveryCallback); checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; ASSERT_NE(checkMap2, nullptr); // 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback int count3 = 0; std::shared_ptr authenticateCallback = std::make_shared(count3); std::string deviceId = "1"; std::shared_ptr checkMap3 = nullptr; DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, authenticateCallback); checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; ASSERT_NE(checkMap3, nullptr); // 5. RegisterPublishCallback with pkgName and deviceStateCallback and publishId int count4 = 0; std::shared_ptr devicePublishCallback = std::make_shared(count4); int32_t publishId = 0; std::shared_ptr checkMap4 = nullptr; DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, devicePublishCallback); checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; ASSERT_NE(checkMap4, nullptr); // 6. call DeviceManagerNotify UnRegisterPackageCallback with testPkgName std::string testPkgName = "com.ohos.test1"; DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(testPkgName); checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 7. check if checkMap checkMap1 checkMap2 checkMap3 is null ASSERT_NE(checkMap, nullptr); ASSERT_NE(checkMap1, nullptr); ASSERT_NE(checkMap2, nullptr); ASSERT_NE(checkMap3, nullptr); ASSERT_NE(checkMap4, nullptr); } /** * @tc.name: UnRegisterPackageCallback_003 * @tc.desc: 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback * 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback * 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId * 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback * 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId * 6. call DeviceManagerNotify UnRegisterPackageCallback with testPkgName * 7. check if checkMap checkMap1 checkMap2 checkMap3 is not null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterPackageCallback_003, testing::ext::TestSize.Level0) { // 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback std::string pkgName = "com.ohos.test"; int count[5] = {0, 0, 0, 0, 0}; std::shared_ptr dmInitCallback = std::make_shared(count[0]); std::shared_ptr checkMap = nullptr; DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); ASSERT_NE(DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName], nullptr); // 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback std::shared_ptr deviceStateCallback = std::make_shared(count[1]); std::shared_ptr checkMap1 = nullptr; DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, deviceStateCallback); ASSERT_NE(DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName], nullptr); // 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId std::shared_ptr deviceDiscoveryCallback = std::make_shared(count[2]); uint16_t subscribeId = 0; std::shared_ptr checkMap2 = nullptr; DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, deviceDiscoveryCallback); ASSERT_NE(DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId], nullptr); // 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback std::shared_ptr authenticateCallback = std::make_shared(count[3]); std::string deviceId = "1"; std::shared_ptr checkMap3 = nullptr; DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, authenticateCallback); ASSERT_NE(DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId], nullptr); // 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId std::shared_ptr devicePublishCallback = std::make_shared(count[4]); int32_t publishId = 0; std::shared_ptr checkMap4 = nullptr; DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, devicePublishCallback); ASSERT_NE(DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId], nullptr); // 6. call DeviceManagerNotify UnRegisterPackageCallback with testPkgName std::string testPkgName = "com.ohos.test1"; DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(testPkgName); checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 6. check if checkMap checkMap1 checkMap2 checkMap3 is null ASSERT_NE(checkMap, nullptr); ASSERT_NE(checkMap1, nullptr); ASSERT_NE(checkMap2, nullptr); ASSERT_NE(checkMap3, nullptr); ASSERT_NE(checkMap4, nullptr); // 7. call checkMap OnRemoteDied() checkMap->OnRemoteDied(); // call checkMap1 OnDeviceOnline DmDeviceInfo deviceInfo; checkMap1->OnDeviceOnline(deviceInfo); // call checkMap2 OnDeviceFound checkMap2->OnDeviceFound(subscribeId, deviceInfo); // call checkMap3 OnAuthResult checkMap3->OnAuthResult(deviceId, "1", 1, 1); // call checkMap4 OnPublishResult checkMap4->OnPublishResult(publishId, 0); // 8. check count count1 count2 count3 is 1 for (uint32_t i = 0; i < 5; i++) { ASSERT_EQ(count[i], 1); } } /** * @tc.name: UnRegisterPackageCallback_004 * @tc.desc: 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback * 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback * 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId * 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback * 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId * 6. call DeviceManagerNotify UnRegisterPackageCallback with PkgName * 7. check if checkMap checkMap1 checkMap2 checkMap3 is null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterPackageCallback_004, testing::ext::TestSize.Level0) { // 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback std::string pkgName = "com.ohos.test"; int count[5] = {0, 0, 0, 0, 0}; std::shared_ptr dmInitCallback = std::make_shared(count[0]); std::shared_ptr checkMap = nullptr; DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); ASSERT_NE(DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName], nullptr); // 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback std::shared_ptr deviceStateCallback = std::make_shared(count[1]); std::shared_ptr checkMap1 = nullptr; DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, deviceStateCallback); ASSERT_NE(DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName], nullptr); // 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId std::shared_ptr deviceDiscoveryCallback = std::make_shared(count[2]); uint16_t subscribeId = 0; std::shared_ptr checkMap2 = nullptr; DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, deviceDiscoveryCallback); ASSERT_NE(DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId], nullptr); // 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback std::shared_ptr authenticateCallback = std::make_shared(count[3]); std::string deviceId = "1"; std::shared_ptr checkMap3 = nullptr; DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, authenticateCallback); ASSERT_NE(DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId], nullptr); // 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId std::shared_ptr devicePublishCallback = std::make_shared(count[4]); int32_t publishId = 0; std::shared_ptr checkMap4 = nullptr; DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, devicePublishCallback); ASSERT_NE(DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId], nullptr); // 6. call DeviceManagerNotify UnRegisterPackageCallback with PkgName DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(pkgName); checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 6. check if checkMap checkMap1 checkMap2 checkMap3 is null if (checkMap == nullptr && checkMap1 == nullptr && checkMap2 == nullptr && checkMap3 == nullptr && checkMap4 == nullptr) { for (uint32_t i = 0; i < 5; i++) { ASSERT_NE(count[i], 1); } return; } ASSERT_EQ(checkMap, nullptr); ASSERT_EQ(checkMap1, nullptr); ASSERT_EQ(checkMap2, nullptr); ASSERT_EQ(checkMap3, nullptr); ASSERT_EQ(checkMap4, nullptr); } /** * @tc.name: UnRegisterPackageCallback_005 * @tc.desc: 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback * 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback * 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId * 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback * 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId * 6. call DeviceManagerNotify UnRegisterPackageCallback with testPkgName * 7. check if checkMap checkMap1 checkMap2 checkMap3 is not null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterPackageCallback_005, testing::ext::TestSize.Level0) { // 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback std::string pkgName = "com.ohos.test"; int count = 0; std::shared_ptr dmInitCallback = std::make_shared(count); std::shared_ptr checkMap = nullptr; DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; ASSERT_NE(checkMap, nullptr); // 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback int count1 = 0; std::shared_ptr deviceStateCallback = std::make_shared(count1); std::shared_ptr checkMap1 = nullptr; DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, deviceStateCallback); checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; ASSERT_NE(checkMap1, nullptr); // 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId int count2 = 0; std::shared_ptr deviceDiscoveryCallback = std::make_shared(count2); uint16_t subscribeId = 0; std::shared_ptr checkMap2 = nullptr; DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, deviceDiscoveryCallback); checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; ASSERT_NE(checkMap2, nullptr); // 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback int count3 = 0; std::shared_ptr authenticateCallback = std::make_shared(count3); std::string deviceId = "1"; std::shared_ptr checkMap3 = nullptr; DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, authenticateCallback); checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; ASSERT_NE(checkMap3, nullptr); // 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId int count4 = 0; std::shared_ptr devicePublishCallback = std::make_shared(count4); int32_t publishId = 0; std::shared_ptr checkMap4 = nullptr; DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, devicePublishCallback); checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][subscribeId]; ASSERT_NE(checkMap4, nullptr); // 5. call DeviceManagerNotify UnRegisterPackageCallback with testPkgName std::string testPkgName = ""; DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(testPkgName); checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 6. check if checkMap checkMap1 checkMap2 checkMap3 is null ASSERT_NE(checkMap, nullptr); ASSERT_NE(checkMap1, nullptr); ASSERT_NE(checkMap2, nullptr); ASSERT_NE(checkMap3, nullptr); ASSERT_NE(checkMap4, nullptr); } /** * @tc.name: UnRegisterPackageCallback_005 * @tc.desc: 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback * 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback * 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId * 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback * 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId * 6. call DeviceManagerNotify UnRegisterPackageCallback with testPkgName * 7. check if checkMap checkMap1 checkMap2 checkMap3 is not null * @tc.type: FUNC * @tc.require: AR000GHSJK */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterPackageCallback_006, testing::ext::TestSize.Level0) { // 1. RegisterDeathRecipientCallback with pkgName and dmInitCallback std::string pkgName; int count = 0; std::shared_ptr dmInitCallback = std::make_shared(count); std::shared_ptr checkMap = nullptr; DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; ASSERT_EQ(checkMap, nullptr); // 2. RegisterDeviceStateCallback with pkgName and deviceStateCallback int count1 = 0; std::shared_ptr deviceStateCallback = std::make_shared(count1); std::shared_ptr checkMap1 = nullptr; DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, deviceStateCallback); checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; ASSERT_EQ(checkMap1, nullptr); // 3. RegisterDiscoverCallback with pkgName and deviceStateCallback and subscribeId int count2 = 0; std::shared_ptr deviceDiscoveryCallback = std::make_shared(count2); uint16_t subscribeId = 0; std::shared_ptr checkMap2 = nullptr; DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, deviceDiscoveryCallback); checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; ASSERT_EQ(checkMap2, nullptr); // 4. RegisterAuthenticateCallback with pkgName and deviceId and authenticateCallback int count3 = 0; std::shared_ptr authenticateCallback = std::make_shared(count3); std::string deviceId = "1"; std::shared_ptr checkMap3 = nullptr; DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, authenticateCallback); checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; ASSERT_EQ(checkMap3, nullptr); // 5. RegisterPublishCallback with pkgName and devicePublishCallback and publishId int count4 = 0; std::shared_ptr devicePublishCallback = std::make_shared(count4); int32_t publishId = 0; std::shared_ptr checkMap4 = nullptr; DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, devicePublishCallback); checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][subscribeId]; ASSERT_EQ(checkMap4, nullptr); // 5. call DeviceManagerNotify UnRegisterPackageCallback with testPkgName std::string testPkgName = ""; DeviceManagerNotify::GetInstance().UnRegisterPackageCallback(testPkgName); checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; checkMap1 = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; checkMap2 = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; checkMap3 = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; checkMap4 = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 6. check if checkMap checkMap1 checkMap2 checkMap3 is null ASSERT_EQ(checkMap, nullptr); ASSERT_EQ(checkMap1, nullptr); ASSERT_EQ(checkMap2, nullptr); ASSERT_EQ(checkMap3, nullptr); ASSERT_EQ(checkMap4, nullptr); } /* * Feature: DeviceManagerNotifyTest RegisterDeviceManagerFaCallback * Function: DeviceManagerNotifyTest * SubFunction: RegisterDeviceManagerFaCallback * FunctionPoints: DeviceManagerNotifyTest RegisterDeviceManagerFaCallback * EnvConditions: RegisterDeviceManagerFaCallback success. * CaseDescription: 1. set pkgName not null * set dmUiCallback_ not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeviceManagerFaCallback_001, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmUiCallback_ not null int count = 0; std::shared_ptr dmUiCallback_ = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); } /* * Feature: DeviceManagerNotifyTest RegisterDeviceManagerFaCallback * Function: DeviceManagerNotifyTest * SubFunction: RegisterDeviceManagerFaCallback * FunctionPoints: DeviceManagerNotifyTest RegisterDeviceManagerFaCallback * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set dmUiCallback_ null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap null */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeviceManagerFaCallback_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback null std::shared_ptr dmUiCallback_ = nullptr; // 2. set checkMap not null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 5. check checkMap null ASSERT_EQ(checkMap, nullptr); } /* * Feature: DeviceManagerNotifyTest RegisterDeviceManagerFaCallback * Function: DeviceManagerNotifyTest * SubFunction: RegisterDeviceManagerFaCallback * FunctionPoints: DeviceManagerNotifyTest RegisterDeviceManagerFaCallback * EnvConditions: N/A. * CaseDescription: 1. set pkgName com.ohos.test * set dmUiCallback_ not null * 2. set checkMap null * 3. set testpkcName com.ohos.test1 * 4. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 5. Get checkMap from DeviceManagerNotify with testpkcName * 6. check checkMap null */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeviceManagerFaCallback_003, testing::ext::TestSize.Level0) { // 1. set pkgName com.ohos.test std::string pkgName = "com.ohos.test"; // set dmInitCallback not null std::shared_ptr dmUiCallback_ = nullptr; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 4. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 5. Get checkMap from DeviceManagerNotify with testpkcName checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[testPkgName]; // 6. check checkMap not null ASSERT_EQ(checkMap, nullptr); } /* * Feature: DeviceManagerNotifyTest RegisterDeviceManagerFaCallback * Function: DeviceManagerNotifyTest * SubFunction: RegisterDeviceManagerFaCallback * FunctionPoints: DeviceManagerNotifyTest RegisterDeviceManagerFaCallback * EnvConditions: RegisterDeviceManagerFaCallback success. * CaseDescription: 1. set pkgName not null * set dmUiCallback_ not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeviceManagerFaCallback_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmUiCallback_ not null int count = 0; std::shared_ptr dmUiCallback_ = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call checkMap OnCall std::string paramJson = "test"; checkMap->OnCall(paramJson); ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest RegisterDeviceManagerFaCallback * Function: DeviceManagerNotifyTest * SubFunction: RegisterDeviceManagerFaCallback * FunctionPoints: DeviceManagerNotifyTest RegisterDeviceManagerFaCallback * EnvConditions: N/A. * CaseDescription: 1. set pkgName com.ohos.test * set dmUiCallback_ not null * 2. set checkMap null * 3. set testpkcName com.ohos.test1 * 4. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 5. Get checkMap from DeviceManagerNotify with testpkcName * 6. check checkMap null */ HWTEST_F(DeviceManagerNotifyTest, RegisterDeviceManagerFaCallback_005, testing::ext::TestSize.Level0) { // 1. set pkgName com.ohos.test std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr dmUiCallback_ = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 4. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 5. Get checkMap from DeviceManagerNotify with testpkcName checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[testPkgName]; // 6. check checkMap not null if (checkMap == nullptr) { ASSERT_NE(count, 1); return; } ASSERT_EQ(checkMap, nullptr); } /* * Feature: DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback * Function: DeviceManagerNotifyTest * SubFunction: UnRegisterDeviceManagerFaCallback * FunctionPoints: DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback * EnvConditions: UnRegisterDeviceManagerFaCallback success. * CaseDescription: 1. set pkgName not null * set dmUiCallback_ not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback with parameter * 7. Get checkMap from DeviceManagerNotify * 8. check checkMap null */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceManagerFaCallback_001, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr dmUiCallback_ = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().UnRegisterDeviceManagerFaCallback(pkgName); // 7. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 8 check checkMap null ASSERT_EQ(checkMap, nullptr); } /* * Feature: DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback * Function: DeviceManagerNotifyTest * SubFunction: UnRegisterDeviceManagerFaCallback * FunctionPoints: DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback * EnvConditions: N/A. * CaseDescription: 1. set pkgName com.ohos.test * set dmInitCallback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceManagerFaCallback_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmUiCallback_ not null int count = 0; std::shared_ptr dmUiCallback_ = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 7. call DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterDeviceManagerFaCallback(testPkgName); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 8 check checkMap not null ASSERT_NE(checkMap, nullptr); } /* * Feature: DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback_003 * Function: DeviceManagerNotifyTest * SubFunction: UnRegisterDeviceManagerFaCallback * FunctionPoints: DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback * EnvConditions: N/A. * CaseDescription: 1. set pkgName com.ohos.test * set dmInitCallback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceManagerFaCallback_003, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmUiCallback_ not null int count = 0; std::shared_ptr dmUiCallback_ = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 7. call DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterDeviceManagerFaCallback(testPkgName); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 9. check checkMap not null ASSERT_NE(checkMap, nullptr); // 10. call checkMap OnCall std::string paramJson = "test"; checkMap->OnCall(paramJson); ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback_004 * Function: DeviceManagerNotifyTest * SubFunction: UnRegisterDeviceManagerFaCallback * FunctionPoints: DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback * EnvConditions: UnRegisterDeviceManagerFaCallback success. * CaseDescription: 1. set pkgName not null * set dmUiCallback_ not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback with parameter * 7. Get checkMap from DeviceManagerNotify * 8. check checkMap null */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceManagerFaCallback_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr dmUiCallback_ = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().UnRegisterDeviceManagerFaCallback(pkgName); // 7. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 8 check checkMap null if (checkMap == nullptr) { ASSERT_NE(count, 1); return; } ASSERT_EQ(checkMap, nullptr); } /* * Feature: DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback_005 * Function: DeviceManagerNotifyTest * SubFunction: UnRegisterDeviceManagerFaCallback * FunctionPoints: DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback * EnvConditions: N/A. * CaseDescription: 1. set pkgName com.ohos.test * set dmInitCallback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback with testpkcName * 8. Get checkMap from DeviceManagerNotify * 9. check checkMap not null */ HWTEST_F(DeviceManagerNotifyTest, UnRegisterDeviceManagerFaCallback_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmUiCallback_ not null int count = 0; std::shared_ptr dmUiCallback_ = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 4. Get checkMap from DeviceManagerNotify RegisterDeathRecipientCallback checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = ""; // 7. call DeviceManagerNotifyTest UnRegisterDeviceManagerFaCallback with testpkcName DeviceManagerNotify::GetInstance().UnRegisterDeviceManagerFaCallback(testPkgName); // 8. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 9. check checkMap not null ASSERT_NE(checkMap, nullptr); // 10. call checkMap OnCall std::string paramJson = "test"; checkMap->OnCall(paramJson); ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest OnRemoteDied * Function: DeviceManagerNotifyTest * SubFunction: OnRemoteDied * FunctionPoints: DeviceManagerNotifyTest OnRemoteDied * EnvConditions: OnRemoteDied success. * CaseDescription: 1. set pkgName not null * set dmInitCallback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnRemoteDied * 7. check if dmInitCallback OnRemoteDied called. */ HWTEST_F(DeviceManagerNotifyTest, OnRemoteDied1, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmInitCallback not null int count = 0; std::shared_ptr dmInitCallback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeathRecipientCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeathRecipientCallback(pkgName, dmInitCallback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmInitCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnRemoteDied DeviceManagerNotify::GetInstance().OnRemoteDied(); // 7. check if dmInitCallback OnRemoteDied called ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest OnDeviceOnline * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceOnline * FunctionPoints: DeviceManagerNotifyTest OnDeviceOnline * EnvConditions: OnDeviceOnline success. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDeviceOnline * 7. check if callback OnDeviceOnline called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceOnline_001, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnDeviceOnline DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceOnline(pkgName, deviceInfo); // 7. check if callback OnDeviceOnline called ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest OnDeviceOnline * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceOnline * FunctionPoints: DeviceManagerNotifyTest OnDeviceOnline * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotify OnDeviceOnline with testpkcName * 8. check if callback OnDeviceOnline called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceOnline_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 7. call DeviceManagerNotify OnDeviceOnline with testpkcName DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceOnline(testPkgName, deviceInfo); // 8. check if callback OnDeviceOnline called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDeviceOnline * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceOnline * FunctionPoints: DeviceManagerNotifyTest OnDeviceOnline * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotify OnDeviceOnline with testpkcName * 8. check if callback OnDeviceOnline called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceOnline_003, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = ""; // 7. call DeviceManagerNotify OnDeviceOnline with testpkcName DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceOnline(testPkgName, deviceInfo); // 8. check if callback OnDeviceOnline called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDeviceOnline * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceOnline * FunctionPoints: DeviceManagerNotifyTest OnDeviceOnline * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotify OnDeviceOnline with testpkcName * 8. check if callback OnDeviceOnline called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceOnline_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "111"; // 7. call DeviceManagerNotify OnDeviceOnline with testpkcName DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceOnline(testPkgName, deviceInfo); // 8. check if callback OnDeviceOnline called ASSERT_NE(count, 1); } /* * Feature: DeviceManagerNotifyTest OnDeviceOnline * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceOnline * FunctionPoints: DeviceManagerNotifyTest OnDeviceOnline * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify UnRegisterDeviceStateCallback withtestPkgName * 7. call DeviceManagerNotify OnDeviceOnline with testpkcName * 8. check if callback OnDeviceOnline called */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceOnline_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); std::string testPkgName = ""; // 6. call DeviceManagerNotify UnRegisterDeviceStateCallback withtestPkgName DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(testPkgName); // 7. call DeviceManagerNotify OnDeviceOnline with testpkcName DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceOnline(testPkgName, deviceInfo); // 8. check if callback OnDeviceOnline called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDeviceOffline * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceOffline * FunctionPoints: DeviceManagerNotifyTest OnDeviceOffline * EnvConditions: OnDeviceOffline success. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDeviceOffline * 7. check if callback OnDeviceOffline called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceOffline_001, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnDeviceOffline DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceOffline(pkgName, deviceInfo); // 7. check if callback OnDeviceOffline called ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest OnDeviceOffline * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceOffline * FunctionPoints: DeviceManagerNotifyTest OnDeviceOffline * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotify OnDeviceOffline with testpkcName * 8. check if callback OnDeviceOffline called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceOffline_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 7. call DeviceManagerNotify OnDeviceOffline with testpkcName DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceOffline(testPkgName, deviceInfo); // 8. check if callback OnDeviceOffline called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDeviceOffline * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceOffline * FunctionPoints: DeviceManagerNotifyTest OnDeviceOffline * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotify OnDeviceOffline with testpkcName * 8. check if callback OnDeviceOffline called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceOffline_003, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName null std::string testPkgName = ""; // 7. call DeviceManagerNotify OnDeviceOffline with testpkcName DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceOffline(testPkgName, deviceInfo); // 8. check if callback OnDeviceOffline called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDeviceOffline * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceOffline * FunctionPoints: DeviceManagerNotifyTest OnDeviceOffline * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotify OnDeviceOffline with testpkcName * 8. check if callback OnDeviceOffline called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceOffline_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName null std::string testPkgName = ""; // 7. call DeviceManagerNotify OnDeviceOffline with testpkcName DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceOffline(testPkgName, deviceInfo); // 8. check if callback OnDeviceOffline called ASSERT_NE(count, 1); } /* * Feature: DeviceManagerNotifyTest OnDeviceOffline * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceOffline * FunctionPoints: DeviceManagerNotifyTest OnDeviceOffline * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify UnRegisterDeviceStateCallback withtestPkgName * 7. call DeviceManagerNotify OnDeviceOffline with testpkcName * 8. check if callback OnDeviceOffline called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceOffline_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify UnRegisterDeviceStateCallback withtestPkgName std::string testPkgName = ""; DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(testPkgName); // 7. call DeviceManagerNotify OnDeviceOffline with testpkcName DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceOffline(testPkgName, deviceInfo); // 8. check if callback OnDeviceOffline called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDeviceChanged * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceChanged * FunctionPoints: DeviceManagerNotifyTest OnDeviceChanged * EnvConditions: OnDeviceChanged success. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDeviceChanged * 7. check if callback OnDeviceChanged called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceChanged_001, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnDeviceChanged DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceChanged(pkgName, deviceInfo); // 7. check if callback OnDeviceChanged called ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest OnDeviceChanged * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceChanged * FunctionPoints: DeviceManagerNotifyTest OnDeviceChanged * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotify OnDeviceChanged with testpkcName * 8. check if callback OnDeviceChanged called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceChanged_002, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = "com.ohos.test1"; // 7. call DeviceManagerNotify OnDeviceChanged with testpkcName DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceChanged(testPkgName, deviceInfo); // 8. check if callback OnDeviceChanged called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDeviceChanged * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceChanged * FunctionPoints: DeviceManagerNotifyTest OnDeviceChanged * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotify OnDeviceChanged with testpkcName * 8. check if callback OnDeviceChanged called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceChanged_003, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = ""; // 7. call DeviceManagerNotify OnDeviceChanged with testpkcName DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceChanged(testPkgName, deviceInfo); // 8. check if callback OnDeviceChanged called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDeviceChanged * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceChanged * FunctionPoints: DeviceManagerNotifyTest OnDeviceChanged * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotify OnDeviceChanged with testpkcName * 8. check if callback OnDeviceChanged called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceChanged_004, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. set testpkcName com.ohos.test1 std::string testPkgName = ""; // 7. call DeviceManagerNotify OnDeviceChanged with testpkcName DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceChanged(testPkgName, deviceInfo); // 8. check if callback OnDeviceChanged called ASSERT_NE(count, 1); } /* * Feature: DeviceManagerNotifyTest OnDeviceChanged * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceChanged * FunctionPoints: DeviceManagerNotifyTest OnDeviceChanged * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set Callback not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. set testpkcName com.ohos.test1 * 7. call DeviceManagerNotify OnDeviceChanged with testpkcName * 8. check if callback OnDeviceChanged called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceChanged_005, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set Callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceStateCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceStateCallback(pkgName, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceStateCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify UnRegisterDeviceStateCallback withtestPkgName std::string testPkgName = ""; DeviceManagerNotify::GetInstance().UnRegisterDeviceStateCallback(testPkgName); // 7. call DeviceManagerNotify OnDeviceChanged with testpkcName DmDeviceInfo deviceInfo; DeviceManagerNotify::GetInstance().OnDeviceChanged(testPkgName, deviceInfo); // 8. check if callback OnDeviceChanged called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDeviceFound * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceFound * FunctionPoints: DeviceManagerNotifyTest OnDeviceFound * EnvConditions: OnDeviceFound success. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDeviceFound * 7. check if callback OnDeviceFound called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceFound1, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); DmDeviceInfo deviceInfo; // 6. call DeviceManagerNotify OnDeviceFound DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, subscribeId, deviceInfo); // 7. check if callback OnDeviceFound called ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest OnDeviceFound * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceFound * FunctionPoints: DeviceManagerNotifyTest OnDeviceFound * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDeviceFound With testPkgName * 7. check if callback OnDeviceFound called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceFound2, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); DmDeviceInfo deviceInfo; std::string testPkgName = "com.ohos.test1"; // 6. call DeviceManagerNotify OnDeviceFound DeviceManagerNotify::GetInstance().OnDeviceFound(testPkgName, subscribeId, deviceInfo); // 7. check if callback OnDeviceFound called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDeviceFound * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceFound * FunctionPoints: DeviceManagerNotifyTest OnDeviceFound * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDeviceFound With testsubscribeId * 7. check if callback OnDeviceFound called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceFound3, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); DmDeviceInfo deviceInfo; uint16_t testsubscribeId = 1; // 6. call DeviceManagerNotify OnDeviceFound DeviceManagerNotify::GetInstance().OnDeviceFound(pkgName, testsubscribeId, deviceInfo); // 7. check if callback OnDeviceFound called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDeviceFound * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceFound * FunctionPoints: DeviceManagerNotifyTest OnDeviceFound * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDeviceFound With testPkgName * 7. check if callback OnDeviceFound called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceFound4, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); DmDeviceInfo deviceInfo; std::string testPkgName = ""; // 6. call DeviceManagerNotify OnDeviceFound DeviceManagerNotify::GetInstance().OnDeviceFound(testPkgName, subscribeId, deviceInfo); // 7. check if callback OnDeviceFound called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDeviceFound * Function: DeviceManagerNotifyTest * SubFunction: OnDeviceFound * FunctionPoints: DeviceManagerNotifyTest OnDeviceFound * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDeviceFound With testPkgName * 7. check if callback OnDeviceFound called. */ HWTEST_F(DeviceManagerNotifyTest, OnDeviceFound5, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); DmDeviceInfo deviceInfo; std::string testPkgName = ""; DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(testPkgName, subscribeId); // 6. call DeviceManagerNotify OnDeviceFound DeviceManagerNotify::GetInstance().OnDeviceFound(testPkgName, subscribeId, deviceInfo); // 7. check if callback OnDeviceFound called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDiscoverFailed * Function: DeviceManagerNotifyTest * SubFunction: OnDiscoverFailed * FunctionPoints: DeviceManagerNotifyTest OnDiscoverFailed * EnvConditions: OnDiscoverFailed success. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDiscoverFailed * 7. check if callback OnDiscoverFailed called. */ HWTEST_F(DeviceManagerNotifyTest, OnDiscoverFailed1, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); int32_t failedReason = 0; // 6. call DeviceManagerNotify OnDiscoverFailed DeviceManagerNotify::GetInstance().OnDiscoveryFailed(pkgName, subscribeId, failedReason); // 7. check if callback OnDiscoverFailed called ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest OnDiscoverFailed * Function: DeviceManagerNotifyTest * SubFunction: OnDiscoverFailed * FunctionPoints: DeviceManagerNotifyTest OnDiscoverFailed * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDiscoverFailed With testPkgName * 7. check if callback OnDiscoverFailed called. */ HWTEST_F(DeviceManagerNotifyTest, OnDiscoverFailed2, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); std::string testPkgName = "com.ohos.test1"; int32_t failedReason = 0; // 6. call DeviceManagerNotify OnDiscoverFailed DeviceManagerNotify::GetInstance().OnDiscoveryFailed(testPkgName, subscribeId, failedReason); // 7. check if callback OnDiscoverFailed called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDiscoverFailed * Function: DeviceManagerNotifyTest * SubFunction: OnDiscoverFailed * FunctionPoints: DeviceManagerNotifyTest OnDiscoverFailed * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDiscoverFailed With testsubscribeId * 7. check if callback OnDiscoverFailed called. */ HWTEST_F(DeviceManagerNotifyTest, OnDiscoverFailed3, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); int32_t failedReason = 0; uint16_t testsubscribeId = 1; // 6. call DeviceManagerNotify OnDiscoverFailed DeviceManagerNotify::GetInstance().OnDiscoveryFailed(pkgName, testsubscribeId, failedReason); // 7. check if callback OnDiscoverFailed called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDiscoverFailed * Function: DeviceManagerNotifyTest * SubFunction: OnDiscoverFailed * FunctionPoints: DeviceManagerNotifyTest OnDiscoverFailed * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDiscoverFailed With testPkgName * 7. check if callback OnDiscoverFailed called. */ HWTEST_F(DeviceManagerNotifyTest, OnDiscoverFailed4, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); std::string testPkgName = ""; int32_t failedReason = 0; // 6. call DeviceManagerNotify OnDiscoverFailed DeviceManagerNotify::GetInstance().OnDiscoveryFailed(testPkgName, subscribeId, failedReason); // 7. check if callback OnDiscoverFailed called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDiscoverFailed * Function: DeviceManagerNotifyTest * SubFunction: OnDiscoverFailed * FunctionPoints: DeviceManagerNotifyTest OnDiscoverFailed * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDiscoverFailed With testPkgName * 7. check if callback OnDiscoverFailed called. */ HWTEST_F(DeviceManagerNotifyTest, OnDiscoverFailed5, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); std::string testPkgName = ""; DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(testPkgName, subscribeId); int32_t failedReason = 0; // 6. call DeviceManagerNotify OnDiscoverFailed DeviceManagerNotify::GetInstance().OnDiscoveryFailed(testPkgName, subscribeId, failedReason); // 7. check if callback OnDiscoverFailed called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDiscoverySuccess * Function: DeviceManagerNotifyTest * SubFunction: OnDiscoverySuccess * FunctionPoints: DeviceManagerNotifyTest OnDiscoverySuccess * EnvConditions: OnDiscoverySuccess success. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDiscoverySuccess * 7. check if callback OnDiscoverySuccess called. */ HWTEST_F(DeviceManagerNotifyTest, OnDiscoverySuccess1, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnDiscoverySuccess DeviceManagerNotify::GetInstance().OnDiscoverySuccess(pkgName, subscribeId); // 7. check if callback OnDiscoverySuccess called ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest OnDiscoverySuccess * Function: DeviceManagerNotifyTest * SubFunction: OnDiscoverySuccess * FunctionPoints: DeviceManagerNotifyTest OnDiscoverySuccess * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDiscoverySuccess With testPkgName * 7. check if callback OnDiscoverySuccess called. */ HWTEST_F(DeviceManagerNotifyTest, OnDiscoverySuccess2, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); std::string testPkgName = "com.ohos.test1"; // 6. call DeviceManagerNotify OnDiscoverySuccess DeviceManagerNotify::GetInstance().OnDiscoverySuccess(testPkgName, subscribeId); // 7. check if callback OnDiscoverySuccess called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDiscoverySuccess * Function: DeviceManagerNotifyTest * SubFunction: OnDiscoverySuccess * FunctionPoints: DeviceManagerNotifyTest OnDiscoverySuccess * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDiscoverySuccess With testsubscribeId * 7. check if callback OnDiscoverySuccess called. */ HWTEST_F(DeviceManagerNotifyTest, OnDiscoverySuccess3, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); uint16_t testsubscribeId = 1; // 6. call DeviceManagerNotify OnDiscoverySuccess DeviceManagerNotify::GetInstance().OnDiscoverySuccess(pkgName, testsubscribeId); // 7. check if callback OnDiscoverySuccess called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDiscoverySuccess * Function: DeviceManagerNotifyTest * SubFunction: OnDiscoverySuccess * FunctionPoints: DeviceManagerNotifyTest OnDiscoverySuccess * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDiscoverySuccess With testPkgName * 7. check if callback OnDiscoverySuccess called. */ HWTEST_F(DeviceManagerNotifyTest, OnDiscoverySuccess4, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); std::string testPkgName = ""; // 6. call DeviceManagerNotify OnDiscoverySuccess DeviceManagerNotify::GetInstance().OnDiscoverySuccess(testPkgName, subscribeId); // 7. check if callback OnDiscoverySuccess called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnDiscoverySuccess * Function: DeviceManagerNotifyTest * SubFunction: OnDiscoverySuccess * FunctionPoints: DeviceManagerNotifyTest OnDiscoverySuccess * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnDiscoverySuccess With testPkgName * 7. check if callback OnDiscoverySuccess called. */ HWTEST_F(DeviceManagerNotifyTest, OnDiscoverySuccess5, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null uint16_t subscribeId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterDiscoveryCallback(pkgName, subscribeId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().deviceDiscoveryCallbacks_[pkgName][subscribeId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); std::string testPkgName = ""; DeviceManagerNotify::GetInstance().UnRegisterDiscoveryCallback(testPkgName, subscribeId); // 6. call DeviceManagerNotify OnDiscoverySuccess DeviceManagerNotify::GetInstance().OnDiscoverySuccess(testPkgName, subscribeId); // 7. check if callback OnDiscoverySuccess called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnPublishResult * Function: DeviceManagerNotifyTest * SubFunction: OnPublishResult Failed * FunctionPoints: DeviceManagerNotifyTest OnPublishResult * EnvConditions: OnPublishResult. * CaseDescription: 1. set pkgName not null * set callback not null * set publishId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnPublishResult * 7. check if callback OnPublishResult called. */ HWTEST_F(DeviceManagerNotifyTest, OnPublishResult1, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set publishId not null int32_t publishId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); int32_t failedReason = 1; // 6. call DeviceManagerNotify OnPublishResult DeviceManagerNotify::GetInstance().OnPublishResult(pkgName, publishId, failedReason); // 7. check if callback OnPublishResult called ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest OnPublishResult * Function: DeviceManagerNotifyTest * SubFunction: OnPublishResult Failed * FunctionPoints: DeviceManagerNotifyTest OnPublishResult * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set publishId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnPublishResult With testPkgName * 7. check if callback OnPublishResult called. */ HWTEST_F(DeviceManagerNotifyTest, OnPublishResult2, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set publishId not null int32_t publishId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); std::string testPkgName = "com.ohos.test1"; int32_t failedReason = 1; // 6. call DeviceManagerNotify OnPublishResult DeviceManagerNotify::GetInstance().OnPublishResult(testPkgName, publishId, failedReason); // 7. check if callback OnPublishResult called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnPublishResult * Function: DeviceManagerNotifyTest * SubFunction: OnPublishResult Failed * FunctionPoints: DeviceManagerNotifyTest OnPublishResult * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set publishId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnPublishFailed With testpublishId * 7. check if callback OnPublishResult called. */ HWTEST_F(DeviceManagerNotifyTest, OnPublishResult3, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set publishId not null int32_t publishId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); int32_t failedReason = 1; int32_t testpublishId = 1; // 6. call DeviceManagerNotify OnPublishResult DeviceManagerNotify::GetInstance().OnPublishResult(pkgName, testpublishId, failedReason); // 7. check if callback OnPublishResult called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnPublishResult * Function: DeviceManagerNotifyTest * SubFunction: OnPublishResult Failed * FunctionPoints: DeviceManagerNotifyTest OnPublishResult * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set publishId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnPublishResult With testPkgName * 7. check if callback OnPublishResult called. */ HWTEST_F(DeviceManagerNotifyTest, OnPublishFailed4, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set publishId not null int32_t publishId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); std::string testPkgName = ""; int32_t failedReason = 1; // 6. call DeviceManagerNotify OnPublishResult DeviceManagerNotify::GetInstance().OnPublishResult(testPkgName, publishId, failedReason); // 7. check if callback OnPublishResult called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnPublishResult * Function: DeviceManagerNotifyTest * SubFunction: OnPublishResult Failed * FunctionPoints: DeviceManagerNotifyTest OnPublishResult * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set publishId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnPublishResult With testPkgName * 7. check if callback OnPublishResult called. */ HWTEST_F(DeviceManagerNotifyTest, OnPublishFailed5, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set publishId not null int32_t publishId = 2; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); std::string testPkgName = ""; DeviceManagerNotify::GetInstance().UnRegisterPublishCallback(testPkgName, publishId); int32_t failedReason = 1; // 6. call DeviceManagerNotify OnPublishResult DeviceManagerNotify::GetInstance().OnPublishResult(testPkgName, publishId, failedReason); // 7. check if callback OnPublishResult called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnPublishResult * Function: DeviceManagerNotifyTest * SubFunction: OnPublishResult * FunctionPoints: DeviceManagerNotifyTest OnPublishResult * EnvConditions: OnPublishResult success. * CaseDescription: 1. set pkgName not null * set callback not null * set publishId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnPublishResult * 7. check if callback OnPublishResult called. */ HWTEST_F(DeviceManagerNotifyTest, OnPublishSuccess1, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set publishId not null int32_t publishId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnPublishResult DeviceManagerNotify::GetInstance().OnPublishResult(pkgName, publishId, 0); // 7. check if callback OnPublishResult called ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest OnPublishResult * Function: DeviceManagerNotifyTest * SubFunction: OnPublishResult * FunctionPoints: DeviceManagerNotifyTest OnPublishResult * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set publishId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnPublishResult With testPkgName * 7. check if callback OnPublishResult called. */ HWTEST_F(DeviceManagerNotifyTest, OnPublishSuccess2, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set publishId not null int32_t publishId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); std::string testPkgName = "com.ohos.test1"; // 6. call DeviceManagerNotify OnPublishResult DeviceManagerNotify::GetInstance().OnPublishResult(testPkgName, publishId, 0); // 7. check if callback OnPublishResult called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnPublishResult * Function: DeviceManagerNotifyTest * SubFunction: OnPublishResult * FunctionPoints: DeviceManagerNotifyTest OnPublishResult * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set publishId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnPublishResult With testpublishId * 7. check if callback OnPublishResult called. */ HWTEST_F(DeviceManagerNotifyTest, OnPublishSuccess3, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set publishId not null int32_t publishId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); int32_t testpublishId = 1; // 6. call DeviceManagerNotify OnPublishResult DeviceManagerNotify::GetInstance().OnPublishResult(pkgName, testpublishId, 0); // 7. check if callback OnPublishResult called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnPublishResult * Function: DeviceManagerNotifyTest * SubFunction: OnPublishResult Success * FunctionPoints: DeviceManagerNotifyTest OnPublishResult * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set publishId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnPublishResult With testPkgName * 7. check if callback OnPublishResult called. */ HWTEST_F(DeviceManagerNotifyTest, OnPublishSuccess4, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set publishId not null int32_t publishId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); std::string testPkgName = ""; // 6. call DeviceManagerNotify OnPublishResult DeviceManagerNotify::GetInstance().OnPublishResult(testPkgName, publishId, 0); // 7. check if callback OnPublishResult called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnPublishResult * Function: DeviceManagerNotifyTest * SubFunction: OnPublishResult Success * FunctionPoints: DeviceManagerNotifyTest OnPublishResult * EnvConditions: N/A. * CaseDescription: 1. set pkgName not null * set callback not null * set subscribeId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterPublishCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnPublishResult With testPkgName * 7. check if callback OnPublishResult called. */ HWTEST_F(DeviceManagerNotifyTest, OnPublishSuccess5, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set publishId not null int32_t publishId = 0; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDiscoverCallback with parameter DeviceManagerNotify::GetInstance().RegisterPublishCallback(pkgName, publishId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().devicePublishCallbacks_[pkgName][publishId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); std::string testPkgName = ""; DeviceManagerNotify::GetInstance().UnRegisterPublishCallback(testPkgName, publishId); // 6. call DeviceManagerNotify OnPublishResult DeviceManagerNotify::GetInstance().OnPublishResult(testPkgName, publishId, 0); // 7. check if callback OnPublishSuccess called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnAuthResult * Function: OnAuthResult * SubFunction: RegisterAuthenticateCallback * FunctionPoints: DeviceManagerNotifyTest OnAuthResult * EnvConditions: OnAuthResult success. * CaseDescription: 1. set pkgName not null * set Callback not null * set deviceId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnAuthResult * 7. check if callback OnDiscoverySuccess called */ HWTEST_F(DeviceManagerNotifyTest, OnAuthResult1, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnAuthResult std::string token = "111"; uint32_t status = 0; uint32_t reason = 0; DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, deviceId, token, status, reason); // 7. check if callback OnDiscoverySuccess called ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest OnAuthResult * Function: OnAuthResult * SubFunction: RegisterAuthenticateCallback * FunctionPoints: DeviceManagerNotifyTest OnAuthResult * EnvConditions: OnAuthResult success. * CaseDescription: 1. set pkgName not null * set Callback not null * set deviceId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnAuthResult with testPkgName * 7. check if callback OnDiscoverySuccess called */ HWTEST_F(DeviceManagerNotifyTest, OnAuthResult2, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnAuthResult std::string testPkgName = "com.ohos.test1"; std::string token = "111"; uint32_t status = 0; uint32_t reason = 0; DeviceManagerNotify::GetInstance().OnAuthResult(testPkgName, deviceId, token, status, reason); // 7. check if callback OnDiscoverySuccess called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnAuthResult * Function: OnAuthResult * SubFunction: RegisterAuthenticateCallback * FunctionPoints: DeviceManagerNotifyTest OnAuthResult * EnvConditions: OnAuthResult success. * CaseDescription: 1. set pkgName not null * set Callback not null * set deviceId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnAuthResult with testDeviceId * 7. check if callback OnDiscoverySuccess called */ HWTEST_F(DeviceManagerNotifyTest, OnAuthResult3, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnAuthResult std::string testDeviceId = "2"; std::string token = "111"; uint32_t status = 0; uint32_t reason = 0; DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, testDeviceId, token, status, reason); // 7. check if callback OnDiscoverySuccess called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnAuthResult * Function: OnAuthResult * SubFunction: RegisterAuthenticateCallback * FunctionPoints: DeviceManagerNotifyTest OnAuthResult * EnvConditions: OnAuthResult success. * CaseDescription: 1. set pkgName not null * set Callback not null * set deviceId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnAuthResult * 7. check if callback OnDiscoverySuccess called */ HWTEST_F(DeviceManagerNotifyTest, OnAuthResult4, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnAuthResult std::string token = "111"; uint32_t status = 0; uint32_t reason = 0; DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, deviceId, token, status, reason); // 7. check if callback OnDiscoverySuccess called ASSERT_EQ(count, 1); checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; ASSERT_EQ(checkMap, nullptr); } /* * Feature: DeviceManagerNotifyTest OnAuthResult * Function: OnAuthResult * SubFunction: RegisterAuthenticateCallback * FunctionPoints: DeviceManagerNotifyTest OnAuthResult * EnvConditions: OnAuthResult success. * CaseDescription: 1. set pkgName not null * set Callback not null * set deviceId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnAuthResult * 7. check if callback OnDiscoverySuccess called */ HWTEST_F(DeviceManagerNotifyTest, OnAuthResult5, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnAuthResult std::string testPkaName = "com.ohos.test1"; std::string token = "111"; uint32_t status = 0; uint32_t reason = 0; DeviceManagerNotify::GetInstance().OnAuthResult(testPkaName, deviceId, token, status, reason); // 7. check if callback OnDiscoverySuccess called ASSERT_EQ(count, 0); checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; ASSERT_NE(checkMap, nullptr); } /* * Feature: DeviceManagerNotifyTest OnAuthResult * Function: OnAuthResult * SubFunction: RegisterAuthenticateCallback * FunctionPoints: DeviceManagerNotifyTest OnAuthResult * EnvConditions: OnAuthResult success. * CaseDescription: 1. set pkgName not null * set Callback not null * set deviceId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnAuthResult * 7. check if callback OnDiscoverySuccess called */ HWTEST_F(DeviceManagerNotifyTest, OnAuthResult6, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnAuthResult std::string testDeviceId = "2"; std::string token = "111"; uint32_t status = 0; uint32_t reason = 0; DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, testDeviceId, token, status, reason); // 7. check if callback OnDiscoverySuccess called ASSERT_EQ(count, 0); checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; ASSERT_NE(checkMap, nullptr); } /* * Feature: DeviceManagerNotifyTest OnAuthResult * Function: OnAuthResult * SubFunction: RegisterAuthenticateCallback * FunctionPoints: DeviceManagerNotifyTest OnAuthResult * EnvConditions: OnAuthResult success. * CaseDescription: 1. set pkgName not null * set Callback not null * set deviceId not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnAuthResult * 7. check if callback OnDiscoverySuccess called */ HWTEST_F(DeviceManagerNotifyTest, OnAuthResult7, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set callback not null int count = 0; std::shared_ptr callback = std::make_shared(count); // set subscribeId not null std::string deviceId = "1"; // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterAuthenticateCallback with parameter DeviceManagerNotify::GetInstance().RegisterAuthenticateCallback(pkgName, deviceId, callback); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnAuthResult std::string token = "111"; uint32_t status = 0; uint32_t reason = 0; DeviceManagerNotify::GetInstance().OnAuthResult(pkgName, deviceId, token, status, reason); // 7. check if callback OnDiscoverySuccess called ASSERT_EQ(count, 1); checkMap = DeviceManagerNotify::GetInstance().authenticateCallback_[pkgName][deviceId]; ASSERT_EQ(checkMap, nullptr); } /* * Feature: DeviceManagerNotifyTest OnUiCall * Function: DeviceManagerNotifyTest * SubFunction: OnUiCall * FunctionPoints: DeviceManagerNotifyTest OnUiCall * EnvConditions: OnUiCall success. * CaseDescription: 1. set pkgName not null * set dmUiCallback_ not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnUiCall * 7. check if callback OnCheckAuthResult called */ HWTEST_F(DeviceManagerNotifyTest, OnUiCall1, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmUiCallback_ not null int count = 0; std::shared_ptr dmUiCallback_ = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnUiCall std::string paramJson = "trstParamJson"; DeviceManagerNotify::GetInstance().OnUiCall(pkgName, paramJson); // 7. check if callback OnCheckAuthResult called ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest OnUiCall * Function: DeviceManagerNotifyTest * SubFunction: OnUiCall * FunctionPoints: DeviceManagerNotifyTest OnUiCall * EnvConditions: OnUiCall success. * CaseDescription: 1. set pkgName not null * set dmUiCallback_ not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnUiCall with testPkgName * 7. check if callback OnCheckAuthResult called */ HWTEST_F(DeviceManagerNotifyTest, OnUiCall2, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmUiCallback_ not null int count = 0; std::shared_ptr dmUiCallback_ = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnUiCall std::string testPkgName = "com.ohos.test1"; std::string paramJson = "trstParamJson"; DeviceManagerNotify::GetInstance().OnUiCall(testPkgName, paramJson); // 7. check if callback OnCheckAuthResult called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnUiCall * Function: DeviceManagerNotifyTest * SubFunction: OnUiCall * FunctionPoints: DeviceManagerNotifyTest OnUiCall * EnvConditions: OnUiCall success. * CaseDescription: 1. set pkgName not null * set dmUiCallback_ not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnUiCall with testPkgName * 7. check if callback OnCheckAuthResult called */ HWTEST_F(DeviceManagerNotifyTest, OnUiCall3, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmUiCallback_ not null int count = 0; std::shared_ptr dmUiCallback_ = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnUiCall std::string testPkgName = ""; std::string paramJson = "trstParamJson"; DeviceManagerNotify::GetInstance().OnUiCall(testPkgName, paramJson); // 7. check if callback OnCheckAuthResult called ASSERT_EQ(count, 0); } /* * Feature: DeviceManagerNotifyTest OnUiCall * Function: DeviceManagerNotifyTest * SubFunction: OnUiCall * FunctionPoints: DeviceManagerNotifyTest OnUiCall * EnvConditions: OnUiCall success. * CaseDescription: 1. set pkgName not null * set dmUiCallback_ not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnUiCall with testPkgName * 7. check if callback OnCheckAuthResult called */ HWTEST_F(DeviceManagerNotifyTest, OnUiCall4, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = "com.ohos.test"; // set dmUiCallback_ not null int count = 0; std::shared_ptr dmUiCallback_ = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnUiCall std::string testPkgName = "com.ohos.test"; std::string paramJson = "trstParamJson"; DeviceManagerNotify::GetInstance().OnUiCall(testPkgName, paramJson); // 7. check if callback OnCheckAuthResult called ASSERT_EQ(count, 1); } /* * Feature: DeviceManagerNotifyTest OnUiCall * Function: DeviceManagerNotifyTest * SubFunction: OnUiCall * FunctionPoints: DeviceManagerNotifyTest OnUiCall * EnvConditions: OnUiCall success. * CaseDescription: 1. set pkgName not null * set dmUiCallback_ not null * 2. set checkMap null * 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter * 4. Get checkMap from DeviceManagerNotify * 5. check checkMap not null * 6. call DeviceManagerNotify OnUiCall with testPkgName * 7. check if callback OnCheckAuthResult called */ HWTEST_F(DeviceManagerNotifyTest, OnUiCall5, testing::ext::TestSize.Level0) { // 1. set pkgName not null std::string pkgName = ""; // set dmUiCallback_ not null int count = 0; std::shared_ptr dmUiCallback_ = std::make_shared(count); // 2. set checkMap null std::shared_ptr checkMap = nullptr; // 3. call DeviceManagerNotifyTest RegisterDeviceManagerFaCallback with parameter DeviceManagerNotify::GetInstance().RegisterDeviceManagerFaCallback(pkgName, dmUiCallback_); // 4. Get checkMap from DeviceManagerNotify checkMap = DeviceManagerNotify::GetInstance().dmUiCallback_[pkgName]; // 5. check checkMap not null ASSERT_NE(checkMap, nullptr); // 6. call DeviceManagerNotify OnUiCall std::string testPkgName = ""; DeviceManagerNotify::GetInstance().UnRegisterDeviceManagerFaCallback(testPkgName); std::string paramJson = "trstParamJson"; DeviceManagerNotify::GetInstance().OnUiCall(testPkgName, paramJson); // 7. check if callback OnCheckAuthResult called ASSERT_EQ(count, 0); } /** * @tc.name: OnCredentialResult1 * @tc.type: FUNC */ HWTEST_F(DeviceManagerNotifyTest, OnCredentialResult1, testing::ext::TestSize.Level0) { std::string pkgName = ""; int32_t action = 1; std::string credentialResult = "failed"; DeviceManagerNotify::GetInstance().OnCredentialResult(pkgName, action, credentialResult); } /** * @tc.name: OnCredentialResult2 * @tc.type: FUNC */ HWTEST_F(DeviceManagerNotifyTest, OnCredentialResult2, testing::ext::TestSize.Level0) { std::string pkgName = "com.ohos.test"; int32_t action = 1; std::string credentialResult = "failed"; DeviceManagerNotify::GetInstance().OnCredentialResult(pkgName, action, credentialResult); } /** * @tc.name: OnVerifyAuthResult1 * @tc.type: FUNC */ HWTEST_F(DeviceManagerNotifyTest, OnVerifyAuthResult1, testing::ext::TestSize.Level0) { std::string pkgName = ""; std::string deviceId = "123"; int32_t resultCode = 0; int32_t flag = 0; DeviceManagerNotify::GetInstance().OnVerifyAuthResult(pkgName, deviceId, resultCode, flag); } /** * @tc.name: OnVerifyAuthResult2 * @tc.type: FUNC */ HWTEST_F(DeviceManagerNotifyTest, OnVerifyAuthResult2, testing::ext::TestSize.Level0) { std::string pkgName = "com.ohos.test"; std::string deviceId = "123"; int32_t resultCode = 0; int32_t flag = 0; DeviceManagerNotify::GetInstance().OnVerifyAuthResult(pkgName, deviceId, resultCode, flag); } } // namespace DmInitCallbackTest::DmInitCallbackTest(int &count) : DmInitCallback() { count_ = &count; } void DmInitCallbackTest::OnRemoteDied() { *count_ = *count_ + 1; } DeviceStateCallbackTest::DeviceStateCallbackTest(int &count) : DeviceStateCallback() { count_ = &count; } void DeviceStateCallbackTest::OnDeviceOnline(const DmDeviceInfo &deviceInfo) { *count_ = *count_ + 1; } void DeviceStateCallbackTest::OnDeviceReady(const DmDeviceInfo &deviceInfo) { *count_ = *count_ + 1; } void DeviceStateCallbackTest::OnDeviceOffline(const DmDeviceInfo &deviceInfo) { *count_ = *count_ + 1; } void DeviceStateCallbackTest::OnDeviceChanged(const DmDeviceInfo &deviceInfo) { *count_ = *count_ + 1; } DiscoveryCallbackTest::DiscoveryCallbackTest(int &count) : DiscoveryCallback() { count_ = &count; } void DiscoveryCallbackTest::OnDeviceFound(uint16_t subscribeId, const DmDeviceInfo &deviceInfo) { *count_ = *count_ + 1; } void DiscoveryCallbackTest::OnDiscoveryFailed(uint16_t subscribeId, int32_t failedReason) { *count_ = *count_ + 1; } void DiscoveryCallbackTest::OnDiscoverySuccess(uint16_t subscribeId) { *count_ = *count_ + 1; } PublishCallbackTest::PublishCallbackTest(int &count) : PublishCallback() { count_ = &count; } void PublishCallbackTest::OnPublishResult(int32_t publishId, int32_t failedReason) { *count_ = *count_ + 1; } AuthenticateCallbackTest::AuthenticateCallbackTest(int &count) : AuthenticateCallback() { count_ = &count; } void AuthenticateCallbackTest::OnAuthResult(const std::string &deviceId, const std::string &token, int32_t status, int32_t reason) { *count_ = *count_ + 1; } DeviceManagerFaCallbackTest::DeviceManagerFaCallbackTest(int &count) : DeviceManagerUiCallback() { count_ = &count; } void DeviceManagerFaCallbackTest::OnCall(const std::string ¶mJson) { *count_ = *count_ + 1; } } // namespace DistributedHardware } // namespace OHOS