!814 新增tdd用例

Merge pull request !814 from dingxiaochen/master
This commit is contained in:
openharmony_ci 2024-11-14 09:15:22 +00:00 committed by Gitee
commit a47979ba15
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 115 additions and 0 deletions

View File

@ -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<sptr<ApnItem>> allApnItem;
sptr<ApnItem> 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<sptr<ApnItem>> allApnItem;
sptr<ApnItem> 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<sptr<ApnItem>> allApnItem;
sptr<ApnItem> 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<uint64_t>(ApnTypes::NONETYPE));
}
} // namespace Telephony
} // namespace OHOS

View File

@ -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