mirror of
https://gitee.com/openharmony/telephony_core_service
synced 2025-02-22 10:41:16 +00:00
VCard group add test
Signed-off-by: mayuecheng <mayuecheng@huawei.com>
This commit is contained in:
parent
41f3adf21b
commit
5e8361ae7e
@ -16,6 +16,7 @@
|
||||
#define protected public
|
||||
#include "vcard_email_data.h"
|
||||
#include "vcard_event_data.h"
|
||||
#include "vcard_group_data.h"
|
||||
#include "vcard_im_data.h"
|
||||
#include "vcard_manager.h"
|
||||
#include "vcard_name_data.h"
|
||||
@ -657,6 +658,11 @@ HWTEST_F(ContactDataTest, VCardRdbHelper, Function | MediumTest | Level3)
|
||||
EXPECT_EQ(VCardRdbHelper::GetInstance().QueryContact(columns, predicates), nullptr);
|
||||
EXPECT_EQ(VCardRdbHelper::GetInstance().QueryRawContact(columns, predicates), nullptr);
|
||||
EXPECT_EQ(VCardRdbHelper::GetInstance().QueryContactData(columns, predicates), nullptr);
|
||||
|
||||
DataShare::DataShareValuesBucket groupDataValue;
|
||||
EXPECT_EQ(VCardRdbHelper::GetInstance().QueryGroupData(columns, predicates), nullptr);
|
||||
EXPECT_EQ(VCardRdbHelper::GetInstance().QueryGroupId(""), DB_FAILD);
|
||||
EXPECT_EQ(VCardRdbHelper::GetInstance().InsertGroupData(groupDataValue), DB_FAILD);
|
||||
}
|
||||
|
||||
HWTEST_F(ContactDataTest, VCardUtils_HandleCh_001, Function | MediumTest | Level3)
|
||||
@ -785,6 +791,25 @@ HWTEST_F(ContactDataTest, VCardUtils_ConstructListFromValue_005, Function | Medi
|
||||
ASSERT_EQ(result, expected);
|
||||
}
|
||||
|
||||
HWTEST_F(ContactDataTest, VCardGroupData_BuildData, Function | MediumTest | Level3)
|
||||
{
|
||||
std::shared_ptr<DataShare::DataShareResultSet> resultSet = std::make_shared<DataShare::DataShareResultSet>();
|
||||
VCardGroupData groupData;
|
||||
EXPECT_EQ(groupData.BuildData(resultSet), TELEPHONY_ERROR);
|
||||
EXPECT_EQ(groupData.BuildData(nullptr), TELEPHONY_ERROR);
|
||||
}
|
||||
|
||||
HWTEST_F(ContactDataTest, VCardGroupData_BuildValuesBucket, Function | MediumTest | Level3)
|
||||
{
|
||||
VCardGroupData groupData;
|
||||
DataShare::DataShareValuesBucket valuesBucket;
|
||||
std::string groupName = "";
|
||||
int32_t groupId = 0;
|
||||
groupData.SetGroupId(groupId);
|
||||
groupData.SetGroupName(groupName);
|
||||
EXPECT_EQ(groupData.BuildValuesBucket(valuesBucket), TELEPHONY_SUCCESS);
|
||||
}
|
||||
|
||||
#endif // TEL_TEST_UNSUPPORT
|
||||
} // namespace Telephony
|
||||
} // namespace OHOS
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
@ -142,9 +142,8 @@ private:
|
||||
void CheckNameExist();
|
||||
std::string ConvertHarmonyEvents(std::string type, std::string value);
|
||||
void AddGroups(std::string rawValue);
|
||||
void AddRemainDatas(std::string name, std::string rawValue, std::string byte, std::vector<std::string> values,
|
||||
std::string propValue, std::vector<std::string> groups,
|
||||
std::map<std::string, std::vector<std::string>> parasMap);
|
||||
void AddRemainDatas(std::string name, std::string rawValue, std::vector<std::string> values,
|
||||
std::string propValue, std::map<std::string, std::vector<std::string>> parasMap);
|
||||
|
||||
private:
|
||||
const int32_t SORT_NAME_MAX_VALUE_SIZE = 3;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -51,8 +51,8 @@ int32_t VCardGroupData::BuildData(std::shared_ptr<DataShare::DataShareResultSet>
|
||||
int curValueIndex;
|
||||
nameResultSet->GetColumnIndex(Group::GROUP_NAME, curValueIndex);
|
||||
nameResultSet->GetString(curValueIndex, groupName);
|
||||
nameResultSet->Close();
|
||||
}
|
||||
nameResultSet->Close();
|
||||
groupName_ = groupName;
|
||||
return TELEPHONY_SUCCESS;
|
||||
}
|
||||
|
@ -735,7 +735,7 @@ int32_t VCardConstructor::ConstructEvents(std::shared_ptr<VCardContact> contact)
|
||||
int32_t VCardConstructor::ConstructGroups(std::shared_ptr<VCardContact> contact)
|
||||
{
|
||||
if (contact == nullptr) {
|
||||
TELEPHONY_LOGI("contact is null");
|
||||
TELEPHONY_LOGE("contact is null");
|
||||
return TELEPHONY_ERR_LOCAL_PTR_NULL;
|
||||
}
|
||||
for (auto groupData : contact->GetGroups()) {
|
||||
|
@ -101,12 +101,11 @@ void VCardContact::AddOtherDatas(std::string name, std::string rawValue, std::st
|
||||
} else if (name == VCARD_TYPE_X_OHOS_CUSTOM || name == VCARD_TYPE_X_MOBILE_CUSTOM) {
|
||||
AddCustom(rawValue, parasMap, propValue);
|
||||
}
|
||||
AddRemainDatas(name, rawValue, byte, values, propValue, groups, parasMap);
|
||||
AddRemainDatas(name, rawValue, values, propValue, parasMap);
|
||||
}
|
||||
|
||||
void VCardContact::AddRemainDatas(std::string name, std::string rawValue, std::string byte,
|
||||
std::vector<std::string> values, std::string propValue, std::vector<std::string> groups,
|
||||
std::map<std::string, std::vector<std::string>> parasMap)
|
||||
void VCardContact::AddRemainDatas(std::string name, std::string rawValue, std::vector<std::string> values,
|
||||
std::string propValue, std::map<std::string, std::vector<std::string>> parasMap)
|
||||
{
|
||||
if (name == VCARD_TYPE_X_AIM || name == VCARD_TYPE_X_MSN || name == VCARD_TYPE_X_YAHOO ||
|
||||
name == VCARD_TYPE_X_ICQ || name == VCARD_TYPE_X_JABBER || name == VCARD_TYPE_X_QQ ||
|
||||
|
@ -153,6 +153,7 @@ int32_t VCardRdbHelper::QueryGroupId(std::string groupName)
|
||||
resultSet->Close();
|
||||
return groupId;
|
||||
}
|
||||
resultSet->Close();
|
||||
OHOS::DataShare::DataShareValuesBucket valuesBucket;
|
||||
valuesBucket.Put(Group::GROUP_NAME, groupName);
|
||||
valuesBucket.Put(Group::GROUP_ACCOUNT_ID, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user