diff --git a/test/apn_manager_test.cpp b/test/apn_manager_test.cpp index a5862f5..28fbc69 100644 --- a/test/apn_manager_test.cpp +++ b/test/apn_manager_test.cpp @@ -518,6 +518,48 @@ HWTEST_F(ApnManagerTest, GetRilAttachApn_001, Function | MediumTest | Level1) ASSERT_EQ(apnManager->GetRilAttachApn(), nullptr); } +/** + * @tc.number GetRilAttachApn_002 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(ApnManagerTest, GetRilAttachApn_002, Function | MediumTest | Level1) +{ + std::vector> allApnItem; + sptr defaultApnItem = ApnItem::MakeDefaultApn(DATA_CONTEXT_ROLE_DEFAULT); + allApnItem.push_back(defaultApnItem); + apnManager->allApnItem_ = allApnItem; + ASSERT_NE(apnManager->GetRilAttachApn(), nullptr); +} + +/** + * @tc.number GetRilAttachApn_003 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(ApnManagerTest, GetRilAttachApn_003, Function | MediumTest | Level1) +{ + std::vector> allApnItem; + sptr apnItem = ApnItem::MakeDefaultApn(DATA_CONTEXT_ROLE_IA); + allApnItem.push_back(apnItem); + apnManager->allApnItem_ = allApnItem; + ASSERT_NE(apnManager->GetRilAttachApn(), nullptr); +} + +/** + * @tc.number GetRilAttachApn_004 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(ApnManagerTest, GetRilAttachApn_004, Function | MediumTest | Level1) +{ + std::vector> allApnItem; + sptr apnItem = ApnItem::MakeDefaultApn(DATA_CONTEXT_ROLE_MMS); + allApnItem.push_back(apnItem); + apnManager->allApnItem_ = allApnItem; + ASSERT_NE(apnManager->GetRilAttachApn(), nullptr); +} + /** * @tc.number ReleaseDataConnection_001 * @tc.name test function branch @@ -1001,5 +1043,68 @@ HWTEST_F(ApnManagerTest, UpdateDefaultCellularDataSlotId_001, TestSize.Level0) int32_t result = CellularDataClient::GetInstance().UpdateDefaultCellularDataSlotId(); EXPECT_EQ(result, 0); } + +/** + * @tc.name : ApnItem_CanDealWithType_001 + * @tc.number: ApnItemTest_001 + * @tc.desc : Test when the type matches with the apnTypes_ then CanDealWithType returns true + */ +HWTEST_F(ApnManagerTest, ApnItem_CanDealWithType_001, TestSize.Level0) +{ + ApnItem apnItem; + apnItem.apnTypes_.push_back("default"); + EXPECT_TRUE(apnItem.CanDealWithType("default")); +} + +/** + * @tc.name : ApnItem_CanDealWithType_002 + * @tc.number: ApnItemTest_002 + * @tc.desc : Test when the type is DATA_CONTEXT_ROLE_INTERNAL_DEFAULT + * and apnTypes_ contains DATA_CONTEXT_ROLE_DEFAULT then CanDealWithType returns true + */ +HWTEST_F(ApnManagerTest, ApnItem_CanDealWithType_002, TestSize.Level0) +{ + ApnItem apnItem; + apnItem.apnTypes_.push_back(DATA_CONTEXT_ROLE_DEFAULT); + EXPECT_TRUE(apnItem.CanDealWithType(DATA_CONTEXT_ROLE_INTERNAL_DEFAULT)); +} + +/** + * @tc.name : ApnItem_CanDealWithType_003 + * @tc.number: ApnItemTest_003 + * @tc.desc : Test when the type is not DATA_CONTEXT_ROLE_IA and + * apnTypes_ contains DATA_CONTEXT_ROLE_ALL then CanDealWithType returns true + */ +HWTEST_F(ApnManagerTest, ApnItem_CanDealWithType_003, TestSize.Level0) +{ + ApnItem apnItem; + apnItem.apnTypes_.push_back(DATA_CONTEXT_ROLE_ALL); + EXPECT_TRUE(apnItem.CanDealWithType("not_ia")); +} + +/** + * @tc.name : ApnItem_CanDealWithType_004 + * @tc.number: ApnItemTest_004 + * @tc.desc : Test when the type does not match with the apnTypes_ then CanDealWithType returns false + */ +HWTEST_F(ApnManagerTest, ApnItem_CanDealWithType_004, TestSize.Level0) +{ + ApnItem apnItem; + apnItem.apnTypes_.push_back("default"); + EXPECT_FALSE(apnItem.CanDealWithType("other")); +} + +/** + * @tc.name : ApnManager_FindApnHolderById_001 + * @tc.number: ApnItemTest_004 + * @tc.desc : Test when the type does not match with the apnTypes_ then CanDealWithType returns false + */ +HWTEST_F(ApnManagerTest, ApnManager_FindApnHolderById_001, TestSize.Level0) +{ + apnManager->apnIdApnHolderMap_.clear(); + EXPECT_EQ(apnManager->FindApnHolderById(0), nullptr); + apnManager->AddApnHolder("default", 10); + EXPECT_EQ(apnManager->FindApnTypeByApnName("abc"), static_cast(ApnTypes::NONETYPE)); +} } // namespace Telephony } // namespace OHOS \ No newline at end of file diff --git a/test/cellular_data_client_test.cpp b/test/cellular_data_client_test.cpp index bd85f87..2e33246 100644 --- a/test/cellular_data_client_test.cpp +++ b/test/cellular_data_client_test.cpp @@ -224,5 +224,15 @@ HWTEST_F(CellularDataClientTest, GetSupplierRegisterState_001, TestSize.Level0) EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR); } +/** + * @tc.number OnInitCellularDataController_001 + * @tc.name test function branch + * @tc.desc Function test + */ +HWTEST_F(CellularDataClientTest, OnInitCellularDataController_001, TestSize.Level0) +{ + int32_t result = CellularDataClient::GetInstance().InitCellularDataController(0); + EXPECT_EQ(result, TELEPHONY_ERR_PERMISSION_ERR); +} } // namespace Telephony } // namespace OHOS \ No newline at end of file