1115cd2caSopenharmony_ci/*
2115cd2caSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3115cd2caSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4115cd2caSopenharmony_ci * you may not use this file except in compliance with the License.
5115cd2caSopenharmony_ci * You may obtain a copy of the License at
6115cd2caSopenharmony_ci *
7115cd2caSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8115cd2caSopenharmony_ci *
9115cd2caSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10115cd2caSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11115cd2caSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12115cd2caSopenharmony_ci * See the License for the specific language governing permissions and
13115cd2caSopenharmony_ci * limitations under the License.
14115cd2caSopenharmony_ci */
15115cd2caSopenharmony_ci
16115cd2caSopenharmony_ci#include "contactability_test.h"
17115cd2caSopenharmony_ci#include "random_number_utils.h"
18115cd2caSopenharmony_ci
19115cd2caSopenharmony_ci#include "data_ability_operation_builder.h"
20115cd2caSopenharmony_ci
21115cd2caSopenharmony_cinamespace Contacts {
22115cd2caSopenharmony_cinamespace Test {
23115cd2caSopenharmony_ciContactAbilityTest::ContactAbilityTest()
24115cd2caSopenharmony_ci{
25115cd2caSopenharmony_ci}
26115cd2caSopenharmony_ci
27115cd2caSopenharmony_ciContactAbilityTest::~ContactAbilityTest()
28115cd2caSopenharmony_ci{
29115cd2caSopenharmony_ci}
30115cd2caSopenharmony_ci
31115cd2caSopenharmony_ciint64_t ContactAbilityTest::RawContactInsert(std::string displayName,
32115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket &rawContactValues)
33115cd2caSopenharmony_ci{
34115cd2caSopenharmony_ci    OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT);
35115cd2caSopenharmony_ci    rawContactValues.Put("display_name", displayName);
36115cd2caSopenharmony_ci    int64_t code = contactsDataAbility.Insert(uriRawContact, rawContactValues);
37115cd2caSopenharmony_ci    return code;
38115cd2caSopenharmony_ci}
39115cd2caSopenharmony_ci
40115cd2caSopenharmony_ciint64_t ContactAbilityTest::RawContactExpandInsert(
41115cd2caSopenharmony_ci    std::vector<std::string> valueVector, int isFavorite, OHOS::DataShare::DataShareValuesBucket &rawContactValues)
42115cd2caSopenharmony_ci{
43115cd2caSopenharmony_ci    int indexZero = 0;
44115cd2caSopenharmony_ci    int indexOne = 1;
45115cd2caSopenharmony_ci    int indexTwo = 2;
46115cd2caSopenharmony_ci    int indexThree = 3;
47115cd2caSopenharmony_ci    OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT);
48115cd2caSopenharmony_ci    rawContactValues.Put("display_name", valueVector[indexZero]);
49115cd2caSopenharmony_ci    rawContactValues.Put("company", valueVector[indexOne]);
50115cd2caSopenharmony_ci    rawContactValues.Put("position", valueVector[indexTwo]);
51115cd2caSopenharmony_ci    rawContactValues.Put("favorite", isFavorite);
52115cd2caSopenharmony_ci    rawContactValues.Put("phonetic_name", valueVector[indexThree]);
53115cd2caSopenharmony_ci    int64_t code = contactsDataAbility.Insert(uriRawContact, rawContactValues);
54115cd2caSopenharmony_ci    return code;
55115cd2caSopenharmony_ci}
56115cd2caSopenharmony_ci
57115cd2caSopenharmony_ciint64_t ContactAbilityTest::RawContactLastContactedInsert(
58115cd2caSopenharmony_ci    std::string displayName, int lastestContactedTime, OHOS::DataShare::DataShareValuesBucket &rawContactValues)
59115cd2caSopenharmony_ci{
60115cd2caSopenharmony_ci    OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT);
61115cd2caSopenharmony_ci    rawContactValues.Put("display_name", displayName);
62115cd2caSopenharmony_ci    rawContactValues.Put("lastest_contacted_time", lastestContactedTime);
63115cd2caSopenharmony_ci    int64_t code = contactsDataAbility.Insert(uriRawContact, rawContactValues);
64115cd2caSopenharmony_ci    return code;
65115cd2caSopenharmony_ci}
66115cd2caSopenharmony_ci
67115cd2caSopenharmony_ciint64_t ContactAbilityTest::ContactDataInsert(int64_t rawContactId, std::string contentType, std::string detailInfo,
68115cd2caSopenharmony_ci    std::string position, OHOS::DataShare::DataShareValuesBucket &contactDataValues)
69115cd2caSopenharmony_ci{
70115cd2caSopenharmony_ci    OHOS::Uri uriContactData(ContactsUri::CONTACT_DATA);
71115cd2caSopenharmony_ci    contactDataValues.Put("raw_contact_id", rawContactId);
72115cd2caSopenharmony_ci    contactDataValues.Put("content_type", contentType);
73115cd2caSopenharmony_ci    contactDataValues.Put("detail_info", detailInfo);
74115cd2caSopenharmony_ci    contactDataValues.Put("position", position);
75115cd2caSopenharmony_ci    int64_t code = contactsDataAbility.Insert(uriContactData, contactDataValues);
76115cd2caSopenharmony_ci    return code;
77115cd2caSopenharmony_ci}
78115cd2caSopenharmony_ci
79115cd2caSopenharmony_ciint64_t ContactAbilityTest::GroupsInsert(std::string groupName, OHOS::DataShare::DataShareValuesBucket &groupValues)
80115cd2caSopenharmony_ci{
81115cd2caSopenharmony_ci    OHOS::Uri uriGroups(ContactsUri::GROUPS);
82115cd2caSopenharmony_ci    groupValues.Put("group_name", groupName);
83115cd2caSopenharmony_ci    int64_t code = contactsDataAbility.Insert(uriGroups, groupValues);
84115cd2caSopenharmony_ci    return code;
85115cd2caSopenharmony_ci}
86115cd2caSopenharmony_ci
87115cd2caSopenharmony_ciint64_t ContactAbilityTest::ContactBlocklistInsert(
88115cd2caSopenharmony_ci    std::string phoneNumber, OHOS::DataShare::DataShareValuesBucket &contactBlocklistValues)
89115cd2caSopenharmony_ci{
90115cd2caSopenharmony_ci    OHOS::Uri uriBlocklist(ContactsUri::BLOCKLIST);
91115cd2caSopenharmony_ci    contactBlocklistValues.Put("phone_number", phoneNumber);
92115cd2caSopenharmony_ci    int64_t code = contactsDataAbility.Insert(uriBlocklist, contactBlocklistValues);
93115cd2caSopenharmony_ci    return code;
94115cd2caSopenharmony_ci}
95115cd2caSopenharmony_ci
96115cd2caSopenharmony_ciint ContactAbilityTest::ContactUpdate(const std::string &tableName, OHOS::DataShare::DataShareValuesBucket updateValues,
97115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates)
98115cd2caSopenharmony_ci{
99115cd2caSopenharmony_ci    int code = 0;
100115cd2caSopenharmony_ci    if (tableName == ContactTabName::RAW_CONTACT) {
101115cd2caSopenharmony_ci        OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT);
102115cd2caSopenharmony_ci        code = contactsDataAbility.Update(uriRawContact, predicates, updateValues);
103115cd2caSopenharmony_ci    } else if (tableName == ContactTabName::CONTACT_DATA) {
104115cd2caSopenharmony_ci        OHOS::Uri uriContactData(ContactsUri::CONTACT_DATA);
105115cd2caSopenharmony_ci        code = contactsDataAbility.Update(uriContactData, predicates, updateValues);
106115cd2caSopenharmony_ci    } else if (tableName == ContactTabName::GROUPS) {
107115cd2caSopenharmony_ci        OHOS::Uri uriGroups(ContactsUri::GROUPS);
108115cd2caSopenharmony_ci        code = contactsDataAbility.Update(uriGroups, predicates, updateValues);
109115cd2caSopenharmony_ci    } else if (tableName == ContactTabName::CONTACT_BLOCKLIST) {
110115cd2caSopenharmony_ci        OHOS::Uri uriBlocklist(ContactsUri::BLOCKLIST);
111115cd2caSopenharmony_ci        code = contactsDataAbility.Update(uriBlocklist, predicates, updateValues);
112115cd2caSopenharmony_ci    } else {
113115cd2caSopenharmony_ci        HILOG_ERROR("ContactsDataAbility ====>no match uri action");
114115cd2caSopenharmony_ci    }
115115cd2caSopenharmony_ci    return code;
116115cd2caSopenharmony_ci}
117115cd2caSopenharmony_ci
118115cd2caSopenharmony_ciint ContactAbilityTest::ContactDelete(const std::string &tableName, OHOS::DataShare::DataSharePredicates predicates)
119115cd2caSopenharmony_ci{
120115cd2caSopenharmony_ci    int code = 0;
121115cd2caSopenharmony_ci    if (tableName == ContactTabName::RAW_CONTACT) {
122115cd2caSopenharmony_ci        OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT);
123115cd2caSopenharmony_ci        code = contactsDataAbility.Delete(uriRawContact, predicates);
124115cd2caSopenharmony_ci    } else if (tableName == ContactTabName::CONTACT_DATA) {
125115cd2caSopenharmony_ci        OHOS::Uri uriContactData(ContactsUri::CONTACT_DATA);
126115cd2caSopenharmony_ci        code = contactsDataAbility.Delete(uriContactData, predicates);
127115cd2caSopenharmony_ci    } else if (tableName == ContactTabName::GROUPS) {
128115cd2caSopenharmony_ci        OHOS::Uri uriGroups(ContactsUri::GROUPS);
129115cd2caSopenharmony_ci        code = contactsDataAbility.Delete(uriGroups, predicates);
130115cd2caSopenharmony_ci    } else if (tableName == ContactTabName::CONTACT_BLOCKLIST) {
131115cd2caSopenharmony_ci        OHOS::Uri uriBlocklist(ContactsUri::BLOCKLIST);
132115cd2caSopenharmony_ci        code = contactsDataAbility.Delete(uriBlocklist, predicates);
133115cd2caSopenharmony_ci    } else if (tableName == ContactTabName::CONTACT) {
134115cd2caSopenharmony_ci        OHOS::Uri uriContact(ContactsUri::CONTACT);
135115cd2caSopenharmony_ci        code = contactsDataAbility.Delete(uriContact, predicates);
136115cd2caSopenharmony_ci    } else if (tableName == ContactTabName::DELETED_RAW_CONTACT_RECORD) {
137115cd2caSopenharmony_ci        OHOS::Uri deleteRawContact(ContactsUri::DELETED_RAW_CONTACT_RECORD);
138115cd2caSopenharmony_ci        code = contactsDataAbility.Delete(deleteRawContact, predicates);
139115cd2caSopenharmony_ci    } else {
140115cd2caSopenharmony_ci        HILOG_ERROR("ContactsDataAbility ====>no match uri action");
141115cd2caSopenharmony_ci    }
142115cd2caSopenharmony_ci    return code;
143115cd2caSopenharmony_ci}
144115cd2caSopenharmony_ci
145115cd2caSopenharmony_cistd::shared_ptr<OHOS::DataShare::DataShareResultSet> ContactAbilityTest::ContactQuery(
146115cd2caSopenharmony_ci    const std::string &tableName, std::vector<std::string> &columns, OHOS::DataShare::DataSharePredicates predicates)
147115cd2caSopenharmony_ci{
148115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet;
149115cd2caSopenharmony_ci
150115cd2caSopenharmony_ci    if (tableName == ContactTabName::RAW_CONTACT) {
151115cd2caSopenharmony_ci        OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT);
152115cd2caSopenharmony_ci        resultSet = contactsDataAbility.Query(uriRawContact, predicates, columns);
153115cd2caSopenharmony_ci    } else if (tableName == ContactTabName::CONTACT_DATA) {
154115cd2caSopenharmony_ci        OHOS::Uri uriContactData(ContactsUri::CONTACT_DATA);
155115cd2caSopenharmony_ci        resultSet = contactsDataAbility.Query(uriContactData, predicates, columns);
156115cd2caSopenharmony_ci    } else if (tableName == ContactTabName::CONTACT) {
157115cd2caSopenharmony_ci        OHOS::Uri uriContact(ContactsUri::CONTACT);
158115cd2caSopenharmony_ci        resultSet = contactsDataAbility.Query(uriContact, predicates, columns);
159115cd2caSopenharmony_ci    } else if (tableName == ContactTabName::GROUPS) {
160115cd2caSopenharmony_ci        OHOS::Uri uriGroups(ContactsUri::GROUPS);
161115cd2caSopenharmony_ci        resultSet = contactsDataAbility.Query(uriGroups, predicates, columns);
162115cd2caSopenharmony_ci    } else if (tableName == ContactTabName::CONTACT_BLOCKLIST) {
163115cd2caSopenharmony_ci        OHOS::Uri uriBlocklist(ContactsUri::BLOCKLIST);
164115cd2caSopenharmony_ci        resultSet = contactsDataAbility.Query(uriBlocklist, predicates, columns);
165115cd2caSopenharmony_ci    } else if (tableName == ContactTabName::DELETED_RAW_CONTACT) {
166115cd2caSopenharmony_ci        OHOS::Uri uriDeletedRawContact(ContactsUri::DELETED_RAW_CONTACT);
167115cd2caSopenharmony_ci        resultSet = contactsDataAbility.Query(uriDeletedRawContact, predicates, columns);
168115cd2caSopenharmony_ci    } else if (tableName == ContactTabName::SEARCH_CONTACT) {
169115cd2caSopenharmony_ci        OHOS::Uri uriSearchContact(ContactsUri::SEARCH);
170115cd2caSopenharmony_ci        resultSet = contactsDataAbility.Query(uriSearchContact, predicates, columns);
171115cd2caSopenharmony_ci    } else {
172115cd2caSopenharmony_ci        HILOG_ERROR("ContactsDataAbility ====>no match uri action");
173115cd2caSopenharmony_ci    }
174115cd2caSopenharmony_ci    return resultSet;
175115cd2caSopenharmony_ci}
176115cd2caSopenharmony_ci
177115cd2caSopenharmony_civoid ContactAbilityTest::QueryAndExpectResult(std::string &tableName, OHOS::DataShare::DataSharePredicates predicates,
178115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket &values, std::string testName)
179115cd2caSopenharmony_ci{
180115cd2caSopenharmony_ci    std::vector<std::string> columns;
181115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(tableName, columns, predicates);
182115cd2caSopenharmony_ci    CheckResultSet(values, resultSet, testName);
183115cd2caSopenharmony_ci}
184115cd2caSopenharmony_ci
185115cd2caSopenharmony_ciint64_t ContactAbilityTest::RawContactInsertValues(OHOS::DataShare::DataShareValuesBucket &values)
186115cd2caSopenharmony_ci{
187115cd2caSopenharmony_ci    OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT);
188115cd2caSopenharmony_ci    int64_t code = contactsDataAbility.Insert(uriRawContact, values);
189115cd2caSopenharmony_ci    return code;
190115cd2caSopenharmony_ci}
191115cd2caSopenharmony_ci
192115cd2caSopenharmony_ciint64_t ContactAbilityTest::ContactDataInsertValues(OHOS::DataShare::DataShareValuesBucket &values)
193115cd2caSopenharmony_ci{
194115cd2caSopenharmony_ci    OHOS::Uri uriContactData(ContactsUri::CONTACT_DATA);
195115cd2caSopenharmony_ci    int64_t code = contactsDataAbility.Insert(uriContactData, values);
196115cd2caSopenharmony_ci    return code;
197115cd2caSopenharmony_ci}
198115cd2caSopenharmony_ci
199115cd2caSopenharmony_ciint64_t ContactAbilityTest::GroupsInsertValues(OHOS::DataShare::DataShareValuesBucket &values)
200115cd2caSopenharmony_ci{
201115cd2caSopenharmony_ci    OHOS::Uri uriGroups(ContactsUri::GROUPS);
202115cd2caSopenharmony_ci    int64_t code = contactsDataAbility.Insert(uriGroups, values);
203115cd2caSopenharmony_ci    return code;
204115cd2caSopenharmony_ci}
205115cd2caSopenharmony_ci
206115cd2caSopenharmony_ciint64_t ContactAbilityTest::ContactBlocklistInsertValues(OHOS::DataShare::DataShareValuesBucket &values)
207115cd2caSopenharmony_ci{
208115cd2caSopenharmony_ci    OHOS::Uri uriContactBolcklist(ContactsUri::BLOCKLIST);
209115cd2caSopenharmony_ci    int64_t code = contactsDataAbility.Insert(uriContactBolcklist, values);
210115cd2caSopenharmony_ci    return code;
211115cd2caSopenharmony_ci}
212115cd2caSopenharmony_ci
213115cd2caSopenharmony_civoid ContactAbilityTest::GetAllRawContactColumns(
214115cd2caSopenharmony_ci    std::vector<std::string> &columnInt, std::vector<std::string> &columnStr)
215115cd2caSopenharmony_ci{
216115cd2caSopenharmony_ci    columnInt.push_back("photo_id");
217115cd2caSopenharmony_ci    columnInt.push_back("photo_file_id");
218115cd2caSopenharmony_ci    columnInt.push_back("is_transfer_voicemail");
219115cd2caSopenharmony_ci    columnInt.push_back("account_id");
220115cd2caSopenharmony_ci    columnInt.push_back("version");
221115cd2caSopenharmony_ci    columnInt.push_back("contacted_count");
222115cd2caSopenharmony_ci    columnInt.push_back("lastest_contacted_time");
223115cd2caSopenharmony_ci    columnInt.push_back("favorite");
224115cd2caSopenharmony_ci    columnInt.push_back("phonetic_name_type");
225115cd2caSopenharmony_ci    columnInt.push_back("read_only");
226115cd2caSopenharmony_ci    columnInt.push_back("merge_mode");
227115cd2caSopenharmony_ci    columnInt.push_back("is_need_merge");
228115cd2caSopenharmony_ci    columnInt.push_back("merge_status");
229115cd2caSopenharmony_ci    columnInt.push_back("is_merge_target");
230115cd2caSopenharmony_ci    columnInt.push_back("vibration_setting");
231115cd2caSopenharmony_ci    columnInt.push_back("sync_id");
232115cd2caSopenharmony_ci
233115cd2caSopenharmony_ci    columnStr.push_back("personal_ringtone");
234115cd2caSopenharmony_ci    columnStr.push_back("personal_notification_ringtone");
235115cd2caSopenharmony_ci    columnStr.push_back("photo_first_name");
236115cd2caSopenharmony_ci    columnStr.push_back("display_name");
237115cd2caSopenharmony_ci    columnStr.push_back("sort");
238115cd2caSopenharmony_ci    columnStr.push_back("favorite_order");
239115cd2caSopenharmony_ci    columnStr.push_back("phonetic_name");
240115cd2caSopenharmony_ci    columnStr.push_back("company");
241115cd2caSopenharmony_ci    columnStr.push_back("position");
242115cd2caSopenharmony_ci    columnStr.push_back("sort_first_letter");
243115cd2caSopenharmony_ci    columnStr.push_back("syn_1");
244115cd2caSopenharmony_ci    columnStr.push_back("syn_2");
245115cd2caSopenharmony_ci    columnStr.push_back("syn_3");
246115cd2caSopenharmony_ci}
247115cd2caSopenharmony_ci
248115cd2caSopenharmony_civoid ContactAbilityTest::GetAllContactDataColumns(
249115cd2caSopenharmony_ci    std::vector<std::string> &columnInt, std::vector<std::string> &columnStr)
250115cd2caSopenharmony_ci{
251115cd2caSopenharmony_ci    columnInt.push_back("read_only");
252115cd2caSopenharmony_ci    columnInt.push_back("version");
253115cd2caSopenharmony_ci    columnInt.push_back("is_preferred_number");
254115cd2caSopenharmony_ci
255115cd2caSopenharmony_ci    columnStr.push_back("detail_info");
256115cd2caSopenharmony_ci    columnStr.push_back("family_name");
257115cd2caSopenharmony_ci    columnStr.push_back("middle_name_phonetic");
258115cd2caSopenharmony_ci    columnStr.push_back("given_name");
259115cd2caSopenharmony_ci    columnStr.push_back("given_name_phonetic");
260115cd2caSopenharmony_ci    columnStr.push_back("alias_detail_info");
261115cd2caSopenharmony_ci    columnStr.push_back("phonetic_name");
262115cd2caSopenharmony_ci    columnStr.push_back("position");
263115cd2caSopenharmony_ci    columnStr.push_back("extend1");
264115cd2caSopenharmony_ci    columnStr.push_back("extend2");
265115cd2caSopenharmony_ci    columnStr.push_back("extend3");
266115cd2caSopenharmony_ci    columnStr.push_back("extend4");
267115cd2caSopenharmony_ci    columnStr.push_back("city");
268115cd2caSopenharmony_ci    columnStr.push_back("country");
269115cd2caSopenharmony_ci    columnStr.push_back("neighborhood");
270115cd2caSopenharmony_ci    columnStr.push_back("pobox");
271115cd2caSopenharmony_ci    columnStr.push_back("region");
272115cd2caSopenharmony_ci    columnStr.push_back("street");
273115cd2caSopenharmony_ci    columnStr.push_back("alpha_name");
274115cd2caSopenharmony_ci    columnStr.push_back("other_lan_last_name");
275115cd2caSopenharmony_ci    columnStr.push_back("other_lan_first_name");
276115cd2caSopenharmony_ci    columnStr.push_back("lan_style");
277115cd2caSopenharmony_ci    columnStr.push_back("custom_data");
278115cd2caSopenharmony_ci    columnStr.push_back("extend6");
279115cd2caSopenharmony_ci    columnStr.push_back("extend7");
280115cd2caSopenharmony_ci    columnStr.push_back("syn_1");
281115cd2caSopenharmony_ci    columnStr.push_back("syn_2");
282115cd2caSopenharmony_ci    columnStr.push_back("syn_3");
283115cd2caSopenharmony_ci}
284115cd2caSopenharmony_ci
285115cd2caSopenharmony_civoid ContactAbilityTest::GetAllGroupsColumns(std::vector<std::string> &columnInt, std::vector<std::string> &columnStr)
286115cd2caSopenharmony_ci{
287115cd2caSopenharmony_ci    columnInt.push_back("account_id");
288115cd2caSopenharmony_ci    columnInt.push_back("ringtone_modify_time");
289115cd2caSopenharmony_ci    columnInt.push_back("lastest_modify_time");
290115cd2caSopenharmony_ci    columnStr.push_back("group_name");
291115cd2caSopenharmony_ci    columnStr.push_back("group_notes");
292115cd2caSopenharmony_ci    columnStr.push_back("group_ringtone");
293115cd2caSopenharmony_ci}
294115cd2caSopenharmony_ci
295115cd2caSopenharmony_civoid ContactAbilityTest::GetAllContactBlocklistColumns(
296115cd2caSopenharmony_ci    std::vector<std::string> &columnInt, std::vector<std::string> &columnStr)
297115cd2caSopenharmony_ci{
298115cd2caSopenharmony_ci    columnInt.push_back("types");
299115cd2caSopenharmony_ci    columnStr.push_back("phone_number");
300115cd2caSopenharmony_ci    columnStr.push_back("content");
301115cd2caSopenharmony_ci    columnStr.push_back("time_stamp");
302115cd2caSopenharmony_ci}
303115cd2caSopenharmony_ci
304115cd2caSopenharmony_civoid ContactAbilityTest::GetDetailsContactDataColumns(std::vector<std::string> &columns)
305115cd2caSopenharmony_ci{
306115cd2caSopenharmony_ci    columns.push_back("email");
307115cd2caSopenharmony_ci    columns.push_back("im");
308115cd2caSopenharmony_ci    columns.push_back("nickname");
309115cd2caSopenharmony_ci    columns.push_back("organization");
310115cd2caSopenharmony_ci    columns.push_back("phone");
311115cd2caSopenharmony_ci    columns.push_back("name");
312115cd2caSopenharmony_ci    columns.push_back("postal_address");
313115cd2caSopenharmony_ci    columns.push_back("photo");
314115cd2caSopenharmony_ci    columns.push_back("group_membership");
315115cd2caSopenharmony_ci    columns.push_back("note");
316115cd2caSopenharmony_ci    columns.push_back("contact_event");
317115cd2caSopenharmony_ci    columns.push_back("website");
318115cd2caSopenharmony_ci    columns.push_back("relation");
319115cd2caSopenharmony_ci    columns.push_back("contact_misc");
320115cd2caSopenharmony_ci    columns.push_back("hicall_device");
321115cd2caSopenharmony_ci    columns.push_back("camcard");
322115cd2caSopenharmony_ci    columns.push_back("sip_address");
323115cd2caSopenharmony_ci}
324115cd2caSopenharmony_ci
325115cd2caSopenharmony_civoid ContactAbilityTest::MergeColumns(
326115cd2caSopenharmony_ci    std::vector<std::string> &columns, std::vector<std::string> &columnsInt, std::vector<std::string> &columnsStr)
327115cd2caSopenharmony_ci{
328115cd2caSopenharmony_ci    int columnsIntSize = columnsInt.size();
329115cd2caSopenharmony_ci    for (int i = 0; i < columnsIntSize; i++) {
330115cd2caSopenharmony_ci        columns.push_back(columnsInt[i]);
331115cd2caSopenharmony_ci    }
332115cd2caSopenharmony_ci    int columnsStrSize = columnsStr.size();
333115cd2caSopenharmony_ci    for (int i = 0; i < columnsStrSize; i++) {
334115cd2caSopenharmony_ci        columns.push_back(columnsStr[i]);
335115cd2caSopenharmony_ci    }
336115cd2caSopenharmony_ci}
337115cd2caSopenharmony_ci
338115cd2caSopenharmony_ci/**
339115cd2caSopenharmony_ci * @brief get ValuesBucket
340115cd2caSopenharmony_ci * @params columnsStart column start index
341115cd2caSopenharmony_ci * @params columnsEnd column end index
342115cd2caSopenharmony_ci * @return ValuesBucket
343115cd2caSopenharmony_ci */
344115cd2caSopenharmony_ciOHOS::DataShare::DataShareValuesBucket ContactAbilityTest::GetAllColumnsValues(
345115cd2caSopenharmony_ci    std::vector<std::string> &columnsInt, std::vector<std::string> &columnsStr)
346115cd2caSopenharmony_ci{
347115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket;
348115cd2caSopenharmony_ci    int randomInt = 0;
349115cd2caSopenharmony_ci    int columnsIntSize = columnsInt.size();
350115cd2caSopenharmony_ci    for (int i = 0; i < columnsIntSize; i++) {
351115cd2caSopenharmony_ci        randomInt = ContactsRand();
352115cd2caSopenharmony_ci        HILOG_INFO("rand=%{public}d", randomInt);
353115cd2caSopenharmony_ci        valuesBucket.Put(columnsInt[i], randomInt);
354115cd2caSopenharmony_ci    }
355115cd2caSopenharmony_ci    std::string randomStr = "";
356115cd2caSopenharmony_ci    int columnsStringSize = columnsStr.size();
357115cd2caSopenharmony_ci    for (int i = 0; i < columnsStringSize; i++) {
358115cd2caSopenharmony_ci        randomStr = columnsStr[i] + std::to_string(ContactsRand());
359115cd2caSopenharmony_ci        valuesBucket.Put(columnsStr[i], randomStr);
360115cd2caSopenharmony_ci    }
361115cd2caSopenharmony_ci
362115cd2caSopenharmony_ci    return valuesBucket;
363115cd2caSopenharmony_ci}
364115cd2caSopenharmony_ci
365115cd2caSopenharmony_civoid ContactAbilityTest::ClearContacts()
366115cd2caSopenharmony_ci{
367115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
368115cd2caSopenharmony_ci    OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT);
369115cd2caSopenharmony_ci    predicates.NotEqualTo("id", "0");
370115cd2caSopenharmony_ci    predicates.And();
371115cd2caSopenharmony_ci    predicates.EqualTo("is_deleted", "0");
372115cd2caSopenharmony_ci    contactsDataAbility.Delete(uriRawContact, predicates);
373115cd2caSopenharmony_ci    int time = 1000;
374115cd2caSopenharmony_ci    std::chrono::milliseconds dura(time);
375115cd2caSopenharmony_ci    std::this_thread::sleep_for(dura);
376115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
377115cd2caSopenharmony_ci    OHOS::Uri uriRawContactComplete(ContactsUri::DELETED_RAW_CONTACT);
378115cd2caSopenharmony_ci    predicates2.NotEqualTo("id", "0");
379115cd2caSopenharmony_ci    contactsDataAbility.Delete(uriRawContactComplete, predicates2);
380115cd2caSopenharmony_ci}
381115cd2caSopenharmony_ci
382115cd2caSopenharmony_ci/*
383115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_100
384115cd2caSopenharmony_ci * @tc.name    Add the basic information of a single contact and verify whether the insertion is successful
385115cd2caSopenharmony_ci * @tc.desc    New capabilities for basic contact data
386115cd2caSopenharmony_ci * @tc.level   Level1
387115cd2caSopenharmony_ci * @tc.size    MediumTest
388115cd2caSopenharmony_ci * @tc.type    Function
389115cd2caSopenharmony_ci */
390115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_100, testing::ext::TestSize.Level1)
391115cd2caSopenharmony_ci{
392115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Insert_test_100 is starting! ---");
393115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket values;
394115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("liming", values);
395115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_100 : rawContactId = %{public}ld", rawContactId);
396115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
397115cd2caSopenharmony_ci
398115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
399115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactId));
400115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
401115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, values, "contact_Insert_test_100");
402115cd2caSopenharmony_ci    ClearContacts();
403115cd2caSopenharmony_ci}
404115cd2caSopenharmony_ci
405115cd2caSopenharmony_ci/*
406115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_200
407115cd2caSopenharmony_ci * @tc.name    Add the basic information of multiple contacts and verify whether the insertion is successful
408115cd2caSopenharmony_ci * @tc.desc    New capabilities for basic contact data
409115cd2caSopenharmony_ci * @tc.level   Level1
410115cd2caSopenharmony_ci * @tc.size    MediumTest
411115cd2caSopenharmony_ci * @tc.type    Function
412115cd2caSopenharmony_ci */
413115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_200, testing::ext::TestSize.Level1)
414115cd2caSopenharmony_ci{
415115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Insert_test_200 is starting! ---");
416115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket values;
417115cd2caSopenharmony_ci    int64_t rawContactIdOne = RawContactInsert("xiaoqian", values);
418115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_200 : rawContactIdOne = %{public}ld", rawContactIdOne);
419115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdOne, 0);
420115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
421115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactIdOne));
422115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
423115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, values, "contact_Insert_test_200");
424115cd2caSopenharmony_ci    values.Clear();
425115cd2caSopenharmony_ci
426115cd2caSopenharmony_ci    int64_t rawContactIdTwo = RawContactInsert("xiaowang", values);
427115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_200 : rawContactIdTwo = %{public}ld", rawContactIdTwo);
428115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdTwo, 0);
429115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactIdTwo));
430115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, values, "contact_Insert_test_200");
431115cd2caSopenharmony_ci
432115cd2caSopenharmony_ci    int64_t rawContactIdThree = RawContactInsert("xiaozhou", values);
433115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_200 : rawContactIdThree = %{public}ld", rawContactIdThree);
434115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdThree, 0);
435115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
436115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactIdThree));
437115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates2, values, "contact_Insert_test_200");
438115cd2caSopenharmony_ci    ClearContacts();
439115cd2caSopenharmony_ci}
440115cd2caSopenharmony_ci
441115cd2caSopenharmony_ci/*
442115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_300
443115cd2caSopenharmony_ci * @tc.name    Add a full field data to the raw_contact table and verify whether the insertion is successful
444115cd2caSopenharmony_ci * @tc.desc    Added ability to raw_contact
445115cd2caSopenharmony_ci * @tc.level   Level1
446115cd2caSopenharmony_ci * @tc.size    MediumTest
447115cd2caSopenharmony_ci * @tc.type    Function
448115cd2caSopenharmony_ci */
449115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_300, testing::ext::TestSize.Level1)
450115cd2caSopenharmony_ci{
451115cd2caSopenharmony_ci    HILOG_INFO("-----contact_Insert_test_300 is starting!-----");
452115cd2caSopenharmony_ci    std::vector<std::string> columnsInt;
453115cd2caSopenharmony_ci    std::vector<std::string> columnsStr;
454115cd2caSopenharmony_ci    std::vector<std::string> columns;
455115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
456115cd2caSopenharmony_ci    GetAllRawContactColumns(columnsInt, columnsStr);
457115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
458115cd2caSopenharmony_ci    int rawId = RawContactInsertValues(valuesBucket);
459115cd2caSopenharmony_ci    EXPECT_GT(rawId, 0);
460115cd2caSopenharmony_ci
461115cd2caSopenharmony_ci    MergeColumns(columns, columnsInt, columnsStr);
462115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
463115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawId));
464115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(rawContacts, columns, predicates);
465115cd2caSopenharmony_ci
466115cd2caSopenharmony_ci    // resultSet count 1
467115cd2caSopenharmony_ci    int rowCount = -1;
468115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
469115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
470115cd2caSopenharmony_ci    CheckResultSet(valuesBucket, resultSet, "contact_Insert_test_300");
471115cd2caSopenharmony_ci    ClearContacts();
472115cd2caSopenharmony_ci}
473115cd2caSopenharmony_ci
474115cd2caSopenharmony_ci/*
475115cd2caSopenharmony_ci* @tc.number  contact_Insert_test_400
476115cd2caSopenharmony_ci* @tc.name    Add the basic information of a single contact and verify whether the insertion is successful
477115cd2caSopenharmony_ci                (name, name Pinyin, Pinyin name, company, position, favorite or not)
478115cd2caSopenharmony_ci* @tc.desc    Add basic information of a single contact
479115cd2caSopenharmony_ci* @tc.level   Level1
480115cd2caSopenharmony_ci* @tc.size    MediumTest
481115cd2caSopenharmony_ci* @tc.type    Function
482115cd2caSopenharmony_ci*/
483115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_400, testing::ext::TestSize.Level1)
484115cd2caSopenharmony_ci{
485115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Insert_test_400 is starting! ---");
486115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket values;
487115cd2caSopenharmony_ci    std::vector<std::string> vectorValue;
488115cd2caSopenharmony_ci    vectorValue.push_back("liming");
489115cd2caSopenharmony_ci    vectorValue.push_back("tiantianxaingshang");
490115cd2caSopenharmony_ci    vectorValue.push_back("Test");
491115cd2caSopenharmony_ci    vectorValue.push_back("liming||lm");
492115cd2caSopenharmony_ci    int64_t rawContactId = RawContactExpandInsert(vectorValue, 1, values);
493115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_400 : rawContactId = %{public}ld", rawContactId);
494115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
495115cd2caSopenharmony_ci
496115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
497115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactId));
498115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
499115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, values, "contact_Insert_test_400");
500115cd2caSopenharmony_ci    ClearContacts();
501115cd2caSopenharmony_ci}
502115cd2caSopenharmony_ci
503115cd2caSopenharmony_ci/*
504115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_500
505115cd2caSopenharmony_ci * @tc.name    Add individual contact details and verify that the insertion was successful
506115cd2caSopenharmony_ci *              (including name, nickname, company, position, mobile phone number and email address)
507115cd2caSopenharmony_ci * @tc.desc    New ability to contact detailed data
508115cd2caSopenharmony_ci * @tc.level   Level1
509115cd2caSopenharmony_ci * @tc.size    MediumTest
510115cd2caSopenharmony_ci * @tc.type    Function
511115cd2caSopenharmony_ci */
512115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_500, testing::ext::TestSize.Level1)
513115cd2caSopenharmony_ci{
514115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Insert_test_500 is starting! ---");
515115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
516115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
517115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("ligang", rawContactValues);
518115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_500 : rawContactId = %{public}ld", rawContactId);
519115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
520115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket values;
521115cd2caSopenharmony_ci    int64_t contactDataIdOne = ContactDataInsert(rawContactId, "name", "ligang", "", values);
522115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_500 : contactDataIdOne = %{public}ld", contactDataIdOne);
523115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdOne, 0);
524115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
525115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contactDataIdOne));
526115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates, values, "contact_Insert_test_500");
527115cd2caSopenharmony_ci    values.Clear();
528115cd2caSopenharmony_ci
529115cd2caSopenharmony_ci    int64_t contactDataIdTwo = ContactDataInsert(rawContactId, "organization", "tiantianxaingshang", "Test", values);
530115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_500 : contactDataIdTwo = %{public}ld", contactDataIdTwo);
531115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdTwo, 0);
532115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
533115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(contactDataIdTwo));
534115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates2, values, "contact_Insert_test_500");
535115cd2caSopenharmony_ci    values.Clear();
536115cd2caSopenharmony_ci
537115cd2caSopenharmony_ci    int64_t contactDataIdThree = ContactDataInsert(rawContactId, "email", "8523@163.com", "", values);
538115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_500 : contactDataIdThree = %{public}ld", contactDataIdThree);
539115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdThree, 0);
540115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
541115cd2caSopenharmony_ci    predicates3.EqualTo("id", std::to_string(contactDataIdThree));
542115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates3, values, "contact_Insert_test_500");
543115cd2caSopenharmony_ci    values.Clear();
544115cd2caSopenharmony_ci
545115cd2caSopenharmony_ci    int64_t contactDataIdFour = ContactDataInsert(rawContactId, "phone", "188520314", "", values);
546115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_500 : contactDataIdFour = %{public}ld", contactDataIdFour);
547115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdFour, 0);
548115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates4;
549115cd2caSopenharmony_ci    predicates4.EqualTo("id", std::to_string(contactDataIdFour));
550115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates4, values, "contact_Insert_test_500");
551115cd2caSopenharmony_ci    values.Clear();
552115cd2caSopenharmony_ci
553115cd2caSopenharmony_ci    int64_t contactDataIdFive = ContactDataInsert(rawContactId, "nickname", "xiaogang", "", values);
554115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_500 : contactDataIdFive = %{public}ld", contactDataIdFive);
555115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdFive, 0);
556115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates5;
557115cd2caSopenharmony_ci    predicates5.EqualTo("id", std::to_string(contactDataIdFive));
558115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates5, values, "contact_Insert_test_500");
559115cd2caSopenharmony_ci    values.Clear();
560115cd2caSopenharmony_ci    ClearContacts();
561115cd2caSopenharmony_ci}
562115cd2caSopenharmony_ci
563115cd2caSopenharmony_ci/*
564115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_600
565115cd2caSopenharmony_ci * @tc.name    Add individual contact details and verify that the insertion was successful
566115cd2caSopenharmony_ci *              (including home, group, aim, notes, and URL)
567115cd2caSopenharmony_ci * @tc.desc    New ability to contact detailed data
568115cd2caSopenharmony_ci * @tc.level   Level1
569115cd2caSopenharmony_ci * @tc.size    MediumTest
570115cd2caSopenharmony_ci * @tc.type    Function
571115cd2caSopenharmony_ci */
572115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_600, testing::ext::TestSize.Level1)
573115cd2caSopenharmony_ci{
574115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Insert_test_600 is starting! ---");
575115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
576115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket values;
577115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("chengshao", values);
578115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_600 : rawContactId = %{public}ld", rawContactId);
579115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
580115cd2caSopenharmony_ci    values.Clear();
581115cd2caSopenharmony_ci
582115cd2caSopenharmony_ci    int64_t contactDataIdOne = ContactDataInsert(rawContactId, "postal_address", "NanJingCity", "", values);
583115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_600 : contactDataIdOne = %{public}ld", contactDataIdOne);
584115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdOne, 0);
585115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
586115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contactDataIdOne));
587115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates, values, "contact_Insert_test_600");
588115cd2caSopenharmony_ci    values.Clear();
589115cd2caSopenharmony_ci
590115cd2caSopenharmony_ci    int64_t contactDataIdTwo = ContactDataInsert(rawContactId, "group_membership", "1", "", values);
591115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_600 : contactDataIdTwo = %{public}ld", contactDataIdTwo);
592115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdTwo, 0);
593115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
594115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(contactDataIdTwo));
595115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates2, values, "contact_Insert_test_600");
596115cd2caSopenharmony_ci    values.Clear();
597115cd2caSopenharmony_ci
598115cd2caSopenharmony_ci    int64_t contactDataIdThree = ContactDataInsert(rawContactId, "note", "dalao", "", values);
599115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_600 : contactDataIdThree = %{public}ld", contactDataIdThree);
600115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
601115cd2caSopenharmony_ci    predicates3.EqualTo("id", std::to_string(contactDataIdThree));
602115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates3, values, "contact_Insert_test_600");
603115cd2caSopenharmony_ci    values.Clear();
604115cd2caSopenharmony_ci
605115cd2caSopenharmony_ci    int64_t contactDataIdFour = ContactDataInsert(rawContactId, "im", "aaaa", "", values);
606115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_600 : contactDataIdFour = %{public}ld", contactDataIdFour);
607115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdFour, 0);
608115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates4;
609115cd2caSopenharmony_ci    predicates4.EqualTo("id", std::to_string(contactDataIdFour));
610115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates4, values, "contact_Insert_test_600");
611115cd2caSopenharmony_ci    values.Clear();
612115cd2caSopenharmony_ci
613115cd2caSopenharmony_ci    int64_t contactDataIdFive = ContactDataInsert(rawContactId, "website", "www.48236.com", "", values);
614115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_600 : contactDataIdFive = %{public}ld", contactDataIdFive);
615115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdFive, 0);
616115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates5;
617115cd2caSopenharmony_ci    predicates5.EqualTo("id", std::to_string(contactDataIdFive));
618115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates5, values, "contact_Insert_test_600");
619115cd2caSopenharmony_ci    values.Clear();
620115cd2caSopenharmony_ci    ClearContacts();
621115cd2caSopenharmony_ci}
622115cd2caSopenharmony_ci
623115cd2caSopenharmony_ci/*
624115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_700
625115cd2caSopenharmony_ci * @tc.name    Add individual contact details and verify that the insertion was successful
626115cd2caSopenharmony_ci *              (including phone ring tones, birthdays, and assistants)
627115cd2caSopenharmony_ci * @tc.desc    New ability to contact detailed data
628115cd2caSopenharmony_ci * @tc.level   Level1
629115cd2caSopenharmony_ci * @tc.size    MediumTest
630115cd2caSopenharmony_ci * @tc.type    Function
631115cd2caSopenharmony_ci */
632115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_700, testing::ext::TestSize.Level1)
633115cd2caSopenharmony_ci{
634115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Insert_test_700 is starting! ---");
635115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
636115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket values;
637115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("yanshao", values);
638115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_700 : rawContactId = %{public}ld", rawContactId);
639115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
640115cd2caSopenharmony_ci    values.Clear();
641115cd2caSopenharmony_ci
642115cd2caSopenharmony_ci    int64_t contactDataIdOne = ContactDataInsert(rawContactId, "contact_event", "19960229", "", values);
643115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_700 : contactDataIdOne = %{public}ld", contactDataIdOne);
644115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdOne, 0);
645115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
646115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contactDataIdOne));
647115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates, values, "contact_Insert_test_700");
648115cd2caSopenharmony_ci    values.Clear();
649115cd2caSopenharmony_ci
650115cd2caSopenharmony_ci    int64_t contactDataIdTwo = ContactDataInsert(rawContactId, "relation", "Secretary", "", values);
651115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_700 : contactDataIdTwo = %{public}ld", contactDataIdTwo);
652115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdTwo, 0);
653115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
654115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(contactDataIdTwo));
655115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates2, values, "contact_Insert_test_700");
656115cd2caSopenharmony_ci    values.Clear();
657115cd2caSopenharmony_ci
658115cd2caSopenharmony_ci    int64_t contactDataIdThree = ContactDataInsert(rawContactId, "contact_misc", "1314", "", values);
659115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_700 : contactDataIdThree = %{public}ld", contactDataIdThree);
660115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdThree, 0);
661115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
662115cd2caSopenharmony_ci    predicates3.EqualTo("id", std::to_string(contactDataIdThree));
663115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates3, values, "contact_Insert_test_700");
664115cd2caSopenharmony_ci    values.Clear();
665115cd2caSopenharmony_ci    ClearContacts();
666115cd2caSopenharmony_ci}
667115cd2caSopenharmony_ci
668115cd2caSopenharmony_ci/*
669115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_800
670115cd2caSopenharmony_ci * @tc.name    Add all details of a single contact and verify whether the insertion is successful
671115cd2caSopenharmony_ci *              (name, mobile number, company, position, nickname, email, home, remarks, aim, birthday, website,
672115cd2caSopenharmony_ci * assistant, group, phone ring)
673115cd2caSopenharmony_ci * @tc.desc    New ability to contact detailed data
674115cd2caSopenharmony_ci * @tc.level   Level1
675115cd2caSopenharmony_ci * @tc.size    MediumTest
676115cd2caSopenharmony_ci * @tc.type    Function
677115cd2caSopenharmony_ci */
678115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_800, testing::ext::TestSize.Level1)
679115cd2caSopenharmony_ci{
680115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Insert_test_800 is starting! ---");
681115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawValuesBucket;
682115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("insert_detail_contactdata", rawValuesBucket);
683115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
684115cd2caSopenharmony_ci
685115cd2caSopenharmony_ci    std::vector<std::string> columns;
686115cd2caSopenharmony_ci    std::vector<std::string> columnQuery;
687115cd2caSopenharmony_ci    columnQuery.push_back("detail_info");
688115cd2caSopenharmony_ci    GetDetailsContactDataColumns(columns);
689115cd2caSopenharmony_ci
690115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket;
691115cd2caSopenharmony_ci
692115cd2caSopenharmony_ci    std::string randomStr = "";
693115cd2caSopenharmony_ci    std::string tableName = ContactTabName::CONTACT_DATA;
694115cd2caSopenharmony_ci    int columnSize = columns.size();
695115cd2caSopenharmony_ci    for (int i = 0; i < columnSize; i++) {
696115cd2caSopenharmony_ci        randomStr = columns[i] + std::to_string(ContactsRand());
697115cd2caSopenharmony_ci        valuesBucket.Put("raw_contact_id", rawContactId);
698115cd2caSopenharmony_ci        valuesBucket.Put("content_type", columns[i]);
699115cd2caSopenharmony_ci        valuesBucket.Put("detail_info", randomStr);
700115cd2caSopenharmony_ci        int contactDataId = ContactDataInsertValues(valuesBucket);
701115cd2caSopenharmony_ci        EXPECT_GT(contactDataId, 0);
702115cd2caSopenharmony_ci
703115cd2caSopenharmony_ci        OHOS::DataShare::DataSharePredicates predicates;
704115cd2caSopenharmony_ci        predicates.EqualTo("id", std::to_string(contactDataId));
705115cd2caSopenharmony_ci        std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
706115cd2caSopenharmony_ci            ContactQuery(tableName, columnQuery, predicates);
707115cd2caSopenharmony_ci        int rowCount = -1;
708115cd2caSopenharmony_ci        resultSet->GetRowCount(rowCount);
709115cd2caSopenharmony_ci        EXPECT_EQ(1, rowCount);
710115cd2caSopenharmony_ci        CheckResultSet(valuesBucket, resultSet, "contact_Insert_test_800");
711115cd2caSopenharmony_ci        valuesBucket.Clear();
712115cd2caSopenharmony_ci    }
713115cd2caSopenharmony_ci    ClearContacts();
714115cd2caSopenharmony_ci}
715115cd2caSopenharmony_ci
716115cd2caSopenharmony_ci/*
717115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_900
718115cd2caSopenharmony_ci * @tc.name    Add multiple contact details and verify that the insertion was successful
719115cd2caSopenharmony_ci * @tc.desc    New ability to contact detailed data
720115cd2caSopenharmony_ci * @tc.level   Level1
721115cd2caSopenharmony_ci * @tc.size    MediumTest
722115cd2caSopenharmony_ci * @tc.type    Function
723115cd2caSopenharmony_ci */
724115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_900, testing::ext::TestSize.Level1)
725115cd2caSopenharmony_ci{
726115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Insert_test_900 is starting! ---");
727115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
728115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket values;
729115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("xiaoming", values);
730115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
731115cd2caSopenharmony_ci    values.Clear();
732115cd2caSopenharmony_ci
733115cd2caSopenharmony_ci    int64_t contactDataIdOne = ContactDataInsert(rawContactId, "name", "xiaoming", "", values);
734115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdOne, 0);
735115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
736115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contactDataIdOne));
737115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates, values, "contact_Insert_test_900");
738115cd2caSopenharmony_ci    values.Clear();
739115cd2caSopenharmony_ci
740115cd2caSopenharmony_ci    int64_t contactDataIdTwo = ContactDataInsert(rawContactId, "organization", "tiantianxaingshang", "Test", values);
741115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdTwo, 0);
742115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
743115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(contactDataIdTwo));
744115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates2, values, "contact_Insert_test_900");
745115cd2caSopenharmony_ci    values.Clear();
746115cd2caSopenharmony_ci
747115cd2caSopenharmony_ci    rawContactId = RawContactInsert("lihong", values);
748115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_900 : rawContactId = %{public}ld", rawContactId);
749115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
750115cd2caSopenharmony_ci    values.Clear();
751115cd2caSopenharmony_ci
752115cd2caSopenharmony_ci    int64_t contactDataIdThree = ContactDataInsert(rawContactId, "name", "lihong", "", values);
753115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_900 : contactDataIdThree = %{public}ld", contactDataIdThree);
754115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdThree, 0);
755115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
756115cd2caSopenharmony_ci    predicates3.EqualTo("id", std::to_string(contactDataIdThree));
757115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates3, values, "contact_Insert_test_900");
758115cd2caSopenharmony_ci    values.Clear();
759115cd2caSopenharmony_ci
760115cd2caSopenharmony_ci    int64_t contactDataIdFour = ContactDataInsert(rawContactId, "organization", "tiantianxaingshang", "Test", values);
761115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_900 : contactDataIdFour = %{public}ld", contactDataIdFour);
762115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdFour, 0);
763115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates4;
764115cd2caSopenharmony_ci    predicates4.EqualTo("id", std::to_string(contactDataIdFour));
765115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates4, values, "contact_Insert_test_900");
766115cd2caSopenharmony_ci    values.Clear();
767115cd2caSopenharmony_ci    ClearContacts();
768115cd2caSopenharmony_ci}
769115cd2caSopenharmony_ci
770115cd2caSopenharmony_ci/*
771115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_1000
772115cd2caSopenharmony_ci * @tc.name    Add a full field data to the contact_data table and verify that the insertion was successful
773115cd2caSopenharmony_ci * @tc.desc    Added ability to contact_data
774115cd2caSopenharmony_ci * @tc.level   Level1
775115cd2caSopenharmony_ci * @tc.size    MediumTest
776115cd2caSopenharmony_ci * @tc.type    Function
777115cd2caSopenharmony_ci */
778115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_1000, testing::ext::TestSize.Level1)
779115cd2caSopenharmony_ci{
780115cd2caSopenharmony_ci    HILOG_INFO("-----contact_Insert_test_1000 is starting!-----");
781115cd2caSopenharmony_ci    std::vector<std::string> columnsInt;
782115cd2caSopenharmony_ci    std::vector<std::string> columnsStr;
783115cd2caSopenharmony_ci    std::vector<std::string> columns;
784115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
785115cd2caSopenharmony_ci    GetAllContactDataColumns(columnsInt, columnsStr);
786115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
787115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
788115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("feimaomao", rawContactValues);
789115cd2caSopenharmony_ci    valuesBucket.Put("raw_contact_id", rawContactId);
790115cd2caSopenharmony_ci    // type 6 is name
791115cd2caSopenharmony_ci    valuesBucket.Put("type_id", 6);
792115cd2caSopenharmony_ci    int ContactDataId = ContactDataInsertValues(valuesBucket);
793115cd2caSopenharmony_ci    EXPECT_GT(ContactDataId, 0);
794115cd2caSopenharmony_ci
795115cd2caSopenharmony_ci    MergeColumns(columns, columnsInt, columnsStr);
796115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
797115cd2caSopenharmony_ci    predicates.EqualTo("raw_contact_id", std::to_string(rawContactId));
798115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(contactData, columns, predicates);
799115cd2caSopenharmony_ci    CheckResultSet(valuesBucket, resultSet, "contact_Insert_test_1000");
800115cd2caSopenharmony_ci    // resultSet count 1
801115cd2caSopenharmony_ci    int rowCount = -1;
802115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
803115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
804115cd2caSopenharmony_ci    CheckResultSet(valuesBucket, resultSet, "contact_Insert_test_1000");
805115cd2caSopenharmony_ci    ClearContacts();
806115cd2caSopenharmony_ci}
807115cd2caSopenharmony_ci
808115cd2caSopenharmony_ci/*
809115cd2caSopenharmony_ci * @tc.number  contact_Update_test_1100
810115cd2caSopenharmony_ci * @tc.name    Modify several basic information of the contact, and verify whether the modification is successful
811115cd2caSopenharmony_ci *              (including name, name Pinyin, Pinyin name, company, position and favorite)
812115cd2caSopenharmony_ci * @tc.desc    Contacts basic data table update ability
813115cd2caSopenharmony_ci * @tc.level   Level1
814115cd2caSopenharmony_ci * @tc.size    MediumTest
815115cd2caSopenharmony_ci * @tc.type    Function
816115cd2caSopenharmony_ci */
817115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_1100, testing::ext::TestSize.Level1)
818115cd2caSopenharmony_ci{
819115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_1100 is starting! ---");
820115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket values;
821115cd2caSopenharmony_ci    std::vector<std::string> vectorValue;
822115cd2caSopenharmony_ci    vectorValue.push_back("zhangming");
823115cd2caSopenharmony_ci    vectorValue.push_back("tiantianxaingshang");
824115cd2caSopenharmony_ci    vectorValue.push_back("Test");
825115cd2caSopenharmony_ci    vectorValue.push_back("zhangming||zm");
826115cd2caSopenharmony_ci    int64_t rawContactId = RawContactExpandInsert(vectorValue, 1, values);
827115cd2caSopenharmony_ci    HILOG_INFO("contact_Update_test_1100 : rawContactId = %{public}ld", rawContactId);
828115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
829115cd2caSopenharmony_ci
830115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
831115cd2caSopenharmony_ci    updateValues.Put("display_name", "dongming");
832115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
833115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactId));
834115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
835115cd2caSopenharmony_ci    int updateCode = ContactUpdate(rawContacts, updateValues, predicates);
836115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
837115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, updateValues, "contact_Update_test_1100");
838115cd2caSopenharmony_ci
839115cd2caSopenharmony_ci    updateValues.Clear();
840115cd2caSopenharmony_ci    updateValues.Put("company", "XXXX");
841115cd2caSopenharmony_ci    updateCode = ContactUpdate(rawContacts, updateValues, predicates);
842115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
843115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, updateValues, "contact_Update_test_1100");
844115cd2caSopenharmony_ci
845115cd2caSopenharmony_ci    updateValues.Clear();
846115cd2caSopenharmony_ci    updateValues.Put("position", "Secretary");
847115cd2caSopenharmony_ci    updateCode = ContactUpdate(rawContacts, updateValues, predicates);
848115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
849115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, updateValues, "contact_Update_test_1100");
850115cd2caSopenharmony_ci
851115cd2caSopenharmony_ci    updateValues.Clear();
852115cd2caSopenharmony_ci    updateValues.Put("favorite", "0");
853115cd2caSopenharmony_ci    updateCode = ContactUpdate(rawContacts, updateValues, predicates);
854115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
855115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, updateValues, "contact_Update_test_1100");
856115cd2caSopenharmony_ci
857115cd2caSopenharmony_ci    updateValues.Clear();
858115cd2caSopenharmony_ci    updateValues.Put("phonetic_name", "dongming||dm");
859115cd2caSopenharmony_ci    updateCode = ContactUpdate(rawContacts, updateValues, predicates);
860115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
861115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, updateValues, "contact_Update_test_1100");
862115cd2caSopenharmony_ci    ClearContacts();
863115cd2caSopenharmony_ci}
864115cd2caSopenharmony_ci
865115cd2caSopenharmony_ci/*
866115cd2caSopenharmony_ci * @tc.number  contact_Update_test_1200
867115cd2caSopenharmony_ci * @tc.name    Modify the basic information of multiple contacts and verify whether the modification is successful
868115cd2caSopenharmony_ci * @tc.desc    Contacts basic data table update ability
869115cd2caSopenharmony_ci * @tc.level   Level1
870115cd2caSopenharmony_ci * @tc.size    MediumTest
871115cd2caSopenharmony_ci * @tc.type    Function
872115cd2caSopenharmony_ci */
873115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_1200, testing::ext::TestSize.Level1)
874115cd2caSopenharmony_ci{
875115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_1200 is starting! ---");
876115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket values;
877115cd2caSopenharmony_ci    int64_t rawContactIdOne = RawContactInsert("zhangming", values);
878115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdOne, 0);
879115cd2caSopenharmony_ci    values.Clear();
880115cd2caSopenharmony_ci
881115cd2caSopenharmony_ci    int64_t rawContactIdTwo = RawContactInsert("ligang", values);
882115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdTwo, 0);
883115cd2caSopenharmony_ci    values.Clear();
884115cd2caSopenharmony_ci
885115cd2caSopenharmony_ci    int64_t rawContactIdThree = RawContactInsert("wanghong", values);
886115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdThree, 0);
887115cd2caSopenharmony_ci    values.Clear();
888115cd2caSopenharmony_ci
889115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
890115cd2caSopenharmony_ci    updateValues.Put("display_name", "dongming");
891115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
892115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactIdOne));
893115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
894115cd2caSopenharmony_ci    int updateCode = ContactUpdate(rawContacts, updateValues, predicates);
895115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
896115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, updateValues, "contact_Update_test_1200");
897115cd2caSopenharmony_ci
898115cd2caSopenharmony_ci    updateValues.Clear();
899115cd2caSopenharmony_ci    updateValues.Put("display_name", std::string("laoliu"));
900115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
901115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(rawContactIdThree));
902115cd2caSopenharmony_ci    updateCode = ContactUpdate(rawContacts, updateValues, predicates2);
903115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
904115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates2, updateValues, "contact_Update_test_1200");
905115cd2caSopenharmony_ci    ClearContacts();
906115cd2caSopenharmony_ci}
907115cd2caSopenharmony_ci
908115cd2caSopenharmony_ci/*
909115cd2caSopenharmony_ci * @tc.number  contact_Update_test_1300
910115cd2caSopenharmony_ci * @tc.name    Update the full field data of the raw_contact table and verify whether the modification is successful
911115cd2caSopenharmony_ci * @tc.desc    Support all raw_contact update capability
912115cd2caSopenharmony_ci * @tc.level   Level1
913115cd2caSopenharmony_ci * @tc.size    MediumTest
914115cd2caSopenharmony_ci * @tc.type    Function
915115cd2caSopenharmony_ci */
916115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_1300, testing::ext::TestSize.Level1)
917115cd2caSopenharmony_ci{
918115cd2caSopenharmony_ci    HILOG_INFO("-----contact_Update_test_1300 is starting!-----");
919115cd2caSopenharmony_ci    std::vector<std::string> columns;
920115cd2caSopenharmony_ci    std::vector<std::string> columnsInt;
921115cd2caSopenharmony_ci    std::vector<std::string> columnsStr;
922115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
923115cd2caSopenharmony_ci    GetAllRawContactColumns(columnsInt, columnsStr);
924115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
925115cd2caSopenharmony_ci    int rawId = RawContactInsertValues(valuesBucket);
926115cd2caSopenharmony_ci    EXPECT_GT(rawId, 0);
927115cd2caSopenharmony_ci
928115cd2caSopenharmony_ci    MergeColumns(columns, columnsInt, columnsStr);
929115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
930115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawId));
931115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSetOne = ContactQuery(rawContacts, columns, predicates);
932115cd2caSopenharmony_ci    CheckResultSet(valuesBucket, resultSetOne, "contact_Update_test_1300");
933115cd2caSopenharmony_ci
934115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket upDateValuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
935115cd2caSopenharmony_ci    int upDateCode = ContactUpdate(rawContacts, upDateValuesBucket, predicates);
936115cd2caSopenharmony_ci    EXPECT_EQ(upDateCode, 0);
937115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(rawContacts, columns, predicates);
938115cd2caSopenharmony_ci
939115cd2caSopenharmony_ci    // resultSet count 1
940115cd2caSopenharmony_ci    int rowCount = -1;
941115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
942115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
943115cd2caSopenharmony_ci    CheckResultSet(upDateValuesBucket, resultSet, "contact_Update_test_1300");
944115cd2caSopenharmony_ci    ClearContacts();
945115cd2caSopenharmony_ci}
946115cd2caSopenharmony_ci
947115cd2caSopenharmony_ci/*
948115cd2caSopenharmony_ci * @tc.number  contact_Update_test_1400
949115cd2caSopenharmony_ci * @tc.name    Modify the details of a single contact and verify whether the modification is successful
950115cd2caSopenharmony_ci *              (name, company, position and email address)
951115cd2caSopenharmony_ci * @tc.desc    The ability to update the contact detail data table
952115cd2caSopenharmony_ci * @tc.level   Level1
953115cd2caSopenharmony_ci * @tc.size    MediumTest
954115cd2caSopenharmony_ci * @tc.type    Function
955115cd2caSopenharmony_ci */
956115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_1400, testing::ext::TestSize.Level1)
957115cd2caSopenharmony_ci{
958115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_1400 is starting! ---");
959115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket values;
960115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("ligang", values);
961115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
962115cd2caSopenharmony_ci    values.Clear();
963115cd2caSopenharmony_ci
964115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesOne;
965115cd2caSopenharmony_ci    int64_t contactDataIdOne = ContactDataInsert(rawContactId, "name", "ligang", "", valuesOne);
966115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdOne, 0);
967115cd2caSopenharmony_ci
968115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesTwo;
969115cd2caSopenharmony_ci    int64_t contactDataIdTwo = ContactDataInsert(rawContactId, "organization", "tiantianxaingshang", "Test", valuesTwo);
970115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdTwo, 0);
971115cd2caSopenharmony_ci
972115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesThree;
973115cd2caSopenharmony_ci    int64_t contactDataIdThree = ContactDataInsert(rawContactId, "email", "8523@163.com", "", valuesThree);
974115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdThree, 0);
975115cd2caSopenharmony_ci
976115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
977115cd2caSopenharmony_ci    updateValues.Put("detail_info", "dongming");
978115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
979115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contactDataIdOne));
980115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
981115cd2caSopenharmony_ci    int updateCode = ContactUpdate(contactData, updateValues, predicates);
982115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
983115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates, updateValues, "contact_Update_test_1400");
984115cd2caSopenharmony_ci
985115cd2caSopenharmony_ci    updateValues.Clear();
986115cd2caSopenharmony_ci    updateValues.Put("detail_info", "vivo");
987115cd2caSopenharmony_ci    updateValues.Put("position", "Developer");
988115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
989115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(contactDataIdTwo));
990115cd2caSopenharmony_ci    updateCode = ContactUpdate(contactData, updateValues, predicates2);
991115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
992115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates2, updateValues, "contact_Update_test_1400");
993115cd2caSopenharmony_ci
994115cd2caSopenharmony_ci    updateValues.Clear();
995115cd2caSopenharmony_ci    updateValues.Put("detail_info", "1220369@qq.com");
996115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
997115cd2caSopenharmony_ci    predicates3.EqualTo("id", std::to_string(contactDataIdThree));
998115cd2caSopenharmony_ci    updateCode = ContactUpdate(contactData, updateValues, predicates3);
999115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1000115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates3, updateValues, "contact_Update_test_1400");
1001115cd2caSopenharmony_ci    ClearContacts();
1002115cd2caSopenharmony_ci}
1003115cd2caSopenharmony_ci
1004115cd2caSopenharmony_ci/*
1005115cd2caSopenharmony_ci * @tc.number  contact_Update_test_1500
1006115cd2caSopenharmony_ci * @tc.name    Modify the details of a single contact and verify that the modification is successful
1007115cd2caSopenharmony_ci *              (mobile phone number, address and nickname)
1008115cd2caSopenharmony_ci * @tc.desc    The ability to update the contact detail data table
1009115cd2caSopenharmony_ci * @tc.level   Level1
1010115cd2caSopenharmony_ci * @tc.size    MediumTest
1011115cd2caSopenharmony_ci * @tc.type    Function
1012115cd2caSopenharmony_ci */
1013115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_1500, testing::ext::TestSize.Level1)
1014115cd2caSopenharmony_ci{
1015115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_1500 is starting! ---");
1016115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
1017115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("xiaomi", rawContactValues);
1018115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
1019115cd2caSopenharmony_ci
1020115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValueOne;
1021115cd2caSopenharmony_ci    int64_t contactDataIdOne = ContactDataInsert(rawContactId, "phone", "1665230", "", contactDataValueOne);
1022115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdOne, 0);
1023115cd2caSopenharmony_ci
1024115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValueTwo;
1025115cd2caSopenharmony_ci    int64_t contactDataIdTwo = ContactDataInsert(rawContactId, "nickname", "xiaomi", "", contactDataValueTwo);
1026115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdTwo, 0);
1027115cd2caSopenharmony_ci
1028115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValueThree;
1029115cd2caSopenharmony_ci    int64_t contactDataIdThree =
1030115cd2caSopenharmony_ci        ContactDataInsert(rawContactId, "postal_address", "BeiJingFir", "", contactDataValueThree);
1031115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdThree, 0);
1032115cd2caSopenharmony_ci
1033115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
1034115cd2caSopenharmony_ci    updateValues.Put("detail_info", "33996652");
1035115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1036115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contactDataIdOne));
1037115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
1038115cd2caSopenharmony_ci    int updateCode = ContactUpdate(contactData, updateValues, predicates);
1039115cd2caSopenharmony_ci    HILOG_INFO("contact_Update_test_1500: updateCode = %{public}d", updateCode);
1040115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1041115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates, updateValues, "contact_Update_test_1500");
1042115cd2caSopenharmony_ci
1043115cd2caSopenharmony_ci    updateValues.Clear();
1044115cd2caSopenharmony_ci    updateValues.Put("detail_info", "mimi");
1045115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
1046115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(contactDataIdTwo));
1047115cd2caSopenharmony_ci    updateCode = ContactUpdate(contactData, updateValues, predicates2);
1048115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1049115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates2, updateValues, "contact_Update_test_1500");
1050115cd2caSopenharmony_ci
1051115cd2caSopenharmony_ci    updateValues.Clear();
1052115cd2caSopenharmony_ci    updateValues.Put("detail_info", "NanJIngGulou");
1053115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
1054115cd2caSopenharmony_ci    predicates3.EqualTo("id", std::to_string(contactDataIdThree));
1055115cd2caSopenharmony_ci    updateCode = ContactUpdate(contactData, updateValues, predicates3);
1056115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1057115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates3, updateValues, "contact_Update_test_1500");
1058115cd2caSopenharmony_ci    ClearContacts();
1059115cd2caSopenharmony_ci}
1060115cd2caSopenharmony_ci
1061115cd2caSopenharmony_ci/*
1062115cd2caSopenharmony_ci * @tc.number  contact_Update_test_1600
1063115cd2caSopenharmony_ci * @tc.name    Modify the details of individual contacts and verify whether the modification is successful
1064115cd2caSopenharmony_ci *              (remarks, goals and birthdays)
1065115cd2caSopenharmony_ci * @tc.desc    The ability to update the contact detail data table
1066115cd2caSopenharmony_ci * @tc.level   Level1
1067115cd2caSopenharmony_ci * @tc.size    MediumTest
1068115cd2caSopenharmony_ci * @tc.type    Function
1069115cd2caSopenharmony_ci */
1070115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_1600, testing::ext::TestSize.Level1)
1071115cd2caSopenharmony_ci{
1072115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_1600 is starting! ---");
1073115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
1074115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("xiaocai", rawContactValues);
1075115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
1076115cd2caSopenharmony_ci
1077115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValueOne;
1078115cd2caSopenharmony_ci    int64_t contactDataIdOne = ContactDataInsert(rawContactId, "note", "dalao", "", contactDataValueOne);
1079115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdOne, 0);
1080115cd2caSopenharmony_ci
1081115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValueTwo;
1082115cd2caSopenharmony_ci    int64_t contactDataIdTwo = ContactDataInsert(rawContactId, "im", "aaaaaa", "", contactDataValueTwo);
1083115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdTwo, 0);
1084115cd2caSopenharmony_ci
1085115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValueThree;
1086115cd2caSopenharmony_ci    int64_t contactDataIdThree =
1087115cd2caSopenharmony_ci        ContactDataInsert(rawContactId, "contact_event", "19820314", "", contactDataValueThree);
1088115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdThree, 0);
1089115cd2caSopenharmony_ci
1090115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
1091115cd2caSopenharmony_ci    updateValues.Put("detail_info", "God");
1092115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1093115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contactDataIdOne));
1094115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
1095115cd2caSopenharmony_ci    int updateCode = ContactUpdate(contactData, updateValues, predicates);
1096115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1097115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates, updateValues, "contact_Update_test_1600");
1098115cd2caSopenharmony_ci
1099115cd2caSopenharmony_ci    updateValues.Clear();
1100115cd2caSopenharmony_ci    updateValues.Put("detail_info", "bcade");
1101115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
1102115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(contactDataIdTwo));
1103115cd2caSopenharmony_ci    updateCode = ContactUpdate(contactData, updateValues, predicates2);
1104115cd2caSopenharmony_ci    HILOG_INFO("contact_Update_test_1600: updateCode = %{public}d", updateCode);
1105115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1106115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates2, updateValues, "contact_Update_test_1600");
1107115cd2caSopenharmony_ci
1108115cd2caSopenharmony_ci    updateValues.Clear();
1109115cd2caSopenharmony_ci    updateValues.Put("detail_info", "19820328");
1110115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
1111115cd2caSopenharmony_ci    predicates3.EqualTo("id", std::to_string(contactDataIdThree));
1112115cd2caSopenharmony_ci    updateCode = ContactUpdate(contactData, updateValues, predicates3);
1113115cd2caSopenharmony_ci    HILOG_INFO("contact_Update_test_1600: updateCode = %{public}d", updateCode);
1114115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1115115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates3, updateValues, "contact_Update_test_1600");
1116115cd2caSopenharmony_ci    ClearContacts();
1117115cd2caSopenharmony_ci}
1118115cd2caSopenharmony_ci
1119115cd2caSopenharmony_ci/*
1120115cd2caSopenharmony_ci * @tc.number  contact_Update_test_1700
1121115cd2caSopenharmony_ci * @tc.name    Modify the details of a single contact and verify that the modification was successful
1122115cd2caSopenharmony_ci *              (URL, assistant, and group)
1123115cd2caSopenharmony_ci * @tc.desc    The ability to update the contact detail data table
1124115cd2caSopenharmony_ci * @tc.level   Level1
1125115cd2caSopenharmony_ci * @tc.size    MediumTest
1126115cd2caSopenharmony_ci * @tc.type    Function
1127115cd2caSopenharmony_ci */
1128115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_1700, testing::ext::TestSize.Level1)
1129115cd2caSopenharmony_ci{
1130115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_1700 is starting! ---");
1131115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
1132115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("xiaocai", rawContactValues);
1133115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
1134115cd2caSopenharmony_ci
1135115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactValuesOne;
1136115cd2caSopenharmony_ci    int64_t contactDataIdOne = ContactDataInsert(rawContactId, "website", "www.aaa.com", "", contactValuesOne);
1137115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdOne, 0);
1138115cd2caSopenharmony_ci
1139115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactValuesTwo;
1140115cd2caSopenharmony_ci    int64_t contactDataIdTwo = ContactDataInsert(rawContactId, "relation", "fuzi", "", contactValuesTwo);
1141115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdTwo, 0);
1142115cd2caSopenharmony_ci
1143115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactValuesThree;
1144115cd2caSopenharmony_ci    int64_t contactDataIdThree = ContactDataInsert(rawContactId, "group_membership", "1", "", contactValuesThree);
1145115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdThree, 0);
1146115cd2caSopenharmony_ci
1147115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
1148115cd2caSopenharmony_ci    updateValues.Put("detail_info", "www.bbb.com");
1149115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1150115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contactDataIdOne));
1151115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
1152115cd2caSopenharmony_ci    int updateCode = ContactUpdate(contactData, updateValues, predicates);
1153115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1154115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates, updateValues, "contact_Update_test_1700");
1155115cd2caSopenharmony_ci
1156115cd2caSopenharmony_ci    updateValues.Clear();
1157115cd2caSopenharmony_ci    updateValues.Put("detail_info", "laozhang");
1158115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
1159115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(contactDataIdTwo));
1160115cd2caSopenharmony_ci    updateCode = ContactUpdate(contactData, updateValues, predicates2);
1161115cd2caSopenharmony_ci    HILOG_INFO("contact_Update_test_1700: updateCode = %{public}d", updateCode);
1162115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1163115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates2, updateValues, "contact_Update_test_1700");
1164115cd2caSopenharmony_ci
1165115cd2caSopenharmony_ci    updateValues.Clear();
1166115cd2caSopenharmony_ci    updateValues.Put("detail_info", "2");
1167115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
1168115cd2caSopenharmony_ci    predicates3.EqualTo("id", std::to_string(contactDataIdThree));
1169115cd2caSopenharmony_ci    updateCode = ContactUpdate(contactData, updateValues, predicates3);
1170115cd2caSopenharmony_ci    HILOG_INFO("contact_Update_test_1700: updateCode = %{public}d", updateCode);
1171115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1172115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates3, updateValues, "contact_Update_test_1700");
1173115cd2caSopenharmony_ci    ClearContacts();
1174115cd2caSopenharmony_ci}
1175115cd2caSopenharmony_ci
1176115cd2caSopenharmony_ci/*
1177115cd2caSopenharmony_ci * @tc.number  contact_Update_test_1800
1178115cd2caSopenharmony_ci * @tc.name    Modify the details of a single contact and verify that the modification was successful (phone ringing)
1179115cd2caSopenharmony_ci * @tc.desc    The ability to update the contact detail data table
1180115cd2caSopenharmony_ci * @tc.level   Level1
1181115cd2caSopenharmony_ci * @tc.size    MediumTest
1182115cd2caSopenharmony_ci * @tc.type    Function
1183115cd2caSopenharmony_ci */
1184115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_1800, testing::ext::TestSize.Level1)
1185115cd2caSopenharmony_ci{
1186115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_1800 is starting! ---");
1187115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
1188115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("xiaocai", rawContactValues);
1189115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
1190115cd2caSopenharmony_ci
1191115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValues;
1192115cd2caSopenharmony_ci    int64_t contactDataIdOne = ContactDataInsert(rawContactId, "contact_misc", "111", "", contactDataValues);
1193115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdOne, 0);
1194115cd2caSopenharmony_ci
1195115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
1196115cd2caSopenharmony_ci    updateValues.Put("detail_info", "222");
1197115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1198115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contactDataIdOne));
1199115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
1200115cd2caSopenharmony_ci    int updateCode = ContactUpdate(contactData, updateValues, predicates);
1201115cd2caSopenharmony_ci    HILOG_INFO("contact_Update_test_1800: updateCode = %{public}d", updateCode);
1202115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1203115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates, updateValues, "contact_Update_test_1800");
1204115cd2caSopenharmony_ci    ClearContacts();
1205115cd2caSopenharmony_ci}
1206115cd2caSopenharmony_ci
1207115cd2caSopenharmony_ci/*
1208115cd2caSopenharmony_ci * @tc.number  contact_Update_test_1900
1209115cd2caSopenharmony_ci * @tc.name    Modify multiple contact details and verify whether the modification is successful
1210115cd2caSopenharmony_ci * @tc.desc    The ability to update the contact detail data table
1211115cd2caSopenharmony_ci * @tc.level   Level1
1212115cd2caSopenharmony_ci * @tc.size    MediumTest
1213115cd2caSopenharmony_ci * @tc.type    Function
1214115cd2caSopenharmony_ci */
1215115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_1900, testing::ext::TestSize.Level1)
1216115cd2caSopenharmony_ci{
1217115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_1900 is starting! ---");
1218115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
1219115cd2caSopenharmony_ci    int64_t rawContactIdOne = RawContactInsert("ligang", rawContactValues);
1220115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdOne, 0);
1221115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactValues;
1222115cd2caSopenharmony_ci    int64_t contactDataId = ContactDataInsert(rawContactIdOne, "name", "ligang", "", contactValues);
1223115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
1224115cd2caSopenharmony_ci    contactValues.Clear();
1225115cd2caSopenharmony_ci
1226115cd2caSopenharmony_ci    contactDataId = ContactDataInsert(rawContactIdOne, "organization", "tiantianxaingshang", "Test", contactValues);
1227115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
1228115cd2caSopenharmony_ci    contactValues.Clear();
1229115cd2caSopenharmony_ci
1230115cd2caSopenharmony_ci    rawContactValues.Clear();
1231115cd2caSopenharmony_ci    int64_t rawContactIdTwo = RawContactInsert("zhangming", rawContactValues);
1232115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdTwo, 0);
1233115cd2caSopenharmony_ci
1234115cd2caSopenharmony_ci    contactDataId = ContactDataInsert(rawContactIdTwo, "name", "zhangming", "", contactValues);
1235115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
1236115cd2caSopenharmony_ci    contactValues.Clear();
1237115cd2caSopenharmony_ci
1238115cd2caSopenharmony_ci    contactDataId = ContactDataInsert(rawContactIdTwo, "organization", "tiantianxaingshang", "Test", contactValues);
1239115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
1240115cd2caSopenharmony_ci
1241115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
1242115cd2caSopenharmony_ci    updateValues.Put("detail_info", "lixiang");
1243115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1244115cd2caSopenharmony_ci    predicates.EqualTo("raw_contact_id", std::to_string(rawContactIdOne));
1245115cd2caSopenharmony_ci    predicates.And();
1246115cd2caSopenharmony_ci    // type 6 is phone
1247115cd2caSopenharmony_ci    predicates.EqualTo("type_id", "6");
1248115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
1249115cd2caSopenharmony_ci    int updateCode = ContactUpdate(contactData, updateValues, predicates);
1250115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1251115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates, updateValues, "contact_Update_test_1900");
1252115cd2caSopenharmony_ci
1253115cd2caSopenharmony_ci    updateValues.Clear();
1254115cd2caSopenharmony_ci    updateValues.Put("detail_info", "zhangsan");
1255115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
1256115cd2caSopenharmony_ci    predicates2.EqualTo("raw_contact_id", std::to_string(rawContactIdTwo));
1257115cd2caSopenharmony_ci    predicates2.And();
1258115cd2caSopenharmony_ci    // type 6 is phone
1259115cd2caSopenharmony_ci    predicates2.EqualTo("type_id", "6");
1260115cd2caSopenharmony_ci    updateCode = ContactUpdate(contactData, updateValues, predicates2);
1261115cd2caSopenharmony_ci    HILOG_INFO("contact_Update_test_1900: updateCode = %{public}d", updateCode);
1262115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1263115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates2, updateValues, "contact_Update_test_1900");
1264115cd2caSopenharmony_ci    ClearContacts();
1265115cd2caSopenharmony_ci}
1266115cd2caSopenharmony_ci
1267115cd2caSopenharmony_ci/*
1268115cd2caSopenharmony_ci * @tc.number  contact_Update_test_2000
1269115cd2caSopenharmony_ci * @tc.name    Update the full field data of the contact_data table and verify whether the modification is successful
1270115cd2caSopenharmony_ci * @tc.desc    Update ability to contact_data
1271115cd2caSopenharmony_ci * @tc.level   Level1
1272115cd2caSopenharmony_ci * @tc.size    MediumTest
1273115cd2caSopenharmony_ci * @tc.type    Function
1274115cd2caSopenharmony_ci */
1275115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_2000, testing::ext::TestSize.Level1)
1276115cd2caSopenharmony_ci{
1277115cd2caSopenharmony_ci    HILOG_INFO("-----contact_Update_test_2000 is starting!-----");
1278115cd2caSopenharmony_ci    std::vector<std::string> columnsInt;
1279115cd2caSopenharmony_ci    std::vector<std::string> columnsStr;
1280115cd2caSopenharmony_ci    std::vector<std::string> columns;
1281115cd2caSopenharmony_ci    std::string tableName = ContactTabName::CONTACT_DATA;
1282115cd2caSopenharmony_ci    GetAllContactDataColumns(columnsInt, columnsStr);
1283115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
1284115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
1285115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("feimaotui", rawContactValues);
1286115cd2caSopenharmony_ci    valuesBucket.Put("raw_contact_id", rawContactId);
1287115cd2caSopenharmony_ci    // type_id 6 is name
1288115cd2caSopenharmony_ci    valuesBucket.Put("type_id", 6);
1289115cd2caSopenharmony_ci    int ContactDataId = ContactDataInsertValues(valuesBucket);
1290115cd2caSopenharmony_ci    EXPECT_GT(ContactDataId, 0);
1291115cd2caSopenharmony_ci
1292115cd2caSopenharmony_ci    MergeColumns(columns, columnsInt, columnsStr);
1293115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1294115cd2caSopenharmony_ci    predicates.EqualTo("raw_contact_id", std::to_string(rawContactId));
1295115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket upDateValuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
1296115cd2caSopenharmony_ci
1297115cd2caSopenharmony_ci    int upDateCode = ContactUpdate(tableName, upDateValuesBucket, predicates);
1298115cd2caSopenharmony_ci    EXPECT_EQ(upDateCode, 0);
1299115cd2caSopenharmony_ci
1300115cd2caSopenharmony_ci    bool isValid = false;
1301115cd2caSopenharmony_ci    int versionCode = valuesBucket.Get("version", isValid);
1302115cd2caSopenharmony_ci    versionCode += 1;
1303115cd2caSopenharmony_ci    upDateValuesBucket.Put("version", versionCode);
1304115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(tableName, columns, predicates);
1305115cd2caSopenharmony_ci
1306115cd2caSopenharmony_ci    // resultSet count 1
1307115cd2caSopenharmony_ci    int rowCount = -1;
1308115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
1309115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
1310115cd2caSopenharmony_ci    CheckResultSet(upDateValuesBucket, resultSet, "contact_Update_test_2000");
1311115cd2caSopenharmony_ci    ClearContacts();
1312115cd2caSopenharmony_ci}
1313115cd2caSopenharmony_ci
1314115cd2caSopenharmony_ci/*
1315115cd2caSopenharmony_ci * @tc.number  contact_Update_test_2100
1316115cd2caSopenharmony_ci * @tc.name    Update all contact details and verify that the modification was successful
1317115cd2caSopenharmony_ci * @tc.desc    New ability to contact detailed data
1318115cd2caSopenharmony_ci * @tc.level   Level1
1319115cd2caSopenharmony_ci * @tc.size    MediumTest
1320115cd2caSopenharmony_ci * @tc.type    Function
1321115cd2caSopenharmony_ci */
1322115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_2100, testing::ext::TestSize.Level1)
1323115cd2caSopenharmony_ci{
1324115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_2100 is starting! ---");
1325115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawValuesBucket;
1326115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("update_detail_contactdata", rawValuesBucket);
1327115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
1328115cd2caSopenharmony_ci
1329115cd2caSopenharmony_ci    std::vector<std::string> columns;
1330115cd2caSopenharmony_ci    std::vector<std::string> columnQuery;
1331115cd2caSopenharmony_ci    columnQuery.push_back("detail_info");
1332115cd2caSopenharmony_ci    GetDetailsContactDataColumns(columns);
1333115cd2caSopenharmony_ci
1334115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket;
1335115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket upDateValuesBucket;
1336115cd2caSopenharmony_ci
1337115cd2caSopenharmony_ci    std::string randomStr = "";
1338115cd2caSopenharmony_ci    std::string updateStrValue = "";
1339115cd2caSopenharmony_ci    std::string tableName = ContactTabName::CONTACT_DATA;
1340115cd2caSopenharmony_ci    int columnSize = columns.size();
1341115cd2caSopenharmony_ci    for (int i = 0; i < columnSize; i++) {
1342115cd2caSopenharmony_ci        randomStr = columns[i] + std::to_string(ContactsRand());
1343115cd2caSopenharmony_ci        valuesBucket.Put("raw_contact_id", rawContactId);
1344115cd2caSopenharmony_ci        valuesBucket.Put("content_type", columns[i]);
1345115cd2caSopenharmony_ci        valuesBucket.Put("detail_info", randomStr);
1346115cd2caSopenharmony_ci        int contactDataId = ContactDataInsertValues(valuesBucket);
1347115cd2caSopenharmony_ci        EXPECT_GT(contactDataId, 0);
1348115cd2caSopenharmony_ci
1349115cd2caSopenharmony_ci        OHOS::DataShare::DataSharePredicates predicates;
1350115cd2caSopenharmony_ci        predicates.EqualTo("id", std::to_string(contactDataId));
1351115cd2caSopenharmony_ci        updateStrValue = "update_all" + randomStr;
1352115cd2caSopenharmony_ci        upDateValuesBucket.Put("detail_info", updateStrValue);
1353115cd2caSopenharmony_ci        int upDateCode = ContactUpdate(tableName, upDateValuesBucket, predicates);
1354115cd2caSopenharmony_ci        EXPECT_EQ(upDateCode, 0);
1355115cd2caSopenharmony_ci
1356115cd2caSopenharmony_ci        std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
1357115cd2caSopenharmony_ci            ContactQuery(tableName, columnQuery, predicates);
1358115cd2caSopenharmony_ci        int rowCount = -1;
1359115cd2caSopenharmony_ci        resultSet->GetRowCount(rowCount);
1360115cd2caSopenharmony_ci        EXPECT_EQ(1, rowCount);
1361115cd2caSopenharmony_ci        CheckResultSet(upDateValuesBucket, resultSet, "contact_Update_test_2100");
1362115cd2caSopenharmony_ci
1363115cd2caSopenharmony_ci        valuesBucket.Clear();
1364115cd2caSopenharmony_ci        upDateValuesBucket.Clear();
1365115cd2caSopenharmony_ci    }
1366115cd2caSopenharmony_ci    ClearContacts();
1367115cd2caSopenharmony_ci}
1368115cd2caSopenharmony_ci
1369115cd2caSopenharmony_ci/*
1370115cd2caSopenharmony_ci * @tc.number  contact_Update_test_2200
1371115cd2caSopenharmony_ci * @tc.name    Add a single contact to your favorites and verify that the favorites field has changed
1372115cd2caSopenharmony_ci * @tc.desc    Contacts favorites and unfavorite capabilities
1373115cd2caSopenharmony_ci * @tc.level   Level1
1374115cd2caSopenharmony_ci * @tc.size    MediumTest
1375115cd2caSopenharmony_ci * @tc.type    Function
1376115cd2caSopenharmony_ci */
1377115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_2200, testing::ext::TestSize.Level1)
1378115cd2caSopenharmony_ci{
1379115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_2200 is starting! ---");
1380115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
1381115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("xiaozong", rawContactValues);
1382115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
1383115cd2caSopenharmony_ci
1384115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
1385115cd2caSopenharmony_ci    updateValues.Put("favorite", 1);
1386115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1387115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactId));
1388115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
1389115cd2caSopenharmony_ci    int updateCode = ContactUpdate(rawContacts, updateValues, predicates);
1390115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1391115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, updateValues, "contact_Update_test_2200");
1392115cd2caSopenharmony_ci    ClearContacts();
1393115cd2caSopenharmony_ci}
1394115cd2caSopenharmony_ci
1395115cd2caSopenharmony_ci/*
1396115cd2caSopenharmony_ci * @tc.number  contact_Update_test_2300
1397115cd2caSopenharmony_ci * @tc.name    Add multiple contacts to favorites and verify that the favorites field is changed
1398115cd2caSopenharmony_ci * @tc.desc    Contacts favorites and unfavorite capabilities
1399115cd2caSopenharmony_ci * @tc.level   Level1
1400115cd2caSopenharmony_ci * @tc.size    MediumTest
1401115cd2caSopenharmony_ci * @tc.type    Function
1402115cd2caSopenharmony_ci */
1403115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_2300, testing::ext::TestSize.Level1)
1404115cd2caSopenharmony_ci{
1405115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_2300 is starting! ---");
1406115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
1407115cd2caSopenharmony_ci    int64_t rawContactIdOne = RawContactInsert("xiaowang", rawContactValues);
1408115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdOne, 0);
1409115cd2caSopenharmony_ci
1410115cd2caSopenharmony_ci    rawContactValues.Clear();
1411115cd2caSopenharmony_ci    int64_t rawContactIdTwo = RawContactInsert("xiaozhou", rawContactValues);
1412115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdTwo, 0);
1413115cd2caSopenharmony_ci    rawContactValues.Clear();
1414115cd2caSopenharmony_ci    int64_t rawContactIdThree = RawContactInsert("laowei", rawContactValues);
1415115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdThree, 0);
1416115cd2caSopenharmony_ci
1417115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
1418115cd2caSopenharmony_ci    updateValues.Put("favorite", 1);
1419115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1420115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactIdOne));
1421115cd2caSopenharmony_ci    predicates.Or();
1422115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactIdTwo));
1423115cd2caSopenharmony_ci    predicates.Or();
1424115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactIdThree));
1425115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
1426115cd2caSopenharmony_ci    int updateCode = ContactUpdate(rawContacts, updateValues, predicates);
1427115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1428115cd2caSopenharmony_ci
1429115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
1430115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(rawContactIdOne));
1431115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates2, updateValues, "contact_Update_test_2300");
1432115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
1433115cd2caSopenharmony_ci    predicates3.EqualTo("id", std::to_string(rawContactIdTwo));
1434115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates3, updateValues, "contact_Update_test_2300");
1435115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates4;
1436115cd2caSopenharmony_ci    predicates4.EqualTo("id", std::to_string(rawContactIdThree));
1437115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates4, updateValues, "contact_Update_test_2300");
1438115cd2caSopenharmony_ci    ClearContacts();
1439115cd2caSopenharmony_ci}
1440115cd2caSopenharmony_ci
1441115cd2caSopenharmony_ci/*
1442115cd2caSopenharmony_ci * @tc.number  contact_Update_test_2400
1443115cd2caSopenharmony_ci * @tc.name    Unfriend individual contacts and verify that the favorites field has changed
1444115cd2caSopenharmony_ci * @tc.desc    Contacts favorites and unfavorite capabilities
1445115cd2caSopenharmony_ci * @tc.level   Level1
1446115cd2caSopenharmony_ci * @tc.size    MediumTest
1447115cd2caSopenharmony_ci * @tc.type    Function
1448115cd2caSopenharmony_ci */
1449115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_2400, testing::ext::TestSize.Level1)
1450115cd2caSopenharmony_ci{
1451115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_2400 is starting! ---");
1452115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket values;
1453115cd2caSopenharmony_ci    std::vector<std::string> vectorValue;
1454115cd2caSopenharmony_ci    vectorValue.push_back("zhangming");
1455115cd2caSopenharmony_ci    vectorValue.push_back("tiantianxaingshang");
1456115cd2caSopenharmony_ci    vectorValue.push_back("Test");
1457115cd2caSopenharmony_ci    vectorValue.push_back("zhangming||zm");
1458115cd2caSopenharmony_ci    int64_t rawContactId = RawContactExpandInsert(vectorValue, 1, values);
1459115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
1460115cd2caSopenharmony_ci
1461115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
1462115cd2caSopenharmony_ci    updateValues.Put("favorite", 0);
1463115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1464115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactId));
1465115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
1466115cd2caSopenharmony_ci    int updateCode = ContactUpdate(rawContacts, updateValues, predicates);
1467115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1468115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, updateValues, "contact_Update_test_2400");
1469115cd2caSopenharmony_ci    ClearContacts();
1470115cd2caSopenharmony_ci}
1471115cd2caSopenharmony_ci
1472115cd2caSopenharmony_ci/*
1473115cd2caSopenharmony_ci * @tc.number  contact_Update_test_2500
1474115cd2caSopenharmony_ci * @tc.name    Remove favorites from multiple contacts and verify that the favorites field has changed
1475115cd2caSopenharmony_ci * @tc.desc    Contacts favorites and unfavorite capabilities
1476115cd2caSopenharmony_ci * @tc.level   Level1
1477115cd2caSopenharmony_ci * @tc.size    MediumTest
1478115cd2caSopenharmony_ci * @tc.type    Function
1479115cd2caSopenharmony_ci */
1480115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_2500, testing::ext::TestSize.Level1)
1481115cd2caSopenharmony_ci{
1482115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_2500 is starting! ---");
1483115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket values;
1484115cd2caSopenharmony_ci    std::vector<std::string> vectorValue;
1485115cd2caSopenharmony_ci    vectorValue.push_back("zhangming");
1486115cd2caSopenharmony_ci    vectorValue.push_back("tiantianxaingshang");
1487115cd2caSopenharmony_ci    vectorValue.push_back("Test");
1488115cd2caSopenharmony_ci    vectorValue.push_back("zhangming||zm");
1489115cd2caSopenharmony_ci    int64_t rawContactId = RawContactExpandInsert(vectorValue, 1, values);
1490115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
1491115cd2caSopenharmony_ci
1492115cd2caSopenharmony_ci    vectorValue.clear();
1493115cd2caSopenharmony_ci    values.Clear();
1494115cd2caSopenharmony_ci    vectorValue.push_back("laozhou");
1495115cd2caSopenharmony_ci    vectorValue.push_back("tiantianxaingshang");
1496115cd2caSopenharmony_ci    vectorValue.push_back("Test");
1497115cd2caSopenharmony_ci    vectorValue.push_back("laozhou||lz");
1498115cd2caSopenharmony_ci    int64_t rawContactIdTwo = RawContactExpandInsert(vectorValue, 1, values);
1499115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdTwo, 0);
1500115cd2caSopenharmony_ci
1501115cd2caSopenharmony_ci    vectorValue.clear();
1502115cd2caSopenharmony_ci    values.Clear();
1503115cd2caSopenharmony_ci    vectorValue.push_back("abiao");
1504115cd2caSopenharmony_ci    vectorValue.push_back("tiantianxaingshang");
1505115cd2caSopenharmony_ci    vectorValue.push_back("Test");
1506115cd2caSopenharmony_ci    vectorValue.push_back("abiao||ab");
1507115cd2caSopenharmony_ci    int64_t rawContactIdThree = RawContactExpandInsert(vectorValue, 1, values);
1508115cd2caSopenharmony_ci    HILOG_INFO("contact_Update_test_2500 : rawContactIdThree = %{public}ld", rawContactIdThree);
1509115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdThree, 0);
1510115cd2caSopenharmony_ci
1511115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
1512115cd2caSopenharmony_ci    updateValues.Put("favorite", 0);
1513115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1514115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactId));
1515115cd2caSopenharmony_ci    predicates.Or();
1516115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactIdTwo));
1517115cd2caSopenharmony_ci    predicates.Or();
1518115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactIdThree));
1519115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
1520115cd2caSopenharmony_ci    int updateCode = ContactUpdate(rawContacts, updateValues, predicates);
1521115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
1522115cd2caSopenharmony_ci
1523115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
1524115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(rawContactId));
1525115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates2, updateValues, "contact_Update_test_2500");
1526115cd2caSopenharmony_ci
1527115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
1528115cd2caSopenharmony_ci    predicates3.EqualTo("id", std::to_string(rawContactIdTwo));
1529115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates3, updateValues, "contact_Update_test_2500");
1530115cd2caSopenharmony_ci
1531115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates4;
1532115cd2caSopenharmony_ci    predicates4.EqualTo("id", std::to_string(rawContactIdThree));
1533115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates4, updateValues, "contact_Update_test_2500");
1534115cd2caSopenharmony_ci    ClearContacts();
1535115cd2caSopenharmony_ci}
1536115cd2caSopenharmony_ci
1537115cd2caSopenharmony_ci/*
1538115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_2600
1539115cd2caSopenharmony_ci * @tc.name    Add a single record to the blocklist and verify that the insertion was successful
1540115cd2caSopenharmony_ci * @tc.desc    The ability to add and remove contacts from the blocklist
1541115cd2caSopenharmony_ci * @tc.level   Level1
1542115cd2caSopenharmony_ci * @tc.size    MediumTest
1543115cd2caSopenharmony_ci * @tc.type    Function
1544115cd2caSopenharmony_ci */
1545115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_2600, testing::ext::TestSize.Level1)
1546115cd2caSopenharmony_ci{
1547115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Insert_test_2600 is starting! ---");
1548115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket blocklistValues;
1549115cd2caSopenharmony_ci    int64_t blocklistId = ContactBlocklistInsert("10086", blocklistValues);
1550115cd2caSopenharmony_ci    EXPECT_GT(blocklistId, 0);
1551115cd2caSopenharmony_ci
1552115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1553115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(blocklistId));
1554115cd2caSopenharmony_ci    std::string contactBlocklist = ContactTabName::CONTACT_BLOCKLIST;
1555115cd2caSopenharmony_ci    QueryAndExpectResult(contactBlocklist, predicates, blocklistValues, "contact_Insert_test_2600");
1556115cd2caSopenharmony_ci    ClearContacts();
1557115cd2caSopenharmony_ci}
1558115cd2caSopenharmony_ci
1559115cd2caSopenharmony_ci/*
1560115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_2700
1561115cd2caSopenharmony_ci * @tc.name    Add multiple records to the blocklist and verify whether the insertion is successful
1562115cd2caSopenharmony_ci * @tc.desc    The ability to add and remove contacts from the blocklist
1563115cd2caSopenharmony_ci * @tc.level   Level1
1564115cd2caSopenharmony_ci * @tc.size    MediumTest
1565115cd2caSopenharmony_ci * @tc.type    Function
1566115cd2caSopenharmony_ci */
1567115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_2700, testing::ext::TestSize.Level1)
1568115cd2caSopenharmony_ci{
1569115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Insert_test_2700 is starting! ---");
1570115cd2caSopenharmony_ci    std::string contactBlocklist = ContactTabName::CONTACT_BLOCKLIST;
1571115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket blocklistValues;
1572115cd2caSopenharmony_ci    int64_t blocklistIdOne = ContactBlocklistInsert("188520", blocklistValues);
1573115cd2caSopenharmony_ci    EXPECT_GT(blocklistIdOne, 0);
1574115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1575115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(blocklistIdOne));
1576115cd2caSopenharmony_ci    QueryAndExpectResult(contactBlocklist, predicates, blocklistValues, "contact_Insert_test_2700");
1577115cd2caSopenharmony_ci
1578115cd2caSopenharmony_ci    blocklistValues.Clear();
1579115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
1580115cd2caSopenharmony_ci    int64_t blocklistIdTwo = ContactBlocklistInsert("130269", blocklistValues);
1581115cd2caSopenharmony_ci    EXPECT_GT(blocklistIdTwo, 0);
1582115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(blocklistIdTwo));
1583115cd2caSopenharmony_ci    QueryAndExpectResult(contactBlocklist, predicates2, blocklistValues, "contact_Insert_test_2700");
1584115cd2caSopenharmony_ci
1585115cd2caSopenharmony_ci    blocklistValues.Clear();
1586115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
1587115cd2caSopenharmony_ci    int64_t blocklistIdThree = ContactBlocklistInsert("772501", blocklistValues);
1588115cd2caSopenharmony_ci    EXPECT_GT(blocklistIdThree, 0);
1589115cd2caSopenharmony_ci    predicates3.EqualTo("id", std::to_string(blocklistIdThree));
1590115cd2caSopenharmony_ci    QueryAndExpectResult(contactBlocklist, predicates3, blocklistValues, "contact_Insert_test_2700");
1591115cd2caSopenharmony_ci    ClearContacts();
1592115cd2caSopenharmony_ci}
1593115cd2caSopenharmony_ci
1594115cd2caSopenharmony_ci/*
1595115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_2800
1596115cd2caSopenharmony_ci * @tc.name    Add a full field data to the contact_blocklist table and verify whether the insertion is successful
1597115cd2caSopenharmony_ci * @tc.desc    Added ability to ContactBlocklist
1598115cd2caSopenharmony_ci * @tc.level   Level1
1599115cd2caSopenharmony_ci * @tc.size    MediumTest
1600115cd2caSopenharmony_ci * @tc.type    Function
1601115cd2caSopenharmony_ci */
1602115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_2800, testing::ext::TestSize.Level1)
1603115cd2caSopenharmony_ci{
1604115cd2caSopenharmony_ci    HILOG_INFO("-----contact_Insert_test_2800 is starting!-----");
1605115cd2caSopenharmony_ci    std::vector<std::string> columnsInt;
1606115cd2caSopenharmony_ci    std::vector<std::string> columnsStr;
1607115cd2caSopenharmony_ci    std::vector<std::string> columns;
1608115cd2caSopenharmony_ci    std::string tableName = ContactTabName::CONTACT_BLOCKLIST;
1609115cd2caSopenharmony_ci    GetAllContactBlocklistColumns(columnsInt, columnsStr);
1610115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
1611115cd2caSopenharmony_ci    int contactBlockId = ContactBlocklistInsertValues(valuesBucket);
1612115cd2caSopenharmony_ci    EXPECT_GT(contactBlockId, 0);
1613115cd2caSopenharmony_ci
1614115cd2caSopenharmony_ci    MergeColumns(columns, columnsInt, columnsStr);
1615115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1616115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contactBlockId));
1617115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(tableName, columns, predicates);
1618115cd2caSopenharmony_ci    // resultSet count 1
1619115cd2caSopenharmony_ci    int rowCount = -1;
1620115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
1621115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
1622115cd2caSopenharmony_ci    CheckResultSet(valuesBucket, resultSet, "contact_Insert_test_2800");
1623115cd2caSopenharmony_ci    ClearContacts();
1624115cd2caSopenharmony_ci}
1625115cd2caSopenharmony_ci
1626115cd2caSopenharmony_ci/*
1627115cd2caSopenharmony_ci * @tc.number  contact_Delete_test_2900
1628115cd2caSopenharmony_ci * @tc.name    Delete a contact from the blocklist and verify whether the deletion is successful
1629115cd2caSopenharmony_ci * @tc.desc    The ability to add and remove contacts from the blocklist
1630115cd2caSopenharmony_ci * @tc.level   Level1
1631115cd2caSopenharmony_ci * @tc.size    MediumTest
1632115cd2caSopenharmony_ci * @tc.type    Function
1633115cd2caSopenharmony_ci */
1634115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Delete_test_2900, testing::ext::TestSize.Level1)
1635115cd2caSopenharmony_ci{
1636115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Delete_test_2900 is starting! ---");
1637115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket blocklistValues;
1638115cd2caSopenharmony_ci    int64_t blocklistId = ContactBlocklistInsert("147852369", blocklistValues);
1639115cd2caSopenharmony_ci    EXPECT_GT(blocklistId, 0);
1640115cd2caSopenharmony_ci
1641115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1642115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(blocklistId));
1643115cd2caSopenharmony_ci    std::string contactBlocklist = ContactTabName::CONTACT_BLOCKLIST;
1644115cd2caSopenharmony_ci    int deleteCode = ContactDelete(contactBlocklist, predicates);
1645115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
1646115cd2caSopenharmony_ci    std::vector<std::string> columns;
1647115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
1648115cd2caSopenharmony_ci        ContactQuery(contactBlocklist, columns, predicates);
1649115cd2caSopenharmony_ci    int rowCount = 0;
1650115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
1651115cd2caSopenharmony_ci    EXPECT_EQ(0, rowCount);
1652115cd2caSopenharmony_ci    resultSet->Close();
1653115cd2caSopenharmony_ci    ClearContacts();
1654115cd2caSopenharmony_ci}
1655115cd2caSopenharmony_ci
1656115cd2caSopenharmony_ci/*
1657115cd2caSopenharmony_ci * @tc.number  contact_Delete_test_3000
1658115cd2caSopenharmony_ci * @tc.name    Delete multiple contacts from the blocklist and verify whether the deletion is successful
1659115cd2caSopenharmony_ci * @tc.desc    The ability to add and remove contacts from the blocklist
1660115cd2caSopenharmony_ci * @tc.level   Level1
1661115cd2caSopenharmony_ci * @tc.size    MediumTest
1662115cd2caSopenharmony_ci * @tc.type    Function
1663115cd2caSopenharmony_ci */
1664115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Delete_test_3000, testing::ext::TestSize.Level1)
1665115cd2caSopenharmony_ci{
1666115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Delete_test_3000 is starting! ---");
1667115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket blocklistValues;
1668115cd2caSopenharmony_ci    int64_t blocklistIdOne = ContactBlocklistInsert("111228855", blocklistValues);
1669115cd2caSopenharmony_ci    EXPECT_GT(blocklistIdOne, 0);
1670115cd2caSopenharmony_ci
1671115cd2caSopenharmony_ci    blocklistValues.Clear();
1672115cd2caSopenharmony_ci    int64_t blocklistIdTwo = ContactBlocklistInsert("11335566", blocklistValues);
1673115cd2caSopenharmony_ci    EXPECT_GT(blocklistIdTwo, 0);
1674115cd2caSopenharmony_ci
1675115cd2caSopenharmony_ci    blocklistValues.Clear();
1676115cd2caSopenharmony_ci    int64_t blocklistIdThree = ContactBlocklistInsert("9933220011", blocklistValues);
1677115cd2caSopenharmony_ci    EXPECT_GT(blocklistIdThree, 0);
1678115cd2caSopenharmony_ci
1679115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1680115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(blocklistIdOne));
1681115cd2caSopenharmony_ci    predicates.Or();
1682115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(blocklistIdTwo));
1683115cd2caSopenharmony_ci    predicates.Or();
1684115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(blocklistIdThree));
1685115cd2caSopenharmony_ci    std::string contactBlocklist = ContactTabName::CONTACT_BLOCKLIST;
1686115cd2caSopenharmony_ci    int deleteCode = ContactDelete(contactBlocklist, predicates);
1687115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
1688115cd2caSopenharmony_ci
1689115cd2caSopenharmony_ci    std::vector<std::string> columns;
1690115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
1691115cd2caSopenharmony_ci        ContactQuery(contactBlocklist, columns, predicates);
1692115cd2caSopenharmony_ci    int rowCount = 0;
1693115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
1694115cd2caSopenharmony_ci    EXPECT_EQ(0, rowCount);
1695115cd2caSopenharmony_ci    resultSet->Close();
1696115cd2caSopenharmony_ci    ClearContacts();
1697115cd2caSopenharmony_ci}
1698115cd2caSopenharmony_ci
1699115cd2caSopenharmony_ci/*
1700115cd2caSopenharmony_ci * @tc.number  contact_Delete_test_3100
1701115cd2caSopenharmony_ci * @tc.name    Delete a full field data of contact_blocklist table and verify whether the deletion is successful
1702115cd2caSopenharmony_ci * @tc.desc    ContactBlocklist deletion capability
1703115cd2caSopenharmony_ci * @tc.level   Level1
1704115cd2caSopenharmony_ci * @tc.size    MediumTest
1705115cd2caSopenharmony_ci * @tc.type    Function
1706115cd2caSopenharmony_ci */
1707115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Delete_test_3100, testing::ext::TestSize.Level1)
1708115cd2caSopenharmony_ci{
1709115cd2caSopenharmony_ci    HILOG_INFO("-----contact_Delete_test_3100 is starting!-----");
1710115cd2caSopenharmony_ci    // insert
1711115cd2caSopenharmony_ci    std::vector<std::string> columns;
1712115cd2caSopenharmony_ci    std::vector<std::string> columnsInt;
1713115cd2caSopenharmony_ci    std::vector<std::string> columnsStr;
1714115cd2caSopenharmony_ci    GetAllContactBlocklistColumns(columnsInt, columnsStr);
1715115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
1716115cd2caSopenharmony_ci    int contacBlockId = ContactBlocklistInsertValues(valuesBucket);
1717115cd2caSopenharmony_ci    EXPECT_GT(contacBlockId, 0);
1718115cd2caSopenharmony_ci
1719115cd2caSopenharmony_ci    // test end delete data
1720115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1721115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contacBlockId));
1722115cd2caSopenharmony_ci    std::string tableName = ContactTabName::CONTACT_BLOCKLIST;
1723115cd2caSopenharmony_ci    int deleteCode = ContactDelete(tableName, predicates);
1724115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
1725115cd2caSopenharmony_ci
1726115cd2caSopenharmony_ci    MergeColumns(columns, columnsInt, columnsStr);
1727115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSetDeleteQuery =
1728115cd2caSopenharmony_ci        ContactQuery(tableName, columns, predicates);
1729115cd2caSopenharmony_ci    int rowCount = -1;
1730115cd2caSopenharmony_ci    resultSetDeleteQuery->GetRowCount(rowCount);
1731115cd2caSopenharmony_ci    EXPECT_EQ(0, rowCount);
1732115cd2caSopenharmony_ci    ClearContacts();
1733115cd2caSopenharmony_ci}
1734115cd2caSopenharmony_ci
1735115cd2caSopenharmony_ci/*
1736115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_3200
1737115cd2caSopenharmony_ci * @tc.name    Join a single contact to the group and verify whether the join is successful
1738115cd2caSopenharmony_ci * @tc.desc    Ability to add and remove contacts from groups
1739115cd2caSopenharmony_ci * @tc.level   Level1
1740115cd2caSopenharmony_ci * @tc.size    MediumTest
1741115cd2caSopenharmony_ci * @tc.type    Function
1742115cd2caSopenharmony_ci */
1743115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_3200, testing::ext::TestSize.Level1)
1744115cd2caSopenharmony_ci{
1745115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Insert_test_3200 is staring! ---");
1746115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
1747115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("xiaoli", rawContactValues);
1748115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
1749115cd2caSopenharmony_ci
1750115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket groupValues;
1751115cd2caSopenharmony_ci    int64_t groupId = GroupsInsert("TestFirstGroup", groupValues);
1752115cd2caSopenharmony_ci    EXPECT_GT(groupId, 0);
1753115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValue;
1754115cd2caSopenharmony_ci    int64_t contactDataId =
1755115cd2caSopenharmony_ci        ContactDataInsert(rawContactId, "group_membership", std::to_string(groupId), "", contactDataValue);
1756115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
1757115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1758115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contactDataId));
1759115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
1760115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates, contactDataValue, "contact_Insert_test_3200");
1761115cd2caSopenharmony_ci    ClearContacts();
1762115cd2caSopenharmony_ci}
1763115cd2caSopenharmony_ci
1764115cd2caSopenharmony_ci/*
1765115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_3300
1766115cd2caSopenharmony_ci * @tc.name    Multiple contacts join the group and verify whether the joining is successful
1767115cd2caSopenharmony_ci * @tc.desc    Ability to add and remove contacts from groups
1768115cd2caSopenharmony_ci * @tc.level   Level1
1769115cd2caSopenharmony_ci * @tc.size    MediumTest
1770115cd2caSopenharmony_ci * @tc.type    Function
1771115cd2caSopenharmony_ci */
1772115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_3300, testing::ext::TestSize.Level1)
1773115cd2caSopenharmony_ci{
1774115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Insert_test_3300 is staring! ---");
1775115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket groupValues;
1776115cd2caSopenharmony_ci    int64_t groupIdOne = GroupsInsert("TestSecondGroup", groupValues);
1777115cd2caSopenharmony_ci    EXPECT_GT(groupIdOne, 0);
1778115cd2caSopenharmony_ci    groupValues.Clear();
1779115cd2caSopenharmony_ci
1780115cd2caSopenharmony_ci    int64_t groupIdTwo = GroupsInsert("DeveloperFirstGroup", groupValues);
1781115cd2caSopenharmony_ci    EXPECT_GT(groupIdTwo, 0);
1782115cd2caSopenharmony_ci
1783115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
1784115cd2caSopenharmony_ci    int64_t rawContactIdOne = RawContactInsert("xiaoli", rawContactValues);
1785115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdOne, 0);
1786115cd2caSopenharmony_ci    rawContactValues.Clear();
1787115cd2caSopenharmony_ci
1788115cd2caSopenharmony_ci    int64_t rawContactIdTwo = RawContactInsert("BossCai", rawContactValues);
1789115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdTwo, 0);
1790115cd2caSopenharmony_ci
1791115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValuesOne;
1792115cd2caSopenharmony_ci    int64_t contactDataIdOne =
1793115cd2caSopenharmony_ci        ContactDataInsert(rawContactIdOne, "group_membership", std::to_string(groupIdOne), "", contactDataValuesOne);
1794115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdOne, 0);
1795115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
1796115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1797115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contactDataIdOne));
1798115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates, contactDataValuesOne, "contact_Insert_test_3300");
1799115cd2caSopenharmony_ci
1800115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValuesTwo;
1801115cd2caSopenharmony_ci    int64_t contactDataIdTwo =
1802115cd2caSopenharmony_ci        ContactDataInsert(rawContactIdTwo, "group_membership", std::to_string(groupIdTwo), "", contactDataValuesTwo);
1803115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdTwo, 0);
1804115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
1805115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(contactDataIdTwo));
1806115cd2caSopenharmony_ci    QueryAndExpectResult(contactData, predicates2, contactDataValuesTwo, "contact_Insert_test_3300");
1807115cd2caSopenharmony_ci    ClearContacts();
1808115cd2caSopenharmony_ci}
1809115cd2caSopenharmony_ci
1810115cd2caSopenharmony_ci/*
1811115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_3400
1812115cd2caSopenharmony_ci * @tc.name    Add a full field data to the groups table and verify whether the insertion is successful
1813115cd2caSopenharmony_ci * @tc.desc    Added ability to groups
1814115cd2caSopenharmony_ci * @tc.level   Level1
1815115cd2caSopenharmony_ci * @tc.size    MediumTest
1816115cd2caSopenharmony_ci * @tc.type    Function
1817115cd2caSopenharmony_ci */
1818115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_3400, testing::ext::TestSize.Level1)
1819115cd2caSopenharmony_ci{
1820115cd2caSopenharmony_ci    HILOG_INFO("-----contact_Insert_test_3400 is starting!-----");
1821115cd2caSopenharmony_ci    std::vector<std::string> columnsInt;
1822115cd2caSopenharmony_ci    std::vector<std::string> columnsStr;
1823115cd2caSopenharmony_ci    std::vector<std::string> columns;
1824115cd2caSopenharmony_ci    std::string group = ContactTabName::GROUPS;
1825115cd2caSopenharmony_ci    GetAllGroupsColumns(columnsInt, columnsStr);
1826115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
1827115cd2caSopenharmony_ci    int rawId = GroupsInsertValues(valuesBucket);
1828115cd2caSopenharmony_ci    EXPECT_GT(rawId, 0);
1829115cd2caSopenharmony_ci
1830115cd2caSopenharmony_ci    MergeColumns(columns, columnsInt, columnsStr);
1831115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1832115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawId));
1833115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(group, columns, predicates);
1834115cd2caSopenharmony_ci    // resultSet count 1
1835115cd2caSopenharmony_ci    int rowCount = -1;
1836115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
1837115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
1838115cd2caSopenharmony_ci    CheckResultSet(valuesBucket, resultSet, "contact_Insert_test_3400");
1839115cd2caSopenharmony_ci    ClearContacts();
1840115cd2caSopenharmony_ci}
1841115cd2caSopenharmony_ci
1842115cd2caSopenharmony_ci/*
1843115cd2caSopenharmony_ci * @tc.number  contact_Delete_test_3500
1844115cd2caSopenharmony_ci * @tc.name    Delete a single contact from the group and verify that the deletion was successful
1845115cd2caSopenharmony_ci * @tc.desc    Ability to add and remove contacts from groups
1846115cd2caSopenharmony_ci * @tc.level   Level1
1847115cd2caSopenharmony_ci * @tc.size    MediumTest
1848115cd2caSopenharmony_ci * @tc.type    Function
1849115cd2caSopenharmony_ci */
1850115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Delete_test_3500, testing::ext::TestSize.Level1)
1851115cd2caSopenharmony_ci{
1852115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Delete_test_3500 is starting! ---");
1853115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket groupValues;
1854115cd2caSopenharmony_ci    int64_t groupId = GroupsInsert("CEO", groupValues);
1855115cd2caSopenharmony_ci    EXPECT_GT(groupId, 0);
1856115cd2caSopenharmony_ci
1857115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
1858115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("xiaoli", rawContactValues);
1859115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
1860115cd2caSopenharmony_ci
1861115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValues;
1862115cd2caSopenharmony_ci    int64_t contactDataId =
1863115cd2caSopenharmony_ci        ContactDataInsert(rawContactId, "group_membership", std::to_string(groupId), "", contactDataValues);
1864115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
1865115cd2caSopenharmony_ci
1866115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
1867115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1868115cd2caSopenharmony_ci    predicates.EqualTo("raw_contact_id", std::to_string(rawContactId));
1869115cd2caSopenharmony_ci    predicates.And();
1870115cd2caSopenharmony_ci    // type_id 9  is group_membership
1871115cd2caSopenharmony_ci    predicates.EqualTo("type_id", "9");
1872115cd2caSopenharmony_ci    int deleteCode = ContactDelete(contactData, predicates);
1873115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
1874115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
1875115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(contactDataId));
1876115cd2caSopenharmony_ci    std::vector<std::string> columns;
1877115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(contactData, columns, predicates2);
1878115cd2caSopenharmony_ci    int rowCount = 0;
1879115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
1880115cd2caSopenharmony_ci    EXPECT_EQ(0, rowCount);
1881115cd2caSopenharmony_ci    resultSet->Close();
1882115cd2caSopenharmony_ci    ClearContacts();
1883115cd2caSopenharmony_ci}
1884115cd2caSopenharmony_ci
1885115cd2caSopenharmony_ci/*
1886115cd2caSopenharmony_ci * @tc.number  contact_Delete_test_3600
1887115cd2caSopenharmony_ci * @tc.name    Delete multiple contacts from the group and verify that the deletion was successful
1888115cd2caSopenharmony_ci * @tc.desc    Ability to add and remove contacts from groups
1889115cd2caSopenharmony_ci * @tc.level   Level1
1890115cd2caSopenharmony_ci * @tc.size    MediumTest
1891115cd2caSopenharmony_ci * @tc.type    Function
1892115cd2caSopenharmony_ci */
1893115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Delete_test_3600, testing::ext::TestSize.Level1)
1894115cd2caSopenharmony_ci{
1895115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Delete_test_3600 is starting! ---");
1896115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket groupValues;
1897115cd2caSopenharmony_ci    int64_t groupIdOne = GroupsInsert("Test", groupValues);
1898115cd2caSopenharmony_ci    HILOG_INFO("contact_Delete_test_3600: groupIdOne = %{public}ld", groupIdOne);
1899115cd2caSopenharmony_ci    EXPECT_GT(groupIdOne, 0);
1900115cd2caSopenharmony_ci
1901115cd2caSopenharmony_ci    groupValues.Clear();
1902115cd2caSopenharmony_ci    int64_t groupIdTwo = GroupsInsert("Developer", groupValues);
1903115cd2caSopenharmony_ci    HILOG_INFO("contact_Delete_test_3600: groupIdTwo = %{public}ld", groupIdTwo);
1904115cd2caSopenharmony_ci    EXPECT_GT(groupIdTwo, 0);
1905115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
1906115cd2caSopenharmony_ci    int64_t rawContactIdOne = RawContactInsert("xiaoli", rawContactValues);
1907115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdOne, 0);
1908115cd2caSopenharmony_ci
1909115cd2caSopenharmony_ci    rawContactValues.Clear();
1910115cd2caSopenharmony_ci    int64_t rawContactIdTwo = RawContactInsert("xiaoyuan", rawContactValues);
1911115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdTwo, 0);
1912115cd2caSopenharmony_ci
1913115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValues;
1914115cd2caSopenharmony_ci    int64_t contactDataIdOne =
1915115cd2caSopenharmony_ci        ContactDataInsert(rawContactIdOne, "group_membership", std::to_string(groupIdOne), "", contactDataValues);
1916115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdOne, 0);
1917115cd2caSopenharmony_ci
1918115cd2caSopenharmony_ci    contactDataValues.Clear();
1919115cd2caSopenharmony_ci    int64_t contactDataIdTwo =
1920115cd2caSopenharmony_ci        ContactDataInsert(rawContactIdTwo, "group_membership", std::to_string(groupIdTwo), "", contactDataValues);
1921115cd2caSopenharmony_ci    EXPECT_GT(contactDataIdTwo, 0);
1922115cd2caSopenharmony_ci
1923115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
1924115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1925115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contactDataIdOne));
1926115cd2caSopenharmony_ci    predicates.Or();
1927115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(contactDataIdTwo));
1928115cd2caSopenharmony_ci    int deleteCode = ContactDelete(contactData, predicates);
1929115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
1930115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
1931115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(contactDataIdOne));
1932115cd2caSopenharmony_ci    std::vector<std::string> columns;
1933115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(contactData, columns, predicates2);
1934115cd2caSopenharmony_ci    int rowCount = 0;
1935115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
1936115cd2caSopenharmony_ci    EXPECT_EQ(0, rowCount);
1937115cd2caSopenharmony_ci    resultSet->Close();
1938115cd2caSopenharmony_ci
1939115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
1940115cd2caSopenharmony_ci    predicates3.EqualTo("id", std::to_string(contactDataIdTwo));
1941115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSetTwo = ContactQuery(contactData, columns, predicates3);
1942115cd2caSopenharmony_ci    int rowCountTwo = 0;
1943115cd2caSopenharmony_ci    resultSetTwo->GetRowCount(rowCountTwo);
1944115cd2caSopenharmony_ci    EXPECT_EQ(0, rowCountTwo);
1945115cd2caSopenharmony_ci    resultSetTwo->Close();
1946115cd2caSopenharmony_ci    ClearContacts();
1947115cd2caSopenharmony_ci}
1948115cd2caSopenharmony_ci
1949115cd2caSopenharmony_ci/*
1950115cd2caSopenharmony_ci * @tc.number  contact_Delete_test_3700
1951115cd2caSopenharmony_ci * @tc.name    Delete the full field data of a groups table and verify whether the deletion is successful
1952115cd2caSopenharmony_ci * @tc.desc    Groups deletion capability
1953115cd2caSopenharmony_ci * @tc.level   Level1
1954115cd2caSopenharmony_ci * @tc.size    MediumTest
1955115cd2caSopenharmony_ci * @tc.type    Function
1956115cd2caSopenharmony_ci */
1957115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Delete_test_3700, testing::ext::TestSize.Level1)
1958115cd2caSopenharmony_ci{
1959115cd2caSopenharmony_ci    HILOG_INFO("-----contact_Delete_test_3700 is starting!-----");
1960115cd2caSopenharmony_ci    // insert
1961115cd2caSopenharmony_ci    std::vector<std::string> columns;
1962115cd2caSopenharmony_ci    std::vector<std::string> columnsInt;
1963115cd2caSopenharmony_ci    std::vector<std::string> columnsStr;
1964115cd2caSopenharmony_ci    GetAllGroupsColumns(columnsInt, columnsStr);
1965115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
1966115cd2caSopenharmony_ci    int groupId = GroupsInsertValues(valuesBucket);
1967115cd2caSopenharmony_ci    EXPECT_GT(groupId, 0);
1968115cd2caSopenharmony_ci
1969115cd2caSopenharmony_ci    // test end delete data
1970115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
1971115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(groupId));
1972115cd2caSopenharmony_ci    EXPECT_GT(groupId, 0);
1973115cd2caSopenharmony_ci    std::string tableName = ContactTabName::GROUPS;
1974115cd2caSopenharmony_ci    int deleteCode = ContactDelete(tableName, predicates);
1975115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
1976115cd2caSopenharmony_ci
1977115cd2caSopenharmony_ci    MergeColumns(columns, columnsInt, columnsStr);
1978115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSetDeleteQuery =
1979115cd2caSopenharmony_ci        ContactQuery(tableName, columns, predicates);
1980115cd2caSopenharmony_ci    int rowCount = -1;
1981115cd2caSopenharmony_ci    resultSetDeleteQuery->GetRowCount(rowCount);
1982115cd2caSopenharmony_ci    EXPECT_EQ(0, rowCount);
1983115cd2caSopenharmony_ci    ClearContacts();
1984115cd2caSopenharmony_ci}
1985115cd2caSopenharmony_ci
1986115cd2caSopenharmony_ci/*
1987115cd2caSopenharmony_ci * @tc.number  contact_Query_test_3800
1988115cd2caSopenharmony_ci * @tc.name    Insert contact information and query contact information according to the returned ID
1989115cd2caSopenharmony_ci * @tc.desc    The ability to query the basic information of a single contact
1990115cd2caSopenharmony_ci * @tc.level   Level1
1991115cd2caSopenharmony_ci * @tc.size    MediumTest
1992115cd2caSopenharmony_ci * @tc.type    Function
1993115cd2caSopenharmony_ci */
1994115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Query_test_3800, testing::ext::TestSize.Level1)
1995115cd2caSopenharmony_ci{
1996115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Query_test_3800 is starting! ---");
1997115cd2caSopenharmony_ci    std::vector<std::string> columns;
1998115cd2caSopenharmony_ci    columns.push_back("display_name");
1999115cd2caSopenharmony_ci    columns.push_back("company");
2000115cd2caSopenharmony_ci    columns.push_back("position");
2001115cd2caSopenharmony_ci    columns.push_back("favorite");
2002115cd2caSopenharmony_ci    columns.push_back("phonetic_name");
2003115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket;
2004115cd2caSopenharmony_ci    valuesBucket.Put("display_name", "xiaoyuan");
2005115cd2caSopenharmony_ci    valuesBucket.Put("company", "tiantianxiangshang");
2006115cd2caSopenharmony_ci    valuesBucket.Put("position", "Test");
2007115cd2caSopenharmony_ci    valuesBucket.Put("favorite", 1);
2008115cd2caSopenharmony_ci    valuesBucket.Put("phonetic_name", "xiaoyuanxy");
2009115cd2caSopenharmony_ci
2010115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsertValues(valuesBucket);
2011115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
2012115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2013115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactId));
2014115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
2015115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(rawContacts, columns, predicates);
2016115cd2caSopenharmony_ci
2017115cd2caSopenharmony_ci    // resultSet count 1
2018115cd2caSopenharmony_ci    int rowCount = -1;
2019115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2020115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
2021115cd2caSopenharmony_ci    CheckResultSet(valuesBucket, resultSet, "contact_Query_test_3800");
2022115cd2caSopenharmony_ci    ClearContacts();
2023115cd2caSopenharmony_ci}
2024115cd2caSopenharmony_ci
2025115cd2caSopenharmony_ci/*
2026115cd2caSopenharmony_ci * @tc.number  contact_Query_test_3900
2027115cd2caSopenharmony_ci * @tc.name    Insert multiple contact information and query the contact information according to the returned ID
2028115cd2caSopenharmony_ci * @tc.desc    The ability to query the basic information of multiple contacts
2029115cd2caSopenharmony_ci * @tc.level   Level1
2030115cd2caSopenharmony_ci * @tc.size    MediumTest
2031115cd2caSopenharmony_ci * @tc.type    Function
2032115cd2caSopenharmony_ci */
2033115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Query_test_3900, testing::ext::TestSize.Level1)
2034115cd2caSopenharmony_ci{
2035115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Query_test_3900 is starting! ---");
2036115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucketOne;
2037115cd2caSopenharmony_ci    valuesBucketOne.Put("display_name", "xiaohei");
2038115cd2caSopenharmony_ci    valuesBucketOne.Put("company", "tiantianxiangshang");
2039115cd2caSopenharmony_ci    valuesBucketOne.Put("position", "Test");
2040115cd2caSopenharmony_ci    valuesBucketOne.Put("favorite", 1);
2041115cd2caSopenharmony_ci    valuesBucketOne.Put("phonetic_name", "xiaohei||xh");
2042115cd2caSopenharmony_ci    int64_t rawContactIdOne = RawContactInsertValues(valuesBucketOne);
2043115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdOne, 0);
2044115cd2caSopenharmony_ci
2045115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucketTwo;
2046115cd2caSopenharmony_ci    valuesBucketTwo.Put("display_name", "xiaobai");
2047115cd2caSopenharmony_ci    valuesBucketTwo.Put("company", "tiantianxiangshang");
2048115cd2caSopenharmony_ci    valuesBucketTwo.Put("position", "Test");
2049115cd2caSopenharmony_ci    valuesBucketTwo.Put("favorite", 1);
2050115cd2caSopenharmony_ci    valuesBucketTwo.Put("phonetic_name", "xiaohei||xh");
2051115cd2caSopenharmony_ci    int64_t rawContactIdTwo = RawContactInsertValues(valuesBucketTwo);
2052115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdTwo, 0);
2053115cd2caSopenharmony_ci
2054115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucketThr;
2055115cd2caSopenharmony_ci    valuesBucketThr.Put("display_name", "xiaocai");
2056115cd2caSopenharmony_ci    valuesBucketThr.Put("company", "tiantianxiangshang");
2057115cd2caSopenharmony_ci    valuesBucketThr.Put("position", "Test");
2058115cd2caSopenharmony_ci    valuesBucketThr.Put("favorite", 1);
2059115cd2caSopenharmony_ci    valuesBucketThr.Put("phonetic_name", "xiaohei||xh");
2060115cd2caSopenharmony_ci    int64_t rawContactIdThr = RawContactInsertValues(valuesBucketThr);
2061115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdThr, 0);
2062115cd2caSopenharmony_ci
2063115cd2caSopenharmony_ci    std::vector<std::string> columns;
2064115cd2caSopenharmony_ci    columns.push_back("display_name");
2065115cd2caSopenharmony_ci    columns.push_back("company");
2066115cd2caSopenharmony_ci    columns.push_back("position");
2067115cd2caSopenharmony_ci    columns.push_back("favorite");
2068115cd2caSopenharmony_ci    columns.push_back("phonetic_name");
2069115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2070115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactIdOne));
2071115cd2caSopenharmony_ci    predicates.Or();
2072115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactIdTwo));
2073115cd2caSopenharmony_ci    predicates.Or();
2074115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactIdThr));
2075115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
2076115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(rawContacts, columns, predicates);
2077115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> listValue;
2078115cd2caSopenharmony_ci    listValue.push_back(valuesBucketOne);
2079115cd2caSopenharmony_ci    listValue.push_back(valuesBucketTwo);
2080115cd2caSopenharmony_ci    listValue.push_back(valuesBucketThr);
2081115cd2caSopenharmony_ci    CheckResultSetList(listValue, resultSet, "contact_Query_test_3900");
2082115cd2caSopenharmony_ci    ClearContacts();
2083115cd2caSopenharmony_ci}
2084115cd2caSopenharmony_ci
2085115cd2caSopenharmony_ci/*
2086115cd2caSopenharmony_ci * @tc.number  contact_Query_test_4000
2087115cd2caSopenharmony_ci * @tc.name    Query the basic information of all contacts in the raw_contact table
2088115cd2caSopenharmony_ci * @tc.desc    The ability to query the basic information of all contacts
2089115cd2caSopenharmony_ci * @tc.level   Level1
2090115cd2caSopenharmony_ci * @tc.size    MediumTest
2091115cd2caSopenharmony_ci * @tc.type    Function
2092115cd2caSopenharmony_ci */
2093115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Query_test_4000, testing::ext::TestSize.Level1)
2094115cd2caSopenharmony_ci{
2095115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Query_test_4000 is starting! ---");
2096115cd2caSopenharmony_ci    std::string tag("contact_Query_test_4000");
2097115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucketOne;
2098115cd2caSopenharmony_ci    valuesBucketOne.Put("display_name", "xiaohsaaei");
2099115cd2caSopenharmony_ci    valuesBucketOne.Put("company", "tiantianxiadsjjnngshang");
2100115cd2caSopenharmony_ci    valuesBucketOne.Put("position", "Tests");
2101115cd2caSopenharmony_ci    valuesBucketOne.Put("favorite", 1);
2102115cd2caSopenharmony_ci    valuesBucketOne.Put("phonetic_name", "xiaohssei||x00h");
2103115cd2caSopenharmony_ci    RawContactInsertValues(valuesBucketOne);
2104115cd2caSopenharmony_ci    RawContactInsertValues(valuesBucketOne);
2105115cd2caSopenharmony_ci    std::vector<std::string> columns;
2106115cd2caSopenharmony_ci    columns.push_back("id");
2107115cd2caSopenharmony_ci    columns.push_back("display_name");
2108115cd2caSopenharmony_ci    columns.push_back("company");
2109115cd2caSopenharmony_ci    columns.push_back("position");
2110115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2111115cd2caSopenharmony_ci    predicates.GreaterThan("id", "0");
2112115cd2caSopenharmony_ci    predicates.EqualTo("is_deleted", "0");
2113115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
2114115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(rawContacts, columns, predicates);
2115115cd2caSopenharmony_ci    // resultSet count
2116115cd2caSopenharmony_ci    int rowCount = -1;
2117115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2118115cd2caSopenharmony_ci    EXPECT_GT(rowCount, 1);
2119115cd2caSopenharmony_ci    ClearContacts();
2120115cd2caSopenharmony_ci}
2121115cd2caSopenharmony_ci
2122115cd2caSopenharmony_ci/*
2123115cd2caSopenharmony_ci * @tc.number  contact_Query_test_4100
2124115cd2caSopenharmony_ci * @tc.name    Insert all contact information and query
2125115cd2caSopenharmony_ci * @tc.desc    The ability to query all information of a single contact
2126115cd2caSopenharmony_ci * @tc.level   Level1
2127115cd2caSopenharmony_ci * @tc.size    MediumTest
2128115cd2caSopenharmony_ci * @tc.type    Function
2129115cd2caSopenharmony_ci */
2130115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Query_test_4100, testing::ext::TestSize.Level1)
2131115cd2caSopenharmony_ci{
2132115cd2caSopenharmony_ci    HILOG_INFO("-----contact_Query_test_4100 is starting!-----");
2133115cd2caSopenharmony_ci    std::vector<std::string> columnsInt;
2134115cd2caSopenharmony_ci    std::vector<std::string> columnsStr;
2135115cd2caSopenharmony_ci    std::vector<std::string> columns;
2136115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
2137115cd2caSopenharmony_ci    GetAllContactDataColumns(columnsInt, columnsStr);
2138115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
2139115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
2140115cd2caSopenharmony_ci    rawContactValues.Put("favorite", "1");
2141115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("feimaomao4100", rawContactValues);
2142115cd2caSopenharmony_ci    valuesBucket.Put("raw_contact_id", rawContactId);
2143115cd2caSopenharmony_ci    // type 6 is name
2144115cd2caSopenharmony_ci    valuesBucket.Put("type_id", 6);
2145115cd2caSopenharmony_ci    int ContactDataId = ContactDataInsertValues(valuesBucket);
2146115cd2caSopenharmony_ci    EXPECT_GT(ContactDataId, 0);
2147115cd2caSopenharmony_ci
2148115cd2caSopenharmony_ci    MergeColumns(columns, columnsInt, columnsStr);
2149115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2150115cd2caSopenharmony_ci    predicates.EqualTo("raw_contact_id", std::to_string(rawContactId));
2151115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(contactData, columns, predicates);
2152115cd2caSopenharmony_ci    CheckResultSet(valuesBucket, resultSet, "contact_Query_test_4100");
2153115cd2caSopenharmony_ci    // resultSet count 1
2154115cd2caSopenharmony_ci    int rowCount = -1;
2155115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2156115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
2157115cd2caSopenharmony_ci    CheckResultSet(valuesBucket, resultSet, "contact_Query_test_4100");
2158115cd2caSopenharmony_ci    ClearContacts();
2159115cd2caSopenharmony_ci}
2160115cd2caSopenharmony_ci
2161115cd2caSopenharmony_ci/*
2162115cd2caSopenharmony_ci * @tc.number  contact_Query_test_4200
2163115cd2caSopenharmony_ci * @tc.name    Add a group and add two new contacts to the group to query the members of the group
2164115cd2caSopenharmony_ci * @tc.desc    Query group member ability
2165115cd2caSopenharmony_ci * @tc.level   Level1
2166115cd2caSopenharmony_ci * @tc.size    MediumTest
2167115cd2caSopenharmony_ci * @tc.type    Function
2168115cd2caSopenharmony_ci */
2169115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Query_test_4200, testing::ext::TestSize.Level1)
2170115cd2caSopenharmony_ci{
2171115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Query_test_4200 is starting! ---");
2172115cd2caSopenharmony_ci    std::string tag("contact_Query_test_4200");
2173115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucketGroup;
2174115cd2caSopenharmony_ci    int64_t groupId = GroupsInsert("dongshihui", valuesBucketGroup);
2175115cd2caSopenharmony_ci    EXPECT_GT(groupId, 0);
2176115cd2caSopenharmony_ci
2177115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValuesBucket;
2178115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("licheng", rawContactValuesBucket);
2179115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
2180115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucketOne;
2181115cd2caSopenharmony_ci    int64_t contactDataId =
2182115cd2caSopenharmony_ci        ContactDataInsert(rawContactId, "group_membership", std::to_string(groupId), "", valuesBucketOne);
2183115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
2184115cd2caSopenharmony_ci
2185115cd2caSopenharmony_ci    rawContactValuesBucket.Clear();
2186115cd2caSopenharmony_ci    rawContactId = RawContactInsert("xiaoyuan", rawContactValuesBucket);
2187115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
2188115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucketTwo;
2189115cd2caSopenharmony_ci    contactDataId = ContactDataInsert(rawContactId, "group_membership", std::to_string(groupId), "", valuesBucketTwo);
2190115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
2191115cd2caSopenharmony_ci
2192115cd2caSopenharmony_ci    std::vector<std::string> columns;
2193115cd2caSopenharmony_ci    columns.push_back("detail_info");
2194115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2195115cd2caSopenharmony_ci    predicates.EqualTo("detail_info", std::to_string(groupId));
2196115cd2caSopenharmony_ci    predicates.And();
2197115cd2caSopenharmony_ci    // type_id 9  is group_membership
2198115cd2caSopenharmony_ci    predicates.EqualTo("type_id", "9");
2199115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
2200115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(contactData, columns, predicates);
2201115cd2caSopenharmony_ci    int rowCount = -1;
2202115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2203115cd2caSopenharmony_ci    EXPECT_EQ(2, rowCount);
2204115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> listValue;
2205115cd2caSopenharmony_ci    listValue.push_back(valuesBucketOne);
2206115cd2caSopenharmony_ci    listValue.push_back(valuesBucketTwo);
2207115cd2caSopenharmony_ci    CheckResultSetList(listValue, resultSet, "contact_Query_test_4200");
2208115cd2caSopenharmony_ci    ClearContacts();
2209115cd2caSopenharmony_ci}
2210115cd2caSopenharmony_ci
2211115cd2caSopenharmony_ci/*
2212115cd2caSopenharmony_ci * @tc.number  contact_Query_test_4300
2213115cd2caSopenharmony_ci * @tc.name    Query favorite contacts
2214115cd2caSopenharmony_ci * @tc.desc    Query the ability of favorite contacts
2215115cd2caSopenharmony_ci * @tc.level   Level1
2216115cd2caSopenharmony_ci * @tc.size    MediumTest
2217115cd2caSopenharmony_ci * @tc.type    Function
2218115cd2caSopenharmony_ci */
2219115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Query_test_4300, testing::ext::TestSize.Level1)
2220115cd2caSopenharmony_ci{
2221115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Query_test_4300 is starting! ---");
2222115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket;
2223115cd2caSopenharmony_ci    valuesBucket.Put("display_name", "xiaoyuan");
2224115cd2caSopenharmony_ci    valuesBucket.Put("company", "tiantianxiangshang");
2225115cd2caSopenharmony_ci    valuesBucket.Put("position", "Test");
2226115cd2caSopenharmony_ci    valuesBucket.Put("favorite", 1);
2227115cd2caSopenharmony_ci    valuesBucket.Put("phonetic_name", "xiaoyuanxy");
2228115cd2caSopenharmony_ci
2229115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsertValues(valuesBucket);
2230115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
2231115cd2caSopenharmony_ci
2232115cd2caSopenharmony_ci    std::vector<std::string> columns;
2233115cd2caSopenharmony_ci    columns.push_back("display_name");
2234115cd2caSopenharmony_ci    columns.push_back("company");
2235115cd2caSopenharmony_ci    columns.push_back("position");
2236115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2237115cd2caSopenharmony_ci    predicates.EqualTo("favorite", "1");
2238115cd2caSopenharmony_ci    predicates.And();
2239115cd2caSopenharmony_ci    predicates.EqualTo("is_deleted", "0");
2240115cd2caSopenharmony_ci    predicates.And();
2241115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactId));
2242115cd2caSopenharmony_ci
2243115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
2244115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(rawContacts, columns, predicates);
2245115cd2caSopenharmony_ci
2246115cd2caSopenharmony_ci    int rowCount = -1;
2247115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2248115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
2249115cd2caSopenharmony_ci    CheckResultSet(valuesBucket, resultSet, "contact_Query_test_4300");
2250115cd2caSopenharmony_ci    ClearContacts();
2251115cd2caSopenharmony_ci}
2252115cd2caSopenharmony_ci
2253115cd2caSopenharmony_ci/*
2254115cd2caSopenharmony_ci * @tc.number  contact_Query_test_4400
2255115cd2caSopenharmony_ci * @tc.name    Query recent contacts
2256115cd2caSopenharmony_ci * @tc.desc    Query recent contact ability
2257115cd2caSopenharmony_ci * @tc.level   Level1
2258115cd2caSopenharmony_ci * @tc.size    MediumTest
2259115cd2caSopenharmony_ci * @tc.type    Function
2260115cd2caSopenharmony_ci */
2261115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Query_test_4400, testing::ext::TestSize.Level1)
2262115cd2caSopenharmony_ci{
2263115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Query_test_4400 is starting! ---");
2264115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValuesBucket;
2265115cd2caSopenharmony_ci    int64_t rawContactId = RawContactLastContactedInsert("wangwu", 60, rawContactValuesBucket);
2266115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
2267115cd2caSopenharmony_ci
2268115cd2caSopenharmony_ci    std::vector<std::string> columns;
2269115cd2caSopenharmony_ci    columns.push_back("id");
2270115cd2caSopenharmony_ci    columns.push_back("display_name");
2271115cd2caSopenharmony_ci    columns.push_back("lastest_contacted_time");
2272115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2273115cd2caSopenharmony_ci    predicates.EqualTo("lastest_contacted_time", "60");
2274115cd2caSopenharmony_ci    predicates.And();
2275115cd2caSopenharmony_ci    predicates.EqualTo("is_deleted", "0");
2276115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
2277115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(rawContacts, columns, predicates);
2278115cd2caSopenharmony_ci
2279115cd2caSopenharmony_ci    int rowCount = -1;
2280115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2281115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
2282115cd2caSopenharmony_ci    CheckResultSet(rawContactValuesBucket, resultSet, "contact_Query_test_4400");
2283115cd2caSopenharmony_ci    ClearContacts();
2284115cd2caSopenharmony_ci}
2285115cd2caSopenharmony_ci
2286115cd2caSopenharmony_ci/*
2287115cd2caSopenharmony_ci * @tc.number  contact_Query_test_4500
2288115cd2caSopenharmony_ci * @tc.name    Query the recently deleted contacts in the deleted contacts table
2289115cd2caSopenharmony_ci * @tc.desc    Ability to query recently deleted contacts
2290115cd2caSopenharmony_ci * @tc.level   Level1
2291115cd2caSopenharmony_ci * @tc.size    MediumTest
2292115cd2caSopenharmony_ci * @tc.type    Function
2293115cd2caSopenharmony_ci */
2294115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Query_test_4500, testing::ext::TestSize.Level1)
2295115cd2caSopenharmony_ci{
2296115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Query_test_4500 is starting! ---");
2297115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
2298115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("xiaobai", rawContactValues);
2299115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
2300115cd2caSopenharmony_ci
2301115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2302115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactId));
2303115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
2304115cd2caSopenharmony_ci    int deleteCode = ContactDelete(rawContacts, predicates);
2305115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
2306115cd2caSopenharmony_ci
2307115cd2caSopenharmony_ci    sleep(SLEEP_TIME);
2308115cd2caSopenharmony_ci    std::vector<std::string> columns;
2309115cd2caSopenharmony_ci    columns.push_back("display_name");
2310115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
2311115cd2caSopenharmony_ci    predicates2.EqualTo("raw_contact_id", std::to_string(rawContactId));
2312115cd2caSopenharmony_ci    std::string deletedRawContact = ContactTabName::DELETED_RAW_CONTACT;
2313115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
2314115cd2caSopenharmony_ci        ContactQuery(deletedRawContact, columns, predicates2);
2315115cd2caSopenharmony_ci
2316115cd2caSopenharmony_ci    int rowCount = -1;
2317115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2318115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
2319115cd2caSopenharmony_ci    CheckResultSet(rawContactValues, resultSet, "contact_Query_test_4500");
2320115cd2caSopenharmony_ci    ClearContacts();
2321115cd2caSopenharmony_ci}
2322115cd2caSopenharmony_ci
2323115cd2caSopenharmony_ci/*
2324115cd2caSopenharmony_ci * @tc.number  contact_Query_test_4600
2325115cd2caSopenharmony_ci * @tc.name    Query the mobile phone numbers of all contacts
2326115cd2caSopenharmony_ci * @tc.desc    Query the capabilities of all mobile phone numbers
2327115cd2caSopenharmony_ci * @tc.level   Level1
2328115cd2caSopenharmony_ci * @tc.size    MediumTest
2329115cd2caSopenharmony_ci * @tc.type    Function
2330115cd2caSopenharmony_ci */
2331115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Query_test_4600, testing::ext::TestSize.Level1)
2332115cd2caSopenharmony_ci{
2333115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Query_test_4600 is starting! ---");
2334115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
2335115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2336115cd2caSopenharmony_ci    predicates.GreaterThan("id", "0");
2337115cd2caSopenharmony_ci    int deleteCode = ContactDelete(contactData, predicates);
2338115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
2339115cd2caSopenharmony_ci
2340115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
2341115cd2caSopenharmony_ci    int64_t rawContactIdOne = RawContactInsert("dongming", rawContactValues);
2342115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdOne, 0);
2343115cd2caSopenharmony_ci
2344115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValues;
2345115cd2caSopenharmony_ci    int64_t contactDataId = ContactDataInsert(rawContactIdOne, "phone", "155825478", "", contactDataValues);
2346115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
2347115cd2caSopenharmony_ci
2348115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValuesTwo;
2349115cd2caSopenharmony_ci    int64_t rawContactIdTwo = RawContactInsert("xiaocai", rawContactValuesTwo);
2350115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdTwo, 0);
2351115cd2caSopenharmony_ci
2352115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValuesTwo;
2353115cd2caSopenharmony_ci    contactDataId = ContactDataInsert(rawContactIdTwo, "phone", "18853269857", "", contactDataValuesTwo);
2354115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
2355115cd2caSopenharmony_ci
2356115cd2caSopenharmony_ci    std::vector<std::string> columns;
2357115cd2caSopenharmony_ci    columns.push_back("detail_info");
2358115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
2359115cd2caSopenharmony_ci    // type_id 5 is phone
2360115cd2caSopenharmony_ci    predicates2.EqualTo("type_id", "5");
2361115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(contactData, columns, predicates2);
2362115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> listValue;
2363115cd2caSopenharmony_ci    listValue.push_back(contactDataValues);
2364115cd2caSopenharmony_ci    listValue.push_back(contactDataValuesTwo);
2365115cd2caSopenharmony_ci    CheckResultSetList(listValue, resultSet, "contact_Query_test_4600");
2366115cd2caSopenharmony_ci    ClearContacts();
2367115cd2caSopenharmony_ci}
2368115cd2caSopenharmony_ci
2369115cd2caSopenharmony_ci/*
2370115cd2caSopenharmony_ci * @tc.number  contact_Query_test_4700
2371115cd2caSopenharmony_ci * @tc.name    Query mailbox of all contacts
2372115cd2caSopenharmony_ci * @tc.desc    Query all mailbox capabilities
2373115cd2caSopenharmony_ci * @tc.level   Level1
2374115cd2caSopenharmony_ci * @tc.size    MediumTest
2375115cd2caSopenharmony_ci * @tc.type    Function
2376115cd2caSopenharmony_ci */
2377115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Query_test_4700, testing::ext::TestSize.Level1)
2378115cd2caSopenharmony_ci{
2379115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Query_test_4700 is starting! ---");
2380115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
2381115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2382115cd2caSopenharmony_ci    predicates.GreaterThan("id", "0");
2383115cd2caSopenharmony_ci    int deleteCode = ContactDelete(contactData, predicates);
2384115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
2385115cd2caSopenharmony_ci
2386115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
2387115cd2caSopenharmony_ci    int64_t rawContactIdOne = RawContactInsert("dongming", rawContactValues);
2388115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdOne, 0);
2389115cd2caSopenharmony_ci    rawContactValues.Clear();
2390115cd2caSopenharmony_ci
2391115cd2caSopenharmony_ci    int64_t rawContactIdTwo = RawContactInsert("xiaocai", rawContactValues);
2392115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdTwo, 0);
2393115cd2caSopenharmony_ci
2394115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactValues;
2395115cd2caSopenharmony_ci    int64_t contactDataId = ContactDataInsert(rawContactIdOne, "email", "166@163.com", "", contactValues);
2396115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
2397115cd2caSopenharmony_ci
2398115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactValuesTwo;
2399115cd2caSopenharmony_ci    contactDataId = ContactDataInsert(rawContactIdTwo, "email", "199@163.com", "", contactValuesTwo);
2400115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
2401115cd2caSopenharmony_ci
2402115cd2caSopenharmony_ci    std::vector<std::string> columns;
2403115cd2caSopenharmony_ci    columns.push_back("detail_info");
2404115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
2405115cd2caSopenharmony_ci    // type_id 1 is   email
2406115cd2caSopenharmony_ci    predicates2.EqualTo("type_id", "1");
2407115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(contactData, columns, predicates2);
2408115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> listValue;
2409115cd2caSopenharmony_ci    listValue.push_back(contactValues);
2410115cd2caSopenharmony_ci    listValue.push_back(contactValuesTwo);
2411115cd2caSopenharmony_ci    CheckResultSetList(listValue, resultSet, "contact_Query_test_4700");
2412115cd2caSopenharmony_ci    ClearContacts();
2413115cd2caSopenharmony_ci}
2414115cd2caSopenharmony_ci
2415115cd2caSopenharmony_ci/*
2416115cd2caSopenharmony_ci * @tc.number  contact_Query_test_4800
2417115cd2caSopenharmony_ci * @tc.name    Query information about a single contact
2418115cd2caSopenharmony_ci * @tc.desc    Ability to query data information of a single contact
2419115cd2caSopenharmony_ci * @tc.level   Level1
2420115cd2caSopenharmony_ci * @tc.size    MediumTest
2421115cd2caSopenharmony_ci * @tc.type    Function
2422115cd2caSopenharmony_ci */
2423115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Query_test_4800, testing::ext::TestSize.Level1)
2424115cd2caSopenharmony_ci{
2425115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Query_test_4800 is starting! ---");
2426115cd2caSopenharmony_ci    std::string tag("contact_Query_test_4800");
2427115cd2caSopenharmony_ci
2428115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
2429115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("BossCai", rawContactValues);
2430115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
2431115cd2caSopenharmony_ci
2432115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactValues;
2433115cd2caSopenharmony_ci    int64_t contactDataId = ContactDataInsert(rawContactId, "name", "BossCai", "", contactValues);
2434115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
2435115cd2caSopenharmony_ci
2436115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactValuesTwo;
2437115cd2caSopenharmony_ci    contactDataId = ContactDataInsert(rawContactId, "organization", "happy500", "Test", contactValuesTwo);
2438115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
2439115cd2caSopenharmony_ci
2440115cd2caSopenharmony_ci    std::vector<std::string> columns;
2441115cd2caSopenharmony_ci    columns.push_back("detail_info");
2442115cd2caSopenharmony_ci    columns.push_back("position");
2443115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2444115cd2caSopenharmony_ci    predicates.EqualTo("raw_contact_id", std::to_string(rawContactId));
2445115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
2446115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(contactData, columns, predicates);
2447115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> listValue;
2448115cd2caSopenharmony_ci    listValue.push_back(contactValues);
2449115cd2caSopenharmony_ci    listValue.push_back(contactValuesTwo);
2450115cd2caSopenharmony_ci    CheckResultSetList(listValue, resultSet, "contact_Query_test_4800");
2451115cd2caSopenharmony_ci    ClearContacts();
2452115cd2caSopenharmony_ci}
2453115cd2caSopenharmony_ci
2454115cd2caSopenharmony_ci/*
2455115cd2caSopenharmony_ci * @tc.number  contact_Delete_test_4900
2456115cd2caSopenharmony_ci * @tc.name    Query the deleted contact according to the original contact ID
2457115cd2caSopenharmony_ci * @tc.desc    Ability to delete contact data from the basic raw data table and record basic raw data
2458115cd2caSopenharmony_ci * @tc.level   Level1
2459115cd2caSopenharmony_ci * @tc.size    MediumTest
2460115cd2caSopenharmony_ci * @tc.type    Function
2461115cd2caSopenharmony_ci */
2462115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Delete_test_4900, testing::ext::TestSize.Level1)
2463115cd2caSopenharmony_ci{
2464115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Delete_test_4900 is starting! ---");
2465115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
2466115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("xiaoli", rawContactValues);
2467115cd2caSopenharmony_ci    HILOG_INFO("rawContactId= %{public}ld", rawContactId);
2468115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
2469115cd2caSopenharmony_ci
2470115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2471115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactId));
2472115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
2473115cd2caSopenharmony_ci    int deleteCode = ContactDelete(rawContacts, predicates);
2474115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
2475115cd2caSopenharmony_ci
2476115cd2caSopenharmony_ci    sleep(SLEEP_TIME);
2477115cd2caSopenharmony_ci    std::vector<std::string> columns;
2478115cd2caSopenharmony_ci    columns.push_back("raw_contact_id");
2479115cd2caSopenharmony_ci    columns.push_back("display_name");
2480115cd2caSopenharmony_ci    std::string deletedRawContact = ContactTabName::DELETED_RAW_CONTACT;
2481115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
2482115cd2caSopenharmony_ci    predicates2.EqualTo("raw_contact_id", std::to_string(rawContactId));
2483115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
2484115cd2caSopenharmony_ci        ContactQuery(deletedRawContact, columns, predicates2);
2485115cd2caSopenharmony_ci
2486115cd2caSopenharmony_ci    int rowCount = -1;
2487115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2488115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
2489115cd2caSopenharmony_ci    rawContactValues.Put("raw_contact_id", rawContactId);
2490115cd2caSopenharmony_ci    CheckResultSet(rawContactValues, resultSet, "contact_Delete_test_4900");
2491115cd2caSopenharmony_ci    ClearContacts();
2492115cd2caSopenharmony_ci}
2493115cd2caSopenharmony_ci
2494115cd2caSopenharmony_ci/*
2495115cd2caSopenharmony_ci * @tc.number  contact_Delete_test_5000
2496115cd2caSopenharmony_ci * @tc.name    Delete a single full field data in the raw_contact table
2497115cd2caSopenharmony_ci * @tc.desc    Raw contact deletion capability
2498115cd2caSopenharmony_ci * @tc.level   Level1
2499115cd2caSopenharmony_ci * @tc.size    MediumTest
2500115cd2caSopenharmony_ci * @tc.type    Function
2501115cd2caSopenharmony_ci */
2502115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Delete_test_5000, testing::ext::TestSize.Level1)
2503115cd2caSopenharmony_ci{
2504115cd2caSopenharmony_ci    HILOG_INFO("-----contact_Delete_test_5000 is starting!-----");
2505115cd2caSopenharmony_ci    // insert
2506115cd2caSopenharmony_ci    std::vector<std::string> columnsInt;
2507115cd2caSopenharmony_ci    std::vector<std::string> columnsStr;
2508115cd2caSopenharmony_ci    GetAllRawContactColumns(columnsInt, columnsStr);
2509115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
2510115cd2caSopenharmony_ci    int rawId = RawContactInsertValues(valuesBucket);
2511115cd2caSopenharmony_ci    EXPECT_GT(rawId, 0);
2512115cd2caSopenharmony_ci
2513115cd2caSopenharmony_ci    // test end delete data
2514115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2515115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawId));
2516115cd2caSopenharmony_ci    EXPECT_GT(rawId, 0);
2517115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
2518115cd2caSopenharmony_ci    int deleteCode = ContactDelete(rawContacts, predicates);
2519115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
2520115cd2caSopenharmony_ci    std::vector<std::string> columns;
2521115cd2caSopenharmony_ci    columns.push_back("is_deleted");
2522115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucketDelete;
2523115cd2caSopenharmony_ci    valuesBucketDelete.Put("is_deleted", 1);
2524115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, valuesBucketDelete, "contact_Delete_test_5000");
2525115cd2caSopenharmony_ci    ClearContacts();
2526115cd2caSopenharmony_ci}
2527115cd2caSopenharmony_ci
2528115cd2caSopenharmony_ci/*
2529115cd2caSopenharmony_ci * @tc.number  contact_Delete_test_5100
2530115cd2caSopenharmony_ci * @tc.name    Query the details of the newly deleted contact
2531115cd2caSopenharmony_ci * @tc.desc    Ability to delete contact data from the detailed data table and record detailed data
2532115cd2caSopenharmony_ci * @tc.level   Level1
2533115cd2caSopenharmony_ci * @tc.size    MediumTest
2534115cd2caSopenharmony_ci * @tc.type    Function
2535115cd2caSopenharmony_ci */
2536115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Delete_test_5100, testing::ext::TestSize.Level1)
2537115cd2caSopenharmony_ci{
2538115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Delete_test_5100 is starting! ---");
2539115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
2540115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("siyuan", rawContactValues);
2541115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
2542115cd2caSopenharmony_ci
2543115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactValue;
2544115cd2caSopenharmony_ci    int64_t contactDataId = ContactDataInsert(rawContactId, "organization", "tiantianxaingshang", "Test", contactValue);
2545115cd2caSopenharmony_ci    EXPECT_GT(contactDataId, 0);
2546115cd2caSopenharmony_ci
2547115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2548115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactId));
2549115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
2550115cd2caSopenharmony_ci    int deleteCode = ContactDelete(rawContacts, predicates);
2551115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
2552115cd2caSopenharmony_ci
2553115cd2caSopenharmony_ci    sleep(SLEEP_TIME);
2554115cd2caSopenharmony_ci    std::vector<std::string> columns;
2555115cd2caSopenharmony_ci    columns.push_back("raw_contact_id");
2556115cd2caSopenharmony_ci    columns.push_back("display_name");
2557115cd2caSopenharmony_ci    std::string deletedRawContact = ContactTabName::DELETED_RAW_CONTACT;
2558115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
2559115cd2caSopenharmony_ci    predicates2.EqualTo("raw_contact_id", std::to_string(rawContactId));
2560115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
2561115cd2caSopenharmony_ci        ContactQuery(deletedRawContact, columns, predicates2);
2562115cd2caSopenharmony_ci
2563115cd2caSopenharmony_ci    int rowCount = -1;
2564115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2565115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
2566115cd2caSopenharmony_ci    rawContactValues.Put("raw_contact_id", rawContactId);
2567115cd2caSopenharmony_ci    CheckResultSet(rawContactValues, resultSet, "contact_Delete_test_5100");
2568115cd2caSopenharmony_ci    ClearContacts();
2569115cd2caSopenharmony_ci}
2570115cd2caSopenharmony_ci
2571115cd2caSopenharmony_ci/*
2572115cd2caSopenharmony_ci * @tc.number  contact_Delete_test_5200
2573115cd2caSopenharmony_ci * @tc.name    Delete a single full field data in the contact_data table
2574115cd2caSopenharmony_ci * @tc.desc    Deleted ability to contact_data
2575115cd2caSopenharmony_ci * @tc.level   Level1
2576115cd2caSopenharmony_ci * @tc.size    MediumTest
2577115cd2caSopenharmony_ci * @tc.type    Function
2578115cd2caSopenharmony_ci */
2579115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Delete_test_5200, testing::ext::TestSize.Level1)
2580115cd2caSopenharmony_ci{
2581115cd2caSopenharmony_ci    HILOG_INFO("-----contact_Delete_test_5200 is starting!-----");
2582115cd2caSopenharmony_ci    std::vector<std::string> columnsInt;
2583115cd2caSopenharmony_ci    std::vector<std::string> columnsStr;
2584115cd2caSopenharmony_ci    std::vector<std::string> columns;
2585115cd2caSopenharmony_ci    std::string tableName = ContactTabName::CONTACT_DATA;
2586115cd2caSopenharmony_ci    GetAllContactDataColumns(columnsInt, columnsStr);
2587115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
2588115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
2589115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("feimaotui", rawContactValues);
2590115cd2caSopenharmony_ci    valuesBucket.Put("raw_contact_id", rawContactId);
2591115cd2caSopenharmony_ci    // type id 6 is name
2592115cd2caSopenharmony_ci    valuesBucket.Put("type_id", 6);
2593115cd2caSopenharmony_ci    int ContactDataId = ContactDataInsertValues(valuesBucket);
2594115cd2caSopenharmony_ci    EXPECT_GT(ContactDataId, 0);
2595115cd2caSopenharmony_ci
2596115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2597115cd2caSopenharmony_ci    predicates.EqualTo("raw_contact_id", std::to_string(rawContactId));
2598115cd2caSopenharmony_ci    int deleteCode = ContactDelete(tableName, predicates);
2599115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
2600115cd2caSopenharmony_ci
2601115cd2caSopenharmony_ci    MergeColumns(columns, columnsInt, columnsStr);
2602115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSetDeleteQuery =
2603115cd2caSopenharmony_ci        ContactQuery(tableName, columns, predicates);
2604115cd2caSopenharmony_ci    // resultSet count 0
2605115cd2caSopenharmony_ci    int rowCount = -1;
2606115cd2caSopenharmony_ci    resultSetDeleteQuery->GetRowCount(rowCount);
2607115cd2caSopenharmony_ci    EXPECT_EQ(0, rowCount);
2608115cd2caSopenharmony_ci    ClearContacts();
2609115cd2caSopenharmony_ci}
2610115cd2caSopenharmony_ci
2611115cd2caSopenharmony_ci/*
2612115cd2caSopenharmony_ci * @tc.number  contact_Delete_test_5300
2613115cd2caSopenharmony_ci * @tc.name    Query deleted basic data
2614115cd2caSopenharmony_ci * @tc.desc    Ability to delete and record basic data of a single contact
2615115cd2caSopenharmony_ci * @tc.level   Level1
2616115cd2caSopenharmony_ci * @tc.size    MediumTest
2617115cd2caSopenharmony_ci * @tc.type    Function
2618115cd2caSopenharmony_ci */
2619115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Delete_test_5300, testing::ext::TestSize.Level1)
2620115cd2caSopenharmony_ci{
2621115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Delete_test_5300 is starting! ---");
2622115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
2623115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("xiaohong", rawContactValues);
2624115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
2625115cd2caSopenharmony_ci
2626115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2627115cd2caSopenharmony_ci    predicates.EqualTo("name_raw_contact_id", std::to_string(rawContactId));
2628115cd2caSopenharmony_ci    std::string contact = ContactTabName::CONTACT;
2629115cd2caSopenharmony_ci    int deleteCode = ContactDelete(contact, predicates);
2630115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
2631115cd2caSopenharmony_ci
2632115cd2caSopenharmony_ci    sleep(SLEEP_TIME);
2633115cd2caSopenharmony_ci    std::vector<std::string> columns;
2634115cd2caSopenharmony_ci    columns.push_back("raw_contact_id");
2635115cd2caSopenharmony_ci    columns.push_back("display_name");
2636115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
2637115cd2caSopenharmony_ci    predicates2.EqualTo("raw_contact_id", std::to_string(rawContactId));
2638115cd2caSopenharmony_ci    std::string deletedRawContact = ContactTabName::DELETED_RAW_CONTACT;
2639115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
2640115cd2caSopenharmony_ci        ContactQuery(deletedRawContact, columns, predicates2);
2641115cd2caSopenharmony_ci
2642115cd2caSopenharmony_ci    int rowCount = -1;
2643115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2644115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
2645115cd2caSopenharmony_ci    rawContactValues.Put("raw_contact_id", rawContactId);
2646115cd2caSopenharmony_ci    CheckResultSet(rawContactValues, resultSet, "contact_Delete_test_5300");
2647115cd2caSopenharmony_ci    ClearContacts();
2648115cd2caSopenharmony_ci}
2649115cd2caSopenharmony_ci
2650115cd2caSopenharmony_ci/*
2651115cd2caSopenharmony_ci * @tc.number  contact_BatchInsert_test_5400
2652115cd2caSopenharmony_ci * @tc.name    Add basic contact information in batch and verify whether the insertion is successful
2653115cd2caSopenharmony_ci * @tc.desc    Bulk increase capacity of address book
2654115cd2caSopenharmony_ci * @tc.level   Level1
2655115cd2caSopenharmony_ci * @tc.size    MediumTest
2656115cd2caSopenharmony_ci * @tc.type    Function
2657115cd2caSopenharmony_ci */
2658115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_BatchInsert_test_5400, testing::ext::TestSize.Level1)
2659115cd2caSopenharmony_ci{
2660115cd2caSopenharmony_ci    HILOG_INFO("--- contact_BatchInsert_test_5400 is starting! ---");
2661115cd2caSopenharmony_ci    OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT);
2662115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValuesOne;
2663115cd2caSopenharmony_ci    rawContactValuesOne.Put("display_name", std::string("zhangming"));
2664115cd2caSopenharmony_ci    rawContactValuesOne.Put("company", std::string("tiantainxiangzuo4200000000"));
2665115cd2caSopenharmony_ci    rawContactValuesOne.Put("position", std::string("Test"));
2666115cd2caSopenharmony_ci
2667115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValuesTwo;
2668115cd2caSopenharmony_ci    rawContactValuesTwo.Put("display_name", std::string("ligang"));
2669115cd2caSopenharmony_ci    rawContactValuesTwo.Put("company", std::string("tiantainxiangzuo4200000000"));
2670115cd2caSopenharmony_ci    rawContactValuesTwo.Put("position", std::string("Developer"));
2671115cd2caSopenharmony_ci
2672115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValuesThree;
2673115cd2caSopenharmony_ci    rawContactValuesThree.Put("display_name", std::string("wanghong"));
2674115cd2caSopenharmony_ci    rawContactValuesThree.Put("company", std::string("tiantainxiangzuo4200000000"));
2675115cd2caSopenharmony_ci    rawContactValuesThree.Put("position", std::string("manage"));
2676115cd2caSopenharmony_ci
2677115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> listAddBluk;
2678115cd2caSopenharmony_ci    listAddBluk.push_back(rawContactValuesOne);
2679115cd2caSopenharmony_ci    listAddBluk.push_back(rawContactValuesTwo);
2680115cd2caSopenharmony_ci    listAddBluk.push_back(rawContactValuesThree);
2681115cd2caSopenharmony_ci
2682115cd2caSopenharmony_ci    int batchInserCode = contactsDataAbility.BatchInsert(uriRawContact, listAddBluk);
2683115cd2caSopenharmony_ci    EXPECT_EQ(batchInserCode, 0);
2684115cd2caSopenharmony_ci
2685115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
2686115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2687115cd2caSopenharmony_ci    predicates.EqualTo("company", "tiantainxiangzuo4200000000");
2688115cd2caSopenharmony_ci    predicates.And();
2689115cd2caSopenharmony_ci    predicates.EqualTo("is_deleted", "0");
2690115cd2caSopenharmony_ci    predicates.OrderByAsc("id");
2691115cd2caSopenharmony_ci    std::vector<std::string> columns;
2692115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(rawContacts, columns, predicates);
2693115cd2caSopenharmony_ci    int rowCount = 0;
2694115cd2caSopenharmony_ci    int queryCount = 3;
2695115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2696115cd2caSopenharmony_ci    EXPECT_EQ(queryCount, rowCount);
2697115cd2caSopenharmony_ci    CheckResultSetList(listAddBluk, resultSet, "contact_BatchInsert_test_5400");
2698115cd2caSopenharmony_ci    ClearContacts();
2699115cd2caSopenharmony_ci}
2700115cd2caSopenharmony_ci
2701115cd2caSopenharmony_ci/*
2702115cd2caSopenharmony_ci * @tc.number  contact_BatchInsert_test_5500
2703115cd2caSopenharmony_ci * @tc.name    Batch add contact details and verify that the insertion was successful
2704115cd2caSopenharmony_ci * @tc.desc    Bulk increase capacity of address book
2705115cd2caSopenharmony_ci * @tc.level   Level1
2706115cd2caSopenharmony_ci * @tc.size    MediumTest
2707115cd2caSopenharmony_ci * @tc.type    Function
2708115cd2caSopenharmony_ci */
2709115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_BatchInsert_test_5500, testing::ext::TestSize.Level1)
2710115cd2caSopenharmony_ci{
2711115cd2caSopenharmony_ci    HILOG_INFO("--- contact_BatchInsert_test_5500 is starting! ---");
2712115cd2caSopenharmony_ci
2713115cd2caSopenharmony_ci    OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT);
2714115cd2caSopenharmony_ci    OHOS::Uri uriContactData(ContactsUri::CONTACT_DATA);
2715115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
2716115cd2caSopenharmony_ci    rawContactValues.Put("display_name", "zhangming");
2717115cd2caSopenharmony_ci    int64_t rawContactId = contactsDataAbility.Insert(uriRawContact, rawContactValues);
2718115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
2719115cd2caSopenharmony_ci
2720115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> listAddBluk = GetBatchList(rawContactId);
2721115cd2caSopenharmony_ci    int batchInserCode = contactsDataAbility.BatchInsert(uriContactData, listAddBluk);
2722115cd2caSopenharmony_ci    EXPECT_EQ(batchInserCode, 0);
2723115cd2caSopenharmony_ci
2724115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
2725115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2726115cd2caSopenharmony_ci    // type_id 1 is email
2727115cd2caSopenharmony_ci    predicates.EqualTo("type_id", "1");
2728115cd2caSopenharmony_ci    predicates.And();
2729115cd2caSopenharmony_ci    predicates.EqualTo("raw_contact_id", std::to_string(rawContactId));
2730115cd2caSopenharmony_ci    std::vector<std::string> columns;
2731115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(contactData, columns, predicates);
2732115cd2caSopenharmony_ci    int rowCount = 0;
2733115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2734115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
2735115cd2caSopenharmony_ci    int indexTwo = 2;
2736115cd2caSopenharmony_ci    CheckResultSet(listAddBluk[indexTwo], resultSet, "contact_BatchInsert_test_5500");
2737115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
2738115cd2caSopenharmony_ci    // type 5 is phone
2739115cd2caSopenharmony_ci    predicates2.EqualTo("type_id", "5");
2740115cd2caSopenharmony_ci    predicates2.And();
2741115cd2caSopenharmony_ci    predicates2.EqualTo("raw_contact_id", std::to_string(rawContactId));
2742115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSetFour =
2743115cd2caSopenharmony_ci        ContactQuery(contactData, columns, predicates2);
2744115cd2caSopenharmony_ci    int rowCountFour = 0;
2745115cd2caSopenharmony_ci    resultSetFour->GetRowCount(rowCountFour);
2746115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCountFour);
2747115cd2caSopenharmony_ci    int indexThree = 3;
2748115cd2caSopenharmony_ci    CheckResultSet(listAddBluk[indexThree], resultSetFour, "contact_BatchInsert_test_5500");
2749115cd2caSopenharmony_ci    ClearContacts();
2750115cd2caSopenharmony_ci}
2751115cd2caSopenharmony_ci
2752115cd2caSopenharmony_cistd::vector<OHOS::DataShare::DataShareValuesBucket> ContactAbilityTest::GetBatchList(int64_t rawContactId)
2753115cd2caSopenharmony_ci{
2754115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValuesOne;
2755115cd2caSopenharmony_ci    contactDataValuesOne.Put("raw_contact_id", rawContactId);
2756115cd2caSopenharmony_ci    contactDataValuesOne.Put("content_type", "name");
2757115cd2caSopenharmony_ci    contactDataValuesOne.Put("detail_info", "zhangming");
2758115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValuesTwo;
2759115cd2caSopenharmony_ci    contactDataValuesTwo.Put("raw_contact_id", rawContactId);
2760115cd2caSopenharmony_ci    contactDataValuesTwo.Put("content_type", "organization");
2761115cd2caSopenharmony_ci    contactDataValuesTwo.Put("detail_info", "tiantianxaingshang");
2762115cd2caSopenharmony_ci    contactDataValuesTwo.Put("position", "Test");
2763115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValuesThree;
2764115cd2caSopenharmony_ci    contactDataValuesThree.Put("raw_contact_id", rawContactId);
2765115cd2caSopenharmony_ci    contactDataValuesThree.Put("content_type", "email");
2766115cd2caSopenharmony_ci    contactDataValuesThree.Put("detail_info", "199632@163.com");
2767115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValuesFour;
2768115cd2caSopenharmony_ci    contactDataValuesFour.Put("raw_contact_id", rawContactId);
2769115cd2caSopenharmony_ci    contactDataValuesFour.Put("content_type", "phone");
2770115cd2caSopenharmony_ci    contactDataValuesFour.Put("detail_info", "1234567898");
2771115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> listAddBluk;
2772115cd2caSopenharmony_ci    listAddBluk.push_back(contactDataValuesOne);
2773115cd2caSopenharmony_ci    listAddBluk.push_back(contactDataValuesTwo);
2774115cd2caSopenharmony_ci    listAddBluk.push_back(contactDataValuesThree);
2775115cd2caSopenharmony_ci    listAddBluk.push_back(contactDataValuesFour);
2776115cd2caSopenharmony_ci    return listAddBluk;
2777115cd2caSopenharmony_ci}
2778115cd2caSopenharmony_ci
2779115cd2caSopenharmony_ci/*
2780115cd2caSopenharmony_ci * @tc.number  contact_Delete_test_5600
2781115cd2caSopenharmony_ci * @tc.name    Delete contacts in batch and verify whether the deletion is successful
2782115cd2caSopenharmony_ci * @tc.desc    delete ability to call records in batches
2783115cd2caSopenharmony_ci * @tc.level   Level1
2784115cd2caSopenharmony_ci * @tc.size    MediumTest
2785115cd2caSopenharmony_ci * @tc.type    Function
2786115cd2caSopenharmony_ci */
2787115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Delete_test_5600, testing::ext::TestSize.Level1)
2788115cd2caSopenharmony_ci{
2789115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Delete_test_5600 is starting!---");
2790115cd2caSopenharmony_ci    int time = 10000;
2791115cd2caSopenharmony_ci    std::chrono::milliseconds dura(time);
2792115cd2caSopenharmony_ci    std::this_thread::sleep_for(dura);
2793115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawValuesBucket;
2794115cd2caSopenharmony_ci    int64_t rawContactIdOne = RawContactInsert("update_detail_contactdata", rawValuesBucket);
2795115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdOne, 0);
2796115cd2caSopenharmony_ci    int64_t rawContactIdTwo = RawContactInsert("update_contactdata", rawValuesBucket);
2797115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdTwo, 0);
2798115cd2caSopenharmony_ci
2799115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2800115cd2caSopenharmony_ci    predicates.GreaterThan("id", "0");
2801115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataSharePredicates> executePredicates =
2802115cd2caSopenharmony_ci        std::make_shared<OHOS::DataShare::DataSharePredicates>(predicates);
2803115cd2caSopenharmony_ci    std::shared_ptr<Uri> uri = std::make_shared<Uri>(ContactsUri::RAW_CONTACT);
2804115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareOperation> operation =
2805115cd2caSopenharmony_ci        OHOS::DataShare::DataShareOperation::NewDeleteBuilder(uri)
2806115cd2caSopenharmony_ci            ->WithPredicatesBackReference(0, 0)
2807115cd2caSopenharmony_ci            ->WithPredicates(executePredicates)
2808115cd2caSopenharmony_ci            ->WithInterruptionAllowed(true)
2809115cd2caSopenharmony_ci            ->Build();
2810115cd2caSopenharmony_ci    std::vector<std::shared_ptr<OHOS::DataShare::DataShareOperation>> executeBatchOperations;
2811115cd2caSopenharmony_ci    executeBatchOperations.push_back(operation);
2812115cd2caSopenharmony_ci    InitAbility();
2813115cd2caSopenharmony_ci    std::vector<std::shared_ptr<OHOS::DataShare::DataShareResult>> dataShareResult =
2814115cd2caSopenharmony_ci        contactsDataAbility.ExecuteBatch(executeBatchOperations);
2815115cd2caSopenharmony_ci    EXPECT_EQ(0, dataShareResult[0]->GetCount());
2816115cd2caSopenharmony_ci    std::string tableName = ContactTabName::CONTACT_DATA;
2817115cd2caSopenharmony_ci    std::vector<std::string> columnQuery;
2818115cd2caSopenharmony_ci    columnQuery.push_back("detail_info");
2819115cd2caSopenharmony_ci    predicates.EqualTo("is_deleted", "0");
2820115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(tableName, columnQuery, predicates);
2821115cd2caSopenharmony_ci    int rowCount = 0;
2822115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2823115cd2caSopenharmony_ci    EXPECT_EQ(0, rowCount);
2824115cd2caSopenharmony_ci    ClearContacts();
2825115cd2caSopenharmony_ci}
2826115cd2caSopenharmony_ci
2827115cd2caSopenharmony_ci/*
2828115cd2caSopenharmony_ci * @tc.number  contact_Update_test_5700
2829115cd2caSopenharmony_ci * @tc.name    Batch favorite / cancel favorite contacts
2830115cd2caSopenharmony_ci * @tc.desc    Batch collection and uncollection capabilities
2831115cd2caSopenharmony_ci * @tc.level   Level1
2832115cd2caSopenharmony_ci * @tc.size    MediumTest
2833115cd2caSopenharmony_ci * @tc.type    Function
2834115cd2caSopenharmony_ci */
2835115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_5700, testing::ext::TestSize.Level1)
2836115cd2caSopenharmony_ci{
2837115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_5700 is starting! ---");
2838115cd2caSopenharmony_ci
2839115cd2caSopenharmony_ci    OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT);
2840115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValuesOne;
2841115cd2caSopenharmony_ci    rawContactValuesOne.Put("display_name", "zhangmingming");
2842115cd2caSopenharmony_ci    rawContactValuesOne.Put("favorite", 1);
2843115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValuesTwo;
2844115cd2caSopenharmony_ci    rawContactValuesTwo.Put("display_name", "yuanmoumou");
2845115cd2caSopenharmony_ci    rawContactValuesTwo.Put("favorite", 1);
2846115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValuesThree;
2847115cd2caSopenharmony_ci    rawContactValuesThree.Put("display_name", "xiaofenren");
2848115cd2caSopenharmony_ci    rawContactValuesThree.Put("favorite", 1);
2849115cd2caSopenharmony_ci
2850115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> listAddBluk;
2851115cd2caSopenharmony_ci    listAddBluk.push_back(rawContactValuesOne);
2852115cd2caSopenharmony_ci    listAddBluk.push_back(rawContactValuesTwo);
2853115cd2caSopenharmony_ci    listAddBluk.push_back(rawContactValuesThree);
2854115cd2caSopenharmony_ci    int batchInserCode = contactsDataAbility.BatchInsert(uriRawContact, listAddBluk);
2855115cd2caSopenharmony_ci    HILOG_INFO("contact_Update_test_5700 : batchInserCode = %{public}d", batchInserCode);
2856115cd2caSopenharmony_ci    EXPECT_EQ(batchInserCode, 0);
2857115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
2858115cd2caSopenharmony_ci    updateValues.Put("favorite", 0);
2859115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2860115cd2caSopenharmony_ci    predicates.EqualTo("display_name", "zhangmingming");
2861115cd2caSopenharmony_ci    predicates.Or();
2862115cd2caSopenharmony_ci    predicates.EqualTo("display_name", "yuanmoumou");
2863115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
2864115cd2caSopenharmony_ci    int updateCode = ContactUpdate(rawContacts, updateValues, predicates);
2865115cd2caSopenharmony_ci    HILOG_INFO("contact_Update_test_5700: updateCode = %{public}d", updateCode);
2866115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
2867115cd2caSopenharmony_ci
2868115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
2869115cd2caSopenharmony_ci    predicates2.EqualTo("display_name", "zhangmingming");
2870115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates2, updateValues, "contact_Update_test_5700");
2871115cd2caSopenharmony_ci
2872115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
2873115cd2caSopenharmony_ci    predicates3.EqualTo("display_name", "xiaofenren");
2874115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates3, rawContactValuesThree, "contact_Update_test_5700");
2875115cd2caSopenharmony_ci    ClearContacts();
2876115cd2caSopenharmony_ci}
2877115cd2caSopenharmony_ci
2878115cd2caSopenharmony_ci/*
2879115cd2caSopenharmony_ci * @tc.number  contact_Update_test_5800
2880115cd2caSopenharmony_ci * @tc.name    Update the contact in batch and verify whether the modification is successful
2881115cd2caSopenharmony_ci * @tc.desc    update ability to call records in batches
2882115cd2caSopenharmony_ci * @tc.level   Level1
2883115cd2caSopenharmony_ci * @tc.size    MediumTest
2884115cd2caSopenharmony_ci * @tc.type    Function
2885115cd2caSopenharmony_ci */
2886115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Update_test_5800, testing::ext::TestSize.Level1)
2887115cd2caSopenharmony_ci{
2888115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Update_test_5800 is starting!---");
2889115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawValuesBucket;
2890115cd2caSopenharmony_ci    int64_t rawContactIdOne = RawContactInsert("update_detail_contactdata", rawValuesBucket);
2891115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdOne, 0);
2892115cd2caSopenharmony_ci    int64_t rawContactIdTwo = RawContactInsert("update_contactdata", rawValuesBucket);
2893115cd2caSopenharmony_ci    EXPECT_GT(rawContactIdTwo, 0);
2894115cd2caSopenharmony_ci
2895115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2896115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactIdOne));
2897115cd2caSopenharmony_ci    predicates.Or();
2898115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactIdTwo));
2899115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareValuesBucket> values =
2900115cd2caSopenharmony_ci        std::make_shared<OHOS::DataShare::DataShareValuesBucket>(rawValuesBucket);
2901115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataSharePredicates> executePredicates =
2902115cd2caSopenharmony_ci        std::make_shared<OHOS::DataShare::DataSharePredicates>(predicates);
2903115cd2caSopenharmony_ci    std::shared_ptr<Uri> uri = std::make_shared<Uri>(ContactsUri::RAW_CONTACT);
2904115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareOperation> operation =
2905115cd2caSopenharmony_ci        OHOS::DataShare::DataShareOperation::NewUpdateBuilder(uri)
2906115cd2caSopenharmony_ci            ->WithValuesBucket(values)
2907115cd2caSopenharmony_ci            ->WithPredicatesBackReference(0, 0)
2908115cd2caSopenharmony_ci            ->WithPredicates(executePredicates)
2909115cd2caSopenharmony_ci            ->WithInterruptionAllowed(true)
2910115cd2caSopenharmony_ci            ->Build();
2911115cd2caSopenharmony_ci    std::vector<std::shared_ptr<OHOS::DataShare::DataShareOperation>> executeBatchOperations;
2912115cd2caSopenharmony_ci    executeBatchOperations.push_back(operation);
2913115cd2caSopenharmony_ci    InitAbility();
2914115cd2caSopenharmony_ci    std::vector<std::shared_ptr<OHOS::DataShare::DataShareResult>> dataShareResult =
2915115cd2caSopenharmony_ci        contactsDataAbility.ExecuteBatch(executeBatchOperations);
2916115cd2caSopenharmony_ci    EXPECT_EQ(0, dataShareResult[0]->GetCount());
2917115cd2caSopenharmony_ci    std::string tableName = ContactTabName::RAW_CONTACT;
2918115cd2caSopenharmony_ci    std::vector<std::string> columnQuery;
2919115cd2caSopenharmony_ci    columnQuery.push_back("display_name");
2920115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(tableName, columnQuery, predicates);
2921115cd2caSopenharmony_ci    int rowCount = 0;
2922115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2923115cd2caSopenharmony_ci    EXPECT_EQ(2, rowCount);
2924115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> listValue;
2925115cd2caSopenharmony_ci    listValue.push_back(rawValuesBucket);
2926115cd2caSopenharmony_ci    listValue.push_back(rawValuesBucket);
2927115cd2caSopenharmony_ci    CheckResultSetList(listValue, resultSet, "contact_Update_test_5800");
2928115cd2caSopenharmony_ci    ClearContacts();
2929115cd2caSopenharmony_ci}
2930115cd2caSopenharmony_ci
2931115cd2caSopenharmony_ci/*
2932115cd2caSopenharmony_ci * @tc.number  contact_BatchInsertAndDelete_test_5900
2933115cd2caSopenharmony_ci * @tc.name    Batch add / delete contact blocklist
2934115cd2caSopenharmony_ci * @tc.desc    Ability to add and remove contacts from the blocklist in batches
2935115cd2caSopenharmony_ci * @tc.level   Level1
2936115cd2caSopenharmony_ci * @tc.size    MediumTest
2937115cd2caSopenharmony_ci * @tc.type    Function
2938115cd2caSopenharmony_ci */
2939115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_BatchInsertAndDelete_test_5900, testing::ext::TestSize.Level1)
2940115cd2caSopenharmony_ci{
2941115cd2caSopenharmony_ci    HILOG_INFO("--- contact_BatchInsertAndDelete_test_5900 is starting! ---");
2942115cd2caSopenharmony_ci    OHOS::Uri uriContactBlocklist(ContactsUri::BLOCKLIST);
2943115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactBlocklistValuesOne;
2944115cd2caSopenharmony_ci    OHOS::Contacts::RandomNumberUtils randomNumberUtils;
2945115cd2caSopenharmony_ci    std::string phoneNumber = randomNumberUtils.Generating(9);
2946115cd2caSopenharmony_ci    contactBlocklistValuesOne.Put("phone_number", phoneNumber);
2947115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactBlocklistValuesTwo;
2948115cd2caSopenharmony_ci    contactBlocklistValuesTwo.Put("phone_number", phoneNumber);
2949115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactBlocklistValuesThree;
2950115cd2caSopenharmony_ci    contactBlocklistValuesThree.Put("phone_number", phoneNumber);
2951115cd2caSopenharmony_ci
2952115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> listAddBluk;
2953115cd2caSopenharmony_ci    listAddBluk.push_back(contactBlocklistValuesOne);
2954115cd2caSopenharmony_ci    listAddBluk.push_back(contactBlocklistValuesTwo);
2955115cd2caSopenharmony_ci    listAddBluk.push_back(contactBlocklistValuesThree);
2956115cd2caSopenharmony_ci    int batchInsertCode = contactsDataAbility.BatchInsert(uriContactBlocklist, listAddBluk);
2957115cd2caSopenharmony_ci    EXPECT_EQ(batchInsertCode, 0);
2958115cd2caSopenharmony_ci
2959115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
2960115cd2caSopenharmony_ci    predicates.EqualTo("phone_number", std::string(phoneNumber));
2961115cd2caSopenharmony_ci    predicates.Or();
2962115cd2caSopenharmony_ci    predicates.EqualTo("phone_number", std::string(phoneNumber));
2963115cd2caSopenharmony_ci    std::string contactBlocklist = ContactTabName::CONTACT_BLOCKLIST;
2964115cd2caSopenharmony_ci    int deleteCode = ContactDelete(contactBlocklist, predicates);
2965115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
2966115cd2caSopenharmony_ci    std::vector<std::string> columns;
2967115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
2968115cd2caSopenharmony_ci        ContactQuery(contactBlocklist, columns, predicates);
2969115cd2caSopenharmony_ci    int rowCount = 0;
2970115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
2971115cd2caSopenharmony_ci    EXPECT_EQ(0, rowCount);
2972115cd2caSopenharmony_ci    ClearContacts();
2973115cd2caSopenharmony_ci}
2974115cd2caSopenharmony_ci
2975115cd2caSopenharmony_ci/*
2976115cd2caSopenharmony_ci * @tc.number  contact_BatchInsertAndDelete_test_6000
2977115cd2caSopenharmony_ci * @tc.name    Batch add contacts to the group, and then delete contacts from the group
2978115cd2caSopenharmony_ci * @tc.desc    Ability to join or remove contacts from groups in bulk
2979115cd2caSopenharmony_ci * @tc.level   Level1
2980115cd2caSopenharmony_ci * @tc.size    MediumTest
2981115cd2caSopenharmony_ci * @tc.type    Function
2982115cd2caSopenharmony_ci */
2983115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_BatchInsertAndDelete_test_6000, testing::ext::TestSize.Level1)
2984115cd2caSopenharmony_ci{
2985115cd2caSopenharmony_ci    HILOG_INFO("--- contact_BatchInsertAndDelete_test_6000 is staring! ---");
2986115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesGroup;
2987115cd2caSopenharmony_ci    int64_t groupIdOne = GroupsInsert("TestFourth", valuesGroup);
2988115cd2caSopenharmony_ci    EXPECT_GT(groupIdOne, 0);
2989115cd2caSopenharmony_ci
2990115cd2caSopenharmony_ci    valuesGroup.Clear();
2991115cd2caSopenharmony_ci    int64_t groupIdTwo = GroupsInsert("TestFifth", valuesGroup);
2992115cd2caSopenharmony_ci    EXPECT_GT(groupIdTwo, 0);
2993115cd2caSopenharmony_ci
2994115cd2caSopenharmony_ci    valuesGroup.Clear();
2995115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
2996115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("xiaocheng", rawContactValues);
2997115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
2998115cd2caSopenharmony_ci
2999115cd2caSopenharmony_ci    OHOS::Uri uriContactData(ContactsUri::CONTACT_DATA);
3000115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValuesOne;
3001115cd2caSopenharmony_ci    contactDataValuesOne.Put("raw_contact_id", rawContactId);
3002115cd2caSopenharmony_ci    contactDataValuesOne.Put("content_type", std::string("group_membership"));
3003115cd2caSopenharmony_ci    contactDataValuesOne.Put("detail_info", std::to_string(groupIdOne));
3004115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket contactDataValuesTwo;
3005115cd2caSopenharmony_ci    contactDataValuesTwo.Put("raw_contact_id", rawContactId);
3006115cd2caSopenharmony_ci    contactDataValuesTwo.Put("content_type", std::string("group_membership"));
3007115cd2caSopenharmony_ci    contactDataValuesTwo.Put("detail_info", std::to_string(groupIdTwo));
3008115cd2caSopenharmony_ci
3009115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> listAddBluk;
3010115cd2caSopenharmony_ci    listAddBluk.push_back(contactDataValuesOne);
3011115cd2caSopenharmony_ci    listAddBluk.push_back(contactDataValuesTwo);
3012115cd2caSopenharmony_ci    int batchInserCode = contactsDataAbility.BatchInsert(uriContactData, listAddBluk);
3013115cd2caSopenharmony_ci    EXPECT_EQ(batchInserCode, 0);
3014115cd2caSopenharmony_ci
3015115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
3016115cd2caSopenharmony_ci    predicates.EqualTo("raw_contact_id", std::to_string(rawContactId));
3017115cd2caSopenharmony_ci    predicates.And();
3018115cd2caSopenharmony_ci    predicates.EqualTo("detail_info", std::to_string(groupIdOne));
3019115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
3020115cd2caSopenharmony_ci    int deleteCode = ContactDelete(contactData, predicates);
3021115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
3022115cd2caSopenharmony_ci
3023115cd2caSopenharmony_ci    std::vector<std::string> columns;
3024115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(contactData, columns, predicates);
3025115cd2caSopenharmony_ci    int rowCount = 0;
3026115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
3027115cd2caSopenharmony_ci    EXPECT_EQ(0, rowCount);
3028115cd2caSopenharmony_ci    ClearContacts();
3029115cd2caSopenharmony_ci}
3030115cd2caSopenharmony_ci
3031115cd2caSopenharmony_ci/*
3032115cd2caSopenharmony_ci * @tc.number  abnormal_contact_Insert_test_6100
3033115cd2caSopenharmony_ci * @tc.name    When inserting a contact, pass in a non-existent field or table name
3034115cd2caSopenharmony_ci * @tc.desc    Exception use case
3035115cd2caSopenharmony_ci * @tc.level   Level1
3036115cd2caSopenharmony_ci * @tc.size    MediumTest
3037115cd2caSopenharmony_ci * @tc.type    Function
3038115cd2caSopenharmony_ci */
3039115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, abnormal_contact_Insert_test_6100, testing::ext::TestSize.Level1)
3040115cd2caSopenharmony_ci{
3041115cd2caSopenharmony_ci    HILOG_INFO("--- abnormal_contact_Insert_test_6100 is starting! ---");
3042115cd2caSopenharmony_ci
3043115cd2caSopenharmony_ci    OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT);
3044115cd2caSopenharmony_ci    OHOS::Uri errorUri(ContactsUri::ERROR_URI);
3045115cd2caSopenharmony_ci
3046115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
3047115cd2caSopenharmony_ci    rawContactValues.Put("display_names", "liming");
3048115cd2caSopenharmony_ci    int64_t rawontactId = contactsDataAbility.Insert(uriRawContact, rawContactValues);
3049115cd2caSopenharmony_ci    HILOG_INFO("abnormal_contact_Insert_test_6100 : rawontactId = %{public}ld", rawontactId);
3050115cd2caSopenharmony_ci    EXPECT_EQ(rawontactId, -1);
3051115cd2caSopenharmony_ci
3052115cd2caSopenharmony_ci    rawContactValues.Clear();
3053115cd2caSopenharmony_ci    rawContactValues.Put("display_name", "liming");
3054115cd2caSopenharmony_ci    rawontactId = contactsDataAbility.Insert(errorUri, rawContactValues);
3055115cd2caSopenharmony_ci    EXPECT_EQ(rawontactId, -1);
3056115cd2caSopenharmony_ci    ClearContacts();
3057115cd2caSopenharmony_ci}
3058115cd2caSopenharmony_ci
3059115cd2caSopenharmony_ci/*
3060115cd2caSopenharmony_ci * @tc.number  abnormal_contact_Insert_test_6200
3061115cd2caSopenharmony_ci * @tc.name    Verification of required fields(type_id) in contact_data table
3062115cd2caSopenharmony_ci * @tc.desc    Added ability to contact_data
3063115cd2caSopenharmony_ci * @tc.level   Level1
3064115cd2caSopenharmony_ci * @tc.size    MediumTest
3065115cd2caSopenharmony_ci * @tc.type    Function
3066115cd2caSopenharmony_ci */
3067115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, abnormal_contact_Insert_test_6200, testing::ext::TestSize.Level1)
3068115cd2caSopenharmony_ci{
3069115cd2caSopenharmony_ci    HILOG_INFO("-----abnormal_contact_Insert_test_6200 is starting!-----");
3070115cd2caSopenharmony_ci    std::vector<std::string> columnsInt;
3071115cd2caSopenharmony_ci    std::vector<std::string> columnsStr;
3072115cd2caSopenharmony_ci    std::vector<std::string> columns;
3073115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
3074115cd2caSopenharmony_ci    GetAllContactDataColumns(columnsInt, columnsStr);
3075115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
3076115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawValuesBucket;
3077115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("lock_type_id", rawValuesBucket);
3078115cd2caSopenharmony_ci    valuesBucket.Put("raw_contact_id", rawContactId);
3079115cd2caSopenharmony_ci    int ContactDataId = ContactDataInsertValues(valuesBucket);
3080115cd2caSopenharmony_ci    EXPECT_EQ(ContactDataId, -1);
3081115cd2caSopenharmony_ci
3082115cd2caSopenharmony_ci    MergeColumns(columns, columnsInt, columnsStr);
3083115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
3084115cd2caSopenharmony_ci    predicates.EqualTo("raw_contact_id", std::to_string(rawContactId));
3085115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(contactData, columns, predicates);
3086115cd2caSopenharmony_ci
3087115cd2caSopenharmony_ci    // resultSet count 0
3088115cd2caSopenharmony_ci    int rowCount = -1;
3089115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
3090115cd2caSopenharmony_ci    EXPECT_EQ(0, rowCount);
3091115cd2caSopenharmony_ci    CheckResultSet(valuesBucket, resultSet, "abnormal_contact_Insert_test_6200");
3092115cd2caSopenharmony_ci    ClearContacts();
3093115cd2caSopenharmony_ci}
3094115cd2caSopenharmony_ci
3095115cd2caSopenharmony_ci/*
3096115cd2caSopenharmony_ci * @tc.number  abnormal_contact_Insert_test_6300
3097115cd2caSopenharmony_ci * @tc.name    Verification of required fields(raw_contact_id) in contact_data table
3098115cd2caSopenharmony_ci * @tc.desc    Added ability to contact_data
3099115cd2caSopenharmony_ci * @tc.level   Level1
3100115cd2caSopenharmony_ci * @tc.size    MediumTest
3101115cd2caSopenharmony_ci *
3102115cd2caSopenharmony_ci * @tc.type    Function
3103115cd2caSopenharmony_ci */
3104115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, abnormal_contact_Insert_test_6300, testing::ext::TestSize.Level1)
3105115cd2caSopenharmony_ci{
3106115cd2caSopenharmony_ci    HILOG_INFO("-----abnormal_contact_Insert_test_6300 is starting!-----");
3107115cd2caSopenharmony_ci    std::vector<std::string> columnsInt;
3108115cd2caSopenharmony_ci    std::vector<std::string> columnsStr;
3109115cd2caSopenharmony_ci    std::vector<std::string> columns;
3110115cd2caSopenharmony_ci    std::string contactData = ContactTabName::CONTACT_DATA;
3111115cd2caSopenharmony_ci    GetAllContactDataColumns(columnsInt, columnsStr);
3112115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket valuesBucket = GetAllColumnsValues(columnsInt, columnsStr);
3113115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawValuesBucket;
3114115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("lock_raw_contact_id", rawValuesBucket);
3115115cd2caSopenharmony_ci    valuesBucket.Put("type_id", 6);
3116115cd2caSopenharmony_ci    int ContactDataId = ContactDataInsertValues(valuesBucket);
3117115cd2caSopenharmony_ci    EXPECT_EQ(ContactDataId, -1);
3118115cd2caSopenharmony_ci
3119115cd2caSopenharmony_ci    MergeColumns(columns, columnsInt, columnsStr);
3120115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
3121115cd2caSopenharmony_ci    predicates.EqualTo("raw_contact_id", std::to_string(rawContactId));
3122115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(contactData, columns, predicates);
3123115cd2caSopenharmony_ci
3124115cd2caSopenharmony_ci    // resultSet count 0
3125115cd2caSopenharmony_ci    int rowCount = -1;
3126115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
3127115cd2caSopenharmony_ci    EXPECT_EQ(0, rowCount);
3128115cd2caSopenharmony_ci    CheckResultSet(valuesBucket, resultSet, "abnormal_contact_Insert_test_6300");
3129115cd2caSopenharmony_ci    ClearContacts();
3130115cd2caSopenharmony_ci}
3131115cd2caSopenharmony_ci
3132115cd2caSopenharmony_ci/*
3133115cd2caSopenharmony_ci * @tc.number  abnormal_contact_Update_test_6400
3134115cd2caSopenharmony_ci * @tc.name    When modifying, an incorrect field or table name or non-existent value is passed in
3135115cd2caSopenharmony_ci * @tc.desc    Exception use case
3136115cd2caSopenharmony_ci * @tc.level   Level1
3137115cd2caSopenharmony_ci * @tc.size    MediumTest
3138115cd2caSopenharmony_ci * @tc.type    Function
3139115cd2caSopenharmony_ci */
3140115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, abnormal_contact_Update_test_6400, testing::ext::TestSize.Level1)
3141115cd2caSopenharmony_ci{
3142115cd2caSopenharmony_ci    HILOG_INFO("--- abnormal_contact_Update_test_6400 is starting! ---");
3143115cd2caSopenharmony_ci    OHOS::Uri errorUri(ContactsUri::ERROR_URI);
3144115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
3145115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("zhangming", rawContactValues);
3146115cd2caSopenharmony_ci    HILOG_INFO("abnormal_contact_Update_test_6400 : rawContactId = %{public}ld", rawContactId);
3147115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
3148115cd2caSopenharmony_ci
3149115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
3150115cd2caSopenharmony_ci    updateValues.Put("display_names", "dongming");
3151115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
3152115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactId));
3153115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
3154115cd2caSopenharmony_ci    int updateCode = ContactUpdate(rawContacts, updateValues, predicates);
3155115cd2caSopenharmony_ci    HILOG_INFO("abnormal_contact_Update_test_6400: updateCode = %{public}d", updateCode);
3156115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, -1);
3157115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, rawContactValues, "abnormal_contact_Update_test_6400");
3158115cd2caSopenharmony_ci
3159115cd2caSopenharmony_ci    updateValues.Clear();
3160115cd2caSopenharmony_ci    updateValues.Put("display_name", "dongming");
3161115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
3162115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(rawContactId));
3163115cd2caSopenharmony_ci    updateCode = contactsDataAbility.Update(errorUri, predicates2, updateValues);
3164115cd2caSopenharmony_ci    HILOG_INFO("abnormal_contact_Update_test_6400: updateCode = %{public}d", updateCode);
3165115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, -1);
3166115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates2, rawContactValues, "abnormal_contact_Update_test_6400");
3167115cd2caSopenharmony_ci
3168115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
3169115cd2caSopenharmony_ci    predicates3.EqualTo("id", "100000");
3170115cd2caSopenharmony_ci    updateCode = ContactUpdate(rawContacts, updateValues, predicates3);
3171115cd2caSopenharmony_ci    HILOG_INFO("abnormal_contact_Update_test_6400: updateCode = %{public}d", updateCode);
3172115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
3173115cd2caSopenharmony_ci    ClearContacts();
3174115cd2caSopenharmony_ci}
3175115cd2caSopenharmony_ci
3176115cd2caSopenharmony_ci/*
3177115cd2caSopenharmony_ci * @tc.number  abnormal_contact_Query_test_6500
3178115cd2caSopenharmony_ci * @tc.name    A wrong field was passed in when querying
3179115cd2caSopenharmony_ci * @tc.desc    Exception use case
3180115cd2caSopenharmony_ci * @tc.level   Level1
3181115cd2caSopenharmony_ci * @tc.size    MediumTest
3182115cd2caSopenharmony_ci * @tc.type    Function
3183115cd2caSopenharmony_ci */
3184115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, abnormal_contact_Query_test_6500, testing::ext::TestSize.Level1)
3185115cd2caSopenharmony_ci{
3186115cd2caSopenharmony_ci    HILOG_INFO("--- abnormal_contact_Query_test_6500 is starting! ---");
3187115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
3188115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("dongming", rawContactValues);
3189115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
3190115cd2caSopenharmony_ci
3191115cd2caSopenharmony_ci    std::vector<std::string> columns;
3192115cd2caSopenharmony_ci    columns.push_back("display_names");
3193115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
3194115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactId));
3195115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
3196115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet = ContactQuery(rawContacts, columns, predicates);
3197115cd2caSopenharmony_ci
3198115cd2caSopenharmony_ci    int rowCount = -2;
3199115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
3200115cd2caSopenharmony_ci    EXPECT_EQ(-1, rowCount);
3201115cd2caSopenharmony_ci    ClearContacts();
3202115cd2caSopenharmony_ci}
3203115cd2caSopenharmony_ci
3204115cd2caSopenharmony_ci/*
3205115cd2caSopenharmony_ci * @tc.number  abnormal_contact_Query_test_6600
3206115cd2caSopenharmony_ci * @tc.name    Pass in a non-existent table name when querying
3207115cd2caSopenharmony_ci * @tc.desc    Exception use case
3208115cd2caSopenharmony_ci * @tc.level   Level1
3209115cd2caSopenharmony_ci * @tc.size    MediumTest
3210115cd2caSopenharmony_ci * @tc.type    Function
3211115cd2caSopenharmony_ci */
3212115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, abnormal_contact_Query_test_6600, testing::ext::TestSize.Level1)
3213115cd2caSopenharmony_ci{
3214115cd2caSopenharmony_ci    HILOG_INFO("--- abnormal_contact_Query_test_6600 is starting! ---");
3215115cd2caSopenharmony_ci    std::string tag("abnormal_contact_Query_test_6600");
3216115cd2caSopenharmony_ci
3217115cd2caSopenharmony_ci    OHOS::Uri errorUri(ContactsUri::ERROR_URI);
3218115cd2caSopenharmony_ci
3219115cd2caSopenharmony_ci    std::vector<std::string> columns;
3220115cd2caSopenharmony_ci    columns.push_back("id");
3221115cd2caSopenharmony_ci    columns.push_back("display_name");
3222115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
3223115cd2caSopenharmony_ci    predicates.GreaterThan("id", "0");
3224115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
3225115cd2caSopenharmony_ci        contactsDataAbility.Query(errorUri, predicates, columns);
3226115cd2caSopenharmony_ci    EXPECT_EQ(resultSet, nullptr);
3227115cd2caSopenharmony_ci    ClearContacts();
3228115cd2caSopenharmony_ci}
3229115cd2caSopenharmony_ci
3230115cd2caSopenharmony_ci/*
3231115cd2caSopenharmony_ci * @tc.number  abnormal_contact_Delete_test_6700
3232115cd2caSopenharmony_ci * @tc.name    When deleting, pass in an incorrect field or table name or a non-existent value
3233115cd2caSopenharmony_ci * @tc.desc    Exception use case
3234115cd2caSopenharmony_ci * @tc.level   Level1
3235115cd2caSopenharmony_ci * @tc.size    MediumTest
3236115cd2caSopenharmony_ci * @tc.type    Function
3237115cd2caSopenharmony_ci */
3238115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, abnormal_contact_Delete_test_6700, testing::ext::TestSize.Level1)
3239115cd2caSopenharmony_ci{
3240115cd2caSopenharmony_ci    HILOG_INFO("-------abnormal_contact_Delete_test_6700 is starting!-------");
3241115cd2caSopenharmony_ci    OHOS::Uri errorUri(ContactsUri::ERROR_URI);
3242115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket values;
3243115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("zhangming", values);
3244115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
3245115cd2caSopenharmony_ci
3246115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
3247115cd2caSopenharmony_ci    predicates.EqualTo("ids", std::to_string(rawContactId));
3248115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
3249115cd2caSopenharmony_ci    int deleteCode = ContactDelete(rawContacts, predicates);
3250115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, -1);
3251115cd2caSopenharmony_ci
3252115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicatesQuery;
3253115cd2caSopenharmony_ci    predicatesQuery.EqualTo("id", std::to_string(rawContactId));
3254115cd2caSopenharmony_ci    std::vector<std::string> columns;
3255115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
3256115cd2caSopenharmony_ci        ContactQuery(rawContacts, columns, predicatesQuery);
3257115cd2caSopenharmony_ci    int rowCount = 0;
3258115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
3259115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
3260115cd2caSopenharmony_ci    resultSet->Close();
3261115cd2caSopenharmony_ci
3262115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
3263115cd2caSopenharmony_ci    predicates2.EqualTo("id", std::to_string(rawContactId));
3264115cd2caSopenharmony_ci    deleteCode = contactsDataAbility.Delete(errorUri, predicates2);
3265115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, -1);
3266115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSetUri =
3267115cd2caSopenharmony_ci        ContactQuery(rawContacts, columns, predicatesQuery);
3268115cd2caSopenharmony_ci    int rowCountUri = 0;
3269115cd2caSopenharmony_ci    resultSetUri->GetRowCount(rowCountUri);
3270115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCountUri);
3271115cd2caSopenharmony_ci    resultSetUri->Close();
3272115cd2caSopenharmony_ci
3273115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates3;
3274115cd2caSopenharmony_ci    predicates3.EqualTo("id", "10000000");
3275115cd2caSopenharmony_ci    deleteCode = ContactDelete(rawContacts, predicates3);
3276115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, -1);
3277115cd2caSopenharmony_ci
3278115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates4;
3279115cd2caSopenharmony_ci    predicates4.EqualTo("id", std::to_string(rawContactId));
3280115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSetId =
3281115cd2caSopenharmony_ci        ContactQuery(rawContacts, columns, predicatesQuery);
3282115cd2caSopenharmony_ci    int rowCountId = 0;
3283115cd2caSopenharmony_ci    resultSetId->GetRowCount(rowCountId);
3284115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCountId);
3285115cd2caSopenharmony_ci    resultSetId->Close();
3286115cd2caSopenharmony_ci    ClearContacts();
3287115cd2caSopenharmony_ci}
3288115cd2caSopenharmony_ci
3289115cd2caSopenharmony_ci/*
3290115cd2caSopenharmony_ci * @tc.number  abnormal_contact_BatchInsert_test_6800
3291115cd2caSopenharmony_ci * @tc.name    When adding contacts in batches, some of them failed, check the processing logic
3292115cd2caSopenharmony_ci * @tc.desc    Exception use case
3293115cd2caSopenharmony_ci * @tc.level   Level1
3294115cd2caSopenharmony_ci * @tc.size    MediumTest
3295115cd2caSopenharmony_ci * @tc.type    Function
3296115cd2caSopenharmony_ci */
3297115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, abnormal_contact_BatchInsert_test_6800, testing::ext::TestSize.Level1)
3298115cd2caSopenharmony_ci{
3299115cd2caSopenharmony_ci    HILOG_INFO("--- abnormal_contact_BatchInsert_test_6800 is starting! ---");
3300115cd2caSopenharmony_ci    OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT);
3301115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
3302115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> listAddBluk;
3303115cd2caSopenharmony_ci    int batchInserCode = 0;
3304115cd2caSopenharmony_ci    for (int i = 0; i < 10; i++) {
3305115cd2caSopenharmony_ci        listAddBluk.clear();
3306115cd2caSopenharmony_ci        for (int j = 10 * i + 1; j <= 10 * (i + 1); j++) {
3307115cd2caSopenharmony_ci            rawContactValues.Clear();
3308115cd2caSopenharmony_ci            std::string name("zhangming");
3309115cd2caSopenharmony_ci            name.append(std::to_string(j));
3310115cd2caSopenharmony_ci            if (j == 14 || j == 27 || j == 57) {
3311115cd2caSopenharmony_ci                rawContactValues.Put("display_names", name);
3312115cd2caSopenharmony_ci            } else {
3313115cd2caSopenharmony_ci                rawContactValues.Put("display_name", name);
3314115cd2caSopenharmony_ci            }
3315115cd2caSopenharmony_ci            listAddBluk.push_back(rawContactValues);
3316115cd2caSopenharmony_ci        }
3317115cd2caSopenharmony_ci        batchInserCode = contactsDataAbility.BatchInsert(uriRawContact, listAddBluk);
3318115cd2caSopenharmony_ci        HILOG_INFO("abnormal_contact_BatchInsert_test_6800 : batchInserCode = %{public}d", batchInserCode);
3319115cd2caSopenharmony_ci        if (batchInserCode == 0) {
3320115cd2caSopenharmony_ci            HILOG_INFO("abnormal_contact_BatchInsert_test_6800 batch insert success!");
3321115cd2caSopenharmony_ci        } else {
3322115cd2caSopenharmony_ci            HILOG_INFO("abnormal_contact_BatchInsert_test_6800 batch insert fail!");
3323115cd2caSopenharmony_ci            EXPECT_EQ(batchInserCode, -1);
3324115cd2caSopenharmony_ci        }
3325115cd2caSopenharmony_ci    }
3326115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
3327115cd2caSopenharmony_ci    predicates.NotEqualTo("id", "0");
3328115cd2caSopenharmony_ci    predicates.And();
3329115cd2caSopenharmony_ci    predicates.EqualTo("is_deleted", "0");
3330115cd2caSopenharmony_ci    contactsDataAbility.Delete(uriRawContact, predicates);
3331115cd2caSopenharmony_ci    int time = 20000;
3332115cd2caSopenharmony_ci    std::chrono::milliseconds dura(time);
3333115cd2caSopenharmony_ci    std::this_thread::sleep_for(dura);
3334115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
3335115cd2caSopenharmony_ci    OHOS::Uri uriRawContactComplete(ContactsUri::DELETED_RAW_CONTACT);
3336115cd2caSopenharmony_ci    predicates2.NotEqualTo("id", "0");
3337115cd2caSopenharmony_ci    contactsDataAbility.Delete(uriRawContactComplete, predicates2);
3338115cd2caSopenharmony_ci}
3339115cd2caSopenharmony_ci
3340115cd2caSopenharmony_ci/*
3341115cd2caSopenharmony_ci * @tc.number  abnormal_contact_BatchInsert_test_6900
3342115cd2caSopenharmony_ci * @tc.name    When adding contacts in batch, item 500 fails. Check the subsequent processing logic
3343115cd2caSopenharmony_ci * @tc.desc    Exception use case
3344115cd2caSopenharmony_ci * @tc.level   Level1
3345115cd2caSopenharmony_ci * @tc.size    MediumTest
3346115cd2caSopenharmony_ci * @tc.type    Function
3347115cd2caSopenharmony_ci */
3348115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, abnormal_contact_BatchInsert_test_6900, testing::ext::TestSize.Level1)
3349115cd2caSopenharmony_ci{
3350115cd2caSopenharmony_ci    HILOG_INFO("--- abnormal_contact_BatchInsert_test_6900 is starting! ---");
3351115cd2caSopenharmony_ci    OHOS::Uri uriRawContact(ContactsUri::RAW_CONTACT);
3352115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
3353115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> listAddBluk;
3354115cd2caSopenharmony_ci    for (int i = 0; i < 1000; i++) {
3355115cd2caSopenharmony_ci        rawContactValues.Clear();
3356115cd2caSopenharmony_ci        std::string name("xiaoyuan");
3357115cd2caSopenharmony_ci        name.append(std::to_string(i));
3358115cd2caSopenharmony_ci        if (i == 500) {
3359115cd2caSopenharmony_ci            rawContactValues.Put("display_names", name);
3360115cd2caSopenharmony_ci        } else {
3361115cd2caSopenharmony_ci            rawContactValues.Put("display_name", name);
3362115cd2caSopenharmony_ci        }
3363115cd2caSopenharmony_ci        listAddBluk.push_back(rawContactValues);
3364115cd2caSopenharmony_ci    }
3365115cd2caSopenharmony_ci    int batchInserCode = contactsDataAbility.BatchInsert(uriRawContact, listAddBluk);
3366115cd2caSopenharmony_ci    HILOG_INFO("abnormal_contact_BatchInsert_test_6900 : batchInserCode = %{public}d", batchInserCode);
3367115cd2caSopenharmony_ci    if (batchInserCode == 0) {
3368115cd2caSopenharmony_ci        HILOG_INFO("abnormal_contact_BatchInsert_test_6900 batch insert success!");
3369115cd2caSopenharmony_ci    } else {
3370115cd2caSopenharmony_ci        HILOG_INFO("abnormal_contact_BatchInsert_test_6900 batch insert fail!");
3371115cd2caSopenharmony_ci        EXPECT_EQ(batchInserCode, -1);
3372115cd2caSopenharmony_ci    }
3373115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
3374115cd2caSopenharmony_ci    predicates.NotEqualTo("id", "0");
3375115cd2caSopenharmony_ci    predicates.And();
3376115cd2caSopenharmony_ci    predicates.EqualTo("is_deleted", "0");
3377115cd2caSopenharmony_ci    contactsDataAbility.Delete(uriRawContact, predicates);
3378115cd2caSopenharmony_ci    int time = 20000;
3379115cd2caSopenharmony_ci    std::chrono::milliseconds dura(time);
3380115cd2caSopenharmony_ci    std::this_thread::sleep_for(dura);
3381115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates2;
3382115cd2caSopenharmony_ci    OHOS::Uri uriRawContactComplete(ContactsUri::DELETED_RAW_CONTACT);
3383115cd2caSopenharmony_ci    predicates2.NotEqualTo("id", "0");
3384115cd2caSopenharmony_ci    contactsDataAbility.Delete(uriRawContactComplete, predicates2);
3385115cd2caSopenharmony_ci}
3386115cd2caSopenharmony_ci
3387115cd2caSopenharmony_ci/*
3388115cd2caSopenharmony_ci * @tc.number  contact_async_insert_test_7000
3389115cd2caSopenharmony_ci * @tc.name    Add contacts async
3390115cd2caSopenharmony_ci * @tc.desc    Ability to join or add contacts
3391115cd2caSopenharmony_ci * @tc.level   Level1
3392115cd2caSopenharmony_ci * @tc.size    MediumTest
3393115cd2caSopenharmony_ci * @tc.type    Function
3394115cd2caSopenharmony_ci */
3395115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_async_insert_test_7000, testing::ext::TestSize.Level1)
3396115cd2caSopenharmony_ci{
3397115cd2caSopenharmony_ci    HILOG_INFO("--- contact_async_insert_test_7000 is staring! ---");
3398115cd2caSopenharmony_ci    std::map<int, OHOS::DataShare::DataShareValuesBucket> result;
3399115cd2caSopenharmony_ci    std::vector<ContactAsync *> contactAsyncVector;
3400115cd2caSopenharmony_ci    int threadNum = 6;
3401115cd2caSopenharmony_ci    for (int i = 0; i < threadNum; ++i) {
3402115cd2caSopenharmony_ci        OHOS::DataShare::DataShareValuesBucket values;
3403115cd2caSopenharmony_ci        std::string name;
3404115cd2caSopenharmony_ci        name.append("asyncTest");
3405115cd2caSopenharmony_ci        name.append(std::to_string(i));
3406115cd2caSopenharmony_ci        values.Put("display_name", name);
3407115cd2caSopenharmony_ci        ContactAsync *contactAsync = new ContactAsync(values, result);
3408115cd2caSopenharmony_ci        std::thread asyncThread(&ContactAsync::Insert, contactAsync);
3409115cd2caSopenharmony_ci        contactAsyncVector.push_back(contactAsync);
3410115cd2caSopenharmony_ci        asyncThread.detach();
3411115cd2caSopenharmony_ci    }
3412115cd2caSopenharmony_ci    std::chrono::milliseconds dura(Time::ASYNC_SLEEP_TIME);
3413115cd2caSopenharmony_ci    std::this_thread::sleep_for(dura);
3414115cd2caSopenharmony_ci    std::vector<std::string> columns;
3415115cd2caSopenharmony_ci    columns.push_back("display_name");
3416115cd2caSopenharmony_ci    std::map<int, OHOS::DataShare::DataShareValuesBucket>::iterator it;
3417115cd2caSopenharmony_ci    for (it = result.begin(); it != result.end(); it++) {
3418115cd2caSopenharmony_ci        OHOS::DataShare::DataSharePredicates predicates;
3419115cd2caSopenharmony_ci        predicates.EqualTo("id", std::to_string(it->first));
3420115cd2caSopenharmony_ci        std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
3421115cd2caSopenharmony_ci            ContactQuery(ContactTabName::RAW_CONTACT, columns, predicates);
3422115cd2caSopenharmony_ci        CheckResultSet(it->second, resultSet, "contact_async_insert_test_7000");
3423115cd2caSopenharmony_ci    }
3424115cd2caSopenharmony_ci    for (int i = 0; i < threadNum; ++i) {
3425115cd2caSopenharmony_ci        delete contactAsyncVector[i];
3426115cd2caSopenharmony_ci    }
3427115cd2caSopenharmony_ci    ClearContacts();
3428115cd2caSopenharmony_ci}
3429115cd2caSopenharmony_ci
3430115cd2caSopenharmony_ci/*
3431115cd2caSopenharmony_ci * @tc.number  contact_async_update_test_7100
3432115cd2caSopenharmony_ci * @tc.name    update contacts async
3433115cd2caSopenharmony_ci * @tc.desc    Ability to join or update contacts
3434115cd2caSopenharmony_ci * @tc.level   Level1
3435115cd2caSopenharmony_ci * @tc.size    MediumTest
3436115cd2caSopenharmony_ci * @tc.type    Function
3437115cd2caSopenharmony_ci */
3438115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_async_update_test_7100, testing::ext::TestSize.Level1)
3439115cd2caSopenharmony_ci{
3440115cd2caSopenharmony_ci    HILOG_INFO("--- contact_async_update_test_7100 is staring! ---");
3441115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawValuesBucket;
3442115cd2caSopenharmony_ci    std::vector<int64_t> rawContactId;
3443115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_update1", rawValuesBucket));
3444115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3445115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_update2", rawValuesBucket));
3446115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3447115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_update3", rawValuesBucket));
3448115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3449115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_update4", rawValuesBucket));
3450115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3451115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_update5", rawValuesBucket));
3452115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3453115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_update6", rawValuesBucket));
3454115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3455115cd2caSopenharmony_ci    std::vector<OHOS::DataShare::DataShareValuesBucket> upDateValues;
3456115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates queryPredicates;
3457115cd2caSopenharmony_ci    std::vector<ContactAsync *> contactAsyncVector;
3458115cd2caSopenharmony_ci    int size = rawContactId.size();
3459115cd2caSopenharmony_ci    for (int i = 0; i < size; ++i) {
3460115cd2caSopenharmony_ci        OHOS::DataShare::DataShareValuesBucket values;
3461115cd2caSopenharmony_ci        std::string name;
3462115cd2caSopenharmony_ci        name.append("asyncTest");
3463115cd2caSopenharmony_ci        values.Put("display_name", name);
3464115cd2caSopenharmony_ci        upDateValues.push_back(values);
3465115cd2caSopenharmony_ci        int id = rawContactId[i];
3466115cd2caSopenharmony_ci        ContactAsync *contactAsync = new ContactAsync(values, id);
3467115cd2caSopenharmony_ci        contactAsyncVector.push_back(contactAsync);
3468115cd2caSopenharmony_ci        std::thread asyncThread(&ContactAsync::Update, contactAsync);
3469115cd2caSopenharmony_ci        asyncThread.detach();
3470115cd2caSopenharmony_ci        queryPredicates.EqualTo("id", std::to_string(rawContactId[i]));
3471115cd2caSopenharmony_ci        if (i < size - 1) {
3472115cd2caSopenharmony_ci            queryPredicates.Or();
3473115cd2caSopenharmony_ci        }
3474115cd2caSopenharmony_ci    }
3475115cd2caSopenharmony_ci    std::chrono::milliseconds dura(Time::ASYNC_SLEEP_TIME);
3476115cd2caSopenharmony_ci    std::this_thread::sleep_for(dura);
3477115cd2caSopenharmony_ci    std::vector<std::string> columns;
3478115cd2caSopenharmony_ci    columns.push_back("display_name");
3479115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
3480115cd2caSopenharmony_ci        ContactQuery(ContactTabName::RAW_CONTACT, columns, queryPredicates);
3481115cd2caSopenharmony_ci    CheckResultSetList(upDateValues, resultSet, "contact_async_update_test_7100");
3482115cd2caSopenharmony_ci    for (int i = 0; i < size; ++i) {
3483115cd2caSopenharmony_ci        delete contactAsyncVector[i];
3484115cd2caSopenharmony_ci    }
3485115cd2caSopenharmony_ci    ClearContacts();
3486115cd2caSopenharmony_ci}
3487115cd2caSopenharmony_ci
3488115cd2caSopenharmony_ci/*
3489115cd2caSopenharmony_ci * @tc.number  contact_async_query_test_7200
3490115cd2caSopenharmony_ci * @tc.name    query contacts async
3491115cd2caSopenharmony_ci * @tc.desc    Ability to join or query
3492115cd2caSopenharmony_ci * @tc.level   Level1
3493115cd2caSopenharmony_ci * @tc.size    MediumTest
3494115cd2caSopenharmony_ci * @tc.type    Function
3495115cd2caSopenharmony_ci */
3496115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_async_query_test_7200, testing::ext::TestSize.Level1)
3497115cd2caSopenharmony_ci{
3498115cd2caSopenharmony_ci    HILOG_INFO("--- contact_async_query_test_7200 is staring! ---");
3499115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawValuesBucket;
3500115cd2caSopenharmony_ci    std::vector<int64_t> rawContactId;
3501115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_query1", rawValuesBucket));
3502115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3503115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_query2", rawValuesBucket));
3504115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3505115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_query3", rawValuesBucket));
3506115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3507115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_query4", rawValuesBucket));
3508115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3509115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_query5", rawValuesBucket));
3510115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3511115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_query6", rawValuesBucket));
3512115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3513115cd2caSopenharmony_ci    std::vector<ContactAsync *> contactAsyncVector;
3514115cd2caSopenharmony_ci    std::vector<std::shared_ptr<OHOS::DataShare::DataShareResultSet>> resultSetVector;
3515115cd2caSopenharmony_ci    int threadNum = 6;
3516115cd2caSopenharmony_ci    for (int i = 0; i < threadNum; ++i) {
3517115cd2caSopenharmony_ci        ContactAsync *contactAsync = new ContactAsync(resultSetVector, rawContactId);
3518115cd2caSopenharmony_ci        contactAsyncVector.push_back(contactAsync);
3519115cd2caSopenharmony_ci        std::thread asyncThread(&ContactAsync::Query, contactAsync);
3520115cd2caSopenharmony_ci        asyncThread.detach();
3521115cd2caSopenharmony_ci    }
3522115cd2caSopenharmony_ci    int queryCount = 6;
3523115cd2caSopenharmony_ci    int size = resultSetVector.size();
3524115cd2caSopenharmony_ci    for (int i = 0; i < size; ++i) {
3525115cd2caSopenharmony_ci        int rowCount = 0;
3526115cd2caSopenharmony_ci        resultSetVector[i]->GetRowCount(rowCount);
3527115cd2caSopenharmony_ci        EXPECT_EQ(queryCount, rowCount);
3528115cd2caSopenharmony_ci        resultSetVector[i]->Close();
3529115cd2caSopenharmony_ci    }
3530115cd2caSopenharmony_ci    for (int i = 0; i < size; ++i) {
3531115cd2caSopenharmony_ci        delete contactAsyncVector[i];
3532115cd2caSopenharmony_ci    }
3533115cd2caSopenharmony_ci    ClearContacts();
3534115cd2caSopenharmony_ci}
3535115cd2caSopenharmony_ci
3536115cd2caSopenharmony_ci/*
3537115cd2caSopenharmony_ci * @tc.number  contact_async_delete_test_7300
3538115cd2caSopenharmony_ci * @tc.name    delete contacts async
3539115cd2caSopenharmony_ci * @tc.desc    Ability to join or delete contacts
3540115cd2caSopenharmony_ci * @tc.level   Level1
3541115cd2caSopenharmony_ci * @tc.size    MediumTest
3542115cd2caSopenharmony_ci * @tc.type    Function
3543115cd2caSopenharmony_ci */
3544115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_async_delete_test_7300, testing::ext::TestSize.Level1)
3545115cd2caSopenharmony_ci{
3546115cd2caSopenharmony_ci    HILOG_INFO("--- contact_async_delete_test_7300 is staring! ---");
3547115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawValuesBucket;
3548115cd2caSopenharmony_ci    std::vector<int64_t> rawContactId;
3549115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_update1", rawValuesBucket));
3550115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3551115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_update2", rawValuesBucket));
3552115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3553115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_update3", rawValuesBucket));
3554115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3555115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_update4", rawValuesBucket));
3556115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3557115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_update5", rawValuesBucket));
3558115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3559115cd2caSopenharmony_ci    rawContactId.push_back(RawContactInsert("async_update6", rawValuesBucket));
3560115cd2caSopenharmony_ci    rawValuesBucket.Clear();
3561115cd2caSopenharmony_ci    int size = rawContactId.size();
3562115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
3563115cd2caSopenharmony_ci    predicates.BeginWrap();
3564115cd2caSopenharmony_ci    std::vector<ContactAsync *> contactAsyncVector;
3565115cd2caSopenharmony_ci    for (int i = 0; i < size; ++i) {
3566115cd2caSopenharmony_ci        int id = rawContactId[i];
3567115cd2caSopenharmony_ci        ContactAsync *contactAsync = new ContactAsync(id);
3568115cd2caSopenharmony_ci        contactAsyncVector.push_back(contactAsync);
3569115cd2caSopenharmony_ci        std::thread asyncThread(&ContactAsync::Delete, contactAsync);
3570115cd2caSopenharmony_ci        asyncThread.detach();
3571115cd2caSopenharmony_ci        predicates.EqualTo("id", std::to_string(id));
3572115cd2caSopenharmony_ci        if (i < size - 1) {
3573115cd2caSopenharmony_ci            predicates.Or();
3574115cd2caSopenharmony_ci        }
3575115cd2caSopenharmony_ci    }
3576115cd2caSopenharmony_ci    predicates.EndWrap();
3577115cd2caSopenharmony_ci    predicates.And();
3578115cd2caSopenharmony_ci    predicates.EqualTo("is_deleted", "0");
3579115cd2caSopenharmony_ci    std::chrono::milliseconds dura(Time::ASYNC_SLEEP_TIME);
3580115cd2caSopenharmony_ci    std::this_thread::sleep_for(dura);
3581115cd2caSopenharmony_ci    std::vector<std::string> columns;
3582115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
3583115cd2caSopenharmony_ci        ContactQuery(ContactTabName::RAW_CONTACT, columns, predicates);
3584115cd2caSopenharmony_ci    int rowCount = 0;
3585115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
3586115cd2caSopenharmony_ci    EXPECT_EQ(0, rowCount);
3587115cd2caSopenharmony_ci    resultSet->Close();
3588115cd2caSopenharmony_ci    for (int i = 0; i < size; ++i) {
3589115cd2caSopenharmony_ci        delete contactAsyncVector[i];
3590115cd2caSopenharmony_ci    }
3591115cd2caSopenharmony_ci    ClearContacts();
3592115cd2caSopenharmony_ci}
3593115cd2caSopenharmony_ci
3594115cd2caSopenharmony_ci/*
3595115cd2caSopenharmony_ci * @tc.number  contact_Insert_test_7400
3596115cd2caSopenharmony_ci * @tc.name    Add the basic information of a single contact and verify text whether the insertion is successful
3597115cd2caSopenharmony_ci * @tc.desc    New capabilities for basic contact data
3598115cd2caSopenharmony_ci * @tc.level   Level1
3599115cd2caSopenharmony_ci * @tc.size    MediumTest
3600115cd2caSopenharmony_ci * @tc.type    Function
3601115cd2caSopenharmony_ci */
3602115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Insert_test_7400, testing::ext::TestSize.Level1)
3603115cd2caSopenharmony_ci{
3604115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Insert_test_7400 is starting! ---");
3605115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket values;
3606115cd2caSopenharmony_ci    int size = 20000;
3607115cd2caSopenharmony_ci    std::string name;
3608115cd2caSopenharmony_ci    for (int i = 0; i < size; ++i) {
3609115cd2caSopenharmony_ci        name.append("l");
3610115cd2caSopenharmony_ci    }
3611115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert(name, values);
3612115cd2caSopenharmony_ci    HILOG_INFO("contact_Insert_test_7400 : rawContactId = %{public}ld", rawContactId);
3613115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
3614115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
3615115cd2caSopenharmony_ci    predicates.EqualTo("id", std::to_string(rawContactId));
3616115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
3617115cd2caSopenharmony_ci    QueryAndExpectResult(rawContacts, predicates, values, "contact_Insert_test_7400");
3618115cd2caSopenharmony_ci    ClearContacts();
3619115cd2caSopenharmony_ci}
3620115cd2caSopenharmony_ci
3621115cd2caSopenharmony_ci/*
3622115cd2caSopenharmony_ci * @tc.number  contact_Delete_Recover_test_7500
3623115cd2caSopenharmony_ci * @tc.name    recover deleted basic data
3624115cd2caSopenharmony_ci * @tc.desc    Ability to recover  record basic data of a single contact
3625115cd2caSopenharmony_ci * @tc.level   Level1
3626115cd2caSopenharmony_ci * @tc.size    MediumTest
3627115cd2caSopenharmony_ci * @tc.type    Function
3628115cd2caSopenharmony_ci */
3629115cd2caSopenharmony_ciHWTEST_F(ContactAbilityTest, contact_Delete_Recover_test_7500, testing::ext::TestSize.Level1)
3630115cd2caSopenharmony_ci{
3631115cd2caSopenharmony_ci    HILOG_INFO("--- contact_Delete_Recover_test_7500 is starting! ---");
3632115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket rawContactValues;
3633115cd2caSopenharmony_ci    int64_t rawContactId = RawContactInsert("xiaohongDelete", rawContactValues);
3634115cd2caSopenharmony_ci    EXPECT_GT(rawContactId, 0);
3635115cd2caSopenharmony_ci
3636115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicates;
3637115cd2caSopenharmony_ci    predicates.EqualTo("name_raw_contact_id", std::to_string(rawContactId));
3638115cd2caSopenharmony_ci    std::string contact = ContactTabName::CONTACT;
3639115cd2caSopenharmony_ci    int deleteCode = ContactDelete(contact, predicates);
3640115cd2caSopenharmony_ci    EXPECT_EQ(deleteCode, 0);
3641115cd2caSopenharmony_ci    int time = 2000;
3642115cd2caSopenharmony_ci    std::chrono::milliseconds dura(time);
3643115cd2caSopenharmony_ci    std::this_thread::sleep_for(dura);
3644115cd2caSopenharmony_ci
3645115cd2caSopenharmony_ci    OHOS::DataShare::DataShareValuesBucket updateValues;
3646115cd2caSopenharmony_ci    updateValues.Put("is_deleted", "0");
3647115cd2caSopenharmony_ci    std::string rawContacts = ContactTabName::RAW_CONTACT;
3648115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicatesUpdate;
3649115cd2caSopenharmony_ci    predicatesUpdate.EqualTo("id", std::to_string(rawContactId));
3650115cd2caSopenharmony_ci    int updateCode = ContactUpdate(rawContacts, updateValues, predicatesUpdate);
3651115cd2caSopenharmony_ci    HILOG_INFO("contact_Delete_Recover_test_7500 : updateCode = %{public}d", updateCode);
3652115cd2caSopenharmony_ci    EXPECT_EQ(updateCode, 0);
3653115cd2caSopenharmony_ci
3654115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicatesDelete;
3655115cd2caSopenharmony_ci    predicatesDelete.EqualTo("raw_contact_id", std::to_string(rawContactId));
3656115cd2caSopenharmony_ci    int deleteCodeOne = ContactDelete(ContactTabName::DELETED_RAW_CONTACT_RECORD, predicatesDelete);
3657115cd2caSopenharmony_ci    EXPECT_EQ(deleteCodeOne, 0);
3658115cd2caSopenharmony_ci
3659115cd2caSopenharmony_ci    OHOS::DataShare::DataSharePredicates predicatesQuery;
3660115cd2caSopenharmony_ci    predicatesQuery.EqualTo("id", std::to_string(rawContactId));
3661115cd2caSopenharmony_ci    predicatesQuery.And();
3662115cd2caSopenharmony_ci    predicatesQuery.EqualTo("is_deleted", "0");
3663115cd2caSopenharmony_ci    std::vector<std::string> columns;
3664115cd2caSopenharmony_ci    std::shared_ptr<OHOS::DataShare::DataShareResultSet> resultSet =
3665115cd2caSopenharmony_ci        ContactQuery(ContactTabName::RAW_CONTACT, columns, predicatesQuery);
3666115cd2caSopenharmony_ci    int rowCount = 0;
3667115cd2caSopenharmony_ci    resultSet->GetRowCount(rowCount);
3668115cd2caSopenharmony_ci    EXPECT_EQ(1, rowCount);
3669115cd2caSopenharmony_ci    resultSet->Close();
3670115cd2caSopenharmony_ci    ClearContacts();
3671115cd2caSopenharmony_ci}
3672115cd2caSopenharmony_ci} // namespace Test
3673115cd2caSopenharmony_ci} // namespace Contacts