mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2024-11-26 17:50:36 +00:00
add tdd test.
Signed-off-by: dingxiaochen <dingxiaochen@huawei.com>
This commit is contained in:
parent
d83eb6b6ba
commit
aa909b5b8f
@ -1430,6 +1430,43 @@ HWTEST_F(SimTest, Telephony_Sim_TestTelProfileUtil_0100, Function | MediumTest |
|
||||
EXPECT_NE(telProfileUtil->DeleteProfiles(), -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_Sim_TestTelProfileUtil_0101
|
||||
* @tc.name TestTelProfileUtil
|
||||
* @tc.desc Function test
|
||||
*/
|
||||
HWTEST_F(SimTest, Telephony_Sim_TestTelProfileUtil_0101, Function | MediumTest | Level3)
|
||||
{
|
||||
auto telProfileUtil = DelayedSingleton<TelProfileUtil>::GetInstance();
|
||||
telProfileUtil->path_ = "";
|
||||
std::string key = "test";
|
||||
std::string key1 = "test1";
|
||||
std::string value = "test";
|
||||
std::string defValue = "";
|
||||
int saveValue = 1;
|
||||
int getValue = 1;
|
||||
bool saveBool = true;
|
||||
bool getBool = true;
|
||||
int64_t longValue = 1;
|
||||
int64_t getLongValue = 1;
|
||||
float saveFloatValue = 1;
|
||||
float getFloatValue = 1;
|
||||
EXPECT_EQ(telProfileUtil->SaveString(key, value), NativePreferences::E_ERROR);
|
||||
EXPECT_EQ(telProfileUtil->ObtainString(key, defValue), "error");
|
||||
EXPECT_EQ(telProfileUtil->SaveInt(key, saveValue), NativePreferences::E_ERROR);
|
||||
EXPECT_EQ(telProfileUtil->ObtainInt(key, getValue), NativePreferences::E_ERROR);
|
||||
EXPECT_EQ(telProfileUtil->SaveBool(key, saveBool), NativePreferences::E_ERROR);
|
||||
EXPECT_TRUE(telProfileUtil->ObtainBool(key, getBool));
|
||||
EXPECT_EQ(telProfileUtil->SaveLong(key, longValue), NativePreferences::E_ERROR);
|
||||
EXPECT_EQ(telProfileUtil->ObtainLong(key, getLongValue), NativePreferences::E_ERROR);
|
||||
EXPECT_EQ(telProfileUtil->SaveFloat(key1, saveFloatValue), NativePreferences::E_ERROR);
|
||||
EXPECT_EQ(telProfileUtil->ObtainFloat(key1, getFloatValue), NativePreferences::E_ERROR);
|
||||
EXPECT_TRUE(telProfileUtil->IsExistKey(key));
|
||||
EXPECT_EQ(telProfileUtil->RemoveKey(key), NativePreferences::E_ERROR);
|
||||
EXPECT_EQ(telProfileUtil->RemoveAll(), NativePreferences::E_ERROR);
|
||||
EXPECT_EQ(telProfileUtil->RefreshSync(), NativePreferences::E_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number Telephony_Sim_TestDump_0100
|
||||
* @tc.name TestDump
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "vcard_photo_data.h"
|
||||
#include "vcard_postal_data.h"
|
||||
#include "vcard_relation_data.h"
|
||||
#include "vcard_configuration.h"
|
||||
#include "vcard_contact.h"
|
||||
#include "vcard_constant.h"
|
||||
#include "vcard_decoder_v21.h"
|
||||
@ -574,6 +575,129 @@ HWTEST_F(ContactDataTest, VCardDecoderV30_UnescapeChar, Function | MediumTest |
|
||||
EXPECT_STREQ(decoder.UnescapeChar('X').c_str(), "X");
|
||||
}
|
||||
|
||||
HWTEST_F(ContactDataTest, VCardDecoderV30_GetLine_001, Function | MediumTest | Level3)
|
||||
{
|
||||
VCardDecoderV30 decoder;
|
||||
decoder.preLine_ = "";
|
||||
EXPECT_STREQ(decoder.GetLine().c_str(), "");
|
||||
decoder.preLine_ = "abc";
|
||||
EXPECT_STREQ(decoder.preLine_.c_str(), "abc");
|
||||
}
|
||||
|
||||
HWTEST_F(ContactDataTest, VCardDecoderV30_PeekLine_001, Function | MediumTest | Level3)
|
||||
{
|
||||
VCardDecoderV30 decoder;
|
||||
decoder.preLine_ = "";
|
||||
EXPECT_STREQ(decoder.GetLine().c_str(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name : DealParamV30_ShouldHandleQuotedValues_WhenQuotedValuesArePresent
|
||||
* @tc.number: VCardDecoderV30Test_001
|
||||
* @tc.desc : Test DealParamV30 method when paramValue contains quoted values
|
||||
*/
|
||||
HWTEST_F(ContactDataTest, VCardDecoderV30_DealParamV30_001, Function | MediumTest | Level3)
|
||||
{
|
||||
VCardDecoderV30 decoder;
|
||||
std::shared_ptr<VCardRawData> rawData = std::make_shared<VCardRawData>();
|
||||
int32_t errorCode;
|
||||
std::string param = "TEST_PARAM";
|
||||
std::string paramValue = "\"quoted,value\"";
|
||||
decoder.DealParamV30(param, paramValue, rawData, errorCode);
|
||||
EXPECT_EQ(rawData->GetParameters(param).size(), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name : DealParamV30_ShouldHandleNonQuotedValues_WhenNonQuotedValuesArePresent
|
||||
* @tc.number: VCardDecoderV30Test_002
|
||||
* @tc.desc : Test DealParamV30 method when paramValue contains non-quoted values
|
||||
*/
|
||||
HWTEST_F(ContactDataTest, VCardDecoderV30_DealParamV30_002, Function | MediumTest | Level3)
|
||||
{
|
||||
VCardDecoderV30 decoder;
|
||||
std::shared_ptr<VCardRawData> rawData = std::make_shared<VCardRawData>();
|
||||
int32_t errorCode;
|
||||
std::string param = "TEST_PARAM";
|
||||
std::string paramValue = "non,quoted,value";
|
||||
decoder.DealParamV30(param, paramValue, rawData, errorCode);
|
||||
EXPECT_EQ(rawData->GetParameters(param).size(), 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name : DealParamV30_ShouldHandleEmptyValues_WhenValueIsEmpty
|
||||
* @tc.number: VCardDecoderV30Test_003
|
||||
* @tc.desc : Test DealParamV30 method when paramValue is empty
|
||||
*/
|
||||
HWTEST_F(ContactDataTest, VCardDecoderV30_DealParamV30_003, Function | MediumTest | Level3)
|
||||
{
|
||||
VCardDecoderV30 decoder;
|
||||
std::shared_ptr<VCardRawData> rawData = std::make_shared<VCardRawData>();
|
||||
int32_t errorCode;
|
||||
std::string param = "TEST_PARAM";
|
||||
std::string paramValue = "";
|
||||
decoder.DealParamV30(param, paramValue, rawData, errorCode);
|
||||
EXPECT_EQ(rawData->GetParameters(param).size(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name : DealParamV30_ShouldHandleNonQuotedValuesWithTrailingComma_WhenTrailingCommaIsPresent
|
||||
* @tc.number: VCardDecoderV30Test_004
|
||||
* @tc.desc : Test DealParamV30 method when paramValue contains non-quoted values with trailing comma
|
||||
*/
|
||||
HWTEST_F(ContactDataTest, VCardDecoderV30_DealParamV30_004, Function | MediumTest | Level3)
|
||||
{
|
||||
VCardDecoderV30 decoder;
|
||||
std::shared_ptr<VCardRawData> rawData = std::make_shared<VCardRawData>();
|
||||
int32_t errorCode;
|
||||
std::string param = "TEST_PARAM";
|
||||
std::string paramValue = "non,quoted,value,";
|
||||
decoder.DealParamV30(param, paramValue, rawData, errorCode);
|
||||
EXPECT_EQ(rawData->GetParameters(param).size(), 3);
|
||||
}
|
||||
|
||||
HWTEST_F(ContactDataTest, VCardDecoderV30_DealParams_001, Function | MediumTest | Level3)
|
||||
{
|
||||
int32_t errorCode = TELEPHONY_ERR_VCARD_FILE_INVALID;
|
||||
std::shared_ptr<VCardRawData> rawData = std::make_shared<VCardRawData>();
|
||||
VCardDecoderV30 decoder;
|
||||
decoder.DealParams("invalid_params", rawData, errorCode);
|
||||
ASSERT_EQ(errorCode, TELEPHONY_ERR_VCARD_FILE_INVALID);
|
||||
}
|
||||
|
||||
HWTEST_F(ContactDataTest, VCardDecoderV30_DealParams_002, Function | MediumTest | Level3)
|
||||
{
|
||||
int32_t errorCode = TELEPHONY_SUCCESS;
|
||||
std::shared_ptr<VCardRawData> rawData = std::make_shared<VCardRawData>();
|
||||
VCardDecoderV30 decoder;
|
||||
decoder.DealParams("valid_params=value", rawData, errorCode);
|
||||
ASSERT_EQ(errorCode, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(ContactDataTest, VCardDecoderV30_DealParams_003, Function | MediumTest | Level3)
|
||||
{
|
||||
int32_t errorCode = TELEPHONY_SUCCESS;
|
||||
std::shared_ptr<VCardRawData> rawData = std::make_shared<VCardRawData>();
|
||||
VCardDecoderV30 decoder;
|
||||
decoder.DealParams("invalid_params", rawData, errorCode);
|
||||
ASSERT_EQ(errorCode, TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(ContactDataTest, VCardConfiguration_IsJapaneseDevice_001, Function | MediumTest | Level3)
|
||||
{
|
||||
int32_t vcardType = VCardConfiguration::VCARD_TYPE_V21_JAPANESE;
|
||||
VCardConfiguration vCardConfig;
|
||||
bool result = vCardConfig.IsJapaneseDevice(vcardType);
|
||||
ASSERT_TRUE(result);
|
||||
}
|
||||
|
||||
HWTEST_F(ContactDataTest, VCardConfiguration_IsJapaneseDevice_002, Function | MediumTest | Level3)
|
||||
{
|
||||
int32_t vcardType = 2;
|
||||
VCardConfiguration vCardConfig;
|
||||
bool result = vCardConfig.IsJapaneseDevice(vcardType);
|
||||
ASSERT_FALSE(result);
|
||||
}
|
||||
|
||||
HWTEST_F(ContactDataTest, VCardEncoder, Function | MediumTest | Level3)
|
||||
{
|
||||
VCardEncoder encoder;
|
||||
|
Loading…
Reference in New Issue
Block a user