1/*
2 * Copyright (c) 2024 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/LICENSE2.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 { describe, beforeAll, afterEach, it, expect, beforeEach } from '@ohos/hypium'
17import { BusinessError } from '@ohos.base';
18import contact from '@ohos.contact';
19import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
20import bundleManager from '@ohos.bundle.bundleManager';
21import account from '@ohos.account.osAccount';
22
23const ExpectTrue = (n: boolean) => {
24  try {
25    expect(n).assertTrue();
26  } catch (err) {
27    console.info("expectInfo", `test failed`);
28  }
29}
30const ExpectFail = () => {
31  try {
32    expect().assertFail();
33  } catch (err) {
34    console.info("expectInfo", `test failed`);
35  }
36}
37
38async function getPermissions() {
39  console.info('getPermission start');
40  type MyPermissions = "ohos.permission.WRITE_CONTACTS" | "ohos.permission.READ_CONTACTS";
41  let list: MyPermissions[] = ['ohos.permission.WRITE_CONTACTS', 'ohos.permission.READ_CONTACTS'];
42  try {
43    let userId: number = await account.getAccountManager().getOsAccountLocalId();
44    let applicationFlags: number = bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT;
45    let applicationInfo: bundleManager.ApplicationInfo = await bundleManager.getApplicationInfoSync('com.example.contacttest', applicationFlags, userId);
46    let tokenId: number = applicationInfo.accessTokenId;
47    for (let index = 0; index < list.length; index++) {
48      await abilityAccessCtrl.createAtManager().grantUserGrantedPermission(tokenId, list[index], 1);
49    }
50  } catch (err) {
51    console.info(`getPermission error ${JSON.stringify(err)}`);
52  }
53  console.info('getPermission end');
54}
55
56export default function AddContactTest() {
57  describe('AddContactTest', () => {
58
59    beforeAll(async (done: Function) => {
60      console.info("beforeAll case");
61      await getPermissions();
62      done();
63    });
64
65    afterEach(async (done: Function) => {
66      try {
67        let context: Context = AppStorage.get('context') as Context;
68        let contactList: contact.Contact[] = [];
69        try {
70          contactList = await contact.queryContacts(context);
71        } catch (queryErr) {
72          console.info(`afterEach queryContacts catch err: ${JSON.stringify(queryErr)}`);
73          done();
74        }
75        try {
76          if (contactList.length > 0) {
77            contactList.forEach(async (item: contact.Contact) => {
78              if (item.key) {
79                await contact.deleteContact(context, item.key);
80                console.info(`afterEach deleteContact success--${item.key}`);
81              }
82            })
83          }
84          done();
85        } catch (deleteErr) {
86          console.info(`afterEach deleteContact catch err: ${JSON.stringify(deleteErr)}`);
87          done();
88        }
89      } catch (error) {
90        console.info(`afterEach catch error: ${JSON.stringify(error)}`);
91        done();
92      }
93    });
94
95    let contactData: contact.Contact = {
96      id: 0,
97      key: "0",
98      contactAttributes: {
99        attributes: [contact.Attribute.ATTR_CONTACT_EVENT, contact.Attribute.ATTR_EMAIL,
100        contact.Attribute.ATTR_GROUP_MEMBERSHIP,
101        contact.Attribute.ATTR_IM, contact.Attribute.ATTR_NAME, contact.Attribute.ATTR_NICKNAME,
102        contact.Attribute.ATTR_NOTE, contact.Attribute.ATTR_ORGANIZATION, contact.Attribute.ATTR_PHONE,
103        contact.Attribute.ATTR_PORTRAIT, contact.Attribute.ATTR_POSTAL_ADDRESS,
104        contact.Attribute.ATTR_RELATION,
105        contact.Attribute.ATTR_SIP_ADDRESS, contact.Attribute.ATTR_WEBSITE]
106      },
107      emails: [{
108        email: "13800000000@email.com", labelName: "自定义邮箱", labelId: 1, displayName: "emailDisplayName"
109      }],
110      events: [{
111        eventDate: "event", labelName: "自定义event", labelId: 2
112      }],
113      groups: [{
114        groupId: 1, title: "群组"
115      }],
116      imAddresses: [{
117        imAddress: "imAddress", labelName: "自定义", labelId: 3
118      }],
119      phoneNumbers: [{
120        phoneNumber: "13800000000", labelName: "自定义phoneNumbers", labelId: 4
121      }],
122      portrait: {
123        uri: "content://head/0"
124      },
125      postalAddresses: [{
126        city: "南京",
127        country: "中国",
128        labelName: "labelName",
129        neighborhood: "neighborhood",
130        pobox: "pobox",
131        postalAddress: "postalAddress",
132        postcode: "postcode",
133        region: "region",
134        street: "street",
135        labelId: 5
136      }],
137      relations: [{
138        relationName: "relationName", labelName: "自定义relationName", labelId: 6
139      }],
140      sipAddresses: [{
141        sipAddress: "sipAddress", labelName: "自定义sipAddress", labelId: 6
142      }],
143      websites: [{
144        website: "website"
145      }],
146      name: {
147        familyName: "familyName",
148        familyNamePhonetic: "familyNamePhonetic",
149        fullName: "小李",
150        givenName: "givenName",
151        givenNamePhonetic: "givenNamePhonetic",
152        middleName: "middleName",
153        middleNamePhonetic: "middleNamePhonetic",
154        namePrefix: "namePrefix",
155        nameSuffix: "nameSuffix"
156      },
157      nickName: {
158        nickName: "nickName"
159      },
160      note: {
161        noteContent: "note"
162      },
163      organization: {
164        name: "TT", title: "开发"
165      }
166    };
167
168    let holder: contact.Holder = {
169      holderId: 1,
170      bundleName: "com.ohos.contacts",
171      displayName: "phone"
172    };
173
174    let attr: contact.ContactAttributes = {
175      attributes: [
176      contact.Attribute.ATTR_CONTACT_EVENT,
177      contact.Attribute.ATTR_EMAIL,
178      contact.Attribute.ATTR_GROUP_MEMBERSHIP,
179      contact.Attribute.ATTR_IM,
180      contact.Attribute.ATTR_NAME,
181      contact.Attribute.ATTR_NICKNAME,
182      contact.Attribute.ATTR_NOTE,
183      contact.Attribute.ATTR_ORGANIZATION,
184      contact.Attribute.ATTR_PHONE,
185      contact.Attribute.ATTR_PORTRAIT,
186      contact.Attribute.ATTR_POSTAL_ADDRESS,
187      contact.Attribute.ATTR_RELATION,
188      contact.Attribute.ATTR_SIP_ADDRESS,
189      contact.Attribute.ATTR_WEBSITE
190      ]
191    };
192
193    /**
194     * @tc.number abnormal_contactsApi_insert_test_2800
195     * @tc.name contactsApi_insert error
196     * @tc.desc Function test
197     */
198    it("abnormal_contactsApi_insert_test_2800", 0,  async (done: Function) => {
199      let contactDataError: contact.Contact = {};
200      try {
201        let rawContactId = await contact.addContact(contactDataError);
202        console.info("abnormal_contactsApi_insert_test_2800 : rawContactId = " + rawContactId);
203        expect(rawContactId === -1).assertTrue();
204        done();
205      } catch (error) {
206        console.info("contactsApi_insert_test_100 : raw_contact insert error = " + error);
207        done();
208      }
209    });
210
211    /**
212     * @tc.number     : SUB_Telephony_Contact_AddContact_0100
213     * @tc.name       : testTelephonyContactAddContact0100
214     * @tc.desc       : Add a contacts and useing the callback method as an asynchronous method 10+
215     * @tc.size       : MediumTest
216     * @tc.type       : Function
217     * @tc.level      : Level 2
218     */
219    it('testTelephonyContactAddContact0100', 0, async (done: Function) => {
220      const caseName: string = "testTelephonyContactAddContact0100";
221      console.info(`${caseName} test start `);
222      try {
223        let context: Context = AppStorage.get('context') as Context;
224        contact.addContact(context, contactData, (err: BusinessError, data: number) => {
225          if (err) {
226            console.log(`${caseName} addContact: err>${JSON.stringify(err)}`);
227            ExpectFail();
228            done();
229          } else {
230            console.log(`${caseName} addContact: success data>${JSON.stringify(data)}`);
231            ExpectTrue(data > 0);
232            done();
233          }
234        });
235      } catch (err) {
236        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
237        ExpectFail();
238        done();
239      }
240      console.info(`${caseName} test end `);
241    })
242
243    /**
244     * @tc.number     : SUB_Telephony_Contact_AddContact_0200
245     * @tc.name       : testTelephonyContactAddContact0200
246     * @tc.desc       : Add a contacts and useing the callback method as an asynchronous method 10+
247     * @tc.size       : MediumTest
248     * @tc.type       : Function
249     * @tc.level      : Level 2
250     */
251    it('testTelephonyContactAddContact0200', 0, async (done: Function) => {
252      const caseName: string = "testTelephonyContactAddContact0200";
253      console.info(`${caseName} test start `);
254      let context: Context = AppStorage.get('context') as Context;
255      let phoneNumContact: contact.Contact = {
256        id: 2, name: {
257          fullName: '李四'
258        }, phoneNumbers: [{
259          phoneNumber: '13800000000'
260        }]
261      };
262      try {
263        contact.addContact(context, phoneNumContact, (err: BusinessError, data: number) => {
264          if (err) {
265            console.log(`${caseName} addContact1: err>${JSON.stringify(err)}`);
266            ExpectFail();
267            done();
268          } else {
269            console.log(`${caseName} addContact1: success data>${JSON.stringify(data)}`);
270            ExpectTrue(data > 0);
271            contact.addContact(context, phoneNumContact, (err: BusinessError, data: number) => {
272              if (err) {
273                console.log(`${caseName} addContact2: err>${JSON.stringify(err)}`);
274                ExpectFail();
275                done();
276              } else {
277                console.log(`${caseName} addContact2: success data>${JSON.stringify(data)}`);
278                ExpectTrue(data > 0);
279                contact.queryContactsByPhoneNumber(context, "13800000000", (err: BusinessError, data: contact.Contact[]) => {
280                  if (err) {
281                    console.info(`${caseName} queryContacts:err->${JSON.stringify(err)}`);
282                    ExpectFail();
283                    done();
284                  } else {
285                    console.info(`${caseName} queryContacts:success->${JSON.stringify(data)}`);
286                    ExpectTrue(data.length === 2);
287                    done()
288                  }
289                });
290              }
291            });
292          }
293        });
294      } catch (err) {
295        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
296        ExpectFail();
297        done();
298      }
299      console.info(`${caseName} test end `);
300    })
301    /**
302     * @tc.number     : SUB_Telephony_Contact_AddContact_0300
303     * @tc.name       : testTelephonyContactAddContact0300
304     * @tc.desc       : Add a contacts and useing the callback method as an asynchronous method 10+
305     * @tc.size       : MediumTest
306     * @tc.type       : Function
307     * @tc.level      : Level 3
308     */
309    it('testTelephonyContactAddContact0300', 0, async (done: Function) => {
310      const caseName: string = "testTelephonyContactAddContact0300";
311      console.info(`${caseName} test start `);
312      let context: Context = AppStorage.get('context') as Context;
313      let phoneNumContact: contact.Contact = {
314        id: 3, name: {
315          fullName: ''
316        }, phoneNumbers: [{
317          phoneNumber: '13800000000'
318        }]
319      };
320      try {
321        contact.addContact(context, phoneNumContact, (err: BusinessError, data: number) => {
322          if (err) {
323            console.log(`${caseName} addContact: err>${JSON.stringify(err)}`);
324            ExpectFail();
325            done();
326          } else {
327            console.log(`${caseName} addContact: success data>${JSON.stringify(data)}`);
328            ExpectTrue(data > 0);
329            done();
330          }
331        });
332      } catch (err) {
333        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
334        ExpectFail();
335        done();
336      }
337      console.info(`${caseName} test end `);
338    })
339    /**
340     * @tc.number     : SUB_Telephony_Contact_AddContact_0400
341     * @tc.name       : testTelephonyContactAddContact0400
342     * @tc.desc       : Add a contacts and useing the callback method as an asynchronous method 10+
343     * @tc.size       : MediumTest
344     * @tc.type       : Function
345     * @tc.level      : Level 3
346     */
347    it('testTelephonyContactAddContact0400', 0, async (done: Function) => {
348      const caseName: string = "testTelephonyContactAddContact0400";
349      console.info(`${caseName} test start `);
350      let context: Context = AppStorage.get('context') as Context;
351      let phoneNumContact: contact.Contact = {
352        id: 3, name: {
353          fullName: '张三'
354        }, phoneNumbers: [{
355          phoneNumber: ''
356        }]
357      };
358      try {
359        contact.addContact(context, phoneNumContact, (err: BusinessError, data: number) => {
360          if (err) {
361            console.log(`${caseName} addContact: err>${JSON.stringify(err)}`);
362            ExpectFail();
363            done();
364          } else {
365            console.log(`${caseName} addContact: success data>${JSON.stringify(data)}`);
366            ExpectTrue(data > 0);
367            done();
368          }
369        });
370      } catch (err) {
371        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
372        ExpectFail();
373        done();
374      }
375      console.info(`${caseName} test end `);
376    })
377    /**
378     * @tc.number     : SUB_Telephony_Contact_AddContact_0500
379     * @tc.name       : testTelephonyContactAddContact0500
380     * @tc.desc       : Add a contacts and useing the callback method as an asynchronous method 10+
381     * @tc.size       : MediumTest
382     * @tc.type       : Function
383     * @tc.level      : Level 3
384     */
385    it('testTelephonyContactAddContact0500', 0, async (done: Function) => {
386      const caseName: string = "testTelephonyContactAddContact0500";
387      console.info(`${caseName} test start `);
388      let context: Context = AppStorage.get('context') as Context;
389      let phoneNumContact: contact.Contact = {
390        id: 3, name: {
391          fullName: 'Frank'
392        }, phoneNumbers: [{
393          phoneNumber: '110'
394        }]
395      };
396      try {
397        contact.addContact(context, phoneNumContact, (err: BusinessError, data: number) => {
398          if (err) {
399            console.log(`${caseName} addContact: err>${JSON.stringify(err)}`);
400            ExpectFail();
401            done();
402          } else {
403            console.log(`${caseName} addContact: success data>${JSON.stringify(data)}`);
404            ExpectTrue(data > 0);
405            done();
406          }
407        });
408      } catch (err) {
409        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
410        ExpectFail();
411        done();
412      }
413      console.info(`${caseName} test end `);
414    })
415    /**
416     * @tc.number     : SUB_Telephony_Contact_AddContact_0600
417     * @tc.name       : testTelephonyContactAddContact0600
418     * @tc.desc       : Add a contacts and useing the callback method as an asynchronous method 10+
419     * @tc.size       : MediumTest
420     * @tc.type       : Function
421     * @tc.level      : Level 3
422     */
423    it('testTelephonyContactAddContact0600', 0, async (done: Function) => {
424      const caseName: string = "testTelephonyContactAddContact0600";
425      console.info(`${caseName} test start `);
426      let context: Context = AppStorage.get('context') as Context;
427      let phoneNumContact: contact.Contact = {
428        id: 3, name: {
429          fullName: 'Frank'
430        }, phoneNumbers: [{
431          phoneNumber: '12345'
432        }]
433      };
434      try {
435        contact.addContact(context, phoneNumContact, (err: BusinessError, data: number) => {
436          if (err) {
437            console.log(`${caseName} addContact: err>${JSON.stringify(err)}`);
438            ExpectFail();
439            done();
440          } else {
441            console.log(`${caseName} addContact: success data>${JSON.stringify(data)}`);
442            ExpectTrue(data > 0);
443            done();
444          }
445        });
446      } catch (err) {
447        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
448        ExpectFail();
449        done();
450      }
451      console.info(`${caseName} test end `);
452    })
453    /**
454     * @tc.number     : SUB_Telephony_Contact_AddContact_0700
455     * @tc.name       : testTelephonyContactAddContact0700
456     * @tc.desc       : Add a contacts and useing the callback method as an asynchronous method 10+
457     * @tc.size       : MediumTest
458     * @tc.type       : Function
459     * @tc.level      : Level 3
460     */
461    it('testTelephonyContactAddContact0700', 0, async (done: Function) => {
462      const caseName: string = "testTelephonyContactAddContact0700";
463      console.info(`${caseName} test start `);
464      let context: Context = AppStorage.get('context') as Context;
465      let phoneNumContact: contact.Contact = {
466        id: 7, name: {
467          fullName: 'Frank'
468        }, phoneNumbers: [{
469          phoneNumber: '13800000000'
470        }, {
471          phoneNumber: '13800000000'
472        }]
473      };
474      try {
475        contact.addContact(context, phoneNumContact, (err: BusinessError, data: number) => {
476          if (err) {
477            console.log(`${caseName} addContact: err>${JSON.stringify(err)}`);
478            ExpectFail();
479            done();
480          } else {
481            console.log(`${caseName} addContact: success data>${JSON.stringify(data)}`);
482            ExpectTrue(data > 0);
483            done();
484          }
485        });
486      } catch (err) {
487        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
488        ExpectFail();
489        done();
490      }
491      console.info(`${caseName} test end `);
492    })
493    /**
494     * @tc.number     : SUB_Telephony_Contact_AddContact_0800
495     * @tc.name       : testTelephonyContactAddContact0800
496     * @tc.desc       : Add a contacts and useing the callback method as an asynchronous method 10+
497     * @tc.size       : MediumTest
498     * @tc.type       : Function
499     * @tc.level      : Level 3
500     */
501    it('testTelephonyContactAddContact0800', 0, async (done: Function) => {
502      const caseName: string = "testTelephonyContactAddContact0800";
503      console.info(`${caseName} test start `);
504      let context: Context = AppStorage.get('context') as Context;
505      let phoneNumContact: contact.Contact = {
506        id: 8, name: {
507          fullName: 'Frank'
508        }, phoneNumbers: [{
509          phoneNumber: '13800000000'
510        }, {
511          phoneNumber: '13811111111'
512        }, {
513          phoneNumber: '13800000000'
514        }, {
515          phoneNumber: '13822222222'
516        }]
517      };
518      try {
519        contact.addContact(context, phoneNumContact, (err: BusinessError, data: number) => {
520          if (err) {
521            console.log(`${caseName} addContact: err>${JSON.stringify(err)}`);
522            ExpectFail();
523            done();
524          } else {
525            console.log(`${caseName} addContact: success data>${JSON.stringify(data)}`);
526            ExpectTrue(data > 0);
527            done();
528          }
529        });
530      } catch (err) {
531        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
532        ExpectFail();
533        done();
534      }
535      console.info(`${caseName} test end `);
536    })
537    /**
538     * @tc.number     : SUB_Telephony_Contact_AddContact_0900
539     * @tc.name       : testTelephonyContactAddContact0900
540     * @tc.desc       : Add a contacts and useing the callback method as an asynchronous method 10+
541     * @tc.size       : MediumTest
542     * @tc.type       : Function
543     * @tc.level      : Level 3
544     */
545    it('testTelephonyContactAddContact0900', 0, async (done: Function) => {
546      const caseName: string = "testTelephonyContactAddContact0900";
547      console.info(`${caseName} test start `);
548      let context: Context = AppStorage.get('context') as Context;
549      let phoneNumContact: contact.Contact = {
550        name: {
551          fullName: 'Frank'
552        }, phoneNumbers: [{
553          phoneNumber: '10086'
554        }]
555      };
556      try {
557        contact.addContact(context, phoneNumContact, (err: BusinessError, data: number) => {
558          if (err) {
559            console.log(`${caseName} callback: err>${JSON.stringify(err)}`);
560            ExpectFail();
561            done();
562          } else {
563            console.log(`${caseName} callback: success data>${JSON.stringify(data)}`);
564            ExpectTrue(data > 0);
565            done();
566          }
567        });
568      } catch (err) {
569        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
570        ExpectFail();
571        done();
572      }
573      console.info(`${caseName} test end `);
574    });
575
576    /**
577     * @tc.number     : SUB_Telephony_Contact_AddContact_1200
578     * @tc.name       : testTelephonyContactAddContact1200
579     * @tc.desc       : Add a contacts and useing the callback method as an asynchronous method 10+
580     * @tc.size       : MediumTest
581     * @tc.type       : Function
582     * @tc.level      : Level 3
583     */
584    it('testTelephonyContactAddContact1200', 0, async (done: Function) => {
585      const caseName: string = "testTelephonyContactAddContact1200";
586      console.info(`${caseName} test start `);
587      let phoneNumContact: contact.Contact = {
588        id: 10, name: {
589          fullName: '张三发发发发发发发发发afafafafafafafafafafaf张三发发发发发发发发发afafafafafafafafafafaf张三发发发发发发发发发afafafafafafafafafafaf张三发发发发发发发发发afafafafafafafafafafaf'
590        }, phoneNumbers: [{
591          phoneNumber: '13811111111'
592        }]
593      };
594      try {
595        let context: Context = AppStorage.get('context') as Context;
596        contact.addContact(context, phoneNumContact, (err: BusinessError, data: number) => {
597          if (err) {
598            console.log(`${caseName} callback: err>${JSON.stringify(err)}`);
599            ExpectFail();
600            done();
601          } else {
602            console.log(`${caseName} callback: success data>${JSON.stringify(data)}`);
603            ExpectTrue(data > 0);
604            done();
605          }
606        });
607      } catch (err) {
608        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
609        ExpectFail();
610        done();
611      }
612      console.info(`${caseName} test end `);
613    })
614    /**
615     * @tc.number     : SUB_Telephony_Contact_AddContact_1300
616     * @tc.name       : testTelephonyContactAddContact1300
617     * @tc.desc       : Add a contacts and useing the callback method as an asynchronous method 10+
618     * @tc.size       : MediumTest
619     * @tc.type       : Function
620     * @tc.level      : Level 3
621     */
622    it('testTelephonyContactAddContact1300', 0, async (done: Function) => {
623      const caseName: string = "testTelephonyContactAddContact1300";
624      console.info(`${caseName} test start `);
625      let context: Context = AppStorage.get('context') as Context;
626      let phoneNumContact: contact.Contact = {
627        id: 10, name: {
628          fullName: '张三'
629        }, phoneNumbers: [{
630          phoneNumber: '010-5591008'
631        }]
632      };
633      try {
634        contact.addContact(context, phoneNumContact, (err: BusinessError, data: number) => {
635          if (err) {
636            console.log(`${caseName} callback: err>${JSON.stringify(err)}`);
637            ExpectFail();
638            done();
639          } else {
640            console.log(`${caseName} callback: success data>${JSON.stringify(data)}`);
641            ExpectTrue(data > 0);
642            done();
643          }
644        });
645      } catch (err) {
646        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
647        ExpectFail();
648        done();
649      }
650      console.info(`${caseName} test end `);
651    })
652    /**
653     * @tc.number     : SUB_Telephony_Contact_AddContact_1400
654     * @tc.name       : testTelephonyContactAddContact1400
655     * @tc.desc       : Add a contacts and useing the callback method as an asynchronous method 10+
656     * @tc.size       : MediumTest
657     * @tc.type       : Function
658     * @tc.level      : Level 3
659     */
660    it('testTelephonyContactAddContact1400', 0, async (done: Function) => {
661      const caseName: string = "testTelephonyContactAddContact1400";
662      console.info(`${caseName} test start `);
663      let context: Context = AppStorage.get('context') as Context;
664      let phoneNumContact: contact.Contact = {
665        id: 10, name: {
666          fullName: 'Eve!@'
667        }, phoneNumbers: [{
668          phoneNumber: '13811111111'
669        }]
670      };
671      try {
672        contact.addContact(context, phoneNumContact, (err: BusinessError, data: number) => {
673          if (err) {
674            console.log(`${caseName} callback: err>${JSON.stringify(err)}`);
675            ExpectFail();
676            done();
677          } else {
678            console.log(`${caseName} callback: success data>${JSON.stringify(data)}`);
679            ExpectTrue(data > 0);
680            done();
681          }
682        });
683      } catch (err) {
684        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
685        ExpectFail();
686        done();
687      }
688      console.info(`${caseName} test end `);
689    })
690    /**
691     * @tc.number     : SUB_Telephony_Contact_AddContact_1500
692     * @tc.name       : testTelephonyContactAddContact1500
693     * @tc.desc       : Add a contacts and useing the callback method as an asynchronous method 10+
694     * @tc.size       : MediumTest
695     * @tc.type       : Function
696     * @tc.level      : Level 3
697     */
698    it('testTelephonyContactAddContact1500', 0, async (done: Function) => {
699      const caseName: string = "testTelephonyContactAddContact1500";
700      console.info(`${caseName} test start `);
701      let context: Context = AppStorage.get('context') as Context;
702      let phoneNumContact: contact.Contact = {
703        id: 10, name: {
704          fullName: '李四'
705        }, phoneNumbers: [{
706          phoneNumber: '+123-456-7890'
707        }]
708      };
709      try {
710        contact.addContact(context, phoneNumContact, (err: BusinessError, data: number) => {
711          if (err) {
712            console.log(`${caseName} callback: err>${JSON.stringify(err)}`);
713            ExpectFail();
714            done();
715          } else {
716            console.log(`${caseName} callback: success data>${JSON.stringify(data)}`);
717            ExpectTrue(data > 0);
718            done();
719          }
720        });
721      } catch (err) {
722        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
723        ExpectFail();
724        done();
725      }
726      console.info(`${caseName} test end `);
727    })
728    /**
729     * @tc.number     : SUB_Telephony_Contact_AddContact_1600
730     * @tc.name       : testTelephonyContactAddContact1600
731     * @tc.desc       : Add a contacts and useing the Promise method as an asynchronous method 10+
732     * @tc.size       : MediumTest
733     * @tc.type       : Function
734     * @tc.level      : Level 2
735     */
736    it('testTelephonyContactAddContact1600', 0, async (done: Function) => {
737      const caseName: string = "testTelephonyContactAddContact1600";
738      console.info(`${caseName} test start `);
739      let context: Context = AppStorage.get('context') as Context;
740      let phoneNumContact: contact.Contact = {
741        id: 15, name: {
742          fullName: '张三'
743        }, phoneNumbers: [{
744          phoneNumber: '13800000000'
745        }]
746      };
747      try {
748        let promise = contact.addContact(context, phoneNumContact);
749        promise.then((data: number) => {
750          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
751          ExpectTrue(data > 0);
752          done();
753        }).catch((err: BusinessError) => {
754          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
755          ExpectFail();
756          done();
757        });
758      } catch (err) {
759        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
760        ExpectFail();
761        done();
762      }
763      console.info(`${caseName} test end `);
764    })
765    /**
766     * @tc.number     : SUB_Telephony_Contact_AddContact_1700
767     * @tc.name       : testTelephonyContactAddContact1700
768     * @tc.desc       : Add a contacts and useing the Promise method as an asynchronous method 10+
769     * @tc.size       : MediumTest
770     * @tc.type       : Function
771     * @tc.level      : Level 2
772     */
773    it('testTelephonyContactAddContact1700', 0, async (done: Function) => {
774      const caseName: string = "testTelephonyContactAddContact1700";
775      console.info(`${caseName} test start `);
776      let context: Context = AppStorage.get('context') as Context;
777      let phoneNumContact: contact.Contact = {
778        id: 16, name: {
779          fullName: '李四'
780        }, phoneNumbers: [{
781          phoneNumber: '13800000000'
782        }]
783      };
784      try {
785        let promise = contact.addContact(context, phoneNumContact);
786        promise.then((data: number) => {
787          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
788          ExpectTrue(data > 0);
789          let promise2 = contact.addContact(context, phoneNumContact);
790          promise2.then((data: number) => {
791            console.log(`${caseName} success data>${JSON.stringify(data)}`);
792            ExpectTrue(data > 0);
793            contact.queryContactsByPhoneNumber(context, "13800000000", (err: BusinessError, data: contact.Contact[]) => {
794              if (err) {
795                console.info(`${caseName} queryContacts:err->${JSON.stringify(err)}`);
796                ExpectFail();
797                done();
798              } else {
799                console.info(`${caseName} queryContacts:success->${JSON.stringify(data)}`);
800                ExpectTrue(data.length === 2);
801                done()
802              }
803            });
804          }).catch((err: BusinessError) => {
805            console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
806            ExpectFail();
807            done();
808          });
809        }).catch((err: BusinessError) => {
810          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
811          ExpectFail();
812          done();
813        });
814      } catch (err) {
815        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
816        ExpectFail();
817        done();
818      }
819      console.info(`${caseName} test end `);
820    })
821    /**
822     * @tc.number     : SUB_Telephony_Contact_AddContact_1800
823     * @tc.name       : testTelephonyContactAddContact1800
824     * @tc.desc       : Add a contacts and useing the Promise method as an asynchronous method 10+
825     * @tc.size       : MediumTest
826     * @tc.type       : Function
827     * @tc.level      : Level 3
828     */
829    it('testTelephonyContactAddContact1800', 0, async (done: Function) => {
830      const caseName: string = "testTelephonyContactAddContact1800";
831      console.info(`${caseName} test start `);
832      let context: Context = AppStorage.get('context') as Context;
833      let phoneNumContact: contact.Contact = {
834        name: {
835          fullName: ''
836        }, phoneNumbers: [{
837          phoneNumber: '13800000000'
838        }]
839      };
840      try {
841        let promise = contact.addContact(context, phoneNumContact);
842        promise.then((data: number) => {
843          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
844          ExpectTrue(data > 0);
845          done();
846        }).catch((err: BusinessError) => {
847          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
848          ExpectFail();
849          done();
850        });
851      } catch (err) {
852        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
853        ExpectFail();
854        done();
855      }
856      console.info(`${caseName} test end `);
857    })
858    /**
859     * @tc.number     : SUB_Telephony_Contact_AddContact_1900
860     * @tc.name       : testTelephonyContactAddContact1900
861     * @tc.desc       : Add a contacts and useing the Promise method as an asynchronous method 10+
862     * @tc.size       : MediumTest
863     * @tc.type       : Function
864     * @tc.level      : Level 3
865     */
866    it('testTelephonyContactAddContact1900', 0, async (done: Function) => {
867      const caseName: string = "testTelephonyContactAddContact1900";
868      console.info(`${caseName} test start `);
869      let context: Context = AppStorage.get('context') as Context;
870      let phoneNumContact: contact.Contact = {
871        name: {
872          fullName: '张三'
873        }, phoneNumbers: [{
874          phoneNumber: ''
875        }]
876      };
877      try {
878        let promise = contact.addContact(context, phoneNumContact);
879        promise.then((data: number) => {
880          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
881          ExpectTrue(data > 0);
882          done();
883        }).catch((err: BusinessError) => {
884          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
885          ExpectFail();
886          done();
887        });
888      } catch (err) {
889        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
890        ExpectFail();
891        done();
892      }
893      console.info(`${caseName} test end `);
894    })
895    /**
896     * @tc.number     : SUB_Telephony_Contact_AddContact_2000
897     * @tc.name       : testTelephonyContactAddContact2000
898     * @tc.desc       : Add a contacts and useing the Promise method as an asynchronous method 10+
899     * @tc.size       : MediumTest
900     * @tc.type       : Function
901     * @tc.level      : Level 3
902     */
903    it('testTelephonyContactAddContact2000', 0, async (done: Function) => {
904      const caseName: string = "testTelephonyContactAddContact2000";
905      console.info(`${caseName} test start `);
906      let context: Context = AppStorage.get('context') as Context;
907      let phoneNumContact: contact.Contact = {
908        name: {
909          fullName: '张三'
910        }, phoneNumbers: [{
911          phoneNumber: '110'
912        }]
913      };
914      try {
915        let promise = contact.addContact(context, phoneNumContact);
916        promise.then((data: number) => {
917          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
918          ExpectTrue(data > 0);
919          done();
920        }).catch((err: BusinessError) => {
921          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
922          ExpectFail();
923          done();
924        });
925      } catch (err) {
926        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
927        ExpectFail();
928        done();
929      }
930      console.info(`${caseName} test end `);
931    })
932    /**
933     * @tc.number     : SUB_Telephony_Contact_AddContact_2100
934     * @tc.name       : testTelephonyContactAddContact2100
935     * @tc.desc       : Add a contacts and useing the Promise method as an asynchronous method 10+
936     * @tc.size       : MediumTest
937     * @tc.type       : Function
938     * @tc.level      : Level 3
939     */
940    it('testTelephonyContactAddContact2100', 0, async (done: Function) => {
941      const caseName: string = "testTelephonyContactAddContact2100";
942      console.info(`${caseName} test start `);
943      let context: Context = AppStorage.get('context') as Context;
944      let phoneNumContact: contact.Contact = {
945        name: {
946          fullName: 'Frank'
947        }, phoneNumbers: [{
948          phoneNumber: '12345'
949        }]
950      };
951      try {
952        let promise = contact.addContact(context, phoneNumContact);
953        promise.then((data: number) => {
954          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
955          ExpectTrue(data > 0);
956          done();
957        }).catch((err: BusinessError) => {
958          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
959          ExpectFail();
960          done();
961        });
962      } catch (err) {
963        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
964        ExpectFail();
965        done();
966      }
967      console.info(`${caseName} test end `);
968    })
969    /**
970     * @tc.number     : SUB_Telephony_Contact_AddContact_2200
971     * @tc.name       : testTelephonyContactAddContact2200
972     * @tc.desc       : Add a contacts and useing the Promise method as an asynchronous method 10+
973     * @tc.size       : MediumTest
974     * @tc.type       : Function
975     * @tc.level      : Level 3
976     */
977    it('testTelephonyContactAddContact2200', 0, async (done: Function) => {
978      const caseName: string = "testTelephonyContactAddContact2200";
979      console.info(`${caseName} test start `);
980      let context: Context = AppStorage.get('context') as Context;
981      let phoneNumContact: contact.Contact = {
982        name: {
983          fullName: 'Frank'
984        }, phoneNumbers: [{
985          phoneNumber: '13800000000'
986        }, {
987          phoneNumber: '13811111111'
988        }]
989      };
990      try {
991        let promise = contact.addContact(context, phoneNumContact);
992        promise.then((data: number) => {
993          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
994          ExpectTrue(data > 0);
995          done();
996        }).catch((err: BusinessError) => {
997          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
998          ExpectFail();
999          done();
1000        });
1001      } catch (err) {
1002        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
1003        ExpectFail();
1004        done();
1005      }
1006      console.info(`${caseName} test end `);
1007    })
1008    /**
1009     * @tc.number     : SUB_Telephony_Contact_AddContact_2300
1010     * @tc.name       : testTelephonyContactAddContact2300
1011     * @tc.desc       : Add a contacts and useing the Promise method as an asynchronous method 10+
1012     * @tc.size       : MediumTest
1013     * @tc.type       : Function
1014     * @tc.level      : Level 3
1015     */
1016    it('testTelephonyContactAddContact2300', 0, async (done: Function) => {
1017      const caseName: string = "testTelephonyContactAddContact2300";
1018      console.info(`${caseName} test start `);
1019      let context: Context = AppStorage.get('context') as Context;
1020      let phoneNumContact: contact.Contact = {
1021        name: {
1022          fullName: 'Frank'
1023        }, phoneNumbers: [{
1024          phoneNumber: '13800000000'
1025        }, {
1026          phoneNumber: '13811111111'
1027        }, {
1028          phoneNumber: '13800000000'
1029        }, {
1030          phoneNumber: '13822222222'
1031        }]
1032      };
1033      try {
1034        let promise = contact.addContact(context, phoneNumContact);
1035        promise.then((data: number) => {
1036          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
1037          ExpectTrue(data > 0);
1038          done();
1039        }).catch((err: BusinessError) => {
1040          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
1041          ExpectFail();
1042          done();
1043        });
1044      } catch (err) {
1045        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
1046        ExpectFail();
1047        done();
1048      }
1049      console.info(`${caseName} test end `);
1050    })
1051    /**
1052     * @tc.number     : SUB_Telephony_Contact_AddContact_2400
1053     * @tc.name       : testTelephonyContactAddContact2400
1054     * @tc.desc       : Add a contacts and useing the Promise method as an asynchronous method 10+
1055     * @tc.size       : MediumTest
1056     * @tc.type       : Function
1057     * @tc.level      : Level 3
1058     */
1059    it('testTelephonyContactAddContact2400', 0, async (done: Function) => {
1060      const caseName: string = "testTelephonyContactAddContact2400";
1061      console.info(`${caseName} test start `);
1062      let context: Context = AppStorage.get('context') as Context;
1063      let phoneNumContact: contact.Contact = {
1064        name: {
1065          fullName: 'Frank'
1066        }, phoneNumbers: [{
1067          phoneNumber: '10086'
1068        }]
1069      };
1070      try {
1071        let promise = contact.addContact(context, phoneNumContact);
1072        promise.then((data: number) => {
1073          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
1074          ExpectTrue(data > 0);
1075          done();
1076        }).catch((err: BusinessError) => {
1077          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
1078          ExpectFail();
1079          done();
1080        });
1081      } catch (err) {
1082        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
1083        ExpectFail();
1084        done();
1085      }
1086      console.info(`${caseName} test end `);
1087    });
1088
1089
1090    /**
1091     * @tc.number     : SUB_Telephony_Contact_AddContact_2700
1092     * @tc.name       : testTelephonyContactAddContact2700
1093     * @tc.desc       : Add a contacts and useing the Promise method as an asynchronous method 10+
1094     * @tc.size       : MediumTest
1095     * @tc.type       : Function
1096     * @tc.level      : Level 3
1097     */
1098    it('testTelephonyContactAddContact2700', 0, async (done: Function) => {
1099      const caseName: string = "testTelephonyContactAddContact2700";
1100      console.info(`${caseName} test start `);
1101      let context: Context = AppStorage.get('context') as Context;
1102      let phoneNumContact: contact.Contact = {
1103        name: {
1104          fullName: '张三发发发发发发发发发张三发发发发发发发发发张三发发发发发发发发发张三发发发发发发发发发张三发发发发发发发发发张三发发发发发发发发发张三发发发发发发发发发'
1105        }, phoneNumbers: [{
1106          phoneNumber: '13811111111'
1107        }]
1108      };
1109      try {
1110        let promise = contact.addContact(context, phoneNumContact);
1111        promise.then((data: number) => {
1112          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
1113          ExpectTrue(data > 0);
1114          done();
1115        }).catch((err: BusinessError) => {
1116          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
1117          ExpectFail();
1118          done();
1119        });
1120      } catch (err) {
1121        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
1122        ExpectFail();
1123        done();
1124      }
1125      console.info(`${caseName} test end `);
1126    });
1127
1128    /**
1129     * @tc.number     : SUB_Telephony_Contact_AddContact_2800
1130     * @tc.name       : testTelephonyContactAddContact2800
1131     * @tc.desc       : Add a contacts and useing the Promise method as an asynchronous method 10+
1132     * @tc.size       : MediumTest
1133     * @tc.type       : Function
1134     * @tc.level      : Level 3
1135     */
1136    it('testTelephonyContactAddContact2800', 0, async (done: Function) => {
1137      const caseName: string = "testTelephonyContactAddContact2800";
1138      console.info(`${caseName} test start `);
1139      let context: Context = AppStorage.get('context') as Context;
1140      let phoneNumContact: contact.Contact = {
1141        name: {
1142          fullName: '张三'
1143        }, phoneNumbers: [{
1144          phoneNumber: '010-5591008'
1145        }]
1146      };
1147      try {
1148        let promise = contact.addContact(context, phoneNumContact);
1149        promise.then((data: number) => {
1150          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
1151          ExpectTrue(data > 0);
1152          done();
1153        }).catch((err: BusinessError) => {
1154          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
1155          ExpectFail();
1156          done();
1157        });
1158      } catch (err) {
1159        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
1160        ExpectFail();
1161        done();
1162      }
1163      console.info(`${caseName} test end `);
1164    })
1165    /**
1166     * @tc.number     : SUB_Telephony_Contact_AddContact_2900
1167     * @tc.name       : testTelephonyContactAddContact2900
1168     * @tc.desc       : Add a contacts and useing the Promise method as an asynchronous method 10+
1169     * @tc.size       : MediumTest
1170     * @tc.type       : Function
1171     * @tc.level      : Level 3
1172     */
1173    it('testTelephonyContactAddContact2900', 0, async (done: Function) => {
1174      const caseName: string = "testTelephonyContactAddContact2900";
1175      console.info(`${caseName} test start `);
1176      let context: Context = AppStorage.get('context') as Context;
1177      let phoneNumContact: contact.Contact = {
1178        name: {
1179          fullName: 'Eve!@'
1180        }, phoneNumbers: [{
1181          phoneNumber: '13811111111'
1182        }]
1183      };
1184      try {
1185        let promise = contact.addContact(context, phoneNumContact);
1186        promise.then((data: number) => {
1187          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
1188          ExpectTrue(data > 0);
1189          done();
1190        }).catch((err: BusinessError) => {
1191          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
1192          ExpectFail();
1193          done();
1194        });
1195      } catch (err) {
1196        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
1197        ExpectFail();
1198        done();
1199      }
1200      console.info(`${caseName} test end `);
1201    })
1202    /**
1203     * @tc.number     : SUB_Telephony_Contact_AddContact_3000
1204     * @tc.name       : testTelephonyContactAddContact3000
1205     * @tc.desc       : Add a contacts and useing the Promise method as an asynchronous method 10+
1206     * @tc.size       : MediumTest
1207     * @tc.type       : Function
1208     * @tc.level      : Level 3
1209     */
1210    it('testTelephonyContactAddContact3000', 0, async (done: Function) => {
1211      const caseName: string = "testTelephonyContactAddContact3000";
1212      console.info(`${caseName} test start `);
1213      let context: Context = AppStorage.get('context') as Context;
1214      let phoneNumContact: contact.Contact = {
1215        name: {
1216          fullName: '张三'
1217        }, phoneNumbers: [{
1218          phoneNumber: '+123-456-7890'
1219        }]
1220      };
1221      try {
1222        let promise = contact.addContact(context, phoneNumContact);
1223        promise.then((data: number) => {
1224          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
1225          ExpectTrue(data > 0);
1226          done();
1227        }).catch((err: BusinessError) => {
1228          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
1229          ExpectFail();
1230          done();
1231        });
1232      } catch (err) {
1233        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
1234        ExpectFail();
1235        done();
1236      }
1237      console.info(`${caseName} test end `);
1238    })
1239
1240
1241    /**
1242     * @tc.number : SUB_Telephony_Contact_AddContact_6100
1243     * @tc.name   : testTelephonyContactAddContact6100
1244     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1245     * @tc.size   : MediumTest
1246     * @tc.type   : Function
1247     * @tc.level  : Level 2
1248     */
1249    it('testTelephonyContactAddContact6100', 0, async (done: Function) => {
1250      const caseName: string = "testTelephonyContactAddContact6100";
1251      console.info(`${caseName} test start `);
1252      let context: Context = AppStorage.get('context') as Context;
1253      if (contactData.nickName !== undefined) {
1254        contactData.nickName.nickName = "小明";
1255      }
1256      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1257        if (addErr) {
1258          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1259          ExpectFail();
1260          done();
1261        } else {
1262          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1263          ExpectTrue(addData > 0);
1264          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1265            if (keyErr) {
1266              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1267              ExpectFail();
1268              done();
1269            } else {
1270              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1271              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1272                if (queryErr) {
1273                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1274                  ExpectFail();
1275                  done();
1276                } else {
1277                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1278                  let resDate: contact.Contact = queryData;
1279                  if (resDate.nickName !== undefined) {
1280                    let nickName: contact.NickName = resDate.nickName;
1281                    ExpectTrue(nickName.nickName === "小明");
1282                    done();
1283                  } else {
1284                    ExpectFail();
1285                    done();
1286                  }
1287                }
1288              });
1289            }
1290          });
1291        }
1292      });
1293      console.info(`${caseName} test end `);
1294    });
1295    /**
1296     * @tc.number : SUB_Telephony_Contact_AddContact_6200
1297     * @tc.name   : testTelephonyContactAddContact6200
1298     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1299     * @tc.size   : MediumTest
1300     * @tc.type   : Function
1301     * @tc.level  : Level 3
1302     */
1303    it('testTelephonyContactAddContact6200', 0, async (done: Function) => {
1304      const caseName: string = "testTelephonyContactAddContact6200";
1305      console.info(`${caseName} test start `);
1306      let context: Context = AppStorage.get('context') as Context;
1307      if (contactData.nickName !== undefined) {
1308        contactData.nickName.nickName = "小  明";
1309      }
1310      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1311        if (addErr) {
1312          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1313          ExpectFail();
1314          done();
1315        } else {
1316          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1317          ExpectTrue(addData > 0);
1318          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1319            if (keyErr) {
1320              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1321              ExpectFail();
1322              done();
1323            } else {
1324              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1325              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1326                if (queryErr) {
1327                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1328                  ExpectFail();
1329                  done();
1330                } else {
1331                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1332                  let resDate: contact.Contact = queryData;
1333                  if (resDate.nickName !== undefined) {
1334                    let nickName: contact.NickName = resDate.nickName;
1335                    ExpectTrue(nickName.nickName === "小  明");
1336                    done();
1337                  } else {
1338                    ExpectFail();
1339                    done();
1340                  }
1341                }
1342              });
1343            }
1344          });
1345        }
1346      });
1347      console.info(`${caseName} test end `);
1348    });
1349
1350    /**
1351     * @tc.number : SUB_Telephony_Contact_AddContact_6300
1352     * @tc.name   : testTelephonyContactAddContact6300
1353     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1354     * @tc.size   : MediumTest
1355     * @tc.type   : Function
1356     * @tc.level  : Level 3
1357     */
1358    it('testTelephonyContactAddContact6300', 0, async (done: Function) => {
1359      const caseName: string = "testTelephonyContactAddContact6300";
1360      console.info(`${caseName} test start `);
1361      let context: Context = AppStorage.get('context') as Context;
1362      if (contactData.nickName !== undefined) {
1363        contactData.nickName.nickName = "小明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明明";
1364      }
1365      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1366        if (addErr) {
1367          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1368          ExpectFail();
1369          done();
1370        } else {
1371          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1372          ExpectTrue(addData > 0);
1373          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1374            if (keyErr) {
1375              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1376              ExpectFail();
1377              done();
1378            } else {
1379              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1380              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1381                if (queryErr) {
1382                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1383                  ExpectFail();
1384                  done();
1385                } else {
1386                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1387                  ExpectTrue(queryData.key === keyData);
1388                  done();
1389                }
1390              });
1391            }
1392          });
1393        }
1394      });
1395      console.info(`${caseName} test end `);
1396    });
1397
1398    /**
1399     * @tc.number : SUB_Telephony_Contact_AddContact_6400
1400     * @tc.name   : testTelephonyContactAddContact6400
1401     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1402     * @tc.size   : MediumTest
1403     * @tc.type   : Function
1404     * @tc.level  : Level 3
1405     */
1406    it('testTelephonyContactAddContact6400', 0, async (done: Function) => {
1407      const caseName: string = "testTelephonyContactAddContact6400";
1408      console.info(`${caseName} test start `);
1409      let context: Context = AppStorage.get('context') as Context;
1410      if (contactData.nickName !== undefined) {
1411        contactData.nickName.nickName = "";
1412      }
1413      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1414        if (addErr) {
1415          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1416          ExpectFail();
1417          done();
1418        } else {
1419          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1420          ExpectTrue(addData > 0);
1421          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1422            if (keyErr) {
1423              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1424              ExpectFail();
1425              done();
1426            } else {
1427              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1428              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1429                if (queryErr) {
1430                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1431                  ExpectFail();
1432                  done();
1433                } else {
1434                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1435                  ExpectTrue(true);
1436                  done();
1437                }
1438              });
1439            }
1440          });
1441        }
1442      });
1443      console.info(`${caseName} test end `);
1444    });
1445    /**
1446     * @tc.number : SUB_Telephony_Contact_AddContact_6500
1447     * @tc.name   : testTelephonyContactAddContact6500
1448     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1449     * @tc.size   : MediumTest
1450     * @tc.type   : Function
1451     * @tc.level  : Level 3
1452     */
1453    it('testTelephonyContactAddContact6500', 0, async (done: Function) => {
1454      const caseName: string = "testTelephonyContactAddContact6500";
1455      console.info(`${caseName} test start `);
1456      let context: Context = AppStorage.get('context') as Context;
1457      if (contactData.nickName !== undefined) {
1458        contactData.nickName.nickName = "contact.addContact()";
1459      }
1460      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1461        if (addErr) {
1462          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1463          ExpectFail();
1464          done();
1465        } else {
1466          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1467          ExpectTrue(addData > 0);
1468          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1469            if (keyErr) {
1470              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1471              ExpectFail();
1472              done();
1473            } else {
1474              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1475              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1476                if (queryErr) {
1477                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1478                  ExpectFail();
1479                  done();
1480                } else {
1481                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1482                  let resDate: contact.Contact = queryData;
1483                  if (resDate.nickName !== undefined) {
1484                    let nickName: contact.NickName = resDate.nickName;
1485                    ExpectTrue(nickName.nickName === "contact.addContact()");
1486                    done();
1487                  } else {
1488                    ExpectFail();
1489                    done();
1490                  }
1491                }
1492              });
1493            }
1494          });
1495        }
1496      });
1497      console.info(`${caseName} test end `);
1498    });
1499    /**
1500     * @tc.number : SUB_Telephony_Contact_AddContact_6600
1501     * @tc.name   : testTelephonyContactAddContact6600
1502     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1503     * @tc.size   : MediumTest
1504     * @tc.type   : Function
1505     * @tc.level  : Level 2
1506     */
1507    it('testTelephonyContactAddContact6600', 0, async (done: Function) => {
1508      const caseName: string = "testTelephonyContactAddContact6600";
1509      console.info(`${caseName} test start `);
1510      let context: Context = AppStorage.get('context') as Context;
1511      if (contactData.note !== undefined) {
1512        contactData.note.noteContent = "同事";
1513      }
1514      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1515        if (addErr) {
1516          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1517          ExpectFail();
1518          done();
1519        } else {
1520          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1521          ExpectTrue(addData > 0);
1522          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1523            if (keyErr) {
1524              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1525              ExpectFail();
1526              done();
1527            } else {
1528              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1529              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1530                if (queryErr) {
1531                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1532                  ExpectFail();
1533                  done();
1534                } else {
1535                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1536                  let resDate: contact.Contact = queryData;
1537                  if (resDate.note !== undefined) {
1538                    let note: contact.Note = resDate.note;
1539                    ExpectTrue(note.noteContent === "同事");
1540                    done();
1541                  } else {
1542                    ExpectFail();
1543                    done();
1544                  }
1545                }
1546              });
1547            }
1548          });
1549        }
1550      });
1551      console.info(`${caseName} test end `);
1552    });
1553    /**
1554     * @tc.number : SUB_Telephony_Contact_AddContact_6700
1555     * @tc.name   : testTelephonyContactAddContact6700
1556     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1557     * @tc.size   : MediumTest
1558     * @tc.type   : Function
1559     * @tc.level  : Level 3
1560     */
1561    it('testTelephonyContactAddContact6700', 0, async (done: Function) => {
1562      const caseName: string = "testTelephonyContactAddContact6700";
1563      console.info(`${caseName} test start `);
1564      let context: Context = AppStorage.get('context') as Context;
1565      if (contactData.note !== undefined) {
1566        contactData.note.noteContent = "同事1990.3";
1567      }
1568      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1569        if (addErr) {
1570          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1571          ExpectFail();
1572          done();
1573        } else {
1574          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1575          ExpectTrue(addData > 0);
1576          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1577            if (keyErr) {
1578              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1579              ExpectFail();
1580              done();
1581            } else {
1582              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1583              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1584                if (queryErr) {
1585                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1586                  ExpectFail();
1587                  done();
1588                } else {
1589                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1590                  let resDate: contact.Contact = queryData;
1591                  if (resDate.note !== undefined) {
1592                    let note: contact.Note = resDate.note;
1593                    ExpectTrue(note.noteContent === "同事1990.3");
1594                    done();
1595                  } else {
1596                    ExpectFail();
1597                    done();
1598                  }
1599                }
1600              });
1601            }
1602          });
1603        }
1604      });
1605      console.info(`${caseName} test end `);
1606    });
1607    /**
1608     * @tc.number : SUB_Telephony_Contact_AddContact_6800
1609     * @tc.name   : testTelephonyContactAddContact6800
1610     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1611     * @tc.size   : MediumTest
1612     * @tc.type   : Function
1613     * @tc.level  : Level 3
1614     */
1615    it('testTelephonyContactAddContact6800', 0, async (done: Function) => {
1616      const caseName: string = "testTelephonyContactAddContact6800";
1617      console.info(`${caseName} test start `);
1618      let context: Context = AppStorage.get('context') as Context;
1619      if (contactData.note !== undefined) {
1620        contactData.note.noteContent = "同事~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ha";
1621      }
1622      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1623        if (addErr) {
1624          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1625          ExpectFail();
1626          done();
1627        } else {
1628          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1629          ExpectTrue(addData > 0);
1630          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1631            if (keyErr) {
1632              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1633              ExpectFail();
1634              done();
1635            } else {
1636              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1637              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1638                if (queryErr) {
1639                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1640                  ExpectFail();
1641                  done();
1642                } else {
1643                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1644                  ExpectTrue(true);
1645                  done();
1646                }
1647              });
1648            }
1649          });
1650        }
1651      });
1652      console.info(`${caseName} test end `);
1653    });
1654    /**
1655     * @tc.number : SUB_Telephony_Contact_AddContact_6900
1656     * @tc.name   : testTelephonyContactAddContact6900
1657     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1658     * @tc.size   : MediumTest
1659     * @tc.type   : Function
1660     * @tc.level  : Level 3
1661     */
1662    it('testTelephonyContactAddContact6900', 0, async (done: Function) => {
1663      const caseName: string = "testTelephonyContactAddContact6900";
1664      console.info(`${caseName} test start `);
1665      let context: Context = AppStorage.get('context') as Context;
1666      if (contactData.note !== undefined) {
1667        contactData.note.noteContent = "";
1668      }
1669      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1670        if (addErr) {
1671          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1672          ExpectFail();
1673          done();
1674        } else {
1675          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1676          ExpectTrue(addData > 0);
1677          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1678            if (keyErr) {
1679              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1680              ExpectFail();
1681              done();
1682            } else {
1683              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1684              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1685                if (queryErr) {
1686                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1687                  ExpectFail();
1688                  done();
1689                } else {
1690                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1691                  ExpectTrue(true);
1692                  done();
1693                }
1694              });
1695            }
1696          });
1697        }
1698      });
1699      console.info(`${caseName} test end `);
1700    });
1701    /**
1702     * @tc.number : SUB_Telephony_Contact_AddContact_7000
1703     * @tc.name   : testTelephonyContactAddContact7000
1704     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1705     * @tc.size   : MediumTest
1706     * @tc.type   : Function
1707     * @tc.level  : Level 3
1708     */
1709    it('testTelephonyContactAddContact7000', 0, async (done: Function) => {
1710      const caseName: string = "testTelephonyContactAddContact7000";
1711      console.info(`${caseName} test start `);
1712      let context: Context = AppStorage.get('context') as Context;
1713      if (contactData.note !== undefined) {
1714        contactData.note.noteContent = "contact.addContact()";
1715      }
1716      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1717        if (addErr) {
1718          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1719          ExpectFail();
1720          done();
1721        } else {
1722          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1723          ExpectTrue(addData > 0);
1724          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1725            if (keyErr) {
1726              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1727              ExpectFail();
1728              done();
1729            } else {
1730              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1731              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1732                if (queryErr) {
1733                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1734                  ExpectFail();
1735                  done();
1736                } else {
1737                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1738                  ExpectTrue(true);
1739                  done();
1740                }
1741              });
1742            }
1743          });
1744        }
1745      });
1746      console.info(`${caseName} test end `);
1747    });
1748
1749    /**
1750     * @tc.number : SUB_Telephony_Contact_AddContact_7100
1751     * @tc.name   : testTelephonyContactAddContact7100
1752     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1753     * @tc.size   : MediumTest
1754     * @tc.type   : Function
1755     * @tc.level  : Level 2
1756     */
1757    it('testTelephonyContactAddContact7100', 0, async (done: Function) => {
1758      const caseName: string = "testTelephonyContactAddContact7100";
1759      console.info(`${caseName} test start `);
1760      let context: Context = AppStorage.get('context') as Context;
1761      if (contactData.organization !== undefined) {
1762        contactData.organization.name = "organization_name";
1763      }
1764      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1765        if (addErr) {
1766          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1767          ExpectFail();
1768          done();
1769        } else {
1770          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1771          ExpectTrue(addData > 0);
1772          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1773            if (keyErr) {
1774              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1775              ExpectFail();
1776              done();
1777            } else {
1778              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1779              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1780                if (queryErr) {
1781                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1782                  ExpectFail();
1783                  done();
1784                } else {
1785                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1786                  let resDate: contact.Contact = queryData;
1787                  if (resDate.organization !== undefined) {
1788                    let organization: contact.Organization = resDate.organization;
1789                    ExpectTrue(organization.name === "organization_name");
1790                    done();
1791                  } else {
1792                    ExpectFail();
1793                    done();
1794                  }
1795                }
1796              });
1797            }
1798          });
1799        }
1800      });
1801      console.info(`${caseName} test end `);
1802    });
1803
1804    /**110.
1805     * @tc.number : SUB_Telephony_Contact_AddContact_7200
1806     * @tc.name   : testTelephonyContactAddContact7200
1807     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1808     * @tc.size   : MediumTest
1809     * @tc.type   : Function
1810     * @tc.level  : Level 3
1811     */
1812    it('testTelephonyContactAddContact7200', 0, async (done: Function) => {
1813      const caseName: string = "testTelephonyContactAddContact7200";
1814      console.info(`${caseName} test start `);
1815      let context: Context = AppStorage.get('context') as Context;
1816      if (contactData.organization !== undefined) {
1817        contactData.organization.name = "organization Development";
1818      }
1819      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1820        if (addErr) {
1821          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1822          ExpectFail();
1823          done();
1824        } else {
1825          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1826          ExpectTrue(addData > 0);
1827          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1828            if (keyErr) {
1829              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1830              ExpectFail();
1831              done();
1832            } else {
1833              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1834              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1835                if (queryErr) {
1836                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1837                  ExpectFail();
1838                  done();
1839                } else {
1840                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1841                  let resDate: contact.Contact = queryData;
1842                  if (resDate.organization !== undefined) {
1843                    let organization: contact.Organization = resDate.organization;
1844                    ExpectTrue(organization.name === "organization Development");
1845                    done();
1846                  } else {
1847                    ExpectFail();
1848                    done();
1849                  }
1850                }
1851              });
1852            }
1853          });
1854        }
1855      });
1856      console.info(`${caseName} test end `);
1857    });
1858    /**
1859     * @tc.number : SUB_Telephony_Contact_AddContact_7300
1860     * @tc.name   : testTelephonyContactAddContact7300
1861     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1862     * @tc.size   : MediumTest
1863     * @tc.type   : Function
1864     * @tc.level  : Level 3
1865     */
1866    it('testTelephonyContactAddContact7300', 0, async (done: Function) => {
1867      const caseName: string = "testTelephonyContactAddContact7300";
1868      console.info(`${caseName} test start `);
1869      let context: Context = AppStorage.get('context') as Context;
1870      if (contactData.organization !== undefined) {
1871        contactData.organization.name = "organizationName";
1872      }
1873      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1874        if (addErr) {
1875          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1876          ExpectFail();
1877          done();
1878        } else {
1879          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1880          ExpectTrue(addData > 0);
1881          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1882            if (keyErr) {
1883              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1884              ExpectFail();
1885              done();
1886            } else {
1887              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1888              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1889                if (queryErr) {
1890                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1891                  ExpectFail();
1892                  done();
1893                } else {
1894                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1895                  let resDate: contact.Contact = queryData;
1896                  if (resDate.organization !== undefined) {
1897                    let organization: contact.Organization = resDate.organization;
1898                    ExpectTrue(organization.name === "organizationName");
1899                    done();
1900                  } else {
1901                    ExpectFail();
1902                    done();
1903                  }
1904                }
1905              });
1906            }
1907          });
1908        }
1909      });
1910      console.info(`${caseName} test end `);
1911    });
1912    /**
1913     * @tc.number : SUB_Telephony_Contact_AddContact_7400
1914     * @tc.name   : testTelephonyContactAddContact7400
1915     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1916     * @tc.size   : MediumTest
1917     * @tc.type   : Function
1918     * @tc.level  : Level 3
1919     */
1920    it('testTelephonyContactAddContact7400', 0, async (done: Function) => {
1921      const caseName: string = "testTelephonyContactAddContact7400";
1922      console.info(`${caseName} test start `);
1923      let context: Context = AppStorage.get('context') as Context;
1924      if (contactData.organization !== undefined) {
1925        contactData.organization.name = "organizationName organizationName organizationName organizationName organizationName organizationName organizationName organizationName organizationName organizationName organizationName organizationName organizationName organizationName organizationName organizationName organizationName organizationName organizationName";
1926      }
1927      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1928        if (addErr) {
1929          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1930          ExpectFail();
1931          done();
1932        } else {
1933          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1934          ExpectTrue(addData > 0);
1935          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1936            if (keyErr) {
1937              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1938              ExpectFail();
1939              done();
1940            } else {
1941              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1942              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1943                if (queryErr) {
1944                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1945                  ExpectFail();
1946                  done();
1947                } else {
1948                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1949                  ExpectTrue(true);
1950                  done();
1951                }
1952              });
1953            }
1954          });
1955        }
1956      });
1957      console.info(`${caseName} test end `);
1958    });
1959    /**
1960     * @tc.number : SUB_Telephony_Contact_AddContact_7500
1961     * @tc.name   : testTelephonyContactAddContact7500
1962     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
1963     * @tc.size   : MediumTest
1964     * @tc.type   : Function
1965     * @tc.level  : Level 3
1966     */
1967    it('testTelephonyContactAddContact7500', 0, async (done: Function) => {
1968      const caseName: string = "testTelephonyContactAddContact7500";
1969      console.info(`${caseName} test start `);
1970      let context: Context = AppStorage.get('context') as Context;
1971      if (contactData.organization !== undefined) {
1972        contactData.organization.name = "";
1973      }
1974      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
1975        if (addErr) {
1976          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
1977          ExpectFail();
1978          done();
1979        } else {
1980          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
1981          ExpectTrue(addData > 0);
1982          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
1983            if (keyErr) {
1984              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
1985              ExpectFail();
1986              done();
1987            } else {
1988              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
1989              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
1990                if (queryErr) {
1991                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
1992                  ExpectFail();
1993                  done();
1994                } else {
1995                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
1996                  ExpectTrue(true);
1997                  done();
1998                }
1999              });
2000            }
2001          });
2002        }
2003      });
2004      console.info(`${caseName} test end `);
2005    });
2006    /**
2007     * @tc.number : SUB_Telephony_Contact_AddContact_7600
2008     * @tc.name   : testTelephonyContactAddContact7600
2009     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
2010     * @tc.size   : MediumTest
2011     * @tc.type   : Function
2012     * @tc.level  : Level 3
2013     */
2014    it('testTelephonyContactAddContact7600', 0, async (done: Function) => {
2015      const caseName: string = "testTelephonyContactAddContact7600";
2016      console.info(`${caseName} test start `);
2017      let context: Context = AppStorage.get('context') as Context;
2018      if (contactData.organization !== undefined) {
2019        contactData.organization.name = "contact.addContact(context, contactData)";
2020      }
2021      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
2022        if (addErr) {
2023          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
2024          ExpectFail();
2025          done();
2026        } else {
2027          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
2028          ExpectTrue(addData > 0);
2029          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
2030            if (keyErr) {
2031              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
2032              ExpectFail();
2033              done();
2034            } else {
2035              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
2036              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
2037                if (queryErr) {
2038                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
2039                  ExpectFail();
2040                  done();
2041                } else {
2042                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
2043                  ExpectTrue(true);
2044                  done();
2045                }
2046              });
2047            }
2048          });
2049        }
2050      });
2051      console.info(`${caseName} test end `);
2052    });
2053    /**
2054     * @tc.number : SUB_Telephony_Contact_AddContact_7700
2055     * @tc.name   : testTelephonyContactAddContact7700
2056     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
2057     * @tc.size   : MediumTest
2058     * @tc.type   : Function
2059     * @tc.level  : Level 2
2060     */
2061    it('testTelephonyContactAddContact7700', 0, async (done: Function) => {
2062      const caseName: string = "testTelephonyContactAddContact7700";
2063      console.info(`${caseName} test start `);
2064      let context: Context = AppStorage.get('context') as Context;
2065      if (contactData.organization !== undefined) {
2066        contactData.organization.title = "test title";
2067      }
2068      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
2069        if (addErr) {
2070          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
2071          ExpectFail();
2072          done();
2073        } else {
2074          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
2075          ExpectTrue(addData > 0);
2076          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
2077            if (keyErr) {
2078              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
2079              ExpectFail();
2080              done();
2081            } else {
2082              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
2083              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
2084                if (queryErr) {
2085                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
2086                  ExpectFail();
2087                  done();
2088                } else {
2089                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
2090                  let resDate: contact.Contact = queryData;
2091                  if (resDate.organization !== undefined) {
2092                    let organization: contact.Organization = resDate.organization;
2093                    ExpectTrue(organization.title === "test title");
2094                    done();
2095                  } else {
2096                    ExpectFail();
2097                    done();
2098                  }
2099                }
2100              });
2101            }
2102          });
2103        }
2104      });
2105      console.info(`${caseName} test end `);
2106    });
2107    /**
2108     * @tc.number : SUB_Telephony_Contact_AddContact_7800
2109     * @tc.name   : testTelephonyContactAddContact7800
2110     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
2111     * @tc.size   : MediumTest
2112     * @tc.type   : Function
2113     * @tc.level  : Level 3
2114     */
2115    it('testTelephonyContactAddContact7800', 0, async (done: Function) => {
2116      const caseName: string = "testTelephonyContactAddContact7800";
2117      console.info(`${caseName} test start `);
2118      let context: Context = AppStorage.get('context') as Context;
2119      if (contactData.organization !== undefined) {
2120        contactData.organization.title = "";
2121      }
2122      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
2123        if (addErr) {
2124          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
2125          ExpectFail();
2126          done();
2127        } else {
2128          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
2129          ExpectTrue(addData > 0);
2130          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
2131            if (keyErr) {
2132              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
2133              ExpectFail();
2134              done();
2135            } else {
2136              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
2137              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
2138                if (queryErr) {
2139                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
2140                  ExpectFail();
2141                  done();
2142                } else {
2143                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
2144                  let resDate: contact.Contact = queryData;
2145                  if (resDate.organization !== undefined) {
2146                    let organization: contact.Organization = resDate.organization;
2147                    ExpectTrue(organization.title === undefined);
2148                    done();
2149                  } else {
2150                    ExpectFail();
2151                    done();
2152                  }
2153                }
2154              });
2155            }
2156          });
2157        }
2158      });
2159      console.info(`${caseName} test end `);
2160    });
2161    /**
2162     * @tc.number : SUB_Telephony_Contact_AddContact_7900
2163     * @tc.name   : testTelephonyContactAddContact7900
2164     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
2165     * @tc.size   : MediumTest
2166     * @tc.type   : Function
2167     * @tc.level  : Level 3
2168     */
2169    it('testTelephonyContactAddContact7900', 0, async (done: Function) => {
2170      const caseName: string = "testTelephonyContactAddContact7900";
2171      console.info(`${caseName} test start `);
2172      let context: Context = AppStorage.get('context') as Context;
2173      if (contactData.organization !== undefined) {
2174        contactData.organization.title = "rgarhrthrtar16546841655gieruhgiuerhgi的回复i耳庇古如果发erjfioerhgiowwhgiorehgr8iiiiiiiiiiii(*&^!$#!@#iiiiiiiiiiiiiiiiiiiiiiiiiii还能否龟儿回归额外回归微软划归俄国会饿v与uvu余部i一个统一的如同当初太原分院吧";
2175      }
2176      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
2177        if (addErr) {
2178          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
2179          ExpectFail();
2180          done();
2181        } else {
2182          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
2183          ExpectTrue(addData > 0);
2184          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
2185            if (keyErr) {
2186              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
2187              ExpectFail();
2188              done();
2189            } else {
2190              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
2191              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
2192                if (queryErr) {
2193                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
2194                  ExpectFail();
2195                  done();
2196                } else {
2197                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
2198                  let resDate: contact.Contact = queryData;
2199                  if (resDate.organization !== undefined) {
2200                    let organization: contact.Organization = resDate.organization;
2201                    if (organization.title !== undefined) {
2202                      ExpectTrue(organization.title.length > 0);
2203                      done();
2204                    }
2205                  } else {
2206                    ExpectFail();
2207                    done();
2208                  }
2209                }
2210              });
2211            }
2212          });
2213        }
2214      });
2215      console.info(`${caseName} test end `);
2216    });
2217    /**
2218     * @tc.number : SUB_Telephony_Contact_AddContact_8000
2219     * @tc.name   : testTelephonyContactAddContact8000
2220     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
2221     * @tc.size   : MediumTest
2222     * @tc.type   : Function
2223     * @tc.level  : Level 3
2224     */
2225    it('testTelephonyContactAddContact8000', 0, async (done: Function) => {
2226      const caseName: string = "testTelephonyContactAddContact8000";
2227      console.info(`${caseName} test start `);
2228      let context: Context = AppStorage.get('context') as Context;
2229      if (contactData.organization !== undefined) {
2230        contactData.organization.title = "contact.addContact(context, contactData, (err: BusinessError, addData) => {})";
2231      }
2232      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
2233        if (addErr) {
2234          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
2235          ExpectFail();
2236          done();
2237        } else {
2238          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
2239          ExpectTrue(addData > 0);
2240          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
2241            if (keyErr) {
2242              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
2243              ExpectFail();
2244              done();
2245            } else {
2246              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
2247              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
2248                if (queryErr) {
2249                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
2250                  ExpectFail();
2251                  done();
2252                } else {
2253                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
2254                  let resDate: contact.Contact = queryData;
2255                  if (resDate.organization !== undefined) {
2256                    let organization: contact.Organization = resDate.organization;
2257                    ExpectTrue(typeof (organization.title) === "string");
2258                    done();
2259                  } else {
2260                    ExpectFail();
2261                    done();
2262                  }
2263                }
2264              });
2265            }
2266          });
2267        }
2268      });
2269      console.info(`${caseName} test end `);
2270    });
2271    /**
2272     * @tc.number : SUB_Telephony_Contact_AddContact_8100
2273     * @tc.name   : testTelephonyContactAddContact8100
2274     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
2275     * @tc.size   : MediumTest
2276     * @tc.type   : Function
2277     * @tc.level  : Level 2
2278     */
2279    it('testTelephonyContactAddContact8100', 0, async (done: Function) => {
2280      const caseName: string = "testTelephonyContactAddContact8100";
2281      console.info(`${caseName} test start `);
2282      let context: Context = AppStorage.get('context') as Context;
2283      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
2284        if (addErr) {
2285          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
2286          ExpectFail();
2287          done();
2288        } else {
2289          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
2290          ExpectTrue(addData > 0);
2291          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
2292            if (keyErr) {
2293              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
2294              ExpectFail();
2295              done();
2296            } else {
2297              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
2298              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
2299                if (queryErr) {
2300                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
2301                  ExpectFail();
2302                  done();
2303                } else {
2304                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
2305                  ExpectTrue(true);
2306                  done();
2307                }
2308              });
2309            }
2310          });
2311        }
2312      });
2313      console.info(`${caseName} test end `);
2314    });
2315    /**
2316     * @tc.number : SUB_Telephony_Contact_AddContact_8200
2317     * @tc.name   : testTelephonyContactAddContact8200
2318     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
2319     * @tc.size   : MediumTest
2320     * @tc.type   : Function
2321     * @tc.level  : Level 3
2322     */
2323    it('testTelephonyContactAddContact8200', 0, async (done: Function) => {
2324      const caseName: string = "testTelephonyContactAddContact8200";
2325      console.info(`${caseName} test start `);
2326      let context: Context = AppStorage.get('context') as Context;
2327      if (contactData.name !== undefined) {
2328        contactData.name.fullName = "axdgdfgfhgdjg194986194949848所赋予的不要动不动辨别!#@¥#%¥……%&contact.queryKey()";
2329        contactData.name.familyName = "axdgdfgfhgdjg194986194949848所赋予的不要动不动辨别!#@¥#%¥……%&contact.queryKey()";
2330      }
2331      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
2332        if (addErr) {
2333          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
2334          ExpectFail();
2335          done();
2336        } else {
2337          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
2338          ExpectTrue(addData > 0);
2339          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
2340            if (keyErr) {
2341              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
2342              ExpectFail();
2343              done();
2344            } else {
2345              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
2346              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
2347                if (queryErr) {
2348                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
2349                  ExpectFail();
2350                  done();
2351                } else {
2352                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
2353                  let resDate: contact.Contact = queryData;
2354                  if (resDate.name !== undefined) {
2355                    let name: contact.Name = resDate.name;
2356                    ExpectTrue(name.fullName !== "" && typeof (name.familyName) === "string");
2357                    done();
2358                  } else {
2359                    ExpectFail();
2360                    done();
2361                  }
2362                }
2363              });
2364            }
2365          });
2366        }
2367      });
2368      console.info(`${caseName} test end `);
2369    });
2370    /**
2371     * @tc.number : SUB_Telephony_Contact_AddContact_8400
2372     * @tc.name   : testTelephonyContactAddContact8400
2373     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
2374     * @tc.size   : MediumTest
2375     * @tc.type   : Function
2376     * @tc.level  : Level 3
2377     */
2378    it('testTelephonyContactAddContact8400', 0, async (done: Function) => {
2379      const caseName: string = "testTelephonyContactAddContact8400";
2380      console.info(`${caseName} test start `);
2381      let context: Context = AppStorage.get('context') as Context;
2382      if (contactData.name !== undefined) {
2383        contactData.name.fullName = "axdgdfgfhgdjg194986194949848所赋予的不要动不动辨别!#@¥#%¥……%&contact.queryKey()";
2384        contactData.name.givenName = "axdgdfgfhgdjg194986194949848所赋予的不要动不动辨别!#@¥#%¥……%&contact.queryKey()";
2385      }
2386      contact.addContact(context, contactData, (err: BusinessError, addData: number) => {
2387        if (err) {
2388          console.info(`${caseName} addContact: err->${JSON.stringify(err)}`);
2389          ExpectFail();
2390          done();
2391        } else {
2392          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
2393          ExpectTrue(addData > 0);
2394          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
2395            if (keyErr) {
2396              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
2397              ExpectFail();
2398              done();
2399            } else {
2400              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
2401              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
2402                if (queryErr) {
2403                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
2404                  ExpectFail();
2405                  done();
2406                } else {
2407                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
2408                  let resDate: contact.Contact = queryData;
2409                  if (resDate.name !== undefined) {
2410                    let name: contact.Name = resDate.name;
2411                    ExpectTrue(name.fullName !== "" && typeof (name.givenName) === "string");
2412                    done();
2413                  } else {
2414                    ExpectFail();
2415                    done();
2416                  }
2417                }
2418              });
2419            }
2420          });
2421        }
2422      });
2423      console.info(`${caseName} test end `);
2424    });
2425    /**
2426     * @tc.number : SUB_Telephony_Contact_AddContact_8500
2427     * @tc.name   : testTelephonyContactAddContact8500
2428     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
2429     * @tc.size   : MediumTest
2430     * @tc.type   : Function
2431     * @tc.level  : Level 3
2432     */
2433    it('testTelephonyContactAddContact8500', 0, async (done: Function) => {
2434      const caseName: string = "testTelephonyContactAddContact8500";
2435      console.info(`${caseName} test start `);
2436      let context: Context = AppStorage.get('context') as Context;
2437      if (contactData.name !== undefined) {
2438        contactData.name.fullName = "axdgdfgfhgdjg194986194949848所赋予的不要动不动辨别!#@¥#%¥……%&contact.queryKey()";
2439        contactData.name.givenNamePhonetic = "axdgdfgfhgdjg194986194949848所赋予的不要动不动辨别!#@¥#%¥……%&contact.queryKey()";
2440      }
2441      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
2442        if (addErr) {
2443          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
2444          ExpectFail();
2445          done();
2446        } else {
2447          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
2448          ExpectTrue(addData > 0);
2449          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
2450            if (keyErr) {
2451              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
2452              ExpectFail();
2453              done();
2454            } else {
2455              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
2456              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
2457                if (queryErr) {
2458                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
2459                  ExpectFail();
2460                  done();
2461                } else {
2462                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
2463                  let resDate: contact.Contact = queryData;
2464                  if (resDate.name !== undefined) {
2465                    let name: contact.Name = resDate.name;
2466                    ExpectTrue(name.fullName !== "" && typeof (name.givenNamePhonetic) === "string");
2467                    done();
2468                  } else {
2469                    ExpectFail();
2470                    done();
2471                  }
2472                }
2473              });
2474            }
2475          });
2476        }
2477      });
2478      console.info(`${caseName} test end `);
2479    });
2480    /**
2481     * @tc.number : SUB_Telephony_Contact_AddContact_8600
2482     * @tc.name   : testTelephonyContactAddContact8600
2483     * @tc.desc   : Add a contacts and useing the callback method as an asynchronous method
2484     * @tc.size   : MediumTest
2485     * @tc.type   : Function
2486     * @tc.level  : Level 3
2487     */
2488    it('testTelephonyContactAddContact8600', 0, async (done: Function) => {
2489      const caseName: string = "testTelephonyContactAddContact8600";
2490      console.info(`${caseName} test start `);
2491      let context: Context = AppStorage.get('context') as Context;
2492      if (contactData.name !== undefined) {
2493        contactData.name.fullName = "axdgdfgfhgdjg194986194949848所赋予的不要动不动辨别!#@¥#%¥……%&contact.queryKey()";
2494        contactData.name.middleName = "axdgdfgfhgdjg194986194949848所赋予的不要动不动辨别!#@¥#%¥……%&contact.queryKey()";
2495      }
2496      contact.addContact(context, contactData, (addErr: BusinessError, addData: number) => {
2497        if (addErr) {
2498          console.info(`${caseName} addContact: err->${JSON.stringify(addErr)}`);
2499          ExpectFail();
2500          done();
2501        } else {
2502          console.info(`${caseName} addContact: success data->${JSON.stringify(addData)}`);
2503          ExpectTrue(addData > 0);
2504          contact.queryKey(context, addData, (keyErr: BusinessError, keyData: string) => {
2505            if (keyErr) {
2506              console.info(`${caseName} queryKey: err->${JSON.stringify(keyErr)}`);
2507              ExpectFail();
2508              done();
2509            } else {
2510              console.info(`${caseName} queryKey: success data->${JSON.stringify(keyData)}`);
2511              contact.queryContact(context, keyData, (queryErr: BusinessError, queryData: contact.Contact) => {
2512                if (queryErr) {
2513                  console.info(`${caseName} queryContact: err->${JSON.stringify(queryErr)}`);
2514                  ExpectFail();
2515                  done();
2516                } else {
2517                  console.info(`${caseName} queryContact: success data->${JSON.stringify(queryData)}`);
2518                  let resDate: contact.Contact = queryData;
2519                  if (resDate.name !== undefined) {
2520                    let name: contact.Name = resDate.name;
2521                    ExpectTrue(name.fullName !== "" && typeof (name.middleName) === "string");
2522                    done();
2523                  } else {
2524                    ExpectFail();
2525                    done();
2526                  }
2527                }
2528              });
2529            }
2530          });
2531        }
2532      });
2533      console.info(`${caseName} test end `);
2534    });
2535
2536
2537
2538
2539
2540
2541
2542    /**
2543     * @tc.number     : SUB_Telephony_Contact_IsLocalContact_0100
2544     * @tc.name       : testTelephonyContactIsLocalContact0100
2545     * @tc.desc       : Determine if the current contact ID is in the phone book and use the callback method as an asynchronous method  10+
2546     * @tc.size       : MediumTest
2547     * @tc.type       : Function
2548     * @tc.level      : Level 2
2549     */
2550    it('testTelephonyContactIsLocalContact0100', 0, async (done: Function) => {
2551      const caseName: string = "testTelephonyContactIsLocalContact0100";
2552      console.info(`${caseName} test start `);
2553      let context: Context = AppStorage.get('context') as Context;
2554      try {
2555        contact.addContact(context, contactData, (err: BusinessError, data: number) => {
2556          if (err) {
2557            console.log(`${caseName} addContact: err>${JSON.stringify(err)}`);
2558            ExpectFail();
2559            done();
2560          } else {
2561            console.log(`${caseName} addContact: success data>${JSON.stringify(data)}`);
2562            ExpectTrue(data > 0);
2563            contact.isLocalContact(context, data, (err: BusinessError<void>, data: boolean) => {
2564              if (err) {
2565                console.log(`${caseName} isLocalContact: err>${JSON.stringify(err)}`);
2566                ExpectFail();
2567                done();
2568              } else {
2569                console.log(`${caseName} isLocalContact: success data>${JSON.stringify(data)}`);
2570                ExpectTrue(data === true);
2571                done();
2572              }
2573            });
2574          }
2575        });
2576      } catch (err) {
2577        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
2578        ExpectFail();
2579        done();
2580      }
2581      console.info(`${caseName} test end `);
2582    })
2583    /**
2584     * @tc.number     : SUB_Telephony_Contact_IsLocalContact_0200
2585     * @tc.name       : testTelephonyContactIsLocalContact0200
2586     * @tc.desc       : Determine if the current contact ID is in the phone book and use the callback method as an asynchronous method  10+
2587     * @tc.size       : MediumTest
2588     * @tc.type       : Function
2589     * @tc.level      : Level 3
2590     */
2591    it('testTelephonyContactIsLocalContact0200', 0, async (done: Function) => {
2592      const caseName: string = "testTelephonyContactIsLocalContact0200";
2593      console.info(`${caseName} test start `);
2594      let context: Context = AppStorage.get('context') as Context;
2595      try {
2596        contact.isLocalContact(context, 9999, (err: BusinessError<void>, data: boolean) => {
2597          if (err) {
2598            console.log(`${caseName} callback: err>${JSON.stringify(err)}`);
2599            ExpectFail();
2600            done();
2601          } else {
2602            console.log(`${caseName} callback: success data>${JSON.stringify(data)}`);
2603            ExpectTrue(data === false);
2604            done();
2605          }
2606        });
2607      } catch (err) {
2608        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
2609        ExpectFail();
2610        done();
2611      }
2612      console.info(`${caseName} test end `);
2613    })
2614
2615    /**
2616     * @tc.number     : SUB_Telephony_Contact_IsLocalContact_0400
2617     * @tc.name       : testTelephonyContactIsLocalContact0400
2618     * @tc.desc       : Determine if the current contact ID is in the phone book and use callback as an asynchronous method 10+
2619     * @tc.size       : MediumTest
2620     * @tc.type       : Function
2621     * @tc.level      : Level 3
2622     */
2623    it('testTelephonyContactIsLocalContact0400', 0, async (done: Function) => {
2624      const caseName: string = "testTelephonyContactIsLocalContact0400";
2625      console.info(`${caseName} test start `);
2626      let context: Context = AppStorage.get('context') as Context;
2627      try {
2628        contact.isLocalContact(context, -1, (err: BusinessError<void>, data: boolean) => {
2629          if (err) {
2630            console.log(`${caseName} err>${JSON.stringify(err)}`);
2631            ExpectTrue(err.code === 401);
2632            done();
2633          } else {
2634            console.log(`${caseName} success data>${JSON.stringify(data)}`);
2635            ExpectTrue(data === false);
2636            done();
2637          }
2638        });
2639      } catch (err) {
2640        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
2641        ExpectFail();
2642        done();
2643      }
2644      console.info(`${caseName} test end `);
2645    })
2646    /**
2647     * @tc.number     : SUB_Telephony_Contact_IsLocalContact_0500
2648     * @tc.name       : testTelephonyContactIsLocalContact0500
2649     * @tc.desc       : Determine if the current contact ID is in the phone book and use callback as an asynchronous method 10+
2650     * @tc.size       : MediumTest
2651     * @tc.type       : Function
2652     * @tc.level      : Level 3
2653     */
2654    it('testTelephonyContactIsLocalContact0500', 0, async (done: Function) => {
2655      const caseName: string = "testTelephonyContactIsLocalContact0500";
2656      console.info(`${caseName} test start `);
2657      try {
2658        let context: Context = AppStorage.get('context') as Context;
2659        contact.isLocalContact(context, 1.5, (err: BusinessError<void>, data: boolean) => {
2660          if (err) {
2661            console.log(`${caseName} callback: err>${JSON.stringify(err)}`);
2662            ExpectFail();
2663            done();
2664          } else {
2665            console.log(`${caseName} callback: success data>${JSON.stringify(data)}`);
2666            ExpectTrue(data === false);
2667            done();
2668          }
2669        });
2670      } catch (err) {
2671        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
2672        ExpectFail();
2673        done();
2674      }
2675      console.info(`${caseName} test end `);
2676    })
2677
2678
2679    /**
2680     * @tc.number     : SUB_Telephony_Contact_IsLocalContact_0700
2681     * @tc.name       : testTelephonyContactIsLocalContact0700
2682     * @tc.desc       : Determine if the current contact ID is in the phone book and use the Promise method as an asynchronous method 10+
2683     * @tc.size       : MediumTest
2684     * @tc.type       : Function
2685     * @tc.level      : Level 3
2686     */
2687    it('testTelephonyContactIsLocalContact0700', 0, async (done: Function) => {
2688      const caseName: string = "testTelephonyContactIsLocalContact0700";
2689      console.info(`${caseName} test start `);
2690      try {
2691        let context: Context = AppStorage.get('context') as Context;
2692        contact.isLocalContact(context, -10000, (err: BusinessError<void>, data: boolean) => {
2693          if (err) {
2694            console.log(`${caseName} callback: err>${JSON.stringify(err)}`);
2695            ExpectTrue(err.code === 401);
2696            done();
2697          } else {
2698            console.log(`${caseName} callback: success data>${JSON.stringify(data)}`);
2699            ExpectTrue(data === false)
2700            done();
2701          }
2702        });
2703      } catch (err) {
2704        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
2705        ExpectFail();
2706        done();
2707      }
2708      console.info(`${caseName} test end `);
2709    })
2710    /**
2711     * @tc.number     : SUB_Telephony_Contact_IsLocalContact_0800
2712     * @tc.name       : testTelephonyContactIsLocalContact0800
2713     * @tc.desc       : Determine if the current contact ID is in the phone book and use the Promise method as an asynchronous method 10+
2714     * @tc.size       : MediumTest
2715     * @tc.type       : Function
2716     * @tc.level      : Level 3
2717     */
2718    it('testTelephonyContactIsLocalContact0800', 0, async (done: Function) => {
2719      const caseName: string = "testTelephonyContactIsLocalContact0800";
2720      console.info(`${caseName} test start `);
2721      try {
2722        let context: Context = AppStorage.get('context') as Context;
2723        contact.isLocalContact(context, 10000000, (err: BusinessError<void>, data: boolean) => {
2724          if (err) {
2725            console.log(`${caseName} callback: err>${JSON.stringify(err)}`);
2726            ExpectFail();
2727            done();
2728          } else {
2729            console.log(`${caseName} callback: success data>${JSON.stringify(data)}`);
2730            ExpectTrue(data === false)
2731            done();
2732          }
2733        });
2734      } catch (err) {
2735        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
2736        ExpectFail();
2737        done();
2738      }
2739      console.info(`${caseName} test end `);
2740
2741    })
2742    /**
2743     * @tc.number     : SUB_Telephony_Contact_IsLocalContact_0900
2744     * @tc.name       : testTelephonyContactIsLocalContact0900
2745     * @tc.desc       : Determine if the current contact ID is in the phone book and use the Promise method as an asynchronous method 10+
2746     * @tc.size       : MediumTest
2747     * @tc.type       : Function
2748     * @tc.level      : Level 2
2749     */
2750    it('testTelephonyContactIsLocalContact0900', 0, async (done: Function) => {
2751      const caseName: string = "testTelephonyContactIsLocalContact0900";
2752      console.info(`${caseName} test start `);
2753      let context: Context = AppStorage.get('context') as Context;
2754      let phoneNumContact: contact.Contact = {
2755        id: 1, name: {
2756          fullName: '张三'
2757        }, phoneNumbers: [{
2758          phoneNumber: '13800000000'
2759        }]
2760      };
2761      try {
2762        contact.addContact(context, phoneNumContact, (err: BusinessError, data: number) => {
2763          if (err) {
2764            console.log(`${caseName} callback: err>${JSON.stringify(err)}`);
2765            ExpectFail();
2766            done();
2767          } else {
2768            console.log(`${caseName} callback: success data>${JSON.stringify(data)}`);
2769            ExpectTrue(data > 0);
2770            let promise = contact.isLocalContact(context, data);
2771            promise.then((data: boolean) => {
2772              console.log(`${caseName} success: data>${JSON.stringify(data)}`);
2773              ExpectTrue(data === true);
2774              done();
2775            }).catch((err: BusinessError) => {
2776              console.error(`isLocalContact fail: err>${JSON.stringify(err)}`);
2777              ExpectFail();
2778              done();
2779            });
2780          }
2781        });
2782      } catch (err) {
2783        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
2784        ExpectFail();
2785        done();
2786      }
2787      console.info(`${caseName} test end `);
2788    })
2789    /**
2790     * @tc.number     : SUB_Telephony_Contact_IsLocalContact_1000
2791     * @tc.name       : testTelephonyContactIsLocalContact1000
2792     * @tc.desc       : Determine if the current contact ID is in the phone book and use Promise as an asynchronous method 10+
2793     * @tc.size       : MediumTest
2794     * @tc.type       : Function
2795     * @tc.level      : Level 3
2796     */
2797    it('testTelephonyContactIsLocalContact1000', 0, async (done: Function) => {
2798      const caseName: string = "testTelephonyContactIsLocalContact1000";
2799      console.info(`${caseName} test start `);
2800      try {
2801        let context: Context = AppStorage.get('context') as Context;
2802        let promise = contact.isLocalContact(context, 9999);
2803        promise.then((data: boolean) => {
2804          console.log(`isLocalContact success: data>${JSON.stringify(data)}`);
2805          ExpectTrue(data === false);
2806          done();
2807        }).catch((err: BusinessError) => {
2808          console.error(`isLocalContact fail: err>${JSON.stringify(err)}`);
2809          ExpectFail();
2810          done();
2811        });
2812      } catch (err) {
2813        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
2814        ExpectFail();
2815        done();
2816      }
2817      console.info(`${caseName} test end `);
2818    })
2819
2820    /**
2821     * @tc.number     : SUB_Telephony_Contact_IsLocalContact_1200
2822     * @tc.name       : testTelephonyContactIsLocalContact1200
2823     * @tc.desc       : Determine if the current contact ID is in the phone book and use Promise as an asynchronous method 10+
2824     * @tc.size       : MediumTest
2825     * @tc.type       : Function
2826     * @tc.level      : Level 3
2827     */
2828    it('testTelephonyContactIsLocalContact1200', 0, async (done: Function) => {
2829      const caseName: string = "testTelephonyContactIsLocalContact1200";
2830      console.info(`${caseName} test start `);
2831      let context: Context = AppStorage.get('context') as Context;
2832      try {
2833        let promise = contact.isLocalContact(context, -1);
2834        promise.then((data: boolean) => {
2835          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
2836          ExpectTrue(data === false);
2837          done();
2838        }).catch((err: BusinessError) => {
2839          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
2840          ExpectTrue(err.code === 401);
2841          done();
2842        });
2843      } catch (err) {
2844        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
2845        ExpectFail();
2846        done();
2847      }
2848      console.info(`${caseName} test end `);
2849    })
2850    /**
2851     * @tc.number     : SUB_Telephony_Contact_IsLocalContact_1300
2852     * @tc.name       : testTelephonyContactIsLocalContact1300
2853     * @tc.desc       : Determine if the current contact ID is in the phone book and use Promise as an asynchronous method 10+
2854     * @tc.size       : MediumTest
2855     * @tc.type       : Function
2856     * @tc.level      : Level 3
2857     */
2858    it('testTelephonyContactIsLocalContact1300', 0, async (done: Function) => {
2859      const caseName: string = "testTelephonyContactIsLocalContact1300";
2860      console.info(`${caseName} test start `);
2861      try {
2862        let context: Context = AppStorage.get('context') as Context;
2863        let promise = contact.isLocalContact(context, 1.5);
2864        promise.then((data: boolean) => {
2865          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
2866          ExpectTrue(data === false);
2867          done();
2868        }).catch((err: BusinessError) => {
2869          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
2870          ExpectFail();
2871          done();
2872        });
2873      } catch (err) {
2874        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
2875        ExpectFail();
2876        done();
2877      }
2878      console.info(`${caseName} test end `);
2879    })
2880
2881    /**
2882     * @tc.number     : SUB_Telephony_Contact_IsLocalContact_1500
2883     * @tc.name       : testTelephonyContactIsLocalContact1500
2884     * @tc.desc       : Determine if the current contact ID is in the phone book and use Promise as an asynchronous method 10+
2885     * @tc.size       : MediumTest
2886     * @tc.type       : Function
2887     * @tc.level      : Level 3
2888     */
2889    it('testTelephonyContactIsLocalContact1500', 0, async (done: Function) => {
2890      const caseName: string = "testTelephonyContactIsLocalContact1500";
2891      console.info(`${caseName} test start `);
2892      try {
2893        let context: Context = AppStorage.get('context') as Context;
2894        let promise = contact.isLocalContact(context, -10000);
2895        promise.then((data: boolean) => {
2896          console.log(`${caseName} success: data>${JSON.stringify(data)}`);
2897          ExpectTrue(data === false);
2898          done();
2899        }).catch((err: BusinessError) => {
2900          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
2901          ExpectTrue(err.code === 401);
2902          done();
2903        });
2904      } catch (err) {
2905        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
2906        ExpectFail();
2907        done();
2908      }
2909      console.info(`${caseName} test end `);
2910    })
2911    /**
2912     * @tc.number     : SUB_Telephony_Contact_IsLocalContact_1600
2913     * @tc.name       : testTelephonyContactIsLocalContact1600
2914     * @tc.desc       : Determine if the current contact ID is in the phone book and use Promise as an asynchronous method 10+
2915     * @tc.size       : MediumTest
2916     * @tc.type       : Function
2917     * @tc.level      : Level 3
2918     */
2919    it('testTelephonyContactIsLocalContact1600', 0, async (done: Function) => {
2920      const caseName: string = "testTelephonyContactIsLocalContact1600";
2921      console.info(`${caseName} test start `);
2922      try {
2923        let context: Context = AppStorage.get('context') as Context;
2924        let promise = contact.isLocalContact(context, 100000000);
2925        promise.then((data: boolean) => {
2926          console.log(`isLocalContact success: data>${JSON.stringify(data)}`);
2927          ExpectTrue(data === false);
2928          done();
2929        }).catch((err: BusinessError) => {
2930          console.error(`${caseName} fail: err>${JSON.stringify(err)}`);
2931          ExpectFail();
2932          done();
2933        });
2934      } catch (err) {
2935        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
2936        ExpectFail();
2937        done();
2938      }
2939      console.info(`${caseName} test end `);
2940    })
2941
2942    /**
2943     * @tc.number     : SUB_Telephony_Contact_DeleteContact_0100
2944     * @tc.name       : testTelephonyContactDeleteContact0100
2945     * @tc.desc       : Delete a contacts and useing the callback method as an asynchronous method 10+
2946     * @tc.size       : MediumTest
2947     * @tc.type       : Function
2948     * @tc.level      : Level 2
2949     */
2950    it('testTelephonyContactDeleteContact0100', 0, async (done: Function) => {
2951      const caseName: string = "testTelephonyContactDeleteContact0100";
2952      console.info(`${caseName} test start `);
2953      let context: Context = AppStorage.get('context') as Context;
2954      contact.addContact(context, contactData, (err: BusinessError, data: number) => {
2955        if (err) {
2956          console.log(`${caseName} addContact:err->${JSON.stringify(err)}`);
2957          ExpectFail();
2958          done();
2959        } else {
2960          console.log(`${caseName} addContact:success->${JSON.stringify(data)}`);
2961          ExpectTrue(data > 0);
2962          contact.queryKey(context, data, (err: BusinessError, key: string) => {
2963            if (err) {
2964              console.log(`${caseName} queryKey: err->${JSON.stringify(err)}`);
2965              ExpectFail();
2966              done();
2967            } else {
2968              console.log(`${caseName} queryKey: success->${JSON.stringify(key)}`);
2969              ExpectTrue(key.length != 0);
2970              contact.deleteContact(context, key, (err: BusinessError) => {
2971                if (err) {
2972                  console.info(`${caseName} deleteContacts:err->${JSON.stringify(err)}`);
2973                  ExpectFail();
2974                  done();
2975                } else {
2976                  console.info(`${caseName} deleteContacts:success`);
2977                  ExpectTrue(true);
2978                  done();
2979                }
2980              });
2981            }
2982          });
2983        }
2984      });
2985      console.info(`${caseName} test end `);
2986    });
2987    /**
2988     * @tc.number     : SUB_Telephony_Contact_DeleteContact_0200
2989     * @tc.name       : testTelephonyContactDeleteContact0200
2990     * @tc.desc       : Delete a contacts and useing the callback method as an asynchronous method 10+
2991     * @tc.size       : MediumTest
2992     * @tc.type       : Function
2993     * @tc.level      : Level 3
2994     */
2995    it('testTelephonyContactDeleteContact0200', 0, async (done: Function) => {
2996      const caseName: string = "testTelephonyContactDeleteContact0200";
2997      console.info(`${caseName} test start `);
2998      let context: Context = AppStorage.get('context') as Context;
2999      try {
3000        contact.deleteContact(context, '', (err: BusinessError) => {
3001          if (err) {
3002            console.info(`${caseName} deleteContacts:err->${JSON.stringify(err)}`);
3003            ExpectTrue(err.code === 401);
3004            done();
3005          } else {
3006            console.info(`${caseName} deleteContacts:success`);
3007            ExpectTrue(true);
3008            done();
3009          }
3010        });
3011      } catch (err) {
3012        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
3013        ExpectFail();
3014        done();
3015      }
3016      console.info(`${caseName} test end `);
3017    });
3018
3019    /**
3020     * @tc.number     : SUB_Telephony_Contact_DeleteContact_0600
3021     * @tc.name       : testTelephonyContactDeleteContact0600
3022     * @tc.desc       : Delete a contacts and useing the promise method as an asynchronous method 10+
3023     * @tc.size       : MediumTest
3024     * @tc.type       : Function
3025     * @tc.level      : Level 2
3026     */
3027    it('testTelephonyContactDeleteContact0600', 0, async (done: Function) => {
3028      const caseName: string = "testTelephonyContactDeleteContact0600";
3029      console.info(`${caseName} test start `);
3030      let context: Context = AppStorage.get('context') as Context;
3031      contact.addContact(context, contactData, (err: BusinessError, data: number) => {
3032        if (err) {
3033          console.log(`${caseName} addContact:err->${JSON.stringify(err)}`);
3034          ExpectFail();
3035          done();
3036        } else {
3037          console.log(`${caseName} addContact:success->${JSON.stringify(data)}`);
3038          ExpectTrue(data > 0);
3039          contact.queryKey(context, data, (err: BusinessError, key: string) => {
3040            if (err) {
3041              console.log(`${caseName} queryKey: err->${JSON.stringify(err)}`);
3042              ExpectFail();
3043              done();
3044            } else {
3045              console.log(`${caseName} queryKey: success->${JSON.stringify(key)}`);
3046              ExpectTrue(key.length != 0);
3047              let promise = contact.deleteContact(context, key);
3048              promise.then(() => {
3049                console.info(`${caseName} deleteContacts:success`);
3050                ExpectTrue(true);
3051                done();
3052              }).catch((err: BusinessError) => {
3053                console.error(`${caseName} deleteContacts:fail->${JSON.stringify(err)}`);
3054                ExpectFail();
3055                done();
3056              });
3057            }
3058          });
3059        }
3060      });
3061      console.info(`${caseName} test end `);
3062    });
3063    /**
3064     * @tc.number     : SUB_Telephony_Contact_DeleteContact_0700
3065     * @tc.name       : testTelephonyContactDeleteContact0700
3066     * @tc.desc       : Delete a contacts and useing the promise method as an asynchronous method 10+
3067     * @tc.size       : MediumTest
3068     * @tc.type       : Function
3069     * @tc.level      : Level 3
3070     */
3071    it('testTelephonyContactDeleteContact0700', 0, async (done: Function) => {
3072      const caseName: string = "testTelephonyContactDeleteContact0700";
3073      console.info(`${caseName} test start `);
3074      let context: Context = AppStorage.get('context') as Context;
3075      try {
3076        let promise = contact.deleteContact(context, "");
3077        promise.then(() => {
3078          console.info(`${caseName} deleteContacts:success`);
3079          ExpectTrue(true);
3080          done();
3081        }).catch((err: BusinessError) => {
3082          console.error(`${caseName} deleteContacts:fail->${JSON.stringify(err)}`);
3083          ExpectTrue(err.code === 401);
3084          done();
3085        });
3086      } catch (err) {
3087        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
3088        ExpectFail();
3089        done();
3090      }
3091      console.info(`${caseName} test end `);
3092    });
3093
3094
3095
3096    /**
3097     * @tc.number     : SUB_Telephony_Contact_QueryHolders_0100
3098     * @tc.name       : testTelephonyContactQueryHolders0100
3099     * @tc.desc       : Query all application information for creating contacts and use the callback method as an asynchronous method.
3100     * @tc.size       : MediumTest
3101     * @tc.type       : Function
3102     * @tc.level      : Level 2
3103     */
3104    it('testTelephonyContactQueryHolders0100', 0, async (done: Function) => {
3105      const caseName: string = "testTelephonyContactQueryHolders0100";
3106      console.info(`${caseName} test start `);
3107      let context: Context = AppStorage.get('context') as Context;
3108      try {
3109        contact.queryHolders(context, (err: BusinessError, data) => {
3110          if (err) {
3111            console.info(`${caseName} callback: err->${JSON.stringify(err)}`);
3112            ExpectFail();
3113            done();
3114          } else {
3115            console.info(`${caseName} callback: success data->${JSON.stringify(data)}`);
3116            ExpectTrue(data.length > 0);
3117            done();
3118          }
3119        });
3120      } catch (err) {
3121        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
3122        ExpectFail();
3123        done();
3124      }
3125      console.info(`${caseName} test end `);
3126    });
3127    /**
3128     * @tc.number     : SUB_Telephony_Contact_QueryHolders_0200
3129     * @tc.name       : testTelephonyContactQueryHolders0200
3130     * @tc.desc       : Query all application information for creating contacts and use the callback method as an asynchronous method.
3131     * @tc.size       : MediumTest
3132     * @tc.type       : Function
3133     * @tc.level      : Level 3
3134     */
3135    it('testTelephonyContactQueryHolders0200', 0, async (done: Function) => {
3136      const caseName: string = "testTelephonyContactQueryHolders0200";
3137      console.info(`${caseName} test start `);
3138      let context: Context = AppStorage.get('context') as Context;
3139      try {
3140        let promise = contact.queryHolders(context);
3141        promise.then((data) => {
3142          console.info(`${caseName} callback: success data->${JSON.stringify(data)}`);
3143          ExpectTrue(data.length > 0);
3144          done();
3145        }).catch((err: BusinessError) => {
3146          console.info(`${caseName} callback: err->${JSON.stringify(err)}`);
3147          ExpectFail();
3148          done();
3149        });
3150      } catch (err) {
3151        console.info(`${caseName} catch: err->${JSON.stringify(err)}`);
3152        ExpectFail();
3153        done();
3154      }
3155      console.info(`${caseName} test end `);
3156    });
3157
3158
3159  })
3160}
3161
3162