From 02a11e9434adca5316c0302c5d8aefe5c1b5e339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=88=E7=9A=93=E6=9D=B0?= Date: Fri, 6 Sep 2024 14:12:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?ut=E6=96=AD=E8=A8=80=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 师皓杰 --- .../continuation_manager_test.cpp | 211 ++++-------------- ...stributed_ability_manager_service_test.cpp | 2 +- .../unittest/bundle_manager_internal_test.cpp | 16 +- .../distributedWant/distributed_want_test.cpp | 44 +--- .../distributed_sched_connect_test.cpp | 67 ++---- .../distributed_sched_continuation_test.cpp | 60 ++--- .../distributed_sched_permission_test.cpp | 9 +- .../distributed_sched_service_first_test.cpp | 24 +- .../distributed_sched_service_second_test.cpp | 28 +-- .../unittest/distributed_sched_stub_test.cpp | 7 - .../unittest/distributed_sched_test_util.cpp | 6 +- .../mission/dms_mission_manager_test.cpp | 88 ++------ .../softbus_transport_test.cpp | 15 +- 13 files changed, 132 insertions(+), 445 deletions(-) diff --git a/services/dtbabilitymgr/test/unittest/continuation_manager/continuation_manager_test.cpp b/services/dtbabilitymgr/test/unittest/continuation_manager/continuation_manager_test.cpp index f991f3b0..58fa9055 100644 --- a/services/dtbabilitymgr/test/unittest/continuation_manager/continuation_manager_test.cpp +++ b/services/dtbabilitymgr/test/unittest/continuation_manager/continuation_manager_test.cpp @@ -265,10 +265,7 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_003, TestS HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_004, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest RegisterDeviceSelectionCallbackTest_004 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); int32_t token = -1; int32_t result1 = dtbabilitymgrService_->Register(nullptr, token); DTEST_LOG << "result1:" << result1 << std::endl; @@ -303,10 +300,7 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_004, TestS HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_005, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest RegisterDeviceSelectionCallbackTest_005 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); int32_t token = -1; int32_t result1 = dtbabilitymgrService_->Register(nullptr, token); DTEST_LOG << "result1:" << result1 << std::endl; @@ -341,10 +335,7 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_005, TestS HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_006, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest RegisterDeviceSelectionCallbackTest_006 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); int32_t token = -1; int32_t result1 = dtbabilitymgrService_->Register(nullptr, token); DTEST_LOG << "result1:" << result1 << std::endl; @@ -379,10 +370,7 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_006, TestS HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_007, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest RegisterDeviceSelectionCallbackTest_007 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); int32_t token = -1; int32_t result1 = dtbabilitymgrService_->Register(nullptr, token); DTEST_LOG << "result1:" << result1 << std::endl; @@ -417,10 +405,7 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_007, TestS HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_008, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest RegisterDeviceSelectionCallbackTest_008 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); int32_t token = -1; int32_t result1 = dtbabilitymgrService_->Register(nullptr, token); DTEST_LOG << "result1:" << result1 << std::endl; @@ -453,10 +438,7 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_008, TestS HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_009, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest RegisterDeviceSelectionCallbackTest_009 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); sptr notifier(new DeviceSelectionNotifierTest()); int32_t result1 = dtbabilitymgrService_->RegisterDeviceSelectionCallback( UNREGISTER_TOKEN, CALLBACK_TYPE1, notifier); @@ -495,10 +477,7 @@ HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_009, TestS HWTEST_F(ContinuationManagerTest, RegisterDeviceSelectionCallbackTest_010, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest RegisterDeviceSelectionCallbackTest_010 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); std::vector continuationResults; ContinuationResult continuationResult1; continuationResult1.SetDeviceId(SELECTED_DEVICE_ID1); @@ -641,10 +620,7 @@ HWTEST_F(ContinuationManagerTest, UnregisterDeviceSelectionCallbackTest_005, Tes HWTEST_F(ContinuationManagerTest, StartDeviceManagerTest_001, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest StartDeviceManagerTest_001 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); int32_t token = -1; int32_t result1 = dtbabilitymgrService_->Register(nullptr, token); DTEST_LOG << "result1:" << result1 << std::endl; @@ -663,10 +639,7 @@ HWTEST_F(ContinuationManagerTest, StartDeviceManagerTest_001, TestSize.Level1) HWTEST_F(ContinuationManagerTest, StartDeviceManagerTest_002, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest StartDeviceManagerTest_002 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); int32_t token = -1; int32_t result1 = dtbabilitymgrService_->Register(nullptr, token); DTEST_LOG << "result1:" << result1 << std::endl; @@ -813,10 +786,7 @@ HWTEST_F(ContinuationManagerTest, UpdateConnectStatusTest_005, TestSize.Level1) HWTEST_F(ContinuationManagerTest, IsExceededRegisterMaxNumTest_001, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest IsExceededRegisterMaxNumTest_001 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); std::vector tokenVec; tokenVec.emplace_back(TEST_TOKEN); uint32_t accessToken = TEST_ACCESS_TOKEN; @@ -835,10 +805,7 @@ HWTEST_F(ContinuationManagerTest, IsExceededRegisterMaxNumTest_001, TestSize.Lev HWTEST_F(ContinuationManagerTest, IsContinuationModeValidTest_001, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest IsContinuationModeValidTest_001 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); ContinuationMode continuationMode = static_cast(ERROR_CONTINUATION_MODE); bool result = dtbabilitymgrService_->IsContinuationModeValid(continuationMode); DTEST_LOG << "result:" << result << std::endl; @@ -854,10 +821,7 @@ HWTEST_F(ContinuationManagerTest, IsContinuationModeValidTest_001, TestSize.Leve HWTEST_F(ContinuationManagerTest, IsContinuationModeValidTest_002, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest IsContinuationModeValidTest_002 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); ContinuationMode continuationMode = ContinuationMode::COLLABORATION_MUTIPLE; bool result = dtbabilitymgrService_->IsContinuationModeValid(continuationMode); DTEST_LOG << "result:" << result << std::endl; @@ -873,10 +837,7 @@ HWTEST_F(ContinuationManagerTest, IsContinuationModeValidTest_002, TestSize.Leve HWTEST_F(ContinuationManagerTest, IsConnectStatusValidTest_001, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest IsConnectStatusValidTest_001 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); DeviceConnectStatus deviceConnectStatus = static_cast(ERROR_CONNECT_STATUS); bool result = dtbabilitymgrService_->IsConnectStatusValid(deviceConnectStatus); DTEST_LOG << "result:" << result << std::endl; @@ -892,10 +853,7 @@ HWTEST_F(ContinuationManagerTest, IsConnectStatusValidTest_001, TestSize.Level1) HWTEST_F(ContinuationManagerTest, IsConnectStatusValidTest_002, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest IsConnectStatusValidTest_002 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); DeviceConnectStatus deviceConnectStatus = DeviceConnectStatus::CONNECTING; bool result = dtbabilitymgrService_->IsConnectStatusValid(deviceConnectStatus); DTEST_LOG << "result:" << result << std::endl; @@ -911,10 +869,7 @@ HWTEST_F(ContinuationManagerTest, IsConnectStatusValidTest_002, TestSize.Level1) HWTEST_F(ContinuationManagerTest, IsTokenRegisteredTest_001, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest IsTokenRegisteredTest_002 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); std::vector tokenVec; uint32_t accessToken = TEST_ACCESS_TOKEN; dtbabilitymgrService_->tokenMap_[accessToken] = tokenVec; @@ -932,10 +887,7 @@ HWTEST_F(ContinuationManagerTest, IsTokenRegisteredTest_001, TestSize.Level1) HWTEST_F(ContinuationManagerTest, IsTokenRegisteredTest_002, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest IsTokenRegisteredTest_002 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); std::vector tokenVec; tokenVec.emplace_back(TEST_TOKEN); uint32_t accessToken = TEST_ACCESS_TOKEN; @@ -954,10 +906,7 @@ HWTEST_F(ContinuationManagerTest, IsTokenRegisteredTest_002, TestSize.Level1) HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredTest_001, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest IsNotifierRegisteredTest_001 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); bool result = dtbabilitymgrService_->IsNotifierRegistered(TEST_TOKEN); DTEST_LOG << "result:" << result << std::endl; EXPECT_EQ(false, result); @@ -972,10 +921,7 @@ HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredTest_001, TestSize.Level1) HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_002, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest IsNotifierRegisteredLockedTest_002 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); bool result = dtbabilitymgrService_->IsNotifierRegisteredLocked(TEST_TOKEN, CALLBACK_TYPE1); DTEST_LOG << "result:" << result << std::endl; EXPECT_EQ(false, result); @@ -990,10 +936,7 @@ HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_002, TestSize.L HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_003, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest IsNotifierRegisteredLockedTest_003 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); bool result = dtbabilitymgrService_->IsNotifierRegisteredLocked(TEST_TOKEN, INVALID_CALLBACK_TYPE); DTEST_LOG << "result:" << result << std::endl; EXPECT_EQ(false, result); @@ -1008,10 +951,7 @@ HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_003, TestSize.L HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredTest_004, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest IsNotifierRegisteredTest_004 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); std::unique_ptr notifierInfo = std::make_unique(); sptr notifier(new DeviceSelectionNotifierTest()); notifierInfo->SetNotifier(CALLBACK_TYPE1, notifier); @@ -1030,10 +970,7 @@ HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredTest_004, TestSize.Level1) HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_005, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest IsNotifierRegisteredLockedTest_005 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); std::unique_ptr notifierInfo = std::make_unique(); sptr notifier(new DeviceSelectionNotifierTest()); notifierInfo->SetNotifier(CALLBACK_TYPE1, notifier); @@ -1052,10 +989,7 @@ HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_005, TestSize.L HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_006, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest IsNotifierRegisteredLockedTest_006 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); std::unique_ptr notifierInfo = std::make_unique(); sptr notifier(new DeviceSelectionNotifierTest()); notifierInfo->SetNotifier(CALLBACK_TYPE1, notifier); @@ -1075,10 +1009,7 @@ HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_006, TestSize.L HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_007, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest IsNotifierRegisteredLockedTest_007 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); std::unique_ptr notifierInfo = std::make_unique(); sptr notifier(new DeviceSelectionNotifierTest()); notifierInfo->SetNotifier(CALLBACK_TYPE1, notifier); @@ -1097,10 +1028,7 @@ HWTEST_F(ContinuationManagerTest, IsNotifierRegisteredLockedTest_007, TestSize.L HWTEST_F(ContinuationManagerTest, QueryTokenByNotifier_001, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest QueryTokenByNotifier_001 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); std::unique_ptr notifierInfo = std::make_unique(); sptr notifier(new DeviceSelectionNotifierTest()); notifierInfo->SetNotifier(CALLBACK_TYPE1, notifier); @@ -1120,10 +1048,7 @@ HWTEST_F(ContinuationManagerTest, QueryTokenByNotifier_001, TestSize.Level1) HWTEST_F(ContinuationManagerTest, QueryTokenByNotifier_002, TestSize.Level1) { DTEST_LOG << "ContinuationManagerTest QueryTokenByNotifier_002 start" << std::endl; - if (dtbabilitymgrService_ == nullptr) { - DTEST_LOG << "dtbabilitymgrService_ is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dtbabilitymgrService_); std::unique_ptr notifierInfo = std::make_unique(); sptr notifier(new DeviceSelectionNotifierTest()); notifierInfo->SetNotifier(CALLBACK_TYPE1, notifier); @@ -1179,17 +1104,11 @@ HWTEST_F(ContinuationManagerTest, MarshallingUnmarshalling_001, TestSize.Level3) Parcel parcel; bool result1 = continuationResult1.Marshalling(parcel); - if (!result1) { - DTEST_LOG << " Marshalling failed" << std::endl; - return; - } + ASSERT_NE(false, result1); DTEST_LOG << "result1:" << result1 << endl; sptr continuationResult2 = continuationResult1.Unmarshalling(parcel); - if (continuationResult2 == nullptr) { - DTEST_LOG << "continuationResult is nullptr" << endl; - return; - } + ASSERT_NE(nullptr, continuationResult2); string deviceId1 = continuationResult2->GetDeviceId(); string deviceType1 = continuationResult2->GetDeviceType(); @@ -1218,15 +1137,9 @@ HWTEST_F(ContinuationManagerTest, ReadFromParcel_001, TestSize.Level3) Parcel parcel; bool result1 = continuationResult.Marshalling(parcel); - if (!result1) { - DTEST_LOG << "Marshalling failed" << std::endl; - return; - } + ASSERT_NE(false, result1); bool result2 = continuationResult.ReadFromParcel(parcel); - if (!result2) { - DTEST_LOG << "ReadFromParcel failed" << std::endl; - return; - } + ASSERT_NE(false, result2); string deviceId1 = continuationResult.GetDeviceId(); string deviceType1 = continuationResult.GetDeviceType(); @@ -1265,22 +1178,13 @@ HWTEST_F(ContinuationManagerTest, Write_Read_ContinuationResultsFromParcel_001, Parcel parcel; std::vector continuationResults2; bool result1 = ContinuationResult::WriteContinuationResultsToParcel(parcel, continuationResults1); - if (!result1) { - DTEST_LOG << "WriteContinuationResultsToParcel failed" << std::endl; - return; - } + ASSERT_NE(false, result1); bool result2 = ContinuationResult::ReadContinuationResultsFromParcel(parcel, continuationResults2); - if (!result2) { - DTEST_LOG << "ReadContinuationResultsFromParcel failed" << std::endl; - return; - } + ASSERT_NE(false, result2); size_t size1 = continuationResults1.size(); size_t size2 = continuationResults2.size(); - if (size1 != size2) { - DTEST_LOG << "continuationResults1.size != continuationResults2.size" << std::endl; - return; - } + ASSERT_EQ(size1, size2); EXPECT_EQ(true, result1); EXPECT_EQ(true, result2); @@ -1434,10 +1338,7 @@ HWTEST_F(ContinuationManagerTest, Str16VecToStr8Vec_001, TestSize.Level3) size_t size1 = input2.size(); size_t size2 = input3.size(); - if (size1 != size2) { - DTEST_LOG << "input2.size != input3.size" << std::endl; - return; - } + ASSERT_EQ(size1, size2); for (size_t i = 0; i < size1; ++i) { EXPECT_EQ(input2[i], input3[i]); } @@ -1471,10 +1372,7 @@ HWTEST_F(ContinuationManagerTest, SetFunction_001, TestSize.Level3) std::vector deviceTypeVec2 = continuationExtraParams.GetDeviceType(); size_t size1 = deviceTypeVec1.size(); size_t size2 = deviceTypeVec2.size(); - if (size1 != size2) { - DTEST_LOG << "deviceTypeVec1.size != deviceTypeVec2.size" << std::endl; - return; - } + ASSERT_EQ(size1, size2); for (size_t i = 0; i < size1; ++i) { EXPECT_EQ(deviceTypeVec1[i], deviceTypeVec2[i]); } @@ -1512,25 +1410,16 @@ HWTEST_F(ContinuationManagerTest, ReadFromParcel_002, TestSize.Level3) Parcel parcel; bool result1 = continuationExtraParams.Marshalling(parcel); - if (!result1) { - DTEST_LOG << "Marshalling failed" << std::endl; - return; - } + ASSERT_NE(false, result1); bool result2 = continuationExtraParams.ReadFromParcel(parcel); - if (!result2) { - DTEST_LOG << "ReadFromParcel failed" << std::endl; - return; - } + ASSERT_NE(false, result2); EXPECT_EQ(true, result1); EXPECT_EQ(true, result2); std::vector deviceTypeVec2 = continuationExtraParams.GetDeviceType(); size_t size1 = deviceTypeVec1.size(); size_t size2 = deviceTypeVec2.size(); - if (size1 != size2) { - DTEST_LOG << "deviceTypeVec1.size != deviceTypeVec2.size" << std::endl; - return; - } + ASSERT_EQ(size1, size2); for (size_t i = 0; i < size1; ++i) { EXPECT_EQ(deviceTypeVec1[i], deviceTypeVec2[i]); } @@ -1569,25 +1458,16 @@ HWTEST_F(ContinuationManagerTest, Unmarshalling_001, TestSize.Level3) Parcel parcel; bool result1 = continuationExtraParams1.Marshalling(parcel); - if (!result1) { - DTEST_LOG << "Marshalling failed" << std::endl; - return; - } + ASSERT_NE(false, result1); sptr continuationExtraParams2 = continuationExtraParams1.Unmarshalling(parcel); - if (continuationExtraParams2 == nullptr) { - DTEST_LOG << "continuationExtraParams is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, continuationExtraParams2); std::vector deviceTypeVec2 = continuationExtraParams2->GetDeviceType(); EXPECT_EQ(true, result1); size_t size1 = deviceTypeVec1.size(); size_t size2 = deviceTypeVec2.size(); - if (size1 != size2) { - DTEST_LOG << "deviceTypeVec1.size != deviceTypeVec2.size" << std::endl; - return; - } + ASSERT_EQ(size1, size2); for (size_t i = 0; i < size1; ++i) { EXPECT_EQ(deviceTypeVec1[i], deviceTypeVec2[i]); } @@ -1675,10 +1555,7 @@ HWTEST_F(ContinuationManagerTest, OnRemoteRequest_003, TestSize.Level3) continuationResults.emplace_back(continuationResult2); bool result1 = ContinuationResult::WriteContinuationResultsToParcel(data, continuationResults); - if (!result1) { - DTEST_LOG << "WriteContinuationResultsToParcel failed" << std::endl; - return; - } + ASSERT_NE(false, result1); MessageParcel reply; MessageOption option; @@ -1739,11 +1616,7 @@ HWTEST_F(ContinuationManagerTest, OnRemoteRequest_005, TestSize.Level3) continuationResults.emplace_back(continuationResult2); bool result1 = ContinuationResult::WriteContinuationResultsToParcel(data, continuationResults); - if (!result1) { - DTEST_LOG << "WriteContinuationResultsToParcel failed" << std::endl; - return; - } - + ASSERT_NE(false, result1); MessageParcel reply; MessageOption option; DeviceSelectionNotifierTest deviceSelectionNotifierTest; diff --git a/services/dtbabilitymgr/test/unittest/distributed_ability_manager_service_test.cpp b/services/dtbabilitymgr/test/unittest/distributed_ability_manager_service_test.cpp index 2a5edbfa..10e78e64 100644 --- a/services/dtbabilitymgr/test/unittest/distributed_ability_manager_service_test.cpp +++ b/services/dtbabilitymgr/test/unittest/distributed_ability_manager_service_test.cpp @@ -1080,7 +1080,7 @@ HWTEST_F(DistributedAbilityManagerServiceTest, DisconnectAbility_001, TestSize.L std::shared_ptr continuationExtraParams = std::make_shared(); dtbabilitymgrService_->connect_ = new AppConnectionStub(token, continuationExtraParams); int32_t ret = dtbabilitymgrService_->DisconnectAbility(); - EXPECT_EQ(ret, ERR_OK); + EXPECT_NE(ret, ERR_OK); DTEST_LOG << "DistributedAbilityManagerServiceTest DisconnectAbility_001 end" << std::endl; } diff --git a/services/dtbschedmgr/test/unittest/bundle_manager_internal_test.cpp b/services/dtbschedmgr/test/unittest/bundle_manager_internal_test.cpp index 5dbfe792..317e36cb 100644 --- a/services/dtbschedmgr/test/unittest/bundle_manager_internal_test.cpp +++ b/services/dtbschedmgr/test/unittest/bundle_manager_internal_test.cpp @@ -402,11 +402,9 @@ HWTEST_F(BundleManagerInternalTest, BundleManagerCallBackTest_005, TestSize.Leve HWTEST_F(BundleManagerInternalTest, GetBundleNameListFromBms_001, TestSize.Level3) { DTEST_LOG << "BundleManagerCallBackTest GetBundleNameListFromBms_001 begin" << std::endl; - const std::string bundleName = "com.ohos.launcher"; + const std::string bundleName = "com.ohos.permissionmanager"; int32_t uid = BundleManagerInternal::GetUidFromBms(bundleName); - if (uid <= 0) { - return; - } + ASSERT_TRUE(uid>0); std::vector u16BundleNameList; BundleManagerInternal::GetBundleNameListFromBms(uid, u16BundleNameList); EXPECT_TRUE(!u16BundleNameList.empty()); @@ -426,9 +424,7 @@ HWTEST_F(BundleManagerInternalTest, GetBundleNameListFromBms_002, TestSize.Level DTEST_LOG << "BundleManagerCallBackTest GetBundleNameListFromBms_002 begin" << std::endl; const std::string bundleName = "com.ohos.permissionmanager"; int32_t uid = BundleManagerInternal::GetUidFromBms(bundleName); - if (uid <= 0) { - return; - } + ASSERT_TRUE(uid>0); std::vector u16BundleNameList; bool ret1 = BundleManagerInternal::GetBundleNameListFromBms(uid, u16BundleNameList); EXPECT_EQ(ret1, true); @@ -446,11 +442,9 @@ HWTEST_F(BundleManagerInternalTest, GetBundleNameListFromBms_002, TestSize.Level HWTEST_F(BundleManagerInternalTest, GetCallerAppIdFromBms_001, TestSize.Level3) { DTEST_LOG << "BundleManagerInternalTest GetCallerAppIdFromBms_001 begin" << std::endl; - const std::string bundleName = "com.ohos.launcher"; + const std::string bundleName = "com.ohos.permissionmanager"; int32_t uid = BundleManagerInternal::GetUidFromBms(bundleName); - if (uid <= 0) { - return; - } + ASSERT_TRUE(uid>0); string appId; bool ret = BundleManagerInternal::GetCallerAppIdFromBms(uid, appId); EXPECT_EQ(ret, true); diff --git a/services/dtbschedmgr/test/unittest/distributedWant/distributed_want_test.cpp b/services/dtbschedmgr/test/unittest/distributedWant/distributed_want_test.cpp index 589ba286..a7392eb2 100644 --- a/services/dtbschedmgr/test/unittest/distributedWant/distributed_want_test.cpp +++ b/services/dtbschedmgr/test/unittest/distributedWant/distributed_want_test.cpp @@ -417,9 +417,7 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Bundle_0100, Function HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0100, Function | MediumTest | Level3) { std::shared_ptr WantIn_ = std::make_shared(); - if (WantIn_ == nullptr) { - return; - } + ASSERT_NE(nullptr, WantIn_); WantIn_->SetAction("12345"); WantIn_->SetFlags(123); @@ -475,9 +473,7 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0100, Funct HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0200, Function | MediumTest | Level3) { std::shared_ptr WantIn_ = std::make_shared(); - if (WantIn_ == nullptr) { - return; - } + ASSERT_NE(nullptr, WantIn_); WantIn_->SetAction("@#¥#3243adsafdf_中文"); WantIn_->SetFlags(123); WantIn_->AddEntity("@#¥#3243adsafdf_中文"); @@ -532,9 +528,7 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0200, Funct HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0300, Function | MediumTest | Level3) { std::shared_ptr WantIn_ = std::make_shared(); - if (WantIn_ == nullptr) { - return; - } + ASSERT_NE(nullptr, WantIn_); WantIn_->SetAction(""); WantIn_->SetFlags(123); @@ -595,9 +589,7 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0300, Funct HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0400, Function | MediumTest | Level3) { std::shared_ptr WantIn_ = std::make_shared(); - if (WantIn_ == nullptr) { - return; - } + ASSERT_NE(nullptr, WantIn_); WantIn_->SetAction("12345"); WantIn_->SetFlags(123); @@ -657,9 +649,7 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0500, Funct { GTEST_LOG_(INFO) << "DistributedScheduleWant_Parcelable_0500 start"; std::shared_ptr WantIn_ = std::make_shared(); - if (WantIn_ == nullptr) { - return; - } + ASSERT_NE(nullptr, WantIn_); WantIn_->AddEntity("system.test.entity"); @@ -723,9 +713,7 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0501, Funct { GTEST_LOG_(INFO) << "DistributedScheduleWant_Parcelable_0501 start"; std::shared_ptr WantIn_ = std::make_shared(); - if (WantIn_ == nullptr) { - return; - } + ASSERT_NE(nullptr, WantIn_); WantIn_->SetAction("system.test.action"); @@ -790,9 +778,7 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_Parcelable_0502, Funct { GTEST_LOG_(INFO) << "DistributedScheduleWant_Parcelable_0502 start"; std::shared_ptr WantIn_ = std::make_shared(); - if (WantIn_ == nullptr) { - return; - } + ASSERT_NE(nullptr, WantIn_); WantIn_->SetFlags(64); @@ -4201,15 +4187,11 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_HasParameter_0200, Fun std::string key = std::to_string(Array::SIGNATURE) + ".#Intent;key=3{\"\\b\\\";end"; std::vector arrayValue = {'.', '=', ';'}; std::shared_ptr p1 = std::make_shared(); - if (p1 == nullptr) { - return; - } + ASSERT_NE(nullptr, p1); p1->SetParam(key, arrayValue); DistributedWant* newWant = nullptr; newWant = DistributedWant::ParseUri(p1->ToUri()); - if (newWant == nullptr) { - return; - } + ASSERT_NE(nullptr, newWant); std::shared_ptr p2(newWant); CompareWant(p1, p2); } @@ -4243,9 +4225,7 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ToString_0100, Functio parameters.SetParam(keyStr, Integer::Box(valueInt)); std::shared_ptr want1 = std::make_shared(); - if (want1 == nullptr) { - return; - } + ASSERT_NE(nullptr, want1); want1->SetElementName(deviceId, bundleName, abilityName); want1->SetUri(uri); want1->SetType(type); @@ -4257,9 +4237,7 @@ HWTEST_F(DistributedWantBaseTest, DistributedScheduleWant_ToString_0100, Functio std::string jsonString = want1->ToString(); DistributedWant* newWant = DistributedWant::FromString(jsonString); - if (newWant == nullptr) { - return; - } + ASSERT_NE(nullptr, newWant); std::shared_ptr want2(newWant); CompareWant(want1, want2); diff --git a/services/dtbschedmgr/test/unittest/distributed_sched_connect_test.cpp b/services/dtbschedmgr/test/unittest/distributed_sched_connect_test.cpp index db008d5d..33114824 100644 --- a/services/dtbschedmgr/test/unittest/distributed_sched_connect_test.cpp +++ b/services/dtbschedmgr/test/unittest/distributed_sched_connect_test.cpp @@ -252,10 +252,7 @@ HWTEST_F(DistributedSchedConnectTest, DumpConnectInfo_001, TestSize.Level1) } auto dms = samgr->GetSystemAbility(DISTRIBUTED_SCHED_SA_ID); - if (dms == nullptr) { - DTEST_LOG << "dms is nullptr" << std::endl; - return; - } + ASSERT_NE(nullptr, dms); std::vector args; args.push_back(u"-connect"); int32_t result = dms->Dump(STDOUT_FD, args); @@ -1015,7 +1012,7 @@ HWTEST_F(DistributedSchedConnectTest, DisconnectAbilityFromRemote004, TestSize.L int32_t ret = DistributedSchedService::GetInstance().DisconnectAbilityFromRemote( connect, 0, "123_remote_device_id"); - EXPECT_EQ(ret, ERR_OK); + EXPECT_NE(ret, ERR_OK); DTEST_LOG << "DistributedSchedConnectTest DisconnectAbilityFromRemote004 end" << std::endl; } @@ -1150,9 +1147,7 @@ HWTEST_F(DistributedSchedConnectTest, ProxyCallDisconnectRemoteAbility001, TestS { DTEST_LOG << "DistributedSchedServiceTest ProxyCallDisconnectRemoteAbility001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); /** * @tc.steps: step1. call HandleLocalCallerDied */ @@ -1177,9 +1172,7 @@ HWTEST_F(DistributedSchedConnectTest, ProxyCallDisconnectRemoteAbility002, TestS { DTEST_LOG << "DistributedSchedServiceTest ProxyCallDisconnectRemoteAbility002 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); sptr connect(new AbilityConnectCallbackTest()); /** * @tc.steps: step1. call HandleLocalCallerDied @@ -1213,9 +1206,7 @@ HWTEST_F(DistributedSchedConnectTest, ProxyCallConnectRemoteAbility001, TestSize { DTEST_LOG << "DistributedSchedServiceTest ProxyCallConnectRemoteAbility001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); OHOS::AAFwk::Want want; want.SetElementName("123_remote_device_id", "ohos.demo.bundleName", "abilityName"); sptr connect(new AbilityConnectCallbackTest()); @@ -1242,9 +1233,7 @@ HWTEST_F(DistributedSchedConnectTest, ProxyCallConnectRemoteAbility002, TestSize { DTEST_LOG << "DistributedSchedServiceTest ProxyCallConnectRemoteAbility002 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); OHOS::AAFwk::Want want; want.SetElementName("123_remote_device_id", "ohos.demo.bundleName", "abilityName"); /** @@ -1271,9 +1260,7 @@ HWTEST_F(DistributedSchedConnectTest, ProxyCallConnectAbilityFromRemote001, Test { DTEST_LOG << "DistributedSchedServiceTest ProxyCallConnectAbilityFromRemote001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); OHOS::AAFwk::Want want; want.SetElementName("123_remote_device_id", "ohos.demo.bundleName", "abilityName"); AppExecFwk::AbilityInfo abilityInfo; @@ -1304,9 +1291,7 @@ HWTEST_F(DistributedSchedConnectTest, ProxyCallConnectAbilityFromRemote002, Test { DTEST_LOG << "DistributedSchedServiceTest ProxyCallConnectAbilityFromRemote002 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); OHOS::AAFwk::Want want; want.SetElementName("123_remote_device_id", "ohos.demo.bundleName", "abilityName"); AppExecFwk::AbilityInfo abilityInfo; @@ -1337,9 +1322,7 @@ HWTEST_F(DistributedSchedConnectTest, ProxyCallDisconnectAbilityFromRemote001, T { DTEST_LOG << "DistributedSchedServiceTest ProxyCallDisconnectAbilityFromRemote001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); sptr connect(new AbilityConnectCallbackTest()); /** * @tc.steps: step1. call CheckDistributedConnectLocked @@ -1367,9 +1350,7 @@ HWTEST_F(DistributedSchedConnectTest, ProxyCallDisconnectAbilityFromRemote002, T { DTEST_LOG << "DistributedSchedServiceTest ProxyCallDisconnectAbilityFromRemote002 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); /** * @tc.steps: step1. call RemoteConnectAbilityMappingLocked */ @@ -1486,9 +1467,7 @@ HWTEST_F(DistributedSchedConnectTest, AbilityConnectionWrapperStub001, TestSize. sptr connectStub(new AbilityConnectionWrapperStub(connect)); ASSERT_NE(connectStub, nullptr); MessageParcel data; - if (!data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)) { - return; - } + ASSERT_NE(false, data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)); MessageParcel reply; MessageOption option; AppExecFwk::ElementName element; @@ -1513,9 +1492,7 @@ HWTEST_F(DistributedSchedConnectTest, AbilityConnectionWrapperStub002, TestSize. sptr connectStub(new AbilityConnectionWrapperStub(connect, "localDeviceId")); ASSERT_NE(connectStub, nullptr); MessageParcel data; - if (!data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)) { - return; - } + ASSERT_NE(false, data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)); MessageParcel reply; MessageOption option; AppExecFwk::ElementName element; @@ -1540,9 +1517,7 @@ HWTEST_F(DistributedSchedConnectTest, AbilityConnectionWrapperStub003, TestSize. sptr connectStub(new AbilityConnectionWrapperStub(connect)); ASSERT_NE(connectStub, nullptr); MessageParcel data; - if (!data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)) { - return; - } + ASSERT_NE(false, data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)); MessageParcel reply; MessageOption option; AppExecFwk::ElementName element; @@ -1566,9 +1541,7 @@ HWTEST_F(DistributedSchedConnectTest, AbilityConnectionWrapperStub004, TestSize. sptr connectStub(new AbilityConnectionWrapperStub(connect, "localDeviceId")); ASSERT_NE(connectStub, nullptr); MessageParcel data; - if (!data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)) { - return; - } + ASSERT_NE(false, data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)); MessageParcel reply; MessageOption option; AppExecFwk::ElementName element; @@ -1618,9 +1591,7 @@ HWTEST_F(DistributedSchedConnectTest, AbilityConnectionWrapperStub006, TestSize. MessageParcel data; MessageParcel reply; MessageOption option; - if (!data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)) { - return; - } + ASSERT_NE(false, data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)); // no element int32_t result = connectStub->OnRemoteRequest(IAbilityConnection::ON_ABILITY_DISCONNECT_DONE, data, reply, option); EXPECT_EQ(result, ERR_INVALID_VALUE); @@ -1640,9 +1611,7 @@ HWTEST_F(DistributedSchedConnectTest, AbilityConnectionWrapperStub007, TestSize. sptr connectStub(new AbilityConnectionWrapperStub(connect, "localDeviceId")); ASSERT_NE(connectStub, nullptr); MessageParcel data; - if (!data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)) { - return; - } + ASSERT_NE(false, data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)); MessageParcel reply; MessageOption option; AppExecFwk::ElementName element; @@ -1667,9 +1636,7 @@ HWTEST_F(DistributedSchedConnectTest, AbilityConnectionWrapperStub008, TestSize. sptr connectStub(new AbilityConnectionWrapperStub(connect, "localDeviceId")); ASSERT_NE(connectStub, nullptr); MessageParcel data; - if (!data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)) { - return; - } + ASSERT_NE(false, data.WriteInterfaceToken(CONNECTION_CALLBACK_INTERFACE_TOKEN)); MessageParcel reply; MessageOption option; // no remoteObject diff --git a/services/dtbschedmgr/test/unittest/distributed_sched_continuation_test.cpp b/services/dtbschedmgr/test/unittest/distributed_sched_continuation_test.cpp index af6ce12c..219295f8 100644 --- a/services/dtbschedmgr/test/unittest/distributed_sched_continuation_test.cpp +++ b/services/dtbschedmgr/test/unittest/distributed_sched_continuation_test.cpp @@ -420,9 +420,7 @@ HWTEST_F(DSchedContinuationTest, ContinueLocalMission_002, TestSize.Level1) auto callback = GetDSchedService(); WantParams wantParams; MockOnStart(); - if (DistributedSchedService::GetInstance().dschedContinuation_ == nullptr) { - return; - } + ASSERT_NE(nullptr, DistributedSchedService::GetInstance().dschedContinuation_); ASSERT_NE(DistributedSchedService::GetInstance().dschedContinuation_, nullptr); DistributedSchedService::GetInstance().dschedContinuation_->PushCallback(missionId, callback, deviceId, false); int32_t ret = DistributedSchedService::GetInstance().ContinueLocalMission( @@ -488,9 +486,7 @@ HWTEST_F(DSchedContinuationTest, ContinueLocalMission_005, TestSize.Level1) int32_t missionId = 0; auto callback = GetDSchedService(); WantParams wantParams; - if (DistributedSchedService::GetInstance().dschedContinuation_ == nullptr) { - return; - } + ASSERT_NE(nullptr, DistributedSchedService::GetInstance().dschedContinuation_); DistributedSchedService::GetInstance().dschedContinuation_ = std::make_shared(); ASSERT_NE(DistributedSchedService::GetInstance().dschedContinuation_, nullptr); DistributedSchedService::GetInstance().dschedContinuation_->PushCallback(missionId, callback, deviceId, false); @@ -1110,9 +1106,7 @@ HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_001, TestSize.Level0 { DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); AAFwk::Want want; CallerInfo callerInfo; callerInfo.uid = 0; @@ -1150,9 +1144,7 @@ HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_002, TestSize.Level1 { DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_002 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); AAFwk::Want want; AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer", @@ -1188,9 +1180,7 @@ HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_003, TestSize.Level1 { DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_003 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); /** * @tc.steps: step1. set want and abilityInfo */ @@ -1301,9 +1291,7 @@ HWTEST_F(DSchedContinuationTest, StartFreeInstallFromRemote_006, TestSize.Level1 { DTEST_LOG << "DSchedContinuationTest StartFreeInstallFromRemote_006 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); AAFwk::Want want; AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer", @@ -1646,9 +1634,7 @@ HWTEST_F(DSchedContinuationTest, ProxyCallNotifyProcessDiedFromRemote001, TestSi { DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyProcessDiedFromRemote001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); CallerInfo callerInfo; callerInfo.sourceDeviceId = "255.255.255.255"; callerInfo.uid = 0; @@ -1687,9 +1673,7 @@ HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteAbilityByCall002, TestSize. { DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteAbilityByCall002 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); std::string bundleName = "bundleName"; std::string abilityName = "abilityName"; std::shared_ptr spWant = MockWant(bundleName, abilityName, 0); @@ -1726,9 +1710,7 @@ HWTEST_F(DSchedContinuationTest, ProxyCallReleaseRemoteAbility002, TestSize.Leve { DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility002 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer", "com.ohos.distributedmusicplayer.MainAbility"); int32_t ret = proxy->ReleaseRemoteAbility(GetDSchedService(), element); @@ -1776,9 +1758,7 @@ HWTEST_F(DSchedContinuationTest, ProxyCallStartAbilityByCallFromRemote002, TestS { DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseRemoteAbility002 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); // mock want std::string bundleName = "bundleName"; std::string abilityName = "abilityName"; @@ -1832,9 +1812,7 @@ HWTEST_F(DSchedContinuationTest, ProxyCallReleaseAbilityFromRemote002, TestSize. { DTEST_LOG << "DistributedSchedServiceTest ProxyCallReleaseAbilityFromRemote002 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); // mock callerinfo CallerInfo callerInfo; callerInfo.sourceDeviceId = "255.255.255.255"; @@ -1858,9 +1836,7 @@ HWTEST_F(DSchedContinuationTest, ProxyCallStartRemoteFreeInstall001, TestSize.Le { DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartRemoteFreeInstall001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); // mock want std::string bundleName = "bundleName"; std::string abilityName = "abilityName"; @@ -1902,9 +1878,7 @@ HWTEST_F(DSchedContinuationTest, ProxyCallNotifyCompleteFreeInstallFromRemote001 { DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyCompleteFreeInstallFromRemote001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); int32_t ret = proxy->NotifyCompleteFreeInstallFromRemote(1, 1); EXPECT_NE(ret, ERR_NULL_OBJECT); DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyCompleteFreeInstallFromRemote001 end" << std::endl; @@ -1920,9 +1894,7 @@ HWTEST_F(DSchedContinuationTest, ProxyCallGetDistributedComponentList001, TestSi { DTEST_LOG << "DistributedSchedServiceTest ProxyCallGetDistributedComponentList001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); vector distributedComponents = { "test "}; int32_t ret = proxy->GetDistributedComponentList(distributedComponents); EXPECT_NE(ret, ERR_NULL_OBJECT); @@ -1957,9 +1929,7 @@ HWTEST_F(DSchedContinuationTest, ProxyCallStartShareFormFromRemote002, TestSize. { DTEST_LOG << "DistributedSchedServiceTest ProxyCallStartShareFormFromRemote002 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); const OHOS::AppExecFwk::FormShareInfo formShareInfo {}; int32_t ret = proxy->StartShareFormFromRemote("111", formShareInfo); EXPECT_NE(ret, ERR_NULL_OBJECT); diff --git a/services/dtbschedmgr/test/unittest/distributed_sched_permission_test.cpp b/services/dtbschedmgr/test/unittest/distributed_sched_permission_test.cpp index 9bd4b741..750d1908 100644 --- a/services/dtbschedmgr/test/unittest/distributed_sched_permission_test.cpp +++ b/services/dtbschedmgr/test/unittest/distributed_sched_permission_test.cpp @@ -1650,9 +1650,7 @@ HWTEST_F(DistributedSchedPermissionTest, FromJson_001, TestSize.Level3) {FIELD_GROUP_TYPE, MOCK_FIELD_GROUP_TYPE}, {FIELD_GROUP_VISIBILITY, MOCK_FIELD_GROUP_VISIBILITY} }; - if (jsonObject.is_discarded()) { - return; - } + ASSERT_NE(true, jsonObject.is_discarded()); from_json(jsonObject, groupInfo); EXPECT_EQ(groupInfo.groupName, MOCK_FIELD_GROUP_NAME); DTEST_LOG << "DistributedSchedPermissionTest FromJson_001 end" << std::endl; @@ -1668,9 +1666,7 @@ HWTEST_F(DistributedSchedPermissionTest, FromJson_002, TestSize.Level3) DTEST_LOG << "DistributedSchedPermissionTest FromJson_002 begin" << std::endl; GroupInfo groupInfo; nlohmann::json jsonObject; - if (jsonObject.is_discarded()) { - return; - } + ASSERT_NE(true, jsonObject.is_discarded()); from_json(jsonObject, groupInfo); EXPECT_EQ(groupInfo.groupName, ""); DTEST_LOG << "DistributedSchedPermissionTest FromJson_002 end " << std::endl; @@ -1734,7 +1730,6 @@ HWTEST_F(DistributedSchedPermissionTest, MarkUriPermission_002, TestSize.Level3) HWTEST_F(DistributedSchedPermissionTest, MarkUriPermission_003, TestSize.Level3) { DTEST_LOG << "DistributedSchedPermissionTest MarkUriPermission_003 begin" << std::endl; - DistributedSchedUtil::MockBundlePermission(); AAFwk::Want want; want.AddFlags(want.FLAG_AUTH_READ_URI_PERMISSION); want.SetUri("file://com.ohos.mms/data/test_B"); diff --git a/services/dtbschedmgr/test/unittest/distributed_sched_service_first_test.cpp b/services/dtbschedmgr/test/unittest/distributed_sched_service_first_test.cpp index 50d356d0..51111226 100644 --- a/services/dtbschedmgr/test/unittest/distributed_sched_service_first_test.cpp +++ b/services/dtbschedmgr/test/unittest/distributed_sched_service_first_test.cpp @@ -201,9 +201,7 @@ HWTEST_F(DistributedSchedServiceFirstTest, StartRemoteAbility_001, TestSize.Leve { DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteAbility_001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); /** * @tc.steps: step1. StartRemoteAbility with uninitialized params * @tc.expected: step1. StartRemoteAbility return INVALID_PARAMETERS_ERR @@ -235,9 +233,7 @@ HWTEST_F(DistributedSchedServiceFirstTest, StartRemoteAbility_002, TestSize.Leve { DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteAbility_002 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); /** * @tc.steps: step1. set want with wrong deviceId * @tc.expected: step2. StartRemoteAbility return INVALID_PARAMETERS_ERR @@ -291,9 +287,7 @@ HWTEST_F(DistributedSchedServiceFirstTest, StartRemoteAbility_004, TestSize.Leve { DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteAbility_004 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); /** * @tc.steps: step1. set want and abilityInfo * @tc.expected: step2. StartRemoteAbility return INVALID_PARAMETERS_ERR @@ -425,9 +419,7 @@ HWTEST_F(DistributedSchedServiceFirstTest, StartAbilityFromRemote_001, TestSize. { DTEST_LOG << "DistributedSchedServiceFirstTest StartAbilityFromRemote_001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); AAFwk::Want want; AppExecFwk::AbilityInfo abilityInfo; CallerInfo callerInfo; @@ -468,9 +460,7 @@ HWTEST_F(DistributedSchedServiceFirstTest, StartRemoteShareForm_002, TestSize.Le DTEST_LOG << "DistributedSchedServiceFirstTest StartRemoteShareForm_002 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); AAFwk::Want want; AppExecFwk::ElementName element("255.255.255.255", "com.ohos.distributedmusicplayer", @@ -623,9 +613,7 @@ HWTEST_F(DistributedSchedServiceFirstTest, SendResultFromRemote_001, TestSize.Le { DTEST_LOG << "DistributedSchedServiceFirstTest SendResultFromRemote_001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); AAFwk::Want want; CallerInfo callerInfo; callerInfo.uid = 0; diff --git a/services/dtbschedmgr/test/unittest/distributed_sched_service_second_test.cpp b/services/dtbschedmgr/test/unittest/distributed_sched_service_second_test.cpp index 95fe9ca8..a21d2de5 100644 --- a/services/dtbschedmgr/test/unittest/distributed_sched_service_second_test.cpp +++ b/services/dtbschedmgr/test/unittest/distributed_sched_service_second_test.cpp @@ -300,9 +300,7 @@ HWTEST_F(DistributedSchedServiceSecondTest, NotifyCompleteFreeInstall_001, TestS DTEST_LOG << "DistributedSchedServiceSecondTest NotifyCompleteFreeInstall_001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); AAFwk::Want want; AppExecFwk::ElementName element("", "com.ohos.distributedmusicplayer", @@ -351,9 +349,7 @@ HWTEST_F(DistributedSchedServiceSecondTest, NotifyStateChangedFromRemote_001, Te { DTEST_LOG << "DistributedSchedServiceSecondTest NotifyStateChangedFromRemote_001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); AppExecFwk::ElementName element("", BUNDLE_NAME, ABILITY_NAME); int result1 = proxy->NotifyStateChangedFromRemote(0, 0, element); DTEST_LOG << "result1:" << result1 << std::endl; @@ -610,9 +606,7 @@ HWTEST_F(DistributedSchedServiceSecondTest, StopRemoteExtensionAbility_003, Test { DTEST_LOG << "DistributedSchedServiceSecondTest StopRemoteExtensionAbility_003 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); AAFwk::Want want; std::string localDeviceId; DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(localDeviceId); @@ -634,9 +628,7 @@ HWTEST_F(DistributedSchedServiceSecondTest, StopExtensionAbilityFromRemote_001, { DTEST_LOG << "DistributedSchedServiceSecondTest StopExtensionAbilityFromRemote_001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); AAFwk::Want remoteWant; std::string deviceId; DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(deviceId); @@ -663,9 +655,7 @@ HWTEST_F(DistributedSchedServiceSecondTest, StopExtensionAbilityFromRemote_002, DTEST_LOG << "DistributedSchedServiceSecondTest StopExtensionAbilityFromRemote_002 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); /** * @tc.steps: step1. set want and abilityInfo */ @@ -712,9 +702,7 @@ HWTEST_F(DistributedSchedServiceSecondTest, StopExtensionAbilityFromRemote_003, { DTEST_LOG << "DistributedSchedServiceSecondTest StopExtensionAbilityFromRemote_003 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); AAFwk::Want remoteWant; AppExecFwk::ElementName element("abcdefg123456", "com.ohos.distributedmusicplayer", "com.ohos.distributedmusicplayer.MainAbility"); @@ -845,9 +833,7 @@ HWTEST_F(DistributedSchedServiceSecondTest, SetCallerInfo_001, TestSize.Level3) DTEST_LOG << "DistributedSchedServiceSecondTest SetCallerInfo_001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); /** * @tc.steps: step1. set want and abilityInfo */ diff --git a/services/dtbschedmgr/test/unittest/distributed_sched_stub_test.cpp b/services/dtbschedmgr/test/unittest/distributed_sched_stub_test.cpp index 0697b9f0..4d6d6d22 100644 --- a/services/dtbschedmgr/test/unittest/distributed_sched_stub_test.cpp +++ b/services/dtbschedmgr/test/unittest/distributed_sched_stub_test.cpp @@ -243,13 +243,6 @@ HWTEST_F(DistributedSchedStubTest, StartRemoteAbilityInner_004, TestSize.Level3) int32_t result = 0; int32_t uid = -1; DistributedSchedService::GetInstance().ReportEvent(want, eventName, result, uid); - - const std::string bundleName = "com.third.hiworld.example"; - uid = BundleManagerInternal::GetUidFromBms(bundleName); - if (uid <= 0) { - return; - } - DistributedSchedService::GetInstance().ReportEvent(want, eventName, result, uid); EXPECT_EQ(ret, DMS_PERMISSION_DENIED); DTEST_LOG << "DistributedSchedStubTest StartRemoteAbilityInner_004 end" << std::endl; } diff --git a/services/dtbschedmgr/test/unittest/distributed_sched_test_util.cpp b/services/dtbschedmgr/test/unittest/distributed_sched_test_util.cpp index 04aa38cb..39c88075 100644 --- a/services/dtbschedmgr/test/unittest/distributed_sched_test_util.cpp +++ b/services/dtbschedmgr/test/unittest/distributed_sched_test_util.cpp @@ -38,7 +38,7 @@ const std::string TAG = "DistributedSchedUtil"; const char* DISTSCHED_PROCESS_NAME = "distributedsched"; constexpr int32_t DMS_LOAD_SA_TIMEOUT_MS = 10000; constexpr int32_t USER_ID = 100; -constexpr int32_t PERMS_NUM = 4; +constexpr int32_t PERMS_NUM = 5; constexpr int32_t FAILED_RETURN = -1; } @@ -88,8 +88,8 @@ void DistributedSchedUtil::MockPermission() "ohos.permission.ABILITY_BACKGROUND_COMMUNICATION", "ohos.permission.ACCESS_SERVICE_DM", "ohos.permission.DISTRIBUTED_DATASYNC", - "ohos.permission.RUNNING_STATE_OBSERVER" - + "ohos.permission.RUNNING_STATE_OBSERVER", + "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" }; MockProcessAndPermission(DISTSCHED_PROCESS_NAME, perms, PERMS_NUM); } diff --git a/services/dtbschedmgr/test/unittest/mission/dms_mission_manager_test.cpp b/services/dtbschedmgr/test/unittest/mission/dms_mission_manager_test.cpp index fb82cc7c..1c82d994 100644 --- a/services/dtbschedmgr/test/unittest/mission/dms_mission_manager_test.cpp +++ b/services/dtbschedmgr/test/unittest/mission/dms_mission_manager_test.cpp @@ -167,9 +167,7 @@ HWTEST_F(DMSMissionManagerTest, testGetRemoteMissionInfo001, TestSize.Level1) HWTEST_F(DMSMissionManagerTest, testGetRemoteMissionInfo002, TestSize.Level1) { sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); std::vector infos; auto ret = proxy->GetMissionInfos(DEVICE_ID, 0, infos); EXPECT_TRUE(ret != ERR_NONE); @@ -195,9 +193,7 @@ HWTEST_F(DMSMissionManagerTest, testGetRemoteMissionInfo002, TestSize.Level1) HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions001, TestSize.Level1) { sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); auto ret = proxy->StartSyncRemoteMissions(DEVICE_ID, false, 0); EXPECT_NE(ret, ERR_NONE); } @@ -210,9 +206,7 @@ HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions001, TestSize.Level1) HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions002, TestSize.Level1) { sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); auto ret = proxy->StartSyncRemoteMissions("", false, 0); EXPECT_NE(ret, ERR_NONE); } @@ -225,9 +219,7 @@ HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions002, TestSize.Level1) HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions003, TestSize.Level1) { sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); auto ret = proxy->StartSyncRemoteMissions(localDeviceId_, false, 0); EXPECT_NE(ret, ERR_NONE); } @@ -376,9 +368,7 @@ HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions014, TestSize.Level3) { DTEST_LOG << "testStartSyncRemoteMissions014 begin" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); auto ret = DistributedSchedMissionManager::GetInstance().StartSyncRemoteMissions(DEVICE_ID, proxy); EXPECT_NE(ret, ERR_NONE); DTEST_LOG << "testStartSyncRemoteMissions014 end" << std::endl; @@ -444,9 +434,7 @@ HWTEST_F(DMSMissionManagerTest, testCleanMissionResources001, TestSize.Level3) HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions001, TestSize.Level1) { sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); auto ret = proxy->StopSyncRemoteMissions(DEVICE_ID); EXPECT_NE(ret, ERR_NONE); } @@ -459,9 +447,7 @@ HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions001, TestSize.Level1) HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions002, TestSize.Level1) { sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); auto ret = proxy->StopSyncRemoteMissions(localDeviceId_); EXPECT_NE(ret, ERR_NONE); } @@ -474,9 +460,7 @@ HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions002, TestSize.Level1) HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions003, TestSize.Level1) { sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); auto ret = proxy->StopSyncRemoteMissions(""); EXPECT_NE(ret, ERR_NONE); } @@ -606,9 +590,7 @@ HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions012, TestSize.Level3) HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener001, TestSize.Level1) { sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); auto ret = proxy->RegisterMissionListener(U16DEVICE_ID, nullptr); EXPECT_TRUE(ret != ERR_NONE); @@ -627,9 +609,7 @@ HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener001, TestSize.Level1) HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener002, TestSize.Level1) { sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); sptr listener(new RemoteMissionListenerTest()); auto ret = proxy->RegisterMissionListener(U16DEVICE_ID, listener); EXPECT_TRUE(ret != ERR_NONE); @@ -745,9 +725,7 @@ HWTEST_F(DMSMissionManagerTest, testRegisterMissionListener008, TestSize.Level3) HWTEST_F(DMSMissionManagerTest, testUnRegisterMissionListener001, TestSize.Level1) { sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); auto ret = proxy->UnRegisterMissionListener(U16DEVICE_ID, nullptr); EXPECT_TRUE(ret != ERR_NONE); @@ -1568,9 +1546,7 @@ HWTEST_F(DMSMissionManagerTest, ProxyCallStopSyncMissionsFromRemote001, TestSize { DTEST_LOG << "DistributedSchedServiceTest ProxyCallStopSyncMissionsFromRemote001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); CallerInfo callerInfo; int32_t ret = proxy->StopSyncMissionsFromRemote(callerInfo); EXPECT_EQ(ret, REQUEST_CODE_ERR); @@ -1587,9 +1563,7 @@ HWTEST_F(DMSMissionManagerTest, ProxyCallNotifyMissionsChangedFromRemote001, Tes { DTEST_LOG << "DistributedSchedServiceTest ProxyCallNotifyMissionsChangedFromRemote001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); CallerInfo callerInfo; std::vector missionInfos; int32_t ret = proxy->NotifyMissionsChangedFromRemote(missionInfos, callerInfo); @@ -1607,9 +1581,7 @@ HWTEST_F(DMSMissionManagerTest, ProxyCallGetRemoteMissionSnapshotInfo001, TestSi { DTEST_LOG << "DistributedSchedServiceTest ProxyCallGetRemoteMissionSnapshotInfo001 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); unique_ptr missionSnapshot = nullptr; int32_t ret = proxy->GetRemoteMissionSnapshotInfo("MockDevId", 1, missionSnapshot); EXPECT_EQ(ret, DMS_PERMISSION_DENIED); @@ -1626,9 +1598,7 @@ HWTEST_F(DMSMissionManagerTest, ProxyCallGetRemoteMissionSnapshotInfo002, TestSi { DTEST_LOG << "DistributedSchedServiceTest ProxyCallGetRemoteMissionSnapshotInfo002 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); unique_ptr missionSnapshot = nullptr; int32_t ret = proxy->GetRemoteMissionSnapshotInfo("", 1, missionSnapshot); EXPECT_EQ(ret, ERR_NULL_OBJECT); @@ -1645,9 +1615,7 @@ HWTEST_F(DMSMissionManagerTest, ProxyCallGetRemoteMissionSnapshotInfo003, TestSi { DTEST_LOG << "DistributedSchedServiceTest ProxyCallGetRemoteMissionSnapshotInfo003 start" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); unique_ptr missionSnapshot = nullptr; int32_t ret = proxy->GetRemoteMissionSnapshotInfo("MockDevId", -1, missionSnapshot); EXPECT_EQ(ret, INVALID_PARAMETERS_ERR); @@ -2177,9 +2145,7 @@ HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions015, TestSize.Level3) DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo; } sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); { std::lock_guard autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_); DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear(); @@ -2214,9 +2180,7 @@ HWTEST_F(DMSMissionManagerTest, testStartSyncRemoteMissions016, TestSize.Level3) DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo; } sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); { std::lock_guard autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_); DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear(); @@ -2426,9 +2390,7 @@ HWTEST_F(DMSMissionManagerTest, testStopSyncRemoteMissions013, TestSize.Level3) */ DTEST_LOG << "testGetRemoteDms001 begin" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); { std::lock_guard autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_); DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear(); @@ -2859,9 +2821,7 @@ HWTEST_F(DMSMissionManagerTest, testNotifyMissionsChangedToRemoteInner003, TestS { DTEST_LOG << "testNotifyMissionsChangedToRemoteInner003 begin" << std::endl; sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); { std::lock_guard autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_); DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear(); @@ -3070,9 +3030,7 @@ HWTEST_F(DMSMissionManagerTest, testRetryStartSyncRemoteMissions005, TestSize.Le DistributedSchedMissionManager::GetInstance().listenDeviceMap_[deviceId] = listenerInfo; } sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); { std::lock_guard autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_); DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear(); @@ -3198,9 +3156,7 @@ HWTEST_F(DMSMissionManagerTest, testOnRemoteDmsDied007, TestSize.Level3) DistributedSchedMissionManager::GetInstance().missionHandler_ = std::make_shared(runner); sptr remote(new RemoteMissionListenerTest()); sptr proxy = GetDms(); - if (proxy == nullptr) { - return; - } + ASSERT_NE(nullptr, proxy); { std::lock_guard autoLock(DistributedSchedMissionManager::GetInstance().remoteDmsLock_); DistributedSchedMissionManager::GetInstance().remoteDmsMap_.clear(); diff --git a/services/dtbschedmgr/test/unittest/softbus_adapter/softbus_transport_test.cpp b/services/dtbschedmgr/test/unittest/softbus_adapter/softbus_transport_test.cpp index 7ed89f2a..cb92a1d6 100644 --- a/services/dtbschedmgr/test/unittest/softbus_adapter/softbus_transport_test.cpp +++ b/services/dtbschedmgr/test/unittest/softbus_adapter/softbus_transport_test.cpp @@ -404,20 +404,6 @@ HWTEST_F(DSchedTransportSoftbusAdapterTest, InitChannel_001, TestSize.Level3) DTEST_LOG << "DSchedTransportSoftbusAdapterTest InitChannel_001 end" << std::endl; } -/** - * @tc.name: OnBind_001 - * @tc.desc: call OnBind with get local - * @tc.type: FUNC - */ -HWTEST_F(DSchedTransportSoftbusAdapterTest, OnBind_001, TestSize.Level3) -{ - DTEST_LOG << "DSchedTransportSoftbusAdapterTest OnBind_001 begin" << std::endl; - int32_t sessionId = 0; - DSchedTransportSoftbusAdapter::GetInstance().OnBind(sessionId, PEERDEVICEID); - EXPECT_EQ(sessionId, 0); - DTEST_LOG << "DSchedTransportSoftbusAdapterTest OnBind_001 end" << std::endl; -} - /** * @tc.name: GetSessionIdByDeviceId_001 * @tc.desc: call GetSessionIdByDeviceId @@ -427,6 +413,7 @@ HWTEST_F(DSchedTransportSoftbusAdapterTest, GetSessionIdByDeviceId_001, TestSize { DTEST_LOG << "DSchedTransportSoftbusAdapterTest GetSessionIdByDeviceId_001 begin" << std::endl; int32_t sessionId = 0; + DSchedTransportSoftbusAdapter::GetInstance().OnBind(sessionId, PEERDEVICEID); std::shared_ptr dataBuffer = std::make_shared(SIZE_1); ASSERT_NE(dataBuffer, nullptr); uint32_t dataType = 0; From 73d90607e2eb1d81289c334f2ab142b333155219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B8=88=E7=9A=93=E6=9D=B0?= Date: Fri, 6 Sep 2024 14:14:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?ut=E6=96=AD=E8=A8=80=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 师皓杰 --- .../test/unittest/bundle_manager_internal_test.cpp | 6 +++--- .../test/unittest/mission/dms_continue_manager_test.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/dtbschedmgr/test/unittest/bundle_manager_internal_test.cpp b/services/dtbschedmgr/test/unittest/bundle_manager_internal_test.cpp index 317e36cb..6ffa3873 100644 --- a/services/dtbschedmgr/test/unittest/bundle_manager_internal_test.cpp +++ b/services/dtbschedmgr/test/unittest/bundle_manager_internal_test.cpp @@ -404,7 +404,7 @@ HWTEST_F(BundleManagerInternalTest, GetBundleNameListFromBms_001, TestSize.Level DTEST_LOG << "BundleManagerCallBackTest GetBundleNameListFromBms_001 begin" << std::endl; const std::string bundleName = "com.ohos.permissionmanager"; int32_t uid = BundleManagerInternal::GetUidFromBms(bundleName); - ASSERT_TRUE(uid>0); + ASSERT_TRUE(uid > 0); std::vector u16BundleNameList; BundleManagerInternal::GetBundleNameListFromBms(uid, u16BundleNameList); EXPECT_TRUE(!u16BundleNameList.empty()); @@ -424,7 +424,7 @@ HWTEST_F(BundleManagerInternalTest, GetBundleNameListFromBms_002, TestSize.Level DTEST_LOG << "BundleManagerCallBackTest GetBundleNameListFromBms_002 begin" << std::endl; const std::string bundleName = "com.ohos.permissionmanager"; int32_t uid = BundleManagerInternal::GetUidFromBms(bundleName); - ASSERT_TRUE(uid>0); + ASSERT_TRUE(uid > 0); std::vector u16BundleNameList; bool ret1 = BundleManagerInternal::GetBundleNameListFromBms(uid, u16BundleNameList); EXPECT_EQ(ret1, true); @@ -444,7 +444,7 @@ HWTEST_F(BundleManagerInternalTest, GetCallerAppIdFromBms_001, TestSize.Level3) DTEST_LOG << "BundleManagerInternalTest GetCallerAppIdFromBms_001 begin" << std::endl; const std::string bundleName = "com.ohos.permissionmanager"; int32_t uid = BundleManagerInternal::GetUidFromBms(bundleName); - ASSERT_TRUE(uid>0); + ASSERT_TRUE(uid > 0); string appId; bool ret = BundleManagerInternal::GetCallerAppIdFromBms(uid, appId); EXPECT_EQ(ret, true); diff --git a/services/dtbschedmgr/test/unittest/mission/dms_continue_manager_test.cpp b/services/dtbschedmgr/test/unittest/mission/dms_continue_manager_test.cpp index e5286c29..00abbb97 100644 --- a/services/dtbschedmgr/test/unittest/mission/dms_continue_manager_test.cpp +++ b/services/dtbschedmgr/test/unittest/mission/dms_continue_manager_test.cpp @@ -843,7 +843,7 @@ HWTEST_F(DMSContinueManagerTest, testSetStateSendEvent_001, TestSize.Level1) HWTEST_F(DMSContinueManagerTest, testGetContinueLaunchMissionInfo_001, TestSize.Level1) { DTEST_LOG << "DMSContinueManagerTest testGetContinueLaunchMissionInfo_001 start" << std::endl; - ContinueLaunchMissionInfo missionInfo = {"com.test.demo", "MainAbility"}; + ContinueLaunchMissionInfo missionInfo = {"com.test.missionInfo", "MainAbility"}; DMSContinueSendMgr::GetInstance().continueLaunchMission_.clear(); int32_t ret = DMSContinueSendMgr::GetInstance().GetContinueLaunchMissionInfo(MISSIONID_01, missionInfo); EXPECT_EQ(ret, INVALID_PARAMETERS_ERR);