diff --git a/telephony/telephonyjstest/BUILD.gn b/telephony/telephonyjstest/BUILD.gn index 5fcf47d4f8a3984c1835470403170f37490da8ec..3f4f81dabfc14a227b617f7062d470a0f15989a9 100644 --- a/telephony/telephonyjstest/BUILD.gn +++ b/telephony/telephonyjstest/BUILD.gn @@ -14,6 +14,7 @@ group("telephonyjstest") { testonly = true deps = [ + "actscontactstageapitest:ActsContactStageAPITest", "call_manager:call_manager", "cellular_data:cellular_data", "netmanager_base:netmanager_base", diff --git a/telephony/telephonyjstest/actscontactstageapitest/AppScope/app.json b/telephony/telephonyjstest/actscontactstageapitest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..97725aa72d91460a6d7df07626058fdff6cb4be1 --- /dev/null +++ b/telephony/telephonyjstest/actscontactstageapitest/AppScope/app.json @@ -0,0 +1,16 @@ +{ + "app": { + "bundleName": "com.example.actscontactstageapitest", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:icon", + "label": "$string:app_name", + "minAPIVersion": 10, + "targetAPIVersion": 10, + "car": { + "apiCompatibleVersion": 10, + "singleUser": false + } + } +} diff --git a/telephony/telephonyjstest/actscontactstageapitest/AppScope/resources/base/element/string.json b/telephony/telephonyjstest/actscontactstageapitest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d1f12ea9692aa14d5e6e140d74baa9b04c25352 --- /dev/null +++ b/telephony/telephonyjstest/actscontactstageapitest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"LifecycleTest" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/actscontactstageapitest/AppScope/resources/base/media/app_icon.png b/telephony/telephonyjstest/actscontactstageapitest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/telephony/telephonyjstest/actscontactstageapitest/AppScope/resources/base/media/app_icon.png differ diff --git a/telephony/telephonyjstest/actscontactstageapitest/BUILD.gn b/telephony/telephonyjstest/actscontactstageapitest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fc2cbc0e45e933d65eebbd7d2601937305ef7f5c --- /dev/null +++ b/telephony/telephonyjstest/actscontactstageapitest/BUILD.gn @@ -0,0 +1,43 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsContactStageAPITest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":ActsTest_js_assets", + ":ActsTest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsContactStageAPITest" + subsystem_name = "telephony" + part_name = "call_manager" +} + +ohos_app_scope("ActsTest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("ActsTest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("ActsTest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":ActsTest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/telephony/telephonyjstest/actscontactstageapitest/Test.json b/telephony/telephonyjstest/actscontactstageapitest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..26f8159182548434ede4726426c136ef5139d06c --- /dev/null +++ b/telephony/telephonyjstest/actscontactstageapitest/Test.json @@ -0,0 +1,29 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.example.actscontactstageapitest", + "module-name": "entry_test", + "shell-timeout": "600000", + "testcase-timeout": 70000 + }, + "kits": [ + { + "test-file-name": [ + "ActsContactStageAPITest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "power-shell wakeup", + "power-shell setmode 602", + "uinput -T -m 200 1000 200 200 200", + "param set persist.ace.testmode.enabled 1" + ] + } + ] +} diff --git a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/TestAbility/TestAbility.ets b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/TestAbility/TestAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..6875e687044d801fb5ae17d76de9bbe78ec29f6f --- /dev/null +++ b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/TestAbility/TestAbility.ets @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import UIAbility from '@ohos.app.ability.UIAbility'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import hilog from '@ohos.hilog'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../test/List.test'; +import window from '@ohos.window'; + +export default class TestAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? ''); + + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite); + globalThis.context = this.context; + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); + windowStage.loadContent('TestAbility/pages/Index', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', + JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/TestAbility/pages/Index.ets b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/TestAbility/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f8e493a1b0db00b6e81a2af99f0a67212f783376 --- /dev/null +++ b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/TestAbility/pages/Index.ets @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..31dba8e3730addb29d10afa6a6beaa0d77c1e4a8 --- /dev/null +++ b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,49 @@ +import hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined; +var abilityDelegatorArguments = undefined; + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'; + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback); + let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName; + let debug = abilityDelegatorArguments.parameters['-D']; + if (debug == 'true') + { + cmd += ' -D'; + } + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/test/List.test.ets b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..83835cc8dc527e41ebc2020de263283951886764 --- /dev/null +++ b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import contactStage from './contactstage.test'; + +export default function testsuite() { + contactStage(); +} \ No newline at end of file diff --git a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/test/contactstage.test.ets b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/test/contactstage.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2ffef4484f6ad7df0ae7a6ad599ca349217afc47 --- /dev/null +++ b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/ets/test/contactstage.test.ets @@ -0,0 +1,1638 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import contact from '@ohos.contact'; +import { afterAll, beforeAll, describe, expect, it } from '@ohos/hypium'; +import uitest from '@ohos.UiTest'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl' + +export default function ContactInterfaceStageTest() { + + describe('ContactInterfaceStageTest', function () { + + function sleep(numberMillis) { + var now = new Date(); + var exitTime = now.getTime() + numberMillis; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) return; + } + } + + beforeAll( async function () { + console.info("beforeAll case"); + try { + let permissions = ["ohos.permission.WRITE_CONTACTS", "ohos.permission.READ_CONTACTS"]; + let atManager = abilityAccessCtrl.createAtManager(); + atManager.requestPermissionsFromUser(globalThis.context, permissions, (err, result) => { + if (err) { + console.info('getPermission failed: ' + JSON.stringify(err)); + } else { + console.info('getPermission suc: ' + JSON.stringify(result)); + } + }); + + let driver = await uitest.Driver.create(); + sleep(500); + + for (let i = 0; i < 5; i++) { + await sleep(500); + console.info("driver is " + JSON.stringify(driver)); + let button = await driver.findComponent(uitest.ON.text('允许')); + if (button != undefined) { + console.info("button is " + JSON.stringify(button)); + await button.click(); + } + } + console.info("getPermission end"); + } catch (error) { + console.info(`getPermission failed, error: ${error}`); + } + sleep(3000); + }); + + afterAll(async function () { + contact.queryContacts(globalThis.context, (err, data) => { + if (err) { + console.info("afterAll queryContacts err = " + JSON.stringify(err)); + expect(false).assertTrue(); + return; + } + console.info("afterAll queryContacts data = " + JSON.stringify(data)); + if (data.length == 0) { + return; + } + for (var i = 0;i < data.length; i++) { + let promise = contact.deleteContact(globalThis.context, data[i].key); + promise.then(() => { + console.info("afterAll deleteContact success"); + }).catch((err) => { + console.info("afterAll deleteContact err = " + JSON.stringify(err)); + }); + } + sleep(3000); + }); + }); + + var contactData = { + id: 0, + key: "0", + contactAttributes: { + attributes: [contact.Attribute.ATTR_CONTACT_EVENT, contact.Attribute.ATTR_EMAIL, + contact.Attribute.ATTR_GROUP_MEMBERSHIP, + contact.Attribute.ATTR_IM, contact.Attribute.ATTR_NAME, contact.Attribute.ATTR_NICKNAME, + contact.Attribute.ATTR_NOTE, contact.Attribute.ATTR_ORGANIZATION, contact.Attribute.ATTR_PHONE, + contact.Attribute.ATTR_PORTRAIT, contact.Attribute.ATTR_POSTAL_ADDRESS, + contact.Attribute.ATTR_RELATION, + contact.Attribute.ATTR_SIP_ADDRESS, contact.Attribute.ATTR_WEBSITE] + }, + emails: [{ + email: "13800000000@email.com", labelName: "自定义邮箱", labelId: 1, displayName: "emailDisplayName" + }], + events: [{ + eventDate: "event", labelName: "自定义event", labelId: 2 + }], + groups: [{ + groupId: 1, title: "群组" + }], + imAddresses: [{ + imAddress: "imAddress", labelName: "自定义", labelId: 3 + }], + phoneNumbers: [{ + phoneNumber: "13800000000", labelName: "自定义phoneNumbers", labelId: 4 + }], + portrait: { + uri: "content://head/0" + }, + postalAddresses: [{ + city: "南京", + country: "中国", + labelName: "labelName", + neighborhood: "neighborhood", + pobox: "pobox", + postalAddress: "postalAddress", + postcode: "postcode", + region: "region", + street: "street", + labelId: 5 + }], + relations: [{ + relationName: "relationName", labelName: "自定义relationName", labelId: 6 + }], + sipAddresses: [{ + sipAddress: "sipAddress", labelName: "自定义sipAddress", labelId: 6 + }], + websites: [{ + website: "website" + }], + name: { + familyName: "familyName", + familyNamePhonetic: "familyNamePhonetic", + fullName: "小李", + givenName: "givenName", + givenNamePhonetic: "givenNamePhonetic", + middleName: "middleName", + middleNamePhonetic: "middleNamePhonetic", + namePrefix: "namePrefix", + nameSuffix: "nameSuffix" + }, + nickName: { + nickName: "nickName" + }, + note: { + noteContent: "note" + }, + organization: { + name: "TT", title: "开发" + } + }; + + var holder = { + holderId: 1, + bundleName: "com.ohos.contacts", + displayName: "phone" + }; + var attr = { + attributes: [contact.Attribute.ATTR_CONTACT_EVENT, contact.Attribute.ATTR_EMAIL, + contact.Attribute.ATTR_GROUP_MEMBERSHIP, + contact.Attribute.ATTR_IM, contact.Attribute.ATTR_NAME, contact.Attribute.ATTR_NICKNAME, + contact.Attribute.ATTR_NOTE, contact.Attribute.ATTR_ORGANIZATION, contact.Attribute.ATTR_PHONE, + contact.Attribute.ATTR_PORTRAIT, contact.Attribute.ATTR_POSTAL_ADDRESS, + contact.Attribute.ATTR_RELATION, + contact.Attribute.ATTR_SIP_ADDRESS, contact.Attribute.ATTR_WEBSITE] + }; + + /** + * @tc.number SUB_Telephony_ContactsApi_query_key_test_0100 + * @tc.name Query key information + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_query_key_test_0100", 0, async function (done) { + var rawContactId = await contact.addContact(globalThis.context, contactData); + expect(rawContactId > 0).assertTrue(); + var holder = { + bundleName: "com.ohos.contacts", displayName: "phone", holderId: 1 + } + try { + var resultSet = await contact.queryKey(globalThis.context, rawContactId, holder); + console.info("SUB_Telephony_ContactsApi_query_key_test_0100 : query resultSet = " + JSON.stringify(resultSet)); + expect(JSON.stringify(resultSet) === null).assertFalse(); + done(); + } catch (error) { + console.info("SUB_Telephony_ContactsApi_query_key_test_0100 query error = " + error); + done(); + } + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_query_key_test_0200 + * @tc.name Query key information + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_query_key_test_0200", 0, async function (done) { + var rawContactId = await contact.addContact(globalThis.context, contactData); + expect(rawContactId > 0).assertTrue(); + console.info("SUB_Telephony_ContactsApi_query_key_test_0200 : query gRawContactId = " + rawContactId); + try { + var resultSet = await contact.queryKey(globalThis.context, rawContactId); + console.info("SUB_Telephony_ContactsApi_query_key_test_0200 : query resultSet = " + JSON.stringify(resultSet)); + expect(JSON.stringify(resultSet) === null).assertFalse(); + done(); + } catch (error) { + console.info("SUB_Telephony_ContactsApi_query_key_test_0200 query error = " + error); + done(); + } + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_insert_test_0100 + * @tc.name contactsApi_insert error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_insert_test_0100", 0, async function (done) { + var contactDataError = {}; + try { + var rawContactId = await contact.addContact(globalThis.context, contactDataError); + console.info("SUB_Telephony_ContactsApi_insert_test_0100 : rawContactId = " + rawContactId); + expect(rawContactId == -1).assertTrue(); + done(); + } catch (error) { + console.info("SUB_Telephony_ContactsApi_insert_test_0100 : raw_contact insert error = " + error); + done(); + } + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_query_contact_test_0300 + * @tc.name contactsApi_query_contact error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_query_contact_test_0300", 0, async function (done) { + var queryId = "-1"; + try { + var resultSet = await contact.queryContact(globalThis.context, queryId); + if (resultSet == null) { + console.info("SUB_Telephony_ContactsApi_query_contact_test_0300 is null"); + } + if (resultSet == undefined) { + console.info("SUB_Telephony_ContactsApi_query_contact_test_0300 is undefined"); + } + console.info("SUB_Telephony_ContactsApi_query_contact_test_0300 : updateCode = " + JSON.stringify(resultSet)); + expect(resultSet == undefined).assertTrue(); + done(); + } catch (error) { + console.info("SUB_Telephony_ContactsApi_query_contact_test_0300 query error = " + error); + done(); + } + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_query_email_test_0400 + * @tc.name contactsApi_query_email error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_query_email_test_0400", 0, async function (done) { + var email = "email2222"; + try { + var resultSet = await contact.queryContactsByEmail(globalThis.context, email); + console.info("SUB_Telephony_ContactsApi_query_email_test_0400 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet.length == 0).assertTrue(); + done(); + } catch (error) { + console.info("SUB_Telephony_ContactsApi_query_email_test_0400 query error = " + error); + done(); + } + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_query_phoneNumber_test_0500 + * @tc.name contactsApi_query_phoneNumber error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_query_phoneNumber_test_0500", 0, async function (done) { + var phoneNumber = "19999999"; + try { + var resultSet = await contact.queryContactsByPhoneNumber(globalThis.context, phoneNumber); + console.info( + "SUB_Telephony_ContactsApi_query_phoneNumber_test_0500 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet.length == 0).assertTrue(); + done(); + } catch (error) { + console.info("SUB_Telephony_ContactsApi_query_phoneNumber_test_0500 query error = " + error); + done(); + } + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_query_key_test_0600 + * @tc.name contactsApi_query_key error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_query_key_test_0600", 0, async function (done) { + var idTest = -1; + try { + var resultSet = await contact.queryKey(globalThis.context, idTest); + console.info("SUB_Telephony_ContactsApi_query_key_test_0600 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet.length == 0).assertTrue(); + done(); + } catch (error) { + console.info("SUB_Telephony_ContactsApi_query_key_test_0600 query error = " + error); + done(); + } + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_addContact_test_0100 + * @tc.name contactsApi_query_key error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_addContact_test_0100", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_addContact_test_0100 addContact err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_addContact_test_0100 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryKey(globalThis.context, data, (err, keyData) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_addContact_test_0100 queryKey err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_addContact_test_0100 keyData = " + JSON.stringify(keyData)); + contact.deleteContact(globalThis.context, keyData, (keyData) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_addContact_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.log('deleteContact success ' + JSON.stringify(keyData)); + done(); + }); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_addContact_test_0200 + * @tc.name contactsApi_query_key error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_addContact_test_0200", 0, async function (done) { + let promise = contact.addContact(globalThis.context, contactData); + promise.then((data) => { + console.info("SUB_Telephony_ContactsApi_addContact_test_0200 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryKey(globalThis.context, data, (err, keyData) => { + if (err) { + console.info("v err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_addContact_test_0200 keyData = " + JSON.stringify(keyData)); + let promise = contact.deleteContact(globalThis.context, keyData); + promise.then(() => { + console.log(`deleteContact success`); + done(); + }).catch((err) => { + console.info("SUB_Telephony_ContactsApi_addContact_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + }); + }); + }).catch((err) => { + console.info("SUB_Telephony_ContactsApi_addContact_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContact_test_0100 + * @tc.name contactsApi_query_key error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContact_test_0100", 0, async function (done) { + var holder = { + bundleName: "com.ohos.contacts", displayName: "phone", holderId: 1 + } + expect(holder.bundleName === null).assertFalse(); + expect(holder.displayName === null).assertFalse(); + expect(holder.holderId != 0).assertTrue(); + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContact_test_0100 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryKey(globalThis.context, data, (err, keyData) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContact_test_0100 keyData = " + JSON.stringify(keyData)); + contact.queryContact(globalThis.context, keyData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContact_test_0100 data = " + JSON.stringify(data)); + expect(data.emails[0].email != '').assertTrue(); + done(); + }); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContact_test_0200 + * @tc.name contactsApi_query_key error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContact_test_0200", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContact_test_0200 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryKey(globalThis.context, data, (err, keyData) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContact_test_0200 keyData = " + JSON.stringify(keyData)); + contact.queryContact(globalThis.context, keyData, holder, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContact_test_0200 data = " + JSON.stringify(data)); + done(); + }); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContact_test_0300 + * @tc.name contactsApi_query_key error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContact_test_0300", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContact_test_0300 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryKey(globalThis.context, data, (err, keyData) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContact_test_0300 keyData = " + JSON.stringify(keyData)); + contact.queryContact(globalThis.context, keyData, attr, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContact_test_0300 data = " + JSON.stringify(data)); + expect(data.emails[0].email != '').assertTrue(); + done(); + }); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContact_test_0400 + * @tc.name contactsApi_query_key error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContact_test_0400", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0400 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContact_test_0400 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryKey(globalThis.context, data, (err, keyData) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0400 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContact_test_0400 keyData = " + JSON.stringify(keyData)); + contact.queryContact(globalThis.context, keyData, holder, attr, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0400 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContact_test_0400 data = " + JSON.stringify(data)); + done(); + }); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContact_test_0500 + * @tc.name contactsApi_query_key error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContact_test_0500", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0500 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContact_test_0500 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryKey(globalThis.context, data, (err, keyData) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0500 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContact_test_0500 keyData = " + JSON.stringify(keyData)); + let promise = contact.queryContact(globalThis.context, keyData, holder, attr); + promise.then((data) => { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0500 data = " + JSON.stringify(data)); + done(); + }).catch((err) => { + console.info("SUB_Telephony_ContactsApi_queryContact_test_0500 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + }); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContacts_test_0100 + * @tc.name contactsApi_query_key error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContacts_test_0100", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0100 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryContacts(globalThis.context, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0100 data = " + JSON.stringify(data)); + expect(data.length > 0).assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContacts_test_0200 + * @tc.name contactsApi_query_key error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContacts_test_0200", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0200 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryContacts(globalThis.context, holder, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0200 data = " + JSON.stringify(data)); + expect(data.length >= 0).assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContacts_test_0300 + * @tc.name contactsApi_query_key error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContacts_test_0300", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0300 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryContacts(globalThis.context, attr, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0300 data = " + JSON.stringify(data)); + expect(data.length > 0).assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContacts_test_0400 + * @tc.name contactsApi_query_key error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContacts_test_0400", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0400 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0400 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryContacts(globalThis.context, holder, attr, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0400 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0400 data = " + JSON.stringify(data)); + expect(data.length >= 0).assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContacts_test_0500 + * @tc.name contactsApi_query_key error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContacts_test_0500", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0500 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0500 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + let promise = contact.queryContacts(globalThis.context, holder, attr); + promise.then((data) => { + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0500 data = " + JSON.stringify(data)); + expect(data.length >= 0).assertTrue(); + done(); + }).catch((err) => { + console.info("SUB_Telephony_ContactsApi_queryContacts_test_0500 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0100 + * @tc.name contactsApi_query_ContactsByPhoneNumber error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0100", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0100 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryContactsByPhoneNumber(globalThis.context, '13800000000', (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0100 data = " + JSON.stringify(data)); + expect(data.length > 0).assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0200 + * @tc.name contactsApi_query_ContactsByPhoneNumber error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0200", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0200 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryContactsByPhoneNumber(globalThis.context, '13800000000', holder, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0200 data = " + JSON.stringify(data)); + expect(data.length > 0).assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0300 + * @tc.name contactsApi_query_ContactsByPhoneNumber error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0300", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0300 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryContactsByPhoneNumber(globalThis.context, '13800000000', attr, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0300 data = " + JSON.stringify(data)); + expect(data.length > 0).assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0400 + * @tc.name contactsApi_query_ContactsByPhoneNumber error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0400", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0400 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0400 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryContactsByPhoneNumber(globalThis.context, '13800000000', holder, attr, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0400 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0400 data = " + JSON.stringify(data)); + expect(data.length > 0).assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0500 + * @tc.name contactsApi_query_ContactsByPhoneNumber error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0500", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0500 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0500 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + let promise = contact.queryContactsByPhoneNumber(globalThis.context, '13800000000', holder, attr); + promise.then((data) => { + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0500 data = " + JSON.stringify(data)); + expect(data.length > 0).assertTrue(); + done(); + }).catch((err) => { + console.info("SUB_Telephony_ContactsApi_queryContactsByPhoneNumber_test_0500 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContactsByEmail_test_0100 + * @tc.name contactsApi_query_queryContactsByEmail error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0100", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0100 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryContactsByEmail(globalThis.context, '13800000000@email.com', (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("v data = " + JSON.stringify(data)); + expect(data.length > 0).assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContactsByEmail_test_0200 + * @tc.name contactsApi_query_queryContactsByEmail error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0200", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0200 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryContactsByEmail(globalThis.context, '13800000000@email.com', holder, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0200 data = " + JSON.stringify(data)); + expect(data.length > 0).assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContactsByEmail_test_0300 + * @tc.name contactsApi_query_queryContactsByEmail error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0300", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0300 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryContactsByEmail(globalThis.context, '13800000000@email.com', attr, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0300 data = " + JSON.stringify(data)); + expect(data.length > 0).assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContactsByEmail_test_0400 + * @tc.name contactsApi_query_queryContactsByEmail error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0400", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0400 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0400 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryContactsByEmail(globalThis.context, '13800000000@email.com', holder, attr, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0400 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0400 data = " + JSON.stringify(data)); + expect(data.length > 0).assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryContactsByEmail_test_0500 + * @tc.name contactsApi_query_queryContactsByEmail error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0500", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0500 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0500 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + let promise = contact.queryContactsByEmail(globalThis.context, '13800000000@email.com', holder, attr); + promise.then((data) => { + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0500 data = " + JSON.stringify(data)); + expect(data.length > 0).assertTrue(); + done(); + }).catch((err) => { + console.info("SUB_Telephony_ContactsApi_queryContactsByEmail_test_0500 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryGroups_test_0100 + * @tc.name contactsApi_query_queryGroups error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryGroups_test_0100", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryGroups_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryGroups_test_0100 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryGroups(globalThis.context, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryGroups_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryGroups_test_0100 data = " + JSON.stringify(data)); + expect(data.length >= 0).assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryGroups_test_0200 + * @tc.name contactsApi_query_queryGroups error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryGroups_test_0200", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryGroups_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryGroups_test_0200 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryGroups(globalThis.context, holder, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryGroups_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryGroups_test_0200 data = " + JSON.stringify(data)); + expect(data.length >= 0).assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryGroups_test_0300 + * @tc.name contactsApi_query_queryGroups error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryGroups_test_0300", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryGroups_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryGroups_test_0300 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + let promise = contact.queryGroups(globalThis.context, holder); + promise.then((data) => { + console.info("SUB_Telephony_ContactsApi_queryGroups_test_0300 data = " + JSON.stringify(data)); + expect(data.length >= 0).assertTrue(); + done(); + }).catch((err) => { + console.info("SUB_Telephony_ContactsApi_queryGroups_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryHolders_test_0100 + * @tc.name contactsApi_query_queryHolders error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryHolders_test_0100", 0, async function (done) { + contact.queryHolders(globalThis.context, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryHolders_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryHolders_test_0100 data = " + JSON.stringify(data)); + expect(data.length >= 0).assertTrue(); + done(); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryHolders_test_0200 + * @tc.name contactsApi_query_queryHolders error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryHolders_test_0200", 0, async function (done) { + let promise = contact.queryHolders(globalThis.context as Context); + promise.then((data) => { + console.info("SUB_Telephony_ContactsApi_queryHolders_test_0200 data = " + JSON.stringify(data)); + expect(data.length >= 0).assertTrue(); + done(); + }).catch((err) => { + console.info("SUB_Telephony_ContactsApi_queryHolders_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryKey_test_0100 + * @tc.name contactsApi_query_queryKey error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryKey_test_0100", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryKey_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryKey_test_0100 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryKey(globalThis.context, data, (err, keyData) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryKey_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryKey_test_0100 keyData = " + JSON.stringify(keyData)); + expect(keyData != '').assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryKey_test_0200 + * @tc.name contactsApi_query_queryKey error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryKey_test_0200", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryKey_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryKey_test_0200 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryKey(globalThis.context, data, holder, (err, keyData) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryKey_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryKey_test_0200 keyData = " + JSON.stringify(keyData)); + expect(keyData != '').assertTrue(); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryKey_test_0300 + * @tc.name contactsApi_query_queryKey error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryKey_test_0300", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryKey_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryKey_test_0300 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + let promise = contact.queryKey(globalThis.context, data, holder); + promise.then((keyData) => { + console.info("SUB_Telephony_ContactsApi_queryKey_test_0300 keyData = " + JSON.stringify(keyData)); + expect(keyData != '').assertTrue(); + done(); + }).catch((err) => { + console.info("SUB_Telephony_ContactsApi_queryKey_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryMyCard_test_0100 + * @tc.name contactsApi_query_queryMyCard error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryMyCard_test_0100", 0, async function (done) { + contact.queryMyCard(globalThis.context, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryMyCard_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryMyCard_test_0100 data = " + JSON.stringify(data)); + done(); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryMyCard_test_0200 + * @tc.name contactsApi_query_queryMyCard error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryMyCard_test_0200", 0, async function (done) { + contact.queryMyCard(globalThis.context, attr, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_queryMyCard_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_queryMyCard_test_0200 data = " + JSON.stringify(data)); + done(); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_queryMyCard_test_0300 + * @tc.name contactsApi_query_queryMyCard error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_queryMyCard_test_0300", 0, async function (done) { + let promise = contact.queryMyCard(globalThis.context, attr); + promise.then((data) => { + console.info("SUB_Telephony_ContactsApi_queryMyCard_test_0300 data = " + JSON.stringify(data)); + done(); + }).catch((err) => { + console.info("SUB_Telephony_ContactsApi_queryMyCard_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_updateContact_test_0100 + * @tc.name contactsApi_query_updateContact error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_updateContact_test_0100", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_updateContact_test_0100 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryKey(globalThis.context, data, (err, keyData) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_updateContact_test_0100 keyData = " + JSON.stringify(keyData)); + contact.updateContact(globalThis.context, { + id: data, + key: keyData, + emails: [{ + email: "13800000001@email.com", + labelName: "自定义邮箱", + labelId: 1, + displayName: "emailDisplayName" + }] + }, (err) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.log('updateContact success'); + contact.queryKey(globalThis.context, data, (err, newKey) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_updateContact_test_0100 newKey = " + JSON.stringify(newKey)); + contact.queryContact(globalThis.context, newKey, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_updateContact_test_0100 data = " + JSON.stringify(data)); + expect(data.emails[0].email == "13800000001@email.com").assertTrue(); + done(); + }); + }); + }); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_updateContact_test_0200 + * @tc.name contactsApi_query_updateContact error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_updateContact_test_0200", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_updateContact_test_0200 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryKey(globalThis.context, data, (err, keyData) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_updateContact_test_0200 keyData = " + JSON.stringify(keyData)); + contact.updateContact(globalThis.context, { + id: data, + key: keyData, + emails: [{ + email: "13800000001@email.com", + labelName: "自定义邮箱", + labelId: 1, + displayName: "emailDisplayName" + }] + }, attr, (err) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.log('updateContact success'); + contact.queryKey(globalThis.context, data, (err, newKey) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_updateContact_test_0200 newKey = " + JSON.stringify(newKey)); + contact.queryContact(globalThis.context, newKey, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_updateContact_test_0200 data = " + JSON.stringify(data)); + expect(data.emails[0].email == "13800000001@email.com").assertTrue(); + done(); + }); + }); + }); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_updateContact_test_0300 + * @tc.name contactsApi_query_updateContact error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_updateContact_test_0300", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_updateContact_test_0300 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.queryKey(globalThis.context, data, (err, keyData) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_updateContact_test_0300 keyData = " + JSON.stringify(keyData)); + let promise = contact.updateContact(globalThis.context, { + id: data, + key: keyData, + emails: [{ + email: "13800000001@email.com", + labelName: "自定义邮箱", + labelId: 1, + displayName: "emailDisplayName" + }] + }, attr); + promise.then(() => { + console.log('updateContact success'); + contact.queryKey(globalThis.context, data, (err, newKey) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_updateContact_test_0300 newKey = " + JSON.stringify(newKey)); + contact.queryContact(globalThis.context, newKey, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_updateContact_test_0300 data = " + JSON.stringify(data)); + expect(data.emails[0].email == "13800000001@email.com").assertTrue(); + done(); + }); + }); + }).catch((err) => { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0300 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + }); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_updateContact_test_0400 + * @tc.name contactsApi_query_updateContact error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_updateContact_test_0400", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0400 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_updateContact_test_0400 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.isLocalContact(globalThis.context, data, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_updateContact_test_0400 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_updateContact_test_0400 data = " + JSON.stringify(data)); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_isLocalContact_test_0200 + * @tc.name contactsApi_query_isLocalContact error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_isLocalContact_test_0200", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_isLocalContact_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_isLocalContact_test_0200 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + let promise = contact.isLocalContact(globalThis.context, data); + promise.then((data) => { + console.info("SUB_Telephony_ContactsApi_isLocalContact_test_0200 data = " + JSON.stringify(data)); + done(); + }).catch((err) => { + console.info("SUB_Telephony_ContactsApi_isLocalContact_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_isMyCard_test_0100 + * @tc.name contactsApi_query_isMyCard error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_isMyCard_test_0100", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_isMyCard_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_isMyCard_test_0100 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + contact.isMyCard(globalThis.context, data, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_isMyCard_test_0100 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_isMyCard_test_0100 data = " + JSON.stringify(data)); + done(); + }); + }); + sleep(500); + }); + + /** + * @tc.number SUB_Telephony_ContactsApi_isMyCard_test_0200 + * @tc.name contactsApi_query_isMyCard error + * @tc.desc Function test + */ + it("SUB_Telephony_ContactsApi_isMyCard_test_0200", 0, async function (done) { + contact.addContact(globalThis.context, contactData, (err, data) => { + if (err) { + console.info("SUB_Telephony_ContactsApi_isMyCard_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + } + console.info("SUB_Telephony_ContactsApi_isMyCard_test_0200 data = " + JSON.stringify(data)); + expect(data > 0).assertTrue(); + let promise = contact.isMyCard(globalThis.context, data); + promise.then((data) => { + console.info("SUB_Telephony_ContactsApi_isMyCard_test_0200 data = " + JSON.stringify(data)); + done(); + }).catch((err) => { + console.info("SUB_Telephony_ContactsApi_isMyCard_test_0200 err = " + JSON.stringify(err)); + expect(false).assertTrue(); + done(); + return; + }); + }); + sleep(500); + }); + }); +} \ No newline at end of file diff --git a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/module.json b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..8747757bc88f23157648218eb49a77df9a244cb7 --- /dev/null +++ b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/module.json @@ -0,0 +1,46 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "description": "$string:module_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "tablet", + "default", + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "TestAbility", + "srcEntrance": "./ets/TestAbility/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.WRITE_CONTACTS" + }, + { + "name": "ohos.permission.READ_CONTACTS" + } + ] + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/element/color.json b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..1bbc9aa9617e97c45440e1d3d66afc1154837012 --- /dev/null +++ b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..65d8fa5a7cf54aa3943dcd0214f58d1771bc1f6c --- /dev/null +++ b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/media/icon.png b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/profile/test_pages.json b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/profile/test_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..9896fb184f3db11f1ed9c3b073fa044ffc170e26 --- /dev/null +++ b/telephony/telephonyjstest/actscontactstageapitest/entry/src/main/resources/base/profile/test_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "TestAbility/pages/Index" + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/actscontactstageapitest/signature/openharmony_sx.p7b b/telephony/telephonyjstest/actscontactstageapitest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..aa986c1fbf951cfb116547cd7fe87a56c98779ee Binary files /dev/null and b/telephony/telephonyjstest/actscontactstageapitest/signature/openharmony_sx.p7b differ diff --git a/telephony/telephonyjstest/sms_mms/sms_mms_error/src/main/js/test/SmsMmsError.test.js b/telephony/telephonyjstest/sms_mms/sms_mms_error/src/main/js/test/SmsMmsError.test.js index db24e2d6d8ae65d09b7a5857d5278aa60ef766b3..845c22391a55165c9a7114b35f286c18e4a0ffe8 100644 --- a/telephony/telephonyjstest/sms_mms/sms_mms_error/src/main/js/test/SmsMmsError.test.js +++ b/telephony/telephonyjstest/sms_mms/sms_mms_error/src/main/js/test/SmsMmsError.test.js @@ -126,7 +126,6 @@ describe('SmsMmsErrorTest', function () { it('Telephony_SmsMms_sendMessage_Promise_0100', 0, async function (done) { try { let sendCallback = function (err, data) { - expect(data.isLastPart).assertEqual(false); console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); } let deliveryCallback = function (err, data) { @@ -162,7 +161,6 @@ describe('SmsMmsErrorTest', function () { it('Telephony_SmsMms_sendShortMessage_Promise_0100', 0, async function (done) { try { let sendCallback = function (err, data) { - expect(data.isLastPart).assertEqual(false); console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); } let deliveryCallback = function (err, data) { @@ -204,7 +202,6 @@ describe('SmsMmsErrorTest', function () { it('Telephony_SmsMms_sendShortMessage_Async_0100', 0, async function (done) { try { let sendCallback = function (err, data) { - expect(data.isLastPart).assertEqual(false); console.log(`sendCallback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); } let deliveryCallback = function (err, data) {