1/*
2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import contactsapi from '@ohos.contact';
17import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from 'deccjsunit/index';
18
19const URI_CONTACTS = 'datashare:///com.ohos.contactsdataability';
20const rawContactUri = 'datashare:///com.ohos.contactsdataability/contacts/raw_contact';
21const contactDataUri = 'datashare:///com.ohos.contactsdataability/contacts/contact_data';
22const groupUri = 'datashare:///com.ohos.contactsdataability/contacts/groups';
23const deletedUri = 'datashare:///com.ohos.contactsdataability/contacts/deleted_raw_contact';
24const ATTRIBUTE_ONE = 1;
25const ATTRIBUTE_TWO = 2;
26const ATTRIBUTE_THREE = 3;
27const ATTRIBUTE_FOUR = 4;
28const ATTRIBUTE_FIVE = 5;
29const ATTRIBUTE_SIX = 6;
30const ATTRIBUTE_SEVEN = 7;
31const ATTRIBUTE_EIGHT = 8;
32const ATTRIBUTE_NINE = 9;
33const ATTRIBUTE_TEN = 10;
34const ATTRIBUTE_ELEVEN = 11;
35const ATTRIBUTE_TWELVE = 12;
36const ATTRIBUTE_THIRTEEN = 13;
37const ATTRIBUTE_FOURTEEN = 14;
38const ATTRIBUTE_ONE_HUNDERD = 100;
39
40describe('ObjectInterfaceTest', function () {
41  function sleep(numberMillis) {
42    let now = new Date();
43    let exitTime = now.getTime() + numberMillis;
44    while (true) {
45      now = new Date();
46      if (now.getTime() > exitTime) {
47        return;
48      }
49    }
50  }
51
52  let contactData = {
53    id: 0,
54    key: '0',
55    contactAttributes: { attributes: [ATTRIBUTE_ONE, ATTRIBUTE_TWO, ATTRIBUTE_THREE, ATTRIBUTE_FOUR, ATTRIBUTE_FIVE,
56      ATTRIBUTE_SIX, ATTRIBUTE_SEVEN, ATTRIBUTE_EIGHT, ATTRIBUTE_NINE, ATTRIBUTE_TEN, ATTRIBUTE_ELEVEN,
57      ATTRIBUTE_TWELVE, ATTRIBUTE_THIRTEEN, ATTRIBUTE_FOURTEEN] },
58    emails: [{ email: 'email', labelName: '自定义邮箱', labelId: 1, displayName: 'emailDisplayName' }],
59    events: [{ eventDate: 'event', labelName: '自定义event', labelId: 2 }],
60    groups: [{ groupId: 1, title: '群组' }],
61    imAddresses: [{ imAddress: 'imAddress', labelName: '自定义', labelId: 3 }],
62    phoneNumbers: [{ phoneNumber: '183', labelName: '自定义phoneNumbers', labelId: 4 }],
63    portrait: { uri: 'content://head/0' },
64    postalAddresses: [
65      {
66        city: '南京',
67        country: '中国',
68        labelName: 'labelName',
69        neighborhood: 'neighborhood',
70        pobox: 'pobox',
71        postalAddress: 'postalAddress',
72        postcode: 'postcode',
73        region: 'region',
74        street: 'street',
75        labelId: 5
76      }
77    ],
78    relations: [{ relationName: 'relationName', labelName: '自定义relationName', labelId: 6 }],
79    sipAddresses: [{ sipAddress: 'sipAddress', labelName: '自定义sipAddress', labelId: 6 }],
80    websites: [{ website: 'website' }],
81    name: {
82      familyName: 'familyName',
83      familyNamePhonetic: 'familyNamePhonetic',
84      fullName: '小李',
85      givenName: 'givenName',
86      givenNamePhonetic: 'givenNamePhonetic',
87      middleName: 'middleName',
88      middleNamePhonetic: 'middleNamePhonetic',
89      namePrefix: 'namePrefix',
90      nameSuffix: 'nameSuffix'
91    },
92    nickName: { nickName: 'nickName' },
93    note: { noteContent: 'note' },
94    organization: { name: 'TT', title: '开发' }
95  };
96
97  let gRawContactId;
98
99  /**
100   * @tc.number  contactsApi_insert_test_100
101   * @tc.name    Insert contact information
102   * @tc.desc    Function test
103   */
104  it('contactsApi_insert_test_100', 0, async function (done) {
105    contactsapi.addContact(contactData, (data) => {
106      console.info('contactsApi_insert_test_100 : data = ' + data);
107      gRawContactId = data;
108      expect(data > 0).assertTrue();
109      done();
110    });
111  });
112
113  /**
114   * @tc.number  contactsApi_delete_test_200
115   * @tc.name    Delete contact information
116   * @tc.desc    Function test
117   */
118  it('contactsApi_delete_test_200', 0, async function (done) {
119    let deleteId = gRawContactId;
120    console.info('contactsApi_delete_test_200 : gRawContactId = ' + gRawContactId);
121    contactsapi.deleteContact(1, (data) => {
122      let gDelete = data;
123      console.info('contactsApi_delete_test_200 : deleteCode = ' + data);
124      expect(gDelete === 0).assertTrue();
125      done();
126    });
127  });
128
129  /**
130   * @tc.number  contactsApi_update_test_300
131   * @tc.name    Update contact information
132   * @tc.desc    Function test
133   */
134  it('contactsApi_update_test_300', 0, async function (done) {
135    let rawContactId = await contactsapi.addContact(contactData);
136    console.info('contactsApi_insert_test_300 : rawContactId = ' + rawContactId);
137    gRawContactId = rawContactId;
138    expect(rawContactId > 0).assertTrue();
139
140    let updateValues = { id: gRawContactId, name: { fullName: '小红' } };
141    let condition = { attributes: [ATTRIBUTE_SIX] };
142    contactsapi.updateContact(updateValues, condition, (data) => {
143      console.info('contactsApi_update_test_300 : updateCode = ' + data);
144      expect(data === 0).assertTrue();
145      done();
146    });
147  });
148
149  /**
150   * @tc.number  contactsApi_update_test_4100
151   * @tc.name    Update contact information
152   * @tc.desc    Function test
153   */
154  it('contactsApi_update_test_4100', 0, async function (done) {
155    let rawContactId = await contactsapi.addContact(contactData);
156    console.info('contactsApi_insert_test_300 : rawContactId = ' + rawContactId);
157    gRawContactId = rawContactId;
158    expect(rawContactId > 0).assertTrue();
159
160    let updateValues = { id: gRawContactId, name: { fullName: '小红' } };
161    contactsapi.updateContact(updateValues, (data) => {
162      console.info('contactsApi_update_test_4100 : updateCode = ' + data);
163      expect(data === 0).assertTrue();
164      done();
165    });
166  });
167
168  /**
169   * @tc.number  contactsApi_query_contact_test_400
170   * @tc.name    Query contacts information
171   * @tc.desc    Function test
172   */
173  it('contactsApi_query_contact_test_400', 0, async function (done) {
174    let queryId = gRawContactId;
175    contactsapi.queryContact(queryId, (data) => {
176      console.info('contactsApi_query_contact_test_400 : query resultSet = ' + JSON.stringify(data));
177      expect(data !== null).assertTrue();
178      done();
179    });
180  });
181
182  /**
183   * @tc.number  contactsApi_query_contact_test_500
184   * @tc.name    Query contacts information
185   * @tc.desc    Function test
186   */
187  it('contactsApi_query_contact_test_500', 0, async function (done) {
188    let queryId = gRawContactId.toString();
189    let holder = { bundleName: 'com.ohos.contacts', displayName: 'phone', holderId: 1 };
190    contactsapi.queryContact(queryId, holder, (data) => {
191      console.info('contactsApi_query_contact_test_500 : query resultSet = ' + JSON.stringify(data));
192      expect(data !== null).assertTrue();
193      done();
194    });
195  });
196
197  /**
198   * @tc.number  contactsApi_query_contact_test_600
199   * @tc.name    Query contacts information
200   * @tc.desc    Function test
201   */
202  it('contactsApi_query_contact_test_600', 0, async function (done) {
203    let queryId = gRawContactId.toString();
204    let holder = { bundleName: 'com.ohos.contacts', displayName: 'phone', holderId: 1 };
205    let ContactAttributes = { attributes: [ATTRIBUTE_ONE, ATTRIBUTE_FIVE, ATTRIBUTE_SIX] };
206
207    contactsapi.queryContact(queryId, holder, ContactAttributes, (data) => {
208      console.info('contactsApi_query_contact_test_600 : query resultSet = ' + JSON.stringify(data));
209      expect(data !== null).assertTrue();
210      done();
211    });
212  });
213
214  /**
215   * @tc.number  contactsApi_query_contact_test_4200
216   * @tc.name    Query contacts information
217   * @tc.desc    Function test
218   */
219  it('contactsApi_query_contact_test_4200', 0, async function (done) {
220    let queryId = gRawContactId.toString();
221    let ContactAttributes = { attributes: [ATTRIBUTE_ONE, ATTRIBUTE_FIVE, ATTRIBUTE_SIX] };
222
223    contactsapi.queryContact(queryId, ContactAttributes, (data) => {
224      console.info('contactsApi_query_contact_test_4200 : query resultSet = ' + JSON.stringify(data));
225      expect(data !== null).assertTrue();
226      done();
227    });
228  });
229
230  /**
231   * @tc.number  contactsApi_query_contacts_test_700
232   * @tc.name    Query contacts information
233   * @tc.desc    Function test
234   */
235  it('contactsApi_query_contacts_test_700', 0, async function (done) {
236    contactsapi.queryContacts((data) => {
237      console.info('contactsApi_query_contacts_test_700 : query resultSet = ' + JSON.stringify(data));
238      expect(data !== null).assertTrue();
239      done();
240    });
241  });
242
243  /**
244   * @tc.number  contactsApi_query_contacts_test_800
245   * @tc.name    Query contacts information
246   * @tc.desc    Function test
247   */
248  it('contactsApi_query_contacts_test_800', 0, async function (done) {
249    let holder = { bundleName: 'com.ohos.contacts', displayName: 'phone', holderId: 1 };
250    contactsapi.queryContacts(holder, (data) => {
251      console.info('contactsApi_query_contacts_test_800 : query resultSet = ' + JSON.stringify(data));
252      expect(data !== null).assertTrue();
253      done();
254    });
255  });
256
257  /**
258   * @tc.number  contactsApi_query_contacts_test_900
259   * @tc.name    Query contacts information
260   * @tc.desc    Function test
261   */
262  it('contactsApi_query_contacts_test_900', 0, async function (done) {
263    let ContactAttributes = { attributes: [ATTRIBUTE_ONE, ATTRIBUTE_FIVE, ATTRIBUTE_SIX] };
264
265    contactsapi.queryContacts(ContactAttributes, (data) => {
266      console.info('contactsApi_query_contacts_test_900 : query resultSet = ' + JSON.stringify(data));
267      expect(data !== null).assertTrue();
268      done();
269    });
270  });
271
272  /**
273   * @tc.number  contactsApi_query_contacts_test_1000
274   * @tc.name    Query contacts information
275   * @tc.desc    Function test
276   */
277  it('contactsApi_query_contacts_test_1000', 0, async function (done) {
278    let holder = { bundleName: 'com.ohos.contacts', displayName: 'phone', holderId: 1 };
279    let ContactAttributes = { attributes: [ATTRIBUTE_ONE, ATTRIBUTE_FIVE, ATTRIBUTE_SIX] };
280
281    contactsapi.queryContacts(holder, ContactAttributes, (data) => {
282      console.info('contactsApi_query_contacts_test_1000 : query resultSet = ' + JSON.stringify(data));
283      expect(data !== null).assertTrue();
284      done();
285    });
286  });
287
288  /**
289   * @tc.number  contactsApi_query_email_test_1100
290   * @tc.name    Query email information
291   * @tc.desc    Function test
292   */
293  it('contactsApi_query_email_test_1100', 0, async function (done) {
294    let email = 'email';
295    let holder = { bundleName: 'com.ohos.contacts', displayName: 'phone', holderId: 1 };
296
297    contactsapi.queryContactsByEmail(email, holder, (data) => {
298      console.info('contactsApi_query_email_test_1100 : query resultSet = ' + JSON.stringify(data));
299      expect(data !== null).assertTrue();
300      done();
301    });
302  });
303
304  /**
305   * @tc.number  contactsApi_query_email_test_1200
306   * @tc.name    Query email information
307   * @tc.desc    Function test
308   */
309  it('contactsApi_query_email_test_1200', 0, async function (done) {
310    let email = 'email';
311    contactsapi.queryContactsByEmail(email, (data) => {
312      console.info('contactsApi_query_email_test_1200 : query resultSet = ' + JSON.stringify(data));
313      expect(data !== null).assertTrue();
314      done();
315    });
316  });
317
318  /**
319   * @tc.number  contactsApi_query_email_test_1300
320   * @tc.name    Query email information
321   * @tc.desc    Function test
322   */
323  it('contactsApi_query_email_test_1300', 0, async function (done) {
324    let email = 'email';
325    let holder = { bundleName: 'com.ohos.contacts', displayName: 'phone', holderId: 1 };
326    let ContactAttributes = { attributes: [ATTRIBUTE_ONE, ATTRIBUTE_FIVE, ATTRIBUTE_SIX] };
327
328    contactsapi.queryContactsByEmail(email, holder, ContactAttributes, (data) => {
329      console.info('contactsApi_query_email_test_1300 : query resultSet = ' + JSON.stringify(data));
330      expect(data !== null).assertTrue();
331      done();
332    });
333  });
334
335  /**
336   * @tc.number  contactsApi_query_email_test_1400
337   * @tc.name    Query email information
338   * @tc.desc    Function test
339   */
340  it('contactsApi_query_email_test_1400', 0, async function (done) {
341    let email = 'email';
342    let ContactAttributes = { attributes: [ATTRIBUTE_ONE, ATTRIBUTE_FIVE, ATTRIBUTE_SIX] };
343
344    contactsapi.queryContactsByEmail(email, ContactAttributes, (data) => {
345      console.info('contactsApi_query_email_test_1400 : query resultSet = ' + JSON.stringify(data));
346      expect(data !== null).assertTrue();
347      done();
348    });
349  });
350
351  /**
352   * @tc.number  contactsApi_query_phoneNumber_test_1500
353   * @tc.name    Query phoneNumber information
354   * @tc.desc    Function test
355   */
356  it('contactsApi_query_phoneNumber_test_1500', 0, async function (done) {
357    let phoneNumber = '183';
358    let holder = { bundleName: 'com.ohos.contacts', displayName: 'phone', holderId: 1 };
359
360    contactsapi.queryContactsByPhoneNumber(phoneNumber, holder, (data) => {
361      console.info('contactsApi_query_phoneNumber_test_1500 : query resultSet = ' + JSON.stringify(data));
362      expect(data !== null).assertTrue();
363      done();
364    });
365  });
366
367  /**
368   * @tc.number  contactsApi_query_phoneNumber_test_1600
369   * @tc.name    Query phoneNumber information
370   * @tc.desc    Function test
371   */
372  it('contactsApi_query_phoneNumber_test_1600', 0, async function (done) {
373    let phoneNumber = '183';
374    let holder = { bundleName: 'com.ohos.contacts', displayName: 'phone', holderId: 1 };
375    let ContactAttributes = { attributes: [ATTRIBUTE_ONE, ATTRIBUTE_FIVE, ATTRIBUTE_SIX] };
376
377    contactsapi.queryContactsByPhoneNumber(phoneNumber, holder, ContactAttributes, (data) => {
378      console.info('contactsApi_query_phoneNumber_test_1600 : query resultSet = ' + JSON.stringify(data));
379      expect(data !== null).assertTrue();
380      done();
381    });
382  });
383
384  /**
385   * @tc.number  contactsApi_query_phoneNumber_test_1700
386   * @tc.name    Query phoneNumber information
387   * @tc.desc    Function test
388   */
389  it('contactsApi_query_phoneNumber_test_1700', 0, async function (done) {
390    let phoneNumber = '183';
391
392    contactsapi.queryContactsByPhoneNumber(phoneNumber, (data) => {
393      console.info('contactsApi_query_phoneNumber_test_1700 : query resultSet = ' + JSON.stringify(data));
394      expect(data !== null).assertTrue();
395      done();
396    });
397  });
398
399  /**
400   * @tc.number  contactsApi_query_phoneNumber_test_1800
401   * @tc.name    Query phoneNumber information
402   * @tc.desc    Function test
403   */
404  it('contactsApi_query_phoneNumber_test_1800', 0, async function (done) {
405    let phoneNumber = '183';
406    let ContactAttributes = { attributes: [ATTRIBUTE_ONE, ATTRIBUTE_FIVE, ATTRIBUTE_SIX] };
407
408    contactsapi.queryContactsByPhoneNumber(phoneNumber, ContactAttributes, (data) => {
409      console.info('contactsApi_query_phoneNumber_test_1800 : query resultSet = ' + JSON.stringify(data));
410      expect(data !== null).assertTrue();
411      done();
412    });
413  });
414
415  /**
416   * @tc.number  contactsApi_query_group_test_1900
417   * @tc.name    Query group
418   * @tc.desc    Function test
419   */
420  it('contactsApi_query_group_test_1900', 0, async function (done) {
421    contactsapi.queryGroups((data) => {
422      console.info('contactsApi_query_group_test_1900 : query resultSet = ' + JSON.stringify(data));
423      expect(data.length === 0).assertTrue();
424      done();
425    });
426  });
427
428  /**
429   * @tc.number  contactsApi_query_group_test_2000
430   * @tc.name    Query group
431   * @tc.desc    Function test
432   */
433  it('contactsApi_query_group_test_2000', 0, async function (done) {
434    let holder = { bundleName: 'com.ohos.contacts', displayName: 'phone', holderId: 1 };
435
436    contactsapi.queryGroups(holder, (data) => {
437      console.info('contactsApi_query_group_test_2000 : query resultSet = ' + JSON.stringify(data));
438      expect(data.length === 0).assertTrue();
439      done();
440    });
441  });
442
443  /**
444   * @tc.number  contactsApi_query_holders_test_2200
445   * @tc.name    Query holders information
446   * @tc.desc    Function test
447   */
448  it('contactsApi_query_holders_test_2200', 0, async function (done) {
449    contactsapi.queryHolders((data) => {
450      console.info('contactsApi_query_holders_test_2200 : query resultSet = ' + JSON.stringify(data));
451      expect(data !== null).assertTrue();
452      done();
453    });
454  });
455
456  /**
457   * @tc.number  contactsApi_query_key_test_2300
458   * @tc.name    Query key information
459   * @tc.desc    Function test
460   */
461  it('contactsApi_query_key_test_2300', 0, async function (done) {
462    let idtest = gRawContactId;
463    let holder = { bundleName: 'com.ohos.contacts', displayName: 'phone', holderId: 1 };
464
465    contactsapi.queryKey(idtest, holder, (data) => {
466      console.info('contactsApi_query_key_test_2300 : query resultSet = ' + JSON.stringify(data));
467      expect(data.length !== 0).assertTrue();
468      done();
469    });
470  });
471
472  /**
473   * @tc.number  contactsApi_query_key_test_2400
474   * @tc.name    Query key information
475   * @tc.desc    Function test
476   */
477  it('contactsApi_query_key_test_2400', 0, async function (done) {
478    let idtest = gRawContactId;
479    console.info('contactsApi_query_key_test_2400 : query gRawContactId = ' + idtest);
480
481    contactsapi.queryKey(idtest, (data) => {
482      console.info('contactsApi_query_key_test_2400 : query resultSet = ' + JSON.stringify(data));
483      expect(data.length !== 0).assertTrue();
484      done();
485    });
486  });
487
488  /**
489   * @tc.number  contactsApi_query_mycard_test_2500
490   * @tc.name    Query mycard information
491   * @tc.desc    Function test
492   */
493  it('contactsApi_query_mycard_test_2500', 0, async function (done) {
494    let holder = { bundleName: 'com.ohos.contacts', displayName: 'phone', holderId: 1 };
495
496    contactsapi.queryMyCard(holder, (data) => {
497      console.info('contactsApi_query_mycard_test_2500 : query resultSet = ' + JSON.stringify(data));
498      expect(data.length === 0).assertTrue();
499      done();
500    });
501  });
502
503  /**
504   * @tc.number  contactsApi_query_mycard_test_4000
505   * @tc.name    Query mycard information
506   * @tc.desc    Function test
507   */
508  it('contactsApi_query_mycard_test_4000', 0, async function (done) {
509    contactsapi.queryMyCard((data) => {
510      console.info('contactsApi_query_mycard_test_4000 : query resultSet = ' + JSON.stringify(data));
511      expect(data.length === 0).assertTrue();
512      done();
513    });
514  });
515
516  /**
517   * @tc.number  contactsApi_isMyCard_test_2600
518   * @tc.name    Query mycard exist
519   * @tc.desc    Function test
520   */
521  it('contactsApi_isMyCard_test_2600', 0, async function (done) {
522    let id = 1;
523
524    contactsapi.isMyCard(id, (data) => {
525      console.info('contactsApi_isMyCard_test_2600 : query isExist = ' + data);
526      expect(data === 0).assertTrue();
527      done();
528    });
529  });
530
531  /**
532   * @tc.number  contactsApi_isLocalContact_test_2700
533   * @tc.name    Query isLocalContact exist
534   * @tc.desc    Function test
535   */
536  it('contactsApi_isLocalContact_test_2700', 0, async function (done) {
537    let id = gRawContactId;
538
539    contactsapi.isLocalContact(id, (data) => {
540      console.info('logMessage contactsApi_isLocalContact_test_2700 isExist = ' + data);
541      expect(data === 1).assertTrue();
542      done();
543    });
544  });
545
546  /**
547   * @tc.number  abnormal_contactsApi_insert_test_2800
548   * @tc.name    contactsApi_insert error
549   * @tc.desc    Function test
550   */
551  it('abnormal_contactsApi_insert_test_2800', 0, async function (done) {
552    let contactDataError = {};
553
554    contactsapi.addContact(contactDataError, (data) => {
555      console.info('abnormal_contactsApi_insert_test_2800 : rawContactId = ' + data);
556      expect(data === -1).assertTrue();
557      done();
558    });
559  });
560
561  /**
562   * @tc.number  abnormal_contactsApi_update_test_3000
563   * @tc.name    contactsApi_update error
564   * @tc.desc    Function test
565   */
566  it('abnormal_contactsApi_update_test_3000', 0, async function (done) {
567    let rawContactId = -1;
568    let updateValues = { id: rawContactId, name: { fullName: '小红' } };
569    let condition = { attributes: [ATTRIBUTE_SIX] };
570
571    contactsapi.updateContact(updateValues, condition, (data) => {
572      console.info('abnormal_contactsApi_update_test_3000 : updateCode = ' + data);
573      expect(data === -1).assertTrue();
574      done();
575    });
576  });
577
578  /**
579   * @tc.number  abnormal_contactsApi_query_contact_test_3100
580   * @tc.name    contactsApi_query_contact error
581   * @tc.desc    Function test
582   */
583  it('abnormal_contactsApi_query_contact_test_3100', 0, async function (done) {
584    let queryId = '-1';
585
586    contactsapi.queryContact(queryId, (data) => {
587      if (data === null) {
588        console.info('abnormal_contactsApi_query_contact_test_3100 is null');
589      }
590      if (data === undefined) {
591        console.info('abnormal_contactsApi_query_contact_test_3100 is undefined');
592      }
593      console.info('abnormal_contactsApi_query_contact_test_3100 : updateCode = ' + JSON.stringify(data));
594      expect(data === undefined).assertTrue();
595      done();
596    });
597  });
598
599  /**
600   * @tc.number  abnormal_contactsApi_query_contacts_test_3200
601   * @tc.name    contactsApi_query_contacts error
602   * @tc.desc    Function test
603   */
604  it('abnormal_contactsApi_query_contacts_test_3200', 0, async function (done) {
605    let ContactAttributes = { attributes: [ATTRIBUTE_ONE_HUNDERD] };
606
607    contactsapi.queryContacts(ContactAttributes, (data) => {
608      if (data === null) {
609        console.info('abnormal_contactsApi_query_contacts_test_3200 is null');
610        return;
611      }
612      console.info('abnormal_contactsApi_query_contacts_test_3200 : query resultSet = ' + JSON.stringify(data));
613      expect(data.length === 0).assertTrue();
614      done();
615    });
616  });
617
618  /**
619   * @tc.number  abnormal_contactsApi_query_email_test_3300
620   * @tc.name    contactsApi_query_email error
621   * @tc.desc    Function test
622   */
623  it('abnormal_contactsApi_query_email_test_3300', 0, async function (done) {
624    let email = 'email2222';
625
626    contactsapi.queryContactsByEmail(email, (data) => {
627      console.info('abnormal_contactsApi_query_email_test_3300 : query resultSet = ' + JSON.stringify(data));
628      expect(data.length === 0).assertTrue();
629      done();
630    });
631  });
632
633  /**
634   * @tc.number  abnormal_contactsApi_query_phoneNumber_test_3400
635   * @tc.name    contactsApi_query_phoneNumber error
636   * @tc.desc    Function test
637   */
638  it('abnormal_contactsApi_query_phoneNumber_test_3400', 0, async function (done) {
639    let phoneNumber = '19999999';
640
641    contactsapi.queryContactsByPhoneNumber(phoneNumber, (data) => {
642      console.info('abnormal_contactsApi_query_phoneNumber_test_3400 : query resultSet = ' + JSON.stringify(data));
643      expect(data.length === 0).assertTrue();
644      done();
645    });
646  });
647
648  /**
649   * @tc.number  abnormal_contactsApi_query_group_test_3500
650   * @tc.name    contactsApi_query_group error
651   * @tc.desc    Function test
652   */
653  it('abnormal_contactsApi_query_group_test_3500', 0, async function (done) {
654    let holder = { bundleName: 'com.ohos.contacts2', displayName: 'phone2', holderId: 2 };
655
656    contactsapi.queryGroups(holder, (data) => {
657      console.info('abnormal_contactsApi_query_group_test_3500 : query resultSet = ' + JSON.stringify(data));
658      expect(data.length === 0).assertTrue();
659      done();
660    });
661  });
662
663  /**
664   * @tc.number  abnormal_contactsApi_query_key_test_3600
665   * @tc.name    contactsApi_query_key error
666   * @tc.desc    Function test
667   */
668  it('abnormal_contactsApi_query_key_test_3600', 0, async function (done) {
669    let idtest = -1;
670
671    contactsapi.queryKey(idtest, (data) => {
672      console.info('abnormal_contactsApi_query_key_test_3600 : query resultSet = ' + JSON.stringify(data));
673      expect(data.length === 0).assertTrue();
674      done();
675    });
676  });
677
678  /**
679   * @tc.number  abnormal_contactsApi_query_mycard_test_3700
680   * @tc.name    contactsApi_query_mycard error
681   * @tc.desc    Function test
682   */
683  it('abnormal_contactsApi_query_mycard_test_3700', 0, async function (done) {
684    let ContactAttributes = { attributes: [ATTRIBUTE_ONE_HUNDERD] };
685
686    contactsapi.queryMyCard(ContactAttributes, (data) => {
687      console.info('abnormal_contactsApi_query_mycard_test_3700 : query resultSet = ' + JSON.stringify(data));
688      expect(data.length === 0).assertTrue();
689      done();
690    });
691  });
692
693  /**
694   * @tc.number  abnormal_contactsApi_isMyCard_test_3800
695   * @tc.name    isMyCard is not exist
696   * @tc.desc    Function test
697   */
698  it('abnormal_contactsApi_isMyCard_test_3800', 0, async function (done) {
699    let id = 999;
700
701    contactsapi.isMyCard(id, (isExist) => {
702      console.info('abnormal_contactsApi_isMyCard_test_3800 : query isExist = ' + isExist);
703      expect(isExist === 0).assertTrue();
704      done();
705    });
706  });
707
708  /**
709   * @tc.number  abnormal_contactsApi_isLocalContact_test_3900
710   * @tc.name    contactsApi_isLocalContact is not exist
711   * @tc.desc    Function test
712   */
713  it('abnormal_contactsApi_isLocalContact_test_3900', 0, async function (done) {
714    let id = 999;
715
716    contactsapi.isLocalContact(id, (isExist) => {
717      console.info('abnormal_contactsApi_isLocalContact_test_3900 : query isExist = ' + isExist);
718      expect(isExist === 0).assertTrue();
719      done();
720    });
721  });
722});
723