diff --git a/frameworks/ans/test/unittest/notification_action_button_test.cpp b/frameworks/ans/test/unittest/notification_action_button_test.cpp index 5b4a324710d543fe457d208c36b33fc1e5873fe5..5a52e97e9f507f8064d78cfe18bddf3bcc031d36 100644 --- a/frameworks/ans/test/unittest/notification_action_button_test.cpp +++ b/frameworks/ans/test/unittest/notification_action_button_test.cpp @@ -118,8 +118,9 @@ HWTEST_F(NotificationActionButtontTest, Create_00001, Function | SmallTest | Lev std::vector> mimeTypeOnlyInputs; std::shared_ptr userInput; bool isContextual = true; - auto rrc = std::make_shared(); - std::shared_ptr result = rrc->Create + std::shared_ptr notificationActionButton = std::make_shared(); + ASSERT_NE(nullptr, notificationActionButton); + std::shared_ptr result = notificationActionButton->Create (icon, title, wantAgent, extras, semanticActionButton, autoCreatedReplies, mimeTypeOnlyInputs, userInput, isContextual); } diff --git a/frameworks/ans/test/unittest/notification_user_input_test.cpp b/frameworks/ans/test/unittest/notification_user_input_test.cpp index f4cb01f1e4200d58cdc41287b15f0e856b6eb7de..28fcd48011256e4e0d2d7cd23cd52221354fe3bb 100644 --- a/frameworks/ans/test/unittest/notification_user_input_test.cpp +++ b/frameworks/ans/test/unittest/notification_user_input_test.cpp @@ -262,8 +262,9 @@ HWTEST_F(NotificationUserInputTest, Create_00004, Function | SmallTest | Level1) std::shared_ptr additional = nullptr; Notification::NotificationConstant::InputEditType editType = Notification::NotificationConstant::InputEditType::EDIT_ENABLED; - auto rrc = std::make_shared(); - rrc->Create(inputKey, tag, options, permitFreeFormInput, permitMimeTypes, + std::shared_ptr notificationUserInput = std::make_shared(); + ASSERT_NE(nullptr, notificationUserInput); + notificationUserInput->Create(inputKey, tag, options, permitFreeFormInput, permitMimeTypes, additional, editType); } @@ -287,8 +288,9 @@ HWTEST_F(NotificationUserInputTest, Create_00005, Function | SmallTest | Level1) std::shared_ptr additional = nullptr; Notification::NotificationConstant::InputEditType editType = Notification::NotificationConstant::InputEditType::EDIT_DISABLED; - auto rrc = std::make_shared(); - rrc->Create(inputKey, tag, options, permitFreeFormInput, permitMimeTypes, + std::shared_ptr notificationUserInput = std::make_shared(); + ASSERT_NE(nullptr, notificationUserInput); + notificationUserInput->Create(inputKey, tag, options, permitFreeFormInput, permitMimeTypes, additional, editType); } @@ -312,8 +314,9 @@ HWTEST_F(NotificationUserInputTest, Create_00006, Function | SmallTest | Level1) std::shared_ptr additional = std::make_shared(); Notification::NotificationConstant::InputEditType editType = Notification::NotificationConstant::InputEditType::EDIT_DISABLED; - auto rrc = std::make_shared(); - rrc->Create(inputKey, tag, options, permitFreeFormInput, permitMimeTypes, + std::shared_ptr notificationUserInput = std::make_shared(); + ASSERT_NE(nullptr, notificationUserInput); + notificationUserInput->Create(inputKey, tag, options, permitFreeFormInput, permitMimeTypes, additional, editType); } diff --git a/frameworks/ans/test/unittest/reminder_request_test.cpp b/frameworks/ans/test/unittest/reminder_request_test.cpp index 78007dc0abc38ac9aabd2e0bf460cfc966bfa534..ade0864442ef544be82db2cac3311f6579ae589c 100644 --- a/frameworks/ans/test/unittest/reminder_request_test.cpp +++ b/frameworks/ans/test/unittest/reminder_request_test.cpp @@ -1036,11 +1036,12 @@ HWTEST_F(ReminderRequestTest, GetUserId_00001, Function | SmallTest | Level1) */ HWTEST_F(ReminderRequestTest, SetActionButton_00001, Function | SmallTest | Level1) { - auto rrc = std::make_shared(); + std::shared_ptr reminderRequestChild = std::make_shared(); + ASSERT_NE(nullptr, reminderRequestChild); std::string title = "this is title"; Notification::ReminderRequest::ActionButtonType type = Notification::ReminderRequest::ActionButtonType::INVALID; - rrc->SetActionButton(title, type); + reminderRequestChild->SetActionButton(title, type); } /** @@ -1051,11 +1052,12 @@ HWTEST_F(ReminderRequestTest, SetActionButton_00001, Function | SmallTest | Leve */ HWTEST_F(ReminderRequestTest, SetActionButton_00002, Function | SmallTest | Level1) { - auto rrc = std::make_shared(); + std::shared_ptr reminderRequestChild = std::make_shared(); + ASSERT_NE(nullptr, reminderRequestChild); std::string title = "this is title"; Notification::ReminderRequest::ActionButtonType type2 = Notification::ReminderRequest::ActionButtonType::CLOSE; - rrc->SetActionButton(title, type2); + reminderRequestChild->SetActionButton(title, type2); } /** @@ -1066,11 +1068,12 @@ HWTEST_F(ReminderRequestTest, SetActionButton_00002, Function | SmallTest | Leve */ HWTEST_F(ReminderRequestTest, SetActionButton_00003, Function | SmallTest | Level1) { - auto rrc = std::make_shared(); + std::shared_ptr reminderRequestChild = std::make_shared(); + ASSERT_NE(nullptr, reminderRequestChild); std::string title = "this is title"; Notification::ReminderRequest::ActionButtonType type3 = Notification::ReminderRequest::ActionButtonType::SNOOZE; - rrc->SetActionButton(title, type3); + reminderRequestChild->SetActionButton(title, type3); } /** @@ -1081,9 +1084,10 @@ HWTEST_F(ReminderRequestTest, SetActionButton_00003, Function | SmallTest | Leve */ HWTEST_F(ReminderRequestTest, AddActionButtons_00001, Function | SmallTest | Level1) { - auto rrc = std::make_shared(); - rrc->AddActionButtons(true); - rrc->AddActionButtons(false); + std::shared_ptr reminderRequestChild = std::make_shared(); + ASSERT_NE(nullptr, reminderRequestChild); + reminderRequestChild->AddActionButtons(true); + reminderRequestChild->AddActionButtons(false); } /** @@ -1094,21 +1098,22 @@ HWTEST_F(ReminderRequestTest, AddActionButtons_00001, Function | SmallTest | Lev */ HWTEST_F(ReminderRequestTest, InitUserId_00001, Function | SmallTest | Level1) { - auto rrc = std::make_shared(); + std::shared_ptr reminderRequestChild = std::make_shared(); + ASSERT_NE(nullptr, reminderRequestChild); bool deSet = true; uint8_t newState = 2; std::string function = "this is function"; int32_t userId = 1; int32_t uid = 2; - rrc->InitUserId(userId); - rrc->InitUid(uid); - rrc->SetState(deSet, newState, function); - uint8_t result1 = rrc->GetState(); + reminderRequestChild->InitUserId(userId); + reminderRequestChild->InitUid(uid); + reminderRequestChild->SetState(deSet, newState, function); + uint8_t result1 = reminderRequestChild->GetState(); EXPECT_EQ(result1, 2); - bool result = rrc->IsShowing(); + bool result = reminderRequestChild->IsShowing(); EXPECT_EQ(result, false); - rrc->OnShow(true, true, true); - rrc->OnShowFail(); + reminderRequestChild->OnShow(true, true, true); + reminderRequestChild->OnShowFail(); } /** @@ -1119,19 +1124,20 @@ HWTEST_F(ReminderRequestTest, InitUserId_00001, Function | SmallTest | Level1) */ HWTEST_F(ReminderRequestTest, OnStart_00001, Function | SmallTest | Level1) { - auto rrc = std::make_shared(); - rrc->OnStart(); - rrc->OnStop(); + std::shared_ptr reminderRequestChild = std::make_shared(); + ASSERT_NE(nullptr, reminderRequestChild); + reminderRequestChild->OnStart(); + reminderRequestChild->OnStop(); bool deSet = true; uint8_t newState = 2; std::string function = "this is function"; int32_t userId = 1; int32_t uid = 2; - rrc->InitUserId(userId); - rrc->InitUid(uid); - rrc->SetState(deSet, newState, function); - rrc->OnStart(); - rrc->OnStop(); + reminderRequestChild->InitUserId(userId); + reminderRequestChild->InitUid(uid); + reminderRequestChild->SetState(deSet, newState, function); + reminderRequestChild->OnStart(); + reminderRequestChild->OnStop(); } /** @@ -1239,9 +1245,10 @@ HWTEST_F(ReminderRequestTest, UpdateNotificationContent_00002, Function | SmallT HWTEST_F(ReminderRequestTest, CreateWantAgent_00001, Function | SmallTest | Level1) { AppExecFwk::ElementName element; - auto rrc = std::make_shared(); + std::shared_ptr reminderRequestChild = std::make_shared(); + ASSERT_NE(nullptr, reminderRequestChild); std::shared_ptr WantAgent = - rrc->CreateWantAgent(element); + reminderRequestChild->CreateWantAgent(element); } /** diff --git a/services/ans/test/unittest/advanced_notification_service_test.cpp b/services/ans/test/unittest/advanced_notification_service_test.cpp index 377f1bfa0e69f07a56e1c35a978cee899802a6a8..fbcf5ad428e97f082023c3cd2b39a50adae649cf 100644 --- a/services/ans/test/unittest/advanced_notification_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test.cpp @@ -2784,6 +2784,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_18500, GTEST_LOG_(INFO) << "OnBundleRemoved_1000 test start"; sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + ASSERT_NE(nullptr, advancedNotificationService_); advancedNotificationService_->OnBundleRemoved(bundleOption); GTEST_LOG_(INFO) << "OnBundleRemoved_1000 test end"; @@ -2799,6 +2800,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_18600, { GTEST_LOG_(INFO) << "OnScreenOn_1000 test start"; + ASSERT_NE(nullptr, advancedNotificationService_); advancedNotificationService_->OnScreenOn(); advancedNotificationService_->OnScreenOff(); @@ -2965,6 +2967,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_19600, GTEST_LOG_(INFO) << "GetLocalNotificationKeys_0100 test start"; sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + ASSERT_NE(nullptr, advancedNotificationService_); advancedNotificationService_->GetLocalNotificationKeys(bundleOption); GTEST_LOG_(INFO) << "GetLocalNotificationKeys_0100 test end"; @@ -3021,6 +3024,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_19900, std::string bundleName = "BundleName"; sptr request = new NotificationRequest(); + ASSERT_NE(nullptr, advancedNotificationService_); advancedNotificationService_->OnDistributedPublish(deviceId, bundleName, request); GTEST_LOG_(INFO) << "CheckDistributedNotificationType_0100 test end"; @@ -3040,6 +3044,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20000, std::string bundleName = "BundleName"; sptr request = new NotificationRequest(); + ASSERT_NE(nullptr, advancedNotificationService_); advancedNotificationService_->OnDistributedUpdate(deviceId, bundleName, request); GTEST_LOG_(INFO) << "OnDistributedUpdate_0100 test end"; @@ -3060,6 +3065,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20100, std::string label = "testLabel"; int32_t id = 1; + ASSERT_NE(nullptr, advancedNotificationService_); advancedNotificationService_->OnDistributedDelete(deviceId, bundleName, label, id); GTEST_LOG_(INFO) << "OnDistributedDelete_0100 test end"; @@ -3115,6 +3121,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20400, AbilityRuntime::WantAgent::WantAgentHelper::GetWantAgent(paramsInfo); request->SetRemovalWantAgent(wantAgent); + ASSERT_NE(nullptr, advancedNotificationService_); advancedNotificationService_->TriggerRemoveWantAgent(request); GTEST_LOG_(INFO) << "TriggerRemoveWantAgent_0100 test end"; @@ -3151,6 +3158,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20600, GTEST_LOG_(INFO) << "OnResourceRemove_0100 test start"; int32_t userId = -2; + ASSERT_NE(nullptr, advancedNotificationService_); advancedNotificationService_->OnResourceRemove(userId); GTEST_LOG_(INFO) << "OnResourceRemove_0100 test end"; @@ -3167,6 +3175,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20700, GTEST_LOG_(INFO) << "OnBundleDataCleared_0100 test start"; sptr bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + ASSERT_NE(nullptr, advancedNotificationService_); advancedNotificationService_->OnBundleDataCleared(bundleOption); GTEST_LOG_(INFO) << "OnBundleDataCleared_0100 test end"; @@ -3187,6 +3196,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20800, int width = 1; int height = 1; bool wideScreen = 1; + ASSERT_NE(nullptr, advancedNotificationService_); advancedNotificationService_->GetDisplayPosition(offsetX, offsetY, width, height, wideScreen); GTEST_LOG_(INFO) << "GetDisplayPosition_0100 test end"; @@ -3205,6 +3215,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_20900, std::vector args; args.push_back(Str8ToStr16("args")); std::string result = "result"; + ASSERT_NE(nullptr, advancedNotificationService_); advancedNotificationService_->GetDumpInfo(args, result); GTEST_LOG_(INFO) << "GetDumpInfo_0100 test end"; @@ -3223,6 +3234,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_21000, std::vector args; args.push_back(Str8ToStr16("-h")); std::string result = "result"; + ASSERT_NE(nullptr, advancedNotificationService_); advancedNotificationService_->GetDumpInfo(args, result); GTEST_LOG_(INFO) << "GetDumpInfo_0200 test end"; @@ -3239,6 +3251,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_21100, GTEST_LOG_(INFO) << "SendFlowControlOccurHiSysEvent_0100 test start"; std::shared_ptr record = nullptr; + ASSERT_NE(nullptr, advancedNotificationService_); advancedNotificationService_->SendFlowControlOccurHiSysEvent(record); GTEST_LOG_(INFO) << "SendFlowControlOccurHiSysEvent_0100 test end"; @@ -3257,6 +3270,7 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_21200, std::shared_ptr record = std::make_shared(); record->request = new NotificationRequest(); record->bundleOption = new NotificationBundleOption(TEST_DEFUALT_BUNDLE, SYSTEM_APP_UID); + ASSERT_NE(nullptr, advancedNotificationService_); advancedNotificationService_->SendFlowControlOccurHiSysEvent(record); GTEST_LOG_(INFO) << "SendFlowControlOccurHiSysEvent_0200 test end"; diff --git a/services/ans/test/unittest/bundle_manager_helper_branch_test/bundle_manager_helper_branch_test.cpp b/services/ans/test/unittest/bundle_manager_helper_branch_test/bundle_manager_helper_branch_test.cpp index 80dc88c84359481d3bd2bdd085eb34774810dffa..6d94d0df46dae7b9e87fe53c9b5aa116f3b6ec8a 100755 --- a/services/ans/test/unittest/bundle_manager_helper_branch_test/bundle_manager_helper_branch_test.cpp +++ b/services/ans/test/unittest/bundle_manager_helper_branch_test/bundle_manager_helper_branch_test.cpp @@ -139,9 +139,10 @@ HWTEST_F(BundleManagerHelperBranchTest, BundleManagerHelper_00700, Function | Sm */ HWTEST_F(BundleManagerHelperBranchTest, BundleManagerHelper_00800, Function | SmallTest | Level1) { - BundleManagerHelper bundleManagerHelper; + std::shared_ptr bundleManagerHelper = std::make_shared(); + ASSERT_NE(nullptr, bundleManagerHelper); mockGetSystemAbilityManager(true); - bundleManagerHelper.Connect(); + bundleManagerHelper->Connect(); } /** @@ -151,10 +152,11 @@ HWTEST_F(BundleManagerHelperBranchTest, BundleManagerHelper_00800, Function | Sm */ HWTEST_F(BundleManagerHelperBranchTest, BundleManagerHelper_00900, Function | SmallTest | Level1) { - BundleManagerHelper bundleManagerHelper; + std::shared_ptr bundleManagerHelper = std::make_shared(); + ASSERT_NE(nullptr, bundleManagerHelper); mockGetSystemAbilityManager(false); // test Connect and bundleMgr_ == nullptr - bundleManagerHelper.Connect(); + bundleManagerHelper->Connect(); } /** @@ -164,11 +166,12 @@ HWTEST_F(BundleManagerHelperBranchTest, BundleManagerHelper_00900, Function | Sm */ HWTEST_F(BundleManagerHelperBranchTest, BundleManagerHelper_01000, Function | SmallTest | Level1) { - BundleManagerHelper bundleManagerHelper; + std::shared_ptr bundleManagerHelper = std::make_shared(); + ASSERT_NE(nullptr, bundleManagerHelper); mockGetSystemAbilityManager(false); - bundleManagerHelper.Connect(); + bundleManagerHelper->Connect(); // test Connect and bundleMgr_ != nullptr - bundleManagerHelper.Connect(); + bundleManagerHelper->Connect(); } /** @@ -178,10 +181,11 @@ HWTEST_F(BundleManagerHelperBranchTest, BundleManagerHelper_01000, Function | Sm */ HWTEST_F(BundleManagerHelperBranchTest, BundleManagerHelper_01100, Function | SmallTest | Level1) { - BundleManagerHelper bundleManagerHelper; + std::shared_ptr bundleManagerHelper = std::make_shared(); + ASSERT_NE(nullptr, bundleManagerHelper); mockGetSystemAbilityManager(false); - bundleManagerHelper.Connect(); - bundleManagerHelper.Disconnect(); + bundleManagerHelper->Connect(); + bundleManagerHelper->Disconnect(); } /** @@ -191,8 +195,9 @@ HWTEST_F(BundleManagerHelperBranchTest, BundleManagerHelper_01100, Function | Sm */ HWTEST_F(BundleManagerHelperBranchTest, BundleManagerHelper_01200, Function | SmallTest | Level1) { - BundleManagerHelper bundleManagerHelper; - bundleManagerHelper.Disconnect(); + std::shared_ptr bundleManagerHelper = std::make_shared(); + ASSERT_NE(nullptr, bundleManagerHelper); + bundleManagerHelper->Disconnect(); } /** diff --git a/services/ans/test/unittest/notification_preferences_database_branch_test/notification_preferences_database_branch_test.cpp b/services/ans/test/unittest/notification_preferences_database_branch_test/notification_preferences_database_branch_test.cpp index c2c6b336d65d33d531c5872217047d7eb229105e..d89bf439ea163ed5a08da00285f6df7c8b80d4a2 100755 --- a/services/ans/test/unittest/notification_preferences_database_branch_test/notification_preferences_database_branch_test.cpp +++ b/services/ans/test/unittest/notification_preferences_database_branch_test/notification_preferences_database_branch_test.cpp @@ -309,6 +309,7 @@ HWTEST_F(NotificationPreferencesDatabaseBranchTest, NotificationPreferences_0150 MockInit(false); // test GetValueFromDisturbeDB function std::string key = ""; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->GetValueFromDisturbeDB(key, [&](std::string &value) {}); } @@ -325,6 +326,7 @@ HWTEST_F(NotificationPreferencesDatabaseBranchTest, NotificationPreferences_0160 MockQueryData(true); // test GetValueFromDisturbeDB function std::string key = ""; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->GetValueFromDisturbeDB(key, [&](std::string &value) {}); } @@ -339,6 +341,7 @@ HWTEST_F(NotificationPreferencesDatabaseBranchTest, NotificationPreferences_0170 MockInit(false); // test GetValueFromDisturbeDB function std::string key = ""; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->GetValueFromDisturbeDB(key, [&](const int32_t &status, std::string &value) {}); } @@ -353,6 +356,7 @@ HWTEST_F(NotificationPreferencesDatabaseBranchTest, NotificationPreferences_0180 MockInit(false); // test PutBundlePropertyValueToDisturbeDB function NotificationPreferencesInfo::BundleInfo bundleInfo; + ASSERT_NE(nullptr, preferncesDB_); EXPECT_EQ(preferncesDB_->PutBundlePropertyValueToDisturbeDB(bundleInfo), false); } @@ -762,6 +766,7 @@ HWTEST_F(NotificationPreferencesDatabaseBranchTest, NotificationPreferences_0430 MockInit(false); NotificationPreferencesInfo info; std::unordered_map values; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseBundleFromDistureDB(info, values); } @@ -813,6 +818,7 @@ HWTEST_F(NotificationPreferencesDatabaseBranchTest, NotificationPreferences_0470 // test GetDoNotDisturbType function NotificationPreferencesInfo info; int32_t userId = 1; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->GetDoNotDisturbType(info, userId); } @@ -830,6 +836,7 @@ HWTEST_F(NotificationPreferencesDatabaseBranchTest, NotificationPreferences_0480 // test GetDoNotDisturbBeginDate function NotificationPreferencesInfo info; int32_t userId = 1; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->GetDoNotDisturbBeginDate(info, userId); } @@ -847,6 +854,7 @@ HWTEST_F(NotificationPreferencesDatabaseBranchTest, NotificationPreferences_0490 // test GetDoNotDisturbEndDate function NotificationPreferencesInfo info; int32_t userId = 1; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->GetDoNotDisturbEndDate(info, userId); } @@ -864,6 +872,7 @@ HWTEST_F(NotificationPreferencesDatabaseBranchTest, NotificationPreferences_0500 // test GetEnableAllNotification function NotificationPreferencesInfo info; int32_t userId = 1; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->GetEnableAllNotification(info, userId); } diff --git a/services/ans/test/unittest/notification_preferences_database_test.cpp b/services/ans/test/unittest/notification_preferences_database_test.cpp index 28d905c81a5d99fe628cba126cddbfd3ccb5f7b9..38decf77f13a6b45834978e33af6c13ad93e90cd 100644 --- a/services/ans/test/unittest/notification_preferences_database_test.cpp +++ b/services/ans/test/unittest/notification_preferences_database_test.cpp @@ -514,6 +514,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_ std::pair entry; entry.first = "ans_bundle_bundleKey_name"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -530,6 +531,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_ std::pair entry; entry.first = "ans_bundle_bundleKey_importance"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -546,6 +548,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_ std::pair entry; entry.first = "ans_bundle_bundleKey_showBadge"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -562,6 +565,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_ std::pair entry; entry.first = "ans_bundle_bundleKey_badgeTotalNum"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -578,6 +582,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_ std::pair entry; entry.first = "ans_bundle_bundleKey_privateAllowed"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -594,6 +599,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_ std::pair entry; entry.first = "ans_bundle_bundleKey_enabledNotification"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -610,6 +616,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_ std::pair entry; entry.first = "ans_bundle_bundleKey_poppedDialog"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -626,6 +633,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseBundlePropertyFromDisturbeDB_ std::pair entry; entry.first = "ans_bundle_bundleKey_uid"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseBundlePropertyFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -642,6 +650,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00100, Fun std::pair entry; entry.first = "ans_bundle_bundleKey_slot_type_1_id"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -658,6 +667,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00200, Fun std::pair entry; entry.first = "ans_bundle_bundleKey_slot_type_1_name"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -674,6 +684,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00300, Fun std::pair entry; entry.first = "ans_bundle_bundleKey_slot_type_1_description"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -690,6 +701,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00400, Fun std::pair entry; entry.first = "ans_bundle_bundleKey_slot_type_1_level"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -706,6 +718,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00500, Fun std::pair entry; entry.first = "ans_bundle_bundleKey_slot_type_1_showBadge"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -722,6 +735,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00600, Fun std::pair entry; entry.first = "ans_bundle_bundleKey_slot_type_1_enableLight"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -738,6 +752,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00700, Fun std::pair entry; entry.first = "ans_bundle_bundleKey_slot_type_1_enableVibration"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -754,6 +769,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00800, Fun std::pair entry; entry.first = "ans_bundle_bundleKey_slot_type_1_ledLightColor"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -770,6 +786,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_00900, Fun std::pair entry; entry.first = "ans_bundle_bundleKey_slot_type_1_lockscreenVisibleness"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -786,6 +803,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_01000, Fun std::pair entry; entry.first = "ans_bundle_bundleKey_slot_type_1_sound"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -802,6 +820,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_01100, Fun std::pair entry; entry.first = "ans_bundle_bundleKey_slot_type_1_vibrationSytle"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -818,6 +837,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_01200, Fun std::pair entry; entry.first = "ans_bundle_bundleKey_slot_type_1_enableBypassDnd"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry); } @@ -834,6 +854,7 @@ HWTEST_F(NotificationPreferencesDatabaseTest, ParseSlotFromDisturbeDB_01300, Fun std::pair entry; entry.first = "ans_bundle_bundleKey_slot_type_1_enabled"; entry.second = "1"; + ASSERT_NE(nullptr, preferncesDB_); preferncesDB_->ParseSlotFromDisturbeDB(bundleInfo, bundleKey, entry); } diff --git a/services/ans/test/unittest/notification_subscriber_manager_branch_test/notification_subscriber_manager_branch_test.cpp b/services/ans/test/unittest/notification_subscriber_manager_branch_test/notification_subscriber_manager_branch_test.cpp index 064ca5ca549bda779edb14e68f1704bd1b96c399..2411e4f295bd15794c3415f788d7496078847933 100755 --- a/services/ans/test/unittest/notification_subscriber_manager_branch_test/notification_subscriber_manager_branch_test.cpp +++ b/services/ans/test/unittest/notification_subscriber_manager_branch_test/notification_subscriber_manager_branch_test.cpp @@ -51,11 +51,13 @@ public: */ HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00100, Function | SmallTest | Level1) { - NotificationSubscriberManager notificationSubscriberManager; + std::shared_ptr notificationSubscriberManager = + std::make_shared(); + ASSERT_NE(nullptr, notificationSubscriberManager); sptr notification = nullptr; sptr notificationMap = nullptr; - notificationSubscriberManager.handler_ = nullptr; - notificationSubscriberManager.NotifyConsumed(notification, notificationMap); + notificationSubscriberManager->handler_ = nullptr; + notificationSubscriberManager->NotifyConsumed(notification, notificationMap); } /** @@ -65,12 +67,14 @@ HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_ */ HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00200, Function | SmallTest | Level1) { - NotificationSubscriberManager notificationSubscriberManager; + std::shared_ptr notificationSubscriberManager = + std::make_shared(); + ASSERT_NE(nullptr, notificationSubscriberManager); sptr notification = nullptr; sptr notificationMap = nullptr; int32_t deleteReason = 1; - notificationSubscriberManager.handler_ = nullptr; - notificationSubscriberManager.NotifyCanceled(notification, notificationMap, deleteReason); + notificationSubscriberManager->handler_ = nullptr; + notificationSubscriberManager->NotifyCanceled(notification, notificationMap, deleteReason); } /** @@ -80,10 +84,12 @@ HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_ */ HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00300, Function | SmallTest | Level1) { - NotificationSubscriberManager notificationSubscriberManager; + std::shared_ptr notificationSubscriberManager = + std::make_shared(); + ASSERT_NE(nullptr, notificationSubscriberManager); sptr notificationMap = nullptr; - notificationSubscriberManager.handler_ = nullptr; - notificationSubscriberManager.NotifyUpdated(notificationMap); + notificationSubscriberManager->handler_ = nullptr; + notificationSubscriberManager->NotifyUpdated(notificationMap); } /** @@ -93,10 +99,12 @@ HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_ */ HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00400, Function | SmallTest | Level1) { - NotificationSubscriberManager notificationSubscriberManager; + std::shared_ptr notificationSubscriberManager = + std::make_shared(); + ASSERT_NE(nullptr, notificationSubscriberManager); sptr date = nullptr; - notificationSubscriberManager.handler_ = nullptr; - notificationSubscriberManager.NotifyDoNotDisturbDateChanged(date); + notificationSubscriberManager->handler_ = nullptr; + notificationSubscriberManager->NotifyDoNotDisturbDateChanged(date); } /** @@ -106,10 +114,12 @@ HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_ */ HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00500, Function | SmallTest | Level1) { - NotificationSubscriberManager notificationSubscriberManager; + std::shared_ptr notificationSubscriberManager = + std::make_shared(); + ASSERT_NE(nullptr, notificationSubscriberManager); sptr callbackData = nullptr; - notificationSubscriberManager.handler_ = nullptr; - notificationSubscriberManager.NotifyEnabledNotificationChanged(callbackData); + notificationSubscriberManager->handler_ = nullptr; + notificationSubscriberManager->NotifyEnabledNotificationChanged(callbackData); } /** @@ -119,9 +129,11 @@ HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_ */ HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00600, Function | SmallTest | Level1) { - NotificationSubscriberManager notificationSubscriberManager; + std::shared_ptr notificationSubscriberManager = + std::make_shared(); + ASSERT_NE(nullptr, notificationSubscriberManager); wptr object = nullptr; - notificationSubscriberManager.OnRemoteDied(object); + notificationSubscriberManager->OnRemoteDied(object); } /** @@ -131,11 +143,13 @@ HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_ */ HWTEST_F(NotificationSubscriberManagerBranchTest, NotificationSubscriberManager_00700, Function | SmallTest | Level1) { - NotificationSubscriberManager notificationSubscriberManager; + std::shared_ptr notificationSubscriberManager = + std::make_shared(); + ASSERT_NE(nullptr, notificationSubscriberManager); std::shared_ptr record = - notificationSubscriberManager.CreateSubscriberRecord(nullptr); + notificationSubscriberManager->CreateSubscriberRecord(nullptr); sptr subscribeInfo = nullptr; - notificationSubscriberManager.AddRecordInfo(record, subscribeInfo); + notificationSubscriberManager->AddRecordInfo(record, subscribeInfo); } /** diff --git a/services/distributed/test/unittest/BUILD.gn b/services/distributed/test/unittest/BUILD.gn index e197b11353f94e0518904e3d1182ab3ff95482f2..8b6af8e1288ada33c23cbd92be30b0c634bf3e46 100644 --- a/services/distributed/test/unittest/BUILD.gn +++ b/services/distributed/test/unittest/BUILD.gn @@ -428,6 +428,7 @@ ohos_unittest("distributed_notification_manager_branch_test") { "ability_base:zuri", "bundle_framework:appexecfwk_base", "c_utils:utils", + "device_manager:devicemanagersdk", "eventhandler:libeventhandler", "hitrace_native:hitrace_meter", "hitrace_native:libhitracechain", diff --git a/services/distributed/test/unittest/distributed_database_callback_test.cpp b/services/distributed/test/unittest/distributed_database_callback_test.cpp index cedce847a35090a1cfff221244821f79af907585..3d551d351300058f612dacbbb12035b822b09809 100755 --- a/services/distributed/test/unittest/distributed_database_callback_test.cpp +++ b/services/distributed/test/unittest/distributed_database_callback_test.cpp @@ -75,6 +75,7 @@ HWTEST_F(DistributedDatabaseCallbackTest, DistributedDatabaseCallback_00100, Fun }; std::shared_ptr databaseCallback_ = std::make_shared(databaseCallback); + ASSERT_NE(nullptr, databaseCallback_); databaseCallback_->callback_.OnInsert = nullptr; std::vector insertEntries; std::vector updateEntries; @@ -110,6 +111,7 @@ HWTEST_F(DistributedDatabaseCallbackTest, DistributedDatabaseCallback_00200, Fun }; std::shared_ptr databaseCallback_ = std::make_shared(databaseCallback); + ASSERT_NE(nullptr, databaseCallback_); databaseCallback_->callback_.OnUpdate = nullptr; std::vector insertEntries; std::vector updateEntries; @@ -145,6 +147,7 @@ HWTEST_F(DistributedDatabaseCallbackTest, DistributedDatabaseCallback_00300, Fun }; std::shared_ptr databaseCallback_ = std::make_shared(databaseCallback); + ASSERT_NE(nullptr, databaseCallback_); databaseCallback_->callback_.OnDelete = nullptr; std::vector insertEntries; std::vector updateEntries; diff --git a/services/distributed/test/unittest/distributed_notification_manager_branch_test/distributed_notification_manager_branch_test.cpp b/services/distributed/test/unittest/distributed_notification_manager_branch_test/distributed_notification_manager_branch_test.cpp index c61e2ae5b108a02d9d245f8210917d909563928a..9647c57bf569b4bf096cba3f1b723876e801f9e7 100755 --- a/services/distributed/test/unittest/distributed_notification_manager_branch_test/distributed_notification_manager_branch_test.cpp +++ b/services/distributed/test/unittest/distributed_notification_manager_branch_test/distributed_notification_manager_branch_test.cpp @@ -63,6 +63,7 @@ void DistributedNotificationManagerBranchTest::TearDown() */ HWTEST_F(DistributedNotificationManagerBranchTest, DistributedNotificationManager_0100, Function | SmallTest | Level1) { + ASSERT_NE(nullptr, distributedManager_); distributedManager_->database_ = nullptr; distributedManager_->OnDeviceConnected("test"); } @@ -74,6 +75,7 @@ HWTEST_F(DistributedNotificationManagerBranchTest, DistributedNotificationManage */ HWTEST_F(DistributedNotificationManagerBranchTest, DistributedNotificationManager_00200, Function | SmallTest | Level1) { + ASSERT_NE(nullptr, distributedManager_); mockOnDeviceConnected(false); distributedManager_->OnDeviceConnected("test"); } @@ -85,6 +87,7 @@ HWTEST_F(DistributedNotificationManagerBranchTest, DistributedNotificationManage */ HWTEST_F(DistributedNotificationManagerBranchTest, DistributedNotificationManager_00300, Function | SmallTest | Level1) { + ASSERT_NE(nullptr, distributedManager_); mockGetEntriesFromDistributedDB(false); distributedManager_->OnDeviceDisconnected("test"); } @@ -96,6 +99,7 @@ HWTEST_F(DistributedNotificationManagerBranchTest, DistributedNotificationManage */ HWTEST_F(DistributedNotificationManagerBranchTest, DistributedNotificationManager_00400, Function | SmallTest | Level1) { + ASSERT_NE(nullptr, distributedManager_); mockGetEntriesFromDistributedDB(true); distributedManager_->OnDeviceDisconnected("test"); } diff --git a/services/distributed/test/unittest/distributed_preferences_branch_test/distributed_preferences_branch_test.cpp b/services/distributed/test/unittest/distributed_preferences_branch_test/distributed_preferences_branch_test.cpp index 99e2eb23807f113384f52f41d3a872fd9adbf593..d4be3acc95cca9730ed9ea9d3c377d7160af2196 100755 --- a/services/distributed/test/unittest/distributed_preferences_branch_test/distributed_preferences_branch_test.cpp +++ b/services/distributed/test/unittest/distributed_preferences_branch_test/distributed_preferences_branch_test.cpp @@ -112,6 +112,7 @@ HWTEST_F(DistributedPreferencesBranchTest, DistributedPreferencesBranchTest_0050 { sptr bundleOption = nullptr; std::string key = "DistributedPreferencesBranchTest"; + ASSERT_NE(nullptr, distributedPreferences_); distributedPreferences_->GetDistributedBundleKey(bundleOption, key); } diff --git a/services/distributed/test/unittest/distributed_preferences_database_test/distributed_preferences_database_test.cpp b/services/distributed/test/unittest/distributed_preferences_database_test/distributed_preferences_database_test.cpp index dac6f71e6954399889c22db784ca39060d00bdc5..2350782994956f1729cca92f9b703bbc98f0aac5 100755 --- a/services/distributed/test/unittest/distributed_preferences_database_test/distributed_preferences_database_test.cpp +++ b/services/distributed/test/unittest/distributed_preferences_database_test/distributed_preferences_database_test.cpp @@ -62,8 +62,10 @@ HWTEST_F(DistributedPreferencesDatabaseTest, DistributedPreferencesDatabase_0010 */ HWTEST_F(DistributedPreferencesDatabaseTest, DistributedPreferencesDatabase_00200, Function | SmallTest | Level1) { - DistributedPreferencesDatabase distributedPreferencesDatabase; - distributedPreferencesDatabase.GetKvStore(); + std::shared_ptr distributedPreferencesDatabase = + std::make_shared(); + ASSERT_NE(nullptr, distributedPreferencesDatabase); + distributedPreferencesDatabase->GetKvStore(); } /** diff --git a/services/distributed/test/unittest/distributed_screen_status_manager_branch_test/distributed_screen_status_manager_branch_test.cpp b/services/distributed/test/unittest/distributed_screen_status_manager_branch_test/distributed_screen_status_manager_branch_test.cpp index 44df0cb7e01c7fa70f404e707372264e92bab040..96c93f44e528062c4e952c384ad259f9e8a7ca81 100755 --- a/services/distributed/test/unittest/distributed_screen_status_manager_branch_test/distributed_screen_status_manager_branch_test.cpp +++ b/services/distributed/test/unittest/distributed_screen_status_manager_branch_test/distributed_screen_status_manager_branch_test.cpp @@ -65,11 +65,13 @@ HWTEST_F(DistributedScreenStatusManagerBranchTest, DistributedScreen_0100, Funct */ HWTEST_F(DistributedScreenStatusManagerBranchTest, DistributedScreen_0200, Function | SmallTest | Level1) { - DistributedScreenStatusManager distributedScreenStatusManager; + std::shared_ptr distributedScreenStatusManager = + std::make_shared(); + ASSERT_NE(nullptr, distributedScreenStatusManager); mockGetDeviceList(false); mockStartWatchDeviceChange(true); std::string deviceId = "aa"; - distributedScreenStatusManager.OnDeviceDisconnected(deviceId); + distributedScreenStatusManager->OnDeviceDisconnected(deviceId); } /** @@ -79,11 +81,13 @@ HWTEST_F(DistributedScreenStatusManagerBranchTest, DistributedScreen_0200, Funct */ HWTEST_F(DistributedScreenStatusManagerBranchTest, DistributedScreen_0300, Function | SmallTest | Level1) { - DistributedScreenStatusManager distributedScreenStatusManager; + std::shared_ptr distributedScreenStatusManager = + std::make_shared(); + ASSERT_NE(nullptr, distributedScreenStatusManager); mockGetDeviceList(true); mockStartWatchDeviceChange(true); std::string deviceId = "aa"; - distributedScreenStatusManager.OnDeviceDisconnected(deviceId); + distributedScreenStatusManager->OnDeviceDisconnected(deviceId); } /** @@ -118,12 +122,14 @@ HWTEST_F(DistributedScreenStatusManagerBranchTest, DistributedScreen_0500, Funct */ HWTEST_F(DistributedScreenStatusManagerBranchTest, DistributedScreen_0600, Function | SmallTest | Level1) { - DistributedScreenStatusManager distributedScreenStatusManager; + std::shared_ptr distributedScreenStatusManager = + std::make_shared(); + ASSERT_NE(nullptr, distributedScreenStatusManager); mockGetDeviceList(true); mockStartWatchDeviceChange(true); - distributedScreenStatusManager.kvStore_ = nullptr; + distributedScreenStatusManager->kvStore_ = nullptr; std::string deviceId = "aa"; - distributedScreenStatusManager.OnDeviceDisconnected(deviceId); + distributedScreenStatusManager->OnDeviceDisconnected(deviceId); } /** @@ -133,9 +139,11 @@ HWTEST_F(DistributedScreenStatusManagerBranchTest, DistributedScreen_0600, Funct */ HWTEST_F(DistributedScreenStatusManagerBranchTest, DistributedScreen_0700, Function | SmallTest | Level1) { - DistributedScreenStatusManager distributedScreenStatusManager; + std::shared_ptr distributedScreenStatusManager = + std::make_shared(); + ASSERT_NE(nullptr, distributedScreenStatusManager); mockStartWatchDeviceChange(false); - distributedScreenStatusManager.GetKvDataManager(); + distributedScreenStatusManager->GetKvDataManager(); } /** @@ -145,9 +153,11 @@ HWTEST_F(DistributedScreenStatusManagerBranchTest, DistributedScreen_0700, Funct */ HWTEST_F(DistributedScreenStatusManagerBranchTest, DistributedScreen_0800, Function | SmallTest | Level1) { - DistributedScreenStatusManager distributedScreenStatusManager; + std::shared_ptr distributedScreenStatusManager = + std::make_shared(); + ASSERT_NE(nullptr, distributedScreenStatusManager); mockStartWatchDeviceChange(false); - distributedScreenStatusManager.GetKvStore(); + distributedScreenStatusManager->GetKvStore(); } /** @@ -157,9 +167,11 @@ HWTEST_F(DistributedScreenStatusManagerBranchTest, DistributedScreen_0800, Funct */ HWTEST_F(DistributedScreenStatusManagerBranchTest, DistributedScreen_0900, Function | SmallTest | Level1) { - DistributedScreenStatusManager distributedScreenStatusManager; + std::shared_ptr distributedScreenStatusManager = + std::make_shared(); + ASSERT_NE(nullptr, distributedScreenStatusManager); mockStartWatchDeviceChange(true); - distributedScreenStatusManager.GetKvStore(); + distributedScreenStatusManager->GetKvStore(); } /** @@ -169,11 +181,13 @@ HWTEST_F(DistributedScreenStatusManagerBranchTest, DistributedScreen_0900, Funct */ HWTEST_F(DistributedScreenStatusManagerBranchTest, DistributedScreen_1000, Function | SmallTest | Level1) { - DistributedScreenStatusManager distributedScreenStatusManager; - distributedScreenStatusManager.kvDataManager_ = nullptr; + std::shared_ptr distributedScreenStatusManager = + std::make_shared(); + ASSERT_NE(nullptr, distributedScreenStatusManager); + distributedScreenStatusManager->kvDataManager_ = nullptr; mockStartWatchDeviceChange(false); std::string deviceId = "aa"; - distributedScreenStatusManager.OnDeviceDisconnected(deviceId); + distributedScreenStatusManager->OnDeviceDisconnected(deviceId); } /** diff --git a/services/test/moduletest/ans_module_test.cpp b/services/test/moduletest/ans_module_test.cpp index 83f22b39296c5b80d06f7cd8b401f4ce5e8c8feb..1521328ed7e65d18af696e189f4ee407b1ca8afd 100644 --- a/services/test/moduletest/ans_module_test.cpp +++ b/services/test/moduletest/ans_module_test.cpp @@ -1090,7 +1090,8 @@ HWTEST_F(AnsModuleTest, AnsModuleTest_0049, Function | SmallTest | Level1) slots.push_back(reminderSlot); slots.push_back(contentSlot); slots.push_back(otherSlot); - + + ASSERT_NE(nullptr, g_advancedNotificationService); g_advancedNotificationService->AddSlots(slots); }