diff --git a/aafwk/aafwk_standard/ActsDataAbilityJsTest/BUILD.gn b/aafwk/aafwk_standard/ActsDataAbilityJsTest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..4a46b4f8901b6f46467910b6525bfad6ab8b4baa --- /dev/null +++ b/aafwk/aafwk_standard/ActsDataAbilityJsTest/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2021 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("ActsDataAbilityJsTest") { + hap_name = "ActsDataAbilityJsTest" + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/ActsDataAbilityJsTest/Test.json b/aafwk/aafwk_standard/ActsDataAbilityJsTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..509e844d9c101a5f83a4ee3a1aed3a719a56419d --- /dev/null +++ b/aafwk/aafwk_standard/ActsDataAbilityJsTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjsunit Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "100000", + "package": "com.example.actsdataabilityjstest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsDataAbilityJsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/config.json b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..25305ed8b2d0feff47d9bbae6994283b3964eade --- /dev/null +++ b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/config.json @@ -0,0 +1,107 @@ +{ + "app": { + "bundleName": "com.example.actsdataabilityjstest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsdataabilityjstest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsdataabilityjstest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "singleton", + "visible": true + } + ], + "reqPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.CLEAN_APPLICATION_DATA", + "reason":"need use ohos.permission.CLEAN_APPLICATION_DATA" + }, + { + "name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/app.js b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..042038cfc6360ed972035a85e944904021ffb1d6 --- /dev/null +++ b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/app.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 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. + */ +export default { + onCreate() { + console.info('ActsProcessManageJsTest onCreate'); + }, + onDestroy() { + console.info('ActsProcessManageJsTest onDestroy'); + }, + onShow() { + console.info('ActsProcessManageJsTest onShow'); + }, + onHide() { + console.info('ActsProcessManageJsTest onHide'); + } +}; diff --git a/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/i18n/en-US.json b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/i18n/zh-CN.json b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/pages/index/index.css b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..cfd4c53e39aecb2d83a0fbdec971eca4041c8a3a --- /dev/null +++ b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,14 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} + +.btn { + width: 200px; + height: 80px; +} diff --git a/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/pages/index/index.hml b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..83c5e0fcabbb1d5df26d69f4a5c2031c1e65b70a --- /dev/null +++ b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,6 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + + +
diff --git a/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..8d0e011ec04e9ffc7bf198f067f8768141aa2c9a --- /dev/null +++ b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2021 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 { Core, ExpectExtend } from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "", + testTime: 0 + }, + onInit() { + console.info('Acts_DataAbilityJSTest onInit'); + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('Acts_DataAbilityJSTest onShow'); + console.info('Acts_DataAbilityJSTest testTime' + this.testTime); + if (this.testTime == 0) { + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + const configService = core.getDefaultService('config') + this.timeout = 30000; + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + } + this.testTime++; + }, + onReady() { + console.info('Acts_DataAbilityJSTest onReady'); + }, + onActive() { + console.info('Acts_DataAbilityJSTest onActive'); + }, + onInactive() { + console.info('Acts_DataAbilityJSTest onInactive'); + }, + onHide() { + console.info('Acts_DataAbilityJSTest onHide'); + }, + onDestroy() { + console.info('Acts_DataAbilityJSTest onDestroy'); + }, + onBackPress() { + console.info('Acts_DataAbilityJSTest onBackPress'); + }, + onNewRequest() { + console.info('Acts_DataAbilityJSTest onNewRequest'); + }, + onStartContinuation() { + console.info('Acts_DataAbilityJSTest onStartContinuation'); + }, + onSaveData(value) { + console.info('Acts_DataAbilityJSTest onSaveData:' + JSON.stringify(value)); + }, + onRestoreData(value) { + console.info('Acts_DataAbilityJSTest onRestoreData:' + JSON.stringify(value)); + }, + onCompleteContinuation(code) { + console.info('Acts_DataAbilityJSTest onCompleteContinuation:' + JSON.stringify(code)); + }, + onConfigurationUpdated(configuration) { + console.info('Acts_DataAbilityJSTest onConfigurationUpdated:' + JSON.stringify(configuration)); + } +} diff --git a/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/resources/base/element/string.json b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03574a36c533357eef7fc0acc5e21af14f4e5f67 --- /dev/null +++ b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "actsparticleabilitytest" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/resources/base/media/icon.png b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/test/ActsDataAbilityJsTest.test.js b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/test/ActsDataAbilityJsTest.test.js new file mode 100644 index 0000000000000000000000000000000000000000..29f1944296fffe47b945f07dc69afe36ff879dcc --- /dev/null +++ b/aafwk/aafwk_standard/ActsDataAbilityJsTest/entry/src/main/js/test/ActsDataAbilityJsTest.test.js @@ -0,0 +1,705 @@ +/* + * Copyright (C) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import featureAbility from '@ohos.ability.featureAbility' +import ohosDataAbility from '@ohos.data.dataability' + +describe('ActsDataAbilityJsTest', function () { +let dataAbilityUri = ("dataability:///com.example.myapplication.DataAbility"); +let DAHelper; +let gSetTimeout = 500; +var valueBucket = { + "name": "ActsDataAbilityHelperTest", + "age": 24, + "salary": 2024.20, +} + +beforeAll(async (done) => { + console.debug('= ACTS_beforeAll 1425 ====: ' + DAHelper + " ,JSON. " + JSON.stringify(DAHelper)); + if(DAHelper == null){ + console.debug('ACTS_beforeAll DAHelper ====>: DAHelper == null'); + } + } catch (err) { + console.error('=ACTS_beforeAll acquireDataAbilityHelper catch(err)====>:' + err); + } + console.debug('= ACTS_beforeAll ==== { + console.debug('= ACTS_beforeEach ==== { + console.debug('= ACTS_afterEach ==== { + console.debug('= ACTS_afterAll ====: ' + DAHelper) + try { + await DAHelper.insert(dataAbilityUri, valueBucket, + (err, data) => { + console.debug("=ACTS_Insert_0400 err,data=======>" + + ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;")); + expect(data).assertEqual(1); + console.log('ACTS_Insert_0400====:' + err); + console.log('ACTS_Insert_0400====: ' + DAHelper) + var valueBucketArray = new Array({ "name": "ActsDataAbilityHelperTest", "age": 24, "salary": 2024.20, }, + { "name": "ActsDataAbilityHelperTest", "age": 24, "salary": 2024.20, }, + { "name": "ActsDataAbilityHelperTest", "age": 24, "salary": 2024.20, }) + try { + await DAHelper.batchInsert( + dataAbilityUri, + valueBucketArray, + (err, data) => { + console.debug("=ACTS_BatchInsert_0600 err,data=======>" + + ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;")); + expect(data).assertEqual(3); + console.log('ACTS_BatchInsert_0600====:' + err); + console.log('ACTS_BatchInsert_0600==== { + console.debug("=ACTS_Query_0400 query err,data=======>" + + ("json err【") + JSON.stringify(err) + (" 】json data【") + + JSON.stringify(data) + (" 】;") + " , " + data); + expect(typeof (data)).assertEqual("object"); + console.log('ACTS_Query_0400====:' + err); + console.log('ACTS_Query_0400====: ' + DAHelper) + try { + let predicates = new ohosDataAbility.DataAbilityPredicates(); + predicates.equalTo('contact_id', 1); + predicates.limitAs(10); + predicates.orderByAsc("order_by_class"); + predicates.offsetAs(1); + console.debug("=ACTS_Update_0400 predicates====>" + + ("json predicates 【") + JSON.stringify(predicates) + (" 】") + " , " + predicates); + await DAHelper.update( + dataAbilityUri, + valueBucket, + predicates, + (err, data) => { + console.debug("=ACTS_Update_0400 err,data=======>" + + ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;")); + expect(data).assertEqual(1); + console.log('ACTS_Update_0400====:' + err); + console.log('ACTS_Update_0400====: ' + DAHelper) + try { + let predicates = new ohosDataAbility.DataAbilityPredicates(); + predicates.equalTo('contact_id', 1); + predicates.limitAs(10); + predicates.orderByAsc("order_by_class"); + predicates.offsetAs(1); + console.debug("=ACTS_Delete_0400 predicates====>" + + ("json predicates 【") + JSON.stringify(predicates) + (" 】") + " , " + predicates); + await DAHelper.delete( + dataAbilityUri, + predicates, + (err, data) => { + console.debug("=ACTS_Delete_0400 err,data=======>" + + ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;")); + expect(data).assertEqual(0); + console.log('ACTS_Delete_0400====:' + err); + console.log('ACTS_Delete_0400====: ' + DAHelper) + let mimeTypeFilter = '*/*' + try { + await DAHelper.getFileTypes( + dataAbilityUri, + mimeTypeFilter, + (err, data) => { + console.debug("=ACTS_GetFileTypes_0200 getFileTypes err,data=======>" + + ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;")); + console.log('=ACTS_GetFileTypes_0200 data.length ====>: ' + data.length); + for (var i = 0; i < data.length; i++) { + expect(typeof (data[i])).assertEqual("string"); + console.log('=ACTS_GetFileTypes_0200 for data ====>: ' + err.code + + " data[" + i + "]: " + data[i]); + if (i == 0) { + expect(data[i]).assertEqual("hap"); + } else if (i == 1) { + expect(data[i]).assertEqual("jpg"); + } else if (i == 2) { + expect(data[i]).assertEqual("image/png"); + } + } + console.log('ACTS_GetFileTypes_0200====:' + err); + console.log('ACTS_GetFileTypes_0200====: ' + DAHelper) + try { + await DAHelper.getType( + dataAbilityUri, + (err, data) => { + console.debug("=ACTS_GetType_0200 err,data=======>" + + ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;")); + expect(data).assertEqual(dataAbilityUri); + console.log('ACTS_GetType_0200====:' + err); + console.log('ACTS_GetType_0200====: ' + DAHelper) + var mode = "r"; + try { + DAHelper.openFile( + dataAbilityUri, + mode, + (err, data) => { + console.debug("=ACTS_OpenFile_0700 err,data=======>" + + ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;")); + expect(typeof (data)).assertEqual("number"); + console.log('DataAbilityHelper ACTS_OpenFile_0700 OpenFile asyncCallback errCode ====>: ' + + err.code + " data: " + data); + ret = true + done(); + }, + ); + } catch (err) { + console.error('=ACTS_OpenFile_0700 getType AsyncCallback catch(err)====>:' + err); + ret = false + done(); + } + setTimeout(function () { + console.log('setTimeout function====<'); + }, gSetTimeout); + console.log('ACTS_OpenFile_0700====: ' + DAHelper) + try { + DAHelper.normalizeUri( + dataAbilityUri, + (err, data) => { + console.debug("=ACTS_NormalizeUri_0200 err,data=======>" + + ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;")); + expect(data).assertEqual(dataAbilityUri); + console.log('ACTS_NormalizeUri_0200====:' + err); + console.log('ACTS_NormalizeUri_0200====: ' + DAHelper) + try { + DAHelper.denormalizeUri( + dataAbilityUri, + (err, data) => { + console.debug("=ACTS_DenormalizeUri_0200 err,data=======>" + + ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;")); + expect(data).assertEqual(dataAbilityUri); + console.log('ACTS_DenormalizeUri_0200====:' + err); + console.log('ACTS_DenormalizeUri_0200==== { + console.debug("=ACTS_OnOff_0100 err=======>" + + ("err【") + JSON.stringify(err) + (" 】") + " , " + err); + expect(err.code).assertEqual(0); + } + ); + } + } catch (err) { + console.error('=ACTS_OnOff_0100 catch(err)====>:' + err); + console.log('ACTS_OnOff_0100===="); + expect(false).assertTrue(); + clearTimeout(currentAlertTimeout); + console.log('ACTS_OnOff_0200==== { + if (err.code != 0) { + console.debug("=ACTS_OnOff_0200 err=======>" + + ("err【") + JSON.stringify(err) + (" 】") + " , " + err); + expect(false).assertTrue(); + console.log('ACTS_OnOff_0200==== { + expect(err.code).assertEqual(0); + console.log('ACTS_OnOff_0200====:' + err); + console.log('ACTS_OnOff_0200==== { + console.debug("=ACTS_ExecuteBatch_Insert_0400 executeBatch err,data====>" + + ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + + (" 】;") + data.length); + expect(err.code).assertEqual(0); + expect(data.length).assertEqual(0); + console.debug('ACTS_ExecuteBatch_Insert_0400====:' + + ("json err 【") + JSON.stringify(err) + (" 】 ,") + err); + console.debug('ACTS_ExecuteBatch_Insert_0400==== { + console.debug("=ACTS_ExecuteBatch_Update_0400 executeBatch err,data====>" + + ("json err【") + JSON.stringify(err) + (" 】json data【") + + JSON.stringify(DataAbilityResult) + (" 】;") + DataAbilityResult.length); + for (var i = 0; i < DataAbilityResult.length; i++) { + console.debug('=ACTS_ExecuteBatch_Update_0400 for data[' + i + '].uri ====>: ' + + DataAbilityResult[i].uri) + expect(DataAbilityResult[i].uri).assertEqual(dataAbilityUri); + console.debug('=ACTS_ExecuteBatch_Update_0400 for data[' + i + '].count ====>: ' + + DataAbilityResult[i].count) + expect(DataAbilityResult[i].count).assertEqual(1); + } + console.debug('ACTS_ExecuteBatch_Update_0400====:' + + ("json err 【") + JSON.stringify(err) + (" 】 ,") + err); + console.debug('ACTS_ExecuteBatch_Update_0400==== { + console.debug("=ACTS_ExecuteBatch_Assert_0400 executeBatch err,data====>" + + ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + + (" 】;") + data.length); + expect(data.length).assertEqual(0); + console.debug('ACTS_ExecuteBatch_Assert_0400====:' + + ("json err 【") + JSON.stringify(err) + (" 】 ,") + err); + console.debug('ACTS_ExecuteBatch_Assert_0400==== { + console.debug("=ACTS_ExecuteBatch_Delete_0400 executeBatch err,data====>" + + ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(DataAbilityResult) + + (" 】;") + DataAbilityResult.length); + for (var i = 0; i < DataAbilityResult.length; i++) { + console.debug('=ACTS_ExecuteBatch_Delete_0400 for data[' + i + '].uri ====>: ' + + DataAbilityResult[i].uri) + expect(DataAbilityResult[i].uri).assertEqual(dataAbilityUri); + console.debug('=ACTS_ExecuteBatch_Delete_0400 for data[' + i + '].count ====>: ' + + DataAbilityResult[i].count) + expect(DataAbilityResult[i].count).assertEqual(1); + } + console.debug('ACTS_ExecuteBatch_Delete_0400====:' + + ("json err 【") + JSON.stringify(err) + (" 】 ,") + err); + console.debug('ACTS_ExecuteBatch_Delete_0400====: ' + rDAHelper + " ,JSON. " + JSON.stringify(rDAHelper)); + expect(typeof (rDAHelper)).assertEqual("object"); + rDAHelper.release().then((data) => { + console.debug("=ACTS_Release_0100 then data====>" + + ("json data 【") + JSON.stringify(data) + (" 】") + " , " + data); + expect(data).assertEqual(true); + console.log('ACTS_Release_0100==== { + console.debug("=ACTS_Release_0100 catch err ====>" + + ("json err 【") + JSON.stringify(err) + (" 】 ")); + expect(false).assertTrue(); + console.log('ACTS_Release_0100====:' + err); + console.log('ACTS_Release_0100====/data/ActsKillProcessWithAccountCloseApi7.hap" + ] + + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/*.hap" + ] + } + ] +} diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/config.json b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..a2d8038c261520e08d1db88a7693018e3b7db168 --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/config.json @@ -0,0 +1,107 @@ +{ + "app": { + "bundleName": "com.example.myapplication.actsapi7killtest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.myapplication.actsapi7killtest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.myapplication.actsapi7killtest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "singleton", + "visible": true + } + ], + "reqPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.CLEAN_APPLICATION_DATA", + "reason":"need use ohos.permission.CLEAN_APPLICATION_DATA" + }, + { + "name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/app.js b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..042038cfc6360ed972035a85e944904021ffb1d6 --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/app.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 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. + */ +export default { + onCreate() { + console.info('ActsProcessManageJsTest onCreate'); + }, + onDestroy() { + console.info('ActsProcessManageJsTest onDestroy'); + }, + onShow() { + console.info('ActsProcessManageJsTest onShow'); + }, + onHide() { + console.info('ActsProcessManageJsTest onHide'); + } +}; diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/i18n/en-US.json b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/i18n/zh-CN.json b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/pages/index/index.css b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..cfd4c53e39aecb2d83a0fbdec971eca4041c8a3a --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,14 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} + +.btn { + width: 200px; + height: 80px; +} diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/pages/index/index.hml b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..83c5e0fcabbb1d5df26d69f4a5c2031c1e65b70a --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,6 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + + +
diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ee3a7077b7d52935d3f70b5cb70e38ea9d0e33f1 --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2021 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 { Core, ExpectExtend } from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "", + testTime: 0 + }, + onInit() { + console.info('ActsProcessManageJsTest onInit'); + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('ActsProcessManageJsTest onShow'); + console.info('ActsProcessManageJsTest testTime' + this.testTime); + if (this.testTime == 0) { + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + const configService = core.getDefaultService('config') + this.timeout = 30000; + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + } + this.testTime++; + }, + onReady() { + console.info('ActsProcessManageJsTest onReady'); + }, + onActive() { + console.info('ActsProcessManageJsTest onActive'); + }, + onInactive() { + console.info('ActsProcessManageJsTest onInactive'); + }, + onHide() { + console.info('ActsProcessManageJsTest onHide'); + }, + onDestroy() { + console.info('ActsProcessManageJsTest onDestroy'); + }, + onBackPress() { + console.info('ActsProcessManageJsTest onBackPress'); + }, + onNewRequest() { + console.info('ActsProcessManageJsTest onNewRequest'); + }, + onStartContinuation() { + console.info('ActsProcessManageJsTest onStartContinuation'); + }, + onSaveData(value) { + console.info('ActsProcessManageJsTest onSaveData:' + JSON.stringify(value)); + }, + onRestoreData(value) { + console.info('ActsProcessManageJsTest onRestoreData:' + JSON.stringify(value)); + }, + onCompleteContinuation(code) { + console.info('ActsProcessManageJsTest onCompleteContinuation:' + JSON.stringify(code)); + }, + onConfigurationUpdated(configuration) { + console.info('ActsProcessManageJsTest onConfigurationUpdated:' + JSON.stringify(configuration)); + } +} diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/resources/base/element/string.json b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03574a36c533357eef7fc0acc5e21af14f4e5f67 --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "actsparticleabilitytest" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/resources/base/media/icon.png b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/test/ActsKillProcessTest.test.js b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/test/ActsKillProcessTest.test.js new file mode 100644 index 0000000000000000000000000000000000000000..c6fe236bdd1df7c72241b09661e067bb0f9f1b0b --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/test/ActsKillProcessTest.test.js @@ -0,0 +1,287 @@ +/* + * Copyright (C) 2021 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index" +import appManager from '@ohos.application.AppManager'; +import featureAbility from '@ohos.ability.featureAbility' + +const ACCOUNT_ID = 100; +const NULL_ACCOUNT_ID = 102; +const BUNDLE_NAME = 'com.example.actskillprocesswithaccountcloseapi7'; +const NULL_BUNDLE_NAME = 'com.aaa.bbb'; +const START_ABILITY_NAME = 'com.example.actskillprocesswithaccountcloseapi7.MainAbility'; + +describe('ActskillProcessWithaccountTest', function () { + + beforeEach(async (done) => { + console.log('======>beforeEach killProcessWithAccountFATest<======='); + + await featureAbility.startAbility({ + want: + { + bundleName: BUNDLE_NAME, + abilityName: START_ABILITY_NAME + } + }).then(async () => { + console.log("====>end ACTS_KillProcessWithAccountFA startability ====>success!") + done(); + }) + }) + + function sleep(time) { + let delta; + if (typeof time != 'number' || time <= 0) { + delta = 100; + } else { + delta = Math.round(time); + } + for (let start = Date.now(); Date.now() - start <= delta;); + } + + function checkRunningProcess(name, dataInfo) { + for (let i = 0, len = dataInfo.length; i < len; i++) { + if (dataInfo[i].processName == name) { + return true; + } + } + return false; + } + + /** + * @tc.number: ACTS_KillProcessWithAccountFA_0100 + * @tc.name: Provide the system interface of the specified user management application. + * @tc.desc: Validates the ability to stop the specified process for the specified user. + */ + it('ACTS_KillProcessWithAccountFA_0100', 0, async function (done) { + console.debug("====>ACTS_KillProcessWithAccountFA_0100 start startAbility====>"); + + var procrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0100 ==1== getProcessRunningInfos ======> ' + + JSON.stringify(procrssinfo)); + var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0100====>infores = " + infores) + expect(infores).assertEqual(true); + + await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => { + console.log('ACTS_KillProcessWithAccountFA_0100 killProcess ======> start'); + }) + + setTimeout(async () => { + var copyprocrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0100 getProcessRunningInfos ======> ' + + JSON.stringify(copyprocrssinfo)); + var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0100====>outcopy = " + outcopy) + expect(outcopy).assertEqual(false); + done(); + }, 3000) + }) + + /** + * @tc.number: ACTS_KillProcessWithAccountFA_0300 + * @tc.name: Provide the system interface of the specified user management application. + * @tc.desc: Authentication cannot stop the specified process for the specified user. + */ + it('ACTS_KillProcessWithAccountFA_0300', 0, async function (done) { + console.debug("====>ACTS_KillProcessWithAccountFA_0300 start startAbility====>"); + + var getinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0300 getProcessRunningInfos =1= ======> ' + + JSON.stringify(getinfo)); + var res = checkRunningProcess(BUNDLE_NAME, getinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0300====>res = " + res) + expect(res).assertEqual(true); + + appManager.killProcessWithAccount(NULL_BUNDLE_NAME, ACCOUNT_ID).then(() => { + console.log('ACTS_KillProcessWithAccountFA_0300 ======> '); + }) + + setTimeout(async () => { + var procrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0300 ==1== getProcessRunningInfos ======> ' + + JSON.stringify(procrssinfo)); + var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0300====>infores = " + infores) + expect(infores).assertEqual(true); + + await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => { + console.log('ACTS_KillProcessWithAccountFA_0300 killProcess ======> start'); + sleep(500) + var copyprocrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0300 getProcessRunningInfos ======> ' + + JSON.stringify(copyprocrssinfo)); + var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0300====> outcopy = " + outcopy) + expect(outcopy).assertEqual(false); + done(); + }) + }, 1500) + }) + + /** + * @tc.number: ACTS_KillProcessWithAccountFA_0400 + * @tc.name: Provide the system interface of the specified user management application. + * @tc.desc: Authentication cannot stop the specified process for the specified user. + */ + it('ACTS_KillProcessWithAccountFA_0400', 0, async function (done) { + console.debug("====>ACTS_KillProcessWithAccountFA_0400 start startAbility====>"); + + var getinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0400 getProcessRunningInfos =1= ======> ' + + JSON.stringify(getinfo)); + var res = checkRunningProcess(BUNDLE_NAME, getinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0400====>res = " + res) + expect(res).assertEqual(true); + + appManager.killProcessWithAccount(BUNDLE_NAME, NULL_ACCOUNT_ID).then(() => { + console.log('ACTS_KillProcessWithAccountFA_0400 killProcess ======> start'); + }) + + setTimeout(async () => { + var procrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0400 ==1== getProcessRunningInfos ======> ' + + JSON.stringify(procrssinfo)); + var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0400====>infores = " + infores) + expect(infores).assertEqual(true); + + appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => { + console.log('ACTS_KillProcessWithAccountFA_0400 killProcess2 ======> start'); + + sleep(500) + var copyprocrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0400 ==2== getProcessRunningInfos ======>' + + JSON.stringify(copyprocrssinfo)); + var out = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0400====>infores = " + out) + expect(out).assertEqual(false); + done(); + }) + }, 1500) + }) + + /** + * @tc.number: ACTS_KillProcessWithAccountFA_0500 + * @tc.name: Provide the system interface of the specified user management application. + * @tc.desc: Validates the ability to stop the specified process for the specified user. + */ + it('ACTS_KillProcessWithAccountFA_0500', 0, async function (done) { + console.debug("====>ACTS_KillProcessWithAccountFA_0500 start startAbility====>"); + + var procrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0500 ==1== getProcessRunningInfos ======> ' + + JSON.stringify(procrssinfo)); + var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0500====>infores = " + infores) + expect(infores).assertEqual(true); + + await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID, (async () => { + console.log('ACTS_KillProcessWithAccountFA_0500 killProcess ======> start'); + })) + + setTimeout(async () => { + var copyprocrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0500 getProcessRunningInfos ======> ' + + JSON.stringify(copyprocrssinfo)); + var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0500====>outcopy = " + outcopy) + expect(outcopy).assertEqual(false); + done(); + }, 3000) + }) + + /** + * @tc.number: ACTS_KillProcessWithAccountFA_0700 + * @tc.name: Provide the system interface of the specified user management application. + * @tc.desc: Authentication cannot stop the specified process for the specified user. + */ + it('ACTS_KillProcessWithAccountFA_0700', 0, async function (done) { + console.debug("====>ACTS_KillProcessWithAccountFA_0700 start startAbility====>"); + + var getinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0700 getProcessRunningInfos =1= ======> ' + + JSON.stringify(getinfo)); + var res = checkRunningProcess(BUNDLE_NAME, getinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0700====>res = " + res) + expect(res).assertEqual(true); + + appManager.killProcessWithAccount(NULL_BUNDLE_NAME, ACCOUNT_ID, (() => { + console.log('ACTS_KillProcessWithAccountFA_0700 killProcess ======> start'); + })) + + setTimeout(async () => { + var procrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0700 ==1== getProcessRunningInfos ======> ' + + JSON.stringify(procrssinfo)); + var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0700====>infores = " + infores) + expect(infores).assertEqual(true); + + await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => { + console.log('ACTS_KillProcessWithAccountFA_0700 killProcess ======> start'); + sleep(500) + var copyprocrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0700 getProcessRunningInfos ======> ' + + JSON.stringify(copyprocrssinfo)); + var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0700====> outcopy = " + outcopy) + expect(outcopy).assertEqual(false); + done(); + }) + }, 1500) + }) + + /** + * @tc.number: ACTS_KillProcessWithAccountFA_0800 + * @tc.name: Provide the system interface of the specified user management application. + * @tc.desc: Authentication cannot stop the specified process for the specified user. + */ + it('ACTS_KillProcessWithAccountFA_0800', 0, async function (done) { + console.debug("====>ACTS_KillProcessWithAccountFA_0800 start startAbility====>"); + + var getinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0800 getProcessRunningInfos =1= ======> ' + + JSON.stringify(getinfo)); + var res = checkRunningProcess(BUNDLE_NAME, getinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0800====>res = " + res) + expect(res).assertEqual(true); + + appManager.killProcessWithAccount(BUNDLE_NAME, NULL_ACCOUNT_ID, (() => { + console.log('ACTS_KillProcessWithAccountFA_0800 killProcess ======> start'); + })) + + setTimeout(async () => { + var procrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0800 ==1== getProcessRunningInfos ======> ' + + JSON.stringify(procrssinfo)); + var infores = checkRunningProcess(BUNDLE_NAME, procrssinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0800====>infores = " + infores) + expect(infores).assertEqual(true); + + await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async () => { + console.log('ACTS_KillProcessWithAccountFA_0800 killProcess ======> start'); + sleep(500) + var copyprocrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccountFA_0800 getProcessRunningInfos ======> ' + + JSON.stringify(copyprocrssinfo)); + var outcopy = checkRunningProcess(BUNDLE_NAME, copyprocrssinfo) + console.log("====>ACTS_KillProcessWithAccountFA_0800====> outcopy = " + outcopy) + expect(outcopy).assertEqual(false); + done(); + }) + }, 1500) + }) + +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/test/List.test.js b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..e07d3ce04e33968af6dc4a1e43012c664618308e --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2021 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. + */ +require('./ActsKillProcessTest.test.js') \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountApi7Test/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/BUILD.gn b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..63bd5aebe3359e79a8a82d27415b60668fc09d4f --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (C) 2021 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_hap("ActsKillProcessWithAccountCloseApi7") { + hap_name = "ActsKillProcessWithAccountCloseApi7" + hap_profile = "./src/main/config.json" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/js/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/config.json b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..855f8170cc9d1c19fe29832e72c43452e47a0969 --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/config.json @@ -0,0 +1,99 @@ +{ + "app": { + "bundleName": "com.example.actskillprocesswithaccountcloseapi7", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actskillprocesswithaccountcloseapi7", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actskillprocesswithaccountcloseapi7.MainAbility", + "visible": true, + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "reqPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/app.js b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..5d3012c7d6777f4b04710913de6f1aa718fa8cc9 --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/app.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 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. + */ +export default { + onCreate() { + console.info('ProcessManageSystemAppB onCreate'); + }, + onDestroy() { + console.info('ProcessManageSystemAppB onDestroy'); + }, + onShow() { + console.info('ProcessManageSystemAppB onShow'); + }, + onHide() { + console.info('ProcessManageSystemAppB onHide'); + } +}; diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/i18n/en-US.json b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/i18n/zh-CN.json b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/pages/index/index.css b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/pages/index/index.hml b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e5f1d275cae20f143cdaff8756419d8c7fb99e60 --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/default/pages/index/index.js @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2021 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 commonEvent from '@ohos.commonevent' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + console.info('ACTS_ProcessManage SystemAppB onInit'); + this.title = "ACTS_ProcessManage SystemAppB"; + }, + onReady() { + console.info('ACTS_ProcessManage SystemAppB onReady'); + }, + onActive() { + console.info('ACTS_ProcessManage SystemAppB onActive'); + }, + onShow() { + console.info('ACTS_ProcessManage SystemAppB onShow'); + }, + onInactive() { + console.info('ACTS_ProcessManage SystemAppB onInactive'); + }, + onHide() { + console.info('ACTS_ProcessManage SystemAppB onHide'); + }, + onDestroy() { + console.info('ACTS_ProcessManage SystemAppB onDestroy'); + }, + onBackPress() { + console.info('ACTS_ProcessManage SystemAppB onBackPress'); + }, + onNewRequest() { + console.info('ACTS_ProcessManage SystemAppB onNewRequest'); + }, + onStartContinuation() { + console.info('ACTS_ProcessManage SystemAppB onStartContinuation'); + }, + onSaveData(value) { + console.info('ACTS_ProcessManage SystemAppB onSaveData:' + JSON.stringify(value)); + }, + onRestoreData(value) { + console.info('ACTS_ProcessManage SystemAppB onRestoreData:' + JSON.stringify(value)); + }, + onCompleteContinuation(code) { + console.info('ACTS_ProcessManage SystemAppB onCompleteContinuation:' + JSON.stringify(code)); + }, + onConfigurationUpdated(configuration) { + console.info('ACTS_ProcessManage SystemAppB onConfigurationUpdated:' + JSON.stringify(configuration)); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/resources/base/element/string.json b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..fd60cdefa929070f1798c6e36f0502f1e1e219a4 --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "particlestartability" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/resources/base/media/icon.png b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/ActsKillProcessWithAccountCloseApi7/src/main/js/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/BUILD.gn b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..f46f18c5174f811e09bc997e1dd83a0216336e56 --- /dev/null +++ b/aafwk/aafwk_standard/ActsKillProcessWithAccountApi7/BUILD.gn @@ -0,0 +1,24 @@ +# Copyright (c) 2021 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") + +group("ActsKillProcessWithAccountApi7") { + testonly = true + if (is_standard_system) { + deps = [ + "ActsKillProcessWithAccountApi7Test:ActsKillProcessWithAccountApi7Test", + "ActsKillProcessWithAccountCloseApi7:ActsKillProcessWithAccountCloseApi7", + ] + } +} diff --git a/aafwk/aafwk_standard/BUILD.gn b/aafwk/aafwk_standard/BUILD.gn index e4e998bec5ac33333fc357e6bc4518fac4b5f8b3..a3ecdcc3290e48f5047456c8aab7e994be7d97e7 100755 --- a/aafwk/aafwk_standard/BUILD.gn +++ b/aafwk/aafwk_standard/BUILD.gn @@ -18,13 +18,17 @@ group("aafwk_standard") { if (is_standard_system) { deps = [ "ActsStServiceAbilityClientCaseTest:ActsStServiceAbilityClientCaseTest", + "ActsDataAbilityJsTest:ActsDataAbilityJsTest", + "ActsKillProcessWithAccountApi7:ActsKillProcessWithAccountApi7", "abilitymanager:actsabilitymanagertest", "actsabilitydistributetest:ActsAbilityDistributeTest", "actsabilitydistributetest:ActsAbilityDistributeTest", + "actsabilitymanageretstest:ActsAbilityManagerEtsTest", "amsabilitymanager/amsMissionSnapshotTest:ActsAmsMissionSnapshotTest", "amsabilitymanager/amsMissionSnapshotTestSingleton:ActsAmsMissionSnapshotTestSingleton", "amsabilitymanager/amsMissionSnapshotTestSingletonS:ActsAmsMissionSnapshotTestSingletonS", "amsdatauriutils:ActsAmsDataUriUtilsTest", + "amsgetabilityprocessinfo:amsgetabilityprocessinfo", "amsmultiapp/MultiAppPage:ActsAmsMultiPageApp", "amsmultiapp/MultiAppPageConnectService:ActsAmsMultiPageAppConnectService", "amsmultiapp/MultiAppPageConnect_Service:ActsAmsMultiAppPageConnectService", @@ -43,10 +47,12 @@ group("aafwk_standard") { "amsmultiapp/amsmultiapptester:ActsAmsMultiAppTester", "amsmultiapp/amsmultidataabilityclone:ActsAmsMultiDataAbilityClone", "amsmultiapp/amsmultidataabilityself:ActsAmsMultiDataAbilitySelf", + "amsprocessmanageapi7:amsprocessmanageapi7", "amszipfileunzipfilest:ActsAmsZipfileUnzipfileSTest", "context:context", "featureability:featureability", "formmanager:formmanager", + "lanuageConfigapi7:lanuageConfigapi7", "serviceability/sceneProject/particlestartability:ParticleStartAbility", "serviceability/sceneProject/particletestserver:ParticleTestServer", "serviceability/stserviceabilityserver:amsStServiceAilityServer", diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/default/pages/index/index.js index ded5295b9d4f023dba85ca970fd7153074861554..590bd0c3bf9215878b0bfcf03ff0955ef3786650 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index a447767a22ad613f535ab34f909ca063ef75793b..a812c464a14b89e593b93efdb87c92d865856290 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,23 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", @@ -55,16 +43,20 @@ describe('ActsAmsCallBackFifthScene', function () { console.info('----ActsAmsCallBackFifthScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsCallBackFifthScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamscallbackfifthscene' && - data[i].topAbility.bundleName != 'com.example.actsamscallbackfifthscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamscallbackfifthscene') { + console.log("ActsAmsCallBackFifthScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsCallBackFifthScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -76,8 +68,12 @@ describe('ActsAmsCallBackFifthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackFifthScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -89,8 +85,12 @@ describe('ActsAmsCallBackFifthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackFifthScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -102,9 +102,12 @@ describe('ActsAmsCallBackFifthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackFifthScene SimulateFeatureAbilitySed start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); - setTimeout(done(), 5000); + setTimeout(done, 5000); }); function timeout(done) { @@ -114,346 +117,147 @@ describe('ActsAmsCallBackFifthScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_6600 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by CallBack) */ it('Acts_Ams_test_6600', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - abilityManager.getAllRunningProcesses( + appManager.getProcessRunningInfos( (error, info) => { - console.info('getAllRunningProcesses error.code \ + console.info('Acts_Ams_test_6600 getProcessRunningInfos error.code \ ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_6600 getAllRunningProcesses JSON String: ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_6600 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); - }); + } + ); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_7000 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos + * @tc.name : getMissionInfos : Query Recent Ability Mission Infos * @tc.desc : Query Recent Ability Mission Infos(by CallBack) */ it('Acts_Ams_test_7000', 0, async function (done) { var maxnum = 10; - var flag = 1; - abilityManager.queryRecentAbilityMissionInfos(maxnum, flag, - (error, data) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + data.length + ']'); - console.info('Acts_Ams_test_7000 queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(data[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_6800 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos - * @tc.desc : Query Running Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_6800', 0, async function (done) { - var maxnum = 10; - abilityManager.queryRunningAbilityMissionInfos(maxnum, + missionManager.getMissionInfos("", maxnum, (error, data) => { - console.info('queryRunningAbilityMissionInfos error.code : \ + console.info('Acts_Ams_test_7000 getMissionInfos error.code : \ ' + error.code + ',data length [' + data.length + ']'); - console.info('Acts_Ams_test_6800 queryRunningAbilityMissionInfos data ' + JSON.stringify(data)); expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); + expect(data.length).assertEqual(4); for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(data[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9000 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by CallBack) - */ - it('Acts_Ams_test_9000', 0, async function (done) { - abilityManager.getActiveProcessInfos( - (error, info) => { - console.info('getActiveProcessInfos error.code \ - ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_9000 getActiveProcessInfos data ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10000 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_10000', 0, async function (done) { - var maxnum = 10; - abilityManager.getActiveAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_10000 getActiveAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].missionId)).assertEqual("number"); - expect(info[i].missionId).assertLarger(0); - - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_11000 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_11000', 0, async function (done) { - var maxnum = 10; - abilityManager.getPreviousAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_11000 getPreviousAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].missionId)).assertEqual("number"); - expect(info[i].missionId).assertLarger(0); - - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); + console.info('Acts_Ams_test_7000 getMissionInfos data[' + i + "]: " + JSON.stringify(data[i])); + expect(typeof (data[i].missionId)).assertEqual("number"); + expect(data[i].missionId).assertLarger(0); + + expect(typeof (data[i].want)).assertEqual("object"); + expect(typeof (data[i].want.deviceId)).assertEqual("string"); + expect(typeof (data[i].want.bundleName)).assertEqual("string"); + expect(data[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(data[i].want.bundleName)).assertLarger(-1); + expect(typeof (data[i].want.abilityName)).assertEqual("string"); + expect(data[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(data[i].want.abilityName)).assertLarger(-1); + + expect(typeof (data[i].label)).assertEqual("string"); + expect(typeof (data[i].iconPath)).assertEqual("string"); } done(); - }); + } + ); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_7200 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by CallBack) */ it('Acts_Ams_test_7200', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.removeMission(result[1].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_7200 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[1].missionId, (error, info) => { - console.info('Acts_Ams_test_7200 removeMission error.code \ + console.info('Acts_Ams_test_7200 clearMission error.code \ ' + error.code + ',data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); - }); + } + ); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_7600 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by CallBack) */ it('Acts_Ams_test_7600', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.moveMissionToTop(result[0].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_7600 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.moveMissionToFront(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_7600 moveMissionToTop error.code \ + console.info('Acts_Ams_test_7600 moveMissionToFront error.code \ ' + error.code + ',data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); - }); + } + ); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_12000 - * @tc.name : deleteMissions : Remove Missions + * @tc.name : clearMission : Remove Missions * @tc.desc : Remove Missions(by CallBack) */ it('Acts_Ams_test_12000', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.deleteMissions([result[0].id], + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_12000 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_12000 deleteMissions error.code \ + console.info('Acts_Ams_test_12000 clearMission error.code \ ' + error.code + ',data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); - }); + } + ); setTimeout(timeout, 5000); }) @@ -463,14 +267,15 @@ describe('ActsAmsCallBackFifthScene', function () { * @tc.desc : Kill Processes By BundleName(by CallBack) */ it('Acts_Ams_test_8000', 0, async function (done) { - abilityManager.killProcessesByBundleName('com.ix.verify.io', + appManager.killProcessesByBundleName('com.ix.verify.io', (error, info) => { console.info('Acts_Ams_test_8000 killProcessesByBundleName error.code: \ ' + error.code + ',data [' + info + ']'); expect(typeof (info)).assertEqual("number"); expect(info).assertEqual(0); done(); - }); + } + ); setTimeout(timeout, 5000); }) -}) +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/default/pages/index/index.js index d280f5629e3781e92b248dde4bfbecca5fd5140d..3ba401843b653bc303d30b6ab8d556c67d0b1525 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/default/pages/index/index.js @@ -40,6 +40,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index ef6213c489f1c1e757fe5b22e640429160f76a48..a28022c48c68a6b55235c4059e4a17d9fd6691f2 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,23 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", @@ -52,16 +40,20 @@ describe('ActsAmsCallBackFirstScene', function () { console.info('----ActsAmsCallBackFirstScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsCallBackFirstScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamscallbackfirstscene' && - data[i].topAbility.bundleName != 'com.example.actsamscallbackfirstscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamscallbackfirstscene') { + console.log("ActsAmsCallBackFirstScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsCallBackFirstScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -73,7 +65,10 @@ describe('ActsAmsCallBackFirstScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackFirstScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); setTimeout(done(), 5000); }); @@ -85,53 +80,41 @@ describe('ActsAmsCallBackFirstScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_0200 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by CallBack) */ it('Acts_Ams_test_0200', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - abilityManager.getAllRunningProcesses( + appManager.getProcessRunningInfos( (error, info) => { - console.info('getAllRunningProcesses error.code \ + console.info('Acts_Ams_test_0200 getProcessRunningInfos error.code \ ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_0200 getAllRunningProcesses data ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_0200 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); }); @@ -140,231 +123,33 @@ describe('ActsAmsCallBackFirstScene', function () { /* * @tc.number : Acts_Ams_test_0400 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos + * @tc.name : getMissionInfos : Query Running Ability Mission Infos * @tc.desc : Query Running Ability Mission Infos(by CallBack) */ it('Acts_Ams_test_0400', 0, async function (done) { var maxnum = 10; - abilityManager.queryRunningAbilityMissionInfos(maxnum, + missionManager.getMissionInfos("", maxnum, (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ + console.info('Acts_Ams_test_0400 getMissionInfos error.code : \ ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_0400 queryRunningAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(2); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].id)).assertEqual("number"); - expect(info[i].id).assertLarger(0); - - expect(typeof (info[i].baseAbility)).assertEqual("object"); - expect(typeof (info[i].baseAbility.deviceId)).assertEqual("string"); - expect(info[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].baseAbility.bundleName)).assertEqual("string"); - expect(info[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].baseAbility.abilityName)).assertEqual("string"); - expect(info[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].missionDescription)).assertEqual("object"); - expect(typeof (info[i].missionDescription.label)).assertEqual("string"); - expect(typeof (info[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_0600 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos - * @tc.desc : Query Recent Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_0600', 0, async function (done) { - var maxnum = 10; - var flag = 1; - abilityManager.queryRecentAbilityMissionInfos(maxnum, flag, - (error, info) => { - console.info('queryRunningAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_0600 queryRecentAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(2); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].id)).assertEqual("number"); - expect(info[i].id).assertLarger(0); - - expect(typeof (info[i].baseAbility)).assertEqual("object"); - expect(typeof (info[i].baseAbility.deviceId)).assertEqual("string"); - expect(info[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].baseAbility.bundleName)).assertEqual("string"); - expect(info[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].baseAbility.abilityName)).assertEqual("string"); - expect(info[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].missionDescription)).assertEqual("object"); - expect(typeof (info[i].missionDescription.label)).assertEqual("string"); - expect(typeof (info[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8600 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by CallBack) - */ - it('Acts_Ams_test_8600', 0, async function (done) { - abilityManager.getActiveProcessInfos( - (error, info) => { - console.info('getActiveProcessInfos error.code \ - ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_8600 getActiveProcessInfos data ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9600 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_9600', 0, async function (done) { - var maxnum = 10; - abilityManager.getActiveAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_9600 getActiveAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(2); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].missionId)).assertEqual("number"); - expect(info[i].missionId).assertLarger(0); - - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10600 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_10600', 0, async function (done) { - var maxnum = 10; - abilityManager.getPreviousAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_10600 getPreviousAbilityMissionInfos info ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertEqual(2); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_0400 getMissionInfos data[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].missionId)).assertEqual("number"); expect(info[i].missionId).assertLarger(0); - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); + expect(typeof (info[i].want)).assertEqual("object"); + expect(typeof (info[i].want.deviceId)).assertEqual("string"); + expect(typeof (info[i].want.bundleName)).assertEqual("string"); + expect(info[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(info[i].want.bundleName)).assertLarger(-1); + expect(typeof (info[i].want.abilityName)).assertEqual("string"); + expect(info[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(info[i].want.abilityName)).assertLarger(-1); + + expect(typeof (info[i].label)).assertEqual("string"); + expect(typeof (info[i].iconPath)).assertEqual("string"); } done(); }); @@ -373,18 +158,21 @@ describe('ActsAmsCallBackFirstScene', function () { /* * @tc.number : Acts_Ams_test_1400 - * @tc.name : removeMissions : Remove Missions + * @tc.name : clearMissions : Remove Missions * @tc.desc : Remove Missions(by CallBack) */ it('Acts_Ams_test_1400', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var missionID = result[0].id + 100; - abilityManager.removeMissions([missionID], + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_1400 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var missionID = result[0].missionId + 100; + missionManager.clearMission(missionID, (error, info) => { - console.info('Acts_Ams_test_1400 removeMissions error.code \ + console.info('Acts_Ams_test_1400 clearMissions error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertLarger(0); + expect(error.code).assertLarger(-1); done(); }); setTimeout(timeout, 5000); @@ -392,17 +180,20 @@ describe('ActsAmsCallBackFirstScene', function () { /* * @tc.number : Acts_Ams_test_0800 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by CallBack) */ it('Acts_Ams_test_0800', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.removeMission(result[0].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_0800 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_0800 removeMission error.code \ + console.info('Acts_Ams_test_0800 clearMission error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); @@ -414,35 +205,35 @@ describe('ActsAmsCallBackFirstScene', function () { * @tc.desc : Kill Processes By BundleName(by CallBack) */ it('Acts_Ams_test_1600', 0, async function (done) { - abilityManager.killProcessesByBundleName('com.ix.simulate.feature', + appManager.killProcessesByBundleName('com.ix.simulate.feature', (error, info) => { console.info('Acts_Ams_test_1600 killProcessesByBundleName error.code: \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); - }) /* * @tc.number : Acts_Ams_test_1200 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by CallBack) */ it('Acts_Ams_test_1200', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.moveMissionToTop(result[0].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_1200 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.moveMissionToFront(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_1200 moveMissionToTop error.code \ + console.info('Acts_Ams_test_1200 moveMissionToFront error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); }) -}) - - +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/default/pages/index/index.js index 317505e8dc895d1578a0454cc2d096005a81302c..8b48ca37486b43a1a860e41c0efc46e09cfb7858 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index 70a17b595ad757499f0c70776184158ee27a332a..7aee5154f30196191c3d1c070ae5b7e61a073b74 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,30 +12,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", "com.example.SimulateFeatureAbilityFir", "com.example.VerifyActThirdAbility", "com.example.VerifyIoThirdAbility", - "com.example.SimulateEntryAbilityFir", + "com.example.SimulateEntryAbility", "com.example.actsamscallbackfourthscene.MainAbility" ] @@ -58,16 +46,20 @@ describe('ActsAmsCallBackFourthScene', function () { console.info('----ActsAmsCallBackFourthScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsCallBackFourthScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamscallbackfourthscene' && - data[i].topAbility.bundleName != 'com.example.actsamscallbackfourthscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamscallbackfourthscene') { + console.log("ActsAmsCallBackFourthScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsCallBackFourthScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -79,8 +71,12 @@ describe('ActsAmsCallBackFourthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackFourthScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -92,8 +88,12 @@ describe('ActsAmsCallBackFourthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackFourthScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -105,19 +105,26 @@ describe('ActsAmsCallBackFourthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackFourthScene VerifyActThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: { deviceId: "", bundleName: "com.ix.simulate.entry", - abilityName: "com.example.SimulateEntryAbility", + abilityName: "com.example.SimulateEntryAbilityFir", action: "action1", parameters: {}, }, + }, (error, data) => { + console.info('ActsAmsCallBackFourthScene SimulateEntryAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); } ); setTimeout(done(), 5000); @@ -130,53 +137,41 @@ describe('ActsAmsCallBackFourthScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_5000 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by CallBack) */ it('Acts_Ams_test_5000', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - abilityManager.getAllRunningProcesses( + appManager.getProcessRunningInfos( (error, info) => { - console.info('getAllRunningProcesses error.code \ + console.info('Acts_Ams_test_5000 getProcessRunningInfos error.code \ ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_5000 getAllRunningProcesses JSON String: ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_5000 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); }); @@ -186,251 +181,33 @@ describe('ActsAmsCallBackFourthScene', function () { /* * @tc.number : Acts_Ams_test_5400 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos + * @tc.name : getMissionInfos : Query Recent Ability Mission Infos * @tc.desc : Query Recent Ability Mission Infos(by CallBack) */ it('Acts_Ams_test_5400', 0, async function (done) { var maxnum = 100; - var flag = 1; - abilityManager.queryRecentAbilityMissionInfos(maxnum, flag, - (error, data) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + data.length + ']'); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(4); - for (var i = 0; i < data.length; i++) { - console.info('Acts_Ams_test_5400 queryRecentAbilityMissionInfos id: \ - ' + data[i].id + ' baseAbility.deviceId: \ - ' + data[i].baseAbility.deviceId + ' baseAbility.bundleName: \ - ' + data[i].baseAbility.bundleName + ' baseAbility.abilityName: \ - ' + data[i].baseAbility.abilityName + ' topAbility.deviceId: \ - ' + data[i].topAbility.deviceId + ' topAbility.bundleName: \ - ' + data[i].topAbility.bundleName + ' topAbility.abilityName: \ - ' + data[i].topAbility.abilityName + ' missionDescription.label: \ - ' + data[i].missionDescription.label + ' missionDescription.iconPath: \ - ' + data[i].missionDescription.iconPath); - - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(data[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_5200 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos - * @tc.desc : Query Running Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_5200', 0, async function (done) { - var maxnum = 30; - abilityManager.queryRunningAbilityMissionInfos(maxnum, + missionManager.getMissionInfos("", maxnum, (error, data) => { - console.info('queryRunningAbilityMissionInfos error.code : \ + console.info('Acts_Ams_test_5400 getMissionInfos error.code : \ ' + error.code + ',data length [' + data.length + ']'); expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(4); + expect(data.length).assertEqual(5); for (var i = 0; i < data.length; i++) { - console.info('Acts_Ams_test_5200 queryRunningAbilityMissionInfos id: \ - ' + data[i].id + ' baseAbility.deviceId: \ - ' + data[i].baseAbility.deviceId + ' baseAbility.bundleName: \ - ' + data[i].baseAbility.bundleName + ' baseAbility.abilityName: \ - ' + data[i].baseAbility.abilityName + ' topAbility.deviceId: \ - ' + data[i].topAbility.deviceId + ' topAbility.bundleName: \ - ' + data[i].topAbility.bundleName + ' topAbility.abilityName: \ - ' + data[i].topAbility.abilityName + ' missionDescription.label: \ - ' + data[i].missionDescription.label + ' missionDescription.iconPath: \ - ' + data[i].missionDescription.iconPath); - - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(data[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8900 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by CallBack) - */ - it('Acts_Ams_test_8900', 0, async function (done) { - abilityManager.getActiveProcessInfos( - (error, info) => { - console.info('getActiveProcessInfos error.code \ - ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_8900 getActiveProcessInfos data ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9900 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_9900', 0, async function (done) { - var maxnum = 10; - abilityManager.getActiveAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_9900 getActiveAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(4); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].missionId)).assertEqual("number"); - expect(info[i].missionId).assertLarger(0); - - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10900 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_10900', 0, async function (done) { - var maxnum = 10; - abilityManager.getPreviousAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_10900 getPreviousAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(4); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].missionId)).assertEqual("number"); - expect(info[i].missionId).assertLarger(0); - - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); + console.info('Acts_Ams_test_5400 getMissionInfos data[' + i + "]: " + JSON.stringify(data[i])); + expect(typeof (data[i].missionId)).assertEqual("number"); + expect(data[i].missionId).assertLarger(0); + + expect(typeof (data[i].want)).assertEqual("object"); + expect(typeof (data[i].want.deviceId)).assertEqual("string"); + expect(typeof (data[i].want.bundleName)).assertEqual("string"); + expect(data[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(data[i].want.bundleName)).assertLarger(-1); + expect(typeof (data[i].want.abilityName)).assertEqual("string"); + expect(data[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(data[i].want.abilityName)).assertLarger(-1); + + expect(typeof (data[i].label)).assertEqual("string"); + expect(typeof (data[i].iconPath)).assertEqual("string"); } done(); }); @@ -439,18 +216,20 @@ describe('ActsAmsCallBackFourthScene', function () { /* * @tc.number : Acts_Ams_test_5600 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by CallBack) */ it('Acts_Ams_test_5600', 0, async function (done) { var maxnum = 30; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.removeMission(result[0].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_5600 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_5600 removeMission error.code \ + console.info('Acts_Ams_test_5600 clearMission error.code \ ' + error.code + ',data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); @@ -458,18 +237,20 @@ describe('ActsAmsCallBackFourthScene', function () { /* * @tc.number : Acts_Ams_test_6000 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by CallBack) */ it('Acts_Ams_test_6000', 0, async function (done) { var maxnum = 30; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.moveMissionToTop(result[1].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_6000 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.moveMissionToFront(result[1].missionId, (error, info) => { - console.info('Acts_Ams_test_6000 moveMissionToTop error.code \ + console.info('Acts_Ams_test_6000 moveMissionToFront error.code \ ' + error.code + ',data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); @@ -481,7 +262,7 @@ describe('ActsAmsCallBackFourthScene', function () { * @tc.desc : Kill Processes By BundleName(by CallBack) */ it('Acts_Ams_test_6400', 0, async function (done) { - abilityManager.killProcessesByBundleName('xxxxxxxxx', + missionManager.killProcessesByBundleName('xxxxxxxxx', (error, info) => { console.info('Acts_Ams_test_6400 killProcessesByBundleName error.code \ ' + error.code + ',data [' + info + ']'); @@ -494,20 +275,22 @@ describe('ActsAmsCallBackFourthScene', function () { /* * @tc.number : Acts_Ams_test_11900 - * @tc.name : deleteMissions : delete Missions + * @tc.name : clearMissions : delete Missions * @tc.desc : delete Missions(by CallBack) */ it('Acts_Ams_test_11900', 0, async function (done) { var maxnum = 30; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.deleteMissions([result[1].id, result[0].id], + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_11900 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearAllMissions( (error, info) => { - console.info('Acts_Ams_test_11900 deleteMissions error.code: \ + console.info('Acts_Ams_test_11900 clearAllMissions error.code: \ ' + error.code + ',data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); }) -}) +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/default/pages/index/index.js index ded5295b9d4f023dba85ca970fd7153074861554..590bd0c3bf9215878b0bfcf03ff0955ef3786650 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index 66b2c6ccbf0cd1496ad9070ce8d7e7dcbb63dbb1..15cf58f95e742bce3da7d4414e28546209f3203c 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbacksecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,23 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", @@ -54,16 +42,20 @@ describe('ActsAmsCallBackSecondScene', function () { console.info('----ActsAmsCallBackSecondScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsCallBackSecondScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamscallbacksecondscene' && - data[i].topAbility.bundleName != 'com.example.actsamscallbacksecondscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamscallbacksecondscene') { + console.log("ActsAmsCallBackSecondScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsCallBackSecondScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -75,8 +67,12 @@ describe('ActsAmsCallBackSecondScene', function () { parameters: {}, }, + }, (error, data) => { + console.info('ActsAmsCallBackSecondScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); } ); + await featureAbility.startAbility( { want: @@ -88,6 +84,9 @@ describe('ActsAmsCallBackSecondScene', function () { parameters: {}, }, + }, (error, data) => { + console.info('ActsAmsCallBackSecondScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); } ); setTimeout(done(), 5000); @@ -100,53 +99,41 @@ describe('ActsAmsCallBackSecondScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_1800 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by CallBack) */ it('Acts_Ams_test_1800', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - abilityManager.getAllRunningProcesses( + appManager.getProcessRunningInfos( (error, info) => { - console.info('getAllRunningProcesses error.code \ + console.info('Acts_Ams_test_1800 getProcessRunningInfos error.code \ ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_1800 getAllRunningProcesses data ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_1800 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); }); @@ -155,231 +142,33 @@ describe('ActsAmsCallBackSecondScene', function () { /* * @tc.number : Acts_Ams_test_2000 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos + * @tc.name : getMissionInfos : Query Running Ability Mission Infos * @tc.desc : Query Running Ability Mission Infos(by CallBack) */ it('Acts_Ams_test_2000', 0, async function (done) { var maxnum = 20; - abilityManager.queryRunningAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_2000 queryRunningAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].id)).assertEqual("number"); - expect(info[i].id).assertLarger(0); - - expect(typeof (info[i].baseAbility)).assertEqual("object"); - expect(typeof (info[i].baseAbility.deviceId)).assertEqual("string"); - expect(info[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].baseAbility.bundleName)).assertEqual("string"); - expect(info[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].baseAbility.abilityName)).assertEqual("string"); - expect(info[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].missionDescription)).assertEqual("object"); - expect(typeof (info[i].missionDescription.label)).assertEqual("string"); - expect(typeof (info[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_2200 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos - * @tc.desc : Query Recent Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_2200', 0, async function (done) { - var maxnum = 20; - var flag = 1; - abilityManager.queryRecentAbilityMissionInfos(maxnum, flag, + missionManager.getMissionInfos("", maxnum, (error, info) => { - console.info('queryRunningAbilityMissionInfos error.code : \ + console.info('Acts_Ams_test_2000 getMissionInfos error.code : \ ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_2200 queryRecentAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].id)).assertEqual("number"); - expect(info[i].id).assertLarger(0); - - expect(typeof (info[i].baseAbility)).assertEqual("object"); - expect(typeof (info[i].baseAbility.deviceId)).assertEqual("string"); - expect(info[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].baseAbility.bundleName)).assertEqual("string"); - expect(info[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].baseAbility.abilityName)).assertEqual("string"); - expect(info[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].missionDescription)).assertEqual("object"); - expect(typeof (info[i].missionDescription.label)).assertEqual("string"); - expect(typeof (info[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8700 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by CallBack) - */ - it('Acts_Ams_test_8700', 0, async function (done) { - abilityManager.getActiveProcessInfos( - (error, info) => { - console.info('getActiveProcessInfos error.code \ - ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_8700 getActiveProcessInfos data ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9700 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_9700', 0, async function (done) { - var maxnum = 10; - abilityManager.getActiveAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_9700 getActiveAbilityMissionInfos info ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertEqual(3); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_2000 getMissionInfos data[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].missionId)).assertEqual("number"); expect(info[i].missionId).assertLarger(0); - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10700 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_10700', 0, async function (done) { - var maxnum = 10; - abilityManager.getPreviousAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_10700 getPreviousAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].missionId)).assertEqual("number"); - expect(info[i].missionId).assertLarger(0); - - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); + expect(typeof (info[i].want)).assertEqual("object"); + expect(typeof (info[i].want.deviceId)).assertEqual("string"); + expect(typeof (info[i].want.bundleName)).assertEqual("string"); + expect(info[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(info[i].want.bundleName)).assertLarger(-1); + expect(typeof (info[i].want.abilityName)).assertEqual("string"); + expect(info[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(info[i].want.abilityName)).assertLarger(-1); + + expect(typeof (info[i].label)).assertEqual("string"); + expect(typeof (info[i].iconPath)).assertEqual("string"); } done(); }); @@ -388,17 +177,20 @@ describe('ActsAmsCallBackSecondScene', function () { /* * @tc.number : Acts_Ams_test_2400 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by CallBack) */ it('Acts_Ams_test_2400', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.removeMission(result[1].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_2400 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[1].missionId, (error, info) => { - console.info('Acts_Ams_test_2400 removeMission error.code \ + console.info('Acts_Ams_test_2400 clearMission error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); @@ -406,17 +198,20 @@ describe('ActsAmsCallBackSecondScene', function () { /* * @tc.number : Acts_Ams_test_2800 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by CallBack) */ it('Acts_Ams_test_2800', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.moveMissionToTop(result[0].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_2800 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.moveMissionToFront(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_2800 moveMissionToTop error.code \ + console.info('Acts_Ams_test_2800 moveMissionToFront error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); @@ -428,7 +223,7 @@ describe('ActsAmsCallBackSecondScene', function () { * @tc.desc : Kill Processes By BundleName(by CallBack) */ it('Acts_Ams_test_3200', 0, async function (done) { - abilityManager.killProcessesByBundleName('XXXXXXXXXXXX', + appManager.killProcessesByBundleName('XXXXXXXXXXXX', (error, info) => { console.info('Acts_Ams_test_3200 killProcessesByBundleName error.code: \ ' + error.code + ',data [' + info + ']'); @@ -440,22 +235,22 @@ describe('ActsAmsCallBackSecondScene', function () { /* * @tc.number : Acts_Ams_test_3000 - * @tc.name : removeMissions: Remove Missions + * @tc.name : clearMissions: Remove Missions * @tc.desc : Remove Missions(by CallBack) */ it('Acts_Ams_test_3000', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.removeMissions([result[0].id], + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_3000 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_3000 removeMissions error.code \ + console.info('Acts_Ams_test_3000 clearMission error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); }); setTimeout(timeout, 5000); }) - -}) - - +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/default/pages/index/index.js index ded5295b9d4f023dba85ca970fd7153074861554..590bd0c3bf9215878b0bfcf03ff0955ef3786650 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index 6ff3630b1da5727f5f1864f5580a94e85ee66099..0dcdf5c2cb5915b8daacc3f80a31149727dd63fa 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamscallbackthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,22 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", @@ -52,16 +41,20 @@ describe('ActsAmsCallBackThirdScene', function () { console.info('----ActsAmsCallBackThirdScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsCallBackThirdScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamscallbackthirdscene' && - data[i].topAbility.bundleName != 'com.example.actsamscallbackthirdscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamscallbackthirdscene') { + console.log("ActsAmsCallBackThirdScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsCallBackThirdScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -73,8 +66,12 @@ describe('ActsAmsCallBackThirdScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackThirdScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -86,7 +83,10 @@ describe('ActsAmsCallBackThirdScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsCallBackThirdScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); setTimeout(done(), 5000); }); @@ -98,53 +98,41 @@ describe('ActsAmsCallBackThirdScene', function () { } function sleep(delay) { - var startTime = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_3400 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by CallBack) */ it('Acts_Ams_test_3400', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - abilityManager.getAllRunningProcesses( + appManager.getProcessRunningInfos( (error, info) => { - console.info('getAllRunningProcesses error.code \ + console.info('Acts_Ams_test_3400 getProcessRunningInfos error.code \ ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_3400 getAllRunningProcesses data ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_3400 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); }); @@ -153,231 +141,33 @@ describe('ActsAmsCallBackThirdScene', function () { /* * @tc.number : Acts_Ams_test_3600 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos + * @tc.name : getMissionInfos : Query Running Ability Mission Infos * @tc.desc : Query Running Ability Mission Infos(by CallBack) */ it('Acts_Ams_test_3600', 0, async function (done) { var maxnum = 20; - abilityManager.queryRunningAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_3600 queryRunningAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].id)).assertEqual("number"); - expect(info[i].id).assertLarger(0); - - expect(typeof (info[i].baseAbility)).assertEqual("object"); - expect(typeof (info[i].baseAbility.deviceId)).assertEqual("string"); - expect(info[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].baseAbility.bundleName)).assertEqual("string"); - expect(info[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].baseAbility.abilityName)).assertEqual("string"); - expect(info[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].missionDescription)).assertEqual("object"); - expect(typeof (info[i].missionDescription.label)).assertEqual("string"); - expect(typeof (info[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_3800 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos - * @tc.desc : Query Recent Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_3800', 0, async function (done) { - var maxnum = 20; - var flag = 2; - abilityManager.queryRecentAbilityMissionInfos(maxnum, flag, - (error, info) => { - console.info('queryRunningAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_3800 queryRecentAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].id)).assertEqual("number"); - expect(info[i].id).assertLarger(0); - - expect(typeof (info[i].baseAbility)).assertEqual("object"); - expect(typeof (info[i].baseAbility.deviceId)).assertEqual("string"); - expect(info[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].baseAbility.bundleName)).assertEqual("string"); - expect(info[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].baseAbility.abilityName)).assertEqual("string"); - expect(info[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (info[i].missionDescription)).assertEqual("object"); - expect(typeof (info[i].missionDescription.label)).assertEqual("string"); - expect(typeof (info[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8800 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by CallBack) - */ - it('Acts_Ams_test_8800', 0, async function (done) { - abilityManager.getActiveProcessInfos( - (error, info) => { - console.info('getActiveProcessInfos error.code \ - ' + error.code + ', data length [' + info.length + ']'); - console.info('Acts_Ams_test_8800 getActiveProcessInfos data ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9800 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_9800', 0, async function (done) { - var maxnum = 10; - abilityManager.getActiveAbilityMissionInfos(maxnum, + missionManager.getMissionInfos("", maxnum, (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ + console.info('Acts_Ams_test_3600 getMissionInfos error.code : \ ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_9800 getActiveAbilityMissionInfos info ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertEqual(3); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_3600 getMissionInfos info[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].missionId)).assertEqual("number"); expect(info[i].missionId).assertLarger(0); - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); - } - done(); - }); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10800 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by CallBack) - */ - it('Acts_Ams_test_10800', 0, async function (done) { - var maxnum = 10; - abilityManager.getPreviousAbilityMissionInfos(maxnum, - (error, info) => { - console.info('queryRecentAbilityMissionInfos error.code : \ - ' + error.code + ',data length [' + info.length + ']'); - console.info('Acts_Ams_test_10800 getPreviousAbilityMissionInfos info ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertEqual(3); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].missionId)).assertEqual("number"); - expect(info[i].missionId).assertLarger(0); - - expect(typeof (info[i].bottomAbility)).assertEqual("object"); - expect(typeof (info[i].bottomAbility.deviceId)).assertEqual("string"); - expect(info[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.bundleName)).assertEqual("string"); - expect(info[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.abilityName)).assertEqual("string"); - expect(info[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].bottomAbility.uri)).assertEqual("string"); - expect(info[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (info[i].bottomAbility.shortName)).assertEqual("string"); - expect(info[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].topAbility)).assertEqual("object"); - expect(typeof (info[i].topAbility.deviceId)).assertEqual("string"); - expect(info[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (info[i].topAbility.bundleName)).assertEqual("string"); - expect(info[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(info[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (info[i].topAbility.abilityName)).assertEqual("string"); - expect(info[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(info[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (info[i].topAbility.uri)).assertEqual("string"); - expect(info[i].topAbility.uri.length).assertEqual(0); - expect(typeof (info[i].topAbility.shortName)).assertEqual("string"); - expect(info[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (info[i].windowMode)).assertEqual("number"); - expect(info[i].windowMode).assertEqual(0); + expect(typeof (info[i].want)).assertEqual("object"); + expect(typeof (info[i].want.deviceId)).assertEqual("string"); + expect(typeof (info[i].want.bundleName)).assertEqual("string"); + expect(info[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(info[i].want.bundleName)).assertLarger(-1); + expect(typeof (info[i].want.abilityName)).assertEqual("string"); + expect(info[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(info[i].want.abilityName)).assertLarger(-1); + + expect(typeof (info[i].label)).assertEqual("string"); + expect(typeof (info[i].iconPath)).assertEqual("string"); } done(); }); @@ -386,55 +176,68 @@ describe('ActsAmsCallBackThirdScene', function () { /* * @tc.number : Acts_Ams_test_4000 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by CallBack) */ it('Acts_Ams_test_4000', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.removeMission(result[1].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_4000 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[1].missionId, (error, info) => { - console.info('Acts_Ams_test_4000 removeMission error.code \ + console.info('Acts_Ams_test_4000 clearMission error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); - }); + } + ); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_4400 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by CallBack) */ it('Acts_Ams_test_4400', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.moveMissionToTop(result[0].id, + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_4400 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.moveMissionToFront(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_4400 moveMissionToTop error.code \ + console.info('Acts_Ams_test_4400 moveMissionToFront error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); - }); + } + ); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_11800 - * @tc.name : deleteMissions : delete Missions + * @tc.name : clearMissions : delete Missions * @tc.desc : delete Missions(by CallBack) */ it('Acts_Ams_test_11800', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - abilityManager.deleteMissions([result[0].id], + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_11800 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + missionManager.clearMission(result[0].missionId, (error, info) => { - console.info('Acts_Ams_test_11800 deleteMissions error.code \ + console.info('Acts_Ams_test_11800 clearMissions error.code \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(0); + expect(error.code).assertEqual(0); done(); - }); + } + ); + done(); setTimeout(timeout, 5000); }) @@ -444,15 +247,15 @@ describe('ActsAmsCallBackThirdScene', function () { * @tc.desc : Kill Processes By BundleName(by CallBack) */ it('Acts_Ams_test_4800', 0, async function (done) { - abilityManager.killProcessesByBundleName('xxxxxxxxxxx', + appManager.killProcessesByBundleName('xxxxxxxxxxx', (error, info) => { console.info('Acts_Ams_test_4800 killProcessesByBundleName error.code: \ ' + error.code + ',data [' + info + ']'); - expect(info).assertEqual(2097215); + expect(error.code).assertEqual(2097215); done(); - }); + } + ); + done(); setTimeout(timeout, 5000); }) -}) - - +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/Test.json b/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/Test.json index 703124fbf940b305c81db024e9f357b3aa9f2b73..f02cf70ee9fc043a341f2934a01bae7b426aecdc 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/Test.json +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/Test.json @@ -2,7 +2,7 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "120000", + "test-timeout": "300000", "package": "com.example.actsamstestfifthscene", "shell-timeout": "600000" }, diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/default/pages/index/index.js index 317505e8dc895d1578a0454cc2d096005a81302c..8b48ca37486b43a1a860e41c0efc46e09cfb7858 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index ed497243e7bdabc786dafcb295a7e0e17ff689f8..e39fd291d68276c83938d5f383100522b5b31851 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfifthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,30 +12,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", "com.example.SimulateFeatureAbilityFir", - "com.example.VerifyIoThirdAbility", - "com.example.actsamstestfifthscene.MainAbility", - "com.example.SimulateFeatureAbilitySed" + "com.example.actsamstestfifthscene.MainAbility" ] var bundleNameList = [ @@ -47,24 +33,25 @@ var bundleNameList = [ "com.ohos.telephonydataability", "com.ohos.contactsdataability", "com.ix.simulate.feature", - "com.example.actsamstestfifthscene", - "com.ix.verify.io" + "com.example.actsamstestfifthscene" ] describe('ActsAmsTestFifthScene', function () { console.info('----ActsAmsTestFifthScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsTestFifthScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamstestfifthscene' && - data[i].topAbility.bundleName != 'com.example.actsamstestfifthscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); - } + console.log("ActsAmsTestFifthScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsTestFifthScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } + await featureAbility.startAbility( { want: @@ -81,8 +68,12 @@ describe('ActsAmsTestFifthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFifthScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -99,8 +90,12 @@ describe('ActsAmsTestFifthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFifthScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -117,7 +112,10 @@ describe('ActsAmsTestFifthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFifthScene SimulateFeatureAbilitySed start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); setTimeout(done(), 5000); }); @@ -129,314 +127,127 @@ describe('ActsAmsTestFifthScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* - * @tc.number : Acts_Ams_test_6500 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info - * @tc.desc : Get All Running Processes Info(by Promise) - */ - it('Acts_Ams_test_6500', 0, async function (done) { + * @tc.number : Acts_Ams_test_0100 + * @tc.name : getProcessRunningInfos : Get All Running Processes Info + * @tc.desc : Get All Running Processes Info(by Promise) + */ + it('Acts_Ams_test_0100', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - var info = await abilityManager.getAllRunningProcesses(); - console.info('getAllRunningProcesses data length [' + info.length + ']'); - console.info('Acts_Ams_test_6500 getAllRunningProcesses JSON String: ' + JSON.stringify(info)); + var info = await appManager.getProcessRunningInfos(); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_0100 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); setTimeout(timeout, 5000); }) /* - * @tc.number : Acts_Ams_test_7500 - * @tc.name : moveMissionToTop : Move Mission To Top - * @tc.desc : Move Mission To Top(by Promise) - */ - it('Acts_Ams_test_7500', 0, async function (done) { + * @tc.number : Acts_Ams_test_1100 + * @tc.name : moveMissionToFront : Move Mission To Top + * @tc.desc : Move Mission To Top(by Promise) + */ + it('Acts_Ams_test_1100', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.moveMissionToTop(result[1].id); - console.info('Acts_Ams_test_7500 moveMissionToTop data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); + var result = await missionManager.getMissionInfos("", maxnum).catch(err => { + console.log('Acts_Ams_test_1100 getMissionInfos failed: ' + err); + }); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_1100 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.moveMissionToFront(result[0].missionId); + console.info('Acts_Ams_test_1100 moveMissionToFront data [' + info + ']'); expect(info).assertEqual(0); - sleep(1000); - var ret = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - expect(result[1].baseAbility.bundleName).assertEqual(ret[0].baseAbility.bundleName); - expect(result[1].topAbility.bundleName).assertEqual(ret[0].topAbility.bundleName); done(); setTimeout(timeout, 5000); }) /* - * @tc.number : Acts_Ams_test_6900 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos - * @tc.desc : Query Recent Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_6900', 0, async function (done) { + * @tc.number : Acts_Ams_test_0300 + * @tc.name : getMissionInfos : Query Running Ability Mission Infos + * @tc.desc : Query Running Ability Mission Infos(by Promise) + */ + it('Acts_Ams_test_0300', 0, async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.info(' queryRecentAbilityMissionInfos data length [' + data.length + ']'); - console.info('Acts_Ams_test_6900 queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum).catch(err => { + console.log('Acts_Ams_test_0300 getMissionInfos failed: ' + err); + }); + console.info('Acts_Ams_test_0300 getMissionInfos data ' + JSON.stringify(data)); expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8500 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by Promise) - */ - it('Acts_Ams_test_8500', 0, async function (done) { - var info = await abilityManager.getActiveProcessInfos(); - console.info('Acts_Ams_test_8500 getActiveProcessInfos JSON String: ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9500 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_9500', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getActiveAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_9500 getActiveAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); + expect(data.length).assertEqual(4); for (var i = 0; i < data.length; i++) { + console.info('Acts_Ams_test_0300 getMissionInfos data[' + i + "]: " + JSON.stringify(data[i])); expect(typeof (data[i].missionId)).assertEqual("number"); expect(data[i].missionId).assertLarger(0); - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); + expect(typeof (data[i].want)).assertEqual("object"); + expect(typeof (data[i].want.deviceId)).assertEqual("string"); + expect(typeof (data[i].want.bundleName)).assertEqual("string"); + expect(data[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(data[i].want.bundleName)).assertLarger(-1); + expect(typeof (data[i].want.abilityName)).assertEqual("string"); + expect(data[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(data[i].want.abilityName)).assertLarger(-1); + + expect(typeof (data[i].label)).assertEqual("string"); + expect(typeof (data[i].iconPath)).assertEqual("string"); } done(); setTimeout(timeout, 5000); }) /* - * @tc.number : Acts_Ams_test_10500 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_10500', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getPreviousAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_10500 getPreviousAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].missionId)).assertEqual("number"); - expect(data[i].missionId).assertLarger(0); - - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); + * @tc.number : Acts_Ams_test_0700 + * @tc.name : clearMission : Remove Mission + * @tc.desc : Remove Mission(by Promise) + */ + it('Acts_Ams_test_0700', 0, async function (done) { + var maxnum = 10; + var result = await missionManager.getMissionInfos("", maxnum).catch(err => { + console.log('Acts_Ams_test_0700 getMissionInfos failed: ' + err); + }); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_0700 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_6700 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos - * @tc.desc : Query Running Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_6700', 0, async function (done) { - var maxnum = 10; - var data = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - console.info('queryRunningAbilityMissionInfos data length [' + data.length + ']'); - console.info('Acts_Ams_test_6700 queryRunningAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_11500 - * @tc.name : deleteMissions: delete Missions - * @tc.desc : delete Missions(by Promise) - */ - it('Acts_Ams_test_11500', 0, async function (done) { - var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.deleteMissions([result[1].id]); - console.info('Acts_Ams_test_11500 deleteMissions data [' + info + ']'); + var info = await missionManager.clearMission(result[1].missionId); + console.info('Acts_Ams_test_0700 clearMission data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); }) /* - * @tc.number : Acts_Ams_test_7900 - * @tc.name : killProcessesByBundleName : Kill Processes By BundleName - * @tc.desc : Kill Processes By BundleName(by Promise) - */ - it('Acts_Ams_test_7900', 0, async function (done) { - var info = await abilityManager.killProcessesByBundleName('com.ix.verify.io'); - console.info('Acts_Ams_test_7900 killProcessesByBundleName data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); + * @tc.number : Acts_Ams_test_1500 + * @tc.name : killProcessesByBundleName : Kill Processes By BundleName + * @tc.desc : Kill Processes By BundleName(by Promise) + */ + it('Acts_Ams_test_1500', 0, async function (done) { + var info = await appManager.killProcessesByBundleName('com.ix.simulate.feature'); + console.info('Acts_Ams_test_1500 killProcessesByBundleName data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); }) - }) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/Test.json b/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/Test.json index aa9e125d72712b52d9db4813c3667929d14d597a..4bd37e87f41bbd17e4e4d12f92e5298214501d4d 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/Test.json +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/Test.json @@ -2,7 +2,7 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "120000", + "test-timeout": "300000", "package": "com.example.actsamstestfirstscene", "shell-timeout": "600000" }, diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/default/pages/index/index.js index ded5295b9d4f023dba85ca970fd7153074861554..590bd0c3bf9215878b0bfcf03ff0955ef3786650 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index a6a77dd6dba0f6c0cb4907a774ee6e90918d0021..6bc56ed06cec8111b1496cf1cad9b12550a21ba3 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfirstscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,23 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", @@ -52,14 +40,17 @@ describe('ActsAmsTestFirstScene', function () { console.info('----ActsAmsTestFirstScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsTestFirstScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamstestfirstscene' && - data[i].topAbility.bundleName != 'com.example.actsamstestfirstscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamstestfirstscene') { + console.log("ActsAmsTestFirstScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsTestFirstScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } await featureAbility.startAbility( @@ -78,7 +69,10 @@ describe('ActsAmsTestFirstScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFirstScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); setTimeout(done(), 5000); }); @@ -90,65 +84,57 @@ describe('ActsAmsTestFirstScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_0100 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by Promise) */ it('Acts_Ams_test_0100', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - var info = await abilityManager.getAllRunningProcesses(); - console.info('Acts_Ams_test_0100 getAllRunningProcesses JSON String: ' + JSON.stringify(info)); + var info = await appManager.getProcessRunningInfos(); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_0100 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); setTimeout(timeout, 5000); }) + /* * @tc.number : Acts_Ams_test_1100 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by Promise) */ it('Acts_Ams_test_1100', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.moveMissionToTop(result[0].id); - console.info('Acts_Ams_test_1100 moveMissionToTop data [' + info + ']'); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_0100 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.moveMissionToFront(result[0].missionId); + console.info('Acts_Ams_test_1100 moveMissionToFront data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); @@ -156,209 +142,30 @@ describe('ActsAmsTestFirstScene', function () { /* * @tc.number : Acts_Ams_test_0300 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos + * @tc.name : getMissionInfos : Query Running Ability Mission Infos * @tc.desc : Query Running Ability Mission Infos(by Promise) */ it('Acts_Ams_test_0300', 0, async function (done) { var maxnum = 10; - var data = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - console.info('Acts_Ams_test_0300 queryRunningAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(2); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(data[i].topAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_0500 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos - * @tc.desc : Query Recent Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_0500', 0, async function (done) { - var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.info('Acts_Ams_test_0500 queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(2); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8100 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by Promise) - */ - it('Acts_Ams_test_8100', 0, async function (done) { - var info = await abilityManager.getActiveProcessInfos(); - console.info('Acts_Ams_test_8100 getActiveProcessInfos JSON String: ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9100 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_9100', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getActiveAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_9100 getActiveAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); expect(Array.isArray(data)).assertEqual(true); expect(data.length).assertEqual(2); for (var i = 0; i < data.length; i++) { + console.info('Acts_Ams_test_0300 getMissionInfos data[' + i + "]: " + JSON.stringify(data[i])); expect(typeof (data[i].missionId)).assertEqual("number"); expect(data[i].missionId).assertLarger(0); - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10100 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_10100', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getPreviousAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_10100 getPreviousAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(2); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].missionId)).assertEqual("number"); - expect(data[i].missionId).assertLarger(0); - - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); + expect(typeof (data[i].want)).assertEqual("object"); + expect(typeof (data[i].want.deviceId)).assertEqual("string"); + expect(typeof (data[i].want.bundleName)).assertEqual("string"); + expect(data[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(data[i].want.bundleName)).assertLarger(-1); + expect(typeof (data[i].want.abilityName)).assertEqual("string"); + expect(data[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(data[i].want.abilityName)).assertLarger(-1); + + expect(typeof (data[i].label)).assertEqual("string"); + expect(typeof (data[i].iconPath)).assertEqual("string"); } done(); setTimeout(timeout, 5000); @@ -366,14 +173,17 @@ describe('ActsAmsTestFirstScene', function () { /* * @tc.number : Acts_Ams_test_0700 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by Promise) */ it('Acts_Ams_test_0700', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.removeMission(result[0].id); - console.info('Acts_Ams_test_0700 removeMission data [' + info + ']'); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_0700 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.clearMission(result[0].missionId); + console.info('Acts_Ams_test_0700 clearMission data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); @@ -381,16 +191,19 @@ describe('ActsAmsTestFirstScene', function () { /* * @tc.number : Acts_Ams_test_11100 - * @tc.name : deleteMissions: delete Missions + * @tc.name : clearMissions: delete Missions * @tc.desc : delete Missions(by Promise) */ it('Acts_Ams_test_11100', 0, async function (done) { var maxnum = 10; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_11100 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } expect(result.length).assertEqual(1); - var missionID = result[0].id + 1; - var info = await abilityManager.deleteMissions([missionID]); - console.info('Acts_Ams_test_11100 deleteMissions data [' + info + ']'); + var missionID = result[0].missionId + 1; + var info = await missionManager.clearMission(missionID); + console.info('Acts_Ams_test_11100 clearMissions data [' + info + ']'); expect(info).assertLarger(0); done(); setTimeout(timeout, 5000); @@ -402,10 +215,10 @@ describe('ActsAmsTestFirstScene', function () { * @tc.desc : Kill Processes By BundleName(by Promise) */ it('Acts_Ams_test_1500', 0, async function (done) { - var info = await abilityManager.killProcessesByBundleName('com.ix.simulate.feature'); + var info = await appManager.killProcessesByBundleName('com.ix.simulate.feature'); console.info('Acts_Ams_test_1500 killProcessesByBundleName data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); }) -}) +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/Test.json b/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/Test.json index 8429b0324c1d1e9b1640aab2577257140ab8ab84..cf3b5c6e2b9a34eb75eea53b4e0b376a865f1e20 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/Test.json +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/Test.json @@ -2,7 +2,7 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "120000", + "test-timeout": "300000", "package": "com.example.actsamstestfourthscene", "shell-timeout": "60000" }, diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/default/pages/index/index.js index ded5295b9d4f023dba85ca970fd7153074861554..590bd0c3bf9215878b0bfcf03ff0955ef3786650 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index 7ca0d328296698e38b3eec0089c07242acc1ffeb..0fc802257d857bc5d0fa0620e68d66966c84df23 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestfourthscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,31 +12,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", "com.example.SimulateFeatureAbilityFir", - "com.example.VerifyActThirdAbility", - "com.example.VerifyIoThirdAbility", "com.example.actsamstestfourthscene.MainAbility", - "com.example.SimulateEntryAbilityFir" + "com.example.VerifyIoThirdAbility" ] var bundleNameList = [ @@ -48,25 +34,28 @@ var bundleNameList = [ "com.ohos.telephonydataability", "com.ohos.contactsdataability", "com.ix.simulate.feature", - "com.ix.verify.io", - "com.ix.simulate.entry", "com.example.actsamstestfourthscene", - "com.ix.verify.act" + "com.ix.verify.io" ] + describe('ActsAmsTestFourthScene', function () { console.info('----ActsAmsTestFourthScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsTestFourthScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamstestfourthscene' && - data[i].topAbility.bundleName != 'com.example.actsamstestfourthscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamstestfourthscene') { + console.log("ActsAmsTestFourthScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsTestFourthScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -83,8 +72,12 @@ describe('ActsAmsTestFourthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFourthScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -101,8 +94,12 @@ describe('ActsAmsTestFourthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFourthScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -119,8 +116,12 @@ describe('ActsAmsTestFourthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFourthScene VerifyActThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -137,7 +138,10 @@ describe('ActsAmsTestFourthScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestFourthScene SimulateEntryAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); setTimeout(done(), 5000); }); @@ -149,67 +153,28 @@ describe('ActsAmsTestFourthScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* - * @tc.number : Acts_Ams_test_4900 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.number : Acts_Ams_test_1700 + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by Promise) */ - it('Acts_Ams_test_4900', 0, async function (done) { + it('Acts_Ams_test_1700', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - var info = await abilityManager.getAllRunningProcesses(); - console.info('getAllRunningProcesses data length [' + info.length + ']'); - console.info('Acts_Ams_test_4900 getAllRunningProcesses JSON String: ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8400 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by Promise) - */ - it('Acts_Ams_test_8400', 0, async function (done) { - var info = await abilityManager.getActiveProcessInfos(); - console.info('Acts_Ams_test_8400 getActiveProcessInfos JSON String: ' + JSON.stringify(info)); + var info = await appManager.getProcessRunningInfos(); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_1700 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); @@ -226,205 +191,33 @@ describe('ActsAmsTestFourthScene', function () { }) /* - * @tc.number : Acts_Ams_test_5300 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos + * @tc.number : Acts_Ams_test_2100 + * @tc.name : getMissionInfos : Query Recent Ability Mission Infos * @tc.desc : Query Recent Ability Mission Infos(by Promise) */ - it('Acts_Ams_test_5300', 0, async function (done) { - var maxnum = 100; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.info(' queryRecentAbilityMissionInfos data length [' + data.length + ']'); + it('Acts_Ams_test_2100', 0, async function (done) { + var maxnum = 20; + var data = await missionManager.getMissionInfos("", maxnum); + console.info('Acts_Ams_test_2100 getMissionInfos error.code : \ + ' + error.code + ',data length [' + data.length + ']'); expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(4); - for (var i = 0; i < data.length; i++) { - console.info('Acts_Ams_test_5300 queryRecentAbilityMissionInfos id: \ - ' + data[i].id + ' baseAbility.deviceId: \ - ' + data[i].baseAbility.deviceId + ' baseAbility.bundleName: \ - ' + data[i].baseAbility.bundleName + ' baseAbility.abilityName: \ - ' + data[i].baseAbility.abilityName + ' topAbility.deviceId: \ - ' + data[i].topAbility.deviceId + ' topAbility.bundleName: \ - ' + data[i].topAbility.bundleName + ' topAbility.abilityName: \ - ' + data[i].topAbility.abilityName + ' missionDescription.label: \ - ' + data[i].missionDescription.label + ' missionDescription.iconPath: \ - ' + data[i].missionDescription.iconPath); - - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_5100 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos - * @tc.desc : Query Running Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_5100', 0, async function (done) { - var maxnum = 30; - var data = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - console.info('queryRunningAbilityMissionInfos data length [' + data.length + ']'); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(4); - for (var i = 0; i < data.length; i++) { - console.info('Acts_Ams_test_5100 queryRunningAbilityMissionInfos id: \ - ' + data[i].id + ' baseAbility.deviceId: \ - ' + data[i].baseAbility.deviceId + ' baseAbility.bundleName: \ - ' + data[i].baseAbility.bundleName + ' baseAbility.abilityName: \ - ' + data[i].baseAbility.abilityName + ' topAbility.deviceId: \ - ' + data[i].topAbility.deviceId + ' topAbility.bundleName: \ - ' + data[i].topAbility.bundleName + ' topAbility.abilityName: \ - ' + data[i].topAbility.abilityName + ' missionDescription.label: \ - ' + data[i].missionDescription.label + ' missionDescription.iconPath: \ - ' + data[i].missionDescription.iconPath); - - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9400 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_9400', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getActiveAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_9400 getActiveAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(4); + expect(data.length).assertEqual(5); for (var i = 0; i < data.length; i++) { + console.info('Acts_Ams_test_2100 getMissionInfos data[' + i + "]: " + JSON.stringify(data[i])); expect(typeof (data[i].missionId)).assertEqual("number"); expect(data[i].missionId).assertLarger(0); - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10400 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_10400', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getPreviousAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_10400 getPreviousAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(4); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].missionId)).assertEqual("number"); - expect(data[i].missionId).assertLarger(0); - - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); + expect(typeof (data[i].want)).assertEqual("object"); + expect(typeof (data[i].want.deviceId)).assertEqual("string"); + expect(typeof (data[i].want.bundleName)).assertEqual("string"); + expect(data[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(data[i].want.bundleName)).assertLarger(-1); + expect(typeof (data[i].want.abilityName)).assertEqual("string"); + expect(data[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(data[i].want.abilityName)).assertLarger(-1); + + expect(typeof (data[i].label)).assertEqual("string"); + expect(typeof (data[i].iconPath)).assertEqual("string"); } done(); setTimeout(timeout, 5000); @@ -437,9 +230,11 @@ describe('ActsAmsTestFourthScene', function () { */ it('Acts_Ams_test_5500', 0, async function (done) { var maxnum = 30; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.removeMission(result[0].id); - console.info('Acts_Ams_test_5500 removeMission data [' + info + ']'); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_5500 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await abilityManager.clearMission(result[0].id); expect(typeof (info)).assertEqual("number"); expect(info).assertEqual(0); done(); @@ -448,31 +243,35 @@ describe('ActsAmsTestFourthScene', function () { /* * @tc.number : Acts_Ams_test_5900 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by Promise) */ it('Acts_Ams_test_5900', 0, async function (done) { - var maxnum = 30; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.moveMissionToTop(result[0].id); - console.info('Acts_Ams_test_5900 moveMissionToTop data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); + var maxnum = 20; + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_5900 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.moveMissionToFront(result[0].missionId); + console.info('Acts_Ams_test_5900 moveMissionToFront data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); }) /* - * @tc.number : Acts_Ams_test_6100 - * @tc.name : removeMissions: Remove Missions - * @tc.desc : Remove Missions(by Promise) + * @tc.number : Acts_Ams_test_2100 + * @tc.name : clearMission : Remove Mission + * @tc.desc : Remove Mission(by Promise) */ it('Acts_Ams_test_6100', 0, async function (done) { - var maxnum = 30; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.removeMissions([result[0].id, result[1].id]); - console.info('Acts_Ams_test_6100 removeMissions data [' + info + ']'); - expect(typeof (info)).assertEqual("number"); + var maxnum = 20; + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_6100 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.clearAllMissions(); + console.info('Acts_Ams_test_6100 clearAllMissions data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); @@ -484,7 +283,7 @@ describe('ActsAmsTestFourthScene', function () { * @tc.desc : Kill Processes By BundleName(by Promise) */ it('Acts_Ams_test_6300', 0, async function (done) { - var info = await abilityManager.killProcessesByBundleName('xxxxxxxxxxxx'); + var info = await appManager.killProcessesByBundleName('xxxxxxxxxxxx'); console.info('Acts_Ams_test_6300 killProcessesByBundleName data [' + info + ']'); expect(typeof (info)).assertEqual("number"); expect(info).assertEqual(2097215); diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/Test.json b/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/Test.json index f889d08f761ccaabe63f8a0ed329490f9fa519d7..2a9a90561bebb0b996de85ebf4eab2367d244f0f 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/Test.json +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/Test.json @@ -2,7 +2,7 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "120000", + "test-timeout": "300000", "package": "com.example.actsamstestsecondscene", "shell-timeout": "600000" }, diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/default/pages/index/index.js index ded5295b9d4f023dba85ca970fd7153074861554..590bd0c3bf9215878b0bfcf03ff0955ef3786650 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index 5a52dbb6cbcb8c66416042b3722ac4c177ff5604..37c078535d6766b063a9b4f980a8d8546b11dbd1 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestsecondscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,23 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", @@ -54,16 +42,20 @@ describe('ActsAmsTestSecondScene', function () { console.info('----ActsAmsTestSecondScene----'); beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsTestSecondScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamstestsecondscene' && - data[i].topAbility.bundleName != 'com.example.actsamstestsecondscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamstestsecondscene') { + console.log("ActsAmsTestSecondScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsTestSecondScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -80,8 +72,12 @@ describe('ActsAmsTestSecondScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestSecondScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -98,7 +94,10 @@ describe('ActsAmsTestSecondScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestSecondScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); setTimeout(done(), 5000); }); @@ -110,50 +109,39 @@ describe('ActsAmsTestSecondScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_1700 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by Promise) */ it('Acts_Ams_test_1700', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - var info = await abilityManager.getAllRunningProcesses(); - console.info('Acts_Ams_test_1700 getAllRunningProcesses JSON String: ' + JSON.stringify(info)); + var info = await appManager.getProcessRunningInfos(); + console.info('Acts_Ams_test_1700 getProcessRunningInfos JSON String: ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_1700 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); } done(); setTimeout(timeout, 5000); @@ -161,14 +149,17 @@ describe('ActsAmsTestSecondScene', function () { /* * @tc.number : Acts_Ams_test_2700 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by Promise) */ it('Acts_Ams_test_2700', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.moveMissionToTop(result[0].id); - console.info('Acts_Ams_test_2700 moveMissionToTop data [' + info + ']'); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_2700 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.moveMissionToFront(result[0].missionId); + console.info('Acts_Ams_test_2700 moveMissionToFront data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); @@ -176,240 +167,49 @@ describe('ActsAmsTestSecondScene', function () { /* * @tc.number : Acts_Ams_test_1900 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos + * @tc.name : getMissionInfos : Query Running Ability Mission Infos * @tc.desc : Query Running Ability Mission Infos(by Promise) */ it('Acts_Ams_test_1900', 0, async function (done) { var maxnum = 20; - var data = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - console.info('queryRunningAbilityMissionInfos data length [' + data.length + ']'); - console.info('Acts_Ams_test_1900 queryRunningAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_2100 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos - * @tc.desc : Query Recent Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_2100', 0, async function (done) { - var maxnum = 20; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.info(' queryRecentAbilityMissionInfos data length [' + data.length + ']'); - console.info('Acts_Ams_test_2100 queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8200 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by Promise) - */ - it('Acts_Ams_test_8200', 0, async function (done) { - var info = await abilityManager.getActiveProcessInfos(); - console.info('Acts_Ams_test_8200 getActiveProcessInfos JSON String: ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9200 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_9200', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getActiveAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_9200 getActiveAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.info('Acts_Ams_test_1900 getMissionInfos data ' + JSON.stringify(data)); expect(Array.isArray(data)).assertEqual(true); expect(data.length).assertEqual(3); for (var i = 0; i < data.length; i++) { + console.info('Acts_Ams_test_1900 getMissionInfos data[' + i + "]: " + JSON.stringify(data[i])); expect(typeof (data[i].missionId)).assertEqual("number"); expect(data[i].missionId).assertLarger(0); - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); + expect(typeof (data[i].want)).assertEqual("object"); + expect(typeof (data[i].want.deviceId)).assertEqual("string"); + expect(typeof (data[i].want.bundleName)).assertEqual("string"); + expect(data[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(data[i].want.bundleName)).assertLarger(-1); + expect(typeof (data[i].want.abilityName)).assertEqual("string"); + expect(data[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(data[i].want.abilityName)).assertLarger(-1); + + expect(typeof (data[i].label)).assertEqual("string"); + expect(typeof (data[i].iconPath)).assertEqual("string"); } done(); setTimeout(timeout, 5000); }) - /* - * @tc.number : Acts_Ams_test_10200 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_10200', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getPreviousAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_10200 getPreviousAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].missionId)).assertEqual("number"); - expect(data[i].missionId).assertLarger(0); - - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_11200 - * @tc.name : deleteMissions: delete Missions - * @tc.desc : delete Missions(by Promise) - */ - it('Acts_Ams_test_11200', 0, async function (done) { - var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.deleteMissions([result[0].id]); - console.info('Acts_Ams_test_11200 deleteMissions data [' + info + ']'); - expect(info).assertEqual(0); - done(); - setTimeout(timeout, 5000); - }) - /* * @tc.number : Acts_Ams_test_2100 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by Promise) */ it('Acts_Ams_test_2300', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.removeMission(result[0].id); - console.info('Acts_Ams_test_2300 removeMission data [' + info + ']'); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_2300 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.clearMission(result[0].missionId); + console.info('Acts_Ams_test_2300 clearMission data [' + info + ']'); expect(info).assertEqual(0); done(); setTimeout(timeout, 5000); @@ -421,11 +221,10 @@ describe('ActsAmsTestSecondScene', function () { * @tc.desc : Kill Processes By BundleName(by Promise) */ it('Acts_Ams_test_3100', 0, async function (done) { - var info = await abilityManager.killProcessesByBundleName('XXXXXXXXXXXX'); + var info = await appManager.killProcessesByBundleName('XXXXXXXXXXXX'); console.info('Acts_Ams_test_3100 killProcessesByBundleName data [' + info + ']'); expect(info).assertEqual(2097215); done(); setTimeout(timeout, 5000); }) -}) - +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/Test.json b/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/Test.json index cd2c04356e443c5de382ab0c7c3e7954ed72ba6a..629d269911692abfa2847d5990a4785a1dd4ab53 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/Test.json +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/Test.json @@ -2,7 +2,7 @@ "description": "Configuration for hjunit demo Tests", "driver": { "type": "JSUnitTest", - "test-timeout": "120000", + "test-timeout": "300000", "package": "com.example.actsamstestthirdscene", "shell-timeout": "600000" }, diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/default/pages/index/index.js index ded5295b9d4f023dba85ca970fd7153074861554..590bd0c3bf9215878b0bfcf03ff0955ef3786650 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/default/pages/index/index.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/default/pages/index/index.js @@ -39,6 +39,7 @@ export default { const configService = core.getDefaultService('config') configService.setConfig(this) + this.timeout = 10000 require('../../../test/List.test') core.execute() diff --git a/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js index 6dd0bdb08376a0e48c72be6b145c1e2be876ce18..17677f5903c57a561066f19a60121f6688299c5e 100644 --- a/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/actsamstestthirdscene/entry/src/main/js/test/MangerAbilityJsunit.test.js @@ -12,23 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import featureAbility from '@ohos.ability.featureability' +import missionManager from '@ohos.application.missionManager' +import appManager from "@ohos.application.appManager" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -var WeightReasonCode = { - REASON_UNKNOWN: 0, - WEIGHT_FOREGROUND: 100, - WEIGHT_FOREGROUND_SERVICE: 125, - WEIGHT_VISIBLE: 200, - WEIGHT_PERCEPTIBLE: 230, - WEIGHT_SERVICE: 300, - WEIGHT_TOP_SLEEPING: 325, - WEIGHT_CANT_SAVE_STATE: 350, - WEIGHT_CACHED: 400, - WEIGHT_GONE: 1000 -} - var abilityNameList = [ "com.ohos.launcher.MainAbility", "com.ohos.callui.ServiceAbility", @@ -54,16 +42,20 @@ describe('ActsAmsTestThirdScene', function () { beforeAll(async function (done) { var maxnum = 10; - var flag = 1; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.log('queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.log('ActsAmsTestThirdScene beforeAll getMissionInfos data: ' + JSON.stringify(data)); for (var i = 0; i < data.length; i++) { - if (data[i].baseAbility.bundleName != 'com.example.actsamstestthirdscene' && - data[i].topAbility.bundleName != 'com.example.actsamstestthirdscene') { - var info = abilityManager.removeMission(data[i].id); - console.log(' removeMission data [' + info + ']'); + if (data[i].want.bundleName != 'com.example.actsamstestthirdscene') { + console.log("ActsAmsTestThirdScene, missionId: " + data[i].missionId) + missionManager.clearMission(data[i].missionId, + (error, info) => { + console.info('ActsAmsTestThirdScene beforeAll clearMission error.code \ + ' + error.code + ', want.bundleName:' + data[i].want.bundleName); + } + ); } } + await featureAbility.startAbility( { want: @@ -80,8 +72,12 @@ describe('ActsAmsTestThirdScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestThirdScene SimulateFeatureAbilityFir start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); + await featureAbility.startAbility( { want: @@ -98,7 +94,10 @@ describe('ActsAmsTestThirdScene', function () { parameters: {}, }, - }, + }, (error, data) => { + console.info('ActsAmsTestThirdScene VerifyIoThirdAbility start, error.code \ + ' + error.code + ', data length [' + data.length + ']'); + } ); setTimeout(done(), 5000); }); @@ -110,92 +109,39 @@ describe('ActsAmsTestThirdScene', function () { } function sleep(delay) { - var start = (new Date()).getTime(); - var endTime = (new Date()).getTime(); - for (let index = 1; index > 0; index++) { - if (endTime - startTime > delay) { - break; - } else { - endTime = (new Date()).getTime(); - } + var start = new Date().getTime(); + while (true) { + if (new Date().getTime() - start > delay) { + break; + } } } /* * @tc.number : Acts_Ams_test_3300 - * @tc.name : getAllRunningProcesses : Get All Running Processes Info + * @tc.name : getProcessRunningInfos : Get All Running Processes Info * @tc.desc : Get All Running Processes Info(by Promise) */ it('Acts_Ams_test_3300', 0, async function (done) { console.info("sleep begin"); sleep(5000); console.info("sleep end"); - var info = await abilityManager.getAllRunningProcesses(); - console.info('Acts_Ams_test_3300 getAllRunningProcesses JSON String: ' + JSON.stringify(info)); + var info = await appManager.getProcessRunningInfos(); + console.info('Acts_Ams_test_3300 getProcessRunningInfos JSON String: ' + JSON.stringify(info)); expect(Array.isArray(info)).assertEqual(true); expect(info.length).assertLarger(0); for (var i = 0; i < info.length; i++) { + console.info('Acts_Ams_test_3300 getProcessRunningInfo[' + i + "]: " + JSON.stringify(info[i])); expect(typeof (info[i].pid)).assertEqual("number"); expect(info[i].pid).assertLarger(0); expect(typeof (info[i].processName)).assertEqual("string"); expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].pkgList)).assertEqual(true); - expect(info[i].pkgList.length).assertEqual(0); + expect(Array.isArray(info[i].bundleNames)).assertEqual(true); + expect(info[i].bundleNames.length).assertEqual(0); expect(typeof (info[i].uid)).assertEqual("number"); expect(info[i].uid).assertLarger(0); - - expect(typeof (info[i].lastMemoryLevel)).assertEqual("number"); - expect(info[i].lastMemoryLevel).assertEqual(1); - - expect(typeof (info[i].weight)).assertEqual("number"); - expect(info[i].weight).assertEqual(-1); - - expect(typeof (info[i].weightReasonCode)).assertEqual("number"); - expect(info[i].weightReasonCode).assertEqual(WeightReasonCode.REASON_UNKNOWN); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_3500 - * @tc.name : queryRunningAbilityMissionInfos : Query Running Ability Mission Infos - * @tc.desc : Query Running Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_3500', 0, async function (done) { - var maxnum = 20; - var data = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - console.info('Acts_Ams_test_3500 queryRunningAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); } done(); setTimeout(timeout, 5000); @@ -203,166 +149,31 @@ describe('ActsAmsTestThirdScene', function () { /* * @tc.number : Acts_Ams_test_3700 - * @tc.name : queryRecentAbilityMissionInfos : Query Recent Ability Mission Infos + * @tc.name : getMissionInfos : Query Recent Ability Mission Infos * @tc.desc : Query Recent Ability Mission Infos(by Promise) */ it('Acts_Ams_test_3700', 0, async function (done) { var maxnum = 20; - var flag = 2; - var data = await abilityManager.queryRecentAbilityMissionInfos(maxnum, flag); - console.info('Acts_Ams_test_3700 queryRecentAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].id)).assertEqual("number"); - expect(data[i].id).assertLarger(0); - - expect(typeof (data[i].baseAbility)).assertEqual("object"); - expect(typeof (data[i].baseAbility.deviceId)).assertEqual("string"); - expect(data[i].baseAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].baseAbility.bundleName)).assertEqual("string"); - expect(data[i].baseAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].baseAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].baseAbility.abilityName)).assertEqual("string"); - expect(data[i].baseAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].baseAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - - expect(typeof (data[i].missionDescription)).assertEqual("object"); - expect(typeof (data[i].missionDescription.label)).assertEqual("string"); - expect(typeof (data[i].missionDescription.iconPath)).assertEqual("string"); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_8300 - * @tc.name : getActiveProcessInfos : Get All Active Processes Info - * @tc.desc : Get All Active Processes Info(by Promise) - */ - it('Acts_Ams_test_8300', 0, async function (done) { - var info = await abilityManager.getActiveProcessInfos(); - console.info('Acts_Ams_test_8300 getActiveProcessInfos JSON String: ' + JSON.stringify(info)); - expect(Array.isArray(info)).assertEqual(true); - expect(info.length).assertLarger(0); - for (var i = 0; i < info.length; i++) { - expect(typeof (info[i].pid)).assertEqual("number"); - expect(info[i].pid).assertLarger(0); - - expect(typeof (info[i].processName)).assertEqual("string"); - expect(info[i].processName.length).assertLarger(0); - expect(Array.isArray(info[i].bundleNames)).assertEqual(true); - expect(info[i].bundleNames.length).assertEqual(0); - - expect(typeof (info[i].uid)).assertEqual("number"); - expect(info[i].uid).assertLarger(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_9300 - * @tc.name : getActiveAbilityMissionInfos : Get Active Ability Mission Infos - * @tc.desc : Get Active Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_9300', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getActiveAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_9300 getActiveAbilityMissionInfos data ' + JSON.stringify(data)); + var data = await missionManager.getMissionInfos("", maxnum); + console.info('Acts_Ams_test_3700 getMissionInfos data ' + JSON.stringify(data)); expect(Array.isArray(data)).assertEqual(true); expect(data.length).assertEqual(3); for (var i = 0; i < data.length; i++) { + console.info('Acts_Ams_test_3700 getMissionInfos data[' + i + "]: " + JSON.stringify(data[i])); expect(typeof (data[i].missionId)).assertEqual("number"); expect(data[i].missionId).assertLarger(0); - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); - } - done(); - setTimeout(timeout, 5000); - }) - - /* - * @tc.number : Acts_Ams_test_10300 - * @tc.name : getPreviousAbilityMissionInfos : Get Previous Ability Mission Infos - * @tc.desc : Get Previous Ability Mission Infos(by Promise) - */ - it('Acts_Ams_test_10300', 0, async function (done) { - var upperLimit = 20; - var data = await abilityManager.getPreviousAbilityMissionInfos(upperLimit); - console.info('Acts_Ams_test_10300 getPreviousAbilityMissionInfos data ' + JSON.stringify(data)); - expect(Array.isArray(data)).assertEqual(true); - expect(data.length).assertEqual(3); - for (var i = 0; i < data.length; i++) { - expect(typeof (data[i].missionId)).assertEqual("number"); - expect(data[i].missionId).assertLarger(0); - - expect(typeof (data[i].bottomAbility)).assertEqual("object"); - expect(typeof (data[i].bottomAbility.deviceId)).assertEqual("string"); - expect(data[i].bottomAbility.deviceId.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.bundleName)).assertEqual("string"); - expect(data[i].bottomAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].bottomAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.abilityName)).assertEqual("string"); - expect(data[i].bottomAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].bottomAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].bottomAbility.uri)).assertEqual("string"); - expect(data[i].bottomAbility.uri.length).assertEqual(0); - expect(typeof (data[i].bottomAbility.shortName)).assertEqual("string"); - expect(data[i].bottomAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].topAbility)).assertEqual("object"); - expect(typeof (data[i].topAbility.deviceId)).assertEqual("string"); - expect(typeof (data[i].topAbility.bundleName)).assertEqual("string"); - expect(data[i].topAbility.bundleName.length).assertLarger(0); - expect(bundleNameList.indexOf(data[i].topAbility.bundleName)).assertLarger(-1); - expect(typeof (data[i].topAbility.abilityName)).assertEqual("string"); - expect(data[i].topAbility.abilityName.length).assertLarger(0); - expect(abilityNameList.indexOf(data[i].topAbility.abilityName)).assertLarger(-1); - expect(typeof (data[i].topAbility.uri)).assertEqual("string"); - expect(data[i].topAbility.uri.length).assertEqual(0); - expect(typeof (data[i].topAbility.shortName)).assertEqual("string"); - expect(data[i].topAbility.shortName.length).assertEqual(0); - - expect(typeof (data[i].windowMode)).assertEqual("number"); - expect(data[i].windowMode).assertEqual(0); + expect(typeof (data[i].want)).assertEqual("object"); + expect(typeof (data[i].want.deviceId)).assertEqual("string"); + expect(typeof (data[i].want.bundleName)).assertEqual("string"); + expect(data[i].want.bundleName.length).assertLarger(0); + expect(bundleNameList.indexOf(data[i].want.bundleName)).assertLarger(-1); + expect(typeof (data[i].want.abilityName)).assertEqual("string"); + expect(data[i].want.abilityName.length).assertLarger(0); + expect(abilityNameList.indexOf(data[i].want.abilityName)).assertLarger(-1); + + expect(typeof (data[i].label)).assertEqual("string"); + expect(typeof (data[i].iconPath)).assertEqual("string"); } done(); setTimeout(timeout, 5000); @@ -370,45 +181,54 @@ describe('ActsAmsTestThirdScene', function () { /* * @tc.number : Acts_Ams_test_3900 - * @tc.name : removeMission : Remove Mission + * @tc.name : clearMission : Remove Mission * @tc.desc : Remove Mission(by Promise) */ it('Acts_Ams_test_3900', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.removeMission(result[1].id); - console.info('Acts_Ams_test_3900 removeMission data [' + info + ']'); - expect(info).assertEqual(0); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_3900 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.clearMission(result[1].missionId); + console.info('Acts_Ams_test_3900 clearMission data [' + info + ']'); + expect(info.code).assertEqual(0); done(); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_4300 - * @tc.name : moveMissionToTop : Move Mission To Top + * @tc.name : moveMissionToFront : Move Mission To Top * @tc.desc : Move Mission To Top(by Promise) */ it('Acts_Ams_test_4300', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.moveMissionToTop(result[0].id); - console.info('Acts_Ams_test_4300 moveMissionToTop data [' + info + ']'); - expect(info).assertEqual(0); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_4300 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.moveMissionToFront(result[0].missionId); + console.info('Acts_Ams_test_4300 moveMissionToFront data [' + info + ']'); + expect(info.code).assertEqual(0); done(); setTimeout(timeout, 5000); }) /* * @tc.number : Acts_Ams_test_4500 - * @tc.name : removeMissions: Remove Missions + * @tc.name : clearMissions: Remove Missions * @tc.desc : Remove Missions(by Promise) */ it('Acts_Ams_test_4500', 0, async function (done) { var maxnum = 20; - var result = await abilityManager.queryRunningAbilityMissionInfos(maxnum); - var info = await abilityManager.removeMissions([result[0].id]); - console.info('Acts_Ams_test_4500 removeMissions data [' + info + ']'); - expect(info).assertEqual(0); + var result = await missionManager.getMissionInfos("", maxnum); + for (var i = 0; i < result.length; i++) { + console.info('Acts_Ams_test_4500 getMissionInfos result[' + i + "]: " + JSON.stringify(result[i])); + } + var info = await missionManager.clearMission(result[0].missionId); + console.info('Acts_Ams_test_4500 clearMission data [' + info + ']'); + expect(info.code).assertEqual(0); done(); setTimeout(timeout, 5000); }) @@ -419,11 +239,10 @@ describe('ActsAmsTestThirdScene', function () { * @tc.desc : Kill Processes By BundleName(by Promise) */ it('Acts_Ams_test_4700', 0, async function (done) { - var info = await abilityManager.killProcessesByBundleName('XXXXXXXX'); + var info = await appManager.killProcessesByBundleName('XXXXXXXX'); console.info('Acts_Ams_test_4700 killProcessesByBundleName data [' + info + ']'); - expect(info).assertEqual(2097215); + expect(info.code).assertEqual(2097215); done(); setTimeout(timeout, 5000); }) -}) - +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/Test.json b/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/Test.json index 7ac78910a917151702c06e3c5dc79a842b8ab169..a6b680b41c72c41310edb2fb8ba9f6a3e039b819 100644 --- a/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/Test.json +++ b/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/Test.json @@ -3,7 +3,7 @@ "driver": { "type": "JSUnitTest", "test-timeout": "120000", - "package": "com.ohos.launcher", + "package": "com.example.myapplication11", "abilityName": "com.ohos.launcherSed11.MainAbility", "shell-timeout": "600000" }, diff --git a/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/config.json b/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/config.json index ca3e263df7b3475d5ee35dc4da26d6231af80f43..3d20621699b918849c37d9dfbc93f24d3a955793 100644 --- a/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/config.json +++ b/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/config.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.ohos.launcher", + "bundleName": "com.example.myapplication11", "vendor": "example", "version": { "code": 1000000, diff --git a/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/js/test/MangerAbilityJsunit.test.js index 37ddae73e5795969c05b96599c8f352cce179426..a69c29d1ead901bef68abfc0c1b37ebc6139ae3b 100644 --- a/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/clearmissionscallback/src/main/js/test/MangerAbilityJsunit.test.js @@ -13,7 +13,7 @@ * limitations under the License. */ import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import missionManager from '@ohos.application.missionManager' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' describe('ActsAmsCallBackSixth Scene', function () { @@ -51,7 +51,7 @@ describe('ActsAmsCallBackSixth Scene', function () { * @tc.desc : Clear Missions(by CallBack) */ it('Acts_Ams_test_12200', 0, async function (done) { - abilityManager.clearMissions( + missionManager.clearAllMissions( (error,info) => { console.info('Acts_Ams_test_12200 clearMissions error.code ' + error.code + ',data [' + info + ']' ); expect(typeof(info)).assertEqual("number"); @@ -59,4 +59,4 @@ describe('ActsAmsCallBackSixth Scene', function () { }); done(); }) -}) +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/Test.json b/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/Test.json index b13ed4b357308cc813fa04ebdefd19c4edfbf4fb..cd28daa3f6802d671f0c40555e53736bfbd3f370 100644 --- a/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/Test.json +++ b/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/Test.json @@ -3,7 +3,7 @@ "driver": { "type": "JSUnitTest", "test-timeout": "120000", - "package": "com.ohos.launcher", + "package": "com.example.myapplication111", "abilityName": "com.ohos.launcherSed111.MainAbility", "shell-timeout": "600000" }, diff --git a/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/config.json b/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/config.json index 572b3d75735927d6767690f6c3197270bf3fb660..0eece2ae89479755d13673d82ad12ee703831865 100644 --- a/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/config.json +++ b/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/config.json @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.ohos.launcher", + "bundleName": "com.example.myapplication111", "vendor": "example", "version": { "code": 1000000, diff --git a/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/js/test/MangerAbilityJsunit.test.js b/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/js/test/MangerAbilityJsunit.test.js index 7e9feae45a3ba88089459a283d5423fc3eb962b3..8609e3a4097d611fe33aa9bf88b5034caf18ba39 100644 --- a/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/js/test/MangerAbilityJsunit.test.js +++ b/aafwk/aafwk_standard/abilitymanager/clearmissionspromise/src/main/js/test/MangerAbilityJsunit.test.js @@ -13,7 +13,7 @@ * limitations under the License. */ import featureAbility from '@ohos.ability.featureAbility' -import abilityManager from '@ohos.app.abilityManager' +import missionManager from '@ohos.application.missionManager' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' describe('ActsAmsCallBackSixth Scene', function () { @@ -51,10 +51,10 @@ describe('ActsAmsCallBackSixth Scene', function () { * @tc.desc : Clear Missions(by Promise) */ it('Acts_Ams_test_12100', 0, async function (done) { - var info = await abilityManager.clearMissions(); + var info = await missionManager.clearAllMissions(); console.info('Acts_Ams_test_12100 clearMissions data [' + info + ']'); expect(typeof(info)).assertEqual("number"); expect(info).assertEqual(0); done(); }) -}) +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/BUILD.gn b/aafwk/aafwk_standard/actsabilitymanageretstest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0d799ef4ee841395559d3c59fb524fdf04b0570c --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 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("ActsAbilityManagerEtsTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_ets_assets", + ":hjs_demo_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAbilityManagerEtsTest" +} +ohos_js_assets("hjs_demo_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("hjs_demo_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/Test.json b/aafwk/aafwk_standard/actsabilitymanageretstest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..6a84fb1bc2651c4320e869a3990bc98ce5ca1b28 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for aceceshi Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "600000", + "package": "com.ohos.acecollaboration", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAbilityManagerEtsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/config.json b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..0fb6c3d49860110029fe38061ee4fbbc8a236fe3 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/config.json @@ -0,0 +1,159 @@ +{ + "app": { + "bundleName": "com.ohos.acecollaboration", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.acecollaboration", + "name": ".MyApplication", + "mainAbility": "com.ohos.acecollaboration.MainAbility", + "deviceType": [ + "phone" + ], + "reqPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO" + } + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "srcPath": "MainAbility", + "srcLanguage": "ets", + "name": "com.ohos.acecollaboration.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "orientation": "unspecified", + "srcPath": "MainAbility2", + "name": ".MainAbility2", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability2", + "formsEnabled": false, + "label": "$string:entry_MainAbility2", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:description_serviceability", + "type": "service" + }, + { + "srcPath": "ServiceAbility2", + "name": ".ServiceAbility2", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:description_serviceability2", + "type": "service" + }, + { + "srcPath": "ServiceAbility3", + "name": ".ServiceAbility3", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:description_serviceability3", + "type": "service" + }, + { + "srcPath": "ServiceAbility4", + "name": ".ServiceAbility4", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:description_serviceability4", + "type": "service" + }, + { + "srcPath": "ServiceAbility5", + "name": ".ServiceAbility5", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:description_serviceability5", + "type": "service" + }, + { + "srcPath": "ServiceAbility6", + "name": ".ServiceAbility6", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:description_serviceability6", + "type": "service" + }, + { + "srcPath": "ServiceAbility7", + "name": ".ServiceAbility7", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:description_serviceability7", + "type": "service" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": "MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility2", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "defPermissions": [ + { + "name": "com.ohos.acecollaboration.DataAbilityShellProvider.PROVIDER" + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..5d603333c7bf5167e7d1d3ead6c9daa9c4b2862d --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2021 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. + */ +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a4ac0111471b4f1f725a67debb3f8d9fa2e80fa4 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,172 @@ +/** + * Copyright (c) 2021 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 file from '@system.file'; +import {Core, ExpectExtend, ReportExtend} from "deccjsunit/index.ets"; +import testsuite from "../test/List.test.ets"; +import featureAbility from "@ohos.ability.featureAbility"; + +async function startService2() { + var str = { + "want": { + "bundleName": "com.ohos.acecollaboration", + "abilityName": "com.ohos.acecollaboration.ServiceAbility2", + }, + }; + var data = featureAbility.startAbility(str); + console.info('particleAbility_connectAbility_test_0100 startAbility succeeded: ' + JSON.stringify(data)); +} +async function startService3() { + var str = { + "want": { + "bundleName": "com.ohos.acecollaboration", + "abilityName": "com.ohos.acecollaboration.ServiceAbility3", + }, + }; + var data = featureAbility.startAbility(str); + console.info('particleAbility_connectAbility_test_0200 startAbility succeeded: ' + JSON.stringify(data)); +} +async function startService4() { + var str = { + "want": { + "bundleName": "com.ohos.acecollaboration", + "abilityName": "com.ohos.acecollaboration.ServiceAbility4", + }, + }; + var data = featureAbility.startAbility(str); + console.info('particleAbility_connectAbility_test_0300 startAbility succeeded: ' + JSON.stringify(data)); +} +async function startService5() { + var str = { + "want": { + "bundleName": "com.ohos.acecollaboration", + "abilityName": "com.ohos.acecollaboration.ServiceAbility5", + }, + }; + var data = featureAbility.startAbility(str); + console.info('particleAbility_connectAbility_test_0400 startAbility succeeded: ' + JSON.stringify(data)); +} +async function startService6(){ + var str = { + "want": { + "bundleName": "com.ohos.acecollaboration", + "abilityName": "com.ohos.acecollaboration.ServiceAbility6", + }, + }; + var data = featureAbility.startAbility(str); + console.info('particleAbility_connectAbility_test_0500 startAbility succeeded: ' + JSON.stringify(data)); +} +async function startService7(){ + var str = { + "want": { + "bundleName": "com.ohos.acecollaboration", + "abilityName": "com.ohos.acecollaboration.ServiceAbility7", + }, + }; + var data = featureAbility.startAbility(str); + console.info('particleAbility_connectAbility_test_0600 startAbility succeeded: ' + JSON.stringify(data)); +} + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('ACE ETS TEST 组件协同') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button('disconnectAbility_promise') + .fontSize(40) + .height(40) + .margin({ top: 20 }) + .fontWeight(FontWeight.Bold) + .onClick(() => { + startService2(); + }); + Button('disconnectAbility_callback') + .fontSize(40) + .height(40) + .margin({ top: 20 }) + .fontWeight(FontWeight.Bold) + .onClick(() => { + startService3(); + }); + Button('connectotherAbility') + .fontSize(40) + .height(40) + .margin({ top: 20 }) + .fontWeight(FontWeight.Bold) + .onClick(() => { + startService4(); + }); + Button('connectnull') + .fontSize(40) + .height(40) + .margin({ top: 20 }) + .fontWeight(FontWeight.Bold) + .onClick(() => { + startService5(); + }); + Button('connecterror') + .fontSize(40) + .height(40) + .margin({top:20}) + .fontWeight(FontWeight.Bold) + .onClick(() => { + startService6(); + }); + Button('connectAPI8') + .fontSize(40) + .height(40) + .margin({top:20}) + .fontWeight(FontWeight.Bold) + .onClick(() => { + startService7(); + }); + + } + .width('100%') + .height('100%') + } +} + diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/ContextJsunit.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/ContextJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bcf072662fb6f4c67f9e3d538ea2c8800f4a1de6 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/ContextJsunit.test.ets @@ -0,0 +1,249 @@ +/** + * Copyright (c) 2021 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 featureAbility from '@ohos.ability.featureAbility' +import {describe, beforeEach, afterEach, it, expect} from "deccjsunit/index.ets"; +import Utils from './Utils'; + +export default function contextJsunit() { + describe('appInfoTest', function () { + beforeEach(async function (done) { + console.info("context before each called"); + done() + }); + + afterEach(async function () { + await Utils.sleep(2000); + console.info("context after each called"); + }); + + /* + * @tc.number: context_getCacheDir_test_0100 + * @tc.name: getCacheDir : Obtains the Cache directory on internal storage. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it("context_getCacheDir_test_0100", 0, async function (done) { + console.log("------------------start context_getCacheDir_test_0100-------------------"); + try { + var timeOldStamp = await Utils.getNowTime(); + var context = await featureAbility.getContext(); + context.getCacheDir().then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getCacheDir_test_0100', timeOldStamp, timeNewStamp) + console.log("context_getCacheDir_test_0100: CacheDir is " + data); + }) + } catch (error) { + console.log("logMessage context_getCacheDir_test_0100: error = " + error); + expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache"); + } + var data1 = await context.getCacheDir(); + expect(typeof (data1)).assertEqual("string"); + expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache"); + done(); + console.log("------------------end context_getCacheDir_test_0100-------------------"); + }); + + /* + * @tc.number: context_getCacheDir_test_0200 + * @tc.name: getCacheDir : Obtains the Cache directory on internal storage. + * @tc.desc: Check the return value of the interface (by AsyncCallback) + * @tc.level 0 + */ + it("context_getCacheDir_test_0200", 0, async function (done) { + console.log("------------------start context_getCacheDir_test_0200-------------------"); + try { + var timeOldStamp = await Utils.getNowTime(); + var context = await featureAbility.getContext(); + context.getCacheDir((err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getCacheDir_test_0200', timeOldStamp, timeNewStamp) + console.log("context_getCacheDir_test_0200: getCacheDir successful, result = " + data); + }); + } catch (error) { + console.log("logMessage context_getCacheDir_test_0200: error = " + error); + expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache"); + } + var data1 = await context.getCacheDir(); + expect(typeof (data1)).assertEqual("string"); + expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/cache"); + done(); + console.log("------------------end context_getCacheDir_test_0200-------------------"); + }); + + /* + * @tc.number: context_getFilesDir_test_0100 + * @tc.name: getFilesDir : Obtains the files directory on internal storage. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it("context_getFilesDir_test_0100", 0, async function (done) { + console.log("------------------start context_getFilesDir_test_0100-------------------"); + try { + var timeOldStamp = await Utils.getNowTime(); + var context = await featureAbility.getContext(); + context.getFilesDir().then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getFilesDir_test_0100', timeOldStamp, timeNewStamp) + console.log("context_getFilesDir_test_0100:FilesDir is " + data); + }) + } catch (error) { + console.log("logMessage context_getFilesDir_test_0100: error = " + error); + expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files"); + } + var data1 = await context.getFilesDir(); + expect(typeof (data1)).assertEqual("string"); + expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files"); + done(); + console.log("------------------end context_getFilesDir_test_0100-------------------"); + }); + + /* + * @tc.number: context_getFilesDir_test_0200 + * @tc.name: getFilesDir : Obtains the files directory on internal storage. + * @tc.desc: Check the return value of the interface (by AsyncCallback) + * @tc.level 0 + */ + it("context_getFilesDir_test_0200", 0, async function (done) { + console.log("------------------start context_getFilesDir_test_0200-------------------"); + try { + var timeOldStamp = await Utils.getNowTime(); + var context = await featureAbility.getContext(); + context.getFilesDir((err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getFilesDir_test_0200', timeOldStamp, timeNewStamp) + console.log("context_getFilesDir_test_0200: getFilesDir successful, result = " + data); + }); + } catch (error) { + console.log("logMessage context_getFilesDir_test_0200: error = " + error); + expect(error).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files"); + } + var data1 = await context.getFilesDir(); + expect(typeof (data1)).assertEqual("string"); + expect(data1).assertEqual("/data/accounts/account_0/appdata/com.ohos.acecollaboration/files"); + done(); + console.log("------------------end context_getFilesDir_test_0200-------------------"); + }); + + + /* + * @tc.number: context_getOrCreateDistributedDir_test_0100 + * @tc.name: getOrCreateDistributedDir : Obtains the directory of Distributed files. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it("context_getOrCreateDistributedDir_0100", 0, async function (done) { + console.log("------------------start context_getOrCreateDistributedDir_0100-------------------"); + try { + var timeOldStamp = await Utils.getNowTime(); + var context = await featureAbility.getContext(); + context.getOrCreateDistributedDir().then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getOrCreateDistributedDir_0100', timeOldStamp, timeNewStamp); + console.log("context_getOrCreateDistributedDir_0100: DistributedDir is " + data); + }) + } catch (error) { + console.log("logMessage context_getOrCreateDistributedDir_0100: error = " + error); + expect(error).assertEqual("/data/storage/el2/distributedfiles/entry"); + } + var data1 = await context.getOrCreateDistributedDir(); + expect(typeof (data1)).assertEqual("string"); + expect(data1).assertEqual("/data/storage/el2/distributedfiles/entry"); + done(); + console.log("------------------end context_getOrCreateDistributedDir_0100-------------------"); + }); + + /* + * @tc.number: context_getOrCreateDistributedDir_0200 + * @tc.name: getOrCreateDistributedDir : Obtains the directory of Distributed files. + * @tc.desc: Check the return value of the interface (by AsyncCallback) + * @tc.level 0 + */ + it("context_getOrCreateDistributedDir_0200", 0, async function (done) { + console.log("------------------start context_getOrCreateDistributedDir_0200-------------------"); + try { + var timeOldStamp = await Utils.getNowTime(); + var context = await featureAbility.getContext(); + context.getOrCreateDistributedDir((err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getOrCreateDistributedDir_0200', timeOldStamp, timeNewStamp); + console.log("context_getOrCreateDistributedDir_0200: getOrCreateDistributedDir successful, result = " + data); + }); + } catch (error) { + console.log("logMessage context_getOrCreateDistributedDir_0200: error = " + error); + expect(error).assertEqual("/data/storage/el2/distributedfiles/entry"); + } + var data1 = await context.getOrCreateDistributedDir(); + expect(typeof (data1)).assertEqual("string"); + expect(data1).assertEqual("/data/storage/el2/distributedfiles/entry"); + done(); + console.log("------------------end context_getOrCreateDistributedDir_0200-------------------"); + }); + + /* + * @tc.number: context_getAppType_0100 + * @tc.name: getAppType : Obtains the type of current application. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it("context_getAppType_0100", 0, async function (done) { + console.log("------------------start context_getAppType_0100-------------------"); + try { + var timeOldStamp = await Utils.getNowTime(); + var context = await featureAbility.getContext(); + context.getAppType().then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getAppType_0100_0100', timeOldStamp, timeNewStamp); + console.log("context_getAppType_0100: AppType is " + data); + }) + } catch (error) { + console.log("logMessage context_getAppType_0100: error = " + error); + expect(error).assertEqual("system"); + } + var data1 = await context.getAppType(); + expect(typeof (data1)).assertEqual("string"); + expect(data1).assertEqual("system"); + done(); + console.log("------------------end context_getAppType_0100-------------------"); + }); + + /* + * @tc.number: context_getAppType_0200 + * @tc.name: getAppType : Obtains the type of current application. + * @tc.desc: Check the return value of the interface (by AsyncCallback) + * @tc.level 0 + */ + it("context_getAppType_0200", 0, async function (done) { + console.log("------------------start context_getAppType_0200-------------------"); + try { + var timeOldStamp = await Utils.getNowTime(); + var context = await featureAbility.getContext(); + context.getAppType((err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getAppType_0200_0100', timeOldStamp, timeNewStamp); + console.log("context_getAppType_0200: getAppType successful, result = " + data); + }); + } catch (error) { + console.log("logMessage context_getAppType_0200: error = " + error); + expect(error).assertEqual("system"); + } + var data1 = await context.getAppType(); + expect(typeof (data1)).assertEqual("string"); + expect(data1).assertEqual("system"); + done(); + console.log("------------------end context_getAppType_0200-------------------"); + }); + }) +} diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/DataAbility.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/DataAbility.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f8ed690f0e208ab7048cf556a52abcfdf37be511 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/DataAbility.test.ets @@ -0,0 +1,818 @@ +/** + * Copyright (c) 2021 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 featureAbility from '@ohos.ability.featureAbility' +import {describe, expect, it} from 'deccjsunit/index.ets' + +const URI_CONTACTS = 'dataability:///com.ohos.contactsdataability'; +const contactUri = 'dataability:///com.ohos.contactsdataability/contacts/groups'; +const contactUri2 = 'dataability:///com.ohos.contactsdataability/contacts/groups2'; +import Utils from './Utils'; + +const INSERT_ONE = 'dataAbility_insert_test '; +const QUERY_TWO = 'dataAbility_query_test '; +const UPDATE_THREE = 'dataAbility_update_test '; +const DELETE_FOUR = 'dataAbility_delete_test '; + +export default function DataAbilityJsunit() { + var dataAbilityHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var pacMap = { + 'group_name': 'test1', + 'ringtone_modify_time': 28 + }; + + var pacMap_3 = { + 'group_name': 'test3', + 'ringtone_modify_time': 20 + }; + + var pacMap_4 = { + 'group_name': 'test4', + 'ringtone_modify_time': 40 + }; + + describe('appInfoTest', function () { + + /* + * @tc.number: dataAbility_insert_test_001 + * @tc.name: call : Inserts a single data record into the database. + * @tc.desc: Check the return value of the interface (by AsyncCallback) + * @tc.level 0 + */ + it(INSERT_ONE + '001', 0, async function (done) { + let details; + let wrong; + console.log(INSERT_ONE + '001 start......'); + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri, 'insert', '', pacMap, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(INSERT_ONE + '001', timeOldStamp, timeNewStamp); + if (err) { + wrong = err; + console.error(INSERT_ONE + '001 error: ' + JSON.stringify(err)); + } else { + details = data; + console.info(INSERT_ONE + '001 succeeded data: ' + JSON.stringify(data)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 1) : expectDetails(wrong, true, 2); + done(); + console.log(INSERT_ONE + '001 end ......'); + }); + + /* + * @tc.number: dataAbility_insert_test_002 + * @tc.name: call : Inserts a single data record into the database. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(INSERT_ONE + '002', 0, async function (done) { + let details; + let wrong; + console.log(INSERT_ONE + '002 start......'); + pacMap.group_name = 'test2'; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri, 'insert', '', pacMap).then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(INSERT_ONE + '002', timeOldStamp, timeNewStamp); + details = data; + console.info(INSERT_ONE + '002 succeeded data: ' + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.error(INSERT_ONE + '002 error: ' + JSON.stringify(error)); + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 1) : expectDetails(wrong, true, 2); + done(); + console.log(INSERT_ONE + '002 end......'); + }); + + /* + * @tc.number: dataAbility_insert_test_003 + * @tc.name: call : Inserts a incorrect uri data record into the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(INSERT_ONE + '003', 0, async function (done) { + let details; + let wrong; + console.log(INSERT_ONE + '003 start......'); + dataAbilityHelper.call(contactUri2, 'insert', '', pacMap).then((data) => { + details = data + console.info(INSERT_ONE + '003 succeeded: ' + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.error(INSERT_ONE + '003 error: ' + JSON.stringify(error)); + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 1) : expectDetails(wrong, true, 2); + done(); + console.log(INSERT_ONE + '003 end......'); + }); + + /* + * @tc.number: dataAbility_insert_test_004 + * @tc.name: call : Inserts a null uri data record into the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(INSERT_ONE + '004', 0, async function (done) { + let details; + let wrong; + console.log(INSERT_ONE + '004 start......'); + dataAbilityHelper.call('', 'insert', '', pacMap).then((data) => { + details = data; + console.info(INSERT_ONE + '004 succeeded: ' + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.error(INSERT_ONE + '004 error: ' + JSON.stringify(error)); + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 1) : expectDetails(wrong, true, 2); + done(); + console.log(INSERT_ONE + '004 end......'); + }); + + /* + * @tc.number: dataAbility_insert_test_005 + * @tc.name: call : Inserts a null methold data record into the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(INSERT_ONE + '005', 0, async function (done) { + let details; + let wrong; + console.log(INSERT_ONE + '005 start......'); + let pacMap = { + 'group_name': 'test4', + 'ringtone_modify_time': 28 + }; + dataAbilityHelper.call(contactUri, "", "", pacMap).then((data) => { + details = data; + console.info(INSERT_ONE + '005 succeeded: ' + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.error(INSERT_ONE + '005 error: ' + JSON.stringify(error)); + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 1) : expectDetails(wrong, true, 2); + done(); + console.log(INSERT_ONE + '005 end......'); + }); + + /* + * @tc.number: dataAbility_query_test_001 + * @tc.name: call : Queries data in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(QUERY_TWO + '001', 0, async function (done) { + let details; + let wrong; + console.log(QUERY_TWO + '001 start......'); + let arg = "{\"equalTo\": \"group_name\"}"; + let pacMap = { + "group_name": "test1", + "columns": "group_name,ringtone_modify_time" + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri, 'query', arg, pacMap, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(QUERY_TWO + '001', timeOldStamp, timeNewStamp); + wrong = err; + if (wrong) { + console.error(QUERY_TWO + '001 error: ' + JSON.stringify(wrong)); + } else { + details = data; + console.info(QUERY_TWO + '001 succeeded: ' + JSON.stringify(data)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 2); + done(); + console.log(QUERY_TWO + '001 end......'); + }); + + /* + * @tc.number: dataAbility_query_test_002 + * @tc.name: call : Queries data in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(QUERY_TWO + '002', 0, async function (done) { + let details; + let wrong; + console.log(QUERY_TWO + '002 start......'); + let arg = "{\"between\": \"ringtone_modify_time\"}"; + let pacMap = { + 'ringtone_modify_time': "15, 30", + "columns": "group_name,ringtone_modify_time" + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri, 'query', arg, pacMap, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(QUERY_TWO + '002', timeOldStamp, timeNewStamp); + wrong = err; + if (wrong) { + console.error(QUERY_TWO + '002 error: ' + JSON.stringify(wrong)); + } else { + details = data; + console.info(QUERY_TWO + '002 succeeded: ' + JSON.stringify(data)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 2); + done(); + console.log(QUERY_TWO + '002 end......'); + }); + + /* + * @tc.number: dataAbility_query_test_003 + * @tc.name: call : Queries data in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(QUERY_TWO + '003', 0, async function (done) { + let details; + let wrong; + console.log(QUERY_TWO + '003 start......'); + let arg = { + 'like': 'group_name' + }; + let pacMap = { + 'group_name': '%test%', + 'columns': 'group_name,ringtone_modify_time' + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri, 'query', arg, pacMap, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(QUERY_TWO + '003', timeOldStamp, timeNewStamp); + wrong = err; + if (wrong) { + console.error(QUERY_TWO + '003 error: ' + JSON.stringify(wrong)); + } else { + details = data; + console.info(QUERY_TWO + '003 succeeded: ' + JSON.stringify(data)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 2); + done(); + console.log(QUERY_TWO + '003 end......'); + }); + + /* + * @tc.number: dataAbility_query_test_004 + * @tc.name: call : Queries data in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(QUERY_TWO + '004', 0, async function (done) { + let details; + let wrong; + console.log(QUERY_TWO + '004 start......'); + let arg = { + 'greaterThanOrEqualTo': 'ringtone_modify_time' + }; + let pacMap = { + 'ringtone_modify_time': 20, + 'columns': 'group_name,ringtone_modify_time' + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri, 'query', arg, pacMap, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(QUERY_TWO + '004', timeOldStamp, timeNewStamp); + if (err) { + wrong = err; + console.error(QUERY_TWO + '004 error: ' + JSON.stringify(err)); + return; + } else { + details = data; + console.info(QUERY_TWO + '004 succeeded: ' + JSON.stringify(data)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 2); + done(); + console.log(QUERY_TWO + '004 end......'); + }); + + /* + * @tc.number: dataAbility_query_test_005 + * @tc.name: call : Queries abnormal data in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(QUERY_TWO + '005', 0, async function (done) { + let details; + let wrong; + let pacMap = { + 'ringtone_modify_time': 20, + 'columns': 'group_name,ringtone_modify_time' + }; + console.log(INSERT_ONE + '003 start......'); + dataAbilityHelper.call(contactUri2, 'query', '', pacMap).then((data) => { + details = data + console.info(QUERY_TWO + '005 succeeded: ' + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.error(QUERY_TWO + '005 error: ' + JSON.stringify(error)); + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 2); + done(); + console.log(QUERY_TWO + '005 end......'); + }); + + /* + * @tc.number: dataAbility_query_test_006 + * @tc.name: call : Queries abnormal data in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(QUERY_TWO + '006', 0, async function (done) { + let details; + let wrong; + let pacMap = { + 'ringtone_modify_time': 20, + 'columns': 'group_name,ringtone_modify_time' + }; + console.log(QUERY_TWO + '004 start......'); + dataAbilityHelper.call('', 'query', '', pacMap).then((data) => { + details = data; + console.info(QUERY_TWO + '006 succeeded: ' + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.error(QUERY_TWO + '006 error: ' + JSON.stringify(error)); + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, false, 4) : expectDetails(wrong, true, 2); + done(); + console.log(QUERY_TWO + '006 end......'); + }); + + /* + * @tc.number: dataAbility_update_test_001 + * @tc.name: call : Updates data records in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(UPDATE_THREE + '001', 0, async function (done) { + let details; + let wrong; + console.log(UPDATE_THREE + '001 start......'); + let arg = "{\"equalTo\": \"ringtone_modify_time\"}"; + let pacMap = { + 'ringtone_modify_time': 28, + 'group_name': 'testupdata1' + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri, 'update', arg, pacMap, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(UPDATE_THREE + '001', timeOldStamp, timeNewStamp); + if (err) { + wrong = err; + console.error(UPDATE_THREE + '001 error: ' + JSON.stringify(err)); + } else { + details = data; + console.info(UPDATE_THREE + '001 succeeded: ' + JSON.stringify(data)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); + done(); + console.log(UPDATE_THREE + '001 end......'); + }); + + /* + * @tc.number: dataAbility_update_test_002 + * @tc.name: call : Updates data records in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(UPDATE_THREE + '002', 0, async function (done) { + let details; + let wrong; + console.log(UPDATE_THREE + '002 start......'); + let arg = "{\"between\": \"ringtone_modify_time\"}"; + let pacMap = { + 'ringtone_modify_time': "15, 30", + 'group_name': 'testupdata2' + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri, 'update', arg, pacMap, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(UPDATE_THREE + '002', timeOldStamp, timeNewStamp); + if (err) { + wrong = err; + console.error(UPDATE_THREE + '002 error: ' + JSON.stringify(err)); + } else { + details = data; + console.info(UPDATE_THREE + '002 succeeded: ' + JSON.stringify(data)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); + done(); + console.log(UPDATE_THREE + '002 end......'); + }); + + /* + * @tc.number: dataAbility_update_test_003 + * @tc.name: call : Updates data records in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(UPDATE_THREE + '003', 0, async function (done) { + let details; + let wrong; + console.log(UPDATE_THREE + '003 start......'); + let arg = { + 'contains': 'group_name' + }; + let pacMap = { + 'group_name': 'ata2', + 'ringtone_modify_time': 100 + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri, 'update', arg, pacMap, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(UPDATE_THREE + '003', timeOldStamp, timeNewStamp); + if (err) { + wrong = err; + console.error(UPDATE_THREE + '003 error: ' + JSON.stringify(err)); + } else { + details = data; + console.info(UPDATE_THREE + '003 succeeded: ' + JSON.stringify(data)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); + done(); + console.log(UPDATE_THREE + '003 end......'); + }); + + /* + * @tc.number: dataAbility_update_test_004 + * @tc.name: call : Updates data records in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(UPDATE_THREE + '004', 0, async function (done) { + let details; + let wrong; + console.log(UPDATE_THREE + '004 start......'); + let arg = { + 'lessThan': 'ringtone_modify_time' + }; + let pacMap = { + 'ringtone_modify_time': 32, + 'group_name': 'testupdata2' + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri, 'update', arg, pacMap, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(UPDATE_THREE + '004', timeOldStamp, timeNewStamp); + if (err) { + wrong = err; + console.error(UPDATE_THREE + '004 error: ' + JSON.stringify(err)); + } else { + details = data; + console.info(UPDATE_THREE + '004 succeeded: ' + JSON.stringify(data)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); + done(); + console.log(UPDATE_THREE + '004 end......'); + }); + + /* + * @tc.number: dataAbility_update_test_005 + * @tc.name: call : Updates abnormal data records in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(UPDATE_THREE + '005', 0, async function (done) { + let details; + let wrong; + console.log(UPDATE_THREE + '005 start......'); + + let pacMap = { + 'ringtone_modify_time': 32, + 'group_name': 'testupdata2' + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri2, 'update', '', pacMap, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(UPDATE_THREE + '005', timeOldStamp, timeNewStamp); + if (err) { + wrong = err; + console.error(UPDATE_THREE + '005 error: ' + JSON.stringify(err)); + } else { + details = data; + console.info(UPDATE_THREE + '005 succeeded: ' + JSON.stringify(data)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); + done(); + console.log(UPDATE_THREE + '005 end......'); + }); + + /* + * @tc.number: dataAbility_update_test_006 + * @tc.name: call : Updates abnormal data records in the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(UPDATE_THREE + '006', 0, async function (done) { + let details; + let wrong; + console.log(UPDATE_THREE + '006 start......'); + let pacMap = { + 'ringtone_modify_time': 32, + 'group_name': 'testupdata2' + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call('', 'update', '', pacMap, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(UPDATE_THREE + '006', timeOldStamp, timeNewStamp); + if (err) { + wrong = err; + console.error(UPDATE_THREE + '006 error: ' + JSON.stringify(err)); + } else { + details = data; + console.info(UPDATE_THREE + '006 succeeded: ' + JSON.stringify(data)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); + done(); + console.log(UPDATE_THREE + '006 end......'); + }); + + /* + * @tc.number: dataAbility_delete_test_001 + * @tc.name: call : Deletes one or more data records from the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + dataAbilityHelper.call(contactUri, 'insert', '', pacMap, (err, data) => { + if (err) { + console.error('Operation failed1. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation succeeded1: ' + JSON.stringify(data)); + }); + it(DELETE_FOUR + '001', 0, async function (done) { + let details; + let wrong; + console.log(DELETE_FOUR + '001 start......'); + let arg2 = "{\"equalTo\": \"group_name\"}"; + let pacMap2 = { + 'group_name': 'test1' + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri, 'delete', arg2, pacMap2, (err2, data2) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(DELETE_FOUR + '001', timeOldStamp, timeNewStamp); + if (err2) { + wrong = err2; + console.error(DELETE_FOUR + '001 error: ' + JSON.stringify(err2)); + } else { + details = data2; + console.info(DELETE_FOUR + '001 succeeded: ' + JSON.stringify(data2)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); + done(); + console.log(DELETE_FOUR + '001 end......'); + }); + + /* + * @tc.number: dataAbility_delete_test_002 + * @tc.name: call : Deletes one or more data records from the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it(DELETE_FOUR + '002', 0, async function (done) { + let details; + let wrong + console.log(DELETE_FOUR + '002 start......'); + let arg = "{\"lessThan\": \"ringtone_modify_time\"}"; + let pacMap = { + 'ringtone_modify_time': 32, + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri, 'delete', arg, pacMap, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(DELETE_FOUR + '002', timeOldStamp, timeNewStamp); + if (err) { + wrong = err; + console.error(DELETE_FOUR + '002 error: ' + JSON.stringify(err)); + } else { + details = data; + console.info(DELETE_FOUR + '002 succeeded: ' + JSON.stringify(data)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); + done(); + console.log(DELETE_FOUR + '002 end......'); + }); + + /* + * @tc.number: dataAbility_delete_test_003 + * @tc.name: call : Deletes one or more data records from the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + dataAbilityHelper.call(contactUri, 'insert', '', pacMap_3, (err, data) => { + if (err) { + console.error('Operation failed3. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation succeeded3: ' + JSON.stringify(data)); + }); + it(DELETE_FOUR + '003', 0, async function (done) { + let details; + let wrong; + console.log(DELETE_FOUR + '003 start......'); + let arg2 = { + 'like': 'group_name' + }; + let pacMap2 = { + 'group_name': '%test%' + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri, 'delete', arg2, pacMap2, (err2, data2) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(DELETE_FOUR + '003', timeOldStamp, timeNewStamp); + if (err2) { + wrong = err2; + console.error(DELETE_FOUR + '003 error: ' + JSON.stringify(err2)); + } else { + details = data2; + console.info(DELETE_FOUR + '003 delete succeeded: ' + JSON.stringify(data2)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); + done(); + console.log(DELETE_FOUR + '003 delete end......'); + }); + + /* + * @tc.number: dataAbility_delete_test_004 + * @tc.name: call : Deletes one or more data records from the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + dataAbilityHelper.call(contactUri, 'insert', '', pacMap_4, (err, data) => { + if (err) { + console.error('Operation failed4. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation succeeded4: ' + JSON.stringify(data)); + }); + it(DELETE_FOUR + '004', 0, async function (done) { + let details; + let wrong; + console.log(DELETE_FOUR + '004 start......'); + let arg2 = { + 'greaterThanOrEqualTo': 'ringtone_modify_time' + }; + let pacMap2 = { + 'ringtone_modify_time': 40 + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri, 'delete', arg2, pacMap2, (err2, data2) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(DELETE_FOUR + '004', timeOldStamp, timeNewStamp); + if (err2) { + wrong = err2; + console.error(DELETE_FOUR + '004 error: ' + JSON.stringify(err2)); + } else { + details = data2; + console.info(DELETE_FOUR + '004 delete succeeded: ' + JSON.stringify(data2)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); + done(); + console.log(DELETE_FOUR + '004 delete end......'); + }); + + /* + * @tc.number: dataAbility_delete_test_005 + * @tc.name: call : Deletes abnormal data records from the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + dataAbilityHelper.call(contactUri, 'insert', '', pacMap_4, (err, data) => { + if (err) { + console.error('Operation failed4. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation succeeded5: ' + JSON.stringify(data)); + }); + it(DELETE_FOUR + '005', 0, async function (done) { + let details; + let wrong; + console.log(DELETE_FOUR + '005 start......'); + let pacMap2 = { + 'ringtone_modify_time': 40 + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call(contactUri2, 'delete', '', pacMap2, (err2, data2) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(DELETE_FOUR + '005', timeOldStamp, timeNewStamp); + if (err2) { + wrong = err2; + console.error(DELETE_FOUR + '005 error: ' + JSON.stringify(err2)); + } else { + details = data2; + console.info(DELETE_FOUR + '005 delete succeeded: ' + JSON.stringify(data2)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); + done(); + console.log(DELETE_FOUR + '005 delete end......'); + }); + + /* + * @tc.number: dataAbility_delete_test_006 + * @tc.name: call : Deletes abnormal data records from the database. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + dataAbilityHelper.call(contactUri, 'insert', '', pacMap_4, (err, data) => { + if (err) { + console.error('Operation failed4. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Operation succeeded4: ' + JSON.stringify(data)); + }); + it(DELETE_FOUR + '006', 0, async function (done) { + let details; + let wrong; + console.log(DELETE_FOUR + '006 start......'); + let pacMap2 = { + 'ringtone_modify_time': 40 + }; + var timeOldStamp = await Utils.getNowTime(); + dataAbilityHelper.call('', 'delete', '', pacMap2, (err2, data2) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime(DELETE_FOUR + '006', timeOldStamp, timeNewStamp); + if (err2) { + wrong = err2; + console.error(DELETE_FOUR + '006 error: ' + JSON.stringify(err2)); + } else { + details = data2; + console.info(DELETE_FOUR + '006 delete succeeded: ' + JSON.stringify(data2)); + } + }); + await Utils.sleep(1000); + details != null ? expectDetails(details, true, 3) : expectDetails(wrong, true, 2); + done(); + console.log(DELETE_FOUR + '006 delete end......'); + }); + }) + + function expectDetails(data, isTrue, keyStatus) { + if (data != -1) { + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.result)).assertEqual(isTrue ? 'number' : 'string'); + } + switch (keyStatus) { + case 1: + expect(data.result > 0).assertTrue(); + break + + case 2: + expect(data == -1).assertTrue(); + break + + case 3: + expect(data.result).assertEqual(0); + break + } + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..023315f7c62d5e8ca4b19fef1d668d6c9dc74d82 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2021 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 addContextAndAbilityJsunit from './addContextAndAbilityJsunit.test.ets'; +import getHapModuleInfoJsunit from './getHapModuleInfoJsunit.test.ets'; +import getAbilityInfoJsunit from './getAbilityInfoJsunit.test.ets'; +import getApplicationContext from './getApplicationContextJsunit.test.ets'; +import getAppVersionInfoJsunit from './getAppVersionInfoJsunit.test.ets'; +import ContextJsunit from './ContextJsunit.test.ets'; +import DataAbilityJsunit from './DataAbility.test.ets'; + +export default function testsuite() { + ContextJsunit(); + DataAbilityJsunit(); + addContextAndAbilityJsunit(); + getHapModuleInfoJsunit(); + getAbilityInfoJsunit(); + getApplicationContext(); + getAppVersionInfoJsunit(); +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/Utils.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..d347b04062965c665153e7ac358028d6ae274d53 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2021 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. + */ + +export default class Utils { + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve(reject) + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getNowTime() { + return new Date().getTime(); + } + + /** + * 接口调用时间 + * @param startTime 接口调用开始时间 + * @param endTime 接口调用结束时间 + */ + static getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; + } +} + + + + diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/addContextAndAbilityJsunit.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/addContextAndAbilityJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8aaedaf046defd0f66645c3170fe2ab31c05b222 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/addContextAndAbilityJsunit.test.ets @@ -0,0 +1,300 @@ +/** + * Copyright (c) 2021 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 {describe, it, expect} from "deccjsunit/index.ets"; +import Utils from './Utils'; +import ability_featureAbility from '@ohos.ability.featureAbility'; +import abilityManager from "@ohos.app.abilitymanager" + +const TAG_TEST_0100 = ' context_isUpdatingConfigurations_test_0100 '; +const TAG_TEST_0200 = ' context_isUpdatingConfigurations_test_0200 '; +const TAG_TEST_0300 = ' context_printDrawnCompleted_test_0100 '; +const TAG_TEST_0400 = ' context_printDrawnCompleted_test_0200 '; +const TAG_TEST_0500 = ' context_getAppMemorySize_test_0100 '; +const TAG_TEST_0600 = ' context_getAppMemorySize_test_0200 '; +const TAG_TEST_0700 = ' context_isRamConstrainedDevice_test_0100 '; +const TAG_TEST_0800 = ' context_isRamConstrainedDevice_test_0200 '; +const TAG_TEST_0900 = ' context_featureAbility_test_0100 '; +const TAG_TEST_0010 = ' context_featureAbility_test_0200 '; +const TAG_TEST_0011 = ' context_featureAbility_test_0300 '; +const TAG_TEST_0012 = ' context_featureAbility_test_0400 '; + +export default function addContextAndAbilityJsunit() { + describe('appInfoTest', function () { + /* + * @tc.number: context_isUpdatingConfigurations_test_0100 + * @tc.name: isUpdatingConfigurations : Obtains whether the configuration of the current ability is changing. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0100, 0, async function (done) { + console.info(TAG_TEST_0100 + 'promise START'); + let detailed; + var startTime = await Utils.getNowTime(); + var context = ability_featureAbility.getContext(); + await context.isUpdatingConfigurations().then((data) => { + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0100, startTime, endTime) + console.info(TAG_TEST_0100 + ' promise data is:' + JSON.stringify(data)); + detailed = data; + }).catch((error) => { + console.error(TAG_TEST_0100 + 'promise errors is: ' + JSON.stringify(error)); + }) + expect(typeof (detailed)).assertEqual("boolean"); + expect(detailed).assertEqual(false); + done(); + console.log('------------------ ' + TAG_TEST_0100 + ' end -------------------'); + }); + + /* + * @tc.number: context_isUpdatingConfigurations_test_0200 + * @tc.name: isUpdatingConfigurations : Obtains whether the configuration of the current ability is changing. + * @tc.desc: Check the return value of the interface (by AsyncCallback) + * @tc.level 0 + */ + it(TAG_TEST_0200, 0, async function (done) { + let detailed; + console.info(TAG_TEST_0200 + 'callBack START'); + try { + var startTime = await Utils.getNowTime(); + var context = ability_featureAbility.getContext(); + context.isUpdatingConfigurations((error, data) => { + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0200, startTime, endTime) + detailed = data; + console.info(TAG_TEST_0200 + ' callBack succeeded. data is:' + JSON.stringify(data)); + }); + } catch (error) { + console.error(TAG_TEST_0200 + 'Operation failed. Cause: ' + JSON.stringify(error)); + } + await Utils.sleep(2000) + expect(typeof (detailed)).assertEqual("boolean"); + expect(detailed).assertEqual(false); + done(); + console.log('------------------ ' + TAG_TEST_0200 + ' end -------------------'); + }); + + /* + * @tc.number: context_printDrawnCompleted_test_0100 + * @tc.name: printDrawnCompleted : Inform the system of the time required to complete the drawing of the page + capability. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0300, 0, async function (done) { + let detailed; + console.info(TAG_TEST_0300 + 'callBack START'); + var startTime = await Utils.getNowTime(); + var context = ability_featureAbility.getContext(); + await context.printDrawnCompleted().then((data) => { + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0300, startTime, endTime) + console.info(TAG_TEST_0300 + ' promise data is:' + JSON.stringify(data)); + detailed = data; + }).catch((error) => { + console.error(TAG_TEST_0300 + 'promise error is: ' + JSON.stringify(error)); + }); + await Utils.sleep(2000) + expect(detailed).assertEqual(null); + done(); + console.log('------------------ ' + TAG_TEST_0300 + ' end -------------------'); + }) + + + /* + * @tc.number: context_printDrawnCompleted_test_0200 + * @tc.name: printDrawnCompleted : Inform the system of the time required to complete the drawing of the page + capability. + * @tc.desc: Check the return value of the interface (by AsyncCallback) + * @tc.level 0 + */ + it(TAG_TEST_0400, 0, async function (done) { + let detailed; + console.info(TAG_TEST_0400 + 'callBack START'); + try { + var startTime = await Utils.getNowTime(); + var context = ability_featureAbility.getContext(); + context.printDrawnCompleted((error, data) => { + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0300, startTime, endTime) + detailed = data; + console.info(TAG_TEST_0400 + ' callBack succeeded. data is:' + JSON.stringify(data)); + }); + } catch (error) { + console.error(TAG_TEST_0400 + 'Operation failed. Cause: ' + JSON.stringify(error)); + } + await Utils.sleep(2000) + expect(detailed).assertEqual(null); + done(); + console.log('------------------ ' + TAG_TEST_0400 + ' end -------------------'); + }) + + + /* + * @tc.number: context_getAppMemorySize_test_0100 + * @tc.name: getAppMemorySize : Obtains the memory size of the application. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0500, 0, async function (done) { + console.info(TAG_TEST_0500 + 'promise START'); + let detailed; + var startTime = await Utils.getNowTime(); + await abilityManager.getAppMemorySize() + .then((data) => { + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0500, startTime, endTime) + console.info(TAG_TEST_0500 + ' promise data is:' + JSON.stringify(data)); + detailed = data; + }).catch((error) => { + console.error(TAG_TEST_0500 + 'promise errors is: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000) + expect(typeof (detailed)).assertEqual("number"); + expect(detailed).assertEqual(512); + done(); + console.log('------------------ ' + TAG_TEST_0500 + ' end -------------------'); + }); + + /* + * @tc.number: context_getAppMemorySize_test_0200 + * @tc.name: getAppMemorySize : Obtains the memory size of the application. + * @tc.desc: Check the return value of the interface (by AsyncCallback) + * @tc.level 0 + */ + it(TAG_TEST_0600, 0, async function (done) { + console.info(TAG_TEST_0600 + 'callBack START'); + var startTime = await Utils.getNowTime(); + abilityManager.getAppMemorySize((error, data) => { + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0500, startTime, endTime) + console.info(TAG_TEST_0600 + ' callBack error is: ' + JSON.stringify(error)); + console.info(TAG_TEST_0600 + ' callBack data is:' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("number"); + expect(data).assertEqual(512); + console.log('------------------ ' + TAG_TEST_0600 + ' end -------------------'); + done(); + }) + }); + + /* + * @tc.number: context_isRamConstrainedDevice_test_0100 + * @tc.name: isRamConstrainedDevice : Obtains whether the current device has low ram. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0700, 0, async function (done) { + let detailed; + console.info(TAG_TEST_0700 + 'promise START'); + var startTime = await Utils.getNowTime(); + await abilityManager.isRamConstrainedDevice().then((data) => { + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0500, startTime, endTime) + console.info(TAG_TEST_0700 + ' promise data is:' + JSON.stringify(data)); + detailed = data; + }).catch((error) => { + console.error(TAG_TEST_0700 + 'promise errors is: ' + JSON.stringify(error)); + }) + await Utils.sleep(1000) + expect(typeof (detailed)).assertEqual("boolean"); + expect(detailed).assertEqual(false) + done(); + console.log('------------------ ' + TAG_TEST_0700 + ' end -------------------'); + }); + + /* + * @tc.number: context_isRamConstrainedDevice_test_0200 + * @tc.name: isRamConstrainedDevice : Obtains whether the current device has low ram. + * @tc.desc: Check the return value of the interface (by AsyncCallback) + * @tc.level 0 + */ + it(TAG_TEST_0800, 0, async function (done) { + console.info(TAG_TEST_0800 + 'callBack START'); + var startTime = await Utils.getNowTime(); + abilityManager.isRamConstrainedDevice((error, data) => { + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0500, startTime, endTime) + console.info(TAG_TEST_0800 + ' callBack error is:' + error); + console.info(TAG_TEST_0800 + ' callBack data is:' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("boolean"); + expect(data).assertEqual(false); + done(); + }) + console.log('------------------ ' + TAG_TEST_0800 + ' end -------------------'); + }); + /* + * @tc.number: context_featureAbility_test_0100 + * @tc.name: featureAbility.ErrorCode : featureAbility.ErrorCode + * @tc.desc: Check the featureAbility.ErrorCode.NO_ERROR + * @tc.level 0 + */ + it(TAG_TEST_0900, 0, async function (done) { + console.info(TAG_TEST_0900 + ' NO_ERROR START'); + var no_error = ability_featureAbility.ErrorCode.NO_ERROR + console.info(TAG_TEST_0900 + ' featureAbility no_error is: ' + no_error); + expect(typeof (no_error)).assertEqual("number"); + expect(no_error).assertEqual(0); + done(); + console.log('------------------ ' + TAG_TEST_0900 + ' end -------------------'); + }); + + /* + * @tc.number: context_featureAbility_test_0200 + * @tc.name: featureAbility.ErrorCode : featureAbility.ErrorCode + * @tc.desc: Check the featureAbility.ErrorCode.INVALID_PARAMETER + * @tc.level 0 + */ + it(TAG_TEST_0010, 0, async function (done) { + console.info(TAG_TEST_0010 + ' INVALID_PARAMETER START'); + var invalid_parameter = ability_featureAbility.ErrorCode.INVALID_PARAMETER + console.info(TAG_TEST_0010 + ' featureAbility invalid_parameter is: ' + invalid_parameter); + expect(typeof (invalid_parameter)).assertEqual("number"); + expect(invalid_parameter).assertEqual(-1); + done(); + console.log('------------------ ' + TAG_TEST_0010 + ' end -------------------'); + }); + + /* + * @tc.number: context_featureAbility_test_0300 + * @tc.name: featureAbility.ErrorCode : featureAbility.ErrorCode + * @tc.desc: Check the featureAbility.ErrorCode.ABILITY_NOT_FOUND + * @tc.level 0 + */ + it(TAG_TEST_0011, 0, async function (done) { + console.info(TAG_TEST_0011 + ' ABILITY_NOT_FOUND START'); + var ability_not_found = ability_featureAbility.ErrorCode.ABILITY_NOT_FOUND + console.info(TAG_TEST_0011 + ' featureAbility ability_not_found is: ' + ability_not_found); + expect(typeof (ability_not_found)).assertEqual("number"); + expect(ability_not_found).assertEqual(-2); + done(); + console.log('------------------ ' + TAG_TEST_0011 + ' end -------------------'); + }); + + /* + * @tc.number: context_featureAbility_test_0400 + * @tc.name: featureAbility.ErrorCode : featureAbility.ErrorCode + * @tc.desc: Check the featureAbility.ErrorCode.PERMISSION_DENY + * @tc.level 0 + */ + it(TAG_TEST_0012, 0, async function (done) { + console.info(TAG_TEST_0012 + ' PERMISSION_DENY START'); + var permission_deny = ability_featureAbility.ErrorCode.PERMISSION_DENY + console.info(TAG_TEST_0012 + ' featureAbility permission_deny is: ' + permission_deny); + expect(typeof (permission_deny)).assertEqual("number"); + expect(permission_deny).assertEqual(-3); + done(); + console.log('------------------ ' + TAG_TEST_0012 + ' end -------------------'); + }); + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getAbilityInfoJsunit.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getAbilityInfoJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..447fc3ba91a560f2422bc4eba3d83b82063c4cf8 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getAbilityInfoJsunit.test.ets @@ -0,0 +1,333 @@ +/** + * Copyright (c) 2021 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 {describe, it, expect} from "deccjsunit/index.ets"; +import Utils from './Utils'; +import ability_featureAbility from '@ohos.ability.featureAbility'; + +export default function getHapModuleInfoJsunit() { + describe('appInfoTest', function () { + + /** + * @tc.number: context_getAbilityInfo_test_0100 + * @tc.name: getAbilityInfo:Query the current attributionability details. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_getAbilityInfo_test_0100', 0, async function (done) { + console.info('[context_getAbilityInfo_test_0100] START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + var context = ability_featureAbility.getContext(); + await context.getAbilityInfo() + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getAbilityInfo_test_0100', timeOldStamp, timeNewStamp); + console.info('[context_getAbilityInfo_test_0100] data is:' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("object"); + }).catch((error) => { + console.error('[context_getAbilityInfo_test_0100] failed:' + JSON.stringify(error)); + }) + var promise = await context.getAbilityInfo(); + console.info('--[context_getAbilityInfo_test_0100] check---'); + checkAbilityInfo('context_getAbilityInfo_test_0100', promise); + console.info('[context_getAbilityInfo_test_0100] FINISH'); + done(); + }); + + async function startAbility2() { + var str = { + "want": { + "bundleName": "com.ohos.acecollaboration", + "abilityName": "com.ohos.acecollaboration.MainAbility2", + }, + }; + ability_featureAbility.startAbility(str).then((data) => { + console.info('context_getAbilityInfo_test_0300 startMainAbility2 succeeded: ' + JSON.stringify(data)); + }).catch((error) => { + console.error('context_getAbilityInfo_test_0300 startMainAbility2 failed. Cause: ' + JSON.stringify(error)); + }); + } + + /** + * @tc.number: context_getAbilityInfo_test_0200 + * @tc.name: getAbilityInfo:Query the current attributionability details. + * @tc.desc: Check the return value of the interface (by AsyncCallback) + * @tc.level 0 + */ + it('context_getAbilityInfo_test_0200', 0, async function (done) { + try { + console.info('[context_getAbilityInfo_test_0200] START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + var context = ability_featureAbility.getContext(); + context.getAbilityInfo((error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getAbilityInfo_test_0200', timeOldStamp, timeNewStamp); + console.info('[context_getAbilityInfo_test_0200] data is:' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("object"); + }); + } catch (error) { + console.error('[context_getAbilityInfo_test_0200] failed: ' + JSON.stringify(error)); + } + var callback = await context.getAbilityInfo(); + console.info('---[context_getAbilityInfo_test_0200] check---'); + checkAbilityInfo('context_getAbilityInfo_test_0200', callback); + console.info('[context_getAbilityInfo_test_0200] FINISH'); + done(); + }) + + + /** + * @tc.number: context_getAbilityInfo_test_0300_1 + * @tc.name: getAbilityInfo:Query the current attributionability details. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it('context_getAbilityInfo_test_0300_1', 0, async function (done) { + console.info('[context_getAbilityInfo_test_0300] STARTability'); + startAbility2(); + done(); + }); + + /** + * @tc.number: context_getAbilityInfo_test_0400 + * @tc.name: getAbilityInfo:Query the current attributionability details. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_getAbilityInfo_test_0400', 0, async function (done) { + console.info('[context_getAbilityInfo_test_0400] START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + var context = ability_featureAbility.getContext(); + await context.getAbilityInfo() + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getAbilityInfo_test_0400', timeOldStamp, timeNewStamp); + console.info('[context_getAbilityInfo_test_0400] data is:' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("object"); + }).catch((error) => { + console.error('[context_getAbilityInfo_test_0400] failed:' + JSON.stringify(error)); + }) + var promise = await context.getAbilityInfo(); + console.info('--[context_getAbilityInfo_test_0400] check---'); + checkAbilityInfo('context_getAbilityInfo_test_0400', promise); + console.info('[context_getAbilityInfo_test_0400] FINISH'); + done(); + }); + + function checkAbilityInfo(msg, data) { + console.log(msg + "checkAbilityInfo start " + JSON.stringify(data)); + console.log(msg + "checkAbilityInfo bundleName : " + data.bundleName); + console.log(msg + "checkAbilityInfo name : " + data.name); + console.log(msg + "checkAbilityInfo label : " + data.label); + console.log(msg + "checkAbilityInfo description : " + data.description); + console.log(msg + "checkAbilityInfo icon : " + data.icon); + console.log(msg + "checkAbilityInfo descriptionId : " + data.descriptionId); + console.log(msg + "checkAbilityInfo iconId : " + data.iconId); + console.log(msg + "checkAbilityInfo moduleName : " + data.moduleName); + console.log(msg + "checkAbilityInfo process : " + data.process); + console.log(msg + "checkAbilityInfo targetAbility : " + data.targetAbility); + console.log(msg + "checkAbilityInfo backgroundModes : " + data.backgroundModes); + console.log(msg + "checkAbilityInfo isVisible : " + data.isVisible); + console.log(msg + "checkAbilityInfo formEnabled : " + data.formEnabled); + console.log(msg + "checkAbilityInfo type : " + data.type) + console.log(msg + "checkAbilityInfo orientation : " + data.orientation); + console.log(msg + "checkAbilityInfo launchMode : " + data.launchMode); + console.log(msg + "checkAbilityInfo permissions length : " + data.permissions.length); + for (var j = 0; j < data.permissions.length; j++) { + console.log(msg + "getAbilityInfo data.permissions[" + j + "] : " + data.permissions[j]); + } + console.log(msg + "checkAbilityInfo deviceTypes length : " + data.deviceTypes.length); + for (var k = 0; k < data.deviceTypes.length; k++) { + console.log(msg + "getAbilityInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]); + } + console.log(msg + "checkAbilityInfo deviceCapabilities length : " + data.deviceCapabilities.length); + for (var i = 0; i < data.deviceCapabilities.length; i++) { + console.log(msg + "getAbilityInfo data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]); + } + console.log(msg + "checkAbilityInfo readPermission : " + data.readPermission); + console.log(msg + "checkAbilityInfo writePermission : " + data.writePermission); + console.log(msg + "checkAbilityInfo formEntity : " + data.formEntity); + console.log(msg + "checkAbilityInfo minFormHeight : " + data.minFormHeight); + console.log(msg + "checkAbilityInfo defaultFormHeight : " + data.defaultFormHeight); + console.log(msg + "checkAbilityInfo minFormWidth : " + data.minFormWidth); + console.log(msg + "checkAbilityInfo defaultFormWidth : " + data.defaultFormWidth); + console.log(msg + "checkAbilityInfo uri : " + data.uri); + console.log(msg + "checkAbilityInfo customizeData : " + data.customizeData); + console.log(msg + "checkAbilityInfo labelId : " + data.labelId); + console.log(msg + "checkAbilityInfo subType : " + data.subType); + + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.bundleName)).assertEqual("string"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.labelId)).assertEqual("number"); + expect(typeof (data.descriptionId)).assertEqual("number"); + expect(typeof (data.iconId)).assertEqual("number"); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.process)).assertEqual("string"); + expect(typeof (data.targetAbility)).assertEqual("string"); + expect(typeof (data.backgroundModes)).assertEqual("number"); + expect(typeof (data.isVisible)).assertEqual("boolean"); + expect(typeof (data.formEnabled)).assertEqual("boolean"); + expect(typeof (data.type)).assertEqual("number"); + expect(typeof (data.subType)).assertEqual("number"); + expect(typeof (data.orientation)).assertEqual("number"); + expect(typeof (data.launchMode)).assertEqual("number"); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.deviceTypes)).assertEqual(true); + expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); + expect(typeof (data.readPermission)).assertEqual("string"); + expect(typeof (data.writePermission)).assertEqual("string"); + expect(typeof (data.applicationInfo)).assertEqual("object"); + expect(typeof (data.formEntity)).assertEqual("number"); + expect(typeof (data.minFormHeight)).assertEqual("number"); + expect(typeof (data.defaultFormHeight)).assertEqual("number"); + expect(typeof (data.minFormWidth)).assertEqual("number"); + expect(typeof (data.defaultFormWidth)).assertEqual("number"); + expect(typeof (data.uri)).assertEqual("string"); + + expect(data.bundleName).assertEqual("com.ohos.acecollaboration"); + expect(data.name).assertEqual("com.ohos.acecollaboration.MainAbility"); + expect(data.label).assertEqual("$string:entry_MainAbility"); + expect(data.description).assertEqual("$string:mainability_description"); + expect(data.icon).assertEqual("$media:icon"); + expect(data.descriptionId > 0).assertTrue(); + expect(data.iconId > 0).assertTrue(); + expect(data.moduleName).assertEqual("entry"); + expect(data.process).assertEqual(""); + expect(data.targetAbility).assertEqual(""); + expect(data.backgroundModes).assertEqual(0); + expect(data.isVisible).assertEqual(true); + expect(data.formEnabled).assertEqual(false); + expect(data.type).assertEqual(1); + expect(data.orientation).assertEqual(0); + expect(data.launchMode).assertEqual(1); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(data.readPermission).assertEqual(""); + expect(data.writePermission).assertEqual(""); + checkApplicationInfo(msg, data.applicationInfo); + expect(data.formEntity).assertEqual(0); + expect(data.minFormHeight).assertEqual(0); + expect(data.defaultFormHeight).assertEqual(0); + expect(data.minFormWidth).assertEqual(0); + expect(data.defaultFormWidth).assertEqual(0); + expect(data.uri).assertEqual(""); + expect(data.labelId > 0).assertTrue(); + expect(data.subType).assertEqual(0); + + console.log(msg + "---checkAbilityInfo End--- "); + } + + function checkApplicationInfo(msg, info) { + console.log(msg + "checkApplicationInfo start : " + JSON.stringify(info)); + console.log(msg + "checkApplicationInfo name : " + info.name); + console.log(msg + "checkApplicationInfo description : " + info.description); + console.log(msg + "checkApplicationInfo descriptionId : " + info.descriptionId); + console.log(msg + "checkApplicationInfo systemApp : " + info.systemApp); + console.log(msg + "checkApplicationInfo enabled : " + info.enabled); + console.log(msg + "checkApplicationInfo label : " + info.label); + console.log(msg + "checkApplicationInfo labelId : " + info.labelId); + console.log(msg + "checkApplicationInfo icon : " + info.icon); + console.log(msg + "checkApplicationInfo iconId : " + info.iconId); + console.log(msg + "checkApplicationInfo process : " + info.process); + console.log(msg + "checkApplicationInfo supportedModes : " + info.supportedModes); + + console.log(msg + "checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length); + for (var j = 0; j < info.moduleSourceDirs.length; j++) { + console.log(msg + "checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]); + } + console.log(msg + "checkApplicationInfo permissions length : " + info.permissions.length); + for (var k = 0; k < info.permissions.length; k++) { + console.log(msg + "checkApplicationInfo info.permissions[" + k + "] : " + info.permissions[k]); + } + console.log(msg + "checkApplicationInfo moduleInfos length : " + info.moduleInfos.length); + for (var i = 0; i < info.moduleInfos.length; i++) { + console.log(msg + "checkApplicationInfo info.moduleInfos[" + i + "].moduleName : " + + info.moduleInfos[i].moduleName); + console.log(msg + "checkApplicationInfo info.moduleInfos[" + i + "].moduleSourceDir : " + + info.moduleInfos[i].moduleSourceDir); + } + console.log(msg + "checkApplicationInfo entryDir : " + info.entryDir); + + expect(typeof (info)).assertEqual("object"); + expect(typeof (info.name)).assertEqual("string"); + expect(typeof (info.description)).assertEqual("string"); + expect(typeof (info.descriptionId)).assertEqual("number"); + expect(typeof (info.systemApp)).assertEqual("boolean"); + expect(typeof (info.enabled)).assertEqual("boolean"); + expect(typeof (info.label)).assertEqual("string"); + expect(typeof (info.labelId)).assertEqual("string"); + expect(typeof (info.icon)).assertEqual("string"); + expect(typeof (info.iconId)).assertEqual("string"); + expect(typeof (info.process)).assertEqual("string"); + expect(typeof (info.supportedModes)).assertEqual("number"); + expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true); + expect(Array.isArray(info.permissions)).assertEqual(true); + expect(Array.isArray(info.moduleInfos)).assertEqual(true); + expect(typeof (info.entryDir)).assertEqual("string"); + + expect(info.name).assertEqual("com.ohos.acecollaboration"); + expect(info.description).assertEqual("$string:mainability_description"); + expect(info.descriptionId > 0).assertTrue(); + expect(info.systemApp).assertEqual(true); + expect(info.enabled).assertEqual(true); + expect(info.label).assertEqual("$string:entry_MainAbility"); + expect(info.icon).assertEqual("$media:icon"); + expect(info.process).assertEqual(""); + expect(info.supportedModes).assertEqual(0); + expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + if (info.moduleSourceDirs.length == 1){ + expect(info.moduleInfos[0].moduleName).assertEqual("entry"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + }else if(info.moduleSourceDirs.length == 2) { + if (info.moduleInfos[0].moduleName == "myapplication1") { + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication1"); + expect(info.moduleInfos[1].moduleName).assertEqual("entry"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + }else{ + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication2"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication2"); + expect(info.moduleInfos[1].moduleName).assertEqual("entry"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + } + }else { + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication1"); + expect(info.moduleInfos[1].moduleName).assertEqual("myapplication2"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication2"); + expect(info.moduleInfos[2].moduleName).assertEqual("entry"); + expect(info.moduleInfos[2].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + } + + console.log(msg + "---checkApplicationInfo End--- "); + + } + + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getAppVersionInfoJsunit.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getAppVersionInfoJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..852ff5ee53828ce888492e87bfee2a8a8fc9f057 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getAppVersionInfoJsunit.test.ets @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2021 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 {describe, it, expect} from "deccjsunit/index.ets"; +import Utils from './Utils'; +import ability_featureAbility from '@ohos.ability.featureAbility'; + +export default function getHapModuleInfoJsunit() { + describe('appInfoTest', function () { + /** + * @tc.number: context_getAppVersionInfo_test_0100 + * @tc.name: getAppVersionInfo:Gets the version information for the application. + * @tc.desc: Check the return type of the interface (by Promise) + * @tc.level 0 + */ + it('context_getAppVersionInfo_test_0100', 0, async function (done) { + console.info('[context_getAppVersionInfo_test_0100] START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + var context = ability_featureAbility.getContext(); + context.getAppVersionInfo() + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getAppVersionInfo_test_0100', timeOldStamp, timeNewStamp); + console.info('[context_getAppVersionInfo_test_0100] data is:' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("object"); + }).catch((error) => { + console.error('[context_getAppVersionInfo_test_0100] failed:' + JSON.stringify(error)); + }) + var promise = await context.getAppVersionInfo(); + console.info('---[context_getAppVersionInfo_test_0100] check---'); + checkAppVersionInfo('context_getAppVersionInfo_test_0100', promise); + console.info('[context_getAppVersionInfo_test_0100] FINISH'); + done(); + }); + + /** + * @tc.number: context_getAppVersionInfo_test_0200 + * @tc.name: getAppVersionInfo:Gets the version information for the application. + * @tc.desc: Check the return type of the interface (by Callback) + * @tc.level 0 + */ + it('context_getAppVersionInfo_test_0200', 0, async function (done) { + try { + console.info('[context_getAppVersionInfo_test_0200] START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + var context = ability_featureAbility.getContext(); + context.getAppVersionInfo((error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getAppVersionInfo_test_0200', timeOldStamp, timeNewStamp); + console.info('[context_getAppVersionInfo_test_0200] data is:' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("object"); + }); + } + catch (error) { + console.error('[context_getAppVersionInfo_test_0200] failed: ' + JSON.stringify(error)); + } + var callback = await context.getAppVersionInfo(); + console.info('---[context_getAppVersionInfo_test_0200] check---'); + checkAppVersionInfo('context_getAppVersionInfo_test_0200', callback); + console.info('[context_getAppVersionInfo_test_0200] FINISH'); + done(); + }); + + function checkAppVersionInfo(msg, data) { + console.log(msg + "checkAppVersionInfo start : " + JSON.stringify(data)); + console.log(msg + "checkAppVersionInfo appName : " + data.appName); + console.log(msg + "checkAppVersionInfo versionCode : " + data.versionCode); + console.log(msg + "checkAppVersionInfo versionName : " + data.versionName); + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.appName)).assertEqual("string"); + expect(typeof (data.versionCode)).assertEqual("number"); + expect(typeof (data.versionName)).assertEqual("string"); + expect(data.appName).assertEqual(""); + expect(data.versionCode).assertEqual(1000000); + expect(data.versionName).assertEqual("1.0.0"); + console.log(msg + "---checkAppVersionInfo End--- "); + } + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getApplicationContextJsunit.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getApplicationContextJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c342915a809774aaeaa389eb9571582ef5ae3996 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getApplicationContextJsunit.test.ets @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2021 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 {describe, it, expect} from "deccjsunit/index.ets"; +import Utils from './Utils'; +import ability_featureAbility from '@ohos.ability.featureAbility'; + +export default function getHapModuleInfoJsunit() { + describe('appInfoTest', function () { + /** + * @tc.number: context_getApplicationContext_test_0100 + * @tc.name: getApplicationContext:Gets the application context information. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it('context_getApplicationContext_test_0100', 0, async function (done) { + try { + console.info('[context_getApplicationContext_test_0100] START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + var context = ability_featureAbility.getContext().getApplicationContext(); + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getApplicationContext_test_0100', timeOldStamp, timeNewStamp); + console.info('[context_getApplicationContext_test_0100] data is:' + JSON.stringify(context)); + } + catch (error) { + console.error('[context_getApplicationContext_test_0100] failed:' + JSON.stringify(error)); + } + expect(typeof (context)).assertEqual("object"); + console.info('[context_getApplicationContext_test_0100] FINISH'); + done(); + }); + + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getHapModuleInfoJsunit.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getHapModuleInfoJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7d99f6be366de1d94e506061ae4af379bccd8c37 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility/test/getHapModuleInfoJsunit.test.ets @@ -0,0 +1,352 @@ +/** + * Copyright (c) 2021 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 {describe, it, expect} from "deccjsunit/index.ets"; +import Utils from './Utils'; +import ability_featureAbility from '@ohos.ability.featureAbility'; + +export default function getHapModuleInfoJsunit() { + describe('appInfoTest', function () { + /** + * @tc.number: context_getHapModuleInfo_test_0100 + * @tc.name: getHapModuleInfo:Obtains the HapModuleInfo object of the application. + * @tc.desc: Check the return type of the interface (by Promise) + * @tc.level 0 + */ + it('context_getHapModuleInfo_test_0100', 0, async function (done) { + console.info('[context_getHapModuleInfo_test_0100] START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + var context = ability_featureAbility.getContext(); + context.getHapModuleInfo() + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getHapModuleInfo_test_0100', timeOldStamp, timeNewStamp); + console.info('[context_getHapModuleInfo_test_0100] data is:' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("object"); + }) + .catch((error) => { + console.error('[context_getHapModuleInfo_test_0100] failed:' + JSON.stringify(error)); + }) + var promise = await context.getHapModuleInfo(); + console.info('---[context_getHapModuleInfo_test_0100] check---'); + checkHapModuleInfo('context_getHapModuleInfo_test_0100', promise); + console.info('[context_getHapModuleInfo_test_0100] FINISH'); + done(); + }); + + /** + * @tc.number: context_getHapModuleInfo_test_0200 + * @tc.name: getHapModuleInfo:Obtains the HapModuleInfo object of the application. + * @tc.desc: Check the return type of the interface (by Callback) + * @tc.level 0 + */ + it('context_getHapModuleInfo_test_0200', 0, async function (done) { + let callback; + try { + console.info('[context_getHapModuleInfo_test_0200] START'); + var timeOldStamp = await Utils.getNowTime(); + var context = ability_featureAbility.getContext(); + context.getHapModuleInfo((error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getHapModuleInfo_test_0200', timeOldStamp, timeNewStamp); + console.info('[context_getHapModuleInfo_test_0200] data is:' + JSON.stringify(data)); + callback = data; + expect(typeof (data)).assertEqual("object"); + }); + } catch (error) { + console.error('[context_getHapModuleInfo_test_0200] failed: ' + JSON.stringify(error)); + } + await Utils.sleep(1000); + console.info('---[context_getHapModuleInfo_test_0200] check---'); + checkHapModuleInfo('context_getHapModuleInfo_test_0200', callback); + console.info('[context_getHapModuleInfo_test_0200] FINISH'); + done(); + }); + + /** + * @tc.number: context_getHapModuleInfo_test_0300_1 + * @tc.name: getHapModuleInfo:Obtains the HapModuleInfo object of the application. + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ + it('context_getHapModuleInfo_test_0300_1', 0, async function (done) { + console.info('[context_getHapModuleInfo_test_0300_1] START'); + var str = { + "want": { + "bundleName": "com.ohos.acecollaboration", + "abilityName": "com.example.myapplication1.MainAbility", + }, + }; + ability_featureAbility.startAbility(str) + .then((data) => { + console.info('[context_getHapModuleInfo_test_0300_1] start myapplication1 successful: ' + JSON.stringify(data)) + }).catch((error) => { + console.error('[context_getHapModuleInfo_test_0300_1] start myapplication1 Cause: ' + JSON.stringify(error)); + }) + done(); + }); + + function checkHapModuleInfo(msg, data) { + console.log(msg + "checkHapModuleInfo start " + JSON.stringify(data)); + console.log(msg + "checkHapModuleInfo name : " + data.name); + console.log(msg + "checkHapModuleInfo description : " + data.description); + console.log(msg + "checkHapModuleInfo descriptionId : " + data.descriptionId); + console.log(msg + "checkHapModuleInfo icon : " + data.icon); + console.log(msg + "checkHapModuleInfo label : " + data.label); + console.log(msg + "checkHapModuleInfo labelId : " + data.labelId); + console.log(msg + "checkHapModuleInfo iconId : " + data.iconId); + console.log(msg + "checkHapModuleInfo backgroundImg : " + data.backgroundImg); + console.log(msg + "checkHapModuleInfo supportedModes : " + data.supportedModes); + console.log(msg + "checkHapModuleInfo reqCapabilities length : " + data.reqCapabilities.length); + for (var j = 0; j < data.reqCapabilities.length; j++) { + console.log(msg + "getHapModuleInfo data.reqCapabilities[" + j + "] : " + data.reqCapabilities[j]); + } + console.log(msg + "checkHapModuleInfo deviceTypes length : " + data.deviceTypes.length); + for (var k = 0; k < data.deviceTypes.length; k++) { + console.log(msg + "getHapModuleInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]); + } + console.log(msg + "checkHapModuleInfo abilityInfos length : " + data.abilityInfos.length); + console.log(msg + "checkHapModuleInfo moduleName : " + data.moduleName); + console.log(msg + "checkHapModuleInfo mainAbilityName : " + data.mainAbilityName); + console.log(msg + "checkHapModuleInfo installationFree : " + data.installationFree); + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.descriptionId)).assertEqual("number"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.labelId)).assertEqual("number"); + expect(typeof (data.iconId)).assertEqual("number"); + expect(typeof (data.backgroundImg)).assertEqual("string"); + expect(typeof (data.supportedModes)).assertEqual("number"); + expect(Array.isArray(data.reqCapabilities)).assertEqual(true); + expect(Array.isArray(data.deviceTypes)).assertEqual(true); + expect(Array.isArray(data.abilityInfos)).assertEqual(true); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.mainAbilityName)).assertEqual("string"); + expect(typeof (data.installationFree)).assertEqual("boolean"); + expect(data.name).assertEqual("com.ohos.acecollaboration"); + expect(data.description).assertEqual(""); + expect(data.descriptionId).assertEqual(0); + expect(data.icon).assertEqual("$media:icon"); + expect(data.label).assertEqual("$string:entry_MainAbility"); + expect(data.labelId).assertEqual(0); + expect(data.iconId).assertEqual(0); + expect(data.backgroundImg).assertEqual(""); + expect(data.supportedModes).assertEqual(0); + expect(data.deviceTypes[0]).assertEqual("phone"); + for (var i = 0; i < data.abilityInfos.length; i++) { + console.log(msg + "-------AbilityInfo data.abilityInfos[" + i + "] : START ------" ); + checkAbilityInfo(msg,data.abilityInfos[i]); + } + expect(data.moduleName).assertEqual("entry") + expect(data.mainAbilityName).assertEqual(""); + expect(data.installationFree).assertEqual(false); + console.log(msg + "---checkHapModuleInfo End---"); + } + + function checkAbilityInfo(msg,data) { + console.log(msg+ "checkAbilityInfo start " + JSON.stringify(data)); + console.log(msg+ "checkAbilityInfo bundleName : " + data.bundleName); + console.log(msg+ "checkAbilityInfo name : " + data.name); + console.log(msg+ "checkAbilityInfo label : " + data.label); + console.log(msg+ "checkAbilityInfo description : " + data.description); + console.log(msg+ "checkAbilityInfo icon : " + data.icon); + console.log(msg+ "checkAbilityInfo descriptionId : " + data.descriptionId); + console.log(msg+ "checkAbilityInfo iconId : " + data.iconId); + console.log(msg+ "checkAbilityInfo moduleName : " + data.moduleName); + console.log(msg+ "checkAbilityInfo process : " + data.process); + console.log(msg+ "checkAbilityInfo targetAbility : " + data.targetAbility); + console.log(msg+ "checkAbilityInfo backgroundModes : " + data.backgroundModes); + console.log(msg+ "checkAbilityInfo isVisible : " + data.isVisible); + console.log(msg+ "checkAbilityInfo formEnabled : " + data.formEnabled); + console.log(msg+ "checkAbilityInfo type : " + data.type) + console.log(msg+ "checkAbilityInfo orientation : " + data.orientation); + console.log(msg+ "checkAbilityInfo launchMode : " + data.launchMode); + console.log(msg+ "checkAbilityInfo permissions length : " + data.permissions.length); + for (var j = 0; j < data.permissions.length; j++) { + console.log(msg+ "getAbilityInfo data.permissions[" + j + "] : " + data.permissions[j]); + } + console.log(msg+ "checkAbilityInfo deviceTypes length : " + data.deviceTypes.length); + for (var k = 0; k < data.deviceTypes.length; k++) { + console.log(msg+ "getAbilityInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]); + } + console.log(msg+ "checkAbilityInfo deviceCapabilities length : " + data.deviceCapabilities.length); + for (var i = 0; i < data.deviceCapabilities.length; i++) { + console.log(msg+ "getAbilityInfo data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]); + } + console.log(msg+ "checkAbilityInfo readPermission : " + data.readPermission); + console.log(msg+ "checkAbilityInfo writePermission : " + data.writePermission); + console.log(msg+ "checkAbilityInfo formEntity : " + data.formEntity); + console.log(msg+ "checkAbilityInfo minFormHeight : " + data.minFormHeight); + console.log(msg+ "checkAbilityInfo defaultFormHeight : " + data.defaultFormHeight); + console.log(msg+ "checkAbilityInfo minFormWidth : " + data.minFormWidth); + console.log(msg+ "checkAbilityInfo defaultFormWidth : " + data.defaultFormWidth); + console.log(msg+ "checkAbilityInfo uri : " + data.uri); + console.log(msg+ "checkAbilityInfo labelId : " + data.labelId); + console.log(msg+ "checkAbilityInfo subType : " + data.subType); + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.bundleName)).assertEqual("string"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.labelId)).assertEqual("number"); + expect(typeof (data.descriptionId)).assertEqual("number"); + expect(typeof (data.iconId)).assertEqual("number"); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.process)).assertEqual("string"); + expect(typeof (data.targetAbility)).assertEqual("string"); + expect(typeof (data.backgroundModes)).assertEqual("number"); + expect(typeof (data.isVisible)).assertEqual("boolean"); + expect(typeof (data.formEnabled)).assertEqual("boolean"); + expect(typeof (data.type)).assertEqual("number"); + expect(typeof (data.subType)).assertEqual("number"); + expect(typeof (data.orientation)).assertEqual("number"); + expect(typeof (data.launchMode)).assertEqual("number"); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.deviceTypes)).assertEqual(true); + expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); + expect(typeof (data.readPermission)).assertEqual("string"); + expect(typeof (data.writePermission)).assertEqual("string"); + expect(typeof (data.applicationInfo)).assertEqual("object"); + expect(typeof (data.formEntity)).assertEqual("number"); + expect(typeof (data.minFormHeight)).assertEqual("number"); + expect(typeof (data.defaultFormHeight)).assertEqual("number"); + expect(typeof (data.minFormWidth)).assertEqual("number"); + expect(typeof (data.defaultFormWidth)).assertEqual("number"); + expect(typeof (data.uri)).assertEqual("string"); + expect(data.bundleName).assertEqual("com.ohos.acecollaboration"); + expect(data.name).assertEqual("com.ohos.acecollaboration.MainAbility"); + expect(data.label).assertEqual("$string:entry_MainAbility"); + expect(data.description).assertEqual("$string:mainability_description"); + expect(data.icon).assertEqual("$media:icon"); + expect(data.descriptionId > 0).assertTrue(); + expect(data.iconId > 0).assertTrue(); + expect(data.moduleName).assertEqual("entry"); + expect(data.process).assertEqual(""); + expect(data.targetAbility).assertEqual(""); + expect(data.backgroundModes).assertEqual(0); + expect(data.isVisible).assertEqual(true); + expect(data.formEnabled).assertEqual(false); + expect(data.type).assertEqual(1); + expect(data.orientation).assertEqual(0); + expect(data.launchMode).assertEqual(1); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(data.readPermission).assertEqual(""); + expect(data.writePermission).assertEqual(""); + checkApplicationInfo(msg,data.applicationInfo); + expect(data.formEntity).assertEqual(0); + expect(data.minFormHeight).assertEqual(0); + expect(data.defaultFormHeight).assertEqual(0); + expect(data.minFormWidth).assertEqual(0); + expect(data.defaultFormWidth).assertEqual(0); + expect(data.uri).assertEqual(""); + expect(data.labelId > 0).assertTrue(); + expect(data.subType).assertEqual(0); + console.log(msg+ "---checkAbilityInfo End--- "); + } + + function checkApplicationInfo(msg,info) { + console.log(msg+ "checkApplicationInfo start : " + JSON.stringify(info)); + console.log(msg+ "checkApplicationInfo name : " + info.name); + console.log(msg+ "checkApplicationInfo description : " + info.description); + console.log(msg+ "checkApplicationInfo descriptionId : " + info.descriptionId); + console.log(msg+ "checkApplicationInfo systemApp : " + info.systemApp); + console.log(msg+ "checkApplicationInfo enabled : " + info.enabled); + console.log(msg+ "checkApplicationInfo label : " + info.label); + console.log(msg+ "checkApplicationInfo labelId : " + info.labelId); + console.log(msg+ "checkApplicationInfo icon : " + info.icon); + console.log(msg+ "checkApplicationInfo iconId : " + info.iconId); + console.log(msg+ "checkApplicationInfo process : " + info.process); + console.log(msg+ "checkApplicationInfo supportedModes : " + info.supportedModes); + console.log(msg+ "checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length); + for (var j = 0; j < info.moduleSourceDirs.length; j++) { + console.log(msg+ "checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]); + } + console.log(msg+ "checkApplicationInfo permissions length : " + info.permissions.length); + for (var k = 0; k < info.permissions.length; k++) { + console.log(msg+ "checkApplicationInfo info.permissions[" + k + "] : " + info.permissions[k]); + } + console.log(msg+ "checkApplicationInfo moduleInfos length : " + info.moduleInfos.length); + for (var i = 0; i < info.moduleInfos.length; i++) { + console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleName : " + + info.moduleInfos[i].moduleName); + console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleSourceDir : " + + info.moduleInfos[i].moduleSourceDir); + } + console.log(msg+ "checkApplicationInfo entryDir : " + info.entryDir); + expect(typeof (info)).assertEqual("object"); + expect(typeof (info.name)).assertEqual("string"); + expect(typeof (info.description)).assertEqual("string"); + expect(typeof (info.descriptionId)).assertEqual("number"); + expect(typeof (info.systemApp)).assertEqual("boolean"); + expect(typeof (info.enabled)).assertEqual("boolean"); + expect(typeof (info.label)).assertEqual("string"); + expect(typeof (info.labelId)).assertEqual("string"); + expect(typeof (info.icon)).assertEqual("string"); + expect(typeof (info.iconId)).assertEqual("string"); + expect(typeof (info.process)).assertEqual("string"); + expect(typeof (info.supportedModes)).assertEqual("number"); + expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true); + expect(Array.isArray(info.permissions)).assertEqual(true); + expect(Array.isArray(info.moduleInfos)).assertEqual(true); + expect(typeof (info.entryDir)).assertEqual("string"); + if (info.moduleSourceDirs.length == 1){ + expect(info.moduleInfos[0].moduleName).assertEqual("entry"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + }else if(info.moduleSourceDirs.length == 2) { + if (info.moduleInfos[0].moduleName == "myapplication1") { + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication1"); + expect(info.moduleInfos[1].moduleName).assertEqual("entry"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + }else{ + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication2"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication2"); + expect(info.moduleInfos[1].moduleName).assertEqual("entry"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + } + }else { + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication1"); + expect(info.moduleInfos[1].moduleName).assertEqual("myapplication2"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication2"); + expect(info.moduleInfos[2].moduleName).assertEqual("entry"); + expect(info.moduleInfos[2].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + } + expect(info.name).assertEqual("com.ohos.acecollaboration"); + expect(info.description).assertEqual("$string:mainability_description"); + expect(info.descriptionId > 0).assertTrue(); + expect(info.systemApp).assertEqual(true); + expect(info.enabled).assertEqual(true); + expect(info.label).assertEqual("$string:entry_MainAbility"); + expect(info.icon).assertEqual("$media:icon"); + expect(info.process).assertEqual(""); + expect(info.supportedModes).assertEqual(0); + expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + console.log(msg+ "---checkApplicationInfo End--- "); + } + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/app.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc86a0485f5fa3d43dc0d7a7d858e3f41ed87304 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/app.ets @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2021 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. + */ +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/pages/index.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e90a861b06feb9417415562b2421a432ac6d461d --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/pages/index.ets @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2021 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 featureAbility from "@ohos.ability.featureAbility"; +import testsuite2 from "../test/List.test.ets"; +import file from '@system.file'; +import {Core, ExpectExtend, ReportExtend} from "deccjsunit/index.ets"; + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + console.info("start run testcase2!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + console.info('parameters2---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite2(); + core.execute(); + console.info('Operation successful2. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed2. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/List.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3d3c47dce1c1f0a41a634b0d1559aa3b54c517e2 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/List.test.ets @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2021 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 getAbilityInfoJsunit from './getAbilityInfoJsunit2.test.ets'; + +export default function testsuite2() { + getAbilityInfoJsunit(); +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/Utils.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..44eeb6fe62c02130e9d8dd290b157426e2af9d2f --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/Utils.ets @@ -0,0 +1,48 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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. + */ + +export default class Utils { + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getNowTime() { + return new Date().getTime(); + } + + /** + * 接口调用时间 + * @param startTime 接口调用开始时间 + * @param endTime 接口调用结束时间 + */ + static getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; + } +} + + + + diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/getAbilityInfoJsunit2.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/getAbilityInfoJsunit2.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..827da661a688dc43e67505489d4e27b7da6d4ecd --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/MainAbility2/test/getAbilityInfoJsunit2.test.ets @@ -0,0 +1,245 @@ +/** + * Copyright (c) 2021 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 {describe, it, expect} from "deccjsunit/index.ets"; +import Utils from './Utils'; +import ability_featureAbility from '@ohos.ability.featureAbility'; + +export default function getAbilityInfoJsunit() { + describe('appInfoTest', function () { + + /** + * @tc.number: context_getAbilityInfo_test_0300 + * @tc.name: getAbilityInfo:Query the current attributionability details. + * @tc.desc: Check the return type of the interface (by Callback) + * @tc.level 0 + */ + it('context_getAbilityInfo_test_0300', 0, async function (done) { + try{ + console.info('[context_getAbilityInfo_test_0300] START2'); + var timeOldStamp = await Utils.getNowTime(); + var context = ability_featureAbility.getContext(); + await context.getAbilityInfo((error, data)=>{ + var timeNewStamp= Utils.getNowTime(); + Utils.getDurationTime('context_getAbilityInfo_test_0300',timeOldStamp,timeNewStamp); + console.info('[context_getAbilityInfo_test_0300] data is:' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("object"); + }); + } catch (error){ + console.error('[context_getAbilityInfo_test_0300] failed: ' + JSON.stringify(error)); + } + var callback = await context.getAbilityInfo(); + console.info('---[context_getAbilityInfo_test_0300] check---'); + checkAbilityInfo2('context_getAbilityInfo_test_0300',callback); + console.info('[context_getAbilityInfo_test_0300] FINISH'); + done(); + }) + + function checkAbilityInfo2(msg,data) { + console.log(msg+ "checkAbilityInfo2 start " + JSON.stringify(data)); + console.log(msg+ "checkAbilityInfo2 bundleName : " + data.bundleName); + console.log(msg+ "checkAbilityInfo2 name : " + data.name); + console.log(msg+ "checkAbilityInfo2 label : " + data.label); + console.log(msg+ "checkAbilityInfo2 description : " + data.description); + console.log(msg+ "checkAbilityInfo2 icon : " + data.icon); + console.log(msg+ "checkAbilityInfo2 descriptionId : " + data.descriptionId); + console.log(msg+ "checkAbilityInfo2 iconId : " + data.iconId); + console.log(msg+ "checkAbilityInfo2 moduleName : " + data.moduleName); + console.log(msg+ "checkAbilityInfo2 process : " + data.process); + console.log(msg+ "checkAbilityInfo2 targetAbility : " + data.targetAbility); + console.log(msg+ "checkAbilityInfo2 backgroundModes : " + data.backgroundModes); + console.log(msg+ "checkAbilityInfo2 isVisible : " + data.isVisible); + console.log(msg+ "checkAbilityInfo2 formEnabled : " + data.formEnabled); + console.log(msg+ "checkAbilityInfo2 type : " + data.type) + console.log(msg+ "checkAbilityInfo2 orientation : " + data.orientation); + console.log(msg+ "checkAbilityInfo2 launchMode : " + data.launchMode); + console.log(msg+ "checkAbilityInfo2 permissions length : " + data.permissions.length); + for (var j = 0; j < data.permissions.length; j++) { + console.log(msg+ "getAbilityInfo2 data.permissions[" + j + "] : " + data.permissions[j]); + } + console.log(msg+ "checkAbilityInfo2 deviceTypes length : " + data.deviceTypes.length); + for (var k = 0; k < data.deviceTypes.length; k++) { + console.log(msg+ "getAbilityInfo2 data.deviceTypes[" + k + "] : " + data.deviceTypes[k]); + } + console.log(msg+ "checkAbilityInfo2 deviceCapabilities length : " + data.deviceCapabilities.length); + for (var i = 0; i < data.deviceCapabilities.length; i++) { + console.log(msg+ "getAbilityInfo2 data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]); + } + console.log(msg+ "checkAbilityInfo2 readPermission : " + data.readPermission); + console.log(msg+ "checkAbilityInfo2 writePermission : " + data.writePermission); + console.log(msg+ "checkAbilityInfo2 formEntity : " + data.formEntity); + console.log(msg+ "checkAbilityInfo2 minFormHeight : " + data.minFormHeight); + console.log(msg+ "checkAbilityInfo2 defaultFormHeight : " + data.defaultFormHeight); + console.log(msg+ "checkAbilityInfo2 minFormWidth : " + data.minFormWidth); + console.log(msg+ "checkAbilityInfo2 defaultFormWidth : " + data.defaultFormWidth); + console.log(msg+ "checkAbilityInfo2 uri : " + data.uri); + console.log(msg+ "checkAbilityInfo2 customizeData : " + data.customizeData); + console.log(msg+ "checkAbilityInfo2 labelId : " + data.labelId); + console.log(msg+ "checkAbilityInfo2 subType : " + data.subType); + + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.bundleName)).assertEqual("string"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.labelId)).assertEqual("number"); + expect(typeof (data.descriptionId)).assertEqual("number"); + expect(typeof (data.iconId)).assertEqual("number"); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.process)).assertEqual("string"); + expect(typeof (data.targetAbility)).assertEqual("string"); + expect(typeof (data.backgroundModes)).assertEqual("number"); + expect(typeof (data.isVisible)).assertEqual("boolean"); + expect(typeof (data.formEnabled)).assertEqual("boolean"); + expect(typeof (data.type)).assertEqual("number"); + expect(typeof (data.subType)).assertEqual("number"); + expect(typeof (data.orientation)).assertEqual("number"); + expect(typeof (data.launchMode)).assertEqual("number"); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.deviceTypes)).assertEqual(true); + expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); + expect(typeof (data.readPermission)).assertEqual("string"); + expect(typeof (data.writePermission)).assertEqual("string"); + expect(typeof (data.applicationInfo)).assertEqual("object"); + expect(typeof (data.formEntity)).assertEqual("number"); + expect(typeof (data.minFormHeight)).assertEqual("number"); + expect(typeof (data.defaultFormHeight)).assertEqual("number"); + expect(typeof (data.minFormWidth)).assertEqual("number"); + expect(typeof (data.defaultFormWidth)).assertEqual("number"); + expect(typeof (data.uri)).assertEqual("string"); + + expect(data.bundleName).assertEqual("com.ohos.acecollaboration"); + expect(data.name).assertEqual("com.ohos.acecollaboration.MainAbility2"); + expect(data.label).assertEqual("$string:entry_MainAbility2"); + expect(data.description).assertEqual("$string:description_mainability2"); + expect(data.icon).assertEqual("$media:icon"); + expect(data.descriptionId > 0).assertTrue(); + expect(data.iconId > 0).assertTrue(); + expect(data.moduleName).assertEqual("entry"); + expect(data.process).assertEqual(""); + expect(data.targetAbility).assertEqual(""); + expect(data.backgroundModes).assertEqual(0); + expect(data.isVisible).assertEqual(false); + expect(data.formEnabled).assertEqual(false); + expect(data.type).assertEqual(1); + expect(data.orientation).assertEqual(0); + expect(data.launchMode).assertEqual(1); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(data.readPermission).assertEqual(""); + expect(data.writePermission).assertEqual(""); + checkApplicationInfo2(msg,data.applicationInfo); + expect(data.formEntity).assertEqual(0); + expect(data.minFormHeight).assertEqual(0); + expect(data.defaultFormHeight).assertEqual(0); + expect(data.minFormWidth).assertEqual(0); + expect(data.defaultFormWidth).assertEqual(0); + expect(data.uri).assertEqual(""); + expect(data.labelId >0).assertTrue(); + expect(data.subType).assertEqual(0); + console.log(msg+ "---checkAbilityInfo End--- "); + } + + function checkApplicationInfo2(msg,info) { + console.log(msg+ "checkApplicationInfo start : " + JSON.stringify(info)); + console.log(msg+ "checkApplicationInfo name : " + info.name); + console.log(msg+ "checkApplicationInfo description : " + info.description); + console.log(msg+ "checkApplicationInfo descriptionId : " + info.descriptionId); + console.log(msg+ "checkApplicationInfo systemApp : " + info.systemApp); + console.log(msg+ "checkApplicationInfo enabled : " + info.enabled); + console.log(msg+ "checkApplicationInfo label : " + info.label); + console.log(msg+ "checkApplicationInfo labelId : " + info.labelId); + console.log(msg+ "checkApplicationInfo icon : " + info.icon); + console.log(msg+ "checkApplicationInfo iconId : " + info.iconId); + console.log(msg+ "checkApplicationInfo process : " + info.process); + console.log(msg+ "checkApplicationInfo supportedModes : " + info.supportedModes); + + console.log(msg+ "checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length); + for (var j = 0; j < info.moduleSourceDirs.length; j++) { + console.log(msg+ "checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]); + } + console.log(msg+ "checkApplicationInfo permissions length : " + info.permissions.length); + for (var k = 0; k < info.permissions.length; k++) { + console.log(msg+ "checkApplicationInfo info.permissions[" + k + "] : " + info.permissions[k]); + } + console.log(msg+ "checkApplicationInfo moduleInfos length : " + info.moduleInfos.length); + for (var i = 0; i < info.moduleInfos.length; i++) { + console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleName : " + info.moduleInfos[i].moduleName); + console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleSourceDir : " + info.moduleInfos[i].moduleSourceDir); + } + console.log(msg+ "checkApplicationInfo entryDir : " + info.entryDir); + + expect(typeof (info)).assertEqual("object"); + expect(typeof (info.name)).assertEqual("string"); + expect(typeof (info.description)).assertEqual("string"); + expect(typeof (info.descriptionId)).assertEqual("number"); + expect(typeof (info.systemApp)).assertEqual("boolean"); + expect(typeof (info.enabled)).assertEqual("boolean"); + expect(typeof (info.label)).assertEqual("string"); + expect(typeof (info.labelId)).assertEqual("string"); + expect(typeof (info.icon)).assertEqual("string"); + expect(typeof (info.iconId)).assertEqual("string"); + expect(typeof (info.process)).assertEqual("string"); + expect(typeof (info.supportedModes)).assertEqual("number"); + expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true); + expect(Array.isArray(info.permissions)).assertEqual(true); + expect(Array.isArray(info.moduleInfos)).assertEqual(true); + expect(typeof (info.entryDir)).assertEqual("string"); + + expect(info.name).assertEqual("com.ohos.acecollaboration"); + expect(info.description).assertEqual("$string:mainability_description"); + expect(info.descriptionId > 0).assertTrue(); + expect(info.systemApp).assertEqual(true); + expect(info.enabled).assertEqual(true); + expect(info.label).assertEqual("$string:entry_MainAbility"); + expect(info.icon).assertEqual("$media:icon"); + expect(info.process).assertEqual(""); + expect(info.supportedModes).assertEqual(0); + expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + if (info.moduleSourceDirs.length == 1){ + expect(info.moduleInfos[0].moduleName).assertEqual("entry"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + }else if(info.moduleSourceDirs.length == 2) { + if (info.moduleInfos[0].moduleName == "myapplication1") { + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication1"); + expect(info.moduleInfos[1].moduleName).assertEqual("entry"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + }else{ + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication2"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication2"); + expect(info.moduleInfos[1].moduleName).assertEqual("entry"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + } + }else { + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication1"); + expect(info.moduleInfos[1].moduleName).assertEqual("myapplication2"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication2"); + expect(info.moduleInfos[2].moduleName).assertEqual("entry"); + expect(info.moduleInfos[2].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + } + console.log(msg+ "---checkApplicationInfo End--- "); + } + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..1503232a7024bbced8a52b26449f056600b0f0bf --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2021 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 rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + }, + onConnect(want) { + console.info('ServiceAbility onConnect'); + return new StubTest("test"); + }, + onDisConnect(want) { + console.info('ServiceAbility onDisConnect'); + }, +}; diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility2/service.ts b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..a3c5e888497e748d7b1953bcbcbef23a6c0d0486 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility2/service.ts @@ -0,0 +1,132 @@ +/** + * Copyright (c) 2021 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 particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc' + +class StubTest2 extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility2 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility2 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +function getNowTime() { + return new Date().getTime(); +} + +function getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; +} + +async function sleep(time: any) { + var now = new Date(); + var exitTime = now.getTime() + time; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) + break; + } + console.info(`sleep ${time} over...`); +} + +export default { + onStart() { + console.info('ServiceAbility2 onStart'); + }, + onStop() { + console.info('ServiceAbility2 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility2 onCommand'); + let request = { + "bundleName": "com.ohos.acecollaboration", + "abilityName": "com.ohos.acecollaboration.ServiceAbility", + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.deviceId : ' + + JSON.stringify(element.deviceId)); + console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.bundleName : ' + + JSON.stringify(element.bundleName)); + console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.abilityName : ' + + JSON.stringify(element.abilityName)); + console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.uri : ' + + JSON.stringify(element.uri)); + console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect element.shortName : ' + + JSON.stringify(element.shortName)); + console.log('particleAbility_connectAbility_test_0100 ConnectAbility onConnect proxy : ' + + JSON.stringify(proxy)); + }, + onDisconnect: async function (element1: any) { + console.log('particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.deviceId : ' + + JSON.stringify(element1.deviceId)); + console.log('particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.bundleName : ' + + JSON.stringify(element1.bundleName)); + console.log('particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.abilityName: ' + + JSON.stringify(element1.abilityName)); + console.log('particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.uri : ' + + JSON.stringify(element1.uri)); + console.log('particleAbility_connectAbility_test_0100 ConnectAbility onDisconnect element.shortName : ' + + JSON.stringify(element1.shortName)); + }, + onFailed: async function (code: any) { + console.log('particleAbility_connectAbility_test_0100 ConnectAbility onFailed errCode : ' + code); + }, + } + + let connection_succeeded: any; + console.info('particleAbility_connectAbility_test_0100 start '); + var timeOldStamp = getNowTime(); + var connection = particleAbility.connectAbility(request, options); + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0100 connectability', timeOldStamp, timeNewStamp); + connection_succeeded = connection; + console.info('particleAbility_connectAbility_test_0100 service request is:' + JSON.stringify(request)); + console.info('particleAbility_connectAbility_test_0100 options is:' + JSON.stringify(options)); + console.info('particleAbility_connectAbility_test_0100 data is: ' + JSON.stringify(connection)); + console.info('particleAbility_connectAbility_test_0100 connection=: ' + connection); + sleep(5000); + console.info('particleAbility_connectAbility_test_0100 disconnectability start '); + var timeOldStamp = getNowTime(); + particleAbility.disconnectAbility(connection_succeeded).then((data: any) => { + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0100 disconnectability', timeOldStamp, timeNewStamp); + console.info('particleAbility_connectAbility_test_0100 disconnectability succeeded: ' + + JSON.stringify(data)); + }).catch((error: any) => { + console.error('particleAbility_connectAbility_test_0100 disconnectability failed. Cause: ' + + JSON.stringify(error)); + }) + }, + onConnect(want) { + console.info('ServiceAbility2 onConnect'); + return new StubTest2("test"); + }, +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility3/service.ts b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility3/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..72c61a28d0ce923795b0a7b8d5a0dfa2e598af64 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility3/service.ts @@ -0,0 +1,133 @@ +/** + * Copyright (c) 2021 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 particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc'; + +class StubTest3 extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility3 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility3 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +function getNowTime() { + return new Date().getTime(); +} + +function getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; +} + +async function sleep(time: any) { + var now = new Date(); + var exitTime = now.getTime() + time; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) + break; + } + console.info(`sleep ${time} over...`); +} + +export default { + onStart() { + console.info('ServiceAbility3 onStart'); + }, + onStop() { + console.info('ServiceAbility3 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility3 onCommand'); + let request = { + "bundleName": "com.ohos.acecollaboration", + "abilityName": "com.ohos.acecollaboration.ServiceAbility", + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.log('particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.deviceId : ' + + JSON.stringify(element.deviceId)) + console.log('particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.bundleName : ' + + JSON.stringify(element.bundleName)) + console.log('particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.abilityName : ' + + JSON.stringify(element.abilityName)) + console.log('particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.uri : ' + + JSON.stringify(element.uri)) + console.log('particleAbility_connectAbility_test_0200 ConnectAbility onConnect element.shortName : ' + + JSON.stringify(element.shortName)) + console.log('particleAbility_connectAbility_test_0200 ConnectAbility onConnect proxy : ' + + JSON.stringify(proxy)); + }, + onDisconnect: async function (element1: any) { + console.log('particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.deviceId :' + + JSON.stringify(element1.deviceId)); + console.log('particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.bundleName :' + + JSON.stringify(element1.bundleName)); + console.log('particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.abilityName :' + + JSON.stringify(element1.abilityName)); + console.log('particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.uri : ' + + JSON.stringify(element1.uri)); + console.log('particleAbility_connectAbility_test_0200 ConnectAbility onDisconnect element.shortName : ' + + JSON.stringify(element1.shortName)); + }, + onFailed: function (code: any) { + console.log('particleAbility_connectAbility_test_0200 ConnectAbility onFailed errCode: ' + code) + }, + } + + let connection_succeeded: any; + console.info('particleAbility_connectAbility_test_0200 start '); + var timeOldStamp = getNowTime(); + var connection = particleAbility.connectAbility(request, options); + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0200 connectability', timeOldStamp, timeNewStamp); + connection_succeeded = connection; + console.info('particleAbility_connectAbility_test_0200 service request is:' + JSON.stringify(request)); + console.info('particleAbility_connectAbility_test_0200 options is:' + JSON.stringify(options)); + console.info('particleAbility_connectAbility_test_0200 connection=: ' + connection); + sleep(5000); + console.info('particleAbility_connectAbility_test_0200 disconnectability start '); + try { + var timeOldStamp = getNowTime(); + particleAbility.disconnectAbility(connection_succeeded, (error, data) => { + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0200 disconnectability', timeOldStamp, timeNewStamp); + console.info('particleAbility_connectAbility_test_0200 disconnectability succeeded: ' + JSON.stringify(data)); + }) + } + catch(error: any){ + console.error('particleAbility_connectAbility_test_0200 disconnectability failed. Cause: ' + + JSON.stringify(error)); + } + }, + onConnect(want) { + console.info('ServiceAbility3 onConnect'); + return new StubTest3("test"); + }, +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility4/service.ts b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility4/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..d35fb6c9b69ef69e536f5b53d8843a4e2fc39d00 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility4/service.ts @@ -0,0 +1,132 @@ +/** + * Copyright (c) 2021 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 particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc' + +class StubTest4 extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility4 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility4 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +function getNowTime() { + return new Date().getTime(); +} + +function getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; +} + +async function sleep(time: any) { + var now = new Date(); + var exitTime = now.getTime() + time; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) + break; + } + console.info(`sleep ${time} over...`); +} + +export default { + onStart() { + console.info('ServiceAbility4 onStart'); + }, + onStop() { + console.info('ServiceAbility4 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility4 onCommand'); + let request = { + "bundleName": "com.open.harmony.packagemag", + "abilityName": "com.open.harmony.packagemag.packServiceAbility", + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.deviceId : ' + + JSON.stringify(element.deviceId)) + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.bundleName : ' + + JSON.stringify(element.bundleName)) + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.abilityName : ' + + JSON.stringify(element.abilityName)) + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.uri : ' + + JSON.stringify(element.uri)) + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect element.shortName : ' + + JSON.stringify(element.shortName)) + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onConnect proxy : ' + + JSON.stringify(proxy)); + }, + onDisconnect: async function (element1: any) { + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.deviceId : ' + + JSON.stringify(element1.deviceId)); + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.bundleName: ' + + JSON.stringify(element1.bundleName)); + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.abilityName:' + + JSON.stringify(element1.abilityName)); + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.uri: ' + + JSON.stringify(element1.uri)); + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onDisconnect element.shortName :' + + JSON.stringify(element1.shortName)); + }, + onFailed: function (code: any) { + console.log('particleAbility_connectAbility_test_0300 ConnectAbility onFailed errCode : '+ code); + }, + } + + let connection_succeeded: any; + console.info('particleAbility_connectAbility_test_0300 start '); + var timeOldStamp = getNowTime(); + var connection = particleAbility.connectAbility(request, options); + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0300 connectability', timeOldStamp, timeNewStamp); + connection_succeeded = connection; + console.info('particleAbility_connectAbility_test_0300 service request is:' + JSON.stringify(request)); + console.info('particleAbility_connectAbility_test_0300 options is:' + JSON.stringify(options)); + console.info('particleAbility_connectAbility_test_0300 data is: ' + JSON.stringify(connection)); + console.info('particleAbility_connectAbility_test_0300 connection=: ' + connection); + sleep(5000); + console.info('particleAbility_connectAbility_test_0300 disconnectability start '); + var timeOldStamp = getNowTime(); + particleAbility.disconnectAbility(connection_succeeded).then((data: any) => { + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0300 disconnectability', timeOldStamp, timeNewStamp); + console.info('particleAbility_connectAbility_test_0300 disconnectability succeeded:' + + JSON.stringify(data)); + }).catch ((error: any) =>{ + console.error('particleAbility_connectAbility_test_0300 disconnectability failed. Cause: ' + + JSON.stringify(error)); + }) + }, + onConnect(want) { + console.info('ServiceAbility4 onConnect'); + return new StubTest4("test"); + }, +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility5/service.ts b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility5/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..16a737c348c7c200b1ef49acc08c922c755f6e26 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility5/service.ts @@ -0,0 +1,147 @@ +/** + * Copyright (c) 2021 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 particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc' + +class StubTest5 extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility5 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility5 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +function getNowTime() { + return new Date().getTime(); +} + +function getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; +} + +async function sleep(time: any) { + var now = new Date(); + var exitTime = now.getTime() + time; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) + break; + } + console.info(`sleep ${time} over...`); +} + +export default { + onStart() { + console.info('ServiceAbility5 onStart'); + }, + onStop() { + console.info('ServiceAbility5 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility5 onCommand'); + let request = { + "bundleName": "", + "abilityName": "", + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.log('particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.deviceId : ' + + JSON.stringify(element.deviceId)) + console.log('particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.bundleName : ' + + JSON.stringify(element.bundleName)) + console.log('particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.abilityName : ' + + JSON.stringify(element.abilityName)) + console.log('particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.uri : ' + + JSON.stringify(element.uri)) + console.log('particleAbility_connectAbility_test_0400 ConnectAbility onConnect element.shortName : ' + + JSON.stringify(element.shortName)) + console.log('particleAbility_connectAbility_test_0400 ConnectAbility onConnect proxy : ' + + JSON.stringify(proxy)); + }, + onDisconnect: function (element1: any) { + console.log('particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.deviceId : ' + + JSON.stringify(element1.deviceId)); + console.log('particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.bundleName: ' + + JSON.stringify(element1.bundleName)); + console.log('particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.abilityName:' + + JSON.stringify(element1.abilityName)); + console.log('particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.uri : ' + + JSON.stringify(element1.uri)); + console.log('particleAbility_connectAbility_test_0400 ConnectAbility onDisconnect element.shortName : ' + + JSON.stringify(element1.shortName)); + }, + onFailed: function (code: any) { + console.log('particleAbility_connectAbility_test_0400 ConnectAbility onFailed errCode:' + code); + }, + } + + let connection_succeeded: any; + console.info('particleAbility_connectAbility_test_0400 start '); + var timeOldStamp = getNowTime(); + var connection = particleAbility.connectAbility(request, options); + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0400 connectability', timeOldStamp, timeNewStamp); + connection_succeeded = connection; + console.info('particleAbility_connectAbility_test_0400 service request is:' + JSON.stringify(request)); + console.info('particleAbility_connectAbility_test_0400 options is:' + JSON.stringify(options)); + console.info('particleAbility_connectAbility_test_0400 connection=: ' + connection); + sleep(5000); + console.info('particleAbility_connectAbility_test_0400 disconnectability start '); + var timeOldStamp = getNowTime(); + particleAbility.disconnectAbility(connection_succeeded).then((data: any) => { + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0400 disconnectability', timeOldStamp, timeNewStamp); + console.info('particleAbility_connectAbility_test_0400 disconnectability succeeded: ' + + JSON.stringify(data)); + }).catch((error: any) => { + console.error('particleAbility_connectAbility_test_0400 disconnectability failed. Cause: ' + + JSON.stringify(error)); + }); + sleep(5000); + console.info('particleAbility_connectAbility_test_0400 disconnectability_fail start '); + try { + var timeOldStamp = getNowTime(); + particleAbility.disconnectAbility(-1).then((data: any) => { + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0400 disconnectability_fail', + timeOldStamp, timeNewStamp); + console.info('particleAbility_connectAbility_test_0400 disconnectability_fail succeeded: ' + + JSON.stringify(data)); + }) + } + catch (error: any) { + console.error('particleAbility_connectAbility_test_0400 disconnectability_fail failed. Cause: ' + + JSON.stringify(error)); + } + }, + onConnect(want) { + console.info('ServiceAbility5 onConnect'); + return new StubTest5("test"); + }, +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility6/service.ts b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility6/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..b36d40babb5564311b59d2bb63837c2c6298a0a5 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility6/service.ts @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2021 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 particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc' + +class StubTest6 extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility6 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility6 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} +function getNowTime() { + return new Date().getTime(); +} + +function getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; +} + +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + + let request = { + "bundleName":"com.ohos.acecollaboration", + "abilityName":"com.ohos.acecollaboration.xxx", + } + let options = { + onConnect:async function (element:any, proxy:any) { + console.log('particleAbility_connectAbility_test_0500 ConnectAbility onConnect element.deviceId : ' + + JSON.stringify(element.deviceId)) + console.log('particleAbility_connectAbility_test_0500 ConnectAbility onConnect element.bundleName : ' + + JSON.stringify(element.bundleName)) + console.log('particleAbility_connectAbility_test_0500 ConnectAbility onConnect element.abilityName : ' + + JSON.stringify(element.abilityName)) + console.log('particleAbility_connectAbility_test_0500 ConnectAbility onConnect element.uri : ' + + JSON.stringify(element.uri)) + console.log('particleAbility_connectAbility_test_0500 ConnectAbility onConnect element.shortName : ' + + JSON.stringify(element.shortName)) + console.log('particleAbility_connectAbility_test_0500 ConnectAbility onConnect proxy : ' + + JSON.stringify(proxy)); + }, + onDisconnect:function (element1:any) { + console.log('particleAbility_connectAbility_test_0500 ConnectAbility onDisconnect element.deviceId : ' + + JSON.stringify(element1.deviceId)); + console.log('particleAbility_connectAbility_test_0500 ConnectAbility onDisconnect element.bundleName: ' + + JSON.stringify(element1.bundleName)); + console.log('particleAbility_connectAbility_test_0500 ConnectAbility onDisconnect element.abilityName:' + + JSON.stringify(element1.abilityName)); + console.log('particleAbility_connectAbility_test_0500 ConnectAbility onDisconnect element.uri : ' + + JSON.stringify(element1.uri)); + console.log('particleAbility_connectAbility_test_0500 ConnectAbility onDisconnect element.shortName : ' + + JSON.stringify(element1.shortName)); + }, + onFailed:function (code:any) { + console.log('particleAbility_connectAbility_test_0500 ConnectAbility service onFailed errCode:' + code) + }, + } + + console.info('particleAbility_connectAbility_test_0500 errorabilityName start'); + var timeOldStamp = getNowTime(); + var connection = particleAbility.connectAbility(request, options); + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0500 connectability', timeOldStamp, timeNewStamp); + console.info('particleAbility_connectAbility_test_0500 errorabilityName request is:' + + JSON.stringify(request)); + console.info('particleAbility_connectAbility_test_0500 errorabilityName options is:' + + JSON.stringify(options)); + console.info('particleAbility_connectAbility_test_0500 errorabilityName connection=: ' + connection); + }, + onConnect(want) { + console.info('ServiceAbility6 onConnect'); + return new StubTest6("test"); + }, +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility7/service.ts b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility7/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..32fe65dec8ea4d8e89197d561f6cecc2785db423 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/ets/ServiceAbility7/service.ts @@ -0,0 +1,135 @@ +/** + * Copyright (c) 2021 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 particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc' + +class StubTest7 extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility7 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility7 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +function getNowTime() { + return new Date().getTime(); +} + +function getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; +} + +async function sleep(time: any) { + var now = new Date(); + var exitTime = now.getTime() + time; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) + break; + } + console.info(`sleep ${time} over...`); +} +export default { + onStart() { + console.info('ServiceAbility7 onStart'); + }, + onStop() { + console.info('ServiceAbility7 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility7 onCommand'); + + let request = { + "bundleName":"com.example.myapplication", + "abilityName":"com.example.myapplication.ServiceAbility_API8", + } + let options = { + onConnect:async function (element:any, proxy:any) { + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.deviceId : ' + + JSON.stringify(element.deviceId)) + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.bundleName : ' + + JSON.stringify(element.bundleName)) + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.abilityName : ' + + JSON.stringify(element.abilityName)) + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.uri : ' + + JSON.stringify(element.uri)) + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect element.shortName : ' + + JSON.stringify(element.shortName)) + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onConnect proxy : ' + + JSON.stringify(proxy)); + }, + onDisconnect:async function (element1:any) { + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.deviceId : ' + + JSON.stringify(element1.deviceId)); + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.bundleName: ' + + JSON.stringify(element1.bundleName)); + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.abilityName:' + + JSON.stringify(element1.abilityName)); + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.uri : ' + + JSON.stringify(element1.uri)); + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onDisconnect element.shortName : ' + + JSON.stringify(element1.shortName)); + }, + onFailed:function (code:any) { + console.log('particleAbility_connectAbility_test_0600 ConnectAbility onFailed errCode:' + code); + }, + } + + let connection_succeeded:any; + console.info('particleAbility_connectAbility_test_0600 start '); + var timeOldStamp = getNowTime(); + var connection = particleAbility.connectAbility(request, options); + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0600 connectability', timeOldStamp, timeNewStamp); + connection_succeeded = connection; + console.info('particleAbility_connectAbility_test_0600 service request is:' + JSON.stringify(request)); + console.info('particleAbility_connectAbility_test_0600 options is:' + JSON.stringify(options)); + console.info('particleAbility_connectAbility_test_0600 data is: ' + JSON.stringify(connection)); + console.info('particleAbility_connectAbility_test_0600 connection=: ' + connection); + sleep(5000); + console.info('particleAbility_connectAbility_test_0600 disconnectability start '); + var timeOldStamp = getNowTime(); + particleAbility.disconnectAbility(connection_succeeded).then((data: any) => { + var timeNewStamp = getNowTime(); + getDurationTime('particleAbility_connectAbility_test_0600 disconnectability', timeOldStamp, timeNewStamp); + console.info('particleAbility_connectAbility_test_0600 disconnectability succeeded: ' + + JSON.stringify(data)); + }).catch((error: any) =>{ + console.error('particleAbility_connectAbility_test_0600 disconnectability failed. Cause: ' + + JSON.stringify(error)); + }); + }, + onConnect(want) { + console.info('ServiceAbility7 onConnect'); + return new StubTest7("test"); + }, + onDisConnect(want) { + console.info('ServiceAbility7 onDisConnect'); + }, +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ffd4ec49bed1ed0a06d1373e4a8d1f19afc51ac8 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,48 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "mainability_description", + "value": "eTS_Empty Ability" + }, + { + "name": "description_serviceability", + "value": "hap sample empty service" + }, + { + "name": "description_serviceability2", + "value": "hap sample empty service" + }, + { + "name": "description_serviceability3", + "value": "hap sample empty service" + }, + { + "name": "description_serviceability4", + "value": "hap sample empty service" + }, + { + "name": "description_serviceability5", + "value": "hap sample empty service" + }, + { + "name": "description_mainability2", + "value": "eTS_Empty Ability2" + }, + { + "name": "entry_MainAbility2", + "value": "MainAbility2" + }, + { + "name": "description_serviceability6", + "value": "hap sample empty service" + }, + { + "name": "description_serviceability7", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsabilitymanageretstest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/config.json b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..ebcff6d524d771d93a18e206afb0934260198e78 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/config.json @@ -0,0 +1,57 @@ +{ + "app": { + "bundleName": "com.ohos.acecollaboration", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.myapplication1", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "myapplication1", + "moduleType": "feature", + "installationFree": false + }, + "abilities": [ + { + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:myapplication1_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..7aa1eae37d7e14260b0f22a90c5a5f7560b8f0f2 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2021 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..d39e37aa687879af8aa3ab6021f85353730243fb --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2021 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 file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; +import testsuite_app1 from "../test/List.test.ets"; +import featureAbility from "@ohos.ability.featureAbility"; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite_app1(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('myapplication1 page') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/List.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e5bd7d594d190f2b30c723d0f93c439f28d27375 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2021 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 getHapModuleInfoJsunit_app1 from './getHapModuleInfoJsunit_app1.test.ets'; + +export default function testsuite_app1() { + getHapModuleInfoJsunit_app1(); + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/Utils.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..58900ffcdfc72e853714250ae84cda913c6c9947 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2021 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. + */ + +export default class Utils { + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve(reject) + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getNowTime() { + return new Date().getTime(); + } + + static getDurationTime(msg,startTime, endTime) { + console.info(msg+'Get Interface startTime: ' + startTime); + console.info(msg+'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg+'Get Interface Duration: ' + duration); + return duration; + } +} + + + + diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/getHapModuleInfoJsunit_app1.test.ets b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/getHapModuleInfoJsunit_app1.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..685a71d103d5574b438ddfd73b934ec212570fc2 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/ets/MainAbility/test/getHapModuleInfoJsunit_app1.test.ets @@ -0,0 +1,301 @@ +/** + * Copyright (c) 2021 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 {describe, it, expect} from "deccjsunit/index.ets"; +import Utils from './Utils'; +import ability_featureAbility from '@ohos.ability.featureAbility'; + +export default function getHapModuleInfoJsunit() { + describe('appInfoTest', function () { + + /** + * @tc.number: context_getHapModuleInfo_test_0300 + * @tc.name: getHapModuleInfo:Obtains the HapModuleInfo object of the application. + * @tc.desc: Check the return type of the interface (by Promise) + * @tc.level 0 + */ + it('context_getHapModuleInfo_test_0300', 0, async function (done) { + console.info('[context_getHapModuleInfo_test_0300] START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + var context = ability_featureAbility.getContext(); + context.getHapModuleInfo() + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('context_getHapModuleInfo_test_0300', timeOldStamp, timeNewStamp); + console.info('[context_getHapModuleInfo_test_0300] data is:' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("object"); + }) + .catch((error) => { + console.error('[context_getHapModuleInfo_test_0300] failed:' + JSON.stringify(error)); + }) + var promise = await context.getHapModuleInfo(); + console.info('---[context_getHapModuleInfo_test_0300] check---'); + checkHapModuleInfo_app('context_getHapModuleInfo_test_0300', promise); + console.info('[context_getHapModuleInfo_test_0300] FINISH'); + done(); + }); + + function checkHapModuleInfo_app(msg, data) { + console.log(msg + "checkHapModuleInfo start " + JSON.stringify(data)); + console.log(msg + "checkHapModuleInfo name : " + data.name); + console.log(msg + "checkHapModuleInfo description : " + data.description); + console.log(msg + "checkHapModuleInfo descriptionId : " + data.descriptionId); + console.log(msg + "checkHapModuleInfo icon : " + data.icon); + console.log(msg + "checkHapModuleInfo label : " + data.label); + console.log(msg + "checkHapModuleInfo labelId : " + data.labelId); + console.log(msg + "checkHapModuleInfo iconId : " + data.iconId); + console.log(msg + "checkHapModuleInfo backgroundImg : " + data.backgroundImg); + console.log(msg + "checkHapModuleInfo supportedModes : " + data.supportedModes); + console.log(msg + "checkHapModuleInfo reqCapabilities length : " + data.reqCapabilities.length); + for (var j = 0; j < data.reqCapabilities.length; j++) { + console.log(msg + "getHapModuleInfo data.reqCapabilities[" + j + "] : " + data.reqCapabilities[j]); + } + console.log(msg + "checkHapModuleInfo deviceTypes length : " + data.deviceTypes.length); + for (var k = 0; k < data.deviceTypes.length; k++) { + console.log(msg + "getHapModuleInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]); + } + console.log(msg + "checkHapModuleInfo abilityInfos length : " + data.abilityInfos.length); + console.log(msg + "checkHapModuleInfo moduleName : " + data.moduleName); + console.log(msg + "checkHapModuleInfo mainAbilityName : " + data.mainAbilityName); + console.log(msg + "checkHapModuleInfo installationFree : " + data.installationFree); + + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.descriptionId)).assertEqual("number"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.labelId)).assertEqual("number"); + expect(typeof (data.iconId)).assertEqual("number"); + expect(typeof (data.backgroundImg)).assertEqual("string"); + expect(typeof (data.supportedModes)).assertEqual("number"); + expect(Array.isArray(data.reqCapabilities)).assertEqual(true); + expect(Array.isArray(data.deviceTypes)).assertEqual(true); + expect(Array.isArray(data.abilityInfos)).assertEqual(true); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.mainAbilityName)).assertEqual("string"); + expect(typeof (data.installationFree)).assertEqual("boolean"); + expect(data.name).assertEqual("com.example.myapplication1"); + expect(data.description).assertEqual(""); + expect(data.descriptionId).assertEqual(0); + expect(data.icon).assertEqual("$media:icon"); + expect(data.label).assertEqual("$string:myapplication1_MainAbility"); + expect(data.labelId).assertEqual(0); + expect(data.iconId).assertEqual(0); + expect(data.backgroundImg).assertEqual(""); + expect(data.supportedModes).assertEqual(0); + + expect(data.deviceTypes[0]).assertEqual("phone"); + checkAbilityInfo(msg,data.abilityInfos[0]); + + expect(data.moduleName).assertEqual("myapplication1") + expect(data.mainAbilityName).assertEqual(""); + expect(data.installationFree).assertEqual(false); + + console.log(msg + "---checkHapModuleInfo End---"); + } + + function checkAbilityInfo(msg,data) { + console.log(msg+ "checkAbilityInfo start " + JSON.stringify(data)); + console.log(msg+ "checkAbilityInfo bundleName : " + data.bundleName); + console.log(msg+ "checkAbilityInfo name : " + data.name); + console.log(msg+ "checkAbilityInfo label : " + data.label); + console.log(msg+ "checkAbilityInfo description : " + data.description); + console.log(msg+ "checkAbilityInfo icon : " + data.icon); + console.log(msg+ "checkAbilityInfo descriptionId : " + data.descriptionId); + console.log(msg+ "checkAbilityInfo iconId : " + data.iconId); + console.log(msg+ "checkAbilityInfo moduleName : " + data.moduleName); + console.log(msg+ "checkAbilityInfo process : " + data.process); + console.log(msg+ "checkAbilityInfo targetAbility : " + data.targetAbility); + console.log(msg+ "checkAbilityInfo backgroundModes : " + data.backgroundModes); + console.log(msg+ "checkAbilityInfo isVisible : " + data.isVisible); + console.log(msg+ "checkAbilityInfo formEnabled : " + data.formEnabled); + console.log(msg+ "checkAbilityInfo type : " + data.type) + console.log(msg+ "checkAbilityInfo orientation : " + data.orientation); + console.log(msg+ "checkAbilityInfo launchMode : " + data.launchMode); + console.log(msg+ "checkAbilityInfo permissions length : " + data.permissions.length); + for (var j = 0; j < data.permissions.length; j++) { + console.log(msg+ "getAbilityInfo data.permissions[" + j + "] : " + data.permissions[j]); + } + console.log(msg+ "checkAbilityInfo deviceTypes length : " + data.deviceTypes.length); + for (var k = 0; k < data.deviceTypes.length; k++) { + console.log(msg+ "getAbilityInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]); + } + console.log(msg+ "checkAbilityInfo deviceCapabilities length : " + data.deviceCapabilities.length); + for (var i = 0; i < data.deviceCapabilities.length; i++) { + console.log(msg+ "getAbilityInfo data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]); + } + console.log(msg+ "checkAbilityInfo readPermission : " + data.readPermission); + console.log(msg+ "checkAbilityInfo writePermission : " + data.writePermission); + console.log(msg+ "checkAbilityInfo formEntity : " + data.formEntity); + console.log(msg+ "checkAbilityInfo minFormHeight : " + data.minFormHeight); + console.log(msg+ "checkAbilityInfo defaultFormHeight : " + data.defaultFormHeight); + console.log(msg+ "checkAbilityInfo minFormWidth : " + data.minFormWidth); + console.log(msg+ "checkAbilityInfo defaultFormWidth : " + data.defaultFormWidth); + console.log(msg+ "checkAbilityInfo uri : " + data.uri); + console.log(msg+ "checkAbilityInfo labelId : " + data.labelId); + console.log(msg+ "checkAbilityInfo subType : " + data.subType); + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.bundleName)).assertEqual("string"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.labelId)).assertEqual("number"); + expect(typeof (data.descriptionId)).assertEqual("number"); + expect(typeof (data.iconId)).assertEqual("number"); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.process)).assertEqual("string"); + expect(typeof (data.targetAbility)).assertEqual("string"); + expect(typeof (data.backgroundModes)).assertEqual("number"); + expect(typeof (data.isVisible)).assertEqual("boolean"); + expect(typeof (data.formEnabled)).assertEqual("boolean"); + expect(typeof (data.type)).assertEqual("number"); + expect(typeof (data.subType)).assertEqual("number"); + expect(typeof (data.orientation)).assertEqual("number"); + expect(typeof (data.launchMode)).assertEqual("number"); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.deviceTypes)).assertEqual(true); + expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); + expect(typeof (data.readPermission)).assertEqual("string"); + expect(typeof (data.writePermission)).assertEqual("string"); + expect(typeof (data.applicationInfo)).assertEqual("object"); + expect(typeof (data.formEntity)).assertEqual("number"); + expect(typeof (data.minFormHeight)).assertEqual("number"); + expect(typeof (data.defaultFormHeight)).assertEqual("number"); + expect(typeof (data.minFormWidth)).assertEqual("number"); + expect(typeof (data.defaultFormWidth)).assertEqual("number"); + expect(typeof (data.uri)).assertEqual("string"); + expect(data.bundleName).assertEqual("com.ohos.acecollaboration"); + expect(data.name).assertEqual("com.example.myapplication1.MainAbility"); + expect(data.label).assertEqual("$string:myapplication1_MainAbility"); + expect(data.description).assertEqual("$string:description_mainability"); + expect(data.icon).assertEqual("$media:icon"); + expect(data.descriptionId > 0).assertTrue(); + expect(data.iconId > 0).assertTrue(); + expect(data.moduleName).assertEqual("myapplication1"); + expect(data.process).assertEqual(""); + expect(data.targetAbility).assertEqual(""); + expect(data.backgroundModes).assertEqual(0); + expect(data.isVisible).assertEqual(true); + expect(data.formEnabled).assertEqual(false); + expect(data.type).assertEqual(1); + expect(data.orientation).assertEqual(0); + expect(data.launchMode).assertEqual(1); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(data.readPermission).assertEqual(""); + expect(data.writePermission).assertEqual(""); + checkApplicationInfo(msg,data.applicationInfo); + expect(data.formEntity).assertEqual(0); + expect(data.minFormHeight).assertEqual(0); + expect(data.defaultFormHeight).assertEqual(0); + expect(data.minFormWidth).assertEqual(0); + expect(data.defaultFormWidth).assertEqual(0); + expect(data.uri).assertEqual(""); + expect(data.labelId > 0).assertTrue(); + expect(data.subType).assertEqual(0); + console.log(msg+ "---checkAbilityInfo End--- "); + } + + function checkApplicationInfo(msg,info) { + console.log(msg+ "checkApplicationInfo start : " + JSON.stringify(info)); + console.log(msg+ "checkApplicationInfo name : " + info.name); + console.log(msg+ "checkApplicationInfo description : " + info.description); + console.log(msg+ "checkApplicationInfo descriptionId : " + info.descriptionId); + console.log(msg+ "checkApplicationInfo systemApp : " + info.systemApp); + console.log(msg+ "checkApplicationInfo enabled : " + info.enabled); + console.log(msg+ "checkApplicationInfo label : " + info.label); + console.log(msg+ "checkApplicationInfo labelId : " + info.labelId); + console.log(msg+ "checkApplicationInfo icon : " + info.icon); + console.log(msg+ "checkApplicationInfo iconId : " + info.iconId); + console.log(msg+ "checkApplicationInfo process : " + info.process); + console.log(msg+ "checkApplicationInfo supportedModes : " + info.supportedModes); + console.log(msg+ "checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length); + for (var j = 0; j < info.moduleSourceDirs.length; j++) { + console.log(msg+ "checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]); + } + console.log(msg+ "checkApplicationInfo permissions length : " + info.permissions.length); + for (var k = 0; k < info.permissions.length; k++) { + console.log(msg+ "checkApplicationInfo info.permissions[" + k + "] : " + info.permissions[k]); + } + console.log(msg+ "checkApplicationInfo moduleInfos length : " + info.moduleInfos.length); + for (var i = 0; i < info.moduleInfos.length; i++) { + console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleName : " + info.moduleInfos[i].moduleName); + console.log(msg+ "checkApplicationInfo info.moduleInfos[" + i + "].moduleSourceDir : " + info.moduleInfos[i].moduleSourceDir); + } + console.log(msg+ "checkApplicationInfo entryDir : " + info.entryDir); + expect(typeof (info)).assertEqual("object"); + expect(typeof (info.name)).assertEqual("string"); + expect(typeof (info.description)).assertEqual("string"); + expect(typeof (info.descriptionId)).assertEqual("number"); + expect(typeof (info.systemApp)).assertEqual("boolean"); + expect(typeof (info.enabled)).assertEqual("boolean"); + expect(typeof (info.label)).assertEqual("string"); + expect(typeof (info.labelId)).assertEqual("string"); + expect(typeof (info.icon)).assertEqual("string"); + expect(typeof (info.iconId)).assertEqual("string"); + expect(typeof (info.process)).assertEqual("string"); + expect(typeof (info.supportedModes)).assertEqual("number"); + expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true); + expect(Array.isArray(info.permissions)).assertEqual(true); + expect(Array.isArray(info.moduleInfos)).assertEqual(true); + expect(typeof (info.entryDir)).assertEqual("string"); + expect(info.name).assertEqual("com.ohos.acecollaboration"); + expect(info.description).assertEqual("$string:mainability_description"); + expect(info.descriptionId > 0).assertTrue(); + expect(info.systemApp).assertEqual(true); + expect(info.enabled).assertEqual(true); + expect(info.label).assertEqual("$string:entry_MainAbility"); + expect(info.icon).assertEqual("$media:icon"); + expect(info.process).assertEqual(""); + expect(info.supportedModes).assertEqual(0); + if (info.moduleSourceDirs.length == 1){ + expect(info.moduleInfos[0].moduleName).assertEqual("entry"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + }else if(info.moduleSourceDirs.length == 2) { + if (info.moduleInfos[0].moduleName == "myapplication1") { + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication1"); + expect(info.moduleInfos[1].moduleName).assertEqual("entry"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + }else{ + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication2"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication2"); + expect(info.moduleInfos[1].moduleName).assertEqual("entry"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + } + }else { + expect(info.moduleInfos[0].moduleName).assertEqual("myapplication1"); + expect(info.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication1"); + expect(info.moduleInfos[1].moduleName).assertEqual("myapplication2"); + expect(info.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.example.myapplication2"); + expect(info.moduleInfos[2].moduleName).assertEqual("entry"); + expect(info.moduleInfos[2].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + } + expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/" + + "com.ohos.acecollaboration/com.ohos.acecollaboration"); + console.log(msg+ "---checkApplicationInfo End--- "); + } + + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c69dada1a3f8a111a6cfdb7743f45b8449bee1b2 --- /dev/null +++ b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "myapplication1_MainAbility", + "value": "myapplication1_MainAbility" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsabilitymanageretstest/myapplication1/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsabilitymanageretstest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actsabilitymanageretstest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/aafwk/aafwk_standard/actsabilitymanageretstest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/BUILD.gn b/aafwk/aafwk_standard/amsgetabilityprocessinfo/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..28fe324e3b2dc661f239cc7e9312850902d1a964 --- /dev/null +++ b/aafwk/aafwk_standard/amsgetabilityprocessinfo/BUILD.gn @@ -0,0 +1,21 @@ +# Copyright (c) 2021 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") + +group("amsgetabilityprocessinfo") { + testonly = true + if (is_standard_system) { + deps = [ "actsprocessmanagejstest:ActsAbilityRunningInfosTest" ] + } +} diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/BUILD.gn b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3347f21032a6b5c9e05ff8eceb74421932cf094b --- /dev/null +++ b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2021 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("ActsAbilityRunningInfosTest") { + hap_name = "ActsAbilityRunningInfosTest" + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/Test.json b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..b4c890b9391fe8208e42310ab376b0bda10af6a7 --- /dev/null +++ b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.abilityrunninginfostest", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAbilityRunningInfosTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/config.json b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..80c1bad19b4a557e124cdca4920acd08a50aa791 --- /dev/null +++ b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/config.json @@ -0,0 +1,107 @@ +{ + "app": { + "bundleName": "com.example.abilityrunninginfostest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.abilityrunninginfostest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.abilityrunninginfostest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "singleton", + "visible": true + } + ], + "reqPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.CLEAN_APPLICATION_DATA", + "reason":"need use ohos.permission.CLEAN_APPLICATION_DATA" + }, + { + "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason": "need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/app.js b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..042038cfc6360ed972035a85e944904021ffb1d6 --- /dev/null +++ b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/app.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 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. + */ +export default { + onCreate() { + console.info('ActsProcessManageJsTest onCreate'); + }, + onDestroy() { + console.info('ActsProcessManageJsTest onDestroy'); + }, + onShow() { + console.info('ActsProcessManageJsTest onShow'); + }, + onHide() { + console.info('ActsProcessManageJsTest onHide'); + } +}; diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/i18n/en-US.json b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/i18n/zh-CN.json b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.css b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..cfd4c53e39aecb2d83a0fbdec971eca4041c8a3a --- /dev/null +++ b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,14 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} + +.btn { + width: 200px; + height: 80px; +} diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.hml b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..83c5e0fcabbb1d5df26d69f4a5c2031c1e65b70a --- /dev/null +++ b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,6 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + + +
diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ee3a7077b7d52935d3f70b5cb70e38ea9d0e33f1 --- /dev/null +++ b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2021 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 { Core, ExpectExtend } from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "", + testTime: 0 + }, + onInit() { + console.info('ActsProcessManageJsTest onInit'); + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('ActsProcessManageJsTest onShow'); + console.info('ActsProcessManageJsTest testTime' + this.testTime); + if (this.testTime == 0) { + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + const configService = core.getDefaultService('config') + this.timeout = 30000; + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + } + this.testTime++; + }, + onReady() { + console.info('ActsProcessManageJsTest onReady'); + }, + onActive() { + console.info('ActsProcessManageJsTest onActive'); + }, + onInactive() { + console.info('ActsProcessManageJsTest onInactive'); + }, + onHide() { + console.info('ActsProcessManageJsTest onHide'); + }, + onDestroy() { + console.info('ActsProcessManageJsTest onDestroy'); + }, + onBackPress() { + console.info('ActsProcessManageJsTest onBackPress'); + }, + onNewRequest() { + console.info('ActsProcessManageJsTest onNewRequest'); + }, + onStartContinuation() { + console.info('ActsProcessManageJsTest onStartContinuation'); + }, + onSaveData(value) { + console.info('ActsProcessManageJsTest onSaveData:' + JSON.stringify(value)); + }, + onRestoreData(value) { + console.info('ActsProcessManageJsTest onRestoreData:' + JSON.stringify(value)); + }, + onCompleteContinuation(code) { + console.info('ActsProcessManageJsTest onCompleteContinuation:' + JSON.stringify(code)); + }, + onConfigurationUpdated(configuration) { + console.info('ActsProcessManageJsTest onConfigurationUpdated:' + JSON.stringify(configuration)); + } +} diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/resources/base/element/string.json b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03574a36c533357eef7fc0acc5e21af14f4e5f67 --- /dev/null +++ b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "actsparticleabilitytest" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/resources/base/media/icon.png b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/test/ActsProcessManageJsTest.test.js b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/test/ActsProcessManageJsTest.test.js new file mode 100644 index 0000000000000000000000000000000000000000..6e35b0e268777412a295803684ff760f3861a1ca --- /dev/null +++ b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/test/ActsProcessManageJsTest.test.js @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import commonEvent from '@ohos.commonevent' +import bundle from '@ohos.bundle' +import missionManager from '@ohos.application.missionManager' +import abilityManager from '@ohos.application.AbilityManager' +import featureAbility from '@ohos.ability.featureAbility' +import appManager from '@ohos.application.AppManager' + +describe('ActsAbilityRunningInfosTest', function () { + + + function checkRunningAbility(name, dataInfo) { + for (let i = 0, len = dataInfo.length; i < len; i++) { + if (dataInfo[i].ability.abilityName == name) { + expect(dataInfo[i].uid).assertLarger(10000); + expect(dataInfo[i].pid).assertLarger(500); + expect(dataInfo[i].startTime).assertLarger(3000); + expect(dataInfo[i].abilityState).assertLarger(0); + return true; + } + } + return false; + } + + function checkRunningProcess(name, dataInfo) { + for (let i = 0, len = dataInfo.length; i < len; i++) { + if (dataInfo[i].processName == name) { + expect(dataInfo[i].uid).assertLarger(2000); + expect(dataInfo[i].pid).assertLarger(500); + return true; + } + } + return false; + } + + /* + * @tc.number: ACTS_getAbilityRunningInfos_0100 + * @tc.name: Application running ability information query + * @tc.desc: Verify applications are started to query getAbilityRunningInfos ability information + * (by promise) + */ + it('ACTS_getAbilityRunningInfos_0100', 0, async function (done) { + console.log('ACTS_getAbilityRunningInfos_0100==== ACTS_getAbilityRunningInfos_0100 ====>' + JSON.stringify(data)) + expect(checkRunningAbility('com.ohos.launcher.MainAbility', data)).assertTrue(); + done(); + }) + + /* + * @tc.number: ACTS_getAbilityRunningInfos_0200 + * @tc.name: Application running ability information query + * @tc.desc: Verify applications are started to query getAbilityRunningInfos ability information + * (by callback) + */ + it('ACTS_getAbilityRunningInfos_0200', 0, async function (done) { + console.log('ACTS_getAbilityRunningInfos_0200===={ + console.info('====> ACTS_getAbilityRunningInfos_0200 ====>' + JSON.stringify(data)) + expect(checkRunningAbility('com.ohos.launcher.MainAbility', data)).assertTrue(); + done(); + }) + }) + + /* + * @tc.number: ACTS_getAbilityRunningInfos_0100 + * @tc.name: Application running ability information query + * @tc.desc: Verify applications are started to query getProcessRunningInfos ability information + * (by promise) + */ + it('ACTS_getProcessRunningInfos_0100', 0, async function (done) { + console.log('ACTS_getProcessRunningInfos_0100==== ACTS_getProcessRunningInfos_0100 ====>' + JSON.stringify(data)) + expect(checkRunningProcess('com.ohos.launcher', data)).assertTrue(); + done(); + }) + + /* + * @tc.number: ACTS_getProcessRunningInfos_0200 + * @tc.name: Application running ability information query + * @tc.desc: Verify applications are started to query getProcessRunningInfos ability information + * (by callback) + */ + it('ACTS_getProcessRunningInfos_0200', 0, async function (done) { + console.log('ACTS_getProcessRunningInfos_0200==== { + console.info('====> ACTS_getProcessRunningInfos_0200 ====>' + JSON.stringify(data)) + expect(checkRunningProcess('com.ohos.launcher', data)).assertTrue(); + done(); + }) + }) +}) diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/test/List.test.js b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..a7c683b3c0d578297e04ff1d997cf048087eec47 --- /dev/null +++ b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2021 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. + */ +require('./ActsProcessManageJsTest.test.js') \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amsgetabilityprocessinfo/actsprocessmanagejstest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/BUILD.gn b/aafwk/aafwk_standard/amsprocessmanageapi7/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b734289749f59db1a6cabdfbe1b17bb35b9486f3 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/BUILD.gn @@ -0,0 +1,27 @@ +# Copyright (c) 2021 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") + +group("amsprocessmanageapi7") { + testonly = true + if (is_standard_system) { + deps = [ + "actsprocessmanagejstest:ActsAmsProcessManageJsTestApi7", + "pmsystemappa:ActsAmsProcessManageSystemAppAApi7", + "pmsystemappamulti:ActsAmsProcessManageSystemAppAMultiApi7", + "pmsystemappb:ActsAmsProcessManageSystemAppBApi7", + "pmvendorappa:ActsAmsProcessManageVendorAppAApi7", + ] + } +} diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/BUILD.gn b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8d08bac2de38f6dfab3d9ae8a4f24eb09bcda838 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2021 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("ActsAmsProcessManageJsTestApi7") { + hap_name = "ActsAmsProcessManageJsTestApi7" + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/Test.json b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..50d1e3c1426dea433035c4deb62493c82dfc0672 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/Test.json @@ -0,0 +1,40 @@ +{ + "description": "Configuration for hjsunit Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.acts.actsprocessmanagejstestapi7", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsProcessManageJsTestApi7.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsAmsProcessManageSystemAppAApi7.hap->/data/ActsAmsProcessManageSystemAppAApi7.hap", + "ActsAmsProcessManageSystemAppAMultiApi7.hap->/data/ActsAmsProcessManageSystemAppAMultiApi7.hap", + "ActsAmsProcessManageSystemAppBApi7.hap->/data/ActsAmsProcessManageSystemAppBApi7.hap", + "ActsAmsProcessManageVendorAppAApi7.hap->/data/ActsAmsProcessManageVendorAppAApi7.hap" + ] + + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/*.hap" + ] + } + ] +} diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/config.json b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..855dbe43597811e92c08dc2ede36c47298350905 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/config.json @@ -0,0 +1,103 @@ +{ + "app": { + "bundleName": "com.acts.actsprocessmanagejstestapi7", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.acts.actsprocessmanagejstestapi7", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.acts.actsprocessmanagejstestapi7.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "singleton", + "visible": true + } + ], + "reqPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.CLEAN_APPLICATION_DATA", + "reason":"need use ohos.permission.CLEAN_APPLICATION_DATA" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/app.js b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..042038cfc6360ed972035a85e944904021ffb1d6 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/app.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 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. + */ +export default { + onCreate() { + console.info('ActsProcessManageJsTest onCreate'); + }, + onDestroy() { + console.info('ActsProcessManageJsTest onDestroy'); + }, + onShow() { + console.info('ActsProcessManageJsTest onShow'); + }, + onHide() { + console.info('ActsProcessManageJsTest onHide'); + } +}; diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/i18n/en-US.json b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/i18n/zh-CN.json b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.css b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..cfd4c53e39aecb2d83a0fbdec971eca4041c8a3a --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,14 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} + +.btn { + width: 200px; + height: 80px; +} diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.hml b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..83c5e0fcabbb1d5df26d69f4a5c2031c1e65b70a --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,6 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + + +
diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ee3a7077b7d52935d3f70b5cb70e38ea9d0e33f1 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2021 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 { Core, ExpectExtend } from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "", + testTime: 0 + }, + onInit() { + console.info('ActsProcessManageJsTest onInit'); + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('ActsProcessManageJsTest onShow'); + console.info('ActsProcessManageJsTest testTime' + this.testTime); + if (this.testTime == 0) { + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + const configService = core.getDefaultService('config') + this.timeout = 30000; + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + } + this.testTime++; + }, + onReady() { + console.info('ActsProcessManageJsTest onReady'); + }, + onActive() { + console.info('ActsProcessManageJsTest onActive'); + }, + onInactive() { + console.info('ActsProcessManageJsTest onInactive'); + }, + onHide() { + console.info('ActsProcessManageJsTest onHide'); + }, + onDestroy() { + console.info('ActsProcessManageJsTest onDestroy'); + }, + onBackPress() { + console.info('ActsProcessManageJsTest onBackPress'); + }, + onNewRequest() { + console.info('ActsProcessManageJsTest onNewRequest'); + }, + onStartContinuation() { + console.info('ActsProcessManageJsTest onStartContinuation'); + }, + onSaveData(value) { + console.info('ActsProcessManageJsTest onSaveData:' + JSON.stringify(value)); + }, + onRestoreData(value) { + console.info('ActsProcessManageJsTest onRestoreData:' + JSON.stringify(value)); + }, + onCompleteContinuation(code) { + console.info('ActsProcessManageJsTest onCompleteContinuation:' + JSON.stringify(code)); + }, + onConfigurationUpdated(configuration) { + console.info('ActsProcessManageJsTest onConfigurationUpdated:' + JSON.stringify(configuration)); + } +} diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/resources/base/element/string.json b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03574a36c533357eef7fc0acc5e21af14f4e5f67 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "actsparticleabilitytest" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/resources/base/media/icon.png b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/test/ActsProcessManageJsTest.test.js b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/test/ActsProcessManageJsTest.test.js new file mode 100644 index 0000000000000000000000000000000000000000..4b7944c955a3f5b84c82415b7ebb973365ca4cbd --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/test/ActsProcessManageJsTest.test.js @@ -0,0 +1,1418 @@ +/* + * Copyright (c) 2021 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 commonEvent from "@ohos.commonevent" +import abilitymanager from '@ohos.app.abilitymanager' +import abilityManager from '@ohos.application.appManager' +import missionmanager from '@ohos.application.missionManager' +import featureAbility from '@ohos.ability.featureAbility' +import file from '@system.file' +import bundle from '@ohos.bundle' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + +const BUNDLE_PATHS = [['/data/ActsAmsProcessManageSystemAppAApi7.hap', + '/data/ActsAmsProcessManageSystemAppAMultiApi7.hap'], +['/data/ActsAmsProcessManageSystemAppBApi7.hap'], +['/data/ActsAmsProcessManageVendorAppAApi7.hap']]; +const BUNDLE_NAMES = ['com.acts.pmsystemappaapi7', + 'com.acts.pmsystemappbapi7', + 'com.acts.pmvendorappaapi7']; +const PATHS_COUNT = 3; +const BUNDLE_COUNT = 3; + +var subscribeInfo = { + events: [ + "event_from_ProcessManage_SystemAppA", + "event_from_ProcessManage_VendorAppA" + ], +}; +var eventFromSystemA = "event_from_ProcessManage_SystemAppA"; +var eventFromVendorA = "event_from_ProcessManage_VendorAppA"; + +var systemABundleName = "com.acts.pmsystemappaapi7"; +var systemAMultiBundleName = "com.acts.pmsystemappamultiapi7"; +var systemBBundleName = "com.acts.pmsystemappbapi7"; +var vendorABundleName = "com.acts.pmvendorappaapi7"; +var vendorServiceBundleName = "com.acts.pmvendorappserviceapi7"; +var systemAAbilityName = "com.acts.pmsystemappaapi7.MainAbility"; +var systemBAbilityName = "com.acts.pmsystemappbapi7.MainAbility"; +var vendorAAbilityName = "com.acts.pmvendorappaapi7.MainAbility"; +var systemAMultiAbilityName = "com.acts.pmsystemappamultiapi7.MainAbility"; +var vendorServiceAbilityName = "com.acts.pmvendorappserviceapi7.ServiceAbility"; + +var systemAProcessName = systemABundleName; +var systemAMultiProcessName = systemAMultiBundleName; +var systemBProcessName = systemBBundleName; +var vendorAProcessName = vendorABundleName; +var uriSystemA = 'internal://cache/../../com.acts.pmsystemappaapi7/'; +var uriSystemB = 'internal://cache/../../com.acts.pmsystemappbapi7/'; +var uriVendorA = 'internal://cache/../../com.acts.pmvendorappaapi7/'; + +describe('ActsAmsProcessManageJsTestApi7', function () { + + beforeEach(async (done) => { + await clearMissionId(); + setTimeout(async function () { + try { + let installer = await bundle.getBundleInstaller(); + console.log('======>ACTS_ProcessManage beforeEach installer<=======' + JSON.stringify(installer)); + var count = 0; + for (let i = 0; i < PATHS_COUNT; i++) { + installer.install(BUNDLE_PATHS[i], { + userId: 100, + installFlag: 1, + isKeepData: false + }, (err, data) => { + count++; + console.log('======>ACTS_ProcessManage beforeEach install finish<=======' + err.code); + console.log('======>ACTS_ProcessManage beforeEach install finish<=======' + data.status); + console.log('======>ACTS_ProcessManage beforeEach install finish<=======' + data.statusMessage); + if (count == PATHS_COUNT) { + done(); + } + }) + } + } catch (err) { + console.log('======>ACTS_ProcessManage beforeEach err<=======' + err); + } + }, 500); + }) + + afterEach(async (done) => { + setTimeout(async function () { + let installer = await bundle.getBundleInstaller(); + var count = 0; + var testMissionId; + + testMissionId = await getMissionId(); + console.log('======>ACTS_ProcessManage afterEach testMissionId<=======' + testMissionId); + await missionmanager.moveMissionToFront(testMissionId); + + for (let i = 0; i < BUNDLE_COUNT; i++) { + installer.uninstall(BUNDLE_NAMES[i], { + userId: 100, + installFlag: 1, + isKeepData: false + }, (err, data) => { + count++; + console.log('======>ACTS_ProcessManage afterEach uninstall finish<=======' + err.code); + console.log('======>ACTS_ProcessManage afterEach uninstall finish<=======' + data.status); + console.log('======>ACTS_ProcessManage afterEach uninstall finish<=======' + data.statusMessage); + if (count == BUNDLE_COUNT) { + done(); + } + }) + } + }, 500); + }) + + function getMissionId() { + return new Promise(async (resolve, reject) => { + var numMax = 1024; + var missionId = -1; + var missionInfos = await missionmanager.getMissionInfos('', numMax); + for (let i = 0; i < missionInfos.length; i++) { + console.log('getMissionId result: ' + i + '= ' + JSON.stringify(missionInfos[i])) + if ((missionInfos[i].want.abilityName == "com.acts.actsprocessmanagejstestapi7.MainAbility") && + (missionInfos[i].runningState == 0)) { + missionId = missionInfos[i].missionId; + break; + } + } + console.log('======>getMissionId resolve missionId<=======' + missionId); + resolve(missionId); + }) + } + + function clearMissionId() { + return new Promise(async (resolve, reject) => { + var numMax = 1024; + var missionInfos = await missionmanager.getMissionInfos('', numMax); + for (let i = 0; i < missionInfos.length; i++) { + if ((missionInfos[i].want.bundleName == systemABundleName) || + (missionInfos[i].want.bundleName == systemBBundleName) || + (missionInfos[i].want.bundleName == vendorABundleName) || + (missionInfos[i].want.bundleName == vendorServiceBundleName)) { + missionmanager.clearMission(missionInfos[i].missionId, (err, data) => { + console.debug("====>ACTS_ProcessManage clearMission id:" + missionInfos[i].missionId); + }); + } + } + console.log('======>ACTS_ProcessManage clearMission finish<======='); + resolve(); + }) + } + + + function checkPromiseExistDelay(processName) { + return new Promise(async (resolve, reject) => { + setTimeout(async function () { + try { + var processInfos = await abilitymanager.getActiveProcessInfos(); + console.debug("====>ACTS_ProcessManage checkPromiseExistDelay processInfos====>" + + JSON.stringify(processInfos)); + resolve(checkProcessExistInInfos(processInfos, processName)); + } catch (err) { + onsole.debug("====>ACTS_ProcessManage checkPromiseExistDelay err====>" + + JSON.stringify(err)); + } + }, 2000); + }); + } + + function checkProcessExistInInfos(processInfos, processName) { + for (var i = 0; i < processInfos.length; i++) { + if (processInfos[i].processName == processName) { + return true; + } + } + return false; + } + + function checkPromiseMissionExistDelay(abilityName) { + var numMax = 1024; + + return new Promise(async (resolve, reject) => { + try { + var missionInfos = await missionmanager.getMissionInfos('', numMax); + console.debug("====>ACTS_ProcessManage checkPromiseMissionExistDelay missionInfos====>" + + JSON.stringify(missionInfos)); + resolve(checkMissionExistInInfos(missionInfos, abilityName)); + } catch (err) { + onsole.debug("====>ACTS_ProcessManage checkPromiseMissionExistDelay err====>" + + JSON.stringify(err)); + } + }); + } + + function checkMissionExistInInfos(missionInfos, abilityName) { + for (var i = 0; i < missionInfos.length; i++) { + if ((missionInfos[i].want.abilityName == abilityName) && (missionInfos[i].runningState == 0)) { + return true; + } + } + return false; + } + + function getAppDataPathFileNums(uri, callBack) { + setTimeout(async function () { + + file.list({ + uri: uri, + success: function (data) { + console.log('====>ActsProcessManageJsTest call list success data ====>' + JSON.stringify(data)); + callBack(null, data.fileList.length); + }, + fail: function (data, code) { + callBack(data, null); + console.log('call list failed, code: ' + code + ', data: ' + data); + }, + }); + }, 2000); + } + + /* + * @tc.number: ACTS_ProcessManage_killProcessesByBundleNameFA_0100 + * @tc.name: The system application stops itself + * @tc.desc: Check the process was killed (by promise) + */ + it('ACTS_ProcessManage_killProcessesByBundleNameFA_0100', 0, async function (done) { + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0100 begin'); + + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "promiseKill", + parameters: { + testTarget: systemABundleName + } + }, + } + ); + + setTimeout(async function () { + var processexist = await checkPromiseExistDelay(systemAProcessName); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0100 processexist:====>" + + JSON.stringify(processexist)); + expect(processexist).assertEqual(false); + + var missionexist = await checkPromiseMissionExistDelay(systemAAbilityName) + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0100 missionexist:====>" + + JSON.stringify(missionexist)); + expect(missionexist).assertEqual(false); + + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0100 end'); + done(); + }, 4000); + }) + + /* + * @tc.number: ACTS_ProcessManage_killProcessesByBundleNameFA_0200 + * @tc.name: The system application stops other system application + * @tc.desc: Check the process was killed (by promise) + */ + it('ACTS_ProcessManage_killProcessesByBundleNameFA_0200', 0, async function (done) { + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0200 begin'); + var subscriber; + + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "promiseKill", + parameters: { + testTarget: systemBBundleName + } + }, + }, (error, data) => { + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0200 - startAbility: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + } + ); + await commonEvent.createSubscriber(subscribeInfo).then(async (data) => { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0200 Create Subscriber data====>" + + data); + subscriber = data; + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0200 subscriber====>" + + JSON.stringify(subscriber)); + await commonEvent.subscribe(subscriber, subscribeCallBack); + }); + async function subscribeCallBack(err, data) { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0200 Subscribe CallBack data:====>" + + JSON.stringify(data)); + expect(data.event).assertEqual(eventFromSystemA); + expect(data.data).assertEqual('0'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + + } + async function unSubscribeCallback() { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0200 UnSubscribe CallBack====>"); + var processexist = await checkPromiseExistDelay(systemBProcessName); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0200 processexist:====>" + + JSON.stringify(processexist)); + expect(processexist).assertEqual(false); + + var missionexist = await checkPromiseMissionExistDelay(systemBAbilityName) + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0200 missionexist:====>" + + JSON.stringify(missionexist)); + expect(missionexist).assertEqual(false); + + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0200 end'); + done(); + } + }) + + /* + * @tc.number: ACTS_ProcessManage_killProcessesByBundleNameFA_0300 + * @tc.name: The system application stops third-party application + * @tc.desc: Check the process was killed (by promise) + */ + it('ACTS_ProcessManage_killProcessesByBundleNameFA_0300', 0, async function (done) { + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0300 begin'); + var subscriber; + + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "promiseKill", + parameters: { + testTarget: vendorABundleName + } + }, + } + ); + await commonEvent.createSubscriber(subscribeInfo).then(async (data) => { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0300 Create Subscriber data====>" + + data); + subscriber = data; + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0300 subscriber====>" + + JSON.stringify(subscriber)); + await commonEvent.subscribe(subscriber, subscribeCallBack); + }); + async function subscribeCallBack(err, data) { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0300 Subscribe CallBack data:====>" + + JSON.stringify(data)); + expect(data.event).assertEqual(eventFromSystemA); + expect(data.data).assertEqual('0'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + async function unSubscribeCallback() { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0300 UnSubscribe CallBack====>"); + var processexist = await checkPromiseExistDelay(vendorAProcessName); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0300 processexist:====>" + + JSON.stringify(processexist)); + expect(processexist).assertEqual(false); + + var missionexist = await checkPromiseMissionExistDelay(vendorAAbilityName) + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0300 missionexist:====>" + + JSON.stringify(missionexist)); + expect(missionexist).assertEqual(false); + + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0300 end'); + done(); + } + }) + + /* + * @tc.number: ACTS_ProcessManage_killProcessesByBundleNameFA_0400 + * @tc.name: The system application stops multiprocess application + * @tc.desc: Check the process was killed (by promise) + */ + it('ACTS_ProcessManage_killProcessesByBundleNameFA_0400', 0, async function (done) { + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0400 begin'); + var flagProcessA = 0; + var flagProcessAMulti = 0; + var flagMissionA = 0; + var flagMissionAMulti = 0; + var numMax = 1024; + + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "promiseKill", + parameters: { + testTarget: systemAMultiAbilityName + } + }, + } + ); + setTimeout(async function () { + + var processInfos = await abilitymanager.getActiveProcessInfos(); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0400 processInfos====>" + + JSON.stringify(processInfos)); + for (var i = 0; i < processInfos.length; i++) { + if (processInfos[i].processName == systemAProcessName) { + flagProcessA++; + } + if (processInfos[i].processName == systemAMultiProcessName) { + flagProcessAMulti++; + } + } + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0400 flagProcessA====>" + + JSON.stringify(flagProcessA)); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0400 flagProcessAMulti====>" + + JSON.stringify(flagProcessAMulti)); + expect(flagProcessA).assertEqual(0); + expect(flagProcessAMulti).assertEqual(0); + + var missionInfos = await missionmanager.getMissionInfos('', numMax); + console.debug("====>ACTS_ProcessManage checkPromiseMissionExistDelay missionInfos====>" + + JSON.stringify(missionInfos)); + for (var i = 0; i < missionInfos.length; i++) { + + if ((missionInfos[i].want.abilityName == systemAAbilityName) + && (missionInfos[i].runningState == 0)) { + flagMissionA++; + } + if ((missionInfos[i].want.abilityName == systemAMultiAbilityName) + && (missionInfos[i].runningState == 0)) { + flagMissionAMulti++; + } + } + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0400 flagMissionA====>" + + JSON.stringify(flagMissionA)); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0400 flagMissionAMulti====>" + + JSON.stringify(flagMissionAMulti)); + expect(flagMissionA).assertEqual(0); + expect(flagMissionAMulti).assertEqual(0); + + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0400 end'); + done(); + }, 4000); + }) + + /* + * @tc.number: ACTS_ProcessManage_killProcessesByBundleNameFA_0500 + * @tc.name: The system application stops itself + * @tc.desc: Check the process was killed (by AsyncCallback) + */ + it('ACTS_ProcessManage_killProcessesByBundleNameFA_0500', 0, async function (done) { + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0500 begin'); + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "asyncKill", + parameters: { + testTarget: systemABundleName + } + }, + } + ); + setTimeout(async function () { + var processexist = await checkPromiseExistDelay(systemAProcessName); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0500 processexist:====>" + + JSON.stringify(processexist)); + expect(processexist).assertEqual(false); + + var missionexist = await checkPromiseMissionExistDelay(systemAAbilityName) + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0500 missionexist:====>" + + JSON.stringify(missionexist)); + expect(missionexist).assertEqual(false); + + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0500 end'); + done(); + }, 4000); + }) + + /* + * @tc.number: ACTS_ProcessManage_killProcessesByBundleNameFA_0600 + * @tc.name: The system application stops other system application + * @tc.desc: Check the process was killed (by AsyncCallback) + */ + it('ACTS_ProcessManage_killProcessesByBundleNameFA_0600', 0, async function (done) { + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0600 begin'); + var subscriber; + + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "asyncKill", + parameters: { + testTarget: systemBBundleName + } + }, + } + ); + await commonEvent.createSubscriber(subscribeInfo).then(async (data) => { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0600 Create Subscriber data====>" + + data); + subscriber = data; + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0600 subscriber====>" + + JSON.stringify(subscriber)); + await commonEvent.subscribe(subscriber, subscribeCallBack); + }); + async function subscribeCallBack(err, data) { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0600 Subscribe CallBack data:====>" + + JSON.stringify(data)); + expect(data.event).assertEqual(eventFromSystemA); + expect(data.data).assertEqual('0'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + + } + + async function unSubscribeCallback() { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0600 UnSubscribe CallBack====>"); + var processexist = await checkPromiseExistDelay(systemBProcessName); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0600 processexist:====>" + + JSON.stringify(processexist)); + expect(processexist).assertEqual(false); + + var missionexist = await checkPromiseMissionExistDelay(systemBAbilityName) + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0600 missionexist:====>" + + JSON.stringify(missionexist)); + expect(missionexist).assertEqual(false); + + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0600 end'); + done(); + } + }) + + /* + * @tc.number: ACTS_ProcessManage_killProcessesByBundleNameFA_0700 + * @tc.name: The system application stops third-party application + * @tc.desc: Check the process was killed (by AsyncCallback) + */ + it('ACTS_ProcessManage_killProcessesByBundleNameFA_0700', 0, async function (done) { + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0700 begin'); + var subscriber; + + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "asyncKill", + parameters: { + testTarget: vendorABundleName + } + }, + } + ); + await commonEvent.createSubscriber(subscribeInfo).then(async (data) => { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0700 Create Subscriber data====>" + + data); + subscriber = data; + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0700 subscriber====>" + + JSON.stringify(subscriber)); + await commonEvent.subscribe(subscriber, subscribeCallBack); + }); + async function subscribeCallBack(err, data) { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0700 Subscribe CallBack data:====>" + + JSON.stringify(data)); + expect(data.event).assertEqual(eventFromSystemA); + expect(data.data).assertEqual('0'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + + } + + async function unSubscribeCallback() { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0700 UnSubscribe CallBack====>"); + var processexist = await checkPromiseExistDelay(vendorAProcessName); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0700 processexist:====>" + + JSON.stringify(processexist)); + expect(processexist).assertEqual(false); + + var missionexist = await checkPromiseMissionExistDelay(vendorAAbilityName) + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0700 missionexist:====>" + + JSON.stringify(missionexist)); + expect(missionexist).assertEqual(false); + + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0700 end'); + done(); + + } + }) + + /* + * @tc.number: ACTS_ProcessManage_killProcessesByBundleNameFA_0800 + * @tc.name: The system application stops multiprocess application + * @tc.desc: Check the process was killed (by AsyncCallback) + */ + it('ACTS_ProcessManage_killProcessesByBundleNameFA_0800', 0, async function (done) { + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0800 begin'); + var flagProcessA = 0; + var flagProcessAMulti = 0; + var flagMissionA = 0; + var flagMissionAMulti = 0; + var numMax = 1024; + + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "asyncKill", + parameters: { + testTarget: systemAMultiAbilityName + } + }, + } + ); + setTimeout(async function () { + + var processInfos = await abilitymanager.getActiveProcessInfos(); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0800 processInfos====>" + + JSON.stringify(processInfos)); + for (var i = 0; i < processInfos.length; i++) { + if (processInfos[i].processName == systemAProcessName) { + flagProcessA++; + } + if (processInfos[i].processName == systemAMultiProcessName) { + flagProcessAMulti++; + } + } + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0800 flagProcessA====>" + + JSON.stringify(flagProcessA)); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0800 flagProcessAMulti====>" + + JSON.stringify(flagProcessAMulti)); + expect(flagProcessA).assertEqual(0); + expect(flagProcessAMulti).assertEqual(0); + + var missionInfos = await missionmanager.getMissionInfos('', numMax); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0800 missionInfos====>" + + JSON.stringify(missionInfos)); + for (var i = 0; i < missionInfos.length; i++) { + + if ((missionInfos[i].want.abilityName == systemAAbilityName) + && (missionInfos[i].runningState == 0)) { + flagMissionA++; + } + if ((missionInfos[i].want.abilityName == systemAMultiAbilityName) + && (missionInfos[i].runningState == 0)) { + flagMissionAMulti++; + } + } + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0800 flagMissionA====>" + + JSON.stringify(flagMissionA)); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0800 flagMissionAMulti====>" + + JSON.stringify(flagMissionAMulti)); + expect(flagMissionA).assertEqual(0); + expect(flagMissionAMulti).assertEqual(0); + + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0800 end'); + done(); + }, 4000); + + }) + + + /* + * @tc.number: ACTS_ProcessManage_killProcessesByBundleNameFA_0900 + * @tc.name: Parameter is null + * @tc.desc: Check the result is OK (by promise) + */ + it('ACTS_ProcessManage_killProcessesByBundleNameFA_0900', 0, async function (done) { + + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0900 begin'); + try { + var result = await abilityManager.killProcessesByBundleName(null); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0900 null result:====>" + + JSON.stringify(result)); + expect(result == 0).assertEqual(false); + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_0900 end'); + done(); + } + catch (err) { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_0900 err:====>" + + JSON.stringify(err)); + done(); + } + }) + + + /* + * @tc.number: ACTS_ProcessManage_killProcessesByBundleNameFA_1000 + * @tc.name: Parameter is '' + * @tc.desc: Check the result is OK (by promise) + */ + it('ACTS_ProcessManage_killProcessesByBundleNameFA_1000', 0, async function (done) { + + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_1000 begin'); + try { + var result = await abilityManager.killProcessesByBundleName(''); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_1000 '' result:====>" + + JSON.stringify(result)); + expect(result).assertEqual(2097215); + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_1000 end'); + done(); + } + catch (err) { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_1000 err:====>" + + JSON.stringify(err)); + done(); + } + }) + + /* + * @tc.number: ACTS_ProcessManage_killProcessesByBundleNameFA_1100 + * @tc.name: Parameter is undefined + * @tc.desc: Check the result is OK (by promise) + */ + it('ACTS_ProcessManage_killProcessesByBundleNameFA_1100', 0, async function (done) { + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_1100 begin'); + try { + var result = await abilityManager.killProcessesByBundleName(undefined); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_1100 undefined result:====>" + + JSON.stringify(result)); + expect(result == 0).assertEqual(false); + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_1100 end'); + done(); + } + catch (err) { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_1100 err:====>" + + JSON.stringify(err)); + done(); + } + }) + + /* + * @tc.number: ACTS_ProcessManage_killProcessesByBundleNameFA_1200 + * @tc.name: Stop an application that doesn't exist + * @tc.desc: Check the result is OK (by promise) + */ + it('ACTS_ProcessManage_killProcessesByBundleNameFA_1200', 0, async function (done) { + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_1200 begin'); + try { + var result = await abilityManager.killProcessesByBundleName("aa.bb.notExist"); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_1200 aa.bb.notExist result:====>" + + JSON.stringify(result)); + expect(result).assertEqual(2097215); + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_1200 end'); + done(); + } + catch (err) { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_1200 err:====>" + + JSON.stringify(err)); + done(); + } + }) + + /* + * @tc.number: ACTS_ProcessManage_killProcessesByBundleNameFA_1300 + * @tc.name: Stop an application that exists but is not started + * @tc.desc: Check the result is OK (by promise) + */ + it('ACTS_ProcessManage_killProcessesByBundleNameFA_1300', 0, async function (done) { + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_1300 begin'); + try { + var result = await abilityManager.killProcessesByBundleName(systemABundleName); + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_1300 without runnning result:====>" + + JSON.stringify(result)); + expect(result).assertEqual(0); + console.log('ACTS_ProcessManage_killProcessesByBundleNameFA_1300 end'); + done(); + } + catch (err) { + console.debug("====>ACTS_ProcessManage_killProcessesByBundleNameFA_1300 err:====>" + + JSON.stringify(err)); + done(); + } + }) + + + /* + * @tc.number: ACTS_ProcessManage_clearUpApplicationDataFA_0100 + * @tc.name: The system application cleans itself + * @tc.desc: Check the process was cleaned up (by promise) + */ + it('ACTS_ProcessManage_clearUpApplicationDataFA_0100', 0, async function (done) { + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0100 begin'); + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "promiseCleanup", + parameters: { + testTarget: systemABundleName + } + }, + } + ); + setTimeout(async function () { + var processexist = await checkPromiseExistDelay(systemAProcessName); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0100 processexist:====>" + + JSON.stringify(processexist)); + expect(processexist).assertEqual(false); + + var missionexist = await checkPromiseMissionExistDelay(systemAAbilityName) + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0100 missionexist:====>" + + JSON.stringify(missionexist)); + expect(missionexist).assertEqual(false); + + getAppDataPathFileNums(uriSystemA, async (err, nums) => { + expect(err).assertEqual(null); + expect(nums).assertEqual(4); + console.log('====>ACTS_ProcessManage_clearUpApplicationDataFA_0100 getFileNums nums = ' + + nums); + done(); + }); + }, 2000); + }) + + /* + * @tc.number: ACTS_ProcessManage_clearUpApplicationDataFA_0200 + * @tc.name: The system application cleans other system application + * @tc.desc: Check the process was cleaned up (by promise) + */ + it('ACTS_ProcessManage_clearUpApplicationDataFA_0200', 0, async function (done) { + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0200 begin'); + var subscriber; + + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "promiseCleanup", + parameters: { + testTarget: systemBBundleName + } + }, + } + ); + var subscriber = await commonEvent.createSubscriber(subscribeInfo) + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0200 subscriber====>" + + JSON.stringify(subscriber)); + await commonEvent.subscribe(subscriber, subscribeCallBack); + + async function subscribeCallBack(err, data) { + + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0200 SubscribeCallBack data.event:====>" + + JSON.stringify(data.event)); + expect(data.event).assertEqual(eventFromSystemA); + expect(data.data).assertEqual('0'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + + var processexist = await checkPromiseExistDelay(systemBProcessName); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0200 subscribeCallBack processexist:" + + JSON.stringify(processexist)); + expect(processexist).assertEqual(false); + var missionexist = await checkPromiseMissionExistDelay(systemBAbilityName) + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0200 subscribeCallBack missionexist:" + + JSON.stringify(missionexist)); + expect(missionexist).assertEqual(false); + + getAppDataPathFileNums(uriSystemB, async (err, nums) => { + expect(err).assertEqual(null); + expect(nums).assertEqual(4); + console.log('====>ACTS_ProcessManage_clearUpApplicationDataFA_0200 getFileNums nums = ' + nums); + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0200 end'); + done(); + }); + } + function unSubscribeCallback() { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0200 UnSubscribe CallBack====>"); + } + }) + + /* + * @tc.number: ACTS_ProcessManage_clearUpApplicationDataFA_0300 + * @tc.name: The system application cleans third-party application + * @tc.desc: Check the process was cleaned up (by promise) + */ + it('ACTS_ProcessManage_clearUpApplicationDataFA_0300', 0, async function (done) { + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0300 begin'); + var subscriber; + + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "promiseCleanup", + parameters: { + testTarget: vendorABundleName + } + }, + } + ); + var subscriber = await commonEvent.createSubscriber(subscribeInfo) + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0300 subscriber====>" + + JSON.stringify(subscriber)); + await commonEvent.subscribe(subscriber, subscribeCallBack); + + async function subscribeCallBack(err, data) { + + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0300 SubscribeCallBack data.event:====>" + + JSON.stringify(data)); + expect(data.event).assertEqual(eventFromSystemA); + expect(data.data).assertEqual('0'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + setTimeout(async function () { + var processexist = await checkPromiseExistDelay(vendorAProcessName); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0300 subscribeCallBack processexist:" + + JSON.stringify(processexist)); + expect(processexist).assertEqual(false); + var missionexist = await checkPromiseMissionExistDelay(vendorAAbilityName) + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0300 subscribeCallBack missionexist:" + + JSON.stringify(missionexist)); + expect(missionexist).assertEqual(false); + getAppDataPathFileNums(uriVendorA, async (err, nums) => { + expect(err).assertEqual(null); + expect(nums).assertEqual(4); + console.log('====>ACTS_ProcessManage_clearUpApplicationDataFA_0300 getFileNums nums = ' + nums); + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0300 end'); + done(); + }); + }, 6000); + } + function unSubscribeCallback() { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0300 UnSubscribe CallBack====>"); + } + }) + + /* + * @tc.number: ACTS_ProcessManage_clearUpApplicationDataFA_0400 + * @tc.name: The system application cleans multiprocess application + * @tc.desc: Check the process was cleaned up (by promise) + */ + it('ACTS_ProcessManage_clearUpApplicationDataFA_0400', 0, async function (done) { + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0400 begin'); + var flagProcessA = 0; + var flagProcessAMulti = 0; + var flagMissionA = 0; + var flagMissionAMulti = 0; + var numMax = 1024; + + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "promiseCleanup", + parameters: { + testTarget: systemAMultiAbilityName + } + }, + } + ); + setTimeout(async function () { + + var processInfos = await abilitymanager.getActiveProcessInfos(); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0400 processInfos====>" + + JSON.stringify(processInfos)); + for (var i = 0; i < processInfos.length; i++) { + if (processInfos[i].processName == systemAProcessName) { + flagProcessA++; + } + if (processInfos[i].processName == systemAMultiProcessName) { + flagProcessAMulti++; + } + } + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0400 flagProcessA====>" + + JSON.stringify(flagProcessA)); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0400 flagProcessAMulti====>" + + JSON.stringify(flagProcessAMulti)); + expect(flagProcessA).assertEqual(0); + expect(flagProcessAMulti).assertEqual(0); + + var missionInfos = await missionmanager.getMissionInfos('', numMax); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0400 missionInfos====>" + + JSON.stringify(missionInfos)); + for (var i = 0; i < missionInfos.length; i++) { + if ((missionInfos[i].want.abilityName == systemAAbilityName) + && (missionInfos[i].runningState == 0)) { + flagMissionA++; + } + if ((missionInfos[i].want.abilityName == systemAMultiAbilityName) + && (missionInfos[i].runningState == 0)) { + flagMissionAMulti++; + } + } + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0400 flagMissionA====>" + + JSON.stringify(flagMissionA)); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0400 flagMissionAMulti====>" + + JSON.stringify(flagMissionAMulti)); + expect(flagMissionA).assertEqual(0); + expect(flagMissionAMulti).assertEqual(0); + + getAppDataPathFileNums(uriSystemA, async (err, nums) => { + expect(err).assertEqual(null); + expect(nums).assertEqual(4); + console.log('====>ACTS_ProcessManage_clearUpApplicationDataFA_0400 getFileNums nums = ' + + nums); + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0400 end'); + done(); + }); + }, 6000); + }) + + /* + * @tc.number: ACTS_ProcessManage_clearUpApplicationDataFA_0500 + * @tc.name: The system application cleans itself + * @tc.desc: Check the process was cleaned up (by AsyncCallback) + */ + it('ACTS_ProcessManage_clearUpApplicationDataFA_0500', 0, async function (done) { + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0500 begin'); + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "asyncCleanup", + parameters: { + testTarget: systemABundleName + } + }, + } + ); + setTimeout(async function () { + var processexist = await checkPromiseExistDelay(systemAProcessName); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0500 processexist:====>" + + JSON.stringify(processexist)); + expect(processexist).assertEqual(false); + + var missionexist = await checkPromiseMissionExistDelay(systemAAbilityName) + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0500 missionexist:====>" + + JSON.stringify(missionexist)); + expect(missionexist).assertEqual(false); + + getAppDataPathFileNums(uriSystemA, async (err, nums) => { + expect(err).assertEqual(null); + expect(nums).assertEqual(4); + console.log('====>ACTS_ProcessManage_clearUpApplicationDataFA_0500 getFileNums nums = ' + + nums); + done(); + }); + }, 6000); + }) + + /* + * @tc.number: ACTS_ProcessManage_clearUpApplicationDataFA_0600 + * @tc.name: The system application cleans other system application + * @tc.desc: Check the process was cleaned up (by AsyncCallback) + */ + it('ACTS_ProcessManage_clearUpApplicationDataFA_0600', 0, async function (done) { + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0600 begin'); + var subscriber; + + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "asyncCleanup", + parameters: { + testTarget: systemBBundleName + } + }, + } + ); + await commonEvent.createSubscriber(subscribeInfo).then(async (data) => { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0600 Create Subscriber data====>" + + data); + subscriber = data; + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0600 subscriber====>" + + JSON.stringify(subscriber)); + await commonEvent.subscribe(subscriber, subscribeCallBack); + }); + async function subscribeCallBack(err, data) { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0600 SubscribeCallBack data:====>" + + JSON.stringify(data)); + expect(data.event).assertEqual(eventFromSystemA); + expect(data.data).assertEqual('0'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + setTimeout(async function () { + var processexist = await checkPromiseExistDelay(systemBProcessName); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0600 processexist:====>" + + JSON.stringify(processexist)); + expect(processexist).assertEqual(false); + + var missionexist = await checkPromiseMissionExistDelay(systemBAbilityName) + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0600 missionexist:====>" + + JSON.stringify(missionexist)); + expect(missionexist).assertEqual(false); + + getAppDataPathFileNums(uriSystemB, async (err, nums) => { + expect(err).assertEqual(null); + expect(nums).assertEqual(4); + console.log('====>ACTS_ProcessManage_clearUpApplicationDataFA_0600 getFileNums nums = ' + nums); + + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0600 end'); + done(); + }); + }, 6000); + } + function unSubscribeCallback() { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0600 UnSubscribe CallBack====>"); + } + }) + + /* + * @tc.number: ACTS_ProcessManage_clearUpApplicationDataFA_0700 + * @tc.name: The system application cleans third-party application + * @tc.desc: Check the process was cleaned up (by AsyncCallback) + */ + it('ACTS_ProcessManage_clearUpApplicationDataFA_0700', 0, async function (done) { + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0700 begin'); + var subscriber; + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "asyncCleanup", + parameters: { + testTarget: vendorABundleName + } + }, + } + ); + await commonEvent.createSubscriber(subscribeInfo).then(async (data) => { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0700 Create Subscriber data====>" + + data); + subscriber = data; + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0700 subscriber====>" + + JSON.stringify(subscriber)); + await commonEvent.subscribe(subscriber, subscribeCallBack); + }); + async function subscribeCallBack(err, data) { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0700 SubscribeCallBack data:====>" + + JSON.stringify(data)); + expect(data.event).assertEqual(eventFromSystemA); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + setTimeout(async function () { + var processexist = await checkPromiseExistDelay(vendorAProcessName); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0700 processexist:====>" + + JSON.stringify(processexist)); + expect(processexist).assertEqual(false); + + var missionexist = await checkPromiseMissionExistDelay(vendorAAbilityName) + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0700 missionexist:====>" + + JSON.stringify(missionexist)); + expect(missionexist).assertEqual(false); + getAppDataPathFileNums(uriVendorA, async (err, nums) => { + expect(err).assertEqual(null); + expect(nums).assertEqual(4); + console.log('====>ACTS_ProcessManage_clearUpApplicationDataFA_0700 getFileNums nums = ' + nums); + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0700 end'); + done(); + + }); + }, 6000); + } + function unSubscribeCallback() { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0700 UnSubscribe CallBack====>"); + } + }) + + /* + * @tc.number: ACTS_ProcessManage_clearUpApplicationDataFA_0800 + * @tc.name: The system application cleans multiprocess application + * @tc.desc: Check the process was cleaned up (by AsyncCallback) + */ + it('ACTS_ProcessManage_clearUpApplicationDataFA_0800', 0, async function (done) { + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0800 begin'); + var flagProcessA = 0; + var flagProcessAMulti = 0; + var flagMissionA = 0; + var flagMissionAMulti = 0; + var numMax = 1024; + + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "asyncCleanup", + parameters: { + testTarget: systemAMultiAbilityName + } + }, + } + ); + setTimeout(async function () { + + var processInfos = await abilitymanager.getActiveProcessInfos(); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0800 processInfos====>" + + JSON.stringify(processInfos)); + for (var i = 0; i < processInfos.length; i++) { + if (processInfos[i].processName == systemAProcessName) { + flagProcessA++; + } + if (processInfos[i].processName == systemAMultiProcessName) { + flagProcessAMulti++; + } + } + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0800 flagProcessA====>" + + JSON.stringify(flagProcessA)); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0800 flagProcessAMulti====>" + + JSON.stringify(flagProcessAMulti)); + expect(flagProcessA).assertEqual(0); + expect(flagProcessAMulti).assertEqual(0); + + var missionInfos = await missionmanager.getMissionInfos('', numMax); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0800 missionInfos====>" + + JSON.stringify(missionInfos)); + for (var i = 0; i < missionInfos.length; i++) { + if ((missionInfos[i].want.abilityName == systemAAbilityName) + && (missionInfos[i].runningState == 0)) { + flagMissionA++; + } + if ((missionInfos[i].want.abilityName == systemAMultiAbilityName) + && (missionInfos[i].runningState == 0)) { + flagMissionAMulti++; + } + } + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0800 flagMissionA====>" + + JSON.stringify(flagMissionA)); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0800 flagMissionAMulti====>" + + JSON.stringify(flagMissionAMulti)); + expect(flagMissionA).assertEqual(0); + expect(flagMissionAMulti).assertEqual(0); + + getAppDataPathFileNums(uriSystemA, async (err, nums) => { + expect(err).assertEqual(null); + expect(nums).assertEqual(4); + console.log('====>ACTS_ProcessManage_clearUpApplicationDataFA_0800 getFileNums nums = ' + + nums); + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0800 end'); + done(); + }); + }, 6000); + }) + + /* + * @tc.number: ACTS_ProcessManage_clearUpApplicationDataFA_0900 + * @tc.name: Parameter is null + * @tc.desc: Check the result is OK (by AsyncCallback) + */ + it('ACTS_ProcessManage_clearUpApplicationDataFA_0900', 0, async function (done) { + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0900 begin'); + + try { + var result = await abilityManager.clearUpApplicationData(null); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0900 null result:====>" + + JSON.stringify(result)); + expect(result == 0).assertEqual(false); + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_0900 end'); + done(); + } + catch (err) { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_0900 err:====>" + + JSON.stringify(err)); + done(); + } + }) + + /* + * @tc.number: ACTS_ProcessManage_clearUpApplicationDataFA_1000 + * @tc.name: Parameter is '' + * @tc.desc: Check the result is OK (by AsyncCallback) + */ + it('ACTS_ProcessManage_clearUpApplicationDataFA_1000', 0, async function (done) { + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_1000 begin'); + abilityManager.clearUpApplicationData('', (err, data) => { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_1000 '' result:====>" + + JSON.stringify(data)); + expect(err.code).assertEqual(0); + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_1000 end'); + done(); + }); + }) + + /* + * @tc.number: ACTS_ProcessManage_clearUpApplicationDataFA_1100 + * @tc.name: Parameter is undefined + * @tc.desc: Check the result is OK (by AsyncCallback) + */ + it('ACTS_ProcessManage_clearUpApplicationDataFA_1100', 0, async function (done) { + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_1100 begin'); + try { + var result = await abilityManager.clearUpApplicationData(undefined); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_1100 undefined result:====>" + + JSON.stringify(result)); + expect(result == 0).assertEqual(false); + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_1100 end'); + done(); + } + catch (err) { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_1100 err:====>" + + JSON.stringify(err)); + done(); + } + }) + + /* + * @tc.number: ACTS_ProcessManage_clearUpApplicationDataFA_1200 + * @tc.name: Stop an application that doesn't exist + * @tc.desc: Check the result is OK (by AsyncCallback) + */ + it('ACTS_ProcessManage_clearUpApplicationDataFA_1200', 0, async function (done) { + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_1200 begin'); + abilityManager.clearUpApplicationData("aa.bb.notExist", (err, data) => { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_1200 aa.bb.notExist result:====>" + + JSON.stringify(data)); + expect(err.code).assertEqual(0); + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_1200 end'); + done(); + }); + }) + + /* + * @tc.number: ACTS_ProcessManage_clearUpApplicationDataFA_1300 + * @tc.name: Stop an application that exists but is not started + * @tc.desc: Check the result is OK (by AsyncCallback) + */ + it('ACTS_ProcessManage_clearUpApplicationDataFA_1300', 0, async function (done) { + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_1300 begin'); + abilityManager.clearUpApplicationData(systemABundleName, (err, data) => { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_1300 without running result:====>" + + JSON.stringify(data)); + expect(err.code).assertEqual(0); + setTimeout(async function () { + getAppDataPathFileNums(uriSystemA, async (err, nums) => { + expect(err).assertEqual(null); + expect(nums).assertEqual(4); + console.log('====>ACTS_ProcessManage_clearUpApplicationDataFA_1300 getFileNums nums = ' + nums); + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_1300 end'); + done(); + }); + }, 4000); + }); + }) + + /* + * @tc.number: ACTS_ProcessManage_clearUpApplicationDataFA_1400 + * @tc.name: The system application cleans third-party application for ten times + * @tc.desc: Check the process was cleaned up (by AsyncCallback) + */ + it('ACTS_ProcessManage_clearUpApplicationDataFA_1400', 0, async function (done) { + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_1400 begin'); + var subscriber; + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: systemAAbilityName, + action: "promiseCleanupTentimes", + parameters: { + testTarget: vendorABundleName + } + }, + } + ); + + await commonEvent.createSubscriber(subscribeInfo).then(async (data) => { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_1400 Create Subscriber data====>" + + data); + subscriber = data; + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_1400 subscriber====>" + + JSON.stringify(subscriber)); + await commonEvent.subscribe(subscriber, subscribeCallBack); + }); + + async function subscribeCallBack(err, data) { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_1400 Subscribe CallBack data:====>" + + JSON.stringify(data)); + expect(data.event).assertEqual(eventFromSystemA); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + setTimeout(async function () { + var processexist = await checkPromiseExistDelay(vendorAProcessName); + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_1400 processexist:====>" + + JSON.stringify(processexist)); + expect(processexist).assertEqual(false); + + var missionexist = await checkPromiseMissionExistDelay(vendorAAbilityName) + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_1400 missionexist:====>" + + JSON.stringify(missionexist)); + expect(missionexist).assertEqual(false); + + getAppDataPathFileNums(uriVendorA, async (err, nums) => { + expect(err).assertEqual(null); + expect(nums).assertEqual(4); + console.log('====>ACTS_ProcessManage_clearUpApplicationDataFA_1400 getAppDataPathFileNums nums = ' + + nums); + + console.log('ACTS_ProcessManage_clearUpApplicationDataFA_1400 end'); + done(); + }); + }, 15000); + } + function unSubscribeCallback() { + console.debug("====>ACTS_ProcessManage_clearUpApplicationDataFA_1400 UnSubscribe CallBack====>"); + } + }) +}) \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/test/List.test.js b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..a7c683b3c0d578297e04ff1d997cf048087eec47 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2021 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. + */ +require('./ActsProcessManageJsTest.test.js') \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amsprocessmanageapi7/actsprocessmanagejstest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/BUILD.gn b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..31dc26c90acd3db562c86c8b041347e7bb55f94a --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (C) 2021 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_hap("ActsAmsProcessManageSystemAppAApi7") { + hap_name = "ActsAmsProcessManageSystemAppAApi7" + hap_profile = "./src/main/config.json" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/js/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/config.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..829eb86b1b8e255346717f35efb40221fe93a3df --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/config.json @@ -0,0 +1,107 @@ +{ + "app": { + "bundleName": "com.acts.pmsystemappaapi7", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": { + "default": { + "process": "com.acts.pmsystemappaapi7" + } + }, + "module": { + "package": "com.acts.pmsystemappaapi7", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.acts.pmsystemappaapi7.MainAbility", + "visible": true, + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "reqPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.CLEAN_APPLICATION_DATA", + "reason":"need use ohos.permission.CLEAN_APPLICATION_DATA" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/app.js b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..cbcbab28325171fef09134ede1173011a95e91d7 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/app.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 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. + */ +export default { + onCreate() { + console.info('ProcessManageSystemAppA onCreate'); + }, + onDestroy() { + console.info('ProcessManageSystemAppA onDestroy'); + }, + onShow() { + console.info('ProcessManageSystemAppA onShow'); + }, + onHide() { + console.info('ProcessManageSystemAppA onHide'); + } +}; diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/i18n/en-US.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/i18n/zh-CN.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/pages/index/index.css b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/pages/index/index.hml b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ac65f898986eb9bc0966f0ab86ca766b8bded579 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/default/pages/index/index.js @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2021 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 commonEvent from '@ohos.commonevent' +import abilityManager from '@ohos.application.appManager' +import featureAbility from '@ohos.ability.featureability' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +var subscribeInfo = { + events: ["event_from_ProcessManage_SystemTest", + "event_SystemAppBToSystemAppA", + "event_VendorAppAToSystemAppA", + "event_SystemAppAMultiToSystemAppA", + "event_VendorAppServiceToSystemAppA" + ], +}; +var publishEventName = "event_from_ProcessManage_SystemAppA"; +var eventFromSystemAMulti = "event_SystemAppAMultiToSystemAppA"; +var testAction; +var testTarget; +var subscriber; +var systemABundleName = "com.acts.pmsystemappaapi7"; +var systemBBundleName = "com.acts.pmsystemappbapi7"; +var vendorABundleName = "com.acts.pmvendorappaapi7"; +var systemBAbilityName = "com.acts.pmsystemappbapi7.MainAbility"; +var vendorAAbilityName = "com.acts.pmvendorappaapi7.MainAbility"; +var multiAAbilityName = "com.acts.pmsystemappamultiapi7.MainAbility"; + +function onReceivedPublishCallBack() { + console.log("ACTS_ProcessManage SystemAppA onReceivedPublishCallBack"); +} + +function publishResultEvent(testResult) { + console.log("ACTS_ProcessManage SystemAppA publishResultEvent testAction:" + testAction); + console.log("ACTS_ProcessManage SystemAppA publishResultEvent testTarget:" + testTarget); + console.log("ACTS_ProcessManage SystemAppA publishResultEvent testResult:" + testResult); + let publishData = { data: testResult.toString() }; + console.log("ACTS_ProcessManage SystemAppA publishResultEvent publishData:" + + JSON.stringify(publishData)); + commonEvent.publish(publishEventName, publishData, onReceivedPublishCallBack); + +} +function onReceivedHandleCallback(err, data) { + publishResultEvent(data); + console.log("ACTS_ProcessManage SystemAppA onReceivedHandleCallback data:" + + JSON.stringify(data)); +} + +async function onShowProcess() { + + var abilityWant = await featureAbility.getWant(); + console.log("ACTS_ProcessManage SystemAppA onShowProcess abilityWant:" + + JSON.stringify(abilityWant)); + testAction = abilityWant.action; + console.log("ACTS_ProcessManage SystemAppA onShowProcess testAction:" + testAction); + testTarget = abilityWant.parameters.testTarget; + console.log("ACTS_ProcessManage SystemAppA onShowProcess testTarget:" + testTarget); + + + if (testTarget == systemABundleName) { + + if (testAction == "promiseKill") { + console.log("ACTS_ProcessManage SystemAppA onShowProcess testAction:" + testAction); + var result = await abilityManager.killProcessesByBundleName(testTarget); + console.log("ACTS_ProcessManage SystemAppA onShowProcess result:" + result); + publishResultEvent(result); + } else if (testAction == "asyncKill") { + console.log("ACTS_ProcessManage SystemAppA onShowProcess testAction:" + testAction); + abilityManager.killProcessesByBundleName(testTarget, onReceivedHandleCallback); + } else if (testAction == "promiseCleanup") { + console.log("ACTS_ProcessManage SystemAppA onShowProcess testAction:" + testAction); + var result = await abilityManager.clearUpApplicationData(testTarget); + console.log("ACTS_ProcessManage SystemAppA onShowProcess result:" + result); + publishResultEvent(result); + } else if (testAction == "asyncCleanup") { + console.log("ACTS_ProcessManage SystemAppA onShowProcess testAction:" + testAction); + abilityManager.clearUpApplicationData(testTarget, onReceivedHandleCallback); + } + + } + else { + try { + subscriber = await commonEvent.createSubscriber(subscribeInfo) + console.debug("ACTS_ProcessManage SystemAppA onShowProcess subscriber:" + + JSON.stringify(subscriber)); + commonEvent.subscribe(subscriber, subscribeCallBack); + } catch (err) { + console.debug("ACTS_ProcessManage SystemAppA onShowProcess err:" + err); + } + + if (testTarget == systemBBundleName) { + await featureAbility.startAbility( + { + want: + { + bundleName: systemBBundleName, + abilityName: systemBAbilityName, + }, + } + ); + } + else if (testTarget == vendorABundleName) { + await featureAbility.startAbility( + { + want: + { + bundleName: vendorABundleName, + abilityName: vendorAAbilityName, + }, + } + ); + } + else if (testTarget == multiAAbilityName) { + await featureAbility.startAbility( + { + want: + { + bundleName: systemABundleName, + abilityName: multiAAbilityName, + }, + } + ); + } + } + + async function subscribeCallBack(err, data) { + console.debug("ACTS_ProcessManage SystemAppA subscribeCallBack SubscribeCallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_ProcessManage SystemAppA subscribeCallBack SubscribeCallBack data.event:====>" + + JSON.stringify(data.event)); + + if (data.event == eventFromSystemAMulti) { + testTarget = systemABundleName; + } + + if (testAction == "promiseKill") { + console.log("ACTS_ProcessManage SystemAppA subscribeCallBack testAction:" + testAction); + var result = await abilityManager.killProcessesByBundleName(testTarget); + console.log("ACTS_ProcessManage SystemAppA subscribeCallBack result:" + result); + publishResultEvent(result); + } else if (testAction == "asyncKill") { + console.log("ACTS_ProcessManage SystemAppA subscribeCallBack testAction:" + testAction); + await abilityManager.killProcessesByBundleName(testTarget, onReceivedHandleCallback); + } else if (testAction == "promiseCleanup") { + console.log("ACTS_ProcessManage SystemAppA subscribeCallBack testAction:" + testAction); + var result = await abilityManager.clearUpApplicationData(testTarget); + console.log("ACTS_ProcessManage SystemAppA subscribeCallBack result:" + result); + publishResultEvent(result); + } else if (testAction == "asyncCleanup") { + console.log("ACTS_ProcessManage SystemAppA subscribeCallBack testAction:" + testAction); + await abilityManager.clearUpApplicationData(testTarget, onReceivedHandleCallback); + } else if (testAction == "promiseCleanupTentimes") { + for (var i = 0; i < 10; i++) { + console.log("ACTS_ProcessManage SystemAppA subscribeCallBack testAction:" + testAction); + var result = await abilityManager.clearUpApplicationData(testTarget); + console.log("ACTS_ProcessManage SystemAppA subscribeCallBack result:" + result); + } + publishResultEvent(result); + } + } + +} + +export default { + data: { + title: "" + }, + onInit() { + console.info('ACTS_ProcessManage SystemAppA onInit'); + this.title = "ProcessManageSystemAppA"; + }, + onReady() { + console.info('ACTS_ProcessManage SystemAppA onReady'); + onShowProcess(); + }, + onActive() { + console.info('ACTS_ProcessManage SystemAppA onActive'); + }, + onShow() { + console.info('ACTS_ProcessManage SystemAppA onShow'); + + }, + onInactive() { + console.info('ACTS_ProcessManage SystemAppA onInactive'); + }, + onHide() { + console.info('ACTS_ProcessManage SystemAppA onHide'); + }, + onDestroy() { + console.info('ACTS_ProcessManage SystemAppA onDestroy'); + }, + onBackPress() { + console.info('ACTS_ProcessManage SystemAppA onBackPress'); + }, + onNewRequest() { + console.info('ACTS_ProcessManage SystemAppA onNewRequest'); + }, + onStartContinuation() { + console.info('ACTS_ProcessManage SystemAppA onStartContinuation'); + }, + onSaveData(value) { + console.info('ACTS_ProcessManage SystemAppA onSaveData:' + JSON.stringify(value)); + }, + onRestoreData(value) { + console.info('ACTS_ProcessManage SystemAppA onRestoreData:' + JSON.stringify(value)); + }, + onCompleteContinuation(code) { + console.info('ACTS_ProcessManage SystemAppA onCompleteContinuation:' + JSON.stringify(code)); + }, + onConfigurationUpdated(configuration) { + console.info('ACTS_ProcessManage SystemAppA onConfigurationUpdated:' + JSON.stringify(configuration)); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/resources/base/element/string.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..fd60cdefa929070f1798c6e36f0502f1e1e219a4 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "particlestartability" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/resources/base/media/icon.png b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappa/src/main/js/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/BUILD.gn b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..934d06d652eae1629b8150a3abd120a17391645c --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (C) 2021 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_hap("ActsAmsProcessManageSystemAppAMultiApi7") { + hap_name = "ActsAmsProcessManageSystemAppAMultiApi7" + hap_profile = "./src/main/config.json" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/js/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/config.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..fcc970b486ca7375903bb2b247545043d1d84198 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/config.json @@ -0,0 +1,107 @@ +{ + "app": { + "bundleName": "com.acts.pmsystemappaapi7", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": { + "default": { + "process": "com.acts.pmsystemappamultiapi7" + } + }, + "module": { + "package": "com.acts.pmsystemappamultiapi7", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "secondEntry", + "moduleType": "feature" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.acts.pmsystemappamultiapi7.MainAbility", + "visible": true, + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "reqPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.CLEAN_APPLICATION_DATA", + "reason":"need use ohos.permission.CLEAN_APPLICATION_DATA" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/app.js b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..5d3012c7d6777f4b04710913de6f1aa718fa8cc9 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/app.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 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. + */ +export default { + onCreate() { + console.info('ProcessManageSystemAppB onCreate'); + }, + onDestroy() { + console.info('ProcessManageSystemAppB onDestroy'); + }, + onShow() { + console.info('ProcessManageSystemAppB onShow'); + }, + onHide() { + console.info('ProcessManageSystemAppB onHide'); + } +}; diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/i18n/en-US.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/i18n/zh-CN.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/pages/index/index.css b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/pages/index/index.hml b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..9420ad20ef1d46228f20092685359f0ff00ac0d4 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/default/pages/index/index.js @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2021 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 commonEvent from '@ohos.commonevent' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +var publishEventName = "event_SystemAppAMultiToSystemAppA"; + +function onReceivedPublishCallBack() { + console.log("ACTS_ProcessManage SystemAppAMulti onReceivedPublishCallBack"); +} + +export default { + data: { + title: "" + }, + onInit() { + console.info('ACTS_ProcessManage SystemAppAMulti onInit'); + this.title = "ACTS_ProcessManage SystemAppAMulti"; + }, + onReady() { + console.info('ACTS_ProcessManage SystemAppAMulti onReady'); + commonEvent.publish(publishEventName,onReceivedPublishCallBack); + }, + onActive() { + console.info('ACTS_ProcessManage SystemAppAMulti onActive'); + }, + onShow() { + console.info('ACTS_ProcessManage SystemAppAMulti onShow'); + }, + onInactive() { + console.info('ACTS_ProcessManage SystemAppAMulti onInactive'); + }, + onHide() { + console.info('ACTS_ProcessManage SystemAppAMulti onHide'); + }, + onDestroy() { + console.info('ACTS_ProcessManage SystemAppAMulti onDestroy'); + }, + onBackPress() { + console.info('ACTS_ProcessManage SystemAppAMulti onBackPress'); + }, + onNewRequest() { + console.info('ACTS_ProcessManage SystemAppAMulti onNewRequest'); + }, + onStartContinuation() { + console.info('ACTS_ProcessManage SystemAppAMulti onStartContinuation'); + }, + onSaveData(value) { + console.info('ACTS_ProcessManage SystemAppAMulti onSaveData:' + JSON.stringify(value)); + }, + onRestoreData(value) { + console.info('ACTS_ProcessManage SystemAppAMulti onRestoreData:' + JSON.stringify(value)); + }, + onCompleteContinuation(code) { + console.info('ACTS_ProcessManage SystemAppAMulti onCompleteContinuation:' + JSON.stringify(code)); + }, + onConfigurationUpdated(configuration) { + console.info('ACTS_ProcessManage SystemAppAMulti onConfigurationUpdated:' + JSON.stringify(configuration)); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/resources/base/element/string.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..fd60cdefa929070f1798c6e36f0502f1e1e219a4 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "particlestartability" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/resources/base/media/icon.png b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappamulti/src/main/js/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/BUILD.gn b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8ae53eed564a3118ff804d20485b3c2e6de68813 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (C) 2021 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_hap("ActsAmsProcessManageSystemAppBApi7") { + hap_name = "ActsAmsProcessManageSystemAppBApi7" + hap_profile = "./src/main/config.json" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/js/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/config.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..9cc2e488d8c97b09a51d5cc8939f2fda9784da94 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/config.json @@ -0,0 +1,87 @@ +{ + "app": { + "bundleName": "com.acts.pmsystemappbapi7", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.acts.pmsystemappbapi7", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.acts.pmsystemappbapi7.MainAbility", + "visible": true, + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "reqPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/app.js b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..5d3012c7d6777f4b04710913de6f1aa718fa8cc9 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/app.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 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. + */ +export default { + onCreate() { + console.info('ProcessManageSystemAppB onCreate'); + }, + onDestroy() { + console.info('ProcessManageSystemAppB onDestroy'); + }, + onShow() { + console.info('ProcessManageSystemAppB onShow'); + }, + onHide() { + console.info('ProcessManageSystemAppB onHide'); + } +}; diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/i18n/en-US.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/i18n/zh-CN.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/pages/index/index.css b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/pages/index/index.hml b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..afb29461087565d6a77f26ffab84831de1123955 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/default/pages/index/index.js @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2021 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 commonEvent from '@ohos.commonevent' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +var publishEventName = "event_SystemAppBToSystemAppA"; + +function onReceivedPublishCallBack() { + console.log("ACTS_ProcessManage SystemAppB onReceivedPublishCallBack"); +} + +export default { + data: { + title: "" + }, + onInit() { + console.info('ACTS_ProcessManage SystemAppB onInit'); + this.title = "ACTS_ProcessManage SystemAppB"; + }, + onReady() { + console.info('ACTS_ProcessManage SystemAppB onReady'); + commonEvent.publish(publishEventName,onReceivedPublishCallBack); + }, + onActive() { + console.info('ACTS_ProcessManage SystemAppB onActive'); + }, + onShow() { + console.info('ACTS_ProcessManage SystemAppB onShow'); + }, + onInactive() { + console.info('ACTS_ProcessManage SystemAppB onInactive'); + }, + onHide() { + console.info('ACTS_ProcessManage SystemAppB onHide'); + }, + onDestroy() { + console.info('ACTS_ProcessManage SystemAppB onDestroy'); + }, + onBackPress() { + console.info('ACTS_ProcessManage SystemAppB onBackPress'); + }, + onNewRequest() { + console.info('ACTS_ProcessManage SystemAppB onNewRequest'); + }, + onStartContinuation() { + console.info('ACTS_ProcessManage SystemAppB onStartContinuation'); + }, + onSaveData(value) { + console.info('ACTS_ProcessManage SystemAppB onSaveData:' + JSON.stringify(value)); + }, + onRestoreData(value) { + console.info('ACTS_ProcessManage SystemAppB onRestoreData:' + JSON.stringify(value)); + }, + onCompleteContinuation(code) { + console.info('ACTS_ProcessManage SystemAppB onCompleteContinuation:' + JSON.stringify(code)); + }, + onConfigurationUpdated(configuration) { + console.info('ACTS_ProcessManage SystemAppB onConfigurationUpdated:' + JSON.stringify(configuration)); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/resources/base/element/string.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..fd60cdefa929070f1798c6e36f0502f1e1e219a4 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "particlestartability" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/resources/base/media/icon.png b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amsprocessmanageapi7/pmsystemappb/src/main/js/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/BUILD.gn b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..37f7f37103be4789ce3856cb73a6b3778ffab064 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (C) 2021 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_hap("ActsAmsProcessManageVendorAppAApi7") { + hap_name = "ActsAmsProcessManageVendorAppAApi7" + hap_profile = "./src/main/config.json" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/js/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..f06e218defa7f707e22a3890903c574e1c498217 Binary files /dev/null and b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/config.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..38a8588558fc0b664a90d8a23d9386d87b1d9f93 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "com.acts.pmvendorappaapi7", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.acts.pmvendorappaapi7", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.acts.pmvendorappaapi7.MainAbility", + "visible": true, + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/app.js b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..c5cd374c44f4090c18d007979a6fe3b89f229a57 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/app.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 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. + */ +export default { + onCreate() { + console.info('ProcessManageVendorAppA onCreate'); + }, + onDestroy() { + console.info('ProcessManageVendorAppA onDestroy'); + }, + onShow() { + console.info('ProcessManageVendorAppA onShow'); + }, + onHide() { + console.info('ProcessManageVendorAppA onHide'); + } +}; diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/i18n/en-US.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/i18n/zh-CN.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/pages/index/index.css b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/pages/index/index.hml b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..cf78782112855a55f0fd50bc2d7ca055bd6cbdd5 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/default/pages/index/index.js @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2021 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 commonEvent from '@ohos.commonevent' +import abilityManager from '@ohos.application.appManager' +import featureAbility from '@ohos.ability.featureability' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +var publishEventName = "event_VendorAppAToSystemAppA"; +var publishEventNameVendor = "event_from_ProcessManage_VendorAppA"; +var testAction; +var testTarget; + +function onReceivedPublishCallBack() { + console.log("ACTS_ProcessManage VendorAppA onReceivedPublishCallBack"); +} + +function onReceivedHandleCallback(err, data) { + console.log("ACTS_ProcessManage VendorAppA onReceivedHandleCallback JSON.stringify data:" + + JSON.stringify(data)); + console.log("ACTS_ProcessManage VendorAppA onReceivedHandleCallback data:" + + data); + console.log("ACTS_ProcessManage VendorAppA onReceivedHandleCallback err:" + + err); + commonEvent.publish(publishEventNameVendor,onReceivedPublishCallBack); +} + +export default { + data: { + title: "" + }, + onInit() { + console.info('ACTS_ProcessManage VendorAppA onInit'); + this.title = "ACTS_ProcessManage VendorAppA"; + }, + async onReady() { + console.info('ACTS_ProcessManage VendorAppA onReady'); + var abilityWant = await featureAbility.getWant(); + console.log("ACTS_ProcessManage VendorAppA onShow abilityWant:" + + JSON.stringify(abilityWant)); + testAction = abilityWant.action; + console.log("ACTS_ProcessManage VendorAppA onShow testAction:" + testAction); + testTarget = abilityWant.parameters.testTarget; + console.log("ACTS_ProcessManage VendorAppA onShow testTarget:" + testTarget); + if (testAction == 'thirdpartykill') { + console.log("ACTS_ProcessManage VendorAppA onForeground testAction:" + testAction); + appManager.killProcessesByBundleName(testTarget, onReceivedHandleCallback); + } + if (testAction == 'thirdpartyclear') { + console.log("ACTS_ProcessManage VendorAppA onForeground testAction:" + testAction); + appManager.clearUpApplicationData(testTarget, onReceivedHandleCallback); + } + else{ + commonEvent.publish(publishEventName, onReceivedPublishCallBack); + } + + }, + onActive() { + console.info('ACTS_ProcessManage VendorAppA onActive'); + }, + onShow() { + console.info('ACTS_ProcessManage VendorAppA onShow'); + }, + onInactive() { + console.info('ACTS_ProcessManage VendorAppA onInactive'); + }, + onHide() { + console.info('ACTS_ProcessManage VendorAppA onHide'); + }, + onDestroy() { + console.info('ACTS_ProcessManage VendorAppA onDestroy'); + }, + onBackPress() { + console.info('ACTS_ProcessManage VendorAppA onBackPress'); + }, + onNewRequest() { + console.info('ACTS_ProcessManage VendorAppA onNewRequest'); + }, + onStartContinuation() { + console.info('ACTS_ProcessManage VendorAppA onStartContinuation'); + }, + onSaveData(value) { + console.info('ACTS_ProcessManage VendorAppA onSaveData:' + JSON.stringify(value)); + }, + onRestoreData(value) { + console.info('ACTS_ProcessManage VendorAppA onRestoreData:' + JSON.stringify(value)); + }, + onCompleteContinuation(code) { + console.info('ACTS_ProcessManage VendorAppA onCompleteContinuation:' + JSON.stringify(code)); + }, + onConfigurationUpdated(configuration) { + console.info('ACTS_ProcessManage VendorAppA onConfigurationUpdated:' + JSON.stringify(configuration)); + } +} diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/resources/base/element/string.json b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..fd60cdefa929070f1798c6e36f0502f1e1e219a4 --- /dev/null +++ b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "particlestartability" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/resources/base/media/icon.png b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amsprocessmanageapi7/pmvendorappa/src/main/js/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/BUILD.gn b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..25a9b80478ab8a52ee65201d7664943b37d3d66f --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/BUILD.gn @@ -0,0 +1,35 @@ +# Copyright (c) 2021 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_hap("ActslanguageconfigAppATest") { + hap_name = "ActslanguageconfigAppATest" + hap_profile = "./src/main/config.json" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/js/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/config.json b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..2c3e93c92637459c41f4be0798fb65c6b3bae4b1 --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/config.json @@ -0,0 +1,87 @@ +{ + "app": { + "bundleName": "com.example.actslanguageconfigappatest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actslanguageconfigappatest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actslanguageconfigappatest.MainAbility", + "visible": true, + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "reqPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/app.js b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..5d3012c7d6777f4b04710913de6f1aa718fa8cc9 --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/app.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 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. + */ +export default { + onCreate() { + console.info('ProcessManageSystemAppB onCreate'); + }, + onDestroy() { + console.info('ProcessManageSystemAppB onDestroy'); + }, + onShow() { + console.info('ProcessManageSystemAppB onShow'); + }, + onHide() { + console.info('ProcessManageSystemAppB onHide'); + } +}; diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/i18n/en-US.json b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/i18n/zh-CN.json b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/pages/index/index.css b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/pages/index/index.hml b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e91d102285d362b9d01077e065ed95986f0fb531 --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/default/pages/index/index.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2021 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 commonEvent from '@ohos.commonevent' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +function onReceivedPublishCallBack(){ + console.log("========Publish CallBack UpdateLanguageFinish========"); +} + + +export default { + data: { + title: "" + }, + onInit() { + console.info('ACTS_ProcessManage SystemAppB onInit'); + this.title = "ACTS_ProcessManage SystemAppB"; + }, + onReady() { + console.info('ACTS_ProcessManage SystemAppB onReady'); + commonEvent.publish('UpdateLanguageFinish',onReceivedPublishCallBack); + }, + onActive() { + console.info('ACTS_ProcessManage SystemAppB onActive'); + }, + onShow() { + console.info('ACTS_ProcessManage SystemAppB onShow'); + }, + + onDestroy() { + console.info('ACTS_ProcessManage SystemAppB onDestroy'); + }, + onConfigurationUpdated(config) { + console.log("Acts_LanguageConfigAppA onConfigurationUpdated called" + JSON.stringify(config)); + console.log("Acts_LanguageConfigAppA configuration:" + + JSON.stringify(globalThis.abilityContext.configuration)); + + }, + onCompleteContinuation(code) { + console.info('ACTS_ProcessManage SystemAppB onCompleteContinuation:' + JSON.stringify(code)); + }, + onConfigurationUpdated(configuration) { + console.info('ACTS_ProcessManage SystemAppB onConfigurationUpdated:' + JSON.stringify(configuration)); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/resources/base/element/string.json b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..fd60cdefa929070f1798c6e36f0502f1e1e219a4 --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "particlestartability" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/resources/base/media/icon.png b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/lanuageConfigapi7/ActslanguageconfigAppATest/src/main/js/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/BUILD.gn b/aafwk/aafwk_standard/lanuageConfigapi7/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a53cd4af2267fa3b0168b41e7235996cba09e800 --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/BUILD.gn @@ -0,0 +1,24 @@ +# Copyright (c) 2021 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") + +group("lanuageConfigapi7") { + testonly = true + if (is_standard_system) { + deps = [ + "ActslanguageconfigAppATest:ActslanguageconfigAppATest", + "LanguageConfigTestApi7:LanguageConfigTestApi7", + ] + } +} diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/BUILD.gn b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..624e5f61383e7dde82af2ba9be53e958e2aafc9c --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2021 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("LanguageConfigTestApi7") { + hap_name = "LanguageConfigTestApi7" + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/Test.json b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..8a59d111e65dda5a65a836160e5a3a70b1e8fb03 --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/Test.json @@ -0,0 +1,38 @@ + +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.languageconfigtestapi7", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "LanguageConfigTestApi7.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test" + ] + }, + { + "type": "PushKit", + "push": [ + "ActslanguageconfigAppATest.hap->/data/test/ActslanguageconfigAppATest.hap"] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 777 /data/test/*.hap" + ] + } + ] +} + diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/config.json b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..8e9b5b2a5a2fef425fe191a4bb191db69249c5f7 --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/config.json @@ -0,0 +1,87 @@ +{ + "app": { + "bundleName": "com.example.languageconfigtestapi7", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.languageconfigtestapi7", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.languageconfigtestapi7.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "singleton", + "visible": true + } + ], + "reqPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/app.js b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..042038cfc6360ed972035a85e944904021ffb1d6 --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/app.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 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. + */ +export default { + onCreate() { + console.info('ActsProcessManageJsTest onCreate'); + }, + onDestroy() { + console.info('ActsProcessManageJsTest onDestroy'); + }, + onShow() { + console.info('ActsProcessManageJsTest onShow'); + }, + onHide() { + console.info('ActsProcessManageJsTest onHide'); + } +}; diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/i18n/en-US.json b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/i18n/zh-CN.json b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/pages/index/index.css b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..18463feca0a77306fe28b9bcecdfe733ac5b3418 --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 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. + */ + .container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} + +.btn { + width: 200px; + height: 80px; +} diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/pages/index/index.hml b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..5b17eddbc838bd39d96337c68ddb86c3383d804e --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2021 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. + */ +
+ + {{ $t('strings.hello') }} {{ title }} + + +
diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..ee3a7077b7d52935d3f70b5cb70e38ea9d0e33f1 --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2021 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 { Core, ExpectExtend } from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "", + testTime: 0 + }, + onInit() { + console.info('ActsProcessManageJsTest onInit'); + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('ActsProcessManageJsTest onShow'); + console.info('ActsProcessManageJsTest testTime' + this.testTime); + if (this.testTime == 0) { + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + const configService = core.getDefaultService('config') + this.timeout = 30000; + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + } + this.testTime++; + }, + onReady() { + console.info('ActsProcessManageJsTest onReady'); + }, + onActive() { + console.info('ActsProcessManageJsTest onActive'); + }, + onInactive() { + console.info('ActsProcessManageJsTest onInactive'); + }, + onHide() { + console.info('ActsProcessManageJsTest onHide'); + }, + onDestroy() { + console.info('ActsProcessManageJsTest onDestroy'); + }, + onBackPress() { + console.info('ActsProcessManageJsTest onBackPress'); + }, + onNewRequest() { + console.info('ActsProcessManageJsTest onNewRequest'); + }, + onStartContinuation() { + console.info('ActsProcessManageJsTest onStartContinuation'); + }, + onSaveData(value) { + console.info('ActsProcessManageJsTest onSaveData:' + JSON.stringify(value)); + }, + onRestoreData(value) { + console.info('ActsProcessManageJsTest onRestoreData:' + JSON.stringify(value)); + }, + onCompleteContinuation(code) { + console.info('ActsProcessManageJsTest onCompleteContinuation:' + JSON.stringify(code)); + }, + onConfigurationUpdated(configuration) { + console.info('ActsProcessManageJsTest onConfigurationUpdated:' + JSON.stringify(configuration)); + } +} diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/resources/base/element/string.json b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03574a36c533357eef7fc0acc5e21af14f4e5f67 --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "actsparticleabilitytest" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/resources/base/media/icon.png b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/test/List.test.js b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..3fe0750522ac92a3e9feb711aeaeee21ffd18b48 --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2021 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. + */ +require('./lanuageConfigapi7.test.js') \ No newline at end of file diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/test/lanuageConfigapi7.test.js b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/test/lanuageConfigapi7.test.js new file mode 100644 index 0000000000000000000000000000000000000000..6a6de95cbdfb28b3fc34e469139d546441041831 --- /dev/null +++ b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/entry/src/main/js/test/lanuageConfigapi7.test.js @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import commonEvent from '@ohos.commonevent' +import bundle from '@ohos.bundle' +import missionManager from '@ohos.application.missionManager' +import abilityManager from '@ohos.application.abilityManager' +import featureAbility from '@ohos.ability.featureability' + +var subscriberInfoMultiInstance = { + events: ["UpdateLanguageFinish"] +}; +const BUNDLE_PATHS = [['/data/test/ActslanguageconfigAppATest.hap']]; +const BUNDLE_NAMES = ['com.example.actslanguageconfigappatest']; +const BUNDLE_COUNT = 1; +const START_ABILITY_TIMEOUT = 5000; +const MAX_MISSION_NUM = 1024; + +async function startAbilityProcess(parameters) { + let bundleName; + let abilityName; + + let idx = parameters.nextStep; + switch (parameters.step[idx]) { + case "StartA1": + bundleName = "com.example.actslanguageconfigappatest"; + abilityName = "com.example.actslanguageconfigappatest.MainAbility"; + break; + + default: + break; + } + parameters.nextStep = ++idx; + await featureAbility.startAbility({ + want: { + bundleName: bundleName, + abilityName: abilityName, + parameters: parameters + } + + }) +} + + +function getMissionId() { + return new Promise(async (resolve, reject) => { + var missionId = -1; + var missionInfos = await missionManager.getMissionInfos('', MAX_MISSION_NUM); + for (let i = 0; i < missionInfos.length; i++) { + console.log('getMissionId result: ' + i + '= ' + JSON.stringify(missionInfos[i])) + if ((missionInfos[i].want.abilityName == "com.example.languageconfigtestapi7.MainAbility") && + (missionInfos[i].runningState == 0)) { + missionId = missionInfos[i].missionId; + break; + } + } + console.log('======>Acts_getMissionId resolve missionId<=======' + missionId); + resolve(missionId); + }) +} + +describe('ActsAbilityTest', function () { + beforeEach(async (done) => { + console.log('======>Acts_beforeEach ininin<======='); + let installer = await bundle.getBundleInstaller(); + var count = 0; + + for (let i = 0; i < BUNDLE_COUNT; i++) { + installer.install(BUNDLE_PATHS[i], { + userId: 100, + installFlag: 1, + isKeepData: false + }, (err, data) => { + count++; + console.log('======>Acts_beforeEach install finish <=======' + err.code); + console.log('======>Acts_beforeEach install finish <=======' + data.status); + console.log('======>Acts_beforeEach install finish <=======' + data.statusMessage); + if (count == BUNDLE_COUNT) { + setTimeout(() => { + done(); + }, 1000) + } + }) + } + }) + + /* + * @tc.number: Acts_UpdateConfigurationFA_0100 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('Acts_UpdateConfigurationFA_0100', 0, async function (done) { + console.log('Acts_UpdateConfigurationFA_0100====Acts_Subscribe CallBack data:====>" + JSON.stringify(data)); + + expect(data.event).assertEqual("UpdateLanguageFinish"); + clearTimeout(id); + console.log('Acts_UpdateConfigurationFA_0100 start set lang'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("Acts_====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + + setTimeout( function () { + console.debug("Acts_====>UnSubscribe CallBack====>"); + done(); + }, 2000); + + } + + function timeout() { + expect().assertFail(); + console.log('Acts_StartLanguageConfigTester timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Acts_Start LanguageConfigTester Acts_UpdateConfigurationFA_0100 timer id : ' + id); + + console.log('Acts_LanguageConfigTester Acts_UpdateConfigurationFA_0100 start Ability'); + startAbilityProcess({ + startId: 0, + stepNum: 1, + nextStep: 0, + step: ["StartA1"] + }); + }) + + +}) diff --git a/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/lanuageConfigapi7/LanguageConfigTestApi7/signature/openharmony_sx.p7b differ diff --git a/ace/ace_ets_component/entry/src/main/config.json b/ace/ace_ets_component/entry/src/main/config.json index 4878724bd5455603505d9149f1c5016ef618eb11..dc5e271720ed24c3679bf173c93189f943dbfb50 100755 --- a/ace/ace_ets_component/entry/src/main/config.json +++ b/ace/ace_ets_component/entry/src/main/config.json @@ -59,6 +59,7 @@ }, "pages": [ "pages/index", + "pages/toggle", "pages/actionSheet", "pages/gauge", "pages/ellipse", @@ -66,7 +67,6 @@ "pages/systemRouterB", "pages/marquee", "pages/stepper", - "pages/gridContainer", "pages/list", "pages/general-properties/sizeSetting", "pages/general-properties/positionSetting", @@ -94,6 +94,7 @@ "pages/general-properties/flex", "pages/swiper", "pages/gridPage", + "pages/span", "pages/text", "pages/badge", "pages/canvas", @@ -110,7 +111,49 @@ "pages/tabs", "pages/tapGesture", "pages/progress", - "pages/animate" + "pages/animate", + "pages/column", + "pages/rating", + "pages/canvas2", + "pages/shape", + "pages/motionPath", + "pages/scrollCode", + "pages/transition", + "pages/priorityGesture", + "pages/parallelGesture", + "pages/alertDialog", + "pages/blank", + "pages/sharedTransition", + "pages/sharedTransition2", + "pages/alphabetIndexer", + "pages/line", + "pages/circle", + "pages/aboutToDisappear", + "pages/timeStamp", + "pages/bindMenu", + "pages/bindPopup", + "pages/gridContainer", + "pages/direction", + "pages/divider", + "pages/listItem", + "pages/systemPrompt", + "pages/configuration", + "pages/sourceType", + "pages/NavigatorBackCode", + "pages/NavigatorCode", + "pages/NavigatorDetailCode", + "pages/PieceCode", + "pages/sourceType", + "pages/pageTransition", + "pages/pageTransition2", + "pages/scrollBar", + "pages/search", + "pages/pageTransition2", + "pages/lifecycle", + "pages/pageTransition2", + "pages/navigation", + "pages/stateStyle", + "pages/focus" ], "name": ".MainAbility", "window": { diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/NavigatorBackCode.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/NavigatorBackCode.ets new file mode 100755 index 0000000000000000000000000000000000000000..d7f919aab16c828ac3e34739966660d952cdee8d --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/NavigatorBackCode.ets @@ -0,0 +1,27 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct NavigatorBackCode { + build() { + Column() { + Navigator({ target: 'pages/NavigatorCode', type: NavigationType.Back }) { + Text('Return to Navigator Page').width('100%').textAlign(TextAlign.Center) + } + }.width('100%').height(200).padding({ left: 35, right: 35, top: 35 }) + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/NavigatorCode.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/NavigatorCode.ets new file mode 100755 index 0000000000000000000000000000000000000000..c5ea4fbe4ec02b71a035b9719f5c8b9a1afa8881 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/NavigatorCode.ets @@ -0,0 +1,69 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter'; + +@Entry +@Component +struct NavigatorCode { + @State active: boolean = false; + @State Text: string = 'news'; + @State typeValue: NavigationType = NavigationType.Back; + private stateChangCallBack = (eventData) => { + if (eventData != null) { + var navigationTypeValue = eventData.data.typeValue; + console.info("navigationTypeValue:" + navigationTypeValue); + if (navigationTypeValue != null) { + this.typeValue = navigationTypeValue; + console.info("this.typeValue:" + this.typeValue); + } else { + console.info("navigationTypeValue is null or empty " + NavigatorCode); + } + } else { + console.info("NavigatorCode page color not change called:" + JSON.stringify(eventData)); + } + } + + onPageShow() { + console.info('navigatorCode page show called'); + var stateChangeEvent = { + eventId: 90, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + + var stateChangeEvent = { + eventId: 101, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack) + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { + Navigator({ target: 'pages/NavigatorDetailCode', type: NavigationType.Push }) { + Text('Go to ' + this.Text + ' page').width('100%').textAlign(TextAlign.Center) + }.params({ text: this.Text }).key('button') + + Navigator() { + Text('Back to previous page').width('100%').textAlign(TextAlign.Center) + }.active(this.active) + .onClick(() => { + this.active = true + }) + }.height(150).width(350).padding(35) + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/NavigatorDetailCode.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/NavigatorDetailCode.ets new file mode 100755 index 0000000000000000000000000000000000000000..013b1f4fe4ab8ae7b1fd5b59c596113698523c4a --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/NavigatorDetailCode.ets @@ -0,0 +1,34 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct NavigatorDetailCode { + @State text: string = router.getParams().text + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { + Navigator({ target: 'pages/NavigatorBackCode', type: NavigationType.Push }) { + Text('Go to back page').width('100%').height(20) + } + + Text('This is ' + this.text + ' page').width('100%').textAlign(TextAlign.Center) + } + .width('100%').height(200).padding({ left: 35, right: 35, top: 35 }) + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/PieceCode.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/PieceCode.ets new file mode 100755 index 0000000000000000000000000000000000000000..d81f866408ca1d08cf61b014b69c8caa27ef7e71 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/PieceCode.ets @@ -0,0 +1,37 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter'; + +@Entry +@Component +struct PieceCode { + @State fontColor: Color = "#FF008000"; + + onPageShow() { + } + + build() { + Column() { + Piece({ content: "piece" , icon: "1" }) + .iconPosition(IconPosition.End) + .fontColor(this.Color) + .fontStyle(FontStyle.Italic) + .key("piece") + }.width('100%').margin({ top: 300 }) + .height('100%') + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/aboutToDisappear.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/aboutToDisappear.ets new file mode 100755 index 0000000000000000000000000000000000000000..f31e5203b873dc73d5fc01dee05591cfaa29bd93 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/aboutToDisappear.ets @@ -0,0 +1,80 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct ParentComp { + @State isCountDown: boolean = true + build() { + Column() { + Text(this.isCountDown ? 'Count Down' : 'Stopwatch') + if (this.isCountDown) { + Image($rawfile('ic_health_heart.png')).width(50).height(50) + TimerComponent({counter: 10, changePerSec: -1, showInColor: Color.Red}) + } else { + Image($rawfile('ic_health_heart.png')).width(150).height(150) + TimerComponent({counter: 0, changePerSec: +1, showInColor: Color.Black }) + } + Button(this.isCountDown ? 'Swtich to Stopwatch' : 'Switch to Count Down') + .onClick(() => { + this.isCountDown = !this.isCountDown + }) + .key('button1') + } + } +} + +@Component +struct TimerComponent { + @State counter: number = 0 + private changePerSec: number = -1 + private showInColor: Color = Color.Black + private timerId : number = -1 + @State onActionCalled :boolean = false + + build() { + Text(`${this.counter}sec`) + .fontColor(this.showInColor) + } + + aboutToAppear() { + this.timerId = setInterval(() => {this.counter += this.changePerSec}, 1000) + } + + aboutToDisappear() { + if (this.timerId > 0) { + clearTimeout(this.timerId) + console.info('ting--1'); + try { + var backData = { + data: { + "ACTION": this.onActionCalled, + } + } + var backEvent = { + eventId: 160, + priority: events_emitter.EventPriority.LOW + } + console.info("button1 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button1 emit action state err: " + JSON.stringify(err.message)) + } + this.timerId = -1 + } + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/alertDialog.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/alertDialog.ets new file mode 100755 index 0000000000000000000000000000000000000000..0d0cfc240010f38d605247dc712351c1550d0471 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/alertDialog.ets @@ -0,0 +1,66 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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. + */ +@Entry +@Component +struct AlertDialogExample { + build() { + Column({ space: 5 }) { + Button('one button dialog') + .onClick(() => { + AlertDialog.show( + { + title: 'title', + message: 'text', + confirm: { + value: 'button', + action: () => { + console.info('Button-clicking callback') + } + }, + cancel: () => { + console.info('Closed callbacks') + } + } + ) + }) + .backgroundColor(0x317aff) + Button('two button dialog') + .onClick(() => { + AlertDialog.show( + { + title: 'title', + message: 'text', + primaryButton: { + value: 'cancel', + action: () => { + console.info('Callback when the first button is clicked') + } + }, + secondaryButton: { + value: 'ok', + action: () => { + console.info('Callback when the second button is clicked') + } + }, + cancel: () => { + console.info('Closed callbacks') + } + } + ) + }).backgroundColor(0x317aff) + }.width('100%').margin({ top: 5 }) + } +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/alphabetIndexer.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/alphabetIndexer.ets new file mode 100755 index 0000000000000000000000000000000000000000..3ea261f9be96a17bef12e9eefa3b1342c75fff38 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/alphabetIndexer.ets @@ -0,0 +1,67 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter'; +@Entry +@Component +struct AlphabetIndexerSample { + private value: string[] = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', + 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; + @State color: Color = Color.Red; + @State fontSize: string = 20; + @State fontWeight: FontWeight = FontWeight.Bolder; + @State fontFamily: string = 'sans-serif'; + @State fontStyle: FontStyle = FontStyle.Italic; + + build() { + AlphabetIndexer({ arrayValue: this.value, selected: 0 }) + .selectedColor(0xffffff) + .popupColor(0xFFFAF0) + .selectedBackgroundColor(0xCCCCCC) + .popupBackground(0xD2B48C) + .usingPopup(true) + .selectedFont({ size: 16, weight: FontWeight.Bolder }) + .popupFont({ size: 30, weight: FontWeight.Bolder }) + .itemSize(28) + .alignStyle(IndexerAlign.Left) + .onSelected((index: number) => { + console.info(this.value[index] + '被选中了'); + }) + .margin({ left: 50 }) + .font({size: this.fontSize, weight: this.fontWeight, family: this.fontFamily, style: this.fontStyle }) + .color(this.color) + .key('alphabetIndexer') + } + onPageShow() { + console.info('alphabetIndexer page show called'); + var stateChangeEvent = { + eventId: 71, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + } + private stateChangCallBack = (eventData) => { + if (eventData != null) { + console.info("alphabetIndexer page state change called:" + JSON.stringify(eventData)); + let font = JSON.parse(eventData.data.font); + if(font) { + this.fontSize = font.size; + this.fontWeight = font.weight; + this.fontFamily = font.family; + this.fontStyle = font.style; + } + } + } +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/badge.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/badge.ets index 3cdb575b2d8d586acc7597199167ef5116925378..f31804155647dc2492686f610b1cf630b3e7eb14 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/badge.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/badge.ets @@ -18,16 +18,23 @@ import events_emitter from '@ohos.emitter'; @Entry @Component struct BadgeExample { - @State counts: number = 1 - @State message: string = 'new' + @State counts: number = 1; + @State message: string = 'new'; @State fontSizeValue: number = 20; + @State colorValue: Color = Color.Red; private stateChangCallBack = (eventData) => { if (eventData != null) { console.info("Badge page state change called:" + JSON.stringify(eventData)); - if(eventData.data.fontSizeValue != null) { + if (eventData.data.fontSizeValue != null) { this.fontSizeValue = eventData.data.fontSizeValue; } + if (eventData.data.colorValue != null) { + this.colorValue = eventData.data.colorValue; + } + if (eventData.data.message != null) { + this.message = eventData.data.message; + } } } @@ -45,7 +52,7 @@ struct BadgeExample { Badge({ count: this.counts, maxCount: 99, - style: { color: 0xFFFFFF, fontSize: this.fontSizeValue, badgeSize: 50, badgeColor: Color.Red } + style: { color: this.colorValue, fontSize: this.fontSizeValue, badgeSize: 50, badgeColor: Color.Red } }) { Button('message') .onClick(() => { @@ -53,6 +60,26 @@ struct BadgeExample { }) .width(200).height(100).backgroundColor(0x317aff).fontSize(20) }.width(100).height(50).key('badge') + + Badge({ + value: this.message, + style: { color: this.colorValue, fontSize: 9, badgeSize: 20, badgeColor: Color.Red } + }) { + Text('message') + .width(80).height(50).fontSize(16).lineHeight(37) + .borderRadius(10).textAlign(TextAlign.Center).backgroundColor(0xF3F4ED) + }.width(80).height(50).key('badge2') + + Badge({ + value: '', + position: 1, + style: { badgeSize: 6, badgeColor: Color.Red } + }) { + Text('message') + .width(90).height(50).fontSize(16).lineHeight(37) + .borderRadius(10).textAlign(TextAlign.Center).backgroundColor(0xF3F4ED) + }.width(90).height(50) + }.width('100%').margin({ top: 5 }) } } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/bindMenu.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/bindMenu.ets new file mode 100755 index 0000000000000000000000000000000000000000..3ce33b16bcd2193f38bcb614c7894d597c924757 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/bindMenu.ets @@ -0,0 +1,71 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct MenuExample { + @State onActionCalled: boolean = true + @Builder MenuBuilder() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Text('text1') + .fontSize(20) + .width(100) + .height(50) + .textAlign(TextAlign.Center) + Divider().height(10) + Text('text2') + .fontSize(20) + .width(100) + .height(50) + .textAlign(TextAlign.Center) + Divider().height(10) + Button('button') + .key('button') + .fontSize(20) + .width(100) + .height(50) + .onClick(() => { + console.info("bindMenu button START") + try { + var backData = { + data: { + "ACTION": this.onActionCalled, + } + } + var backEvent = { + eventId: 123, + priority: events_emitter.EventPriority.LOW + } + console.info("bindMenuTest_0100 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("bindMenuTest_0100 emit action state err: " + JSON.stringify(err.message)) + } + }) + }.width(100) + } + + build() { + Column() { + Text('click for menu') + .key('text') + } + .width('100%') + .margin({ top: 5 }) + .bindMenu(this.MenuBuilder) + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/bindPopup.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/bindPopup.ets new file mode 100755 index 0000000000000000000000000000000000000000..be2fc5fee5906e7c6e765d641c63a4a8c943151e --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/bindPopup.ets @@ -0,0 +1,148 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct PopupExample { + @State noHandlePopup: boolean = false + @State handlePopup: boolean = false + @State customPopup: boolean = false + @State maskColor: string = 0x33000000 + @State enableArrow: boolean = true + @State placementOnTop: boolean = false + + @Builder popupBuilder() { + Row({ space: 2 }) { + Image($rawfile('ic_health_heart.png')).width(24).height(24).margin({ left: -5 }).key('image') + Text('Custom Popup').fontSize(12).key('text') + }.width(100).height(50).backgroundColor(Color.White) + } + + build() { + Flex({ direction: FlexDirection.Column }) { + Button('no handle popup') + .key('button2') + .onClick(() => { + this.noHandlePopup = !this.noHandlePopup + try { + var backData = { + data: { + "placementOnTop": this.placementOnTop, + } + } + var backEvent = { + eventId: 238, + priority: events_emitter.EventPriority.LOW + } + console.info("button2 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button2 emit action state err: " + JSON.stringify(err.message)) + } + }) + .bindPopup(this.noHandlePopup, { + message: 'content1 content1', + placementOnTop: this.placementOnTop, + onStateChange: (e) => { + console.info(e.isVisible.toString()) + if (!e.isVisible) { + this.noHandlePopup = false + } + } + }) + .position({ x: 100, y: 50 }) + + Button('custom popup 1') + .key('button1') + .onClick(() => { + try { + var backData = { + data: { + "maskColor": this.maskColor, + "enableArrow": this.enableArrow + } + } + var backEvent = { + eventId: 237, + priority: events_emitter.EventPriority.LOW + } + console.info("button1 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button1 emit action state err: " + JSON.stringify(err.message)) + } + }) + .position({ x: 100, y: 200 }) + + Button('custom popup') + .key('button') + .onClick(() => { + this.customPopup = !this.customPopup + try { + var backData = { + data: { + "maskColor": this.maskColor, + "enableArrow": this.enableArrow + } + } + var backEvent = { + eventId: 236, + priority: events_emitter.EventPriority.LOW + } + console.info("button start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button emit action state err: " + JSON.stringify(err.message)) + } + }) + .bindPopup(this.customPopup, { + builder: this.popupBuilder, + placement: Placement.Bottom, + maskColor: this.maskColor, + popupColor: Color.White, + enableArrow: this.enableArrow, + onStateChange: (e) => { + if (!e.isVisible) { + this.customPopup = false + } + } + }) + .position({ x: 100, y: 350 }) + }.width('100%').padding({ top: 5 }) + } + + onPageShow() { + console.info('customPopupOption page show called'); + var stateChangeEvent = { + eventId: 126, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack) + } + + private stateChangCallBack = (eventData) => { + if (eventData != null) { + console.info("customPopupOption page state change called:" + JSON.stringify(eventData)); + if (eventData.data.enableArrow != null) { + this.enableArrow = eventData.data.enableArrow; + } + if (eventData.data.maskColor != null) { + this.maskColor = eventData.data.maskColor; + } + } + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/blank.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/blank.ets new file mode 100755 index 0000000000000000000000000000000000000000..387be78fa07140e635c94d6c32c501802cc59d01 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/blank.ets @@ -0,0 +1,50 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter'; + +@Entry +@Component +struct BlankExample { + @State colorValue: Color = Color.Blue; + + private stateChangCallBack = (eventData) => { + if (eventData != null) { + console.info("Blank page state change called:" + JSON.stringify(eventData)); + if (eventData.data.colorValue != null) { + this.colorValue = eventData.data.colorValue; + } + } + } + + onPageShow() { + console.info('Blank page show called'); + var stateChangeEvent = { + eventId: 90, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + } + + build() { + Column() { + Row() { + Text('Bluetooth').fontSize(18) + Blank().color(this.colorValue).key('blank') + Toggle({ type: ToggleType.Switch }) + }.width('100%').backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 }) + }.backgroundColor(0xEFEFEF).padding(20) + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/canvas.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/canvas.ets index f19739b63aebec767d8488758b7928b834a3c4bf..1a8039df3b1a89ea3c9f93a1f7d3af7601f1c22e 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/canvas.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/canvas.ets @@ -81,6 +81,7 @@ struct CanvasExample { this.fill(); this.textMetrics(); this.getBitImageSize(); + this.rotate(); }) .key('canvas1') }.width('100%').height('350%') @@ -319,7 +320,8 @@ struct CanvasExample { } rotate() { this.context.rotate(45 * Math.PI / 180); - this.context.fillRect(70, 20, 50, 50); + this.context.fillRect(180, 20, 50, 50); + this.context.rotate(-45 * Math.PI / 180); } transform() { this.context.fillStyle = 'rgb(0,0,0)'; diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/canvas3.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/canvas3.ets deleted file mode 100755 index cd17f181004621ff1aa4b1433767d0951e97c311..0000000000000000000000000000000000000000 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/canvas3.ets +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' - -@Entry -@Component -struct Canvas3Example { - private settings: RenderingContextSettings = new RenderingContextSettings(true); - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); - - build() { - Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Start }) { - Column() { - Canvas(this.context) - .width('100%') - .height('100%') - .backgroundColor('#ffff00') - .onReady(() => { - this.rotate(); - }) - .key('canvas3') - }.width('100%').height('100%') - } - .width('100%') - .height('100%') - } - onPageShow() { - } - rotate() { - this.context.rotate(45 * Math.PI / 180); - this.context.fillRect(200, 20, 100, 100); - } -} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/circle.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/circle.ets new file mode 100755 index 0000000000000000000000000000000000000000..418fc3c6f15ab00ccdb8ff16b2df78590b315878 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/circle.ets @@ -0,0 +1,52 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter'; +@Entry +@Component +struct CircleExample { + @State width: string = "450px"; + @State height: string = "450px"; + onPageShow() { + console.info('[circle] page show called'); + var stateChangeEvent = { + eventId: 455, + priority: events_emitter.EventPriority.LOW + } + console.info('[circle] page show calledA'); + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + } + private stateChangCallBack = (eventData) => { + console.info("[circle] page stateChangCallBack"); + if (eventData != null) { + console.info("[circle] page state change called:" + JSON.stringify(eventData)); + if(eventData.data.width != null) { + this.width = eventData.data.width; + } + if(eventData.data.height != null) { + this.height = eventData.data.height; + } + } + } + build() { + Flex({ justifyContent: FlexAlign.SpaceAround }) { + Circle({ width: 150, height: 150 }) + Circle() + .width(`${this.width}`) + .height(`${this.height}`) + .key('circle') + }.width('100%').height('100%').margin({ top: 5 }) + } +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/configuration.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/configuration.ets new file mode 100755 index 0000000000000000000000000000000000000000..c34f4b9600740a2e55c731714d4ec78e884f7b66 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/configuration.ets @@ -0,0 +1,52 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 Configuration from '@system.configuration'; +import events_emitter from '@ohos.emitter'; +@Entry +@Component +struct promptExample { + build(){ + Column(){ + Button('click') + .key('button') + .backgroundColor('#FF0B8FE2') + .fontSize(20) + .margin({top: 20}) + .onClick(()=>{ + console.info('button is start'); + let localeInfo = Configuration.getLocale(); + console.info('localeInfo result is' + JSON.stringify(localeInfo)); + try{ + var backData = { + data: { + "COUNTRY": localeInfo.countryOrRegion, + "DIR":localeInfo.dir + } + } + console.log("backData is" + JSON.stringify(backData.data)); + var backEvent = { + eventId: 36, + priority: events_emitter.EventPriority.LOW + } + console.info("confituration start to emit action state"); + events_emitter.emit(backEvent, backData); + }catch{ + console.info("confituration emit action state err: " + JSON.stringify(err.message)); + } + }) + } + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/direction.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/direction.ets new file mode 100755 index 0000000000000000000000000000000000000000..0511f6585555230106e2990a1c34f6bd0f0fcb0e --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/direction.ets @@ -0,0 +1,55 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter'; + +@Entry +@Component +struct Index { + @State direction:FlexDirection = FlexDirection.Column + build() { + Flex({ direction: this.direction, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(60) + .fontWeight(500) + Button('Next') + .fontSize(40) + .fontWeight(500) + .width(280) + .height(60) + } + .key('direction') + .width('100%') + .height('100%') + } + + onPageShow() { + console.info('direction page show called'); + var stateChangeEvent = { + eventId: 985, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack) + } + + private stateChangCallBack = (eventData) => { + if (eventData != null) { + console.info("direction page state change called:" + JSON.stringify(eventData)); + if (eventData.data.direction != null) { + this.direction = eventData.data.direction; + } + } + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/divider.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/divider.ets new file mode 100755 index 0000000000000000000000000000000000000000..9478afdcfa8bcdf456f4c2604a932714d8cd8508 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/divider.ets @@ -0,0 +1,67 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter'; +@Entry +@Component +struct DividerExample { + @State color: Color = 0xCCCCCC + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { + Text('Horizontal divider').fontSize(9).fontColor(0xCCCCCC) + Row().width('100%').height(40).backgroundColor(0xF1F3F5) + Divider() + Row().width('100%').height(40).backgroundColor(0xF1F3F5) + + Text('Vertical divider').fontSize(9).fontColor(0xCCCCCC) + Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.Wrap }) { + Text('bravery') + Divider().vertical(true).margin(20).height(15) + Text('effort') + Divider().vertical(true).margin(20).height(15) + Text('upward') + }.width(250) + + Text('Custom Styles').fontSize(9).fontColor(0xCCCCCC) + Row().width('100%').height(40).backgroundColor(0xF1F3F5) + Divider() + .key('Divider') + .vertical(false) + .strokeWidth(5) + .color(this.color) + .lineCap(LineCapStyle.Round) + Row().width('100%').height(40).backgroundColor(0xF1F3F5) + } + .width('100%').height(350).padding({ left: 35, right: 35, top: 35 }) + } + + onPageShow() { + console.info('divider page show called'); + var stateChangeEvent = { + eventId: 917, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack) + } + + private stateChangCallBack = (eventData) => { + if (eventData != null) { + console.info("divider page state change called:" + JSON.stringify(eventData)); + if (eventData.data.color != null) { + this.color = eventData.data.color; + } + } + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/focus.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/focus.ets new file mode 100755 index 0000000000000000000000000000000000000000..1af4c04f9cfd1febb9546f6a14861e0727982f61 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/focus.ets @@ -0,0 +1,67 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct FocusableExample { + @State textOne: string = '' + @State textTwo: string = '' + @State textThree: string = 'The third button cannot be focused' + @State oneButtonColor: string = '#FF0000' + @State twoButtonColor: string = '#FFC0CB' + @State threeButtonColor: string = '#87CEFA' + + build() { + Column({ space:20 }){ + Button(this.textOne) + .backgroundColor(this.oneButtonColor) + .width(300).height(70).fontColor(Color.Black) + .focusable(true) + .onFocus(() => { + this.textOne = 'First Button onFocus' + this.oneButtonColor = '#AFEEEE' + }) + .onBlur(() => { + this.textOne = 'First Button onBlur' + this.oneButtonColor = '#FFC0CB' + }) + Button(this.textTwo) + .backgroundColor(this.twoButtonColor) + .width(300).height(70).fontColor(Color.Black) + .focusable(true) + .onFocus(() => { + this.textTwo = 'Second Button onFocus' + this.twoButtonColor = '#AFEEEE' + }) + .onBlur(() => { + this.textTwo = 'Second Button onBlur' + this.twoButtonColor = '#FFC0CB' + }) + Button(this.textThree) + .backgroundColor(this.threeButtonColor) + .width(300).height(70).fontColor(Color.Black) + .focusable(false) + .onFocus(() => { + this.textThree = 'Third Button onFocus' + this.threeButtonColor = '#AFEEEE' + }) + .onBlur(() => { + this.textThree = 'Third Button onBlur' + this.threeButtonColor = '#FFC0CB' + }) + }.width('100%').margin({ top:20 }) + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/general-properties/flex.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/general-properties/flex.ets index d23fefc9f2e4403654b894e5e49a543f372093cd..a003153a0da4c27904465834eab0cd20695f64de 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/general-properties/flex.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/general-properties/flex.ets @@ -18,7 +18,7 @@ import events_emitter from '@ohos.emitter' @Entry @Component struct FlexExample { - + @State direction: FlexDirection = FlexDirection.Row private stateChangCallBack = (eventData) => { if (eventData != null) { console.info("Flex page state change called:" + JSON.stringify(eventData)); @@ -117,7 +117,7 @@ struct FlexExample { .backgroundColor(0xD2B48C).textAlign(TextAlign.Center) Text('no alignSelf,height:100').width('34%').height(100) .backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) - }.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) + }.key('flex').width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) }.width('100%').margin({ top: 5 }) } } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/gridContainer.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/gridContainer.ets index 246648a0a186388880b77725dbba6b250649fd71..7d9ff8456fd8f5959886d0e317ee5cad157184b0 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/gridContainer.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/gridContainer.ets @@ -98,6 +98,7 @@ struct GridContainerExample { md: { span: 2, offset: 10 }, lg: { span: 6, offset: 6 } }) + .height(50) .backgroundColor(0x00BFFF) .textAlign(TextAlign.Center) diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/lifecycle.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/lifecycle.ets new file mode 100755 index 0000000000000000000000000000000000000000..8d8f1ea1e5fce57dceb5fa620ff3e280e29ece18 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/lifecycle.ets @@ -0,0 +1,134 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter'; + +@Entry +@Component +struct EllipseExample { + + onActive(){ + console.log("lifecycle-->onActive") + } + onInactive(){ + console.log("lifecycle-->onInactive") + } + onShow(){ + console.log("lifecycle-->onShow") + } + onCastTempToNormal(){ + console.log("lifecycle-->onCastTempToNormal") + } + onVisibilityChanged(){ + console.log("lifecycle-->onVisibilityChanged") + } + onTriggerEvent(){ + console.log("lifecycle-->onTriggerEvent") + } + onDelete(){ + console.log("lifecycle-->onDelete") + } + onAcquireFormState(){ + console.log("lifecycle-->onAcquireFormState") + } + onHide(){ + console.log("lifecycle-->onHide") + } + onWindowDisplayModeChanged(){ + console.log("lifecycle-->onWindowDisplayModeChanged") + } + onStartContinuation(){ + console.log("lifecycle-->onStartContinuation") + } + onSaveData(){ + console.log("lifecycle-->onSaveData") + } + onCompleteContinuation(){ + console.log("lifecycle-->onCompleteContinuation") + } + onRestoreData(){ + console.log("lifecycle-->onRestoreData") + } + onRemoteTerminated(){ + console.log("lifecycle-->onRemoteTerminated") + } + onSaveAbilityState(){ + console.log("lifecycle-->onSaveAbilityState") + } + onRestoreAbilityState(){ + console.log("lifecycle-->onRestoreAbilityState") + } + onInactive(){ + console.log("lifecycle-->onInactive") + } + onActive(){ + console.log("lifecycle-->onActive") + } + onNewWant(){ + console.log("lifecycle-->onNewWant") + } + onMemoryLevel(){ + console.log("lifecycle-->onMemoryLevel") + } + onCommand(){ + console.log("lifecycle-->onCommand") + } + onStop(){ + console.log("lifecycle-->onStop") + } + onConnect(){ + console.log("lifecycle-->onConnect") + } + onDisconnect(){ + console.log("lifecycle-->onDisconnect") + } + onReconnect(){ + console.log("lifecycle-->onReconnect") + } + update(){ + console.log("lifecycle-->update") + } + normalizeUri(){ + console.log("lifecycle-->normalizeUri") + } + batchInsert(){ + console.log("lifecycle-->batchInsert") + } + denormalizeUri(){ + console.log("lifecycle-->denormalizeUri") + } + openFile(){ + console.log("lifecycle-->openFile") + } + getFileTypes(){ + console.log("lifecycle-->getFileTypes") + } + onInitialized(){ + console.log("lifecycle-->onInitialized") + } + getType(){ + console.log("lifecycle-->getType") + } + + build(){ + Column(){ + Button('click') + .key('button') + .backgroundColor('#FF0B8FE2') + .fontSize(20) + .margin({top: 20}) + } + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/line.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/line.ets new file mode 100755 index 0000000000000000000000000000000000000000..0c6a52fb59e298d21a8b6183073ec445b786b3f8 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/line.ets @@ -0,0 +1,56 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct LineExample { + @State startPoint:Point = [0,0] + @State endPoint:Point = [50,100] + build() { + Column() { + Line({ width: 50, height: 100 }).startPoint(this.startPoint).endPoint(this.endPoint) + .key('line') + }.margin({ top: 5 }) + } + + private stateChangCallBack = (eventData) => { + if (eventData != null) { + console.info("line page state change called:" + JSON.stringify(eventData)); + if (eventData.data.startPoint != null) { + this.startPoint[0] = eventData.data.startPoint; + } + if (eventData.data.startPointOne != null) { + this.startPoint[1] = eventData.data.startPointOne; + } + if (eventData.data.endPoint != null) { + this.endPoint[0] = eventData.data.endPoint; + } + if (eventData.data.endPointOne != null) { + this.endPoint[1] = eventData.data.endPointOne; + } + } + } + + onPageShow() { + console.info('line page show called'); + var stateChangeEvent = { + eventId: 233, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/listItem.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/listItem.ets new file mode 100755 index 0000000000000000000000000000000000000000..11419b8fe2e873c95d23d36c9766e4c90887c552 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/listItem.ets @@ -0,0 +1,88 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter'; + +@Entry +@Component +struct ListItemExample { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + @State editFlag: boolean = false; + @State sticky: Sticky = Sticky.Normal; + @State editMode: boolean = true; + + onPageShow() { + console.info('[ListItem] page show called'); + var stateChangeEvent = { + eventId: 1015, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + + var stateChangeEventOne = { + eventId: 1016, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventOne, this.stateChangCallBack); + } + + private stateChangCallBack = (eventData) => { + console.info("[ListItem] page stateChangCallBack"); + if (eventData != null) { + console.info("[ListItem] page state change called:" + JSON.stringify(eventData)); + if(eventData.data.sticky != null) { + this.sticky = eventData.data.sticky; + } + } + if (eventData != null) { + console.info("[ListItem] page state change called:" + JSON.stringify(eventData)); + if(eventData.data.editMode != null) { + this.editMode = eventData.data.editMode; + } + } + } + + build() { + Column() { + List({ space: 20, initialIndex: 0 }) { + ListItem() { + Text('sticky:Normal , click me edit list') + .width('100%').height(40).fontSize(12).fontColor(0xFFFFFF) + .textAlign(TextAlign.Center).backgroundColor(0x696969) + .onClick(() => { + this.editFlag = !this.editFlag + }) + }.sticky(this.sticky).key('ListItem') + + ForEach(this.arr, (item) => { + ListItem() { + Text('' + item) + .width('100%').height(100).fontSize(16) + .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) + }.editable(this.editFlag) + }, item => item) + } + .key('List') + .editMode(this.editMode) + .onItemDelete((index: number) => { + console.info(this.arr[index - 1] + 'Delete') + this.arr.splice(index - 1,1) + this.editFlag = false + return true + }) + .width('90%') + }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/loadingProgress.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/loadingProgress.ets new file mode 100755 index 0000000000000000000000000000000000000000..0cd364c7b1d17393903a940207444d070dcd03ea --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/loadingProgress.ets @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct LoadingProgressExample { + build() { + Column({ space: 5 }) { + Text('Orbital LoadingProgress ').fontSize(9).fontColor(0xCCCCCC).width('90%') + LoadingProgress() + .color(Color.Blue) + }.width('100%').margin({ top: 6 }) + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/navigation.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/navigation.ets new file mode 100755 index 0000000000000000000000000000000000000000..b5baf4ae7af4dee36c91dd95ed4838b1bda2bbd8 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/navigation.ets @@ -0,0 +1,151 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter'; + +@Entry +@Component +struct NavigationExample { + private arr: number[] = [0, 1, 2, 3, 4, 5] + @State hideBar: boolean = true + @State toolBar: boolean = true + @State hideToolBar: boolean = false + @State hideTitleBar: boolean = false + @State hideBackButton: boolean = false + @State onActionCalled: boolean = false + @State titleMode: NavigationTitleMode = NavigationTitleMode.Free + + private stateChangCallBack = (eventData) => { + if (eventData != null) { + console.info("tabs page state change called:" + JSON.stringify(eventData)); + if (eventData.data.vertical != null) { + this.titleMode = eventData.data.titleMode; + } + if (eventData.data.hideToolBar != null) { + this.hideToolBar = parseInt(eventData.data.hideToolBar); + } + if (eventData.data.hideTitleBar != null) { + this.hideTitleBar = parseInt(eventData.data.hideTitleBar); + } + if (eventData.data.hideBackButton != null) { + this.hideBackButton = parseInt(eventData.data.hideBackButton); + } + } + } + + onPageShow() { + console.info('progress page show called'); + var stateChangeEvent = { + eventId: 555, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack) + } + + @Builder NavigationTitle() { + Column() { + Text('title') + .width(80) + .height(60) + .fontColor(Color.Blue) + .fontSize(30) + } + .onClick(() => { + console.log("title") + }) + } + + @Builder NavigationMenus() { + Row() { + Image('images/add.png') + .width(25) + .height(25) + Image('comment/more.png') + .width(25) + .height(25) + .margin({ left: 30 }) + }.width(100) + } + + build() { + Column() { + Navigation() { + Search({ value: '', placeholder: "" }).width('85%').margin(26) + List({ space: 5, initialIndex: 0 }) { + ForEach(this.arr, (item) => { + ListItem() { + Text('' + item) + .width('90%') + .height(80) + .backgroundColor('#3366CC') + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) + }.editable(true) + }, item => item) + } + .listDirection(Axis.Vertical) + .key('Navigation') + .height(300) + .margin({ top: 10, left: 18 }) + .width('100%') + + Button(this.hideBar ? "tool bar" : "hide bar") + .backgroundColor(0x2788D9).width(200).height(100).fontSize(20) + .key('NavigationContent1') + .onClick(() => { + this.hideBar = !this.hideBar; + console.info('navigationContent1 current action state is: ' + this.hideBar); + try { + var backData = { + data: { + "ACTION": this.hideBar, + } + } + var backEvent = { + eventId: 44, + priority: events_emitter.EventPriority.LOW + } + console.info("navigationContent1 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("navigationContent1 emit action state err: " + JSON.stringify(err.message)) + } + }) + .margin({ left: 135, top: 60 }) + } + .title(this.NavigationTitle) + .subTitle('subtitle') + .menus(this.NavigationMenus) + .titleMode(NavigationTitleMode.Free) + .hideTitleBar(false) + .hideBackButton(false) + .onTitleModeChanged((titleModel: NavigationTitleMode) => { + console.log('titleMode') + }) + .toolBar({ items: [ + { value: 'app', icon: 'images/grid.svg', action: () => { + console.log("app") + } }, + { value: 'add', icon: 'images/add.svg', action: () => { + console.log("add") + } }, + { value: 'collect', icon: 'images/collect.svg', action: () => { + console.log("collect") + } }] }) + .hideToolBar(this.hideBar) + } + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/pageTransition.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/pageTransition.ets new file mode 100755 index 0000000000000000000000000000000000000000..93136f8038977950ddd5800888d14167140c89da --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/pageTransition.ets @@ -0,0 +1,94 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' +@Entry +@Component +struct PageTransitionExample1 { + @State scale: number = 1 + @State opacity: number = 1 + @State active: boolean = false + @State type: RouteType = NavigationType.Push + + build() { + Column() { + Navigator({ target: 'pages/pageTransition2', type: this.type }) { + Image($rawfile('ic_health_heart.png')) + .width("100%") + .height("100%") + } + .key('Navigator') + .onClick(() => { + this.active = true + console.info('pageTransition current action state is: ' + this.active); + try { + var backData = { + data: { + "scale" : this.scale, + "opacity" : this.opacity, + } + } + var backEvent = { + eventId: 96, + priority: events_emitter.EventPriority.LOW + } + console.info("pageTransition start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("pageTransition emit action state err: " + JSON.stringify(err.message)) + } + }) + }.scale({ x: this.scale }).opacity(this.opacity) + } + + pageTransition() { + PageTransitionEnter({ duration: 1200, curve: Curve.Linear }) + .onEnter((type: RouteType, progress: number) => { + this.scale = 1 + this.opacity = progress + }) + PageTransitionExit({ duration: 1500, curve: Curve.Ease }) + .onExit((type: RouteType, progress: number) => { + this.scale = 1 - progress + this.opacity = 1 + }) + } + + onPageShow() { + console.info('active page show called'); + events_emitter.on(stateChangeEvent, this.stateChangCallBack) + + var stateChangeEventOne = { + eventId: 95, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventOne, this.stateChangCallBack) + } + + private stateChangCallBack = (eventData) => { + if (eventData != null) { + console.info("active page state change called:" + JSON.stringify(eventData)); + if (eventData.data.scale != null) { + this.scale = parseInt(eventData.data.scale); + } + if (eventData.data.opacity != null) { + this.opacity = parseInt(eventData.data.opacity); + } + if (eventData.data.type != null) { + this.type = eventData.data.type; + } + } + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/pageTransition2.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/pageTransition2.ets new file mode 100755 index 0000000000000000000000000000000000000000..e2251bb15b6af9c6c919a43c79b47b00991a917f --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/pageTransition2.ets @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' +@Entry +@Component +struct AExample { + @State scale: number = 1 + @State opacity: number = 1 + @State active: boolean = false + build() { + Column() { + Navigator({ target: 'pages/pageTransition' ,type: NavigationType.Push}) { + Image($rawfile('ic_health_heart.png')).width("100%").height("100%") + } + }.height("100%").width("100%").scale({ x: this.scale }).opacity(this.opacity) + } + pageTransition() { + PageTransitionEnter({ duration: 1200, curve: Curve.Linear }) + .onEnter((type: RouteType, progress: number) => { + this.scale = 1 + this.opacity = progress + }) + PageTransitionExit({ duration: 1500, curve: Curve.Ease }) + .onExit((type: RouteType, progress: number) => { + this.scale = 1 - progress + this.opacity = 1 + }) + } +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/panel.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/panel.ets new file mode 100755 index 0000000000000000000000000000000000000000..c52af08b3b02e61895ec5a2cf6b491a04c95c211 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/panel.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct PanelExample { + @State show: boolean = true + @State type: PanelType = PanelType.Foldable + @State mode: PanelMode = PanelMode.Half + + private stateChangCallBack = (eventData) => { + console.info("rating page stateChangCallBack"); + if (eventData != null) { + console.info("rating page state change called:" + JSON.stringify(eventData.data.rating)); + if(eventData.data.type != null) { + this.type = eventData.data.type; + } + } + } + + onPageShow() { + console.info('rating page show called'); + var stateChangeEvent = { + eventId: 440, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack) + var stateChangeEventTwo = { + eventId: 441, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventTwo, this.stateChangCallBack) + var stateChangeEventThree = { + eventId: 442, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventThree, this.stateChangCallBack) + } + + build() { + Column() { + Text('2021-09-30 Today Calendar: 1.afternoon......Click for details') + .width('90%').height(50).borderRadius(10) + .backgroundColor(0xFF0000).padding({ left: 20 }) + .onClick(() => { + this.show = !this.show + }) + Panel(this.show) { + Column() { + Text('HAHA') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .type(this.type).mode(this.mode) + .dragBar(true) + .halfHeight(500) + .key('Panel') + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/radio.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/radio.ets new file mode 100755 index 0000000000000000000000000000000000000000..203a7d86b871bd267aa282625f8908aabc164e74 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/radio.ets @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct RadioExample { + build() { + Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Column() { + Text('Radio1') + Radio({ value: 'Radio1', group: 'radioGroup' }).checked(true) + .height(50) + .width(50) + .onChange((value: boolean) => { + console.log('Radio1 status is ' + value) + }) + } + Column() { + Text('Radio2') + Radio({ value: 'Radio2', group: 'radioGroup' }).checked(false) + .height(50) + .width(50) + .onChange((value: boolean) => { + console.log('Radio2 status is ' + value) + }) + } + Column() { + Text('Radio3') + Radio({ value: 'Radio3', group: 'radioGroup' }).checked(false) + .height(50) + .width(49) + .onChange((value: boolean) => { + console.log('Radio3 status is ' + value) + }) + } + }.padding({ top: 30 }) + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/row.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/row.ets new file mode 100755 index 0000000000000000000000000000000000000000..3fd19d9bbd437db5518d2118694fa7a7ac048537 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/row.ets @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2021 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. + */ +@Entry +@Component +struct RowExample { + build() { + Column({ space: 5 }) { + Text('space').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row({ space: 5 }) { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.width('90%').height(107).border({ width: 1 }) + + Text('alignItems(Top)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.alignItems(VerticalAlign.Top).height('15%').border({ width: 1 }) + + Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.alignItems(VerticalAlign.Center).height('15%').border({ width: 1 }) + + Text('justifyContent(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(50).backgroundColor(0x00FFFF) + }.width('90%').border({ width: 1 }).justifyContent(FlexAlign.End) + + Text('justifyContent(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Row() { + Row().width('30%').height(50).backgroundColor(0xAFEEEE) + Row().width('30%').height(49).backgroundColor(0x00FFFF) + }.width('90%').border({ width: 1 }).justifyContent(FlexAlign.Center) + }.width('100%') + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/scrollBar.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/scrollBar.ets new file mode 100755 index 0000000000000000000000000000000000000000..0e5061d780c975694539a6a50439b227875cf7ff --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/scrollBar.ets @@ -0,0 +1,88 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter'; + +@Entry +@Component +struct ScrollBarExample { + private scroller: Scroller = new Scroller() + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + @State directionValue: ScrollBarDirection = ScrollBarDirection.Vertical; + @State stateValue: BarState= BarState.Off; + + private stateChangCallBack = (eventData) => { + console.info("scrollBar page state change called:" + JSON.stringify(eventData)); + if (eventData != null) { + if (eventData.data.directionValue != null) { + let directionObject = JSON.parse(eventData.data.directionObject); + this.directionValue = directionObject.directionValue; + } + if (eventData.data.stateValue != null) { + let stateObject = JSON.parse(eventData.data.stateObject); + this.stateValue = stateObject.stateValue; + } + } + } + + onPageShow() { + console.info('scrollBar page show called'); + var stateChangeEvent = { + eventId: 80, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + + var stateChangeEvent2 = { + eventId: 41, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent2, this.stateChangCallBack); + } + + build() { + Column() { + Stack({ alignContent: Alignment.End }) { + Scroll(this.scroller) { + Flex({ direction: FlexDirection.Column }) { + ForEach(this.arr, (item) => { + Row() { + Text(item.toString()) + .width('90%') + .height(100) + .backgroundColor('#3366CC') + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) + .margin({ top: 5 }) + } + }, item => item) + }.margin({ left: 52 }) + } + .scrollBar(BarState.Off) + .scrollable(ScrollDirection.Vertical) + + ScrollBar({ scroller: this.scroller, direction: this.directionValue, state: this.stateValue }) { + Text() + .width(30) + .height(100) + .borderRadius(10) + .backgroundColor('#C0C0C0') + }.key('scroll').width(30).backgroundColor('#ededed') + } + } + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/scrollCode.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/scrollCode.ets index 8dcfc3e388cb06f03a3be71f4510c6560a93b2ac..2f7c798212ac69d7e178afd453ead5012030fc88 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/scrollCode.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/scrollCode.ets @@ -18,7 +18,7 @@ import events_emitter from '@ohos.emitter'; @Entry @Component struct scrollCode { - @State scrollable: ScrollDirection = ScrollDirection.Vertical; + @State scrollable: ScrollDirection = ScrollDirection.None; @State scrollBar: BarState = BarState.On; @State scrollBarColor: Color = "#FF0000FF"; @State scrollBarWidth: number = 30; @@ -120,22 +120,37 @@ struct scrollCode { .onScrollEnd(() => { console.info('Scroll Stop') }) - Button('scroll 100') .onClick(() => { this.scroller.scrollTo({ xOffset: 0, yOffset: this.scroller.currentOffset().yOffset + 100 }) - }) - .margin({ top: 10, left: 20 }) + }).margin({ top: 170, left: 20 }) Button('back top') .onClick(() => { this.scroller.scrollEdge(Edge.Top) }) - .margin({ top: 60, left: 20 }) - Button('next page') - .onClick(() => { + .margin({ top: 120, left: 20 }) + Button('next page').backgroundColor(0x2788D9).width(200).height(100).fontSize(20) + .onClick((event: ClickEvent) => { + this.onClickValue = true; + try { + var backData = { + data: { + "scrollToIndex": 10, + "ACTION": this.onClickValue, + "event": JSON.stringify(event) + } + } + var backEvent = { + eventId: 30, + priority: events_emitter.EventPriority.LOW + } + console.info("click to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("click action state err: " + JSON.stringify(err.message)) + } this.scroller.scrollPage({ next: true }) - }) - .margin({ top: 110, left: 20 }) + }).key('button').margin({ top: 10, left: 20 }) }.width('100%').height('100%').backgroundColor(0xDCDCDC) } } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/search.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/search.ets new file mode 100755 index 0000000000000000000000000000000000000000..3bee1b40fb7e7fe4c877c45063edafda3f61e8fb --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/search.ets @@ -0,0 +1,58 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct SearchExample { + @State textFontValue: number= 10; + @State searchButtonValue: string= '' + @State caretPositionValue: string= 10 + private stateChangCallBack = (eventData) => { + console.info("search page state change called:" + JSON.stringify(eventData)); + if (eventData != null) { + if (eventData.data.textFontValue != null) { + this.textFontValue = eventData.data.textFontValue; + } + if (eventData.data.searchButtonValue != null) { + this.searchButtonValue = eventData.data.searchButtonValue; + } + if (eventData.data.caretPositionValue != null) { + this.caretPositionValue = eventData.data.caretPositionValue; + } + } + } + + onPageShow() { + console.info('span page show called'); + var stateChangeEvent = { + eventId: 40, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + } + + build() { + Column() { + Navigation() { + Search({ value: '', placeholder: "", searchButton: "bbb" }).width('85%').margin(26) + .key('search') + } + } + } +} + + diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/sharedTransition.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/sharedTransition.ets new file mode 100755 index 0000000000000000000000000000000000000000..c2b28f9b4ad3cee9d2518e1507df27bf73bdadf1 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/sharedTransition.ets @@ -0,0 +1,84 @@ +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct SharedTransitionExample { + @State scale: number = 1 + @State opacity: number = 1 + @State active: boolean = false + @State duration: number = 1000 + @State delay: number = 0 + + build() { + List() { + ListItem() { + Row() { + Navigator({ target: 'pages/sharedTransition2', type: NavigationType.Push }) { + Image($rawfile('ic_health_heart.png')).width(50).height(50) + .sharedTransition('sharedImage1', { duration:this.duration , delay: this.delay }) + } + .key('Navigator') + .padding({ left: 10 }) + .onClick(() => { + this.active = true + console.info('SharedTransition current action state is: ' + this.active); + try { + var backData = { + data: { + "duration" : this.duration, + "delay" : this.delay, + } + } + var backEvent = { + eventId: 556, + priority: events_emitter.EventPriority.LOW + } + console.info("SharedTransition start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("SharedTransition emit action state err: " + JSON.stringify(err.message)) + } + }) + Text('SharedTransition').width(80).height(80).textAlign(TextAlign.Center) + } + } + } + } + + onPageShow() { + console.info('sharedTransition page show called'); + var stateChangeEvent = { + eventId: 555, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack) + } + + private stateChangCallBack = (eventData) => { + if (eventData != null) { + console.info("sharedTransition page state change called:" + JSON.stringify(eventData)); + if (eventData.data.duration != null) { + this.duration = eventData.data.duration; + } + if (eventData.data.delay != null) { + this.delay = eventData.data.delay; + } + } + } +} + + diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/sharedTransition2.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/sharedTransition2.ets new file mode 100755 index 0000000000000000000000000000000000000000..7b2dd8ef9cfdb53fc201e8b8f71e6ba894aa0098 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/sharedTransition2.ets @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct SharedTransition2Example { + build() { + Stack() { + Image($rawfile('ic_health_heart.png')).width(150).height(150).sharedTransition('sharedImage1') + }.width('100%').height(400) + } +} + diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/sourceType.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/sourceType.ets new file mode 100755 index 0000000000000000000000000000000000000000..674124c074c3079c7278e063527364138651659e --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/sourceType.ets @@ -0,0 +1,56 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter'; + +@Entry +@Component +struct ClickExample { + @State text: string = ''; + + build() { + Column() { + Button('Touch').backgroundColor(0x2788D9).width(100).height(500).fontSize(20) + .onTouch((event: TouchEvent) => { + if (event.type === TouchType.Down) { + this.eventType = 'Down' + } + if (event.type === TouchType.Up) { + this.eventType = 'Up' + } + if (event.type === TouchType.Move) { + this.eventType = 'Move' + } + console.info(this.text = 'source:' + event.source); + try { + var backData = { + data: { + "event": JSON.stringify(event), + } + } + var backEvent = { + eventId: 155, + priority: events_emitter.EventPriority.LOW + } + console.info("sourceTypeTest_0100 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("sourceTypeTest_0100 emit action state err: " + JSON.stringify(err.message)) + } + }).key('button') + Text(this.text).padding(15).fontSize(20).key('text') + }.height(350).width('100%').padding(10) + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/span.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/span.ets index acae2f9c57b3876a8b39e0c0aa075859ecd3ba8b..e24548fbdf983282630dfee716ae801b58cc842c 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/span.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/span.ets @@ -21,6 +21,7 @@ struct SpanExample { @State decorationValue:object={ type: TextDecorationType.None, color: Color.Red } @State textCaseValue:TextCase=TextCase.Normal @State fontSizeValue:number=40 + @State fontColorValue: Color= 0xCCCCCC private stateChangCallBack = (eventData) => { console.info("span page state change called:" + JSON.stringify(eventData)); @@ -31,6 +32,9 @@ struct SpanExample { if (eventData.data.textCaseValue != null) { this.textCaseValue = eventData.data.textCaseValue; } + if (eventData.data.fontColorValue != null) { + this.fontColorValue = eventData.data.fontColorValue; + } } } @@ -47,11 +51,17 @@ struct SpanExample { priority: events_emitter.EventPriority.LOW } events_emitter.on(stateChangeEvent2, this.stateChangCallBack); + + var stateChangeEvent3 = { + eventId: 42, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent3, this.stateChangCallBack); } build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { - Text('Basic Usage').fontSize(9).fontColor(0xCCCCCC) + Text('Basic Usage').fontSize(9).fontColor(this.fontColorValue).key('fontColor') Text() { Span('This is the Span component').fontSize(this.fontSizeValue).textCase(this.textCaseValue) .decoration(this.decorationValue).key('decoration') diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/stateStyle.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/stateStyle.ets new file mode 100755 index 0000000000000000000000000000000000000000..0d0ccea5356cef78e1992c783de4a1c5db8a7f48 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/stateStyle.ets @@ -0,0 +1,107 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct StyleExample { + @State isEnable: boolean = true + + @Styles pressedStyles() { + .backgroundColor("#ED6F21") + .borderRadius(10) + .borderStyle(BorderStyle.Dashed) + .borderWidth(2) + .borderColor("#33000000") + .width(120) + .height(30) + .opacity(1) + } + + @Styles disabledStyles() { + .backgroundColor("#E5E5E5") + .borderRadius(10) + .borderStyle(BorderStyle.Solid) + .borderWidth(2) + .borderColor("#2a4c1919") + .width(90) + .height(25) + .opacity(1) + } + + @Styles normalStyles() { + .backgroundColor("#0A59F7") + .borderRadius(10) + .borderStyle(BorderStyle.Solid) + .borderWidth(2) + .borderColor("#33000000") + .width(100) + .height(25) + .opacity(1) + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) { + Text("normal") + .fontSize(14) + .fontColor(Color.White) + .opacity(0.5) + .stateStyles({ + normal: this.normalStyles, + }) + .margin({ bottom: 20 }) + .textAlign(TextAlign.Center) + Text("pressed") + .backgroundColor("#0A59F7") + .borderRadius(20) + .borderStyle(BorderStyle.Dotted) + .borderWidth(2) + .borderColor(Color.Red) + .width(100) + .height(25) + .opacity(1) + .fontSize(14) + .fontColor(Color.White) + .stateStyles({ + pressed: this.pressedStyles, + }) + .margin({ bottom: 20 }) + .textAlign(TextAlign.Center) + Text(this.isEnable == true ? "effective" : "disabled") + .backgroundColor("#0A59F7") + .borderRadius(20) + .borderStyle(BorderStyle.Solid) + .borderWidth(2) + .borderColor(Color.Gray) + .width(100) + .height(25) + .opacity(1) + .fontSize(14) + .fontColor(Color.White) + .enabled(this.isEnable) + .stateStyles({ + disabled: this.disabledStyles, + }) + .textAlign(TextAlign.Center) + Text("control disabled") + .onClick(() => { + this.isEnable = !this.isEnable + console.log(`${this.isEnable}`) + }) + } + .width(350).height(300) + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/systemPrompt.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/systemPrompt.ets new file mode 100755 index 0000000000000000000000000000000000000000..4e39fb548674a5aae1ab460d227168501b6b803a --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/systemPrompt.ets @@ -0,0 +1,73 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter'; +import prompt from '@system.prompt'; + +@Entry +@Component +struct promptExample { + @State text: string = 'item1' + @State color: string = '#000000' + build(){ + Column(){ + Button('showActionMenu') + .key('button1') + .backgroundColor('#FF0B8FE2') + .fontSize(20) + .margin({top: 20}) + .onClick(()=>{ + prompt.showActionMenu({ + title: 'Title Info', + buttons: [ + { + text: this.text, + color: this.color, + }, + ], + success: function(data) { + console.log('dialog success callback,click button : ' + data.tapIndex); + }, + fail: function(data) { + console.log('dialog fail callback' + data.errMsg); + }, + }); + }) + Button('showDialog') + .key('button2') + .backgroundColor('#FF0B8FE2') + .fontSize(20) + .margin({top: 20}) + .onClick(()=> { + prompt.showDialog({ + title: 'Title Info', + message: 'Message Info', + buttons: [ + { + text: this.text, + color: this.color, + }, + ], + success: function(data) { + console.log('dialog success callback,click button : ' + data.index); + }, + cancel: function() { + console.log('dialog cancel callback'); + }, + }); + }) + } + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/text.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/text.ets index e8c9bca721746cba39b8bfa0464f2a2a17837384..93072d67557c5f2190a41bc3ed734b2e5a6ce957 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/text.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/text.ets @@ -17,12 +17,13 @@ import events_emitter from '@ohos.emitter' @Entry @Component struct TextExample { - @State fontSize: number = 9 + @State fontSize: number = 9; + @State fontColor: string = "0xCCCCCC"; build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { Text('lineHeight') .fontSize(this.fontSize) - .fontColor(0xCCCCCC) + .fontColor(this.fontColor) .key('text') Image($rawfile('test.png')) .key('image') @@ -39,6 +40,12 @@ struct TextExample { priority: events_emitter.EventPriority.LOW } events_emitter.on(stateChangeEvent, this.stateChangCallBack) + + var stateChangeEventOne = { + eventId: 198, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventOne, this.stateChangCallBack) } private stateChangCallBack = (eventData) => { @@ -47,6 +54,9 @@ struct TextExample { if (eventData.data.fontSize != null) { this.fontSize = parseInt(eventData.data.fontSize); } + if (eventData.data.fontColor != null) { + this.fontColor = eventData.data.fontColor; + } } } } diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/timeStamp.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/timeStamp.ets new file mode 100755 index 0000000000000000000000000000000000000000..272156b7d7de2b622c87ff0f80906c3489ac379d --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/timeStamp.ets @@ -0,0 +1,47 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 events_emitter from '@ohos.emitter' +@Entry +@Component +struct ClickExample { + @State text: string = '' + build() { + Column() { + Button('Click').backgroundColor(0x2788D9) + .key('button') + .onClick((event: ClickEvent) => { + this.text = event.timestamp + console.info(this.text) + try { + var backData = { + data: { + "Text": this.text, + } + } + var backEvent = { + eventId: 235, + priority: events_emitter.EventPriority.LOW + } + console.info("button start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button emit action state err: " + JSON.stringify(err.message)) + } + }) + Text(this.text).padding(15) + }.height(300).width('100%').padding(35) + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/toggle.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/toggle.ets index 11a755ec98072ee9c4e1ac36e83830405b98f451..4f7ffc0361c22adb17148fea44343e80b8e5dc93 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/toggle.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/toggle.ets @@ -18,7 +18,7 @@ import events_emitter from '@ohos.emitter'; @Entry @Component struct ToggleExample { - @State selectedColor : color = '#330A59F7'; + @State selectedColor : Color = '#330A59F7'; @State toggleType : ToggleType = ToggleType.Button; @State isOn : boolean = false; @@ -29,6 +29,12 @@ struct ToggleExample { priority: events_emitter.EventPriority.LOW } events_emitter.on(stateChangeEvent, this.stateChangCallBack); + + var stateChangeEventOne = { + eventId: 1012, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventOne, this.stateChangCallBack); } private stateChangCallBack = (eventData) => { diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/transition.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/transition.ets index 7bdd4c05b2b2a4cfca3434811353315207b72cd2..da24b523930070b46881be1b69a29d7a4de4a33e 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/transition.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/transition.ets @@ -19,13 +19,14 @@ import events_emitter from '@ohos.emitter' struct TransitionExample { @State btn1: boolean = false @State show: string = "show" + @State opacity: number = 1 @State onActionCalled: boolean = false @State transitionTypeOne: TransitionType = TransitionType.Insert @State transitionTypeTwo: TransitionType = TransitionType.Delete build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,}) { - Button(this.show).width(80).height(30).backgroundColor(0x317aff).margin({bottom:50}).key('button') + Button(this.show).width(80).height(30).backgroundColor(0x317aff).margin({bottom:50}).key('button').opacity(this.opacity) .onClick(() => { this.onActionCalled = true; try { @@ -54,10 +55,28 @@ struct TransitionExample { }) if (this.btn1) { Button() { - Image($r('app.media.bg')).width("80%").height(300).key('image') + Image($rawfile('test.png')).width("80%").height(300).key('image') }.transition({ type: this.transitionTypeOne, scale: {x:0,y:1.0} }).key('button1') .transition({ type: this.transitionTypeTwo, scale: { x: 1.0, y: 0.0 } }) } }.height(400).width("100%").padding({top:100}) } + + onPageShow() { + console.info('transition page show called'); + var stateChangeEvent = { + eventId: 112, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + } + + private stateChangCallBack = (eventData) => { + if (eventData != null) { + console.info("transition state change called:" + JSON.stringify(eventData)); + if (eventData.data.opacity != null) { + this.opacity = parseInt(eventData.data.opacity); + } + } + } } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/AboutToDisappearJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/AboutToDisappearJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..315d4ed1cf0f74b75c1783a639f6fc9b514a7d4e --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/AboutToDisappearJsunit.test.ets @@ -0,0 +1,71 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils'; + +export default function aboutToDisappearJsunit() { + describe('aboutToDisappearTest', function () { + beforeEach(async function (done) { + console.info("aboutToDisappear beforeEach start"); + let options = { + uri: 'pages/aboutToDisappear', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get aboutToDisappear state pages:" + JSON.stringify(pages)); + if (!("aboutToDisappear" == pages.name)) { + console.info("get aboutToDisappear state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push aboutToDisappear page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push aboutToDisappear page error:" + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("aboutToDisappear after each called"); + }); + + it('aboutToDisappearTest_0100', 0, async function (done) { + console.info('aboutToDisappearTest_0100 START'); + await Utils.sleep(1500); + let callback = (indexEvent) => { + console.info("aboutToDisappearTest_0100 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.ACTION).assertEqual(false); + } + let indexEvent = { + eventId: 160, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("aboutToDisappearTest_0100 on events_emitter err : " + JSON.stringify(err)); + } + console.info("aboutToDisappearTest_0100 click result is: " + JSON.stringify(sendEventByKey('button1',10,""))); + await Utils.sleep(1000); + console.info('aboutToDisappearTest_0100 END'); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/AlphabetIndexerJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/AlphabetIndexerJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..293156fa7c36c592bfb7102b0531ec5a061ab061 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/AlphabetIndexerJsunit.test.ets @@ -0,0 +1,102 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import router from '@system.router'; +import Utils from './Utils'; +import events_emitter from '@ohos.events.emitter'; + +export default function alphabetIndexerJsunit() { + describe('alphabetIndexerTest', function () { + beforeEach(async function (done) { + console.info("alphabetIndexer beforeEach start"); + let options = { + uri: 'pages/alphabetIndexer', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get alphabetIndexer state pages:" + JSON.stringify(pages)); + if (!("alphabetIndexer" == pages.name)) { + console.info("get alphabetIndexer state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push alphabetIndexer page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push alphabetIndexer page error:" + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("alphabetIndexer after each called"); + }); + + it('testAlphabetIndexer01', 0, async function (done) { + console.info('[testAlphabetIndexer01] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('alphabetIndexer'); + let obj = JSON.parse(strJson); + console.info("[testAlphabetIndexer01] alphabetIndexer obj is: " + JSON.stringify(obj)); + let font = JSON.parse(obj.$attrs.font); + console.info("[testAlphabetIndexer01] font: " + JSON.stringify(font)); + expect(font.size).assertEqual(20); + expect(font.weight).assertEqual('FontWeight.Bolder'); + expect(font.family).assertEqual('sans-serif'); + expect(font.style).assertEqual('FontStyle.Italic'); + console.info('testAlphabetIndexer01 END'); + done(); + }); + + it('testAlphabetIndexer02', 0, async function (done) { + console.info('[testAlphabetIndexer02] START'); + try { + let obj = { + size: 25, + weight: 400, + family: 'Arial', + style: FontStyle.Normal + } + let eventData = { + data: { + "font": JSON.stringify(obj) + } + } + var innerEvent = { + eventId: 71, + priority: events_emitter.EventPriority.LOW + } + console.info("[testAlphabetIndexer02] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testAlphabetIndexer02] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('alphabetIndexer'); + let objNew = JSON.parse(strJsonNew); + console.info("[testAlphabetIndexer02] alphabetIndexer obj is: " + JSON.stringify(objNew)); + let font = JSON.parse(objNew.$attrs.font); + console.info("[testAlphabetIndexer02] font: " + JSON.stringify(font)); + expect(font.size).assertEqual(25); + expect(font.weight).assertEqual("FontWeight.400"); + expect(font.family).assertEqual('Arial'); + expect(font.style).assertEqual('FontStyle.Normal'); + console.info('testAlphabetIndexer02 END'); + done(); + }); + }); +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/BadgeJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/BadgeJsunit.test.ets index b8a8d83cdfcfe5aa0c610511153a464a109c502d..aca8b7f8a532735fd16b8f81f7396f94adfbd24f 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/BadgeJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/BadgeJsunit.test.ets @@ -30,7 +30,7 @@ export default function badgeJsunit() { router.clear(); let pages = router.getState(); console.info("get badge state pages: " + JSON.stringify(pages)); - if (!("appear" == pages.name)) { + if (!("badge" == pages.name)) { console.info("get badge state pages.name: " + JSON.stringify(pages.name)); result = await router.push(options); await Utils.sleep(2000); @@ -168,5 +168,81 @@ export default function badgeJsunit() { done(); }); + it('testBadge06', 0, async function (done) { + console.info('[testBadge06] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('badge2'); + let obj = JSON.parse(strJson); + console.info("[testBadge06] component obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Badge'); + expect(obj.$attrs.value).assertEqual('new'); + done(); + }); + + it('testBadge07', 0, async function (done) { + console.info('[testBadge07] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('badge2'); + let obj = JSON.parse(strJson); + console.info("[testBadge07] component obj is: " + JSON.stringify(obj)); + let style = JSON.parse(obj.$attrs.style); + expect(obj.$type).assertEqual('Badge'); + expect(style.color).assertEqual('#FFFF0000'); + done(); + }); + + it('testBadge08', 0, async function (done) { + console.info('[testBadge08] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "colorValue": Color.Blue, + } + } + var innerEvent = { + eventId: 70, + priority: events_emitter.EventPriority.LOW + } + console.info("[testBadge08] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testBadge08] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('badge2'); + let objNew = JSON.parse(strJsonNew); + console.info("[testBadge08] component objNew is: " + JSON.stringify(objNew)); + let style = JSON.parse(objNew.$attrs.style); + expect(style.color).assertEqual('#FF0000FF'); + done(); + }); + + it('testBadge09', 0, async function (done) { + console.info('[testBadge09] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "message": "test", + } + } + var innerEvent = { + eventId: 70, + priority: events_emitter.EventPriority.LOW + } + console.info("[testBadge09] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testBadge09] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('badge2'); + let objNew = JSON.parse(strJsonNew); + console.info("[testBadge09] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.value).assertEqual('test'); + done(); + }); + }) } diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/BindMenuJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/BindMenuJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..e851d768bfc052223bdcba5a890772d840e40cf4 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/BindMenuJsunit.test.ets @@ -0,0 +1,72 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils'; + +export default function aboutToDisappearJsunit() { + describe('bindMenuTest', function () { + beforeEach(async function (done) { + console.info("bindMenu beforeEach start"); + let options = { + uri: 'pages/bindMenu', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get bindMenu state pages:" + JSON.stringify(pages)); + if (!("bindMenu" == pages.name)) { + console.info("get bindMenu state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push bindMenu page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push bindMenu page error:" + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("bindMenu after each called"); + }); + + it('bindMenuTest_0100', 0, async function (done) { + console.info('bindMenuTest_0100 START'); + console.info("bindMenuTest_0100 text click result is: " + JSON.stringify(sendEventByKey('text',10,""))); + await Utils.sleep(1500); + let callback = (indexEvent) => { + console.info("bindMenuTest_0100 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.ACTION).assertEqual(true); + } + let indexEvent = { + eventId: 123, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("bindMenuTest_0100 on events_emitter err : " + JSON.stringify(err)); + } + console.info("bindMenuTest_0100 button click result is: " + JSON.stringify(sendEventByKey('button',10,""))); + await Utils.sleep(1000); + console.info('bindMenuTest_0100 END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/BindPopupJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/BindPopupJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..6ff43845e1c67dfe45354612668d340899e60093 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/BindPopupJsunit.test.ets @@ -0,0 +1,134 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import Utils from './Utils'; +import events_emitter from '@ohos.events.emitter'; + +export default function customPopupOptionJsunit(){ + describe('bindPopupTest', function (){ + beforeEach(async function (done) { + let options = { + uri: 'pages/bindPopup', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get bindPopup state success " + JSON.stringify(pages)); + if (!("bindPopup" == pages.name)) { + console.info("get bindPopup state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(1000); + console.info("push bindPopup page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push bindPopup page error: " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("bindPopup after each called"); + }); + + it('bindPopupTest_0100', 0, async function (done) { + console.info('bindPopupTest_0100 START'); + await Utils.sleep(1500); + let callback = (indexEvent) => { + console.info("bindPopupTest_0100 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.enableArrow).assertEqual(true); + expect(indexEvent.data.maskColor).assertEqual(0x33000000); + } + let indexEvent = { + eventId: 236, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("bindPopupTest_0100 on events_emitter err : " + JSON.stringify(err)); + } + console.info("bindPopupTest_0100 click result is: " + JSON.stringify(sendEventByKey('button',10,""))); + await Utils.sleep(1000); + console.info("bindPopupTest_0100 click Two result is: " + JSON.stringify(sendEventByKey('image',10,""))); + await Utils.sleep(1000); + console.info('bindPopupTest_0100 END'); + done(); + }); + + it('bindPopupTest_0200', 0, async function (done) { + console.info('bindPopupTest_0200 START'); + try { + let eventData = { + data: { + "enableArrow": false, + "maskColor": 0x33000009 + } + } + let indexEvent = { + eventId: 126, + priority: events_emitter.EventPriority.LOW + } + console.info("bindPopupTest_0200 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("bindPopupTest_0200 change component data error: " + err.message); + } + await Utils.sleep(1500); + let callbackOne = (indexEventOne) => { + console.info("bindPopupTest_0200 get state result is: " + JSON.stringify(indexEventOne)); + expect(indexEventOne.data.enableArrow).assertEqual(false); + expect(indexEventOne.data.maskColor).assertEqual(0x33000009); + } + let indexEventOne = { + eventId: 237, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEventOne, callbackOne); + } catch (err) { + console.info("bindPopupTest_0200 on events_emitter err : " + JSON.stringify(err)); + } + console.info("bindPopupTest_0200 click result is: " + JSON.stringify(sendEventByKey('button1',10,""))); + await Utils.sleep(1000); + console.info('bindPopupTest_0200 END'); + done(); + }); + + it('bindPopupTest_0300', 0, async function (done) { + console.info('bindPopupTest_0300 START'); + await Utils.sleep(1500); + let callback = (indexEvent) => { + console.info("bindPopupTest_0300 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.placementOnTop).assertEqual(false); + } + let indexEvent = { + eventId: 238, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("bindPopupTest_0300 on events_emitter err : " + JSON.stringify(err)); + } + console.info("bindPopupTest_0300 click result is: " + JSON.stringify(sendEventByKey('button2',10,""))); + await Utils.sleep(1000); + console.info('bindPopupTest_0300 END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/BlankJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/BlankJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..757c4a6c75dd8a36169ef5d3d8e88200ebb0df29 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/BlankJsunit.test.ets @@ -0,0 +1,89 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter' +import Utils from './Utils'; + +export default function blankJsunit() { + describe('appInfoTest', function () { + beforeEach(async function (done) { + console.info("blank beforeEach start"); + let options = { + uri: 'pages/blank', + } + let result; + try { + router.clear(); + let pages = router.getState(); + console.info("get blank state pages: " + JSON.stringify(pages)); + if (!("blank" == pages.name)) { + console.info("get blank state pages.name: " + JSON.stringify(pages.name)); + result = await router.push(options); + await Utils.sleep(2000); + console.info("push blank page result: " + JSON.stringify(result)); + } + } catch (err) { + console.error("push blank page error: " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("blank after each called"); + }) + + it('testBlank01', 0, async function (done) { + console.info('[testBlank01] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('blank'); + let obj = JSON.parse(strJson); + console.info("[testBlank01] component obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Blank'); + expect(obj.$attrs.color).assertEqual('#FF0000FF'); + expect(obj.$attrs.min).assertEqual('0.000000px'); + done(); + }); + + it('testBlank02', 0, async function (done) { + console.info('[testBlank02] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "colorValue": Color.Red, + } + } + var innerEvent = { + eventId: 90, + priority: events_emitter.EventPriority.LOW + } + console.info("[testBlank02] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testBlank02] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('blank'); + let objNew = JSON.parse(strJsonNew); + console.info("[testBlank02] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$type).assertEqual('Blank'); + expect(objNew.$attrs.color).assertEqual('#FFFF0000'); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/CircleJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/CircleJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..669e5199ce85205de0cbe6d9a6fb199cac3d51ad --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/CircleJsunit.test.ets @@ -0,0 +1,119 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils'; + +export default function circleJsunit() { + describe('circleTest', function () { + beforeEach(async function (done) { + console.info("circle beforeEach start"); + let options = { + uri: 'pages/circle', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get circle state pages:" + JSON.stringify(pages)); + if (!("circle" == pages.name)) { + console.info("get circle state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push circle page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push circle page error:" + JSON.stringify(result)); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("circle after each called"); + }); + + it('circleTest_0100', 0, async function (done) { + console.info('circleTest_0100 START'); + let strJson = getInspectorByKey('circle'); + console.info("circleTest_0100 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("circleTest_0100 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.height).assertEqual('450.00px'); + expect(obj.$attrs.width).assertEqual('450.00px'); + done(); + }); + + it('circleTest_0200', 0, async function (done) { + console.info('[circleTest_0200] START'); + try { + var eventData = { + data: { + "width": '500px', + "height": '500px', + } + } + console.info('[circleTest_0200] START'); + var innerEvent = { + eventId:455, + priority: events_emitter.EventPriority.LOW + } + console.info("[circleTest_0200] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[circleTest_0200] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('circle'); + let obj = JSON.parse(strJson); + console.info("[circleTest_0200] component objNew is: " + JSON.stringify(obj)); + expect(obj.$attrs.height).assertEqual('500.00px'); + expect(obj.$attrs.width).assertEqual('500.00px'); + console.info('circleTest_0200 END'); + done(); + }); + + it('circleTest_0300', 0, async function (done) { + console.info('[circleTest_0300] START'); + try { + var eventData = { + data: { + "width": '-a', + "height": '-b', + } + } + console.info('[circleTest_0300] START'); + var innerEvent = { + eventId:455, + priority: events_emitter.EventPriority.LOW + } + console.info("[circleTest_0300] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[circleTest_0300] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('circle'); + let obj = JSON.parse(strJson); + console.info("[circleTest_0300] component objNew is: " + JSON.stringify(obj)); + expect(obj.$attrs.height).assertEqual('0.00px'); + expect(obj.$attrs.width).assertEqual('0.00px'); + console.info('circleTest_0300 END'); + done(); + }); + + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ConfigurationJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ConfigurationJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..91157ca6438406fc574bed54f38dc4346aaca1dc --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ConfigurationJsunit.test.ets @@ -0,0 +1,73 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils'; + +export default function transFormJsunit() { + describe('appInfoTest', function () { + beforeEach(async function (done) { + console.info("prompt beforeEach start"); + let options = { + uri: 'pages/configuration', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get prompt state pages:" + JSON.stringify(pages)); + if (!("prompt " == pages.name)) { + console.info("get prompt state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push prompt page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push prompt page error:" + err); + } + done(); + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("prompt each called"); + }); + it('configurationTest_0100', 0, async function (done) { + console.info('configurationTest_0100 is start'); + try { + let callBackConfiguration = (backData) => { + console.info("configurationTest_0100 get configurationEvent result is: " + JSON.stringify(backData)); + expect(backData.data.COUNTRY).assertEqual(''); + expect(backData.data.DIR).assertEqual('ltr'); + } + var configurationEvent = { + eventId: 36, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(configurationEvent, callBackConfiguration); + } catch (err) { + console.info("configurationTest_0100 on configurationEvent err : " + JSON.stringify(err)); + } + console.info("testAppear01 click result is: " + JSON.stringify(sendEventByKey('button', 10, ""))); + console.info('[configurationTest01] END'); + done(); + }); + }) +} + + + + diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/DirectionJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/DirectionJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..33eee8d3fe5d05072fea077a1b44c157b98f5e30 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/DirectionJsunit.test.ets @@ -0,0 +1,110 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import Utils from './Utils'; +import events_emitter from '@ohos.events.emitter'; + +export default function directionJsunit(){ + describe('directionTest', function (){ + beforeEach(async function (done) { + let options = { + uri: 'pages/direction', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get direction state success " + JSON.stringify(pages)); + if (!("direction" == pages.name)) { + console.info("get direction state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(1000); + console.info("push direction page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push direction page error: " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("direction after each called"); + }); + + it('directionTest_0100', 0, async function (done) { + console.info('directionTest_0100 START'); + let strJson = getInspectorByKey('direction'); + console.info("directionTest_0100 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("directionTest_0100 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.constructor.direction).assertEqual("FlexDirection.Column"); + done(); + }); + + it('directionTest_0200', 0, async function (done) { + console.info('directionTest_0200 START'); + try { + let eventData = { + data: { + "direction": FlexDirection.Row, + } + } + let indexEvent = { + eventId: 985, + priority: events_emitter.EventPriority.LOW + } + console.info("directionTest_0200 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("directionTest_0200 change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJsonNew = getInspectorByKey('direction'); + let objNew = JSON.parse(strJsonNew); + console.info("directionTest_0200 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + console.info('directionTest_0200 END'); + done(); + }); + + it('directionTest_0300', 0, async function (done) { + console.info('directionTest_0300 START'); + try { + let eventData = { + data: { + "direction": 666, + } + } + let indexEvent = { + eventId: 985, + priority: events_emitter.EventPriority.LOW + } + console.info("directionTest_0300 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("directionTest_0300 change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJsonNew = getInspectorByKey('direction'); + let objNew = JSON.parse(strJsonNew); + console.info("directionTest_0300 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + console.info('directionTest_0300 END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/DividerJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/DividerJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..0e981d1ebd7fd6794c3a5937aee087afd0e01388 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/DividerJsunit.test.ets @@ -0,0 +1,95 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils'; + +export default function dividerJsunit() { + describe('dividerTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/divider', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get divider state success " + JSON.stringify(pages)); + if (!("divider" == pages.name)) { + console.info("get divider state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(1000); + console.info("push divider page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push divider page error: " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("divider after each called"); + }); + + it('dividerTest_0100', 0, async function (done) { + console.info('dividerTest_0100 START'); + let strJson = getInspectorByKey('Divider'); + console.info("dividerTest_0100 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("dividerTest_0100 component obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Divider'); + done(); + }); + + it('dividerTest_0200', 0, async function (done) { + console.info('dividerTest_0200 START'); + let strJson = getInspectorByKey('Divider'); + console.info("dividerTest_0200 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("dividerTest_0200 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.color).assertEqual('#FFCCCCCC'); + console.info('dividerTest_0200 END'); + done(); + }); + + it('dividerTest_0300', 0, async function (done) { + console.info('dividerTest_0300 START'); + try { + let eventData = { + data: { + "color": '#FF000990', + } + } + let indexEvent = { + eventId: 917, + priority: events_emitter.EventPriority.LOW + } + console.info("dividerTest_0300 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("dividerTest_0300 change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJsonNew = getInspectorByKey('Divider'); + let objNew = JSON.parse(strJsonNew); + console.info("dividerTest_0300 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.color).assertEqual('#FF000990'); + console.info('dividerTest_0300 END'); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/EllipseJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/EllipseJsunit.test.ets index d51a990aa2fff24ac5618bc00c757fa4b8cb9501..4cd05d34d21e075201dd1ec7d6544a6d53fd1d88 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/EllipseJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/EllipseJsunit.test.ets @@ -63,8 +63,7 @@ export default function ellipseJsunit() { try { var eventData = { data: { - "width": '500px', - "height": '500px' + "width": '100px' } } var innerEvent = { @@ -80,10 +79,35 @@ export default function ellipseJsunit() { let strJson = getInspectorByKey('ellipse'); let obj = JSON.parse(strJson); console.info("[testEllipse02] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.height).assertEqual('500.000000px'); - expect(obj.$attrs.width).assertEqual('500.000000px'); + expect(obj.$attrs.width).assertEqual('100.000000px'); console.info('testEllipse02 END'); done(); }); + + it('testEllipse03', 0, async function (done) { + console.info('[testEllipse03] START'); + try { + var eventData = { + data: { + "height": '500px' + } + } + var innerEvent = { + eventId: 5, + priority: events_emitter.EventPriority.LOW + } + console.info("[testEllipse03] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testEllipse03] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('ellipse'); + let obj = JSON.parse(strJson); + console.info("[testEllipse03] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.height).assertEqual('500.000000px'); + console.info('testEllipse03 END'); + done(); + }); }) } diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GridContainerJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GridContainerJsunit.test.ets index 7546cdd0a664393e00150c33613856dccaea9389..d947353eae68253da34209b3a7c1602f6ad3b6c5 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GridContainerJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GridContainerJsunit.test.ets @@ -61,6 +61,7 @@ export default function girdContainerJsunit() { done(); }); + it('testGirdContainer02', 0, async function (done) { console.info('[testEllipse02] START'); try { diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/LineJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/LineJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..0523b7f8abb99a1dd2568710df4b5b25668b2f6a --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/LineJsunit.test.ets @@ -0,0 +1,204 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import Utils from './Utils'; +import events_emitter from '@ohos.events.emitter'; + +export default function LineJsunit(){ + describe('LineTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/line', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get line state success " + JSON.stringify(pages)); + if (!("line" == pages.name)) { + console.info("get line state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(1000); + console.info("push line page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push line page error: " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("line after each called"); + }); + + it('lineTest_0100', 0, async function (done) { + console.info('lineTest_0100 START'); + let strJson = getInspectorByKey('line'); + console.info("lineTest_0100 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("lineTest_0100 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.startPoint[0]).assertEqual(0); + done(); + }); + + it('lineTest_0200', 0, async function (done) { + console.info('lineTest_0200 START'); + let strJson = getInspectorByKey('line'); + console.info("lineTest_0200 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("lineTest_0200 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.startPoint[1]).assertEqual(0); + done(); + }); + + it('lineTest_0300', 0, async function (done) { + console.info('lineTest_0300 START'); + let strJson = getInspectorByKey('line'); + console.info("lineTest_0300 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("lineTest_0300 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.endPoint[0]).assertEqual(50); + done(); + }); + + it('lineTest_0400', 0, async function (done) { + console.info('lineTest_0400 START'); + let strJson = getInspectorByKey('line'); + console.info("lineTest_0400 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("lineTest_0400 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.endPoint[1]).assertEqual(100); + done(); + }); + + it('lineTest_0500', 0, async function (done) { + console.info('lineTest_0500 START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "startPoint": 50, + "startPointOne": 50, + } + } + var innerEvent = { + eventId: 233, + priority: events_emitter.EventPriority.LOW + } + console.info("lineTest_0500 start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("lineTest_0500 change component error: " + err.message); + } + await Utils.sleep(2000); + var strJson = getInspectorByKey('line'); + var obj = JSON.parse(strJson); + console.info("lineTest_0500 component obj is: " + JSON.stringify(obj.$attrs.startPoint[0])); + console.info("lineTest_0500 component objOne is: " + JSON.stringify(obj.$attrs.startPoint[1])); + expect(obj.$attrs.startPoint[0]).assertEqual(50); + expect(obj.$attrs.startPoint[1]).assertEqual(50); + done(); + }); + + it('lineTest_0600', 0, async function (done) { + console.info('lineTest_0600 START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "endPoint": 100, + "endPointOne": 150, + } + } + var innerEvent = { + eventId: 233, + priority: events_emitter.EventPriority.LOW + } + console.info("lineTest_0600 start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("lineTest_0600 change component error: " + err.message); + } + await Utils.sleep(2000); + var strJson = getInspectorByKey('line'); + var obj = JSON.parse(strJson); + console.info("lineTest_0600 component obj is: " + JSON.stringify(obj.$attrs.endPoint[0])); + console.info("lineTest_0600 component objOne is: " + JSON.stringify(obj.$attrs.endPoint[1])); + expect(obj.$attrs.endPoint[0]).assertEqual(100); + expect(obj.$attrs.endPoint[1]).assertEqual(150); + done(); + }); + + it('lineTest_0700', 0, async function (done) { + console.info('lineTest_0700 START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "startPoint": 'A', + "startPointOne": 'B', + } + } + var innerEvent = { + eventId: 233, + priority: events_emitter.EventPriority.LOW + } + console.info("lineTest_0700 start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("lineTest_0700 change component error: " + err.message); + } + await Utils.sleep(2000); + var strJson = getInspectorByKey('line'); + var obj = JSON.parse(strJson); + console.info("lineTest_0700 component obj is: " + JSON.stringify(obj.$attrs.startPoint[0])); + console.info("lineTest_0700 component objOne is: " + JSON.stringify(obj.$attrs.startPoint[1])); + expect(obj.$attrs.startPoint[0]).assertEqual(0); + expect(obj.$attrs.startPoint[1]).assertEqual(0); + done(); + }); + + it('lineTest_0800', 0, async function (done) { + console.info('lineTest_0900 START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "endPoint": 'A', + "endPointOne": 'B', + } + } + var innerEvent = { + eventId: 233, + priority: events_emitter.EventPriority.LOW + } + console.info("lineTest_0800 start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("lineTest_0800 change component error: " + err.message); + } + await Utils.sleep(2000); + var strJson = getInspectorByKey('line'); + var obj = JSON.parse(strJson); + console.info("lineTest_0800 component obj is: " + JSON.stringify(obj.$attrs.endPoint[0])); + console.info("lineTest_0800 component objOne is: " + JSON.stringify(obj.$attrs.endPoint[1])); + expect(obj.$attrs.endPoint[0]).assertEqual(0); + expect(obj.$attrs.endPoint[1]).assertEqual(0); + done(); + }); + }) +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/List.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/List.test.ets index 6e598a6d05e82f352b0cd523091a05bd6074d283..9e91175ca1b3a3a06f99df3d21714ab978d3d818 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/List.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/List.test.ets @@ -64,10 +64,34 @@ import toggleJsunit from './ToggleJsunit.test.ets'; import shapeJsunit from './ShapeJsunit.test.ets' import motionPathJsunit from './MotionPathJsunit.test.ets'; import scrollCodeJsunit from './ScrollCodeJsunit.test.ets'; -import canvas3Jsunit from './Canvas3Jsunit.test.ets'; import transitionJsunit from './TransitionJsunit.test.ets'; import priorityGestureJsunit from './PriorityGestureJsunit.test.ets'; import parallelGestureJsunit from './ParallelGestureJsunit.test.ets'; +import blankJsunit from './BlankJsunit.test.ets'; +import sharedTransitionJsunit from './SharedTransitionJsunit.test.ets'; +import alphabetIndexerJsunit from './AlphabetIndexerJsunit.test.ets'; +import lineJsunit from './LineJsunit.test.ets'; +import circleJsunit from './CircleJsunit.test.ets'; +import aboutToDisappearJsunit from './AboutToDisappearJsunit.test.ets'; +import bindMenuJsunit from './BindMenuJsunit.test.ets'; +import bindPopupJsunit from './BindPopupJsunit.test.ets'; +import directionJsunit from './DirectionJsunit.test.ets'; +import timeStampJsunit from './TimeStampJsunit.test.ets'; +import listItemJsunit from './ListItemJsunit.test.ets'; +import navigatorCodeJsunit from './NavigatorCodeJsunit.test.ets'; +import pieceJsunit from './PieceJsunit.test.ets'; +import dividerJsunit from './DividerJsunit.test.ets'; +import systemAppJsunit from './SystemAppJsunit.test.ets'; +import systempromptJsunit from './SystempromptJsunit.test.ets'; +import configurationJsunit from './ConfigurationJsunit.test.ets'; +import sourceTypeJsunit from './SourceTypeJsunit.test.ets'; +import pageTransitionJsunit from './PageTransitionJsunit.test.ets'; +import navigationJsunit from './NavigationJsunit.test.ets'; +import loadingProgressJsunit from './LoadingProgressJsunit.test.ets'; +import radioJsunit from './RadioJsunit.test.ets'; +import rowJsunit from './RowJsunit.test.ets'; +import scrollBarJsunit from './ScrollBarJsunit.test.ets'; +import searchJsunit from './SearchJsunit.test.ets'; export default function testsuite() { gaugeJsunit(); @@ -105,7 +129,6 @@ export default function testsuite() { badgeJsunit(); canvasJsunit(); canvas2Jsunit(); - canvas3Jsunit(); longPressGestureJsUnit(); buttonJsunit(); responseRegionJsunit(); @@ -126,4 +149,29 @@ export default function testsuite() { transitionJsunit(); priorityGestureJsunit(); parallelGestureJsunit(); -} \ No newline at end of file + blankJsunit(); + sharedTransitionJsunit(); + alphabetIndexerJsunit(); + lineJsunit(); + circleJsunit(); + aboutToDisappearJsunit(); + timeStampJsunit(); + bindMenuJsunit(); + bindPopupJsunit(); + directionJsunit(); + dividerJsunit(); + systempromptJsunit(); + configurationJsunit(); + sourceTypeJsunit(); + pageTransitionJsunit(); + navigationJsunit(); + loadingProgressJsunit(); + radioJsunit(); + rowJsunit(); + listItemJsunit(); + navigatorCodeJsunit(); + pieceJsunit(); + searchJsunit(); + scrollBarJsunit(); + systemAppJsunit(); +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ListItemJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ListItemJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..5e8c689f73deb4d3adcfd01f156f80388012a983 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ListItemJsunit.test.ets @@ -0,0 +1,123 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils'; + +export default function listItemJsunit() { + describe('listItemTest', function () { + beforeEach(async function (done) { + console.info("listItem beforeEach start"); + let options = { + uri: 'pages/listItem', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get listItem state pages:" + JSON.stringify(pages)); + if (!("listItem" == pages.name)) { + console.info("get listItem state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push listItem page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push listItem page error:" + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("listItem after each called"); + }); + + it('testListItem01', 0, async function (done) { + console.info('[testListItem01] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('ListItem'); + let obj = JSON.parse(strJson); + console.info("[testListItem01] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.sticky).assertEqual('Sticky.Normal'); + console.info('testListItem01 END'); + done(); + }); + + it('testListItem02', 0, async function (done) { + console.info('[testListItem02] START'); + try { + var eventData = { + data: { + "sticky": Sticky.None + } + } + var innerEvent = { + eventId: 1015, + priority: events_emitter.EventPriority.LOW + } + console.info("[testListItem02] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testListItem02] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('ListItem'); + let obj = JSON.parse(strJson); + console.info("[testListItem02] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.sticky).assertEqual('Sticky.None'); + console.info('testListItem02 END'); + done(); + }); + + it('testListItem03', 0, async function (done) { + console.info('[testListItem03] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('List'); + let obj = JSON.parse(strJson); + console.info("[testListItem03] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.editMode).assertEqual('true'); + console.info('testListItem03 END'); + done(); + }); + + it('testListItem04', 0, async function (done) { + console.info('[testEllipse03] START'); + try { + var eventData = { + data: { + "editMode": false + } + } + var innerEvent = { + eventId: 1016, + priority: events_emitter.EventPriority.LOW + } + console.info("[testListItem04] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testListItem04] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('List'); + let obj = JSON.parse(strJson); + console.info("[testListItem04] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.editMode).assertEqual('false'); + console.info('testListItem04 END'); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/LoadingProgressJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/LoadingProgressJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..748f099320e2f5f1f9fdad8e63b7b18dbee13ac3 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/LoadingProgressJsunit.test.ets @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import Utils from './Utils'; +import events_emitter from '@ohos.events.emitter'; + +export default function loadingProgressJsunit() { + describe('loadingProgressTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/loadingProgress', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get loadingProgress state success " + JSON.stringify(pages)); + if (!("loadingProgress" == pages.name)) { + console.info("get loadingProgress state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(4000); + console.info("push loadingProgress page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push loadingProgress page error " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("loadingProgress after each called"); + }); + }) +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/NavigationJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/NavigationJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..e85f4a61d45f8524a7d1af9d27f044555457a081 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/NavigationJsunit.test.ets @@ -0,0 +1,125 @@ +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils'; + +export default function navigationJsunit() { + describe('appInfoTest', function () { + beforeEach(async function (done) { + console.info("navigation beforeEach start"); + let options = { + uri: 'pages/navigation', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get navigation state pages:" + JSON.stringify(pages)); + if (!("navigation" == pages.name)) { + console.info("get navigation state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push navigation page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push navigation page error:" + JSON.stringify(err)); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("navigation after each called"); + }); + + it('testNavigation_100', 0, async function (done) { + console.info('[testNavigation_100] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('Navigation'); + let obj = JSON.parse(strJson); + console.info("[testNavigation_100] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.width).assertEqual("100.000000%"); + console.info('[testNavigation_100] END'); + done(); + }); + + it('testNavigation_200', 0, async function (done) { + console.info('testNavigation_200 START'); + await Utils.sleep(1000); + let callback = (indexEvent) => { + console.info("testNavigation_200 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.ACTION).assertEqual(false); + } + let indexEvent = { + eventId: 44, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("testNavigation_200 on events_emitter err : " + JSON.stringify(err)); + } + console.info("testNavigation_200 click result is: " + JSON.stringify(sendEventByKey('NavigationContent1',10,""))); + await Utils.sleep(2000); + console.info('testNavigation_200 END'); + done(); + }); + + it('testNavigation_300', 0, async function (done) { + console.info('[testNavigation_300] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('Navigation'); + let obj = JSON.parse(strJson); + console.info("[testNavigation_300] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.height).assertEqual("300.000000vp"); + console.info('[testNavigation_300] END'); + done(); + }); + + it('testNavigation_400', 0, async function (done) { + console.info('testNavigation_400 START'); + await Utils.sleep(1000); + let callback = (indexEvent) => { + console.info("testNavigation_400 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.ACTION).assertEqual(true); + } + let indexEvent = { + eventId: 44, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("testNavigation_400 on events_emitter err : " + JSON.stringify(err)); + } + console.info("testNavigation_400 click result is: " + JSON.stringify(sendEventByKey('NavigationContent1',10,""))); + await Utils.sleep(2000); + console.info('testNavigation_400 END'); + done(); + }); + + it('testNavigation_500', 0, async function (done) { + console.info('[testNavigation_500] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('Navigation'); + let obj = JSON.parse(strJson); + console.info("[testNavigation_500] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.align).assertEqual("Alignment.Center"); + console.info('[testNavigation_500] END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/NavigatorCodeJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/NavigatorCodeJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..d975f481d025014ffe7dac17cdecaa1ea9946e28 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/NavigatorCodeJsunit.test.ets @@ -0,0 +1,106 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; + +export default function navigatorCodeJsunit() { + beforeEach(async function (done) { + console.info("NavigatorClick beforeEach start"); + let options = { + uri: 'pages/NavigatorCode', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get NavigatorClick state pages:" + JSON.stringify(pages)); + if (!("NavigatorClick" == pages.name)) { + console.info("get NavigatorClick state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push NavigatorClick page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push NavigatorClick page error:" + JSON.stringify(result)); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("NavigatorClick after each called"); + }); + + it('test_NavigatorClick_001', 0, async function (done) { + console.info('[test_NavigatorClick_001] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('NavigatorClick'); + let obj = JSON.parse(strJson); + console.info("[test_NavigatorClick_001] component obj is: " + JSON.stringify(obj)); + await Utils.sleep(1000); + expect(obj.$attrs.active).assertEqual('false'); + done(); + }); + + it('test_NavigatorClick_004', 0, async function (done) { + console.info('[test_NavigatorClick_004] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "typeValue": "NavigationType.Back" + } + } + var innerEvent = { + eventId: 101, + priority: events_emitter.EventPriority.LOW + } + console.info("[test_NavigatorClick_004] start to publish emit" + JSON.stringify(eventData)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[test_NavigatorClick_004] change component error: " + err.message); + } + await Utils.sleep(2000); + var strJson = getInspectorByKey('NavigatorType'); + var obj = JSON.parse(strJson); + console.info("[test_NavigatorClick_004] component obj is: " + JSON.stringify(obj.$attrs.type)); + expect(obj.$attrs.type).assertEqual('NavigationType.Back'); + done(); + }); + + it('test_NavigatorClick_004', 0, async function (done) { + await Utils.sleep(1000) + var callback = (eventData) => { + console.info("[test_NavigatorClick_004] get event state result is: " + JSON.stringify(eventData)); + expect(eventData.data.ACTION).assertEqual(10) + } + var innerEvent = { + eventId: 30, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(innerEvent, callback) + } catch (err) { + console.info("[test_NavigatorClick_004] on events_emitter err : " + JSON.stringify(err)); + } + console.info('[test_NavigatorClick_004] sendEventByKey ' + JSON.stringify(sendEventByKey('button', 10, ""))); + await Utils.sleep(1000) + console.info('[test_NavigatorClick_004] testSendTouchEvent END'); + done(); + }); +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/PageTransitionJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/PageTransitionJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..71de5edc0608acd058c41f33ec7e6eab6e88b6a8 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/PageTransitionJsunit.test.ets @@ -0,0 +1,121 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter' +import Utils from './Utils'; + +export default function pageTransitionJsunit() { + describe('pageTransitionTest', function () { + beforeEach(async function (done) { + console.info("pageTransition beforeEach start"); + let options = { + uri: 'pages/pageTransition', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get pageTransition state pages:" + JSON.stringify(pages)); + if (!("pageTransition" == pages.name)) { + console.info("get pageTransition state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push pageTransition page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push pageTransition page error:" + JSON.stringify(err)); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("pageTransition after each called"); + }); + + it('pageTransitionTest_0100', 0, async function (done) { + console.info('pageTransitionTest_0100 START'); + let strJson = getInspectorByKey('Navigator'); + let obj = JSON.parse(strJson); + console.info("pageTransitionTest_0100 component obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Navigator'); + expect(obj.$attrs.target).assertEqual('pages/pageTransition2'); + console.info('pageTransitionTest_0100 END'); + done(); + }); + + it('pageTransitionTest_0200', 0, async function (done) { + console.info('pageTransitionTest_0200 START'); + let strJson = getInspectorByKey('Navigator'); + console.info("pageTransitionTest_0200 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("pageTransitionTest_0200 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.active).assertEqual('false'); + console.info('pageTransitionTest_0200 END'); + done(); + }); + + it('pageTransitionTest_0300', 0, async function (done) { + console.info('pageTransitionTest_0300 START'); + let strJson = getInspectorByKey('Navigator'); + console.info("pageTransitionTest_0300 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("pageTransitionTest_0300 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.type).assertEqual('NavigationType.Push'); + console.info('pageTransitionTest_0300 END'); + done(); + }); + + it('pageTransitionTest_0400', 0, async function (done) { + console.info('pageTransitionTest_0400 START'); + try { + let eventData = { + data: { + "scale": 6, + "opacity": 5, + } + } + let indexEvent = { + eventId: 95, + priority: events_emitter.EventPriority.LOW + } + console.info("pageTransitionTest_0400 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("pageTransitionTest_0400 change component data error: " + err.message); + } + let callback = (indexEventOne) => { + console.info("pageTransitionTest_0400 get state result is: " + JSON.stringify(indexEventOne)); + expect(indexEventOne.data.scale).assertEqual(6); + expect(indexEventOne.data.opacity).assertEqual(5); + } + let indexEventOne = { + eventId: 96, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEventOne, callback); + } catch (err) { + console.info("pageTransitionTest_0400 on events_emitter err : " + JSON.stringify(err)); + } + console.info("pageTransitionTest_0400 click result is: " + JSON.stringify(sendEventByKey('Navigator',10,""))); + await Utils.sleep(2000); + console.info('pageTransitionTest_0400 END'); + done(); + }); + }) +} + diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/PanelJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/PanelJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..cb2b8d1467c94be040b00b01b2d295e5af653a91 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/PanelJsunit.test.ets @@ -0,0 +1,174 @@ +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import Utils from './Utils'; +import events_emitter from '@ohos.events.emitter'; + +export default function panelJsunit() { + describe('panelTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/panel', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get panel state success " + JSON.stringify(pages)); + if (!("panel" == pages.name)) { + console.info("get panel state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(4000); + console.info("push panel page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push panel page error " + JSON.stringify(err)); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("panel after each called"); + }); + + it('testPanel_100', 0, async function (done) { + console.info('testPanel_100 START'); + await Utils.sleep(1000); + try { + let eventData = { + data: { + "type": "PanelType.Minibar" + } + } + var innerEvent = { + eventId: 440, + priority: events_emitter.EventPriority.LOW + } + console.info("testPanel_100 start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("testPanel_100 change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('Panel'); + let obj = JSON.parse(strJson); + console.info("testPanel_100 component obj is: " + JSON.stringify(obj)); + await Utils.sleep(2000); + expect(obj.$attrs.type).assertEqual("PanelType.Minibar"); + console.info('testPanel_100 END'); + done(); + }); + + it('testPanel_200', 0, async function (done) { + console.info('testPanel_200 START'); + await Utils.sleep(1000); + try { + let eventData = { + data: { + "mode": "PanelMode.Mini" + } + } + var innerEvent = { + eventId: 441, + priority: events_emitter.EventPriority.LOW + } + console.info("testPanel_200 start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("testPanel_200 change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('Panel'); + let obj = JSON.parse(strJson); + console.info("testPanel_200 component obj is: " + JSON.stringify(obj)); + await Utils.sleep(2000); + expect(obj.$attrs.mode).assertEqual("PanelMode.Mini"); + console.info('testPanel_200 END'); + done(); + }); + + it('testPanel_300', 0, async function (done) { + console.info('testPanel_300 START'); + await Utils.sleep(1000); + try { + let eventData = { + data: { + "show": "true" + } + } + var innerEvent = { + eventId: 442, + priority: events_emitter.EventPriority.LOW + } + console.info("testPanel_300 start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("testPanel_300 change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('Panel'); + let obj = JSON.parse(strJson); + console.info("testPanel_300 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.show).assertEqual("true"); + console.info('testPanel_300 END'); + done(); + }); + + it('testPanel_400', 0, async function (done) { + console.info('testPanel_400 START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('Panel'); + let obj = JSON.parse(strJson); + console.info("testPanel_400 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.dragBar).assertEqual("true"); + console.info('testPanel_400 END'); + done(); + }); + + it('testPanel_500', 0, async function (done) { + console.info('testPanel_500 START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('Panel'); + let obj = JSON.parse(strJson); + console.info("testPanel_500 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.fullHeight).assertEqual("0.000000vp"); + console.info('testPanel_500 END'); + done(); + }); + + it('testPanel_600', 0, async function (done) { + console.info('testPanel_600 START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('Panel'); + let obj = JSON.parse(strJson); + console.info("testPanel_600 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.halfHeight).assertEqual("500.000000vp"); + console.info('testPanel_600 END'); + done(); + }); + + it('testPanel_700', 0, async function (done) { + console.info('testPanel_700 START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('Panel'); + let obj = JSON.parse(strJson); + console.info("testPanel_700 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.miniHeight).assertEqual("0.000000vp"); + console.info('testPanel_700 END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/Canvas3Jsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/PieceJsunit.test.ets similarity index 54% rename from ace/ace_ets_component/entry/src/main/ets/MainAbility/test/Canvas3Jsunit.test.ets rename to ace/ace_ets_component/entry/src/main/ets/MainAbility/test/PieceJsunit.test.ets index 2724ffd468a454b98d54611bc9370fe7ae29aa60..8b1088b0f39f68c59a6e83e04e86004ac23325c4 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/Canvas3Jsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/PieceJsunit.test.ets @@ -15,42 +15,45 @@ */ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; import Utils from './Utils'; -export default function canvasJsunit() { - describe('canvas3Test', function () { +export default function pieceJsunit() { + describe('appInfoTest', function () { beforeEach(async function (done) { - console.info("canvas3 beforeEach start"); let options = { - uri: 'pages/canvas3', + uri: 'pages/PieceCode', } try { router.clear(); let pages = router.getState(); - console.info("get canvas3 state pages:" + JSON.stringify(pages)); - if (!("canvas3" == pages.name)) { - console.info("get canvas3 state pages.name:" + JSON.stringify(pages.name)); + console.info("get PieceCode state success " + JSON.stringify(pages)); + if (!("PieceCode" == pages.name)) { + console.info("get PieceCode pages success " + JSON.stringify(pages.name)); let result = await router.push(options); await Utils.sleep(2000); - console.info("push canvas3 page result:" + JSON.stringify(result)); + console.info("push PieceCode page success " + JSON.stringify(result)); } } catch (err) { - console.error("push canvas3 page error:" + err); + console.error("push PieceCode page error " + JSON.stringify(err)); } done() }); afterEach(async function () { - await Utils.sleep(1000); - console.info("canvas3 after each called"); + await Utils.sleep(2000); + console.info("PieceCode after each called"); }); - it('testCanvas01', 0, async function (done) { - console.info('[testCanvas01] START'); + it('test_pieceCode_001', 0, async function (done) { + console.info('[test_pieceCode_001] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('piece'); + console.info("[test_pieceCode_001] strJson: " + strJson); + let obj = JSON.parse(strJson); + console.info("[test_pieceCode_001] component obj is: " + JSON.stringify(obj)); await Utils.sleep(1000); - console.info('[testCanvas01]----------- START'); - console.info('testCanvas01 END'); done(); }); - }); -} + }) +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/RadioJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/RadioJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..43b78d534502c181e15ce7dfc4e57b0de958a0fc --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/RadioJsunit.test.ets @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import Utils from './Utils'; +import events_emitter from '@ohos.events.emitter'; + +export default function progressJsunit() { + describe('progressTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/progress', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get progress state success " + JSON.stringify(pages)); + if (!("progress" == pages.name)) { + console.info("get progress state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(4000); + console.info("push progress page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push progress page error " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("progress after each called"); + }); + + it('testProgress_600', 0, async function (done) { + console.info('[testProgress_600] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('CPValue'); + let obj = JSON.parse(strJson); + console.info("testProgress_600 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.width).assertEqual("100.000000vp"); + console.info('testProgress_600 END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/RowJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/RowJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..143557266a27a60e8069273ecb8222d0b2f003ec --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/RowJsunit.test.ets @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import Utils from './Utils'; +import events_emitter from '@ohos.events.emitter'; + +export default function rowJsunit() { + describe('rowTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/row', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get row state success " + JSON.stringify(pages)); + if (!("row" == pages.name)) { + console.info("get row state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(4000); + console.info("push row page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push row page error " + JSON.stringify(err)); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("row after each called"); + }); + + it('testRow_100', 0, async function (done) { + console.info('testRow_100 START'); + let strJson1 = getInspectorByKey('LPValue'); + let objLP = JSON.parse(strJson1); + console.info("testRow_100 component objLP is: " + objLP.$attrs.value); + await Utils.sleep(1000); + try { + let eventData = { + data: { + "value": 100 + } + } + var innerEvent = { + eventId: 55, + priority: events_emitter.EventPriority.LOW + } + console.info("testRow_100 start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("testRow_100 change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('LPValue'); + let obj = JSON.parse(strJson); + console.info("testRows_100 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.value).assertEqual("100.000000"); + console.info('testRow_100 END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ScrollBarJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ScrollBarJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..621c05f410cfd7de724b3a9ba25dbc3c993c60b9 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ScrollBarJsunit.test.ets @@ -0,0 +1,125 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils'; + +export default function scrollBarJsunit() { + describe('appInfoTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/scrollBar', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get scrollBar state success " + JSON.stringify(pages)); + if (!("span" == pages.name)) { + console.info("get scrollBar success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push scrollBar page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push scrollBar page error " + JSON.stringify(err)); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(2000); + console.info("scrollBar after each called"); + }); + + it('testScrollBar001', 0, async function (done) { + console.info('[testScrollBar001] START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('scroll'); + console.info("[testScrollBar001] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testScrollBar001] direction:" + obj.$attrs.direction); + expect(obj.$attrs.direction).assertEqual('ScrollBarDirection.Vertical'); + done(); + }); + + it('testScrollBar002', 0, async function (done) { + console.info('[testScrollBar002] START'); + let object = { + "directionValue": ScrollBarDirection.Horizontal + }; + try { + var eventData = { + data: { + "directionObject": JSON.stringify(object) + } + } + var innerEvent = { + eventId: 80, + priority: events_emitter.EventPriority.LOW + } + console.info("[testScrollBar002] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testScrollBar002] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('scroll'); + let obj = JSON.parse(strJson); + console.info("[testScrollBar002] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.direction).assertEqual('ScrollBarDirection.Vertical'); + console.info('testScrollBar002 END'); + done(); + }); + + it('testScrollBar003', 0, async function (done) { + console.info('[testScrollBar003] START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('scroll'); + console.info("[testScrollBar003] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testScrollBar003] state:" + obj.$attrs.state); + expect(obj.$attrs.state).assertEqual('BarState.Off'); + done(); + }); + + it('testScrollBar004', 0, async function (done) { + console.info('[testScrollBar004] START'); + try { + let eventData = { + data: { + "stateValue":"BarState.On" + } + } + let indexEvent = { + eventId: 41, + priority: events_emitter.EventPriority.LOW + } + console.info("[testScrollBar004] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testScrollBar004] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('scroll'); + console.info("[testScrollBar004] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testScrollBar004] state:" + obj.$attrs.state); + expect(obj.$attrs.state).assertEqual('BarState.Off'); + done(); + }); + }) +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ScrollCodeJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ScrollCodeJsunit.test.ets index 2030653e1941779a5a62876dbdf2c0156540b3ba..6e42de95abf69852c816f36d9805cf395b210fb7 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ScrollCodeJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ScrollCodeJsunit.test.ets @@ -35,7 +35,7 @@ export default function scrollCodeJsunit() { console.info("push ScrollCode page success " + JSON.stringify(result)); } } catch (err) { - console.error("push ScrollCode page error: " + err); + console.error("push ScrollCode page error " + JSON.stringify(err)); } done() }); @@ -52,7 +52,7 @@ export default function scrollCodeJsunit() { let obj = JSON.parse(strJson); console.info("[test_scrollCode_001] component obj is: " + JSON.stringify(obj)); await Utils.sleep(1000); - expect(obj.$attrs.scrollable).assertEqual('ScrollDirection.Vertical'); + expect(obj.$attrs.scrollable).assertEqual('ScrollDirection.None'); expect(obj.$attrs.scrollBar).assertEqual('BarState.On'); expect(obj.$attrs.scrollBarColor).assertEqual('#FF0000FF'); expect(obj.$attrs.scrollBarWidth).assertEqual('30.000000px'); @@ -163,5 +163,27 @@ export default function scrollCodeJsunit() { done(); }); + + it('test_scrollCode_006', 0, async function (done) { + await Utils.sleep(1000) + var callback = (eventData) => { + console.info("[test_scrollCode_006] get event state result is: " + JSON.stringify(eventData)); + expect(eventData.data.scrollToIndex).assertEqual(10) + } + var innerEvent = { + eventId: 30, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(innerEvent, callback) + } catch (err) { + console.info("[test_scrollCode_006] on events_emitter err : " + JSON.stringify(err)); + } + console.info('[test_scrollCode_006] sendEventByKey ' + JSON.stringify(sendEventByKey('button', 10, ""))); + await Utils.sleep(1000) + console.info('[test_scrollCode_006] testSendTouchEvent END'); + done(); + }); + }) } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SearchJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SearchJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..6ddcdd12288164ef8fbb03caafe3043115ea1b05 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SearchJsunit.test.ets @@ -0,0 +1,84 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils'; + +export default function searchJsunit() { + describe('appInfoTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/search', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get search state success " + JSON.stringify(pages)); + if (!("span" == pages.name)) { + console.info("get search success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push search page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push search page error " + JSON.stringify(err)); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(2000); + console.info("search after each called"); + }); + + it('testSearch001', 0, async function (done) { + console.info('[testSearch001] START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('search'); + console.info("[testSearch001] component strJson:" + strJson); + let obj = JSON.parse(strJson); + expect(obj.$attrs.searchButton).assertEqual(''); + done(); + }); + + it('testSearch002', 0, async function (done) { + console.info('[testSearch002] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "searchButtonValue": 'abc' + } + } + var innerEvent = { + eventId: 40, + priority: events_emitter.EventPriority.LOW + } + console.info("[testSearch002] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testSearch002] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('search'); + let objNew = JSON.parse(strJsonNew); + console.info("[testSearch002] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.searchButton).assertEqual(''); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SharedTransitionJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SharedTransitionJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..5e7d1e6642ea133c15de3d8aa67959015abb40fc --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SharedTransitionJsunit.test.ets @@ -0,0 +1,121 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.emitter' +import Utils from './Utils'; + +export default function sharedTransitionJsunit() { + describe('sharedTransitionTest', function () { + beforeEach(async function (done) { + console.info("sharedTransition beforeEach start"); + let options = { + uri: 'pages/sharedTransition', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get sharedTransition state pages:" + JSON.stringify(pages)); + if (!("sharedTransition" == pages.name)) { + console.info("get sharedTransition state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push sharedTransition page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push sharedTransition page error:" + JSON.stringify(err)); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("sharedTransition after each called"); + }); + + it('sharedTransitionTest_0100', 0, async function (done) { + console.info('sharedTransitionTest_0100 START'); + let strJson = getInspectorByKey('Navigator'); + let obj = JSON.parse(strJson); + console.info("sharedTransitionTest_0100 component obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Navigator') + expect(obj.$ID).assertEqual(6) + console.info('sharedTransitionTest_0100 END'); + done(); + }); + + it('sharedTransitionTest_0200', 0, async function (done) { + console.info('sharedTransitionTest_0200 START'); + let strJson = getInspectorByKey('Navigator'); + let obj = JSON.parse(strJson); + console.info("sharedTransitionTest_0200 component obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Navigator') + expect(obj.$attrs.target).assertEqual('pages/sharedTransition2') + console.info('sharedTransitionTest_0200 END'); + done(); + }); + + it('sharedTransitionTest_0300', 0, async function (done) { + console.info('sharedTransitionTest_0300 START'); + let strJson = getInspectorByKey('Navigator'); + let obj = JSON.parse(strJson); + console.info("sharedTransitionTest_0300 component obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Navigator') + expect(obj.$attrs.active).assertEqual('false') + console.info('sharedTransitionTest_0300 END'); + done(); + }); + + it('sharedTransitionTest_0400', 0, async function (done) { + console.info('sharedTransitionTest_0400 START'); + try { + let eventData = { + data: { + "duration": 2000, + "delay": 5, + } + } + let indexEvent = { + eventId: 555, + priority: events_emitter.EventPriority.LOW + } + console.info("sharedTransitionTest_0400 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("sharedTransitionTest_0400 change component data error: " + err.message); + } + let callback = (indexEventOne) => { + console.info("sharedTransitionTest_0400 get state result is: " + JSON.stringify(indexEventOne)); + expect(indexEventOne.data.duration).assertEqual(2000); + expect(indexEventOne.data.delay).assertEqual(5); + } + let indexEventOne = { + eventId: 556, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEventOne, callback); + } catch (err) { + console.info("sharedTransitionTest_0400 on events_emitter err : " + JSON.stringify(err)); + } + console.info("sharedTransitionTest_0400 click result is: " + JSON.stringify(sendEventByKey('Navigator',10,""))); + await Utils.sleep(2000); + console.info('sharedTransitionTest_0400 END'); + done(); + }); + }) +} + diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SourceTypeJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SourceTypeJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..f5e6cf5233e19553c48925fd3e1dccef4534a1d0 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SourceTypeJsunit.test.ets @@ -0,0 +1,75 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; + +export default function sourceTypeJsunit() { + beforeEach(async function (done) { + console.info("sourceType beforeEach start"); + let options = { + uri: 'pages/sourceType', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get sourceType state pages:" + JSON.stringify(pages)); + if (!("sourceType" == pages.name)) { + console.info("get sourceType state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push sourceType page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push sourceType page error:" + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("sourceType after each called"); + }); + + it('sourceTypeTest_0100', 0, async function (done) { + await Utils.sleep(1000) + let rect = await Utils.getComponentRect('button') + console.info("sourceTypeTest_0100 rectInfo is " + JSON.stringify(rect)); + let x_value = rect.left + (rect.right - rect.left) / 2 + let y_value = rect.top + (rect.bottom - rect.top) / 2 + console.info("sourceTypeTest_0100 onTouch location is: " + "[x]=== " + x_value + " [y]===" + y_value); + let point: TouchObject = { id: 1, x: x_value, y: y_value, type: TouchType.Down} + var callback = (eventData) => { + console.info("sourceTypeTest_0100 get event state result is: " + JSON.stringify(eventData)); + let event = JSON.parse(eventData.data.event); + expect(event.source).assertEqual(0) + } + var innerEvent = { + eventId: 155, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(innerEvent, callback) + } catch (err) { + console.info("sourceTypeTest_0100 on events_emitter err : " + JSON.stringify(err)); + } + console.info('sourceTypeTest_0100 sendTouchEvent :' + sendTouchEvent(point)); + await Utils.sleep(1000) + console.info('sourceTypeTest_0100 testSendTouchEvent END'); + done(); + }); +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SpanJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SpanJsunit.test.ets index cbdda33344be98efbd20d5cb54e6c3fd152183bc..c9a459bad0eab0db53012a758ee3cdad08d88157 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SpanJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SpanJsunit.test.ets @@ -35,7 +35,7 @@ export default function spanJsunit() { console.info("push span page success " + JSON.stringify(result)); } } catch (err) { - console.error("push span page error: " + err); + console.error("push span page error " + JSON.stringify(err)); } done() }); @@ -93,5 +93,42 @@ export default function spanJsunit() { expect(obj.$attrs.textCase).assertEqual('TextCase.UpperCase'); done(); }); + + it('testSpan004', 0, async function (done) { + console.info('[testSpan004] START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('fontColor'); + console.info("[testSpan004] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testSpan004] fontColor:" + obj.$attrs.fontColor); + expect(obj.$attrs.fontColor).assertEqual('#FF000000'); + done(); + }); + + it('testSpan005', 0, async function (done) { + console.info('[testSpan005] START'); + try { + let eventData = { + data: { + "fontColorValue": '#FF000990' + } + } + let indexEvent = { + eventId: 42, + priority: events_emitter.EventPriority.LOW + } + console.info("[testSpan005] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testSpan005] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('fontColor'); + console.info("[testSpan005] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testSpan005] fontColor:" + obj.$attrs.fontColor); + expect(obj.$attrs.fontColor).assertEqual('#FF000990'); + done(); + }); }) } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SystemAppJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SystemAppJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..0b2df393b428ce1c352c4920a87fc21345709c52 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SystemAppJsunit.test.ets @@ -0,0 +1,56 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import app from '@system.app'; + +export default function systemAppJsunit() { + describe('appInfoTest', function () { + it('systemAppTest_0100', 0, async function (done) { + console.info('systemAppTest_0100 START'); + var a = app.getInfo(); + console.log('systemAppTest_0100 END' + JSON.stringify(a)); + expect(a.appID == "com.open.harmony.acetest").assertTrue(); + console.info('systemAppTest_0100 END'); + done(); + }); + + it('systemAppTest_0200', 0, async function (done) { + console.info('systemAppTest_0200 START'); + var a = app.getInfo(); + console.log('systemAppTest_0200 END' + JSON.stringify(a)); + expect(a.appName == "$string:entry_MainAbility").assertTrue(); + console.info('systemAppTest_0200 END'); + done(); + }); + + it('systemAppTest_0300', 0, async function (done) { + console.info('systemAppTest_0300 START'); + var a = app.getInfo(); + console.log('systemAppTest_0300 END' + JSON.stringify(a)); + expect(a.versionName == "1.0.0").assertTrue(); + console.info('systemAppTest_0300 END'); + done(); + }); + + it('systemAppTest_0400', 0, async function (done) { + console.info('systemAppTest_0400 START'); + app.terminate(); + console.info('systemAppTest_0400 END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SystempromptJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SystempromptJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..f22ec36fc812fdb8619c2eed435c3604d6c94af1 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SystempromptJsunit.test.ets @@ -0,0 +1,69 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils'; + +export default function transFormJsunit() { + describe('appInfoTest', function () { + beforeEach(async function (done) { + console.info("prompt beforeEach start"); + let options = { + uri: 'pages/systemPrompt', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get prompt state pages:" + JSON.stringify(pages)); + if (!("prompt " == pages.name)) { + console.info("get prompt state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push prompt page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push prompt page error:" + err); + } + done(); + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("prompt each called"); + }); + it('promptTest_0100', 0, async function (done) { + console.info('promptTest_0100 is start'); + await Utils.sleep(1500); + console.info("promptTest_0100 click result is: " + JSON.stringify(sendEventByKey('button1',10,""))); + await Utils.sleep(1500); + console.info('promptTest_0100 END'); + done(); + }); + it('promptTest_0200', 0, async function (done) { + console.info('promptTest_0200 is start'); + await Utils.sleep(1500); + console.info("promptTest_0200 click result is: " + JSON.stringify(sendEventByKey('button2',10,""))); + await Utils.sleep(1500); + console.info('promptTest_0200 END'); + done(); + }); + }) +} + + + + diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TextJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TextJsunit.test.ets index d59c97c98b62304fedc562d0e84902b97742e491..786d599e9cd11e02b80f4cd59f259f62da08d331 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TextJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TextJsunit.test.ets @@ -99,5 +99,43 @@ export default function textJsunit() { console.info('testText_0300 END'); done(); }); + + it('testText_0700', 0, async function (done) { + console.info('testText_0700 START'); + let strJson = getInspectorByKey('text'); + console.info("testText_0700 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("testText_0700 component obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Text'); + expect(obj.$attrs.fontColor).assertEqual('#FF000000'); + console.info('testText_0700 END'); + done(); + }); + + it('testText_0800', 0, async function (done) { + console.info('testText_0800 START'); + try { + let eventData = { + data: { + "fontColor": "#330A59F7", + } + } + let indexEvent = { + eventId: 198, + priority: events_emitter.EventPriority.LOW + } + console.info("testText_0800 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("testText_0800 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('text'); + let objNew = JSON.parse(strJsonNew); + console.info("testText_0800 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.fontColor).assertEqual('#330A59F7'); + console.info('testText_0800 END'); + done(); + }); }) } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TimeStampJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TimeStampJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..4e127fdd3419fddef6ecd590e05a4074b0384c6e --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TimeStampJsunit.test.ets @@ -0,0 +1,70 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import Utils from './Utils'; +import events_emitter from '@ohos.events.emitter'; + +export default function timeStampJsunit(){ + describe('timeStampTest', function (){ + beforeEach(async function (done) { + let options = { + uri: 'pages/timeStamp', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get timeStamp state success " + JSON.stringify(pages)); + if (!("timeStamp" == pages.name)) { + console.info("get timeStamp state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(1000); + console.info("push timeStamp page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push timeStamp page error: " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("timeStamp after each called"); + }); + + it('timeStampTest_0100', 0, async function (done) { + console.info('timeStampTest_0100 START'); + await Utils.sleep(1500); + let callback = (indexEvent) => { + console.info("timeStampTest_0100 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.Text).assertNotEqual(null); + } + let indexEvent = { + eventId: 235, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("timeStampTest_0100 on events_emitter err : " + JSON.stringify(err)); + } + console.info("timeStampTest_0100 click result is: " + JSON.stringify(sendEventByKey('button',10,""))); + await Utils.sleep(1500); + console.info('timeStampTest_0100 END'); + done(); + }); + }) +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ToggleJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ToggleJsunit.test.ets index 5619c576a50f2a6b695cee7421dc59c4d04ed818..b00bdd94181a44003f850e88d94dbe34859898b8 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ToggleJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ToggleJsunit.test.ets @@ -52,6 +52,7 @@ export default function ToggleJsunit() { let strJson = getInspectorByKey('toggle'); let obj = JSON.parse(strJson); console.info("[testToggle01] obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Toggle'); expect(obj.$attrs.selectedColor).assertEqual('#330A59F7'); console.info('[testToggle01] END'); done(); @@ -104,5 +105,31 @@ export default function ToggleJsunit() { console.info('testToggle04 END'); done(); }); + + it('testToggle05', 0, async function (done) { + console.info('testToggle05 START'); + try { + let eventData = { + data: { + "selectedColor": '#330A59F8', + } + } + let indexEvent = { + eventId: 1012, + priority: events_emitter.EventPriority.LOW + } + console.info("testToggle05 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("testToggle05 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('toggle'); + let objNew = JSON.parse(strJsonNew); + console.info("testToggle05 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.selectedColor).assertEqual('#330A59F8'); + console.info('testToggle05 END'); + done(); + }); }) } diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TransitionJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TransitionJsunit.test.ets index 48596eee66b76c4f5297604d57590f3b86bcd9fd..875c38a5bbb50c80ab9fde3388a718ffa8427ba2 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TransitionJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TransitionJsunit.test.ets @@ -79,5 +79,57 @@ export default function transitionJsunit() { console.info('transitionTest_0200 END'); done(); }); + + it('transitionTest_0300', 0, async function (done) { + console.info('transitionTest_0300 START'); + try { + let eventData = { + data: { + "opacity": 2, + } + } + let indexEvent = { + eventId: 112, + priority: events_emitter.EventPriority.LOW + } + console.info("transitionTest_0300 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("transitionTest_0300 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('button'); + let objNew = JSON.parse(strJsonNew); + console.info("transitionTest_0300 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.opacity).assertEqual(2); + console.info('transitionTest_0300 END'); + done(); + }); + + it('transitionTest_0400', 0, async function (done) { + console.info('transitionTest_0400 START'); + try { + let eventData = { + data: { + "opacity": 'a', + } + } + let indexEvent = { + eventId: 112, + priority: events_emitter.EventPriority.LOW + } + console.info("transitionTest_0400 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("transitionTest_0400 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('button'); + let objNew = JSON.parse(strJsonNew); + console.info("transitionTest_0400 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.opacity).assertEqual(null); + console.info('transitionTest_0400 END'); + done(); + }); }) } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ZIndexJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ZIndexJsunit.test.ets index 1d48e8fdbb6cab4d743e6745578dd1b1140de6b8..9c89b711171ed0962becd89191d481726fcb2764 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ZIndexJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ZIndexJsunit.test.ets @@ -82,5 +82,31 @@ export default function enableJsunit() { console.info('testZIndex02 END'); done(); }); + + it('testZIndex03', 0, async function (done) { + console.info('[testZIndex03] START'); + try { + var eventData = { + data: { + "zIndex": -5 + } + } + var innerEvent = { + eventId: 84, + priority: events_emitter.EventPriority.LOW + } + console.info("[testZIndex03] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testZIndex03] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('zIndex'); + let obj = JSON.parse(strJson); + console.info("[testZIndex03] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.zIndex).assertEqual(-5); + console.info('testZIndex03 END'); + done(); + }); }) } diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/general-properties/ClickEventJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/general-properties/ClickEventJsunit.test.ets index 5b3356583f3d1a1e7fde126b30938e98547057eb..3d1e14b7de1bac0d8d150fbfbe94feb8c40bfe2d 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/general-properties/ClickEventJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/general-properties/ClickEventJsunit.test.ets @@ -58,8 +58,8 @@ export default function clickEventJsunit() { let event = JSON.parse(eventData.data.event); expect(event.screenX).assertEqual(240) expect(event.screenY).assertEqual(60) - expect(event.x).assertEqual(240) - expect(event.y).assertEqual(60) + expect(event.x).assertEqual(100) + expect(event.y).assertEqual(50) } var innerEvent = { eventId: 30, diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/general-properties/FlexJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/general-properties/FlexJsunit.test.ets index 043edbe0573f4c147c30c9562d15f877171dda17..986491038e2ce2844bd956db5784bb46d43c2e47 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/general-properties/FlexJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/general-properties/FlexJsunit.test.ets @@ -16,6 +16,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import router from '@ohos.events.emitter'; import Utils from '../Utils.ets'; +import router from '@system.router'; export default function flexJsunit() { describe('flexTest', function () { @@ -93,5 +94,26 @@ export default function flexJsunit() { console.info('testFlex_0400 END'); done(); }); + + it('testFlex_0500', 0, async function (done) { + console.info('testFlex_0500 START'); + let strJson = getInspectorByKey('flex'); + console.info("testFlex_0500 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("testFlex_0500 component obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Flex'); + done(); + }); + + it('testFlex_0600', 0, async function (done) { + console.info('testFlex_0600 START'); + let strJson = getInspectorByKey('flex'); + console.info("testFlex_0600 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("testFlex_0600 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.constructor.direction).assertEqual('FlexDirection.Row'); + console.info('testFlex_0600 END'); + done(); + }); }) } \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/BUILD.gn b/appexecfwk/bundle_standard/bundlemanager/BUILD.gn index bdf77ff3285e7d4faf1f04ba1db4e9b57c215325..4ca6e4b6d6c9bef3378a584eacf897e1c3acde8d 100644 --- a/appexecfwk/bundle_standard/bundlemanager/BUILD.gn +++ b/appexecfwk/bundle_standard/bundlemanager/BUILD.gn @@ -9,7 +9,7 @@ # 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. +# limitations under the License. import("//test/xts/tools/build/suite.gni") @@ -25,6 +25,7 @@ group("bundlemanager") { "actsbmskittest:ActsBmsKitTest", "actsbmsmetadatatest:ActsBmsMetaDataTest", "actsbmsmoduleusagerecordtest:ActsBmsModuleUsageRecordTest", + "actsbundlemanageretstest:ActsBundleManagerEtsTest", "actsbundlemanagertest:ActsBundleManagerTest", "actsbundlemanageruninstall:ActsBundleManagerUninstallTest", "actsbundlemgrmultipleinstalltest:ActsBundleMgrMultipleInstallTest", diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsjsunpermissiontest/entry/src/main/js/test/ActsBmsJsUnPermissionTest.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmsjsunpermissiontest/entry/src/main/js/test/ActsBmsJsUnPermissionTest.test.js index d3f886bfe158fdd0f954e64df17fa8b7a78257cd..39053503e73c1e871b79a3bd3a59afca5a72bd5b 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsjsunpermissiontest/entry/src/main/js/test/ActsBmsJsUnPermissionTest.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsjsunpermissiontest/entry/src/main/js/test/ActsBmsJsUnPermissionTest.test.js @@ -15,7 +15,7 @@ import bundle from '@ohos.bundle' import innerBundleManager from '@ohos.bundle.innerBundleManager' -import { describe, it, expect } from 'deccjsunit/index' +import {describe, it, expect} from 'deccjsunit/index' const STATUS_INSTALL_PERMISSION_DENIED = 0X44; const STATUS_UNINSTALL_PERMISSION_DENIED = 0X45; @@ -47,7 +47,7 @@ describe('ActsBmsJsUnPermissionTest', function () { expect(data.status).assertEqual(STATUS_INSTALL_PERMISSION_DENIED); expect(data.statusMessage).assertEqual("STATUS_INSTALL_PERMISSION_DENIED"); done(); - }; + } }); /* @@ -69,7 +69,7 @@ describe('ActsBmsJsUnPermissionTest', function () { expect(data.status).assertEqual(STATUS_UNINSTALL_PERMISSION_DENIED); expect(data.statusMessage).assertEqual("STATUS_UNINSTALL_PERMISSION_DENIED"); done(); - }; + } }); /* @@ -144,8 +144,8 @@ describe('ActsBmsJsUnPermissionTest', function () { it('queryAbilityByWantTest_100', 0, async function (done) { console.debug('queryAbilityByWantTest_100 start'); bundle.queryAbilityByWant({ - bundleName : LAUNCHER_BUNDLE_NAME, - abilityName : LAUNCHER_MAIN_ABILITY + bundleName: LAUNCHER_BUNDLE_NAME, + abilityName: LAUNCHER_MAIN_ABILITY }, DEFAULT_FLAG, DEFAULT_USER_ID).then(data => { expect().assertFail(); done(); @@ -211,8 +211,8 @@ describe('ActsBmsJsUnPermissionTest', function () { it('setAbilityEnabledTest_100', 0, async function (done) { console.debug('setAbilityEnabledTest_100 start'); let abilityInfo = { - bundleName : LAUNCHER_BUNDLE_NAME, - name : LAUNCHER_MAIN_ABILITY + bundleName: LAUNCHER_BUNDLE_NAME, + name: LAUNCHER_MAIN_ABILITY }; bundle.setAbilityEnabled(abilityInfo, false).then(data => { expect().assertFail(); @@ -270,4 +270,40 @@ describe('ActsBmsJsUnPermissionTest', function () { done(); }); }); + + /* + * @tc.number: getAbilityLabelTest_100 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('getAbilityLabelTest_100', 0, async function (done) { + console.debug('[getAbilityLabelTest_100] promise START'); + await bundle.getAbilityLabel(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY) + .then((data) => { + expect().assertFail(); + done(); + }) + .catch((error) => { + expect(error).assertEqual(INVALID_CODE); + done(); + }); + }); + + /* + * @tc.number: getAbilityInfo_100 + * @tc.name: test getAbilityInfo + * @tc.desc: test getAbilityInfo + */ + it('getAbilityInfo_100', 0, async function (done) { + console.debug('getAbilityInfo_100 start'); + bundle.getAbilityInfo(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY).then(data => { + expect().assertFail(); + done(); + }).catch(err => { + expect(err).assertEqual(INVALID_CODE); + done(); + }); + }) + }) diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/BUILD.gn b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3c80521fd4aee6befa2e06d783ea6a440778f420 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 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("ActsBundleManagerEtsTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_ets_assets", + ":hjs_demo_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsBundleManagerEtsTest" +} +ohos_js_assets("hjs_demo_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("hjs_demo_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..c916382f6a76a6f0191eff83bbc70ee6ed88f308 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for actsbundleetsgetinfotest Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "600000", + "package": "com.open.harmony.packagemag", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsBundleManagerEtsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/config.json b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..87603be2bc8c1c3e7f9918c6d2e8a83c7a502b17 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/config.json @@ -0,0 +1,85 @@ +{ + "app": { + "bundleName": "com.open.harmony.packagemag", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.open.harmony.packagemag", + "name": ".MyApplication", + "mainAbility": "com.open.harmony.packagemag.MainAbility", + "deviceType": [ + "phone" + ], + "reqPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + } + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:mainability_description", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:description_serviceability", + "type": "service" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/app.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a47e22427b28a7af740c97ab4467f0872c41496 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2021 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/pages/index.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e98a1ac989e8e7ca55ae68c551b07e252000e064 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2021 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 router from '@system.router'; +import file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; +import testsuite from "../test/List.test.ets"; +import featureAbility from "@ohos.ability.featureAbility"; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('ACE ETS TEST 包管理 2 ') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/pages/second.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..9002655f12f0ace700bf00ab324320cdd262bfa6 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/pages/second.ets @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2021 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 router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetAbilityLabelJsUnit.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetAbilityLabelJsUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b6e10c72ef77eeb03dd9325cf3bac456ff49e79b --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetAbilityLabelJsUnit.test.ets @@ -0,0 +1,248 @@ +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index.ets'; +import Utils from './Utils'; +import Bundle from '@ohos.bundle'; + +const BUNDLE_NAME = 'com.open.harmony.packagemag' +const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility' +const SERVICE_ABILITY_NAME = 'com.open.harmony.packagemag.ServiceAbility' + +const OTHER_BUNDLE_NAME = 'com.ohos.acepackage' +const OTHER_ABILITY_NAME = 'com.ohos.acepackage.MainAbility' + +const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error' +const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility' + +export default function getAbilityLabelJsUnit() { + + describe('context_getAbilityLabel_test', function () { + beforeEach(async function (done) { + console.info('context_getAbilityLabel_test before each called'); + done() + }); + + afterEach(async function () { + await Utils.sleep(2000); + console.info('context_getAbilityLabel_test after each called'); + }); + + /* + * @tc.number: context_getAbilityLabel_test_0100 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_getAbilityLabel_test_0100', 0, async function (done) { + console.info('[context_getAbilityLabel_test_0100] promise START'); + await Utils.sleep(1000); + let mData; + var timeOldStamp = await Utils.getNowTime(); + await Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getAbilityLabel_test_0100]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_getAbilityLabel_test_0100] promise in '); + console.info('[context_getAbilityLabel_test_0100] promise data is: ' + JSON.stringify(data)); + }) + .catch((error) => { + console.info('[context_getAbilityLabel_test_0100] promise error is: ' + error); + }); + getAbilityLabelSuccess('[context_getAbilityLabel_test_0100]', mData); + done(); + }); + + /* + * @tc.number: context_getAbilityLabel_test_0200 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by callbac) + * @tc.level 0 + */ + it('context_getAbilityLabel_test_0200', 0, async function (done) { + console.info('[context_getAbilityLabel_test_0200] callBack START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME, (error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getAbilityLabel_test_0200]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_getAbilityLabel_test_0200] callBack in'); + console.info('[context_getAbilityLabel_test_0200] callBack error: ' + error); + console.info('[context_getAbilityLabel_test_0200] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getAbilityLabelSuccess('[context_getAbilityLabel_test_0200]', mData); + done(); + }); + + /* + * @tc.number: context_getAbilityLabel_test_0300 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_getAbilityLabel_test_0300', 0, async function (done) { + console.info('[context_getAbilityLabel_test_0300] promise START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mError; + await Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp); + + console.info('[context_getAbilityLabel_test_0300] promise in '); + console.info('[context_getAbilityLabel_test_0300] promise data is: ' + JSON.stringify(data)); + }) + .catch((error) => { + var timeNewStamp = Utils.getNowTime(); + mError = error; + Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp); + console.info('[context_getAbilityLabel_test_0300] promise error is: ' + error); + }); + await Utils.sleep(2000); + getAbilityLabelFailure('[context_getAbilityLabel_test_0300]', mError); + done(); + }); + + /* + * @tc.number: context_getAbilityLabel_test_0400 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_getAbilityLabel_test_0400', 0, async function (done) { + console.info('[context_getAbilityLabel_test_0400] callBack START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mError; + Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR, (error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getAbilityLabel_test_0400]', timeOldStamp, timeNewStamp); + mError = error; + console.info('[context_getAbilityLabel_test_0400] callBack in'); + console.info('[context_getAbilityLabel_test_0400] callBack error: ' + error); + console.info('[context_getAbilityLabel_test_0400] callBack data is:' + JSON.stringify(data)); + + }); + await Utils.sleep(2000); + getAbilityLabelFailure('[context_getAbilityLabel_test_0400]', mError); + done(); + }); + + /* + * @tc.number: context_getAbilityLabel_test_0500 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_getAbilityLabel_test_0500', 0, async function (done) { + console.info('[context_getAbilityLabel_test_0500] promise START'); + await Utils.sleep(1000); + let mData; + let mError = null; + var timeOldStamp = await Utils.getNowTime(); + await Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getAbilityLabel_test_0500]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_getAbilityLabel_test_0500] promise in '); + console.info('[context_getAbilityLabel_test_0500] promise data is: ' + JSON.stringify(data)); + }) + .catch((error) => { + mError = error; + console.info('[context_getAbilityLabel_test_0500] promise error is: ' + error); + }); + if (mError != null) { + getAbilityLabelFailure('[context_getAbilityLabel_test_0500]', mError); + } else { + getAbilityLabelSuccess('[context_getAbilityLabel_test_0500]', mData); + } + done(); + }); + + /* + * @tc.number: context_getAbilityLabel_test_0600 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by callbac) + * @tc.level 0 + */ + it('context_getAbilityLabel_test_0600', 0, async function (done) { + console.info('[context_getAbilityLabel_test_0600] callBack START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + let mError = null; + Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME, (error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getAbilityLabel_test_0600]', timeOldStamp, timeNewStamp); + mData = data; + mError = error; + console.info('[context_getAbilityLabel_test_0600] callBack in'); + console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error); + console.info('[context_getAbilityLabel_test_0600] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + if (mError != null) { + getAbilityLabelFailure('[context_getAbilityLabel_test_0600]', mError); + } else { + getAbilityLabelSuccess('[context_getAbilityLabel_test_0600]', mData); + } + done(); + }); + + + /* + * @tc.number: context_getAbilityLabel_test_0700 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by callbac) + * @tc.level 0 + */ + it('context_getAbilityLabel_test_0700', 0, async function (done) { + console.info('[context_getAbilityLabel_test_0700] callBack START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mError; + Bundle.getAbilityLabel(BUNDLE_NAME, SERVICE_ABILITY_NAME, (error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getAbilityLabel_test_0700]', timeOldStamp, timeNewStamp); + mError = error; + console.info('[context_getAbilityLabel_test_0700] callBack in'); + console.info('[context_getAbilityLabel_test_0700] callBack error: ' + error); + console.info('[context_getAbilityLabel_test_0700] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getAbilityLabelFailure('[context_getAbilityLabel_test_0700]', mError); + done(); + }); + + function getAbilityLabelSuccess(msg, data) { + console.log(msg + ' start ' + JSON.stringify(data)); + console.log(msg + ' result ' + data); + expect(typeof (data)).assertEqual('string'); + } + + function getAbilityLabelFailure(msg, error) { + console.log(msg + ' Failure '); + console.log(msg + ' error ' + JSON.stringify(error)); + expect(typeof (error)).assertEqual('number'); + } + + }) + +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetBundleGidsJsUnit.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetBundleGidsJsUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..012a6540985127047bc45a335d49918d0c49f3a7 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetBundleGidsJsUnit.test.ets @@ -0,0 +1,211 @@ +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index.ets'; +import Utils from './Utils'; +import Bundle from '@ohos.bundle'; + +const BUNDLE_NAME = 'com.open.harmony.packagemag' +const OTHER_BUNDLE_NAME = 'com.ohos.acepackage' +const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error' + +export default function bundleGidsJsUnit() { + describe('context_getBundleGids_test', function () { + beforeEach(async function (done) { + console.info('context_getBundleGids_test before each called'); + done() + }); + + afterEach(async function () { + await Utils.sleep(2000); + console.info('context_getBundleGids_test after each called'); + }); + + /* + * @tc.number: context_getBundleGids_test_0100 + * @tc.name: getBundleGids : Gets the lists of bundle with gids + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_getBundleGids_test_0100', 0, async function (done) { + console.info('[context_getBundleGids_test_0100] promise START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.getBundleGids(BUNDLE_NAME) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getBundleGids_test_0100]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_getBundleGids_test_0100] promise data is: ' + JSON.stringify(data)); + }) + .catch((error) => { + console.info('[context_getBundleGids_test_0100] promise error is: ' + error); + }); + getGidsSuccess('[context_getBundleGids_test_0100]', mData); + done(); + }); + + /* + * @tc.number: context_getBundleGids_test_0200 + * @tc.name: getBundleGids : Gets the lists of bundle with gids + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_getBundleGids_test_0200', 0, async function (done) { + console.info('[context_getBundleGids_test_0200] callBack START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.getBundleGids(BUNDLE_NAME, (error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getBundleGids_test_0200]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_getBundleGids_test_0200] callBack in'); + console.info('[context_getBundleGids_test_0200] callBack error: ' + error); + console.info('[context_getBundleGids_test_0200] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getGidsSuccess('[context_getBundleGids_test_0200]', mData); + done(); + }); + + /* + * @tc.number: context_getBundleGids_test_0300 + * @tc.name: getBundleGids : Gets the lists of bundle with gids + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_getBundleGids_test_0300', 0, async function (done) { + console.info('[context_getBundleGids_test_0300] promise START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mError; + await Bundle.getBundleGids(BUNDLE_NAME_ERROR) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getBundleGids_test_0300]', timeOldStamp, timeNewStamp); + console.info('[context_getBundleGids_test_0300] promise data is: ' + JSON.stringify(data)); + }) + .catch((error) => { + var timeNewStamp = Utils.getNowTime(); + mError = error; + Utils.getDurationTime('[context_getBundleGids_test_0300]', timeOldStamp, timeNewStamp); + console.info('[context_getBundleGids_test_0300] promise error is: ' + error); + }); + getGidsFailure('[context_getBundleGids_test_0300]', mError); + done(); + }); + + /* + * @tc.number: context_getBundleGids_test_0400 + * @tc.name: getBundleGids : Gets the lists of bundle with gids + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_getBundleGids_test_0400', 0, async function (done) { + console.info('[context_getBundleGids_test_0400] callBack START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mError; + Bundle.getBundleGids(BUNDLE_NAME_ERROR, (error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getBundleGids_test_0400]', timeOldStamp, timeNewStamp); + + mError = error; + console.info('[context_getBundleGids_test_0400] callBack in'); + console.info('[context_getBundleGids_test_0400] callBack error: ' + error); + console.info('[context_getBundleGids_test_0400] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getGidsFailure('[context_getBundleGids_test_0400]', mError); + done(); + }); + + /* + * @tc.number: context_getBundleGids_test_0500 + * @tc.name: getBundleGids : Gets the lists of bundle with gids + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_getBundleGids_test_0500', 0, async function (done) { + console.info('[context_getBundleGids_test_0500] promise START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + let mError; + await Bundle.getBundleGids(OTHER_BUNDLE_NAME) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getBundleGids_test_0500]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_getBundleGids_test_0500] promise data is: ' + JSON.stringify(data)); + }) + .catch((error) => { + mError = error; + console.info('[context_getBundleGids_test_0500] promise error is: ' + error); + }); + if (mError != null) { + getGidsFailure('[context_getBundleGids_test_0500]', mError); + } else { + getGidsSuccess('[context_getBundleGids_test_0500]', mData); + } + done(); + }); + + /* + * @tc.number: context_getBundleGids_test_0600 + * @tc.name: getBundleGids : Gets the lists of bundle with gids + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_getBundleGids_test_0600', 0, async function (done) { + console.info('[context_getBundleGids_test_0600] callBack START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + let mError = null; + Bundle.getBundleGids(OTHER_BUNDLE_NAME, (error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getBundleGids_test_0600]', timeOldStamp, timeNewStamp); + mData = data; + mError = error; + console.info('[context_getBundleGids_test_0600] callBack in'); + console.info('[context_getBundleGids_test_0600] callBack error: ' + error); + console.info('[context_getBundleGids_test_0600] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + if (mError != null) { + getGidsFailure('[context_getBundleGids_test_0600]', mError); + } else { + getGidsSuccess('[context_getBundleGids_test_0600]', mData); + } + done(); + }); + + function getGidsSuccess(msg, data) { + console.log(msg + ' start ' + JSON.stringify(data)); + for (var j = 0; j < data.length; j++) { + console.log(msg + 'data[' + j + '] : ' + data[j]); + expect((data[j] > 0)).assertEqual(true); + } + expect(Array.isArray(data)).assertEqual(true); + } + + function getGidsFailure(msg, error) { + console.log(msg + ' Failure '); + expect(typeof (error)).assertEqual('number'); + } + }) +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetabilityInfo.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetabilityInfo.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a4f4351cc752ae3265159d931d06eb39c503bf1 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetabilityInfo.test.ets @@ -0,0 +1,470 @@ +/** + * Copyright (c) 2021 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 {describe, beforeEach, afterEach, it, expect} from 'deccjsunit/index.ets'; +import Utils from './Utils'; +import bundleManager from '@ohos.bundle'; + +export default function GetabilityInfo() { + describe('GetabilityInfo', function () { + let bundleName = "com.open.harmony.packagemag"; + let abilityName = "com.open.harmony.packagemag.MainAbility"; + let bundleName_other = "com.ohos.acecollaboration"; + let abilityName_other = "com.ohos.acecollaboration.MainAbility"; + let bundleName1 = "com.harmony.packagemag"; + let abilityName1 = "com.harmony.packagemag1.MainAbility"; + + beforeEach(async function (done) { + console.info('GetabilityInfo before each called'); + done() + }); + + afterEach(async function () { + await Utils.sleep(2000); + console.info('GetabilityInfo after each called'); + }); + + /* + * @tc.number: bundle_getAllApplicationInfo_test_0100 + * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('bundle_GetabilityInfo_test_0100', 0, async function (done) { + console.info('[bundle_GetabilityInfo_test_0100] START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + bundleManager.getAbilityInfo(bundleName, abilityName) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('bundle_GetabilityInfo_test_0100', timeOldStamp, timeNewStamp) + console.info('[bundle_GetabilityInfo_test_0100] getApplicationInfo in '); + console.info('[bundle_GetabilityInfo_test_0100] getApplicationInfo promise data is: ' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("object"); + }).catch((error) => { + console.error('[bundle_GetabilityInfo_test_0100]Operation failed. Cause: ' + JSON.stringify(error)); + }) + var promise = await bundleManager.getAbilityInfo(bundleName, abilityName); + checkAbilityInfo(promise); + done(); + }); + + /* + * @tc.number: bundle_getAbilityInfo_test_0200 + * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('bundle_GetabilityInfo_test_0200', 0, async function (done) { + console.info('[bundle_GetabilityInfo_test_0200] START'); + await Utils.sleep(1000); + let mData; + var timeOldStamp = await Utils.getNowTime(); + await bundleManager.getAbilityInfo(bundleName, abilityName, (err, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('bundle_GetabilityInfo_test_0200', timeOldStamp, timeNewStamp) + if (err) { + console.error('[bundle_GetabilityInfo_test_0200]Operation failed. Cause: ' + JSON.stringify(err)); + } + console.info('[bundle_GetabilityInfo_test_0200] getApplicationInfo callback data is: ' + JSON.stringify(data)); + mData = data; + }) + await Utils.sleep(2000); + checkAbilityInfo(mData); + done(); + }); + + /* + * @tc.number: bundle_getAllApplicationInfo_test_0300 + * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('bundle_GetabilityInfo_test_0300', 0, async function (done) { + console.info('[bundle_GetabilityInfo_test_0300] START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let err = null + var mData + await bundleManager.getAbilityInfo(bundleName_other, abilityName_other) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('bundle_GetabilityInfo_test_0300',timeOldStamp,timeNewStamp) + mData = data + console.info('[bundle_GetabilityInfo_test_0300] getApplicationInfo in '); + console.info('[bundle_GetabilityInfo_test_0300] getApplicationInfo promise data is: ' + JSON.stringify(data)); + expect(mData).assertEqual(false); + }).catch((error) => { + err = error + console.error('[bundle_GetabilityInfo_test_0300]Operation failed. Cause: ' + JSON.stringify(error)); + }); + if(err != null) { + await expect(err).assertEqual(1); + }else{ + checkAbilityInfo_other(mData); + } + done(); + }); + + + /* + * @tc.number: bundle_getAllApplicationInfo_test_0400 + * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('bundle_GetabilityInfo_test_0400', 0, async function (done) { + console.info('[bundle_GetabilityInfo_test_0400] START'); + let error1; + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + bundleManager.getAbilityInfo(bundleName1, abilityName) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('bundle_GetabilityInfo_test_0400', timeOldStamp, timeNewStamp) + console.info('[bundle_GetabilityInfo_test_0400] getApplicationInfo in '); + console.info('[bundle_GetabilityInfo_test_0400] getApplicationInfo data is: ' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("object"); + }).catch((error) => { + console.error('[bundle_GetabilityInfo_test_0400]Operation failed. Cause: ' + JSON.stringify(error)); + error1 = error; + }) + await Utils.sleep(1000); + await expect(error1).assertEqual(1); + done(); + }); + + /* + * @tc.number: bundle_getAllApplicationInfo_test_0500 + * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('bundle_GetabilityInfo_test_0500', 0, async function (done) { + console.info('[bundle_GetabilityInfo_test_0500] START'); + let error + await bundleManager.getAbilityInfo(bundleName, abilityName1).then((data) => { + console.info('[bundle_GetabilityInfo_test_0500] START' + JSON.stringify(data)); + }).catch((err) => { + console.info('[bundle_GetabilityInfo_test_0500] err = ' + JSON.stringify(err)); + error = err + }) + expect(error).assertEqual(1); + done(); + console.info('[bundle_GetabilityInfo_test_0500] END'); + }); + + /* + * @tc.number: bundle_getAllApplicationInfo_test_0600 + * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + let bundleName2 = ""; + it('bundle_GetabilityInfo_test_0600', 0, async function (done) { + console.info('[bundle_GetabilityInfo_test_0600] START'); + let error1; + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + bundleManager.getAbilityInfo(bundleName2, abilityName) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('bundle_GetabilityInfo_test_0600', timeOldStamp, timeNewStamp) + console.info('[bundle_GetabilityInfo_test_0600] getApplicationInfo in '); + console.info('[bundle_GetabilityInfo_test_0600] getApplicationInfo data promise is: ' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("object"); + }).catch((error) => { + console.error('[bundle_GetabilityInfo_test_0600]Operation failed. Cause: ' + JSON.stringify(error)); + error1 = error; + }) + await Utils.sleep(1000); + await expect(error1).assertEqual(1); + done(); + }); + + + /** + * 打印AbilityInfo属性信息 + * @param data + */ + function checkAbilityInfo(data) { + console.log("checkAbilityInfo start " + JSON.stringify(data)); + console.log("checkAbilityInfo bundleName : " + data.bundleName); + console.log("checkAbilityInfo name : " + data.name); + console.log("checkAbilityInfo label : " + data.label); + console.log("checkAbilityInfo description : " + data.description); + console.log("checkAbilityInfo icon : " + data.icon); + console.log("checkAbilityInfo descriptionId : " + data.descriptionId); + console.log("checkAbilityInfo iconId : " + data.iconId); + console.log("checkAbilityInfo moduleName : " + data.moduleName); + console.log("checkAbilityInfo process : " + data.process); + console.log("checkAbilityInfo targetAbility : " + data.targetAbility); + console.log("checkAbilityInfo backgroundModes : " + data.backgroundModes); + console.log("checkAbilityInfo isVisible : " + data.isVisible); + console.log("checkAbilityInfo formEnabled : " + data.formEnabled); + console.log("checkAbilityInfo type : " + data.type) + console.log("checkAbilityInfo orientation : " + data.orientation); + console.log("checkAbilityInfo launchMode : " + data.launchMode); + console.log("checkAbilityInfo permissions length : " + data.permissions.length); + for (var j = 0; j < data.permissions.length; j++) { + console.log("getAbilityInfo data.permissions[" + j + "] : " + data.permissions[j]); + } + console.log("checkAbilityInfo deviceTypes length : " + data.deviceTypes.length); + for (var k = 0; k < data.deviceTypes.length; k++) { + console.log("getAbilityInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]); + } + console.log("checkAbilityInfo deviceCapabilities length : " + data.deviceCapabilities.length); + for (var i = 0; i < data.deviceCapabilities.length; i++) { + console.log("getAbilityInfo data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]); + } + console.log("checkAbilityInfo readPermission : " + data.readPermission); + console.log("checkAbilityInfo writePermission : " + data.writePermission); + console.log("checkAbilityInfo defaultFormWidth : " + data.defaultFormWidth); + console.log("checkAbilityInfo uri : " + data.uri); + console.log("checkAbilityInfo labelId : " + data.labelId); + console.log("checkAbilityInfo subType : " + data.subType); + expect(typeof (data.bundleName)).assertEqual("string"); + expect(typeof (data.name)).assertEqual("string"); + expect(data.label).assertEqual("$string:entry_MainAbility"); + expect(typeof (data.label)).assertEqual("string"); + expect(data.description).assertEqual("$string:mainability_description"); + expect(typeof (data.description)).assertEqual("string"); + expect(data.icon).assertEqual("$media:icon"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.srcPath)).assertEqual("string"); + expect(data.srcLanguage).assertEqual("ets"); + expect(typeof (data.srcLanguage)).assertEqual("string"); + expect(data.isVisible).assertEqual(true); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(typeof (data.process)).assertEqual("string"); + expect(typeof (data.uri)).assertEqual("string"); + expect(data.uri).assertEqual(""); + expect(typeof (data.uri)).assertEqual("string"); + expect(data.moduleName).assertEqual("entry"); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.applicationInfo)).assertEqual("object"); + expect(data.bundleName).assertEqual("com.open.harmony.packagemag") + expect(data.name).assertEqual("com.open.harmony.packagemag.MainAbility"); + checkApplicationInfo(data.applicationInfo); + console.log("---checkAbilityInfo End--- "); + } + + /** + * 打印ApplicationInfo属性信息 + * @param data + */ + function checkApplicationInfo(info) { + console.log("checkApplicationInfo getApplicationInfo : " + JSON.stringify(info)); + console.log("checkApplicationInfo name : " + info.name); + console.log("checkApplicationInfo description : " + info.description); + console.log("checkApplicationInfo descriptionId : " + info.descriptionId); + console.log("checkApplicationInfo systemApp : " + info.systemApp); + console.log("checkApplicationInfo enabled : " + info.enabled); + console.log("checkApplicationInfo label : " + info.label); + console.log("checkApplicationInfo labelId : " + info.labelId); + console.log("checkApplicationInfo icon : " + info.icon); + console.log("checkApplicationInfo process : " + info.process); + console.log("checkApplicationInfo supportedModes : " + info.supportedModes); + console.log("checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length); + for (var j = 0; j < info.moduleSourceDirs.length; j++) { + console.log("checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]); + } + console.log("checkApplicationInfo permissions length : " + info.permissions.length); + for (var j = 0; j < info.permissions.length; j++) { + console.log("checkApplicationInfo info.permissions[" + j + "] : " + info.permissions[j]); + } + console.log("checkApplicationInfo moduleInfos length : " + info.moduleInfos.length); + for (var j = 0; j < info.moduleInfos.length; j++) { + console.log("checkApplicationInfo info.moduleInfos[" + j + "].moduleName : " + info.moduleInfos[j].moduleName); + console.log("checkApplicationInfo info.moduleInfos[" + j + "].moduleSourceDir : " + info.moduleInfos[j].moduleSourceDir); + } + console.log("checkApplicationInfo entryDir : " + info.entryDir); + expect(typeof (info)).assertEqual("object") + expect(typeof (info.name)).assertEqual("string") + expect(typeof (info.codePath)).assertEqual("string") + expect(info.accessTokenId > 0).assertTrue() + expect(typeof (info.accessTokenId)).assertEqual("number") + expect(typeof (info.description)).assertEqual("string") + expect(info.description).assertEqual("$string:mainability_description") + expect(info.descriptionId > 0).assertTrue() + expect(typeof (info.descriptionId)).assertEqual("number") + expect(typeof (info.icon)).assertEqual("string") + expect(info.icon).assertEqual("$media:icon") + expect(info.iconId > 0).assertTrue() + expect(typeof (info.iconId)).assertEqual("number") + expect(typeof (info.label)).assertEqual("string") + expect(info.label).assertEqual("$string:entry_MainAbility") + expect(info.labelId > 0).assertTrue() + expect(typeof (info.labelId)).assertEqual("number") + expect(info.systemApp).assertEqual(true) + expect(typeof (info.entryDir)).assertEqual("string") + expect(info.supportedModes).assertEqual(0) + expect(typeof (info.supportedModes)).assertEqual("number") + expect(typeof (info.process)).assertEqual("string") + expect(info.process).assertEqual("") + expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true); + expect(info.entryDir) + .assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag/com.open.harmony.packagemag"); + expect(Array.isArray(info.permissions)).assertEqual(true); + expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag"); + expect(info.moduleSourceDirs[0]) + .assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag/com.open.harmony.packagemag"); + expect(info.enabled).assertEqual(true); + expect(info.flags).assertEqual(0); + expect(info.uid > 0).assertTrue() + expect(info.entityType).assertEqual("unspecified"); + expect(info.removable).assertEqual(true); + expect(info.accessTokenId > 0).assertTrue() + } + + /** + * 打印ApplicationInfo属性信息 + * @param data + */ + function checkAbilityInfo_other(data) { + console.log("checkAbilityInfo start " + JSON.stringify(data)); + console.log("checkAbilityInfo bundleName : " + data.bundleName); + console.log("checkAbilityInfo name : " + data.name); + console.log("checkAbilityInfo label : " + data.label); + console.log("checkAbilityInfo description : " + data.description); + console.log("checkAbilityInfo icon : " + data.icon); + console.log("checkAbilityInfo descriptionId : " + data.descriptionId); + console.log("checkAbilityInfo iconId : " + data.iconId); + console.log("checkAbilityInfo moduleName : " + data.moduleName); + console.log("checkAbilityInfo process : " + data.process); + console.log("checkAbilityInfo targetAbility : " + data.targetAbility); + console.log("checkAbilityInfo backgroundModes : " + data.backgroundModes); + console.log("checkAbilityInfo isVisible : " + data.isVisible); + console.log("checkAbilityInfo formEnabled : " + data.formEnabled); + console.log("checkAbilityInfo type : " + data.type) + console.log("checkAbilityInfo orientation : " + data.orientation); + console.log("checkAbilityInfo launchMode : " + data.launchMode); + console.log("checkAbilityInfo permissions length : " + data.permissions.length); + for (var j = 0; j < data.permissions.length; j++) { + console.log("getAbilityInfo data.permissions[" + j + "] : " + data.permissions[j]); + } + console.log("checkAbilityInfo deviceTypes length : " + data.deviceTypes.length); + for (var k = 0; k < data.deviceTypes.length; k++) { + console.log("getAbilityInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]); + } + console.log("checkAbilityInfo deviceCapabilities length : " + data.deviceCapabilities.length); + for (var i = 0; i < data.deviceCapabilities.length; i++) { + console.log("getAbilityInfo data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]); + } + console.log("checkAbilityInfo readPermission : " + data.readPermission); + console.log("checkAbilityInfo writePermission : " + data.writePermission); + console.log("checkAbilityInfo defaultFormWidth : " + data.defaultFormWidth); + console.log("checkAbilityInfo uri : " + data.uri); + console.log("checkAbilityInfo labelId : " + data.labelId); + console.log("checkAbilityInfo subType : " + data.subType); + expect(typeof (data.bundleName)).assertEqual("string"); + expect(typeof (data.name)).assertEqual("string"); + expect(data.label).assertEqual("$string:entry_MainAbility"); + expect(typeof (data.label)).assertEqual("string"); + expect(data.description).assertEqual("$string:mainability_description"); + expect(typeof (data.description)).assertEqual("string"); + expect(data.icon).assertEqual("$media:icon"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.srcPath)).assertEqual("string"); + expect(data.srcLanguage).assertEqual("ets"); + expect(typeof (data.srcLanguage)).assertEqual("string"); + expect(data.isVisible).assertEqual(true); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(typeof (data.process)).assertEqual("string"); + expect(typeof (data.uri)).assertEqual("string"); + expect(data.uri).assertEqual(""); + expect(typeof (data.uri)).assertEqual("string"); + expect(data.moduleName).assertEqual("entry"); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.applicationInfo)).assertEqual("object"); + expect(data.bundleName).assertEqual("com.ohos.acecollaboration"); + expect(data.name).assertEqual("com.ohos.acecollaboration.MainAbility"); + checkApplicationInfo_other(data.applicationInfo); + console.log("---checkAbilityInfo End--- "); + } + + /** + * 打印ApplicationInfo属性信息 + * @param data + */ + function checkApplicationInfo_other(info) { + console.log("checkApplicationInfo getApplicationInfo : " + JSON.stringify(info)); + console.log("checkApplicationInfo name : " + info.name); + console.log("checkApplicationInfo description : " + info.description); + console.log("checkApplicationInfo descriptionId : " + info.descriptionId); + console.log("checkApplicationInfo systemApp : " + info.systemApp); + console.log("checkApplicationInfo enabled : " + info.enabled); + console.log("checkApplicationInfo label : " + info.label); + console.log("checkApplicationInfo labelId : " + info.labelId); + console.log("checkApplicationInfo icon : " + info.icon); + console.log("checkApplicationInfo process : " + info.process); + console.log("checkApplicationInfo supportedModes : " + info.supportedModes); + console.log("checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length); + for (var j = 0; j < info.moduleSourceDirs.length; j++) { + console.log("checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]); + } + console.log("checkApplicationInfo permissions length : " + info.permissions.length); + for (var j = 0; j < info.permissions.length; j++) { + console.log("checkApplicationInfo info.permissions[" + j + "] : " + info.permissions[j]); + } + console.log("checkApplicationInfo moduleInfos length : " + info.moduleInfos.length); + for (var j = 0; j < info.moduleInfos.length; j++) { + console.log("checkApplicationInfo info.moduleInfos[" + j + "].moduleName : " + info.moduleInfos[j].moduleName); + console.log("checkApplicationInfo info.moduleInfos[" + j + "].moduleSourceDir : " + info.moduleInfos[j].moduleSourceDir); + } + console.log("checkApplicationInfo entryDir : " + info.entryDir); + expect(typeof (info)).assertEqual("object") + expect(typeof (info.name)).assertEqual("string") + expect(typeof (info.codePath)).assertEqual("string") + expect(info.accessTokenId > 0).assertTrue() + expect(typeof (info.accessTokenId)).assertEqual("number") + expect(typeof (info.description)).assertEqual("string") + expect(info.description).assertEqual("$string:mainability_description") + expect(info.descriptionId > 0).assertTrue() + expect(typeof (info.descriptionId)).assertEqual("number") + expect(typeof (info.icon)).assertEqual("string") + expect(info.icon).assertEqual("$media:icon") + expect(info.iconId > 0).assertTrue() + expect(typeof (info.iconId)).assertEqual("number") + expect(typeof (info.label)).assertEqual("string") + expect(info.label).assertEqual("$string:entry_MainAbility") + expect(info.labelId > 0).assertTrue() + expect(typeof (info.labelId)).assertEqual("number") + expect(info.systemApp).assertEqual(true) + expect(typeof (info.entryDir)).assertEqual("string") + expect(info.supportedModes).assertEqual(0) + expect(typeof (info.supportedModes)).assertEqual("number") + expect(typeof (info.process)).assertEqual("string") + expect(info.process).assertEqual("") + expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true); + expect(info.entryDir) + .assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration/com.ohos.acecollaboration"); + expect(Array.isArray(info.permissions)).assertEqual(true); + expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration"); + expect(info.moduleSourceDirs[0]) + .assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration/com.ohos.acecollaboration"); + expect(info.enabled).assertEqual(true); + expect(info.flags).assertEqual(0); + expect(info.uid > 0).assertTrue() + expect(info.entityType).assertEqual("unspecified"); + expect(info.removable).assertEqual(true); + expect(info.accessTokenId > 0).assertTrue() + } + }); +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsAbilityEnabledETSUnit.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsAbilityEnabledETSUnit.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a6a21aa24850d74b21efec62c8598221933e526 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsAbilityEnabledETSUnit.ets @@ -0,0 +1,313 @@ +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index.ets'; +import Utils from './Utils'; +import Bundle from '@ohos.bundle'; + +const BUNDLE_NAME = 'com.open.harmony.packagemag' +const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility' + +const ABILITY = { + bundleName: BUNDLE_NAME, + name: ABILITY_NAME +} + +const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error' +const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility' + +const ABILITY_ERROR = { + bundleName: BUNDLE_NAME_ERROR, + name: ABILITY_NAME_ERROR +} + +export default function isAbilityEnabledETSUnit() { + describe('context_isAbilityEnabled_test', function () { + beforeEach(async function (done) { + console.info('context_isAbilityEnabled_test before each called'); + done() + }); + + afterEach(async function () { + await Utils.sleep(2000); + console.info('context_isAbilityEnabled_test after each called'); + }); + + /* + * @tc.number: context_isAbilityEnabled_test_0100 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0100', 0, async function (done) { + console.info('[context_isAbilityEnabled_test_0100] promise START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.isAbilityEnabled(ABILITY) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0100]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0100] promise in '); + console.info('[context_isAbilityEnabled_test_0100] promise data is: ' + JSON.stringify(data)); + }) + .catch((error) => { + console.info('[context_isAbilityEnabled_test_0100] promise error is: ' + error); + }); + getAbilityEnabledSuccess('[context_isAbilityEnabled_test_0100]', mData); + done(); + }); + + /* + * @tc.number: context_isAbilityEnabled_test_0200 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0200', 0, async function (done) { + console.info('[context_isAbilityEnabled_test_0200] callBack START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.isAbilityEnabled(ABILITY, (error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0200]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0200] callBack in'); + console.info('[context_isAbilityEnabled_test_0200] callBack error: ' + error); + console.info('[context_isAbilityEnabled_test_0200] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getAbilityEnabledSuccess('[context_isAbilityEnabled_test_0200]', mData); + done(); + }); + + /* + * @tc.number: context_isAbilityEnabled_test_0300 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0300', 0, async function (done) { + console.info('[context_isAbilityEnabled_test_0300] promise START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.isAbilityEnabled(ABILITY_ERROR) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0300] promise in '); + console.info('[context_isAbilityEnabled_test_0300] promise data is: ' + JSON.stringify(data)); + }) + .catch((error) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp); + console.info('[context_isAbilityEnabled_test_0300] promise error is: ' + error); + }); + getAbilityEnabledFalse('[context_isAbilityEnabled_test_0300]', mData); + done(); + }); + + /* + * @tc.number: context_isAbilityEnabled_test_0400 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0400', 0, async function (done) { + console.info('[context_isAbilityEnabled_test_0400] callBack START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + console.info('[context_isAbilityEnabled_test_0400] start c++ callBack '); + Bundle.isAbilityEnabled(ABILITY_ERROR, (error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp); + console.info('[context_isAbilityEnabled_test_0400] callBack in'); + mData = data; + console.info('[context_isAbilityEnabled_test_0400] callBack error: ' + error); + console.info('[context_isAbilityEnabled_test_0400] callBack data is:' + JSON.stringify(data)); + }); + console.info('[context_isAbilityEnabled_test_0400] end c++ callBack '); + await Utils.sleep(2000); + console.info('[context_isAbilityEnabled_test_0400] Failure '); + getAbilityEnabledFalse('[context_isAbilityEnabled_test_0300]', mData); + done(); + }); + + + /* + * @tc.number: context_isAbilityEnabled_test_0500 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0500', 0, async function (done) { + console.info('[context_isAbilityEnabled_test_0500] promise START'); + await Utils.sleep(1000); + + await Bundle.setAbilityEnabled(ABILITY, true) + .then((data) => { + console.info('[context_isAbilityEnabled_test_0500] set enable true '); + console.info('[context_isAbilityEnabled_test_0500] set enable true data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isAbilityEnabled_test_0500] set enable true error is: ' + error); + }) + + var timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.isAbilityEnabled(ABILITY) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0500]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0500] promise in '); + console.info('[context_isAbilityEnabled_test_0500] promise data is: ' + JSON.stringify(data)); + }) + .catch((error) => { + console.info('[context_isAbilityEnabled_test_0500] promise error is: ' + error); + }); + getAbilityEnabledTrue('[context_isAbilityEnabled_test_0500]', mData); + done(); + }); + + /* + * @tc.number: context_isAbilityEnabled_test_0600 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0600', 0, async function (done) { + console.info('[context_isAbilityEnabled_test_0600] promise START'); + await Utils.sleep(1000); + + await Bundle.setAbilityEnabled(ABILITY, false) + .then((data) => { + console.info('[context_isAbilityEnabled_test_0600] set enable false '); + console.info('[context_isAbilityEnabled_test_0600] set enable false data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isAbilityEnabled_test_0600] set enable false error is: ' + error); + }) + + var timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.isAbilityEnabled(ABILITY) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0600]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0600] promise in '); + console.info('[context_isAbilityEnabled_test_0600] promise data is: ' + JSON.stringify(data)); + }) + .catch((error) => { + console.info('[context_isAbilityEnabled_test_0600] promise error is: ' + error); + }); + getAbilityEnabledFalse('[context_isAbilityEnabled_test_0600]', mData); + done(); + }); + + /* + * @tc.number: context_isAbilityEnabled_test_0700 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0700', 0, async function (done) { + console.info('[context_isAbilityEnabled_test_0700] callBack START'); + await Utils.sleep(1000); + + await Bundle.setAbilityEnabled(ABILITY, true) + .then((data) => { + console.info('[context_isAbilityEnabled_test_0700] set enable true '); + console.info('[context_isAbilityEnabled_test_0700] set enable true data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isAbilityEnabled_test_0700] set enable true error is: ' + error); + }) + + var timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.isAbilityEnabled(ABILITY, (error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0700]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0700] callBack in'); + console.info('[context_isAbilityEnabled_test_0700] callBack error: ' + error); + console.info('[context_isAbilityEnabled_test_0700] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getAbilityEnabledTrue('[context_isAbilityEnabled_test_0700]', mData); + done(); + }); + + /* + * @tc.number: context_isAbilityEnabled_test_0800 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0800', 0, async function (done) { + console.info('[context_isAbilityEnabled_test_0800] callBack START'); + await Utils.sleep(1000); + + await Bundle.setAbilityEnabled(ABILITY, false) + .then((data) => { + console.info('[context_isAbilityEnabled_test_0800] set enable false '); + console.info('[context_isAbilityEnabled_test_0800] set enable false data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isAbilityEnabled_test_0800] set enable false error is: ' + error); + }) + + var timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.isAbilityEnabled(ABILITY, (error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0800]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0800] callBack in'); + console.info('[context_isAbilityEnabled_test_0800] callBack error: ' + error); + console.info('[context_isAbilityEnabled_test_0800] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getAbilityEnabledFalse('[context_isAbilityEnabled_test_0800]', mData); + done(); + }); + + + function getAbilityEnabledSuccess(msg, data) { + console.log(msg + ' start ' + JSON.stringify(data)); + console.log(msg + ' data : ' + data); + expect(typeof (data)).assertEqual('boolean') + } + + function getAbilityEnabledTrue(msg, data) { + getAbilityEnabledSuccess(msg, data); + expect(data).assertEqual(true); + } + + function getAbilityEnabledFalse(msg, data) { + getAbilityEnabledSuccess(msg, data); + expect(data).assertEqual(false); + } + + function getAbilityEnabledFailure(msg, error) { + console.log(msg + ' Failure '); + console.log(msg + ' error : ' + error); + expect(typeof (error)).assertEqual('number') + } + + }) +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsApplicationEnabledETSUnit.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsApplicationEnabledETSUnit.ets new file mode 100644 index 0000000000000000000000000000000000000000..d99b7b821bb0b99381c3dc6e274408932688ee42 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsApplicationEnabledETSUnit.ets @@ -0,0 +1,221 @@ +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index.ets'; +import Utils from './Utils'; +import Bundle from '@ohos.bundle'; + +const BUNDLE_NAME = 'com.open.harmony.packagemag' + +const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error' + +export default function IsApplicationEnabledETSUnit() { + describe('context_isApplicationEnabled_test', function () { + beforeEach(async function (done) { + console.info('context_isApplicationEnabled_test before each called'); + done() + }); + + afterEach(async function () { + await Utils.sleep(2000); + console.info('context_isApplicationEnabled_test after each called'); + }); + + /* + * @tc.number: context_isApplicationEnabled_test_0100 + * @tc.name: isApplicationEnabled : Get whether to enable a specified application + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_isApplicationEnabled_test_0100', 0, async function (done) { + console.info('[context_isApplicationEnabled_test_0100] promise START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.isApplicationEnabled(BUNDLE_NAME) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isApplicationEnabled_test_0100]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isApplicationEnabled_test_0100] promise in '); + console.info('[context_isApplicationEnabled_test_0100] promise data is: ' + JSON.stringify(data)); + }) + .catch((error) => { + console.info('[context_isApplicationEnabled_test_0100] promise error is: ' + error); + }); + getApplicationEnabledSuccess('[context_isApplicationEnabled_test_0100]', mData); + done(); + }); + + /* + * @tc.number: context_isApplicationEnabled_test_0200 + * @tc.name: isApplicationEnabled : Get whether to enable a specified application + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_isApplicationEnabled_test_0200', 0, async function (done) { + console.info('[context_isApplicationEnabled_test_0200] callBack START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isApplicationEnabled_test_0200]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isApplicationEnabled_test_0200] callBack in'); + console.info('[context_isApplicationEnabled_test_0200] callBack error: ' + error); + console.info('[context_isApplicationEnabled_test_0200] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getApplicationEnabledSuccess('[context_isApplicationEnabled_test_0200]', mData); + done(); + }); + + /* + * @tc.number: context_isApplicationEnabled_test_0300 + * @tc.name: isApplicationEnabled : Get whether to enable a specified application + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_isApplicationEnabled_test_0300', 0, async function (done) { + console.info('[context_isApplicationEnabled_test_0300] promise START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isApplicationEnabled_test_0300]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isApplicationEnabled_test_0300] promise in '); + console.info('[context_isApplicationEnabled_test_0300] promise data is: ' + JSON.stringify(data)); + }) + .catch((error) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isApplicationEnabled_test_0300]', timeOldStamp, timeNewStamp); + console.info('[context_isApplicationEnabled_test_0300] promise error is: ' + error); + }); + getApplicationEnabledFalse('[context_isApplicationEnabled_test_0300]', mData); + done(); + }); + + /* + * @tc.number: context_isApplicationEnabled_test_0400 + * @tc.name: isApplicationEnabled : Get whether to enable a specified application + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_isApplicationEnabled_test_0400', 0, async function (done) { + console.info('[context_isApplicationEnabled_test_0400] callBack START'); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR, (error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isApplicationEnabled_test_0400]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isApplicationEnabled_test_0400] callBack in'); + console.info('[context_isApplicationEnabled_test_0400] callBack error: ' + error); + console.info('[context_isApplicationEnabled_test_0400] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getApplicationEnabledFalse('[context_isApplicationEnabled_test_0300]', mData); + console.info('[context_isApplicationEnabled_test_0400] Failure '); + done(); + }); + + /* + * @tc.number: context_isApplicationEnabled_test_0500 + * @tc.name: isApplicationEnabled : Get whether to enable a specified application + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_isApplicationEnabled_test_0500', 0, async function (done) { + console.info('[context_isApplicationEnabled_test_0500] promise START'); + + await Bundle.setApplicationEnabled(BUNDLE_NAME, true) + .then((data) => { + console.info('[context_isApplicationEnabled_test_0500] set enable true '); + console.info('[context_isApplicationEnabled_test_0500] set enable true data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isApplicationEnabled_test_0500] set enable true error is: ' + error); + }); + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.isApplicationEnabled(BUNDLE_NAME) + .then((data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isApplicationEnabled_test_0500]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isApplicationEnabled_test_0500] promise in '); + console.info('[context_isApplicationEnabled_test_0500] promise data is: ' + JSON.stringify(data)); + }) + .catch((error) => { + console.info('[context_isApplicationEnabled_test_0500] promise error is: ' + error); + }); + getApplicationEnabledTrue('[context_isApplicationEnabled_test_0500]', mData); + done(); + }); + + /* + * @tc.number: context_isApplicationEnabled_test_0600 + * @tc.name: isApplicationEnabled : Get whether to enable a specified application + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_isApplicationEnabled_test_0600', 0, async function (done) { + console.info('[context_isApplicationEnabled_test_0600] callBack START'); + + await Bundle.setApplicationEnabled(BUNDLE_NAME, false) + .then((data) => { + console.info('[context_isApplicationEnabled_test_0600] set enable false '); + console.info('[context_isApplicationEnabled_test_0600] set enable false data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isApplicationEnabled_test_0600] set enable false error is: ' + error); + }); + + await Utils.sleep(1000); + var timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => { + var timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isApplicationEnabled_test_0600]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isApplicationEnabled_test_0600] callBack in'); + console.info('[context_isApplicationEnabled_test_0600] callBack error: ' + error); + console.info('[context_isApplicationEnabled_test_0600] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getApplicationEnabledFalse('[context_isApplicationEnabled_test_0600]', mData); + done(); + }); + + function getApplicationEnabledSuccess(msg, data) { + console.log(msg + ' start ' + JSON.stringify(data)); + console.log(msg + ' data : ' + data); + expect(typeof (data)).assertEqual('boolean') + } + + function getApplicationEnabledTrue(msg, data) { + getApplicationEnabledSuccess(msg, data); + expect(data).assertEqual(true); + } + + function getApplicationEnabledFalse(msg, data) { + getApplicationEnabledSuccess(msg, data); + expect(data).assertEqual(false); + } + }) +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a962e2f545a3794aabd7f61f090ee348f378d97d --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2021 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 getabilityInfo from './GetabilityInfo.test.ets'; +import getApplicationInfoJsunit from './getApplicationInfoJsunit.test.ets'; +import getAllAppInfoJsunit from './getAllApplicationInfoJsunit.test.ets'; +import getAbilityLabelJsUnit from "./GetAbilityLabelJsUnit.test.ets"; +import isAbilityEnableETSUnit from "./IsAbilityEnabledETSUnit.ets"; +import isApplicationEnabledETSUnit from "./IsApplicationEnabledETSUnit.ets"; + +export default function testsuite() { + //RM.007 + getApplicationInfoJsunit(); + getAllAppInfoJsunit(); + //RM.006 + getabilityInfo(); + //RM.014 + getAbilityLabelJsUnit(); + //RM.017 + isAbilityEnableETSUnit(); + isApplicationEnabledETSUnit(); +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/Utils.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d9553a5c660be0a6ae524110f2dd4a6477abfd6 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,130 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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. + */ + +export default class Utils { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } + + static async swipe(downX, downY, upX, upY, steps) { + console.info('start to swipe') + this.drags(downX, downY, upX, upY, steps, false) + } + + static async drag(downX, downY, upX, upY, steps) { + console.info('start to drag') + this.drags(downX, downY, upX, upY, steps, true) + } + + static async drags(downX, downY, upX, upY, steps, drag) { + var xStep; + var yStep; + var swipeSteps; + var ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + var downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('start to move') + if (drag) { + await this.sleep(500) + } + for (var i = 1;i <= swipeSteps; i++) { + var movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('start to up') + if (drag) { + await this.sleep(100) + } + var upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) + } + + static getNowTime() { + return new Date().getTime(); + } + + static getDurationTime(log,startTime, endTime) { + console.info("Get Interface startTime: " + startTime); + console.info("Get Interface endTime: " + endTime); + var duration = (endTime - startTime); + console.info("Get Interface duration: " + duration); + return duration; + } +} + + + + diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getAllApplicationInfoJsunit.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getAllApplicationInfoJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c35fbbc138434cfccc26003a679b291cb5fd66eb --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getAllApplicationInfoJsunit.test.ets @@ -0,0 +1,404 @@ +/** + * Copyright (c) 2021 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 {describe, beforeEach, afterEach, it, expect} from 'deccjsunit/index.ets'; +import Utils from './Utils'; +import Bundle from '@ohos.bundle'; + +const TAG_TEST_0100_001 = ' bundle_getAllApplicationInfo_test_0100_001 '; +const TAG_TEST_0100_002 = ' bundle_getAllApplicationInfo_test_0100_002 '; +const TAG_TEST_0100_003 = ' bundle_getAllApplicationInfo_test_0100_003 '; +const TAG_TEST_0200_001 = ' bundle_getAllApplicationInfo_test_0200_004 '; +const TAG_TEST_0200_002 = ' bundle_getAllApplicationInfo_test_0200_005 '; +const TAG_TEST_0200_003 = ' bundle_getAllApplicationInfo_test_0200_006 '; +const TAG_TEST_0300_001 = ' bundle_getAllApplicationInfo_test_0300_007 '; +const TAG_TEST_0400_001 = ' bundle_getAllApplicationInfo_test_0400_008 '; +const TAG_TEST_0500_001 = ' bundle_getAllApplicationInfo_test_0500_009 '; +const TAG_TEST_0500_002 = ' bundle_getAllApplicationInfo_test_0500_0010 '; +const USER_ID_100 = 100; +const SLEEP_TIME_1000 = 1000; +const SLEEP_TIME_2000 = 2000; + +export default function applicationBundleJsunit() { + describe('appInfoTest', function () { + beforeEach(async function (done) { + console.info('applicationBundle before each called'); + done() + }); + + afterEach(async function () { + await Utils.sleep(SLEEP_TIME_2000); + console.info('applicationBundle after each called'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0100_001 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0100_001, 0, async function (done) { + console.info(TAG_TEST_0100_001 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + var startTime = await Utils.getNowTime(); + let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100) + .catch((error) => { + console.info(TAG_TEST_0100_001 + 'UserId promise error is: ' + error); + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0100_001, startTime, endTime); + console.info(TAG_TEST_0100_001 + ' UserId promise data is: ' + JSON.stringify(data)); + commonTest(TAG_TEST_0100_001, data) + getApplicationInfoSuccess(TAG_TEST_0100_001, data); + done(); + console.log('------------------ ' + TAG_TEST_0100_001 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0100_002 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0100_002, 0, async function (done) { + console.info(TAG_TEST_0100_002 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + var startTime = await Utils.getNowTime(); + let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_ALL_APPLICATION_INFO, USER_ID_100) + .catch((error) => { + console.info(TAG_TEST_0100_002 + 'UserId promise error is: ' + error); + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0100_002, startTime, endTime); + console.info(TAG_TEST_0100_002 + ' UserId promise data is: ' + JSON.stringify(data)); + commonTest(TAG_TEST_0100_002, data) + getApplicationInfoSuccess(TAG_TEST_0100_002, data); + done(); + console.log('------------------ ' + TAG_TEST_0100_002 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0100_003 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0100_003, 0, async function (done) { + console.info(TAG_TEST_0100_003 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + var startTime = await Utils.getNowTime(); + let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE, USER_ID_100) + .catch((error) => { + console.info(TAG_TEST_0100_003 + 'UserId promise error is: ' + error); + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0100_003, startTime, endTime); + console.info(TAG_TEST_0100_003 + ' UserId promise data is: ' + JSON.stringify(data)); + commonTest(TAG_TEST_0100_003, data) + getApplicationInfoSuccess(TAG_TEST_0100_003, data); + done(); + console.log('------------------ ' + TAG_TEST_0100_003 + ' end -------------------'); + }); + + + /** + * @tc.number: bundle_getApplicationInfo_test_0200_004 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0200_001, 0, async function (done) { + console.info(TAG_TEST_0200_001 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + var startTime = await Utils.getNowTime(); + let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION) + .catch((error) => { + console.info(TAG_TEST_0200_001 + 'onUserId promise error is: ' + error); + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0200_001, startTime, endTime); + console.info(TAG_TEST_0200_001 + ' onUserId promise data is: ' + JSON.stringify(data)); + commonTest(TAG_TEST_0200_001, data) + getApplicationInfoSuccess(TAG_TEST_0200_001, data); + done(); + console.log('------------------ ' + TAG_TEST_0200_001 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0200_005 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0200_002, 0, async function (done) { + console.info(TAG_TEST_0200_002 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + var startTime = await Utils.getNowTime(); + let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_ALL_APPLICATION_INFO) + .catch((error) => { + console.info(TAG_TEST_0200_002 + 'onUserId promise error is: ' + error); + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0200_002, startTime, endTime); + console.info(TAG_TEST_0200_002 + ' onUserId promise data is: ' + JSON.stringify(data)); + commonTest(TAG_TEST_0200_002, data) + getApplicationInfoSuccess(TAG_TEST_0200_002, data); + done(); + console.log('------------------ ' + TAG_TEST_0200_002 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0200_006 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0200_003, 0, async function (done) { + console.info(TAG_TEST_0200_003 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + var startTime = await Utils.getNowTime(); + let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE) + .catch((error) => { + console.info(TAG_TEST_0200_003 + 'onUserId promise error is: ' + error); + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0200_003, startTime, endTime); + console.info(TAG_TEST_0200_003 + ' onUserId promise data is: ' + JSON.stringify(data)); + commonTest(TAG_TEST_0200_003, data) + getApplicationInfoSuccess(TAG_TEST_0200_003, data); + done(); + console.log('------------------ ' + TAG_TEST_0200_003 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0300_007 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by callBack) + * @tc.level 0 + */ + it(TAG_TEST_0300_001, 0, async function (done) { + console.info(TAG_TEST_0300_001 + 'callBack START'); + await Utils.sleep(SLEEP_TIME_1000); + let datas; + var startTime = await Utils.getNowTime(); + Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100, + (error, data) => { + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0300_001, startTime, endTime); + console.info(TAG_TEST_0300_001 + 'UserId callBack in'); + console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error); + console.info(TAG_TEST_0300_001 + 'UserId callBack data is:' + JSON.stringify(data)); + datas = data; + }); + await Utils.sleep(2000); + console.info(TAG_TEST_0300_001 + 'UserId callBack datas is:' + JSON.stringify(datas)); + commonTest(TAG_TEST_0300_001, datas) + getApplicationInfoSuccess(TAG_TEST_0300_001, datas); + done(); + console.log('------------------ ' + TAG_TEST_0300_001 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0400_008 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by callBack) + * @tc.level 0 + */ + it(TAG_TEST_0400_001, 0, async function (done) { + console.info(TAG_TEST_0400_001 + 'callBack START'); + let datas; + var startTime = await Utils.getNowTime(); + Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, (error, data) => { + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0400_001, startTime, endTime); + console.info(TAG_TEST_0400_001 + 'noUserId callBack in'); + console.info(TAG_TEST_0400_001 + 'noUserId callBack error: ' + error); + console.info(TAG_TEST_0400_001 + 'noUserId callBack data is:' + JSON.stringify(data)); + datas = data; + }); + await Utils.sleep(2000); + console.info(TAG_TEST_0400_001 + 'noUserId callBack datas is:' + JSON.stringify(datas)); + commonTest(TAG_TEST_0400_001, datas) + getApplicationInfoSuccess(TAG_TEST_0400_001, datas); + done(); + console.log('------------------ ' + TAG_TEST_0400_001 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0500_009 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0500_001, 0, async function (done) { + console.info(TAG_TEST_0500_001 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + let errors; + var startTime = await Utils.getNowTime(); + let data = await Bundle.getAllApplicationInfo('0') + .catch((error) => { + console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error); + errors = error; + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime); + console.info(TAG_TEST_0500_001 + ' noUserId promise data is: ' + JSON.stringify(data)); + expect(errors).assertEqual(1); + done(); + console.log('------------------ ' + TAG_TEST_0500_001 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0500_0010 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0500_002, 0, async function (done) { + console.info(TAG_TEST_0500_002 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + let errors; + var startTime = await Utils.getNowTime(); + let data = await Bundle.getAllApplicationInfo('0', USER_ID_100) + .catch((error) => { + console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error); + errors = error; + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime); + console.info(TAG_TEST_0500_002 + ' UserId promise data is: ' + JSON.stringify(data)); + expect(errors).assertEqual(1); + done(); + console.log('------------------ ' + TAG_TEST_0500_002 + ' end -------------------'); + }); + + /** + * 打印单个属性 + * @param msg log信息 + * @param data 数据源 + */ + function commonTest(msg, data) { + console.info(msg + 'commonTest data length [' + data.length + ']'); + for (var i = 0; i < data.length; i++) { + console.info(msg + i + ' [ + data[i] + ] :' + JSON.stringify(data[i])); + console.info(msg + '[' + i + '].name:' + data[i].name); + console.info(msg + '[' + i + '].codePath:' + data[i].codePath); + console.info(msg + '[' + i + '].accessTokenId:' + data[i].accessTokenId); + console.info(msg + '[' + i + '].description:' + data[i].description); + console.info(msg + '[' + i + '].descriptionId:' + data[i].descriptionId); + console.info(msg + '[' + i + '].icon:' + data[i].icon); + console.info(msg + '[' + i + '].iconId:' + data[i].iconId); + console.info(msg + '[' + i + '].label:' + data[i].label); + console.info(msg + '[' + i + '].labelId:' + data[i].labelId); + console.info(msg + '[' + i + '].systemApp:' + data[i].systemApp); + console.info(msg + '[' + i + '].supportedModes:' + data[i].supportedModes); + console.info(msg + '[' + i + '].process:' + data[i].process); + console.info(msg + '[' + i + '].entryDir:' + data[i].entryDir); + console.info('getAllApplicationInfo Async permissions length [' + data[i].permissions.length + ']'); + for (var j = 0; j < data[i].permissions.length; j++) { + console.info(msg + '[' + i + ']permissions[' + j + ']:' + data[i].permissions[j]); + } + console.info('getAllApplicationInfo Async moduleSourceDirs length [' + data[i].moduleSourceDirs.length + ']'); + for (var l = 0; l < data[i].moduleSourceDirs.length; l++) { + console.info(msg + '[' + i + ']moduleSourceDirs[' + l + ']:' + data[i].moduleSourceDirs[l]); + } + console.info('getAllApplicationInfo Async moduleInfos length [' + data[i].moduleInfos.length + ']'); + for (var k = 0; k < data[i].moduleInfos.length; k++) { + console.info(msg + '[' + i + ']moduleInfos[' + k + ']moduleName:' + data[i].moduleInfos[k].moduleName); + console.info(msg + '[' + i + ']moduleInfos[' + k + ']moduleSourceDir:' + data[i].moduleInfos[k].moduleSourceDir); + } + console.info(msg + '[' + i + '].metaData:' + data[i].metaData); + console.info(msg + '[' + i + '].metadata:' + data[i].metadata); + console.info(msg + '[' + i + '].enabled:' + data[i].enabled); + console.info(msg + '[' + i + '].flags:' + data[i].flags); + console.info(msg + '[' + i + '].uid:' + data[i].uid); + console.info(msg + '[' + i + '].entityType:' + data[i].entityType); + console.info(msg + '[' + i + '].removable:' + data[i].removable); + } + expectData(msg, data); + } + + /** + * expect属性 + * @param msg log信息 + * @param data 数据源 + */ + function expectData(msg, data) { + console.info(msg + 'commonTest data length [' + data.length + ']'); + for (var i = 0; i < data.length; i++) { + expect(typeof (data)).assertEqual('object'); + expect(typeof (data[i].name)).assertEqual('string'); + expect(typeof (data[i].codePath)).assertEqual('string'); + expect(typeof (data[i].accessTokenId)).assertEqual('number'); + expect(typeof (data[i].description)).assertEqual('string'); + expect(typeof (data[i].descriptionId)).assertEqual('number'); + expect(typeof (data[i].icon)).assertEqual('string'); + expect(typeof (data[i].iconId)).assertEqual('number'); + expect(typeof (data[i].label)).assertEqual('string'); + expect(typeof (data[i].labelId)).assertEqual('number'); + expect(typeof (data[i].systemApp)).assertEqual('boolean') + expect(typeof (data[i].supportedModes)).assertEqual('number'); + expect(typeof (data[i].entryDir)).assertEqual('string'); + expect(typeof (data[i].metaData)).assertEqual('object'); + expect(typeof (data[i].metadata)).assertEqual('object'); + expect(typeof (data[i].enabled)).assertEqual('boolean'); + expect(typeof (data[i].flags)).assertEqual('number'); + expect(typeof (data[i].uid)).assertEqual('number'); + expect(typeof (data[i].entityType)).assertEqual('string'); + expect(typeof (data[i].removable)).assertEqual('boolean'); + expect(Array.isArray(data[i].permissions)).assertEqual(true); + expect(Array.isArray(data[i].moduleSourceDirs)).assertEqual(true); + expect(Array.isArray(data[i].moduleInfos)).assertEqual(true); + } + } + + /** + * expect指定数据属性值 + * @param msg log信息 + * @param data 数据源 + */ + function getApplicationInfoSuccess(msg, data) { + console.info(msg + 'getApplicationInfoSuccess data length [' + data.length + ']'); + for (var i = 0; i < data.length; i++) { + if (data[i].name === 'com.open.harmony.packagemag' || i === 0 && data[i].name === '') { + console.info(msg + JSON.stringify(data[i])); + expect(data[i].name).assertEqual('com.open.harmony.packagemag'); + expect(data[i].codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag'); + expect(data[i].description).assertEqual('$string:mainability_description'); + if (data[i].descriptionId !== 0) { + expect(data[i].descriptionId > 0).assertEqual(true); + } + expect(data[i].icon).assertEqual('$media:icon'); + expect(data[i].iconId > 0).assertEqual(true); + expect(data[i].label).assertEqual('$string:entry_MainAbility'); + if (data[i].label !== 0) { + expect(data[i].labelId > 0).assertEqual(true); + } + expect(data[i].systemApp).assertEqual(true); + expect(data[i].supportedModes).assertEqual(0); + expect(data[i].entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' + + '/com.open.harmony.packagemag'); + expect(data[i].enabled).assertEqual(true); + expect(data[i].entityType).assertEqual('unspecified'); + expect(data[i].removable).assertEqual(true); + expect(data[i].moduleInfos[0].moduleName).assertEqual('entry'); + expect(data[i].moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' + + 'com.open.harmony.packagemag/com.open.harmony.packagemag'); + expect(data[i].moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' + + 'com.open.harmony.packagemag/com.open.harmony.packagemag'); + } + } + } + }); +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getApplicationInfoJsunit.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getApplicationInfoJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7d3193b932deafda6e44cddcf0bf5de6836d87eb --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getApplicationInfoJsunit.test.ets @@ -0,0 +1,595 @@ +/** + * Copyright (c) 2021 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 {describe, beforeEach, afterEach, it, expect} from 'deccjsunit/index.ets'; +import Utils from './Utils'; +import Bundle from '@ohos.bundle'; + +const TAG_TEST_0100_001 = ' bundle_getApplicationInfo_test_0100_001 '; +const TAG_TEST_0100_002 = ' bundle_getApplicationInfo_test_0100_002 '; +const TAG_TEST_0100_003 = ' bundle_getApplicationInfo_test_0100_003 '; +const TAG_TEST_0200_001 = ' bundle_getApplicationInfo_test_0200_004 '; +const TAG_TEST_0200_002 = ' bundle_getApplicationInfo_test_0200_005 '; +const TAG_TEST_0200_003 = ' bundle_getApplicationInfo_test_0200_006 '; +const TAG_TEST_0300_001 = ' bundle_getApplicationInfo_test_0300_007 '; +const TAG_TEST_0400_001 = ' bundle_getApplicationInfo_test_0400_008 '; +const TAG_TEST_0500_001 = ' bundle_getApplicationInfo_test_0500_009 '; +const TAG_TEST_0500_002 = ' bundle_getApplicationInfo_test_0500_0010 '; +const TAG_TEST_0600_001 = ' bundle_getApplicationInfo_test_0600_0011 '; +const TAG_TEST_0600_002 = ' bundle_getApplicationInfo_test_0600_0012 '; +const TAG_TEST_0600_003 = ' bundle_getApplicationInfo_test_0600_0013 '; +const BUNDLE_NAME = 'com.open.harmony.packagemag'; +const BUNDLE_NAME_OTHER = 'com.ohos.acepackage'; +const USER_ID_100 = 100; +const SLEEP_TIME_1000 = 1000; +const SLEEP_TIME_2000 = 2000; + +export default function applicationBundleJsunit() { + describe('appInfoTest', function () { + beforeEach(async function (done) { + console.info('applicationBundle before each called'); + done() + }); + + afterEach(async function () { + await Utils.sleep(SLEEP_TIME_2000); + console.info('applicationBundle after each called'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0100_001 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0100_001, 0, async function (done) { + console.info(TAG_TEST_0100_001 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + let errors; + var startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + USER_ID_100) + .catch((error) => { + console.info(TAG_TEST_0100_001 + 'UserId promise error is: ' + error); + errors = error; + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0100_001, startTime, endTime); + console.info(TAG_TEST_0100_001 + ' UserId promise data is: ' + JSON.stringify(data)); + if (1 === errors) { + expect(errors).assertEqual(1); + } else { + commonTest(TAG_TEST_0100_001, data); + getApplicationInfoSuccess(TAG_TEST_0100_001, data); + } + done(); + console.log('------------------ ' + TAG_TEST_0100_001 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0100_002 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0100_002, 0, async function (done) { + console.info(TAG_TEST_0100_002 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + let errors; + var startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_ALL_APPLICATION_INFO, USER_ID_100) + .catch((error) => { + console.info(TAG_TEST_0100_002 + 'UserId promise error is: ' + error); + errors = error; + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0100_002, startTime, endTime); + console.info(TAG_TEST_0100_002 + ' UserId promise data is: ' + JSON.stringify(data)); + if (1 === errors) { + expect(errors).assertEqual(1); + } else { + commonTest(TAG_TEST_0100_002, data); + getApplicationInfoSuccess(TAG_TEST_0100_002, data); + } + done(); + console.log('------------------ ' + TAG_TEST_0100_002 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0100_003 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0100_003, 0, async function (done) { + console.info(TAG_TEST_0100_003 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + let errors; + var startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE, + USER_ID_100) + .catch((error) => { + console.info(TAG_TEST_0100_003 + 'UserId promise error is: ' + error); + errors = error; + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0100_003, startTime, endTime); + console.info(TAG_TEST_0100_003 + ' UserId promise data is: ' + JSON.stringify(data)); + if (1 === errors) { + expect(errors).assertEqual(1); + } else { + commonTest(TAG_TEST_0100_003, data); + if ('' === data.name) { + getApplicationInfoFial(TAG_TEST_0100_003, data); + } else { + getApplicationInfoSuccess(TAG_TEST_0100_003, data); + } + } + done(); + console.log('------------------ ' + TAG_TEST_0100_003 + ' end -------------------'); + }); + + + /** + * @tc.number: bundle_getApplicationInfo_test_0200_004 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0200_001, 0, async function (done) { + console.info(TAG_TEST_0200_001 + 'promise START'); + let errors; + await Utils.sleep(SLEEP_TIME_1000); + var startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION) + .catch((error) => { + console.info(TAG_TEST_0200_001 + 'onUserId promise error is: ' + error); + errors = error; + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0200_001, startTime, endTime); + console.info(TAG_TEST_0200_001 + ' onUserId promise data is: ' + JSON.stringify(data)); + if (1 === errors) { + expect(errors).assertEqual(1); + } else { + commonTest(TAG_TEST_0200_001, data); + getApplicationInfoSuccess(TAG_TEST_0200_001, data); + } + done(); + console.log('------------------ ' + TAG_TEST_0200_001 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0200_005 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0200_002, 0, async function (done) { + console.info(TAG_TEST_0200_002 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + let errors; + var startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_ALL_APPLICATION_INFO) + .catch((error) => { + console.info(TAG_TEST_0200_002 + 'onUserId promise error is: ' + error); + errors = error; + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0200_002, startTime, endTime); + console.info(TAG_TEST_0200_002 + ' onUserId promise data is: ' + JSON.stringify(data)); + if (1 === errors) { + expect(errors).assertEqual(1); + } else { + commonTest(TAG_TEST_0200_002, data); + getApplicationInfoSuccess(TAG_TEST_0200_002, data); + } + done(); + console.log('------------------ ' + TAG_TEST_0200_002 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0200_006 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0200_003, 0, async function (done) { + console.info(TAG_TEST_0200_003 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + let errors; + var startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE) + .catch((error) => { + console.info(TAG_TEST_0200_003 + 'onUserId promise error is: ' + error); + errors = error; + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0200_003, startTime, endTime); + console.info(TAG_TEST_0200_003 + ' onUserId promise data is: ' + JSON.stringify(data)); + if (1 === errors) { + expect(errors).assertEqual(1); + } else { + commonTest(TAG_TEST_0200_003, data); + getApplicationInfoSuccess(TAG_TEST_0200_003, data); + } + done(); + console.log('------------------ ' + TAG_TEST_0200_003 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0300_007 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by callBack) + * @tc.level 0 + */ + it(TAG_TEST_0300_001, 0, async function (done) { + console.info(TAG_TEST_0300_001 + 'callBack START'); + await Utils.sleep(SLEEP_TIME_1000); + let errors; + let datas; + var startTime = await Utils.getNowTime(); + Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + USER_ID_100, (error, data) => { + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0300_001, startTime, endTime); + console.info(TAG_TEST_0300_001 + 'UserId callBack in'); + console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error); + errors = error; + console.info(TAG_TEST_0300_001 + 'UserId callBack data is:' + JSON.stringify(data)); + datas = data; + }); + await Utils.sleep(2000); + console.info(TAG_TEST_0300_001 + 'UserId callBack data is: ' + JSON.stringify(datas)); + if (1 === errors) { + expect(errors).assertEqual(1); + } else { + commonTest(TAG_TEST_0300_001, datas); + getApplicationInfoSuccess(TAG_TEST_0300_001, datas); + } + done(); + console.log('------------------ ' + TAG_TEST_0300_001 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0400_008 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by callBack) + * @tc.level 0 + */ + it(TAG_TEST_0400_001, 0, async function (done) { + console.info(TAG_TEST_0400_001 + 'callBack START'); + let errors; + let datas; + var startTime = await Utils.getNowTime(); + Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, (error, data) => { + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0400_001, startTime, endTime); + console.info(TAG_TEST_0400_001 + 'noUserId callBack in'); + console.info(TAG_TEST_0400_001 + 'noUserId callBack error: ' + error); + errors = error; + console.info(TAG_TEST_0400_001 + 'noUserId callBack data is:' + JSON.stringify(data)); + datas = data; + }); + await Utils.sleep(2000); + console.info(TAG_TEST_0400_001 + 'noUserId callBack data is: ' + JSON.stringify(datas)); + if (1 === errors) { + expect(errors).assertEqual(1); + } else { + commonTest(TAG_TEST_0400_001, datas); + getApplicationInfoSuccess(TAG_TEST_0400_001, datas); + } + done(); + console.log('------------------ ' + TAG_TEST_0400_001 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0500_009 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0500_001, 0, async function (done) { + console.info(TAG_TEST_0500_001 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + let errors; + var startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo('', 0) + .catch((error) => { + console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error); + errors = error; + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime); + console.info(TAG_TEST_0500_001 + ' noUserId promise data is: ' + JSON.stringify(data)); + if (1 === errors) { + expect(errors).assertEqual(1); + } + done(); + console.log('------------------ ' + TAG_TEST_0500_001 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0500_0010 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0500_002, 0, async function (done) { + console.info(TAG_TEST_0500_002 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + let errors; + var startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo('', '0', USER_ID_100) + .catch((error) => { + console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error); + errors = error; + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime); + console.info(TAG_TEST_0500_002 + ' UserId promise data is: ' + JSON.stringify(data)); + if (1 === errors) { + expect(errors).assertEqual(1); + } + done(); + console.log('------------------ ' + TAG_TEST_0500_002 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0600_0011 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0600_001, 0, async function (done) { + console.info(TAG_TEST_0600_001 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + let errors; + var startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER, + Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION) + .catch((error) => { + console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise error is: ' + error); + errors = error; + }); + console.info(TAG_TEST_0600_001 + ' other bundleName noUserId promise errors is: ' + JSON.stringify(errors)); + console.info(TAG_TEST_0600_001 + ' other bundleName noUserId promise data is: ' + JSON.stringify(data)); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime); + if (1 === errors) { + expect(errors).assertEqual(1); + } else { + commonTest(TAG_TEST_0600_001, data); + getApplicationInfoOtherSuccess(TAG_TEST_0600_001, data); + } + done(); + console.log('------------------ ' + TAG_TEST_0600_001 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0600_0012 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0600_002, 0, async function (done) { + console.info(TAG_TEST_0600_002 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + let errors; + var startTime = await Utils.getNowTime(); + let data = + await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + USER_ID_100) + .catch((error) => { + console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise error is: ' + error); + errors = error; + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0600_002, startTime, endTime); + console.info(TAG_TEST_0600_002 + ' other bundleName UserId promise errors is: ' + JSON.stringify(errors)); + console.info(TAG_TEST_0600_002 + ' other bundleName UserId promise data is: ' + JSON.stringify(data)); + if (1 === errors) { + expect(errors).assertEqual(1); + } else { + commonTest(TAG_TEST_0600_002, data); + getApplicationInfoOtherSuccess(TAG_TEST_0600_002, data); + } + done(); + console.log('------------------ ' + TAG_TEST_0600_002 + ' end -------------------'); + }); + + /** + * @tc.number: bundle_getApplicationInfo_test_0500_009 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0600_003, 0, async function (done) { + console.info(TAG_TEST_0600_003 + 'promise START'); + await Utils.sleep(SLEEP_TIME_1000); + let errors; + var startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo(BUNDLE_NAME, 0) + .catch((error) => { + console.info(TAG_TEST_0600_003 + 'noUserId promise error is: ' + error); + errors = error; + }); + var endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0600_003, startTime, endTime); + console.info(TAG_TEST_0600_003 + ' noUserId promise data is: ' + JSON.stringify(data)); + if (1 === errors) { + expect(errors).assertEqual(1); + } else { + commonTest(TAG_TEST_0600_003, data); + getApplicationInfoSuccess(TAG_TEST_0600_003, data); + } + done(); + console.log('------------------ ' + TAG_TEST_0600_003 + ' end -------------------'); + }); + + /** + * 打印单和expect个属性 + * @param msg log信息 + * @param data 数据源 + */ + function commonTest(msg, data) { + console.log(msg + ' commonTest start ' + JSON.stringify(data)); + console.log(msg + ' name : ' + data.name); + console.log(msg + ' codePath : ' + data.codePath); + console.log(msg + ' accessTokenId : ' + data.accessTokenId); + console.log(msg + ' description : ' + data.description); + console.log(msg + ' descriptionId : ' + data.descriptionId); + console.log(msg + ' icon : ' + data.icon); + console.log(msg + ' iconId : ' + data.iconId); + console.log(msg + ' label : ' + data.label); + console.log(msg + ' labelId : ' + data.labelId); + console.log(msg + ' systemApp : ' + data.systemApp); + console.log(msg + ' supportedModes : ' + data.supportedModes); + console.log(msg + ' entryDir : ' + data.entryDir); + console.log(msg + ' metaData : ' + data.metaData); + console.log(msg + ' metadata : ' + data.metadata); + console.log(msg + ' enabled : ' + data.enabled); + console.log(msg + ' flags : ' + data.flags); + console.log(msg + ' uid : ' + data.uid); + console.log(msg + ' removable : ' + data.removable); + console.log(msg + ' permissions length : ' + data.permissions.length); + for (var j = 0; j < data.permissions.length; j++) { + console.log('getApplicationInfo0001 data.permissions[' + j + '] : ' + data.permissions[j]); + } + console.log(msg + ' moduleSourceDirs length : ' + data.moduleSourceDirs.length); + for (var i = 0; i < data.moduleSourceDirs.length; i++) { + console.log('getApplicationInfo0001 data.moduleSourceDirs[' + i + '] : ' + data.moduleSourceDirs[i]); + } + console.log(msg + ' moduleInfos length : ' + data.moduleInfos.length); + for (var k = 0; k < data.moduleInfos.length; k++) { + console.log('getApplicationInfo0001 data.moduleInfos[' + k + '] : ' + data.moduleInfos[k].moduleName); + console.log('getApplicationInfo0001 data.moduleInfos[' + k + '] : ' + data.moduleInfos[k].moduleSourceDir); + } + expectData(msg, data); + } + + /** + * expect属性 + * @param msg log信息 + * @param data 数据源 + */ + function expectData(msg, data) { + expect(typeof (data)).assertEqual('object'); + expect(typeof (data.name)).assertEqual('string'); + expect(typeof (data.codePath)).assertEqual('string'); + expect(typeof (data.accessTokenId)).assertEqual('number'); + expect(typeof (data.description)).assertEqual('string'); + expect(typeof (data.descriptionId)).assertEqual('number'); + expect(typeof (data.icon)).assertEqual('string'); + expect(typeof (data.iconId)).assertEqual('number'); + expect(typeof (data.label)).assertEqual('string'); + expect(typeof (data.labelId)).assertEqual('number'); + expect(typeof (data.systemApp)).assertEqual('boolean') + expect(typeof (data.supportedModes)).assertEqual('number'); + expect(typeof (data.entryDir)).assertEqual('string'); + expect(typeof (data.metaData)).assertEqual('object'); + expect(typeof (data.metadata)).assertEqual('object'); + expect(typeof (data.enabled)).assertEqual('boolean'); + expect(typeof (data.flags)).assertEqual('number'); + expect(typeof (data.uid)).assertEqual('number'); + expect(typeof (data.entityType)).assertEqual('string'); + expect(typeof (data.removable)).assertEqual('boolean'); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.moduleSourceDirs)).assertEqual(true); + expect(Array.isArray(data.moduleInfos)).assertEqual(true); + } + + /** + * expect属性值 + * @param msg log信息 + * @param data 数据源 + */ + function getApplicationInfoSuccess(msg, data) { + expect(data.name).assertEqual('com.open.harmony.packagemag'); + expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag'); + expect(data.description).assertEqual('$string:mainability_description'); +// expect(data.descriptionId).assertEqual(16777217); + expect(data.icon).assertEqual('$media:icon'); +// expect(data.iconId).assertEqual(16777218); + expect(data.label).assertEqual('$string:entry_MainAbility'); +// expect(data.labelId).assertEqual(16777216); + expect(data.systemApp).assertEqual(true); + expect(data.supportedModes).assertEqual(0); + expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' + + '/com.open.harmony.packagemag'); + expect(data.enabled).assertEqual(true); + expect(data.entityType).assertEqual('unspecified'); + expect(data.removable).assertEqual(true); + expect(data.moduleInfos[0].moduleName).assertEqual('entry'); + expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' + + 'com.open.harmony.packagemag/com.open.harmony.packagemag'); + expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' + + 'com.open.harmony.packagemag/com.open.harmony.packagemag'); + console.log(msg + ' end ' + JSON.stringify(data)); + } + + /** + * expect属性值 + * @param msg log信息 + * @param data 数据源 + */ + function getApplicationInfoFial(msg, data) { + expect(data.name).assertEqual(''); + expect(data.codePath).assertEqual(''); + expect(data.description).assertEqual(''); + expect(data.descriptionId).assertEqual(0); + expect(data.icon).assertEqual(''); + expect(data.iconId).assertEqual(0); + expect(data.label).assertEqual(''); + expect(data.labelId).assertEqual(0); + expect(data.systemApp).assertEqual(false); + expect(data.supportedModes).assertEqual(0); + expect(data.entryDir).assertEqual(''); + expect(data.enabled).assertEqual(false); + expect(data.entityType).assertEqual(''); + expect(data.removable).assertEqual(true); + console.log(msg + ' end ' + JSON.stringify(data)); + } + + + /** + * expect属性值 + * @param msg log信息 + * @param data 数据源 + */ + function getApplicationInfoOtherSuccess(msg, data) { + expect(data.name).assertEqual('com.ohos.acepackage'); + expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.ohos.acepackage'); + expect(data.description).assertEqual('$string:description_mainability'); + expect(data.descriptionId > 0).assertEqual(true); + expect(data.icon).assertEqual('$media:icon'); + expect(data.iconId > 0).assertEqual(true); + expect(data.label).assertEqual('$string:entry_MainAbility'); + expect(data.labelId > 0).assertEqual(true); + expect(data.systemApp).assertEqual(true); + expect(data.supportedModes).assertEqual(0); + expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.ohos.acepackage' + + '/com.ohos.acepackage'); + expect(data.enabled).assertEqual(true); + expect(data.entityType).assertEqual('unspecified'); + expect(data.removable).assertEqual(true); + expect(data.moduleInfos[0].moduleName).assertEqual('entry'); + expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' + + 'com.ohos.acepackage/com.ohos.acepackage'); + expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' + + 'com.ohos.acepackage/com.ohos.acepackage'); + console.log(msg + ' end ' + JSON.stringify(data)); + } + }); +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/ServiceAbility/service.ts b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..383f9f0ebefc00d5761c83f88fcd1ba6c9500cd1 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,11 @@ +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/resources/base/element/string.json b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2482e91c015e2e8d68406790782982adc4789b34 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "mainability_description", + "value": "eTS_Empty Ability" + }, + { + "name": "description_serviceability", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/resources/base/media/icon.png b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/resources/base/media/icon.png differ diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/signature/openharmony_sx.p7b b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/signature/openharmony_sx.p7b differ diff --git a/communication/bluetooth_on/src/main/js/default/test/BluetoothOn.test.js b/communication/bluetooth_on/src/main/js/default/test/BluetoothOn.test.js index 86ee62e76d659923eb6ca4e9eb047f4154b7500d..fd574f87c4b18d194c232a5c93864cc519f6d2ab 100644 --- a/communication/bluetooth_on/src/main/js/default/test/BluetoothOn.test.js +++ b/communication/bluetooth_on/src/main/js/default/test/BluetoothOn.test.js @@ -121,7 +121,6 @@ describe('bluetoothhostTest', function() { }); console.info('[bluetooth_js] discovery end'); done(); - await sleep(2000); }) diff --git a/communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js b/communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js index e0b02c9c808d206c6cfb58094fd1218b4a14025d..fa7583e1efdf4113a892f06c8b66b8fb704ae56f 100644 --- a/communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js +++ b/communication/bluetooth_standard/src/main/js/default/test/Bluetooth.test.js @@ -820,6 +820,7 @@ describe('bluetoothhostTest', function() { console.info('[bluetooth_js] setLocalName end'); }) + /** * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_SET_LOCAL_NAME_00014 * @tc.name testsetLocalName @@ -829,7 +830,7 @@ describe('bluetoothhostTest', function() { * @tc.type Function * @tc.level Level 2 */ - it('bluetooth_classic_set_local_name14', 0, async function (done) { + it('bluetooth_classic_set_local_name14', 0, function () { console.info('[bluetooth_js] set localname start'); var name = bluetooth.setLocalName('0123456789012345678901234567890123456789012345678901' +'23456789012345678901234567890123456789012345678901234567890123456789012345678012' @@ -838,14 +839,29 @@ describe('bluetoothhostTest', function() { expect(name).assertTrue(); var localName = bluetooth.getLocalName(); console.info('[bluetooth_js] getLocalName result14 = ' + JSON.stringify(localName)); + console.info('[bluetooth_js] setLocalName end'); + }) + + + /** + * @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_DISABLE_0001 + * @tc.name testdisablebluetooth + * @tc.desc Test disablebluetooth api. + * @tc.author zhangyujie zwx1079266 + * @tc.size MEDIUM + * @tc.type Function + * @tc.level Level 2 + */ + + it('bluetooth_classic_disable_bluetooth', 0, function () { + console.info('[bluetooth_js] disable test start'); let disable = bluetooth.disableBluetooth(); console.info('[bluetooth_js] disable:' + JSON.stringify(disable)); expect(disable).assertTrue(); - await sleep(2000); - console.info('[bluetooth_js] setLocalName end'); - done(); + var state = bluetooth.getState(); + console.info('[bluetooth_js] bt state:' + JSON.stringify(state)); + console.info('[bluetooth_js] disable end'); }) - }) diff --git a/communication/wifi_hotspot/src/main/js/default/test/WifiSoftAP.test.js b/communication/wifi_hotspot/src/main/js/default/test/WifiSoftAP.test.js index bf0012f1496f1e19c59328347dfb05432cc2de73..130eca64741a3be398bffc612f7ad35eae0f132e 100755 --- a/communication/wifi_hotspot/src/main/js/default/test/WifiSoftAP.test.js +++ b/communication/wifi_hotspot/src/main/js/default/test/WifiSoftAP.test.js @@ -296,7 +296,7 @@ describe('ACTS_WifiTest', function() { console.log("[wifi_test] check current hotspot config preSharedKey is 8bit" ); var config = wifi.getHotspotConfig(); console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config)); - console.info("preSharedKey: " + config.ssid); + console.info("ssid: " + config.ssid); expect(config.ssid.length).assertEqual(32); done(); @@ -355,7 +355,7 @@ describe('ACTS_WifiTest', function() { console.log("[wifi_test] check current hotspot config preSharedKey is 8bit" ); var config = wifi.getHotspotConfig(); console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config)); - console.info("preSharedKey: " + config.ssid); + console.info("ssid: " + config.ssid); expect(true).assertEqual(config.ssid==HotspotConfigC.ssid); }) @@ -440,8 +440,8 @@ describe('ACTS_WifiTest', function() { console.log("[wifi_test] check current hotspot config preSharedKey is 8bit" ); var config = wifi.getHotspotConfig(); console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config)); - console.info("preSharedKey: " + config.ssid); - expect(config.preSharedKey).assertEqual(3); + console.info("ssid: " + config.ssid); + expect(config.securityType).assertEqual(3); console.log("[wifi_test] check the state of Hotspot" ); var isHotspotActive = wifi.isHotspotActive(); console.info("[wifi_test] isHotspotActive -> " + isHotspotActive); @@ -478,8 +478,8 @@ describe('ACTS_WifiTest', function() { console.log("[wifi_test] check current hotspot config preSharedKey is 8bit" ); var config = wifi.getHotspotConfig(); console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config)); - console.info("preSharedKey: " + config.ssid); - expect(config.preSharedKey).assertEqual(1); + console.info("ssid: " + config.ssid); + expect(config.securityType).assertEqual(1); done(); }) @@ -513,7 +513,7 @@ describe('ACTS_WifiTest', function() { console.log("[wifi_test] check current hotspot config maxConn is 8 " ); var config = wifi.getHotspotConfig(); console.info("[wifi_test] getHotspotConfig result -> " + JSON.stringify(config)); - console.info("ssid: " + config.maxConn); + console.info("maxConn: " + config.maxConn); expect(config.maxConn).assertEqual(8); console.log("[wifi_test] set more maxConn invalid hotspot config" ); diff --git a/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js b/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js index 6c92dcc4235b8c08dabb993ad5521476d5bb65d6..2714f67c6a41f22863cb96e502cb4afd0b6ee0e9 100755 --- a/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js +++ b/communication/wifi_standard/src/main/js/default/test/WifiSta.test.js @@ -753,7 +753,6 @@ describe('ACTS_WifiTest', function() { "staticIp": {"ipAddress": 1284752956,"gateway": 1284752936}, }; var result1 = wifi.connectToDevice(wifiDeviceConfigIp); - await sleep(2000); console.log("[wifi_test] wifi connectToDevice result: " + result1); expect(result1).assertTrue(); console.info("[wifi_test] check isconnected wifi"); diff --git a/graphic/webGL/src/main/js/default/test/webGL.test.js b/graphic/webGL/src/main/js/default/test/webGL.test.js old mode 100644 new mode 100755 index cc87d052eeb0a53f42c6ecf1d938f565f860c2b9..e9d9adf51f87582e35a39e67120f9a9c93d3d3ab --- a/graphic/webGL/src/main/js/default/test/webGL.test.js +++ b/graphic/webGL/src/main/js/default/test/webGL.test.js @@ -27472,4 +27472,164 @@ describe('webgl1Test', function() { expect(texParameterValue).assertEqual(gl.COMPARE_REF_TO_TEXTURE); done(); }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1335 + * @tc.name testRangeMin + * @tc.desc Test RangeMin. + */ + it ('testRangeMin', 0, async function(done) { + console.info('jsWebGL testRangeMin test start'); + gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT).rangeMin; + gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_INT).rangeMin; + const min = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_INT).rangeMin; + const max = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT).rangeMax; + expect(min).assertEqual(24); + expect(max).assertEqual(127); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1335 + * @tc.name testAttributeBae + * @tc.desc Test AttributeBae. + */ + it ('testAttributeBae', 0, async function(done) { + console.info('jsWebGL testAttributeBae test start'); + var frameBuffer = gl.createBuffer(); + gl.bindBuffer(gl.FRAMEBUFFER, frameBuffer); + const framebufferParameter = gl.getParameter(gl.FRAMEBUFFER_BINDING); + const isFramebuffer = gl.isFramebuffer(framebufferParameter); + expect(isFamebuffer).assertEqual(true); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1335 + * @tc.name testTypeBase + * @tc.desc Test TypeBase. + */ + it ('testTypeBase', 0, async function(done) { + console.info('jsWebGL testTypeBasetest start'); + const progamObj = globalFunction(); + const info = gl.getActiveAttrib(programObj, 0); + info.size = 123; + info.name = 'name'; + info.type = Number; + const size = info.size; + const name = info.name; + const type = info.type; + expect(size).assertEqual(info.size); + expect(name).assertEqual(info.name); + expect(type).assertEqual(info.type); + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1335 + * @tc.name testWebGLTypeBase + * @tc.desc Test WebGLTypeBase. + */ + it ('testWebGLTypeBase', 0, async function(done) { + console.info('jsWebGL testWebGLTypeBase test start'); + var x =1 ; + expect(x).assertEqual(gl.ONE); + var x1 = 0x8892; + expect(x1).assertEqual(gl.ARRAY_BUFFER); + var x2 = 0x0405; + expect(x2).assertEqual(gl.BACK); + var x3 = 0; + expect(x3).assertEqual(gl.NO_ERROR); + var x4 = 0x0502; + expect(x4).assertEqual(gl.INVALID_OPERATION); + var x5 = 0x80AA; + expect(x5).assertEqual(gl.SAMPLE_COVERAGE_VALUE); + var x6 = 0x80AB; + expect(x6).assertEqual(gl.SAMPLE_COVERAGE_INVERT); + var x7 = 0x1400; + expect(x7).assertEqual(gl.BYTE); + var x8 = 0x1404; + expect(x8).assertEqual(gl.INT); + var x9 = 0x1406; + expect(x9).assertEqual(gl.FLOAT); + var x10 = 0x1907; + expect(x10).assertEqual(gl.RGB); + var x11 = 0x8B89; + expect(x11).assertEqual(gl.ACTIVE_ATTRIBUTES); + var x12 = 0x0DE1; + expect(x12).assertEqual(gl.TEXTURE_2D); + + var x13 = 0x1702; + expect(x13).assertEqual(gl.TEXTURE); + + var x14 = 0x84C0; + expect(x14).assertEqual(gl.TEXTURE0); + var x15 = 0x8D40; + expect(x15).assertEqual(gl.FRAMEBUFFER); + var x16 = 0x8D41; + expect(x16).assertEqual(gl.RENDERBUFFER); + var x17 = 0x8894; + expect(x17).assertEqual(gl.ARRAY_BUFFER); + var x18 = 0; + expect(x18).assertEqual(gl.NONE); + var x19 =0x9242; + expect(x19).assertEqual(gl.CONTEXT_LOST_WEBGL); + var x20 = 0x8892; + expect(x20).assertEqual(gl.ARRAY_BUFFER) + done(); + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1335 + * @tc.name testRendingContextBase + * @tc.desc Test RendingContextBase. + */ + it ('testRendingContextBase', 0, async function(done) { + console.info('jsWebGL testRendingContextBase test start'); + const buffer = gl.createBuffer(); + expect(typeof(buffer)).assertEqual('object'); + + var x1 = gl2.COLOR; + expect(x1).assertEqual(6144); + + var x2 = gl2.STENCIL; + expect(x2).assertEqual(6146); + + var x3 = gl2.MIN; + expect(x3).assertEqual(32775); + + var x4 = gl2.MAX; + expect(x4).assertEqual(32776); + + var x5 = gl2.RG; + expect(x5).assertEqual(33319); + + var x6 = gl2.SYNC_CONDITION; + expect(x6).assertEqual(37139); + + var x7 = gl2.SYNC_STATUS; + expect(x7).assertEqual(37140); + + var x8 = gl2.SYNC_FLAGS; + expect(x8).assertEqual(37141); + + done(); + + }); + + /** + * @tc.number GRAPHIC_FUNCTION_JS_WEBGL_TESTWEBGL_1335 + * @tc.name testAttributeBase + * @tc.desc Test testAttributeBase. + */ + it ('testAttributeBase', 0, async function(done) { + console.info('jsWebGL testAttributeBase test start'); + var attribute = gl.getContextAttributes(); + expect(atttribute.desynchronized).assertEqual(false); + expect(atttribute.antialias).assertEqual(true); + expect(atttribute.premultipliedAlpha).assertEqual(true); + expect(atttribute.preserveDrawingBuffer).assertEqual(false); + expect(atttribute.failIfMajorPerformanceCaveat).assertEqual(false); + done() + }); }) diff --git a/miscservices/BUILD.gn b/miscservices/BUILD.gn index bf26586acb38e6cedd61629861b87940fa177489..37e6764c288eb082e79df5ae14bc9223b91c07a0 100755 --- a/miscservices/BUILD.gn +++ b/miscservices/BUILD.gn @@ -15,6 +15,7 @@ import("//build/ohos_var.gni") group("miscservices") { testonly = true deps = [ + "PasteBoardTest_js:pasteboard_js_test", "TimeTest_js:time_js_test", "TimerTest_js:timer_js_test", ] diff --git a/miscservices/PasteBoardTest_js/BUILD.gn b/miscservices/PasteBoardTest_js/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fbb8d7d95a95249659973a9648a80e61bdab1fa0 --- /dev/null +++ b/miscservices/PasteBoardTest_js/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (C) 2021 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("pasteboard_js_test") { + hap_profile = "./src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsPasteBoardJSApiTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/miscservices/PasteBoardTest_js/Test.json b/miscservices/PasteBoardTest_js/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..9827a384e6246284b3b81dcffa3fd214e8381a2e --- /dev/null +++ b/miscservices/PasteBoardTest_js/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for PasteBoard js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "ohos.acts.miscservices.pasteboard", + "shell-timeout": "180000" + }, + "kits": [ + { + "test-file-name": [ + "ActsPasteBoardJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/miscservices/PasteBoardTest_js/signature/openharmony_sx.p7b b/miscservices/PasteBoardTest_js/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/miscservices/PasteBoardTest_js/signature/openharmony_sx.p7b differ diff --git a/miscservices/PasteBoardTest_js/src/main/config.json b/miscservices/PasteBoardTest_js/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..73cba5cfe733c979c711cfc00fcc1ac1f533c999 --- /dev/null +++ b/miscservices/PasteBoardTest_js/src/main/config.json @@ -0,0 +1,60 @@ +{ + "app": { + "bundleName": "ohos.acts.miscservices.pasteboard", + "vendor": "acts", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.acts.miscservices.pasteboard", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "ohos.acts.miscservices.pasteboard.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} diff --git a/miscservices/PasteBoardTest_js/src/main/js/default/app.js b/miscservices/PasteBoardTest_js/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2b1123aba50aa93c918c68213fb66542e2264948 --- /dev/null +++ b/miscservices/PasteBoardTest_js/src/main/js/default/app.js @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2021 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. + */ + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/miscservices/PasteBoardTest_js/src/main/js/default/i18n/en-US.json b/miscservices/PasteBoardTest_js/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/miscservices/PasteBoardTest_js/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/miscservices/PasteBoardTest_js/src/main/js/default/i18n/zh-CN.json b/miscservices/PasteBoardTest_js/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/miscservices/PasteBoardTest_js/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/miscservices/PasteBoardTest_js/src/main/js/default/pages/index/index.css b/miscservices/PasteBoardTest_js/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/miscservices/PasteBoardTest_js/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/miscservices/PasteBoardTest_js/src/main/js/default/pages/index/index.hml b/miscservices/PasteBoardTest_js/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/miscservices/PasteBoardTest_js/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/miscservices/PasteBoardTest_js/src/main/js/default/pages/index/index.js b/miscservices/PasteBoardTest_js/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..d30b6fcc8da4b06f574810009b7f4bfeeb41345a --- /dev/null +++ b/miscservices/PasteBoardTest_js/src/main/js/default/pages/index/index.js @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2021 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 app from '@system.app' +import {Core, ExpectExtend} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + // core.addService('report', instrumentLog) + core.init() + // core.subscribeEvent('spec', instrumentLog) + // core.subscribeEvent('suite', instrumentLog) + // core.subscribeEvent('task', instrumentLog) + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../test/List.test') + core.execute() + }, + onReady() { + }, +} diff --git a/miscservices/PasteBoardTest_js/src/main/js/default/test/List.test.js b/miscservices/PasteBoardTest_js/src/main/js/default/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..7518e7b60ab3ca6dc8b55918b34fe7546fde584e --- /dev/null +++ b/miscservices/PasteBoardTest_js/src/main/js/default/test/List.test.js @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2021 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. + */ + +require('./PasteBoardJsunit.test.js') \ No newline at end of file diff --git a/miscservices/PasteBoardTest_js/src/main/js/default/test/PasteBoardJsunit.test.js b/miscservices/PasteBoardTest_js/src/main/js/default/test/PasteBoardJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..a8d949fbba2b3c187b4ed565113a166985184d15 --- /dev/null +++ b/miscservices/PasteBoardTest_js/src/main/js/default/test/PasteBoardJsunit.test.js @@ -0,0 +1,2099 @@ +/* + * Copyright (C) 2021 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. + */ + +// @ts-nocheck +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import pasteboard from '@ohos.pasteboard' + +describe('PasteBoardTest', function() { + console.log('start################################start'); + + /** + * @tc.number SUB_pasteBoard_function_JS_API_0100 + * @tc.name Adds PlainTextData + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test1',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_0100 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getPrimaryText(), textData) + + console.log('Checks there is a MIMETYPE_TEXT_PLAIN MIME type of data') + assert.equal(pasteData.hasMimeType(MIMETYPE_TEXT_PLAIN), true) + assert.equal(pasteData.getPrimaryMimeType(), MIMETYPE_TEXT_PLAIN) + + console.log('SUB_pasteBoard_function_JS_API_0100 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_0200 + * @tc.name Adds PlainTextData = '' + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test2',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_0200 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.clear() + + var textData = '' + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is a MIMETYPE_TEXT_PLAIN MIME type of data') + assert.equal(pasteData.hasMimeType(MIMETYPE_TEXT_PLAIN), false) + + console.log('SUB_pasteBoard_function_JS_API_0200 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_0300 + * @tc.name Adds PlainTextData = 'Hello 中国!@#$%^&*()_+{}\?.' + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test3',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_0300 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.clear() + + var textData = 'Hello 中国!@#$%^&*()_+{}\?.' + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getPrimaryText(), textData) + + console.log('Checks there is a MIMETYPE_TEXT_PLAIN MIME type of data') + assert.equal(pasteData.hasMimeType(MIMETYPE_TEXT_PLAIN), true) + assert.equal(pasteData.getPrimaryMimeType(), MIMETYPE_TEXT_PLAIN) + + console.log('SUB_pasteBoard_function_JS_API_0300 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_0400 + * @tc.name Adds 300K PlainTextData + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test4',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_0400 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.clear() + + var textData = '' + for (var i = 0; i < (300 * 1024); i++){ + textData=textData + "A"; + } + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getPrimaryText(), textData) + + console.log('Checks there is a MIMETYPE_TEXT_PLAIN MIME type of data') + assert.equal(pasteData.hasMimeType(MIMETYPE_TEXT_PLAIN), true) + assert.equal(pasteData.getPrimaryMimeType(), MIMETYPE_TEXT_PLAIN) + + console.log('SUB_pasteBoard_function_JS_API_0400 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_0500 + * @tc.name Adds 301K PlainTextData + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test5',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_0500 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.clear() + + var textData = '' + var textData300 = '' + for (var i = 0; i < (301 * 1024); i++){ + textData = textData + "A"; + if(299 == i ) + { + textData300 = textData + } + } + + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getPrimaryText(), textData300) + + console.log('Checks there is a MIMETYPE_TEXT_PLAIN MIME type of data') + assert.equal(pasteData.hasMimeType(MIMETYPE_TEXT_PLAIN), true) + assert.equal(pasteData.getPrimaryMimeType(), MIMETYPE_TEXT_PLAIN) + + console.log('SUB_pasteBoard_function_JS_API_0500 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_0600 + * @tc.name Adds htmlText + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test6',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_0600 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var htmlText = 'Hello World!' + console.log('createHtmlData = ' + htmlText) + var pasteData = pasteboard.createHtmlData(htmlText) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getPrimaryHtml(), htmlText) + + console.log('Checks there is a MIMETYPE_TEXT_HTML MIME type of data') + assert.equal(pasteData.hasMimeType(MIMETYPE_TEXT_HTML), true) + assert.equal(pasteData.getPrimaryMimeType(), MIMETYPE_TEXT_HTML) + + console.log('SUB_pasteBoard_function_JS_API_0600 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_0700 + * @tc.name Adds htmlText = '' + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test7',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_0700 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var htmlText = '' + console.log('createHtmlData = ' + htmlText) + var pasteData = pasteboard.createHtmlData(htmlText) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is a MIMETYPE_TEXT_HTML MIME type of data') + assert.equal(pasteData.hasMimeType(MIMETYPE_TEXT_HTML), false) + + console.log('SUB_pasteBoard_function_JS_API_0700 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_0800 + * @tc.name Adds htmlText = 'Hello 中国!@#$%^&*()_+{}\?.' + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test8',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_0800 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var htmlText = 'Hello 中国!@#$%^&*()_+{}\?.' + console.log('createHtmlData = ' + htmlText) + var pasteData = pasteboard.createHtmlData(htmlText) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getPrimaryHtml(), htmlText) + + console.log('Checks there is a MIMETYPE_TEXT_HTML MIME type of data') + assert.equal(pasteData.hasMimeType(MIMETYPE_TEXT_HTML), true) + assert.equal(pasteData.getPrimaryMimeType(), MIMETYPE_TEXT_HTML) + + console.log('SUB_pasteBoard_function_JS_API_0800 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_0900 + * @tc.name Adds uriText + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test9',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_0900 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var uriText = 'https://www.baidu.com/' + console.log('createUriData = ' + uriText) + var pasteData = pasteboard.createUriData(uriText) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getPrimaryUri(), uriText) + + console.log('Checks there is a MIMETYPE_TEXT_URI MIME type of data') + assert.equal(pasteData.hasMimeType(MIMETYPE_TEXT_URI), true) + assert.equal(pasteData.getPrimaryMimeType(), MIMETYPE_TEXT_URI) + + console.log('SUB_pasteBoard_function_JS_API_0900 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_1000 + * @tc.name Adds uriText = '' + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test10',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_1000 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var uriText = '' + console.log('createUriData = ' + uriText) + var pasteData = pasteboard.createUriData(uriText) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is a MIMETYPE_TEXT_URI MIME type of data') + assert.equal(pasteData.hasMimeType(MIMETYPE_TEXT_URI), false) + assert.equal(pasteData.getPrimaryMimeType(), MIMETYPE_TEXT_URI) + + console.log('SUB_pasteBoard_function_JS_API_1000 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_1100 + * @tc.name Set uriText = 'Hello 中国!@#$%^&*()_+{}\?.' + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test11',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_1100 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var uriText = 'Hello 中国!@#$%^&*()_+{}\?.' + console.log('createUriData = ' + uriText) + var pasteData = pasteboard.createUriData(uriText) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getPrimaryUri(), uriText) + + console.log('Checks there is a MIMETYPE_TEXT_URI MIME type of data') + assert.equal(pasteData.hasMimeType(MIMETYPE_TEXT_URI), true) + assert.equal(pasteData.getPrimaryMimeType(), MIMETYPE_TEXT_URI) + + console.log('SUB_pasteBoard_function_JS_API_1100 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_1200 + * @tc.name Adds want + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test12',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_1200 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var want = new Want() + console.log('createWantData = ' + want) + var pasteData = pasteboard.createWantData(want) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getPrimaryWant(), want) + + console.log('Checks there is a MIMETYPE_TEXT_WANT MIME type of data') + assert.equal(pasteData.hasMimeType(MIMETYPE_TEXT_WANT), true) + assert.equal(pasteData.getPrimaryMimeType(), MIMETYPE_TEXT_WANT) + + console.log('SUB_pasteBoard_function_JS_API_1200 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_1300 + * @tc.name Adds one record(s) + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test13',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_1300 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getRecordAt(0).plainText, textData) + + console.log('SUB_pasteBoard_function_JS_API_1300 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_1400 + * @tc.name Adds 2 record(s) + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test14',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_1400 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData0 = 'Hello World0' + console.log('createPlainTextData = ' + textData0) + var pasteData = pasteboard.createPlainTextData(textData0) + + var textData1 = 'Hello World1' + console.log('addTextRecord = ' + textData1) + pasteData.addTextRecord(textData1) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 2) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getRecordAt(0).plainText, textData0) + assert.equal(pasteData.getRecordAt(1).plainText, textData1) + + console.log('SUB_pasteBoard_function_JS_API_1400 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_1500 + * @tc.name Adds 15 record(s) + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test15',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_1500 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData0 = 'Hello World0' + console.log('createPlainTextData = ' + textData0) + var pasteData = pasteboard.createPlainTextData(textData0) + + var textData = '' + for(var i = 1; i < 15; i++) + { + textData = 'Hello World' + textData = textData + i + console.log('addTextRecord = ' + textData) + pasteData.addTextRecord(textData) + } + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 15) + + console.log('Checks the pasteboard content') + for(var i = 0; i < 15; i++) + { + textData = 'Hello World' + textData = textData + i + assert.equal(pasteData.getRecordAt(i).plainText, textData) + } + + console.log('SUB_pasteBoard_function_JS_API_1500 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_1600 + * @tc.name Adds 30 record(s) + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test16',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_1600 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData0 = 'Hello World0' + console.log('createPlainTextData = ' + textData0) + var pasteData = pasteboard.createPlainTextData(textData0) + + var textData = '' + for(var i = 1; i < 30; i++) + { + textData = 'Hello World' + textData = textData + i + console.log('addTextRecord = ' + textData) + pasteData.addTextRecord(textData) + } + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 30) + + console.log('Checks the pasteboard content') + for(var i = 0; i < 30; i++) + { + textData = 'Hello World' + textData = textData + i + assert.equal(pasteData.getRecordAt(i).plainText, textData) + } + + console.log('SUB_pasteBoard_function_JS_API_1600 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_1700 + * @tc.name Adds 31 record(s) + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test17',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_1700 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData0 = 'Hello World0' + console.log('createPlainTextData = ' + textData0) + var pasteData = pasteboard.createPlainTextData(textData0) + + var textData = '' + for(var i = 1; i < 31; i++) + { + textData = 'Hello World' + textData = textData + i + console.log('addTextRecord = ' + textData) + pasteData.addTextRecord(textData) + } + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 30) + + console.log('Checks the pasteboard content') + for(var i = 0; i < 30; i++) + { + textData = 'Hello World' + textData = textData + i + assert.equal(pasteData.getRecordAt(i).plainText, textData) + } + + console.log('SUB_pasteBoard_function_JS_API_1700 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_1800 + * @tc.name Adds PlainText,HtmlText,UriText,WantText + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test18',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_1800 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + var htmlText = 'Hello World!' + console.log('addHtmlRecord = ' + htmlText) + pasteData.addHtmlRecord(htmlText) + + var uriText = 'https://www.baidu.com/' + console.log('addUriRecord = ' + uriText) + pasteData.addUriRecord(uriText) + + var wantText = new Want() + console.log('addWantRecord = ' + wantText) + pasteData.addWantRecord(wantText) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 4) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getRecordAt(0).plainText, textData) + assert.equal(pasteData.getRecordAt(1).htmlText, htmlText) + assert.equal(pasteData.getRecordAt(2).uri, uriText) + assert.equal(pasteData.getRecordAt(3).want, wantText) + + console.log('SUB_pasteBoard_function_JS_API_1800 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_1900 + * @tc.name Delete one PlainTextData + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test19',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_1900 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Removes the Record') + assert.equal(pasteData.removeRecordAt(0), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + console.log('SUB_pasteBoard_function_JS_API_1900 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_2000 + * @tc.name Delete one htmlText + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test20',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_2000 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var htmlText = 'Hello World!' + console.log('createHtmlData = ' + htmlText) + var pasteData = pasteboard.createHtmlData(htmlText) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Removes the Record') + assert.equal(pasteData.removeRecordAt(0), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + console.log('SUB_pasteBoard_function_JS_API_2000 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_2100 + * @tc.name Delete one uriText + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test21',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_2100 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var uriText = 'https://www.baidu.com/' + console.log('createUriData = ' + uriText) + var pasteData = pasteboard.createUriData(uriText) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Removes the Record') + assert.equal(pasteData.removeRecordAt(0), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + console.log('SUB_pasteBoard_function_JS_API_2100 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_2200 + * @tc.name Delete one want + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test22',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_2200 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var want = new Want() + console.log('createWantData = ' + want) + var pasteData = pasteboard.createWantData(want) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Removes the Record') + assert.equal(pasteData.removeRecordAt(0), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + console.log('SUB_pasteBoard_function_JS_API_2200 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_2300 + * @tc.name Deletes 300K PlainTextData + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test23',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_2300 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.clear() + + var textData = '' + for (var i = 0; i < (300 * 1024); i++){ + textData=textData + "A"; + } + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Removes the Record') + assert.equal(pasteData.removeRecordAt(0), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + console.log('SUB_pasteBoard_function_JS_API_2300 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_2400 + * @tc.name Deletes 30 record(s) + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test24',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_2400 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData0 = 'Hello World0' + console.log('createPlainTextData = ' + textData0) + var pasteData = pasteboard.createPlainTextData(textData0) + + var textData = '' + for(var i = 1; i < 30; i++) + { + textData = 'Hello World' + textData = textData + i + console.log('addTextRecord = ' + textData) + pasteData.addTextRecord(textData) + } + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 30) + + for(var i = 0; i < 30; i++) + { + console.log('Removes the Record') + assert.equal(pasteData.removeRecordAt(0), true) + } + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + console.log('SUB_pasteBoard_function_JS_API_2400 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_2500 + * @tc.name Delete one record of Muti records + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test25',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_2500 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + var htmlText = 'Hello World!' + console.log('addHtmlRecord = ' + htmlText) + pasteData.addHtmlRecord(htmlText) + + var wantText = new Want() + console.log('addWantRecord = ' + wantText) + pasteData.addWantRecord(wantText) + + var uriText = 'https://www.baidu.com/' + console.log('addUriRecord = ' + uriText) + pasteData.addUriRecord(uriText) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 4) + + console.log('Removes the third Record') + assert.equal(pasteData.removeRecordAt(2), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 3) + + console.log('Checks the pasteboard content') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordAt(0).plainText, textData) + assert.equal(pasteData.getRecordAt(1).htmlText, htmlText) + assert.equal(pasteData.getRecordAt(2).uri, uriText) + + console.log('SUB_pasteBoard_function_JS_API_2500 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_2600 + * @tc.name Replace one record or a null record + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test26',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_2600 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData0 = 'Hello World0' + console.log('createPlainTextData = ' + textData0) + var pasteData = pasteboard.createPlainTextData(textData0) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + var textData1 = 'Hello World1' + console.log('Replaces the Record = ' + textData1) + var pasteDataRecord = pasteboard.createPlainTextRecord(textData1) + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.replaceRecordAt(0, pasteDataRecord), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordAt(0).plainText, textData1) + + var textData2 = '' + console.log('Replaces the Record = ' + textData2) + pasteDataRecord = pasteboard.createPlainTextRecord(textData2) + assert.equal(pasteData.replaceRecordAt(0, pasteDataRecord), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('SUB_pasteBoard_function_JS_API_2600 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_2700 + * @tc.name Replace Muti records + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test27',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_2700 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData0 = 'Hello World!' + console.log('createPlainTextData = ' + textData0) + var pasteData = pasteboard.createPlainTextData(textData0) + + var htmlText0 = 'Hello World!' + console.log('addHtmlRecord = ' + htmlText0) + pasteData.addHtmlRecord(htmlText0) + + var wantText0 = new Want() + console.log('addWantRecord = ' + wantText0) + pasteData.addWantRecord(wantText0) + + var uriText0 = 'https://www.baidu.com/' + console.log('addUriRecord = ' + uriText0) + pasteData.addUriRecord(uriText0) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 4) + + var textData1 = 'Hello World1' + console.log('Replaces the PlainText = ' + textData1) + var pasteDataRecord = pasteboard.createPlainTextRecord(textData1) + assert.equal(pasteData.replaceRecordAt(0, pasteDataRecord), true) + + var htmlText1 = 'Hello World 1' + console.log('Replaces the htmlText = ' + htmlText1) + pasteDataRecord = pasteboard.createHtmlTextRecord(htmlText1) + assert.equal(pasteData.replaceRecordAt(0, pasteDataRecord), true) + + var wantText1 = new Want() + console.log('Replaces the wantText = ' + wantText1) + pasteDataRecord = pasteboard.createWantRecord(wantText1) + assert.equal(pasteData.replaceRecordAt(0, pasteDataRecord), true) + + var uriText1 = 'https://www.baidu.com/' + console.log('Replaces the uriText = ' + uriText1) + pasteDataRecord = pasteboard.createWantRecord(uriText1) + assert.equal(pasteData.createUriRecord(0, pasteDataRecord), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 4) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getRecordAt(0).plainText, textData1) + assert.equal(pasteData.getRecordAt(1).htmlText, htmlText1) + assert.equal(pasteData.getRecordAt(2).want, wantText1) + assert.equal(pasteData.getRecordAt(3).uri, uriText1) + + console.log('SUB_pasteBoard_function_JS_API_2700 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_2800 + * @tc.name Set and Query Property + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test28',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_2800 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Sets the Property') + var pasteDataProperty = pasteData.getProperty() + console.log('timestamp = ' + pasteDataProperty.timestamp) + pasteDataProperty.additions["one"] = "Hello" + pasteDataProperty.tag = "Test" + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the Property') + pasteData = systemPasteboard.getPasteData() + pasteDataProperty = pasteData.getProperty() + console.log('timestamp = ' + pasteDataProperty.timestamp) + assert.equal(pasteDataProperty.additions["one"], "Hello") + assert.equal(pasteDataProperty.tag, "Test") + assert.equal(pasteDataProperty.tag, pasteData.getTag()) + assert.equal(pasteDataProperty.mimeTypes[0], MIMETYPE_TEXT_PLAIN) + + console.log('SUB_pasteBoard_function_JS_API_2800 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_2900 + * @tc.name systemPasteboard.off:Set two PlainText records + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test29',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_2900 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.off(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + var uriText = 'https://www.baidu.com/' + console.log('Adds the uriText = ' + uriText) + var pasteDataRecord = pasteboard.createWantRecord(uriText) + pasteData.addRecord(pasteDataRecord) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 2) + + console.log('SUB_pasteBoard_function_JS_API_2900 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_3000 + * @tc.name systemPasteboard.off:Delete one record of Muti records + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test30',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_3000 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.off(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + var htmlText = 'Hello World!' + console.log('addHtmlRecord = ' + htmlText) + pasteData.addHtmlRecord(htmlText) + + var wantText = new Want() + console.log('addWantRecord = ' + wantText) + pasteData.addWantRecord(wantText) + + var uriText = 'https://www.baidu.com/' + console.log('addUriRecord = ' + uriText) + pasteData.addUriRecord(uriText) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 4) + + console.log('Removes the third Record') + assert.equal(pasteData.removeRecordAt(2), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 3) + + console.log('SUB_pasteBoard_function_JS_API_3000 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_3100 + * @tc.name systemPasteboard.off:Replace Muti records + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test31',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_3100 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.off(contentChanges) + systemPasteboard.clear() + + var textData0 = 'Hello World!' + console.log('createPlainTextData = ' + textData0) + var pasteData = pasteboard.createPlainTextData(textData0) + + var htmlText0 = 'Hello World!' + console.log('addHtmlRecord = ' + htmlText0) + pasteData.addHtmlRecord(htmlText0) + + var wantText0 = new Want() + console.log('addWantRecord = ' + wantText0) + pasteData.addWantRecord(wantText0) + + var uriText0 = 'https://www.baidu.com/' + console.log('addUriRecord = ' + uriText0) + pasteData.addUriRecord(uriText0) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 4) + + var textData1 = 'Hello World1' + console.log('Replaces the PlainText = ' + textData1) + var pasteDataRecord = pasteboard.createPlainTextRecord(textData1) + assert.equal(pasteData.replaceRecordAt(0, pasteDataRecord), true) + + var htmlText1 = 'Hello World 1' + console.log('Replaces the htmlText = ' + htmlText1) + pasteDataRecord = pasteboard.createHtmlTextRecord(htmlText1) + assert.equal(pasteData.replaceRecordAt(0, pasteDataRecord), true) + + var wantText1 = new Want() + console.log('Replaces the wantText = ' + wantText1) + pasteDataRecord = pasteboard.createWantRecord(wantText1) + assert.equal(pasteData.replaceRecordAt(0, pasteDataRecord), true) + + var uriText1 = 'https://www.baidu.com/' + console.log('Replaces the uriText = ' + uriText1) + pasteDataRecord = pasteboard.createWantRecord(uriText1) + assert.equal(pasteData.createUriRecord(0, pasteDataRecord), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 4) + + console.log('SUB_pasteBoard_function_JS_API_3100 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_3200 + * @tc.name systemPasteboard.clear:Set two PlainText records + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test32',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_3200 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + var uriText = 'https://www.baidu.com/' + console.log('Adds the uriText = ' + uriText) + var pasteDataRecord = pasteboard.createWantRecord(uriText) + pasteData.addRecord(pasteDataRecord) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 2) + + console.log('Clears the pasteboard content') + systemPasteboard.clear() + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + console.log('SUB_pasteBoard_function_JS_API_3200 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_3300 + * @tc.name Convert the PlainTextData = 'Hello World!' to text + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test33',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_3300 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Converts the PlainTextData to text') + var pasteDataRecord = pasteData.getRecordAt(0) + assert.equal(pasteDataRecord.convertToText(), textData) + + console.log('SUB_pasteBoard_function_JS_API_3300 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_3400 + * @tc.name Convert the PlainTextData = 'Hello 中国!@#$%^&*()_+{}\?.' to text + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test34',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_3400 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello 中国!@#$%^&*()_+{}\?.' + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Converts the PlainTextData to text') + var pasteDataRecord = pasteData.getRecordAt(0) + assert.equal(pasteDataRecord.convertToText(), textData) + + console.log('SUB_pasteBoard_function_JS_API_3400 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_3500 + * @tc.name Converts the uri = 'https://www.baidu.com/' to text + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test35',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_3500 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var uriText = 'https://www.baidu.com/' + console.log('createUriData = ' + uriText) + var pasteData = pasteboard.createUriData(uriText) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Converts the uri to text') + var pasteDataRecord = pasteData.getRecordAt(0) + assert.equal(pasteDataRecord.convertToText(), uriText) + + console.log('SUB_pasteBoard_function_JS_API_3500 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_3600 + * @tc.name Converts the uri = 'Hello 中国!@#$%^&*()_+{}\?.' to text + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test36',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_3600 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var uriText = 'Hello 中国!@#$%^&*()_+{}\?.' + console.log('createUriData = ' + uriText) + var pasteData = pasteboard.createUriData(uriText) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Converts the uri to text') + var pasteDataRecord = pasteData.getRecordAt(0) + assert.equal(pasteDataRecord.convertToText(), uriText) + + console.log('SUB_pasteBoard_function_JS_API_3600 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_3700 + * @tc.name Convert the PlainTextData = 'Hello World!' to text + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test37',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_3700 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createPlainTextRecord = ' + textData) + var pasteDataRecord = pasteboard.createPlainTextRecord(textData) + var pasteData = systemPasteboard.getPasteData() + pasteData.addRecord(pasteDataRecord) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Converts the PlainTextData to text') + pasteDataRecord = pasteData.getRecordAt(0) + assert.equal(pasteDataRecord.convertToText(), textData) + + console.log('SUB_pasteBoard_function_JS_API_3700 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_3800 + * @tc.name Converts the uri = 'https://www.baidu.com/' to text + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test38',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_3800 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var uriText = 'https://www.baidu.com/' + console.log('createUriRecord = ' + uriText) + var pasteDataRecord = pasteboard.createUriRecord(uriText) + var pasteData = systemPasteboard.getPasteData() + pasteData.addRecord(pasteDataRecord) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Converts the uri to text') + pasteDataRecord = pasteData.getRecordAt(0) + assert.equal(pasteDataRecord.convertToText(), uriText) + + console.log('SUB_pasteBoard_function_JS_API_3800 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_3900 + * @tc.name Converts the text,uri from Muti records + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test39',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_3900 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + var htmlText = 'Hello World!' + console.log('addHtmlRecord = ' + htmlText) + pasteData.addHtmlRecord(htmlText) + + var wantText = new Want() + console.log('addWantRecord = ' + wantText) + pasteData.addWantRecord(wantText) + + var uriText = 'https://www.baidu.com/' + console.log('addUriRecord = ' + uriText) + pasteData.addUriRecord(uriText) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 4) + + console.log('Converts the PlainTextData to text') + pasteDataRecord = pasteData.getRecordAt(0) + assert.equal(pasteDataRecord.convertToText(), textData) + + console.log('Converts the uri to text') + pasteDataRecord = pasteData.getRecordAt(3) + assert.equal(pasteDataRecord.convertToText(), uriText) + + console.log('SUB_pasteBoard_function_JS_API_3900 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_4000 + * @tc.name Delete one and then add another PlainTextData + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test40',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_4000 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createUriData = ' + textData) + var pasteData = pasteboard.createUriData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Removes the Record') + assert.equal(pasteData.removeRecordAt(0), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + var textDataNew = 'Hello World!-New' + console.log('createUriData = ' + textDataNew) + var pasteData = pasteboard.createUriData(textDataNew) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getRecordAt(0).plainText, textDataNew) + + console.log('SUB_pasteBoard_function_JS_API_4000 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_4100 + * @tc.name Delete the replaced record + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test41',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_4100 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData0 = 'Hello World0' + console.log('createUriData = ' + textData0) + var pasteData = pasteboard.createUriData(textData0) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + var textData1 = 'Hello World1' + console.log('Replaces the Record = ' + textData1) + var pasteDataRecord = pasteboard.createPlainTextRecord(textData1) + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.replaceRecordAt(0, pasteDataRecord), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordAt(0).plainText, textData1) + + console.log('Removes the the replaced record') + assert.equal(pasteData.removeRecordAt(0), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('SUB_pasteBoard_function_JS_API_4100 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_4200 + * @tc.name Delete one and then add another PlainTextData and then clear + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test42',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_4200 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createUriData = ' + textData) + var pasteData = pasteboard.createUriData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Removes the Record') + assert.equal(pasteData.removeRecordAt(0), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + var textDataNew = 'Hello World!-New' + console.log('createUriData = ' + textDataNew) + var pasteData = pasteboard.createUriData(textDataNew) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getRecordAt(0).plainText, textDataNew) + + console.log('Clears the pasteboard content') + systemPasteboard.clear() + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + console.log('SUB_pasteBoard_function_JS_API_4200 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_4300 + * @tc.name First off the changes Event and then make it on + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test43',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_4300 start') + + console.log('Off the content changes') + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.off(contentChanges) + systemPasteboard.clear() + + var textData = 'Hello World!' + console.log('createUriData = ' + textData) + var pasteData = pasteboard.createUriData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('On the content changes') + systemPasteboard.on(contentChanges) + + console.log('Removes the Record') + assert.equal(pasteData.removeRecordAt(0), true) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + var textDataNew = 'Hello World!-New' + console.log('createUriData = ' + textDataNew) + var pasteData = pasteboard.createUriData(textDataNew) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Checks the pasteboard content') + assert.equal(pasteData.getRecordAt(0).plainText, textDataNew) + + console.log('SUB_pasteBoard_function_JS_API_4300 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_4400 + * @tc.name Clears 300K PlainTextData + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test44',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_4400 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.clear() + + var textData = '' + for (var i = 0; i < (300 * 1024); i++){ + textData=textData + "A"; + } + console.log('createPlainTextData = ' + textData) + var pasteData = pasteboard.createPlainTextData(textData) + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks there is content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), true) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 1) + + console.log('Clears the pasteboard content') + systemPasteboard.clear() + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + console.log('SUB_pasteBoard_function_JS_API_4400 end'); + }) + + /** + * @tc.number SUB_pasteBoard_function_JS_API_4500 + * @tc.name Deletes 30 record(s) + * @tc.desc Test pasteBoard API functionality. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('pasteboard_function_test45',0, async () => { + console.log('SUB_pasteBoard_function_JS_API_4500 start') + + var systemPasteboard = pasteboard.getSystemPasteboard() + systemPasteboard.on(contentChanges) + systemPasteboard.clear() + + var textData0 = 'Hello World0' + console.log('createPlainTextData = ' + textData0) + var pasteData = pasteboard.createPlainTextData(textData0) + + var textData = '' + for(var i = 1; i < 30; i++) + { + textData = 'Hello World' + textData = textData + i + console.log('addTextRecord = ' + textData) + pasteData.addTextRecord(textData) + } + + console.log('Writes PasteData to the pasteboard') + systemPasteboard.setPasteData(pasteData) + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 30) + + console.log('Clears the pasteboard content') + systemPasteboard.clear() + + console.log('Checks the number of records') + pasteData = systemPasteboard.getPasteData() + assert.equal(pasteData.getRecordCount(), 0) + + console.log('Checks there is no content in the pasteboard') + assert.equal(systemPasteboard.hasPasteData(), false) + + console.log('SUB_pasteBoard_function_JS_API_4500 end'); + }) + + /** + * The callback function is used for pasteboard content changes + */ + function contentChanges() { + console.log('#EVENT: The content is changed in the pasteboard') + } +}) diff --git a/miscservices/PasteBoardTest_js/src/main/resources/base/element/string.json b/miscservices/PasteBoardTest_js/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c557307449d870c30d3424570a169ecdc9a06651 --- /dev/null +++ b/miscservices/PasteBoardTest_js/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "JstimeTest" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/miscservices/PasteBoardTest_js/src/main/resources/base/media/icon.png b/miscservices/PasteBoardTest_js/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/miscservices/PasteBoardTest_js/src/main/resources/base/media/icon.png differ diff --git a/multimedia/image/image_js_standard/src/main/js/test/image.test.js b/multimedia/image/image_js_standard/src/main/js/test/image.test.js index 6e73679ba443b59c9c256413139a11ba5e5b41be..889c32aca0b2781c5ea9ae7b48a8b8d8fb361ee1 100644 --- a/multimedia/image/image_js_standard/src/main/js/test/image.test.js +++ b/multimedia/image/image_js_standard/src/main/js/test/image.test.js @@ -1053,7 +1053,7 @@ describe('Image', function () { console.info('TC_25-1 success'); done(); }) - pixelmap.getBytesNumberPerRow( num => { + pixelmap.getBytesNumberPerRow().then(num => { console.info('TC_025-1 num is ' + num); expect(num == expectNum).assertTrue(); done(); @@ -1086,7 +1086,7 @@ describe('Image', function () { console.info('TC_026-1 success'); done(); }) - pixelmap.getPixelBytesNumber(num => { + pixelmap.getPixelBytesNumber().then(num => { console.info('TC_026-1 num is ' + num); expect(num == expectNum).assertTrue(); done(); @@ -1112,22 +1112,22 @@ describe('Image', function () { it('TC_027', 0, async function (done) { const color = new ArrayBuffer(96); let opts = { alphaType: 0, editable: true, pixelFormat: 3, scaleMode: 1, size: { height: 4, width: 6 } } - image.createPixelMap(color, opts) - .then( pixelmap => { - if (pixelmap == null) { - console.info('TC_027 createPixelMap failed'); - expect(false).assertTrue() - done(); - } - pixelmap.release().then(() => { - console.info('TC_027 success'); - expect(true).assertTrue(); + image.createPixelMap(color, opts).then(pixelmap => { + if (pixelmap == null) { + console.info('TC_027 createPixelMap failed'); + expect(false).assertTrue() + done(); + } + pixelmap.release().then(() => { + console.info('TC_027 success'); + expect(true).assertTrue(); + done(); + }) + .catch(error => { + console.log('TC_027 error: ' + error); + expect().assertFail(); done(); }) - }).catch(error => { - console.log('TC_027 error: ' + error); - expect().assertFail(); - done(); }) }) @@ -1146,20 +1146,17 @@ describe('Image', function () { const color = new ArrayBuffer(96); let opts = { alphaType: 0, editable: true, pixelFormat: 3, scaleMode: 1, size: { height: 4, width: 6 } } image.createPixelMap(color, opts, pixelmap => { - expect(pixelmap !== null).assertTrue(); - console.info('TC_026-1 success'); - done(); - }) - pixelmap.release(()=>{ - expect(true).assertTrue(); - console.info('TC_027-1 success'); - done(); - }) - .catch(error => { - console.log('TC_027-1 error: ' + error); - expect().assertFail(); - done(); - }) + if (pixelmap == null) { + console.info('TC_027 createPixelMap failed'); + expect(false).assertTrue() + done(); + } + pixelmap.release(()=>{ + expect(true).assertTrue(); + console.log('TC_027-1 success'); + done(); + }) + }) }) /** @@ -1465,8 +1462,8 @@ describe('Image', function () { console.info('TC_044 release'); expect(true).assertTrue(); done(); - }).catch(()=>{ - console.log('TC_044 error: ' + error); + }).catch(error => { + console.info('TC_044 release'); expect(false).assertTrue(); done(); }) @@ -2519,7 +2516,7 @@ describe('Image', function () { } else { done(); } - done(); + done(); } catch (error) { console.info('TC_053 updateData failed ' + error); } @@ -4565,9 +4562,9 @@ describe('Image', function () { expect(false).assertTrue(); done(); } else { - expect(imageSourceApi.supportedFormats !=null).assertTrue(); + expect(imageSourceApi.supportedFormats != null).assertTrue(); console.info(imageSourceApi.supportedFormats); - console.info('TC_164 success '); + console.info('TC_164 success'); done(); } }) @@ -4588,9 +4585,9 @@ describe('Image', function () { expect(false).assertTrue(); done(); } else { - expect(imagePackerApi.supportedFormats !=null).assertTrue(); + expect(imagePackerApi.supportedFormats != null).assertTrue(); console.info(imagePackerApi.supportedFormats); - console.info('TC_166 success '); + console.info('TC_166 success'); done(); } }) @@ -4624,4 +4621,1634 @@ describe('Image', function () { done(); }) }) + + /** + * @tc.number : TC_168 + * @tc.name : isEditable + * @tc.desc : 1.create pixelmap + * 2.call isEditable + * 3.return true + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_168', 0, async function (done) { + const Color = new ArrayBuffer(96); + let opts = { alphaType: 0, editable: true, pixelFormat: 3, scaleMode: 1, size: { height: 2, width: 3 } } + image.createPixelMap(Color, opts, pixelmap => { + if(pixelmap == null){ + console.info('TC_168 create pixelmap failed'); + expect(false).assertTrue(); + done(); + }else { + expect(pixelmap.isEditable == true).assertTrue(); + console.info('TC_168 success '); + done(); + } + }) + }) + + /** + * @tc.number : TC_171 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(BitsPerSample) + * 4.The return value is not empty + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_171', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_171 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'4'} + imageSourceApi.getImageProperty("BitsPerSample",property) + .then(data => { + console.info('TC_171 BitsPerSample' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + .catch(error => { + console.log('TC_171 error: ' + error); + expect(false).assertFail(); + done(); + }) + } + }) + + /** + * @tc.number : TC_171-1 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(Orientation) + * 4.The return value is not empty + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_171-1', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_171-1 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'4'} + imageSourceApi.getImageProperty("Orientation",property) + .then(data => { + console.info('TC_171-1 Orientation' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + .catch(error => { + console.log('TC_171-1 error: ' + error); + expect(false).assertFail(); + done(); + }) + } + }) + + /** + * @tc.number : TC_171-2 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(ImageLength) + * 4.The return value is not empty + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_171-2', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_171-2 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("ImageLength",property) + .then(data => { + console.info('TC_171-2 ImageLength' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + .catch(error => { + console.log('TC_171-2 error: ' + error); + expect(false).assertFail(); + done(); + }) + } + }) + + /** + * @tc.number : TC_171-3 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(ImageLength) + * 4.The return value is not empty + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_171-3', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_171-3 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("ImageWidth",property) + .then(data => { + console.info('TC_171-3 ImageWidth' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + .catch(error => { + console.log('TC_171-3 error: ' + error); + expect(false).assertFail(); + done(); + }) + } + }) + + /** + * @tc.number : TC_171-4 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(ImageLength) + * 4.The return value is not empty + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_171-4', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_171-4 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("GPSLatitude",property) + .then(data => { + console.info('TC_171-4 GPSLatitude' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + .catch(error => { + console.log('TC_171-4 error: ' + error); + expect(false).assertFail(); + done(); + }) + } + }) + + /** + * @tc.number : TC_171-5 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(ImageLength) + * 4.The return value is not empty + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_171-5', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_171-5 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("GPSLongitude",property) + .then(data => { + console.info('TC_171-5 GPSLongitude' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + .catch(error => { + console.log('TC_171-5 error: ' + error); + expect(false).assertFail(); + done(); + }) + } + }) + + /** + * @tc.number : TC_171-6 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(GPSLatitudeRef) + * 4.The return value is not empty + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_171-6', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_171-6 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("GPSLatitudeRef",property) + .then(data => { + console.info('TC_171-6 GPSLatitudeRef' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + .catch(error => { + console.log('TC_171-6 error: ' + error); + expect(false).assertFail(); + done(); + }) + } + }) + + /** + * @tc.number : TC_171-7 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(ImageLength) + * 4.The return value is not empty + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_171-7', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_171-7 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("GPSLongitudeRef",property) + .then(data => { + console.info('TC_171-7 GPSLongitudeRef' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + .catch(error => { + console.log('TC_171-7 error: ' + error); + expect(false).assertFail(); + done(); + }) + } + }) + + /** + * @tc.number : TC_171-8 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(ImageLength) + * 4.The return value is not empty + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_171-8', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_171-8 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("DateTimeOriginal",property) + .then(data => { + console.info('TC_171-8 DateTimeOriginal' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + .catch(error => { + console.log('TC_171-8 error: ' + error); + expect(false).assertFail(); + done(); + }) + } + }) + + /** + * @tc.number : TC_172 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.call getImageProperty(BitsPerSample) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_172', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_172 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.getImageProperty("BitsPerSample",(error,data) => { + console.info('TC_172 BitsPerSample' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_172-1 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.call getImageProperty(Orientation) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_172-1', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_172-1 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.getImageProperty("Orientation",(error,data) => { + console.info('TC_172-1 Orientation' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_172-2 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.call getImageProperty(ImageLength) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_172-2', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_172-2 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.getImageProperty("ImageLength",(error,data) => { + console.info('TC_172-2 ImageLength' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_172-3 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.call getImageProperty(ImageWidth) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_172-3', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_172-3 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.getImageProperty("ImageWidth",(error,data) => { + console.info('TC_172-3 ImageWidth' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_172-4 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.call getImageProperty(GPSLatitude) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_172-4', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_172-4 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.getImageProperty("GPSLatitude",(error,data) => { + console.info('TC_172-4 GPSLatitude' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_172-5 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.call getImageProperty(GPSLongitude) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_172-5', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_172-5 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.getImageProperty("GPSLongitude",(error,data) => { + console.info('TC_172-5 GPSLongitude' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_172-6 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.call getImageProperty(GPSLatitudeRef) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_172-6', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_172-6 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.getImageProperty("GPSLatitudeRef",(error,data) => { + console.info('TC_172-6 GPSLatitudeRef' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_172-7 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.call getImageProperty(GPSLongitudeRef) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_172-7', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_172-7 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.getImageProperty("GPSLongitudeRef",(error,data) => { + console.info('TC_172-7 GPSLongitudeRef' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_172-8 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.call getImageProperty(DateTimeOriginal) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_172-8', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_172-8 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.getImageProperty("DateTimeOriginal",(error,data) => { + console.info('TC_172-8 DateTimeOriginal' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_173 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(BitsPerSample,property) + * 4.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_173', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_173 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => { + console.info('TC_173 BitsPerSample' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_173-1 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(Orientation,property) + * 4.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_173-1', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_173-1 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("Orientation",property,(error,data) => { + console.info('TC_173-1 Orientation' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_173-2 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(ImageLength,property) + * 4.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_173-2', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_173-2 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("ImageLength",property,(error,data) => { + console.info('TC_173-2 ImageLength' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_173-3 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(ImageWidth,property) + * 4.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_173-3', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_173-3 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("ImageWidth",property,(error,data) => { + console.info('TC_173-3 ImageWidth' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_173-4 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(GPSLatitude,property) + * 4.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_173-4', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_173-4 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("GPSLatitude",property,(error,data) => { + console.info('TC_173-4 GPSLatitude' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_173-5 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(GPSLongitude,property) + * 4.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_173-5', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_173-5 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("GPSLongitude",property,(error,data) => { + console.info('TC_173-5 GPSLongitude' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_173-6 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(GPSLatitudeRef,property) + * 4.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_173-6', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_173-6 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("GPSLatitudeRef",property,(error,data) => { + console.info('TC_173-6 GPSLatitudeRef' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_173-7 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(GPSLongitudeRef,property) + * 4.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_173-7', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_173-7 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("GPSLongitudeRef",property,(error,data) => { + console.info('TC_173-7 GPSLongitudeRef' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_173-8 + * @tc.name : getImageProperty + * @tc.desc : 1.create imagesource + * 2.set property + * 3.call getImageProperty(DateTimeOriginal,property) + * 4.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_173-8', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_173-8 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:0,defaultValue:'10'} + imageSourceApi.getImageProperty("DateTimeOrigina",property,(error,data) => { + console.info('TC_173-8 DateTimeOriginal' + data); + expect(data !== null).assertTrue(); + expect(data !== undefined).assertTrue(); + expect(data !== '').assertTrue(); + done(); + }) + } + }) + + /** + * @tc.number : TC_174 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_174', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_174 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + console.info('TC_174 start modifyImageProperty'); + imageSourceApi.modifyImageProperty("BitsPerSample","4") + .then(() => { + console.info('TC_174 start ImageProperty'); + imageSourceApi.getImageProperty("BitsPerSample").then((value) => { + console.info('TC_174 BitsPerSample' + value); + expect(value == '4').assertTrue(); + done(); + }).catch((err)=>{ + console.info(`TC_174 getimageproperty failed, err:${err}`); + expect(false).assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_174-1 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_174-1', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_174-1 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("Orientation","2") + .then(() => { + imageSourceApi.getImageProperty("Orientation").then((value) => { + console.info('TC_174-1 Orientation' + value); + expect(value == '2').assertTrue(); + done(); + }).catch((err)=>{ + console.info(`TC_174-1 getimageproperty failed, err:${err}`); + expect(false).assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_174-2 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_174-2', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_174-2 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("ImageLength","200") + .then(() => { + imageSourceApi.getImageProperty("ImageLength").then((value) => { + console.info('TC_174-2 ImageLength' + value); + expect(value == '200').assertTrue(); + done(); + }).catch((err)=>{ + console.info(`TC_174-2 getimageproperty failed, err:${err}`); + expect(false).assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_174-3 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_174-3', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_174-3 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("ImageWidth","200") + .then(() => { + imageSourceApi.getImageProperty("ImageWidth").then((value) => { + console.info('TC_174-3 ImageWidth' + value); + expect(value == '200').assertTrue(); + done(); + }).catch((err)=>{ + console.info(`TC_174-3 getimageproperty failed, err:${err}`); + expect(false).assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_174-4 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_174-4', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_174-4 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("GPSLatitude","57.88888") + .then(() => { + imageSourceApi.getImageProperty("GPSLatitude").then((value) => { + console.info('TC_174-4 GPSLatitude' + value); + expect(value == '57.88888').assertTrue(); + done(); + }).catch((err)=>{ + console.info(`TC_174-4 getimageproperty failed, err:${err}`); + expect(false).assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_174-5 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_174-5', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_174-5 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("GPSLongitude","205.3332") + .then(() => { + imageSourceApi.getImageProperty("GPSLongitude").then((value) => { + console.info('TC_174-5 GPSLongitude' + value); + expect(value == '205.3332').assertTrue(); + done(); + }).catch((err)=>{ + console.info(`TC_174-5 getimageproperty failed, err:${err}`); + expect(false).assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_174-6 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_174-6', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_174-6 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("GPSLatitudeRef","N") + .then(() => { + imageSourceApi.getImageProperty("GPSLatitudeRef").then((value) => { + console.info('TC_174-6 GPSLatitudeRef' + value); + expect(value == 'N').assertTrue(); + done(); + }).catch((err)=>{ + console.info(`TC_174-6 getimageproperty failed, err:${err}`); + expect(false).assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_174-7 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_174-7', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_174-7 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("GPSLatitudeRef","W") + .then(() => { + imageSourceApi.getImageProperty("GPSLatitudeRef").then((value) => { + console.info('TC_174-7 GPSLatitudeRef' + value); + expect(value == 'W').assertTrue(); + done(); + }).catch((err)=>{ + console.info(`TC_174-7 getimageproperty failed, err:${err}`); + expect(false).assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_174-8 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_174-8', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_174-8 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("DateTimeOriginal","2022-09-09") + .then(() => { + imageSourceApi.getImageProperty("DateTimeOriginal").then((value) => { + console.info('TC_174-8 DateTimeOriginal' + value); + expect(value == '2022-09-09').assertTrue(); + done(); + }).catch((err)=>{ + console.info(`TC_174-8 getimageproperty failed, err:${err}`); + expect(false).assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_175 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_175', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_175 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("BitsPerSample","4",() => { + imageSourceApi.getImageProperty("BitsPerSample",(error,value) => { + console.info('TC_175 BitsPerSample' + value); + expect(value == "4").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_175-1 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_175-1', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_175-1 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("Orientation","2",() => { + imageSourceApi.getImageProperty("Orientation",(error,value) => { + console.info('TC_175-1 Orientation' + value); + expect(value == "2").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_175-2 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_175-2', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_175-2 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("ImageLength","200",() => { + imageSourceApi.getImageProperty("ImageLength",(error,value) => { + console.info('TC_175-2 ImageLength' + value); + expect(value == "200").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_175-3 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_175-3', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_175-3 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("ImageWidth","200",() => { + imageSourceApi.getImageProperty("ImageWidth",(error,value) => { + console.info('TC_175-3 ImageWidth' + value); + expect(value == "200").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_175-4 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_175-4', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_175-4 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("GPSLatitude","57.88888",() => { + imageSourceApi.getImageProperty("GPSLatitude",(error,value) => { + console.info('TC_175-4 GPSLatitude' + value); + expect(value == "57.88888").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_175-5 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_175-5', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_175-5 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("GPSLongitude","205.3332",() => { + imageSourceApi.getImageProperty("GPSLongitude",(error,value) => { + console.info('TC_175-5 GPSLongitude' + value); + expect(value == "205.3332").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_175-6 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_175-6', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_175-6 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("GPSLatitudeRef","N",() => { + imageSourceApi.getImageProperty("GPSLatitudeRef",(error,value) => { + console.info('TC_175-6 GPSLatitudeRef' + value); + expect(value == "N").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_175-7 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_175-7', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_175-7 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("GPSLongitudeRef","W",() => { + imageSourceApi.getImageProperty("GPSLongitudeRef",(error,value) => { + console.info('TC_175-7 GPSLongitudeRef' + value); + expect(value == "W").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_175-8 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_175-8', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_175-8 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + imageSourceApi.modifyImageProperty("DateTimeOriginal","2022-09-09",() => { + imageSourceApi.getImageProperty("DateTimeOriginal",(error,value) => { + console.info('TC_175-8 DateTimeOriginal' + value); + expect(value == "2022-09-09").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_176 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value,options) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_176', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_176 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:1,defaultValue:'1'} + imageSourceApi.modifyImageProperty("BitsPerSample","4",property,() => { + imageSourceApi.getImageProperty("BitsPerSample",property,(error,value) => { + console.info('TC_176 BitsPerSample' + value); + expect(value == "4").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_176-1 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value,options) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_176-1', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_176-1 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:1,defaultValue:'1'} + imageSourceApi.modifyImageProperty("Orientation","2",property,() => { + imageSourceApi.getImageProperty("Orientation",property,(error,value) => { + console.info('TC_176-1 Orientation' + value); + expect(value == "2").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_176-2 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value,options) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_176-2', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_176-2 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:1,defaultValue:'1'} + imageSourceApi.modifyImageProperty("ImageLength","200",property,() => { + imageSourceApi.getImageProperty("ImageLength",property,(error,value) => { + console.info('TC_176-2 ImageLength' + value); + expect(value == "200").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_176-3 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value,options) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_176-3', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_176-3 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:1,defaultValue:'1'} + imageSourceApi.modifyImageProperty("ImageWidth","200",property,() => { + imageSourceApi.getImageProperty("ImageWidth",property,(error,value) => { + console.info('TC_176-3 ImageWidth' + value); + expect(value == "200").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_176-4 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value,options) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_176-4', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_176-4 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:1,defaultValue:'1'} + imageSourceApi.modifyImageProperty("GPSLatitude","57.88888",property,() => { + imageSourceApi.getImageProperty("GPSLatitude",property,(error,value) => { + console.info('TC_176-4 GPSLatitude' + value); + expect(value == "57.88888").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_176-5 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value,options) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_176-5', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_176-5 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:1,defaultValue:'1'} + imageSourceApi.modifyImageProperty("GPSLongitude","205.3332",property,() => { + imageSourceApi.getImageProperty("GPSLongitude",property,(error,value) => { + console.info('TC_176-5 GPSLongitude' + value); + expect(value == "205.3332").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_176-6 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value,options) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_176-6', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_176-6 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:1,defaultValue:'1'} + imageSourceApi.modifyImageProperty("GPSLatitudeRef","N",property,() => { + imageSourceApi.getImageProperty("GPSLatitudeRef",property,(error,value) => { + console.info('TC_176-6 GPSLatitudeRef' + value); + expect(value == "N").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_176-7 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value,options) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_176-7', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_176-7 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:1,defaultValue:'1'} + imageSourceApi.modifyImageProperty("GPSLongitudeRef","W",property,() => { + imageSourceApi.getImageProperty("GPSLongitudeRef",property,(error,value) => { + console.info('TC_176-7 GPSLongitudeRef' + value); + expect(value == "W").assertTrue(); + done(); + }) + }) + } + }) + + /** + * @tc.number : TC_176-8 + * @tc.name : modifyImageProperty + * @tc.desc : 1.create imagesource + * 2.call modifyImageProperty(key,value,options) + * 3.return null + * @tc.size : MEDIUM + * @tc.type : Functional + * @tc.level : Level 1 + */ + it('TC_176-8', 0, async function (done) { + const imageSourceApi = image.createImageSource('/data/local/tmp/test_exif.jpg'); + if (imageSourceApi == null) { + console.info('TC_176-8 create image source failed'); + expect(false).assertTrue(); + done(); + } else { + let property = {index:1,defaultValue:'1'} + imageSourceApi.modifyImageProperty("DateTimeOriginal","2022-09-09",property,() => { + imageSourceApi.getImageProperty("DateTimeOriginal",property,(error,value) => { + console.info('TC_176-8 DateTimeOriginal' + value); + expect(value == "2022-09-09").assertTrue(); + done(); + }) + }) + } + }) }) \ No newline at end of file diff --git a/multimedia/image/image_js_standard/src/main/js/test/testImg.js b/multimedia/image/image_js_standard/src/main/js/test/testImg.js index 8cd8157aaba1de6a4203332b4ff6f403f057076a..fcc3927237a0b615888beb1c61a8e0b4288a848d 100644 --- a/multimedia/image/image_js_standard/src/main/js/test/testImg.js +++ b/multimedia/image/image_js_standard/src/main/js/test/testImg.js @@ -1,742 +1,610 @@ -/* - * Copyright (C) 2022 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. - */ - -let testPng = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 100, 0, 0, 0, 100, 8, 6, 0, 0, 0, 112, 226, 149, - 84, 0, 0, 32, 0, 73, 68, 65, 84, 120, 1, 212, 193, 123, 176, 231, 247, 93, 223, 247, 231, 251, 253, 249, 254, 126, 231, 156, 61, 123, 191, 105, - 37, 173, 180, 186, 95, 173, 187, 228, 43, 166, 182, 133, 109, 44, 108, 160, 6, 154, 105, 157, 116, 104, 50, 64, 72, 155, 41, 195, 64, 167, 13, 80, - 218, 73, 166, 76, 254, 104, 254, 104, 167, 51, 253, 39, 51, 45, 52, 77, 161, 36, 29, 19, 2, 24, 98, 140, 28, 91, 24, 91, 150, 44, 164, 213, - 93, 187, 146, 86, 123, 95, 237, 253, 156, 243, 251, 253, 190, 223, 247, 235, 213, 253, 237, 34, 220, 106, 86, 182, 105, 160, 99, 30, 143, 224, 175, 177, - 31, 251, 145, 31, 102, 101, 109, 133, 133, 241, 194, 174, 42, 253, 224, 108, 54, 123, 100, 24, 250, 235, 135, 161, 178, 239, 251, 67, 17, 241, 149, 42, - 253, 238, 100, 50, 121, 178, 117, 76, 207, 31, 221, 194, 243, 7, 30, 229, 187, 89, 240, 215, 212, 15, 253, 208, 167, 24, 47, 108, 98, 186, 118, 242, - 253, 165, 250, 135, 150, 62, 176, 178, 178, 186, 208, 247, 61, 146, 232, 103, 61, 173, 235, 4, 62, 106, 243, 175, 165, 250, 159, 108, 61, 149, 153, 126, - 252, 235, 79, 241, 221, 42, 248, 107, 232, 83, 159, 252, 126, 90, 27, 1, 250, 158, 217, 172, 255, 167, 171, 107, 43, 183, 204, 102, 61, 179, 233, 140, - 201, 100, 66, 149, 176, 4, 1, 173, 53, 70, 163, 17, 173, 181, 87, 128, 255, 102, 54, 27, 254, 143, 214, 114, 248, 198, 83, 79, 243, 221, 168, 241, - 215, 208, 237, 183, 221, 66, 102, 94, 93, 195, 240, 63, 207, 102, 211, 251, 214, 86, 39, 172, 156, 91, 101, 101, 117, 194, 249, 149, 53, 250, 97, 96, - 50, 157, 113, 254, 252, 10, 67, 153, 201, 116, 74, 149, 182, 70, 196, 71, 50, 242, 108, 102, 62, 177, 107, 231, 14, 31, 57, 122, 140, 239, 54, 141, - 191, 160, 237, 91, 55, 51, 30, 141, 216, 182, 109, 235, 120, 211, 198, 13, 235, 150, 214, 45, 141, 186, 46, 180, 113, 227, 6, 175, 174, 174, 241, 87, - 237, 83, 159, 122, 132, 79, 127, 252, 251, 121, 97, 223, 190, 191, 63, 235, 251, 31, 95, 91, 155, 196, 233, 211, 167, 89, 93, 153, 176, 54, 153, 48, - 212, 192, 80, 66, 18, 85, 98, 54, 155, 49, 157, 78, 137, 8, 76, 44, 142, 70, 221, 123, 35, 120, 153, 244, 179, 87, 238, 216, 195, 145, 99, 135, - 248, 110, 210, 241, 29, 186, 239, 190, 123, 233, 103, 253, 226, 120, 220, 30, 176, 253, 48, 196, 93, 147, 201, 100, 199, 80, 53, 93, 92, 92, 124, 117, - 109, 109, 237, 209, 141, 27, 55, 254, 193, 245, 215, 95, 127, 124, 239, 222, 189, 12, 195, 192, 95, 133, 8, 248, 151, 127, 240, 185, 235, 134, 161, 255, - 143, 38, 147, 181, 56, 123, 246, 12, 179, 217, 140, 201, 108, 74, 169, 232, 135, 129, 140, 4, 155, 204, 100, 174, 170, 88, 93, 93, 69, 18, 227, 81, - 183, 117, 97, 60, 254, 197, 136, 120, 146, 54, 125, 133, 239, 50, 29, 223, 198, 189, 247, 220, 197, 179, 207, 189, 196, 226, 194, 232, 254, 229, 117, 139, - 63, 11, 60, 50, 244, 195, 150, 217, 48, 208, 186, 14, 19, 100, 22, 227, 241, 194, 143, 75, 254, 234, 139, 47, 190, 248, 143, 134, 97, 248, 131, 204, - 212, 5, 252, 101, 75, 155, 176, 63, 58, 153, 206, 110, 155, 76, 166, 172, 172, 174, 49, 153, 206, 24, 134, 1, 99, 144, 113, 136, 204, 196, 54, 153, - 201, 92, 85, 49, 157, 78, 89, 89, 93, 163, 181, 188, 167, 139, 246, 31, 63, 249, 141, 39, 126, 249, 129, 251, 31, 224, 137, 39, 159, 230, 187, 69, - 242, 45, 188, 255, 125, 239, 37, 91, 151, 239, 125, 207, 253, 63, 178, 180, 180, 244, 235, 227, 209, 232, 51, 150, 183, 204, 102, 51, 214, 214, 86, 89, - 91, 155, 176, 178, 178, 198, 116, 58, 163, 239, 135, 113, 149, 190, 39, 34, 254, 151, 174, 235, 62, 35, 41, 248, 75, 246, 233, 79, 125, 146, 197, 241, - 186, 5, 75, 223, 95, 67, 181, 233, 116, 202, 116, 50, 101, 24, 6, 108, 97, 153, 214, 26, 17, 193, 91, 108, 51, 215, 90, 35, 34, 152, 205, 102, - 72, 34, 51, 31, 121, 224, 254, 7, 183, 65, 240, 221, 164, 227, 29, 124, 240, 131, 239, 103, 113, 221, 152, 209, 180, 251, 248, 226, 120, 252, 63, 88, - 190, 106, 101, 117, 149, 181, 181, 53, 86, 86, 87, 153, 245, 51, 250, 190, 152, 78, 103, 72, 98, 24, 6, 134, 97, 32, 34, 118, 117, 93, 247, 43, - 85, 117, 40, 51, 63, 95, 85, 252, 165, 137, 160, 52, 236, 138, 200, 123, 38, 211, 9, 125, 223, 51, 87, 85, 64, 144, 25, 204, 69, 4, 146, 200, - 76, 230, 36, 49, 55, 12, 3, 17, 48, 12, 3, 195, 208, 174, 109, 173, 93, 11, 188, 201, 119, 145, 142, 119, 176, 184, 48, 198, 131, 239, 88, 183, - 184, 244, 143, 9, 174, 90, 89, 91, 97, 50, 153, 178, 58, 153, 50, 157, 245, 204, 102, 61, 85, 98, 78, 18, 195, 48, 48, 23, 17, 116, 93, 119, - 181, 164, 95, 152, 205, 102, 79, 3, 199, 184, 140, 255, 226, 231, 126, 158, 151, 95, 126, 153, 135, 191, 239, 225, 118, 195, 13, 215, 143, 55, 109, 222, - 180, 28, 17, 203, 4, 75, 24, 108, 97, 27, 75, 171, 42, 77, 215, 38, 107, 43, 215, 93, 119, 195, 228, 23, 254, 193, 127, 185, 222, 25, 155, 185, - 96, 54, 155, 209, 15, 3, 85, 34, 51, 177, 185, 40, 34, 152, 179, 205, 219, 169, 68, 63, 155, 49, 30, 143, 151, 34, 189, 17, 155, 239, 38, 29, - 151, 241, 177, 143, 62, 76, 223, 15, 227, 117, 235, 22, 255, 243, 209, 168, 187, 107, 229, 252, 10, 125, 223, 51, 157, 245, 12, 67, 49, 157, 245, 244, - 179, 30, 219, 204, 101, 38, 173, 53, 102, 179, 25, 17, 65, 215, 117, 116, 93, 247, 189, 125, 223, 255, 141, 241, 120, 252, 63, 78, 167, 83, 126, 255, - 115, 191, 203, 71, 63, 246, 253, 60, 250, 232, 23, 214, 173, 91, 183, 124, 205, 194, 120, 124, 71, 55, 234, 238, 24, 141, 186, 155, 33, 174, 109, 45, - 183, 69, 198, 186, 140, 88, 144, 205, 156, 36, 106, 24, 214, 84, 53, 147, 106, 165, 239, 215, 142, 255, 237, 191, 243, 183, 103, 191, 246, 107, 255, 219, - 50, 113, 2, 8, 44, 19, 209, 184, 28, 219, 188, 197, 54, 195, 48, 48, 26, 141, 48, 38, 34, 107, 227, 198, 205, 62, 124, 248, 48, 255, 221, 63, - 250, 21, 254, 193, 47, 254, 87, 124, 55, 232, 120, 155, 77, 159, 249, 40, 221, 73, 104, 109, 116, 111, 215, 181, 31, 150, 204, 116, 54, 99, 58, 157, - 49, 155, 205, 152, 205, 102, 212, 48, 80, 85, 100, 38, 85, 69, 85, 49, 215, 90, 35, 51, 145, 68, 187, 228, 111, 76, 167, 211, 127, 246, 244, 51, - 79, 158, 95, 89, 89, 187, 243, 217, 103, 159, 126, 248, 154, 107, 118, 127, 100, 52, 30, 223, 213, 117, 221, 14, 240, 66, 107, 13, 73, 16, 96, 155, - 0, 100, 19, 128, 36, 172, 17, 86, 97, 25, 89, 220, 112, 195, 117, 220, 121, 231, 237, 28, 56, 112, 128, 204, 36, 91, 226, 161, 199, 134, 136, 96, - 46, 34, 136, 8, 36, 17, 17, 100, 38, 146, 200, 76, 50, 131, 42, 113, 197, 21, 59, 151, 127, 241, 151, 126, 241, 31, 110, 221, 182, 245, 137, 243, - 231, 206, 125, 227, 87, 255, 215, 127, 122, 240, 153, 167, 159, 62, 182, 119, 239, 222, 67, 207, 61, 255, 210, 217, 67, 135, 143, 206, 214, 173, 91, 226, - 228, 201, 147, 252, 255, 169, 227, 109, 62, 112, 2, 214, 111, 88, 100, 50, 233, 63, 156, 25, 59, 167, 211, 158, 97, 24, 24, 134, 1, 169, 24, 106, - 192, 54, 17, 129, 109, 170, 10, 73, 216, 166, 181, 70, 102, 98, 67, 102, 50, 26, 141, 238, 254, 91, 127, 235, 51, 127, 127, 58, 153, 221, 186, 121, - 243, 166, 143, 108, 216, 176, 113, 231, 120, 52, 138, 11, 32, 192, 54, 24, 162, 5, 146, 136, 72, 230, 194, 5, 1, 68, 16, 145, 68, 66, 89, 96, - 179, 176, 176, 192, 35, 143, 124, 130, 190, 239, 249, 220, 231, 254, 128, 51, 103, 206, 48, 244, 61, 217, 26, 93, 215, 17, 17, 216, 102, 46, 34, 152, - 155, 205, 102, 84, 21, 17, 1, 4, 216, 220, 127, 255, 125, 163, 235, 174, 223, 243, 189, 182, 190, 119, 221, 226, 130, 55, 172, 95, 158, 94, 123, 237, - 53, 167, 239, 190, 231, 174, 35, 251, 247, 237, 123, 229, 200, 161, 67, 207, 156, 59, 119, 246, 107, 131, 227, 233, 126, 82, 135, 178, 197, 240, 235, 191, - 249, 47, 249, 171, 214, 120, 155, 219, 111, 185, 153, 67, 175, 29, 203, 205, 91, 55, 252, 116, 73, 119, 77, 38, 83, 38, 147, 9, 147, 201, 132, 201, - 108, 74, 85, 81, 37, 170, 138, 97, 24, 136, 8, 50, 147, 185, 136, 192, 54, 182, 129, 196, 214, 194, 35, 143, 124, 226, 131, 119, 222, 121, 199, 221, - 235, 214, 173, 91, 191, 110, 105, 41, 50, 27, 115, 153, 73, 70, 227, 146, 32, 35, 9, 130, 224, 146, 8, 200, 76, 8, 192, 129, 205, 69, 182, 88, - 183, 110, 29, 119, 220, 113, 7, 119, 221, 117, 23, 235, 215, 47, 115, 228, 240, 97, 222, 60, 121, 18, 201, 64, 48, 103, 27, 73, 84, 21, 146, 176, - 77, 102, 178, 48, 30, 179, 107, 215, 21, 252, 196, 79, 254, 36, 187, 174, 184, 2, 213, 64, 215, 90, 100, 102, 183, 254, 130, 43, 175, 188, 114, 215, - 158, 61, 187, 239, 216, 182, 125, 219, 135, 218, 104, 244, 239, 163, 250, 161, 104, 220, 23, 65, 222, 114, 203, 205, 39, 206, 157, 247, 234, 67, 15, 220, - 195, 254, 253, 251, 249, 171, 208, 120, 155, 219, 110, 185, 153, 174, 235, 218, 120, 113, 244, 119, 74, 190, 233, 252, 202, 10, 147, 201, 148, 201, 116, 194, - 116, 58, 101, 58, 235, 25, 250, 1, 73, 84, 21, 182, 153, 147, 132, 109, 34, 130, 204, 96, 46, 51, 248, 208, 135, 62, 148, 55, 223, 124, 51, 219, - 182, 109, 103, 52, 26, 17, 17, 68, 64, 102, 99, 46, 34, 200, 76, 34, 32, 51, 177, 77, 107, 13, 99, 36, 147, 145, 32, 99, 204, 92, 4, 23, - 101, 6, 59, 118, 236, 224, 190, 251, 238, 225, 193, 119, 63, 200, 116, 54, 227, 229, 151, 94, 102, 50, 153, 50, 30, 143, 176, 77, 85, 81, 85, 84, - 21, 153, 73, 215, 53, 150, 151, 215, 241, 31, 252, 216, 143, 242, 177, 143, 125, 148, 57, 169, 192, 198, 54, 17, 129, 44, 70, 227, 17, 59, 118, 238, - 224, 154, 107, 174, 25, 109, 221, 190, 117, 219, 116, 50, 185, 119, 229, 252, 202, 15, 73, 254, 200, 85, 87, 109, 95, 159, 45, 14, 62, 255, 252, 139, - 103, 127, 247, 243, 191, 207, 193, 215, 223, 224, 47, 83, 227, 109, 110, 186, 233, 6, 206, 158, 95, 99, 105, 221, 248, 135, 250, 26, 238, 152, 78, 167, - 172, 173, 173, 49, 157, 205, 232, 251, 129, 201, 100, 74, 13, 133, 109, 108, 83, 85, 204, 117, 221, 136, 136, 96, 110, 54, 155, 97, 155, 135, 30, 122, - 128, 31, 251, 177, 31, 229, 166, 155, 110, 98, 97, 97, 76, 102, 35, 51, 201, 76, 32, 120, 75, 102, 146, 25, 204, 101, 6, 178, 201, 76, 46, 49, - 17, 1, 17, 68, 4, 17, 129, 109, 36, 33, 21, 17, 176, 109, 251, 22, 222, 253, 238, 7, 185, 118, 247, 110, 94, 124, 241, 69, 78, 157, 58, 141, - 109, 50, 19, 12, 17, 65, 215, 53, 70, 163, 17, 215, 93, 183, 135, 159, 248, 201, 159, 96, 231, 206, 157, 72, 133, 106, 160, 170, 176, 141, 109, 140, - 177, 133, 100, 108, 179, 101, 235, 22, 246, 92, 183, 135, 133, 165, 133, 238, 244, 169, 83, 187, 39, 147, 181, 143, 102, 196, 71, 126, 253, 127, 255, 103, - 53, 38, 247, 221, 117, 231, 237, 147, 231, 94, 124, 137, 191, 44, 141, 183, 185, 241, 198, 235, 89, 191, 97, 209, 67, 213, 13, 195, 48, 124, 223, 100, - 50, 101, 232, 7, 166, 179, 25, 211, 217, 12, 201, 88, 38, 51, 105, 173, 33, 137, 136, 96, 52, 26, 33, 153, 190, 239, 217, 180, 105, 19, 63, 250, - 163, 159, 230, 231, 126, 238, 103, 185, 251, 238, 187, 89, 88, 24, 3, 65, 4, 23, 101, 38, 17, 129, 109, 34, 130, 8, 200, 108, 92, 18, 68, 4, - 16, 16, 92, 18, 16, 17, 68, 38, 193, 5, 22, 223, 148, 168, 68, 215, 37, 183, 220, 122, 51, 119, 220, 126, 27, 123, 247, 62, 203, 177, 99, 199, - 200, 72, 90, 235, 232, 90, 99, 52, 234, 88, 90, 28, 211, 247, 61, 207, 61, 247, 28, 235, 55, 172, 103, 215, 174, 157, 180, 214, 144, 196, 156, 36, - 164, 66, 22, 82, 17, 128, 109, 90, 107, 236, 220, 185, 157, 171, 174, 186, 138, 243, 231, 207, 230, 233, 211, 167, 174, 12, 226, 227, 209, 229, 157, 147, - 89, 191, 111, 251, 142, 157, 135, 111, 191, 237, 86, 246, 237, 219, 207, 191, 171, 198, 219, 188, 252, 202, 62, 174, 191, 238, 58, 192, 107, 54, 159, 236, - 251, 217, 198, 217, 108, 198, 80, 133, 36, 230, 84, 98, 206, 54, 153, 73, 102, 50, 153, 76, 168, 42, 62, 240, 129, 247, 243, 203, 191, 252, 75, 252, - 248, 143, 255, 56, 187, 119, 95, 67, 102, 0, 65, 107, 73, 102, 35, 34, 152, 203, 12, 50, 147, 204, 4, 76, 68, 2, 6, 2, 219, 68, 4, 17, - 96, 155, 57, 27, 108, 17, 4, 145, 129, 101, 8, 136, 224, 34, 203, 216, 102, 215, 174, 157, 220, 118, 199, 109, 28, 56, 112, 128, 55, 79, 158, 100, - 212, 37, 59, 118, 108, 227, 193, 135, 238, 103, 195, 134, 245, 156, 58, 117, 134, 55, 222, 56, 200, 151, 191, 252, 37, 206, 157, 59, 207, 205, 183, 220, - 194, 242, 242, 50, 150, 152, 179, 5, 97, 36, 3, 193, 220, 48, 244, 68, 152, 165, 229, 101, 174, 187, 126, 15, 37, 113, 232, 240, 209, 110, 24, 234, - 182, 136, 252, 216, 104, 212, 206, 175, 77, 39, 207, 222, 120, 227, 245, 195, 171, 251, 95, 227, 223, 69, 227, 50, 174, 191, 238, 90, 52, 232, 168, 131, - 205, 217, 242, 123, 134, 126, 136, 42, 49, 155, 206, 232, 135, 162, 159, 13, 204, 101, 38, 146, 153, 78, 39, 44, 175, 95, 230, 239, 254, 244, 79, 241, - 75, 191, 244, 11, 220, 123, 223, 189, 116, 221, 136, 136, 32, 51, 128, 36, 179, 49, 23, 17, 100, 38, 54, 68, 4, 151, 4, 223, 20, 68, 4, 23, - 5, 216, 38, 34, 137, 224, 162, 0, 36, 1, 6, 2, 219, 72, 194, 6, 35, 170, 6, 182, 111, 223, 202, 189, 247, 222, 195, 174, 93, 59, 185, 250, - 170, 43, 121, 224, 129, 123, 185, 247, 190, 187, 216, 115, 221, 53, 28, 120, 253, 0, 231, 206, 157, 103, 214, 207, 120, 234, 169, 63, 101, 255, 171, 175, - 114, 251, 109, 183, 178, 188, 188, 76, 213, 128, 109, 36, 17, 201, 69, 85, 69, 85, 1, 102, 168, 129, 214, 117, 92, 117, 213, 46, 22, 23, 23, 56, - 240, 218, 27, 244, 125, 191, 57, 91, 126, 95, 215, 229, 122, 13, 122, 252, 198, 27, 175, 155, 236, 219, 255, 26, 255, 95, 53, 46, 99, 223, 254, 215, - 216, 189, 231, 106, 151, 244, 188, 237, 123, 250, 126, 184, 81, 85, 24, 51, 244, 3, 17, 65, 107, 141, 214, 26, 125, 223, 179, 105, 211, 70, 254, 235, - 95, 250, 69, 126, 234, 167, 126, 130, 141, 27, 54, 98, 65, 68, 16, 193, 5, 65, 102, 71, 68, 2, 65, 68, 146, 217, 128, 32, 34, 137, 72, 90, - 235, 136, 8, 230, 34, 2, 219, 204, 5, 193, 156, 13, 216, 4, 193, 156, 13, 118, 96, 23, 150, 33, 184, 32, 48, 34, 2, 108, 179, 97, 253, 50, - 183, 220, 114, 51, 123, 246, 92, 67, 235, 26, 163, 81, 199, 246, 237, 219, 216, 178, 121, 51, 47, 60, 255, 34, 253, 48, 96, 155, 125, 175, 236, 231, - 165, 23, 95, 226, 214, 91, 111, 101, 243, 150, 77, 88, 96, 27, 169, 144, 10, 187, 176, 141, 109, 176, 177, 12, 152, 93, 187, 174, 96, 113, 105, 145, - 87, 247, 191, 74, 223, 207, 70, 153, 249, 158, 204, 184, 186, 134, 225, 177, 155, 111, 190, 126, 101, 180, 48, 226, 196, 137, 147, 252, 69, 53, 222, 193, - 85, 187, 175, 68, 131, 206, 75, 250, 211, 174, 181, 251, 193, 87, 151, 69, 16, 64, 96, 155, 217, 108, 198, 194, 194, 152, 159, 255, 249, 159, 227, 111, - 254, 205, 207, 48, 26, 143, 136, 8, 34, 130, 136, 32, 51, 137, 8, 50, 27, 17, 65, 68, 144, 153, 68, 4, 153, 73, 102, 18, 17, 204, 69, 152, - 136, 224, 45, 17, 65, 68, 96, 131, 45, 140, 177, 141, 101, 100, 17, 17, 128, 145, 69, 68, 32, 9, 171, 176, 141, 109, 108, 99, 139, 165, 165, 37, - 54, 108, 88, 79, 102, 208, 90, 227, 202, 171, 174, 224, 220, 249, 243, 188, 254, 218, 27, 68, 36, 115, 7, 15, 30, 228, 197, 23, 95, 226, 206, 119, - 189, 139, 205, 155, 55, 33, 9, 91, 84, 21, 17, 193, 91, 36, 35, 21, 115, 182, 216, 177, 99, 59, 75, 75, 75, 188, 252, 242, 126, 250, 126, 200, - 150, 121, 87, 100, 187, 106, 58, 12, 95, 218, 184, 97, 227, 234, 171, 251, 95, 227, 47, 170, 241, 14, 222, 56, 112, 144, 173, 155, 183, 48, 30, 181, - 163, 150, 190, 38, 124, 147, 97, 79, 215, 186, 28, 134, 129, 217, 108, 198, 250, 245, 235, 249, 217, 159, 253, 25, 62, 243, 153, 255, 144, 209, 104, 4, - 17, 180, 76, 50, 147, 204, 36, 34, 200, 12, 32, 153, 203, 76, 34, 130, 136, 32, 51, 137, 8, 222, 98, 155, 75, 204, 156, 109, 108, 115, 73, 96, - 155, 136, 192, 54, 115, 17, 96, 27, 8, 230, 108, 48, 38, 194, 72, 102, 24, 10, 48, 96, 90, 107, 44, 45, 45, 50, 30, 143, 24, 47, 140, 217, - 190, 109, 59, 207, 62, 251, 60, 103, 207, 157, 7, 76, 68, 114, 232, 208, 97, 14, 29, 60, 200, 61, 247, 220, 205, 242, 242, 50, 182, 136, 48, 182, - 168, 26, 176, 141, 109, 36, 17, 17, 216, 98, 110, 231, 206, 157, 200, 197, 171, 251, 95, 165, 74, 145, 173, 189, 43, 35, 54, 206, 166, 179, 71, 175, - 191, 110, 207, 236, 181, 215, 14, 240, 23, 209, 248, 22, 142, 30, 59, 198, 198, 13, 203, 196, 168, 29, 173, 97, 248, 125, 219, 71, 183, 108, 218, 116, - 237, 21, 59, 119, 236, 184, 249, 230, 155, 248, 233, 191, 247, 119, 249, 244, 143, 124, 154, 241, 194, 136, 204, 32, 72, 34, 130, 204, 36, 34, 136, 8, - 50, 147, 204, 36, 34, 137, 8, 34, 130, 204, 36, 34, 176, 77, 68, 96, 27, 155, 11, 2, 169, 0, 19, 145, 128, 177, 185, 36, 192, 64, 96, 34, - 130, 32, 144, 10, 108, 100, 35, 21, 198, 204, 73, 5, 24, 16, 54, 23, 24, 48, 182, 176, 204, 250, 245, 203, 156, 61, 115, 150, 23, 94, 120, 9, - 99, 48, 100, 118, 28, 56, 112, 144, 147, 39, 79, 241, 192, 253, 247, 50, 26, 53, 108, 83, 85, 216, 2, 2, 73, 100, 114, 145, 36, 108, 176, 205, - 206, 157, 59, 56, 117, 242, 36, 135, 14, 29, 37, 35, 35, 91, 222, 29, 48, 153, 76, 214, 30, 187, 238, 186, 61, 126, 253, 192, 27, 124, 167, 26, - 223, 198, 241, 19, 39, 57, 124, 232, 40, 191, 250, 107, 191, 186, 242, 145, 143, 124, 100, 239, 39, 63, 249, 3, 31, 249, 129, 71, 30, 185, 229, 147, - 159, 250, 36, 119, 190, 235, 93, 100, 75, 178, 53, 130, 32, 35, 200, 76, 230, 34, 160, 181, 198, 92, 102, 146, 153, 180, 214, 176, 77, 68, 48, 23, - 17, 204, 73, 34, 34, 184, 196, 68, 128, 109, 222, 34, 21, 127, 78, 198, 128, 45, 100, 97, 132, 108, 2, 144, 4, 8, 201, 128, 1, 99, 131, 84, - 72, 66, 18, 17, 73, 68, 176, 113, 211, 70, 158, 123, 246, 121, 206, 159, 95, 37, 162, 17, 17, 24, 216, 191, 111, 63, 227, 209, 136, 119, 189, 235, - 14, 108, 99, 11, 219, 204, 217, 194, 54, 182, 128, 192, 22, 96, 50, 147, 29, 59, 182, 179, 111, 223, 126, 206, 157, 59, 79, 16, 173, 107, 237, 222, - 214, 186, 231, 118, 108, 223, 250, 194, 166, 205, 155, 121, 227, 141, 131, 124, 39, 146, 239, 208, 149, 87, 94, 193, 246, 237, 91, 127, 96, 215, 174, 157, - 31, 222, 185, 115, 7, 203, 203, 235, 80, 21, 216, 96, 46, 138, 72, 164, 194, 54, 115, 182, 153, 139, 72, 34, 130, 203, 145, 68, 102, 146, 153, 128, - 153, 139, 8, 254, 159, 108, 176, 13, 54, 68, 32, 9, 73, 24, 227, 8, 8, 254, 156, 36, 34, 130, 136, 196, 54, 182, 0, 19, 1, 17, 9, 24, - 73, 92, 113, 197, 14, 238, 124, 215, 237, 100, 54, 90, 107, 216, 38, 35, 176, 204, 111, 252, 250, 191, 224, 241, 175, 61, 65, 132, 145, 140, 36, 36, - 1, 129, 109, 108, 83, 85, 216, 198, 54, 132, 216, 177, 115, 27, 239, 123, 223, 131, 216, 102, 24, 122, 100, 109, 203, 204, 255, 246, 232, 241, 55, 111, - 24, 143, 70, 124, 167, 26, 223, 129, 47, 252, 225, 239, 115, 246, 244, 233, 77, 155, 55, 111, 254, 149, 165, 165, 117, 183, 102, 36, 68, 210, 90, 66, - 4, 217, 146, 140, 196, 230, 162, 214, 146, 136, 192, 134, 204, 36, 34, 176, 33, 34, 136, 8, 50, 147, 214, 26, 182, 249, 127, 51, 118, 17, 145, 216, - 6, 204, 156, 36, 108, 17, 128, 36, 28, 38, 8, 176, 40, 21, 24, 44, 35, 21, 145, 96, 11, 169, 144, 138, 57, 219, 84, 21, 182, 144, 140, 100, - 2, 51, 234, 70, 60, 245, 141, 167, 233, 251, 129, 42, 97, 27, 34, 56, 191, 178, 202, 225, 35, 135, 121, 240, 161, 7, 88, 94, 183, 12, 24, 169, - 176, 69, 4, 84, 137, 170, 1, 219, 72, 2, 11, 89, 108, 218, 188, 145, 67, 7, 143, 112, 236, 232, 9, 32, 232, 186, 182, 43, 35, 125, 246, 236, - 217, 63, 188, 238, 218, 107, 244, 198, 193, 67, 124, 59, 141, 111, 227, 119, 126, 251, 179, 108, 218, 180, 145, 174, 235, 62, 182, 126, 253, 250, 159, 233, - 90, 55, 142, 76, 8, 46, 138, 8, 34, 147, 136, 4, 67, 215, 117, 68, 4, 16, 180, 214, 0, 19, 209, 200, 76, 34, 130, 185, 136, 192, 54, 115, - 182, 121, 139, 109, 108, 51, 103, 27, 73, 204, 217, 134, 0, 89, 4, 1, 6, 169, 48, 198, 50, 82, 17, 128, 45, 108, 99, 27, 73, 128, 145, 140, - 36, 108, 99, 11, 219, 204, 73, 197, 186, 165, 37, 94, 122, 121, 31, 39, 142, 191, 73, 73, 188, 37, 51, 56, 116, 232, 48, 155, 54, 109, 228, 206, - 59, 111, 71, 18, 182, 144, 4, 4, 96, 230, 108, 99, 155, 108, 129, 84, 140, 186, 17, 93, 55, 226, 249, 231, 95, 64, 50, 153, 73, 102, 222, 212, - 186, 246, 39, 227, 241, 248, 213, 173, 219, 182, 112, 248, 240, 81, 190, 149, 228, 219, 24, 141, 70, 124, 245, 79, 30, 111, 11, 11, 11, 63, 220, 186, - 92, 150, 141, 100, 34, 146, 204, 4, 2, 149, 80, 21, 17, 96, 27, 219, 68, 112, 129, 137, 72, 108, 97, 27, 73, 204, 217, 70, 18, 182, 105, 173, - 49, 103, 155, 185, 204, 64, 18, 96, 50, 147, 185, 214, 26, 173, 37, 115, 146, 192, 64, 4, 24, 146, 32, 34, 33, 76, 68, 128, 3, 27, 34, 130, - 136, 0, 140, 13, 17, 193, 55, 153, 185, 165, 165, 69, 110, 187, 245, 102, 50, 147, 204, 68, 18, 96, 108, 3, 201, 231, 126, 239, 243, 28, 58, 120, - 24, 48, 182, 153, 147, 10, 219, 68, 4, 111, 145, 140, 13, 170, 226, 198, 27, 246, 176, 123, 247, 213, 244, 179, 25, 179, 217, 20, 169, 182, 183, 214, - 254, 211, 217, 172, 95, 94, 90, 90, 226, 219, 73, 190, 141, 108, 112, 219, 237, 55, 95, 51, 234, 186, 15, 102, 36, 17, 144, 105, 112, 97, 27, 91, - 24, 51, 103, 155, 8, 136, 0, 27, 36, 3, 198, 22, 118, 97, 23, 146, 176, 141, 36, 108, 83, 85, 84, 21, 85, 3, 32, 108, 176, 141, 109, 108, - 19, 1, 146, 80, 153, 57, 89, 148, 197, 69, 6, 99, 176, 145, 140, 109, 34, 32, 2, 108, 115, 73, 16, 17, 216, 38, 34, 176, 141, 84, 128, 32, - 204, 77, 55, 94, 199, 104, 220, 97, 23, 173, 5, 17, 92, 96, 198, 227, 17, 111, 28, 56, 200, 23, 190, 240, 40, 96, 36, 243, 150, 170, 162, 74, - 24, 99, 138, 26, 122, 40, 225, 18, 227, 81, 227, 93, 119, 220, 138, 129, 26, 196, 48, 12, 4, 254, 104, 102, 124, 111, 215, 26, 223, 78, 242, 109, - 44, 45, 45, 49, 30, 47, 220, 215, 186, 182, 199, 54, 182, 144, 132, 44, 170, 6, 108, 131, 65, 18, 85, 66, 50, 16, 188, 165, 74, 84, 21, 85, - 133, 109, 164, 162, 170, 136, 224, 2, 35, 21, 182, 200, 12, 192, 216, 102, 174, 74, 216, 66, 50, 85, 3, 165, 66, 50, 153, 137, 45, 84, 194, 54, - 182, 145, 4, 2, 99, 74, 133, 36, 230, 170, 4, 4, 17, 96, 27, 201, 216, 226, 45, 42, 177, 243, 138, 237, 92, 121, 229, 14, 50, 131, 136, 0, - 76, 102, 163, 181, 198, 220, 163, 143, 126, 137, 19, 39, 78, 146, 13, 36, 33, 137, 136, 192, 22, 150, 176, 5, 54, 17, 65, 112, 201, 245, 55, 92, - 203, 134, 245, 203, 76, 166, 19, 250, 126, 64, 210, 198, 204, 248, 204, 217, 243, 231, 199, 239, 126, 207, 3, 124, 43, 201, 183, 240, 220, 115, 207, 114, - 195, 13, 123, 232, 186, 238, 193, 136, 24, 219, 198, 54, 146, 176, 77, 68, 18, 17, 128, 201, 76, 50, 19, 91, 72, 162, 170, 152, 139, 128, 214, 146, - 136, 96, 206, 22, 32, 134, 161, 167, 170, 7, 132, 45, 164, 66, 50, 182, 137, 8, 50, 131, 136, 224, 146, 32, 34, 136, 0, 3, 153, 13, 2, 108, - 33, 137, 57, 99, 108, 99, 155, 57, 219, 216, 70, 18, 182, 153, 179, 69, 68, 48, 103, 153, 185, 229, 229, 37, 174, 185, 230, 106, 108, 211, 90, 3, - 130, 57, 73, 116, 221, 136, 3, 175, 31, 228, 79, 159, 122, 6, 219, 72, 162, 170, 168, 42, 170, 10, 219, 216, 252, 185, 136, 192, 18, 155, 55, 109, - 228, 202, 171, 175, 96, 24, 6, 134, 97, 96, 24, 138, 11, 30, 94, 88, 24, 223, 213, 90, 227, 91, 73, 190, 133, 87, 246, 189, 196, 231, 191, 240, - 229, 133, 209, 104, 116, 71, 102, 98, 155, 32, 136, 8, 144, 209, 48, 96, 153, 32, 176, 133, 93, 12, 53, 96, 139, 57, 73, 204, 217, 6, 140, 109, - 34, 2, 91, 72, 66, 18, 54, 68, 4, 182, 145, 10, 91, 72, 194, 6, 219, 216, 34, 18, 108, 99, 131, 101, 84, 3, 168, 176, 184, 32, 176, 193, - 22, 96, 230, 108, 144, 4, 24, 16, 146, 1, 51, 103, 27, 99, 108, 131, 69, 6, 92, 187, 251, 106, 70, 93, 135, 109, 90, 107, 204, 217, 6, 204, - 172, 31, 248, 202, 87, 191, 206, 172, 47, 36, 17, 17, 72, 34, 49, 137, 73, 192, 50, 150, 40, 137, 185, 214, 53, 174, 189, 230, 106, 230, 170, 68, - 213, 128, 228, 93, 45, 242, 145, 43, 175, 220, 193, 67, 15, 222, 207, 59, 73, 190, 5, 73, 44, 173, 91, 220, 16, 25, 187, 249, 51, 178, 176, 141, - 13, 198, 204, 73, 194, 54, 102, 206, 148, 6, 108, 35, 137, 97, 24, 24, 134, 162, 170, 144, 132, 84, 216, 96, 27, 201, 216, 194, 54, 146, 145, 140, - 100, 108, 35, 139, 170, 66, 18, 85, 3, 82, 97, 11, 108, 2, 19, 54, 145, 208, 50, 1, 99, 132, 109, 108, 3, 193, 156, 205, 159, 49, 54, 23, - 25, 3, 102, 78, 42, 84, 3, 187, 118, 237, 100, 121, 121, 153, 136, 32, 2, 50, 147, 136, 128, 8, 34, 147, 103, 159, 125, 158, 147, 39, 79, 49, - 103, 131, 109, 192, 96, 99, 137, 136, 192, 64, 4, 216, 66, 42, 118, 94, 177, 157, 174, 107, 12, 195, 192, 48, 20, 82, 113, 193, 199, 95, 127, 245, - 208, 102, 219, 188, 147, 228, 91, 24, 141, 58, 22, 198, 11, 75, 192, 14, 219, 216, 198, 50, 146, 176, 133, 109, 36, 97, 27, 12, 182, 49, 96, 115, - 129, 137, 8, 170, 132, 109, 36, 3, 198, 6, 169, 136, 8, 108, 51, 12, 133, 36, 164, 34, 2, 108, 35, 23, 118, 225, 48, 229, 226, 146, 192, 54, - 210, 192, 225, 195, 135, 120, 230, 153, 167, 121, 225, 133, 231, 57, 118, 252, 24, 114, 145, 17, 216, 66, 42, 108, 17, 1, 17, 32, 25, 73, 72, 133, - 109, 130, 96, 206, 24, 12, 178, 217, 188, 121, 35, 203, 203, 75, 64, 0, 65, 107, 141, 214, 26, 151, 152, 227, 199, 79, 240, 250, 107, 175, 147, 153, - 72, 194, 54, 16, 148, 132, 13, 182, 177, 4, 4, 82, 97, 196, 230, 45, 155, 88, 92, 92, 64, 85, 84, 13, 12, 195, 128, 237, 59, 51, 243, 142, - 204, 224, 157, 116, 124, 11, 163, 174, 195, 242, 250, 8, 22, 165, 129, 200, 14, 34, 176, 205, 156, 109, 170, 6, 130, 70, 89, 180, 174, 35, 72, 44, - 81, 12, 200, 34, 34, 176, 141, 109, 34, 184, 32, 201, 12, 170, 10, 201, 204, 101, 6, 146, 1, 35, 9, 219, 148, 138, 136, 196, 18, 24, 130, 11, - 100, 158, 254, 198, 55, 248, 173, 223, 254, 44, 71, 14, 31, 165, 4, 91, 54, 109, 230, 246, 59, 110, 229, 193, 135, 30, 228, 202, 171, 174, 36, 34, - 168, 42, 36, 81, 85, 128, 1, 243, 22, 169, 168, 42, 108, 99, 140, 37, 70, 227, 17, 155, 54, 111, 228, 240, 145, 227, 16, 102, 46, 34, 136, 8, - 34, 146, 26, 6, 246, 237, 123, 141, 123, 239, 126, 23, 184, 8, 11, 243, 103, 108, 50, 130, 146, 168, 42, 48, 80, 98, 121, 105, 137, 197, 165, 5, - 78, 159, 62, 75, 14, 73, 215, 4, 205, 155, 51, 121, 223, 194, 194, 226, 99, 239, 126, 232, 94, 190, 250, 181, 111, 240, 118, 29, 239, 224, 7, 30, - 249, 56, 88, 188, 242, 202, 43, 55, 222, 183, 241, 238, 245, 94, 24, 97, 11, 57, 104, 36, 146, 201, 228, 2, 33, 65, 107, 13, 11, 8, 99, 12, - 134, 48, 36, 137, 84, 68, 4, 32, 106, 16, 163, 241, 8, 2, 108, 17, 17, 92, 20, 70, 26, 144, 141, 109, 108, 3, 6, 131, 74, 204, 157, 124, - 243, 77, 126, 231, 119, 254, 53, 127, 250, 212, 94, 206, 157, 95, 101, 24, 6, 146, 198, 222, 103, 159, 227, 235, 143, 127, 157, 135, 31, 254, 48, 247, - 63, 120, 31, 163, 241, 2, 146, 177, 3, 91, 216, 102, 78, 18, 54, 216, 198, 18, 150, 49, 166, 181, 198, 120, 60, 38, 2, 186, 236, 152, 14, 61, - 115, 54, 100, 38, 195, 96, 94, 123, 245, 0, 53, 244, 128, 1, 19, 17, 72, 166, 170, 104, 173, 97, 46, 176, 177, 141, 92, 68, 4, 75, 139, 11, - 84, 137, 42, 161, 18, 170, 66, 248, 125, 199, 79, 188, 185, 48, 234, 186, 41, 151, 209, 241, 14, 178, 5, 63, 253, 247, 254, 179, 117, 63, 242, 233, - 31, 254, 79, 238, 190, 231, 206, 101, 73, 100, 38, 216, 24, 131, 133, 20, 68, 4, 151, 4, 32, 108, 209, 90, 67, 18, 9, 84, 152, 32, 56, 115, - 234, 20, 79, 61, 249, 4, 47, 189, 242, 10, 235, 214, 45, 243, 61, 223, 243, 65, 246, 236, 185, 14, 147, 12, 85, 204, 25, 99, 137, 57, 219, 148, - 6, 194, 32, 137, 140, 224, 141, 131, 7, 121, 225, 165, 87, 56, 125, 230, 28, 147, 217, 12, 167, 32, 130, 213, 179, 107, 156, 223, 187, 194, 177, 227, - 39, 56, 118, 252, 56, 15, 127, 223, 135, 25, 47, 44, 0, 198, 54, 146, 169, 42, 36, 97, 11, 217, 4, 96, 46, 48, 100, 4, 11, 139, 11, 4, - 1, 152, 214, 26, 195, 48, 144, 25, 64, 80, 85, 28, 63, 118, 130, 233, 100, 202, 226, 210, 24, 8, 108, 192, 134, 8, 74, 66, 85, 16, 193, 92, - 56, 104, 153, 44, 44, 44, 82, 85, 216, 66, 54, 146, 136, 204, 59, 22, 198, 227, 45, 16, 71, 184, 140, 142, 119, 48, 110, 141, 219, 110, 190, 233, - 190, 233, 116, 242, 33, 219, 216, 66, 18, 17, 1, 81, 32, 200, 108, 132, 131, 204, 164, 170, 128, 36, 34, 176, 1, 131, 109, 144, 56, 124, 248, 16, - 159, 253, 236, 255, 197, 147, 95, 127, 130, 147, 167, 78, 209, 151, 248, 218, 227, 95, 231, 103, 126, 230, 103, 184, 254, 250, 235, 81, 9, 115, 65, 128, - 36, 108, 176, 69, 73, 132, 185, 192, 148, 138, 35, 71, 15, 115, 238, 220, 121, 102, 195, 140, 133, 205, 29, 59, 174, 217, 201, 120, 97, 204, 137, 163, - 39, 56, 125, 240, 44, 7, 15, 31, 229, 247, 62, 247, 111, 200, 22, 124, 232, 195, 255, 30, 173, 107, 84, 21, 182, 128, 128, 0, 91, 96, 99, 9, - 91, 216, 166, 36, 250, 217, 64, 169, 144, 76, 102, 71, 102, 34, 9, 219, 100, 54, 78, 158, 60, 197, 100, 50, 101, 97, 113, 140, 84, 216, 92, 96, - 34, 192, 18, 182, 152, 179, 140, 44, 140, 137, 12, 84, 69, 149, 168, 42, 134, 128, 110, 60, 222, 158, 153, 87, 3, 71, 184, 140, 228, 50, 126, 240, - 83, 159, 96, 235, 230, 141, 140, 23, 198, 31, 30, 250, 126, 107, 213, 0, 4, 146, 144, 10, 187, 176, 11, 91, 204, 85, 21, 182, 169, 234, 177, 6, - 108, 33, 21, 200, 28, 57, 116, 144, 95, 255, 231, 255, 156, 47, 124, 225, 139, 236, 59, 240, 58, 167, 166, 167, 89, 141, 21, 190, 241, 220, 147, 252, - 198, 111, 254, 6, 171, 171, 171, 88, 198, 18, 150, 128, 32, 50, 104, 93, 71, 102, 98, 27, 91, 216, 197, 234, 234, 121, 134, 26, 136, 81, 114, 199, - 125, 119, 242, 209, 135, 63, 198, 13, 55, 220, 194, 109, 247, 220, 206, 134, 157, 235, 25, 106, 224, 248, 137, 147, 252, 209, 23, 190, 200, 222, 189, 123, - 177, 140, 84, 216, 198, 54, 82, 97, 21, 150, 168, 18, 146, 32, 2, 108, 102, 179, 25, 173, 53, 34, 130, 170, 66, 18, 153, 137, 109, 90, 75, 86, - 86, 86, 153, 76, 103, 128, 177, 132, 85, 84, 21, 118, 81, 26, 48, 2, 12, 22, 152, 139, 102, 211, 41, 6, 36, 49, 235, 123, 6, 9, 73, 27, - 171, 106, 183, 36, 46, 39, 185, 12, 219, 188, 126, 248, 248, 82, 68, 190, 123, 54, 155, 49, 157, 78, 121, 139, 109, 170, 10, 219, 72, 194, 54, 16, - 128, 33, 12, 97, 164, 30, 44, 206, 156, 62, 197, 191, 250, 173, 207, 242, 229, 199, 190, 194, 145, 19, 199, 89, 220, 182, 196, 109, 15, 189, 139, 59, - 31, 186, 135, 93, 55, 93, 201, 87, 158, 248, 99, 246, 238, 125, 22, 34, 144, 196, 48, 12, 16, 208, 181, 70, 70, 50, 234, 58, 186, 174, 67, 18, - 182, 105, 173, 209, 117, 29, 163, 197, 17, 91, 55, 110, 99, 247, 230, 107, 57, 245, 250, 73, 22, 218, 2, 155, 182, 110, 196, 36, 125, 63, 112, 232, - 232, 81, 30, 251, 242, 99, 156, 57, 125, 138, 57, 73, 72, 133, 36, 108, 35, 137, 57, 27, 176, 233, 251, 129, 149, 213, 21, 130, 160, 235, 58, 34, - 2, 219, 68, 4, 182, 177, 205, 48, 12, 172, 172, 172, 128, 193, 22, 178, 80, 21, 85, 198, 6, 219, 72, 194, 152, 204, 196, 130, 149, 149, 85, 44, - 97, 9, 219, 216, 198, 246, 66, 68, 236, 204, 12, 238, 184, 253, 86, 222, 46, 185, 140, 22, 201, 66, 215, 109, 25, 117, 163, 91, 170, 138, 213, 149, - 85, 134, 161, 71, 42, 170, 10, 73, 216, 32, 137, 170, 98, 24, 122, 164, 194, 22, 146, 24, 106, 96, 152, 205, 248, 234, 87, 190, 204, 99, 143, 125, - 133, 227, 111, 158, 34, 70, 112, 195, 237, 55, 241, 137, 135, 63, 201, 117, 219, 111, 96, 195, 120, 19, 238, 204, 87, 190, 242, 37, 166, 147, 53, 164, - 98, 46, 51, 105, 109, 68, 215, 117, 100, 54, 34, 130, 185, 42, 177, 115, 199, 118, 182, 109, 221, 68, 20, 60, 245, 196, 83, 252, 247, 255, 228, 159, - 240, 248, 19, 95, 231, 141, 131, 7, 56, 127, 102, 5, 44, 108, 51, 89, 235, 217, 183, 239, 85, 94, 126, 233, 101, 192, 96, 97, 21, 72, 216, 6, - 11, 169, 8, 32, 34, 56, 123, 238, 28, 43, 231, 87, 137, 12, 50, 147, 204, 32, 34, 136, 8, 70, 163, 17, 17, 129, 108, 134, 190, 71, 18, 230, - 2, 155, 136, 0, 12, 152, 32, 152, 179, 77, 4, 204, 102, 61, 231, 206, 173, 80, 18, 37, 1, 70, 50, 146, 136, 136, 45, 139, 139, 75, 128, 121, - 187, 228, 50, 50, 147, 214, 186, 43, 91, 230, 214, 201, 218, 132, 179, 231, 206, 97, 23, 85, 61, 85, 3, 182, 169, 42, 84, 133, 36, 36, 161, 18, - 42, 83, 37, 112, 112, 228, 216, 17, 254, 237, 151, 31, 227, 240, 145, 99, 244, 253, 64, 118, 29, 145, 240, 252, 222, 23, 57, 248, 202, 33, 78, 188, - 113, 2, 15, 226, 245, 215, 95, 229, 220, 217, 211, 168, 138, 136, 0, 130, 136, 32, 72, 130, 164, 101, 71, 70, 99, 24, 6, 110, 190, 229, 22, 30, - 254, 190, 135, 89, 236, 22, 57, 119, 234, 44, 125, 78, 217, 184, 115, 153, 55, 143, 188, 201, 153, 35, 103, 120, 75, 73, 156, 61, 187, 194, 190, 125, - 251, 25, 102, 83, 194, 194, 26, 176, 132, 101, 176, 176, 197, 92, 100, 114, 234, 228, 105, 166, 147, 25, 173, 117, 216, 32, 153, 204, 36, 34, 136, 8, - 50, 147, 140, 128, 0, 169, 176, 5, 1, 132, 137, 0, 12, 4, 151, 68, 16, 145, 156, 59, 191, 194, 202, 234, 20, 3, 178, 40, 11, 169, 168, 42, - 134, 161, 182, 92, 125, 213, 46, 170, 196, 219, 117, 92, 86, 96, 188, 35, 34, 150, 135, 26, 56, 126, 236, 56, 183, 220, 114, 35, 153, 73, 4, 12, - 67, 79, 102, 16, 209, 48, 102, 212, 141, 48, 194, 6, 27, 236, 224, 185, 189, 207, 240, 210, 43, 175, 176, 186, 54, 1, 139, 217, 234, 148, 253, 47, - 191, 202, 243, 123, 95, 228, 232, 254, 35, 140, 23, 199, 108, 221, 180, 153, 171, 175, 186, 134, 241, 226, 34, 165, 129, 116, 71, 70, 48, 151, 153, 216, - 6, 76, 182, 196, 54, 24, 62, 240, 190, 247, 243, 218, 254, 3, 252, 206, 231, 126, 159, 129, 162, 95, 233, 169, 89, 193, 192, 5, 1, 8, 28, 244, - 125, 241, 230, 137, 147, 172, 173, 173, 177, 184, 184, 136, 205, 69, 182, 144, 204, 37, 6, 7, 135, 14, 29, 161, 170, 176, 133, 84, 204, 217, 38, 34, - 152, 107, 173, 163, 27, 117, 188, 69, 18, 115, 182, 129, 192, 54, 182, 201, 72, 140, 48, 230, 212, 201, 83, 172, 156, 95, 193, 6, 73, 72, 66, 18, - 150, 32, 98, 116, 231, 29, 215, 243, 228, 55, 158, 230, 237, 146, 203, 48, 6, 123, 83, 85, 45, 16, 193, 241, 227, 199, 25, 134, 162, 170, 144, 10, - 169, 176, 65, 18, 146, 40, 21, 146, 40, 21, 178, 88, 89, 89, 225, 185, 103, 159, 227, 212, 169, 51, 148, 4, 4, 158, 193, 155, 7, 78, 226, 126, - 96, 231, 238, 109, 44, 46, 45, 178, 97, 113, 35, 31, 250, 208, 135, 25, 141, 58, 36, 129, 33, 34, 136, 8, 34, 130, 174, 235, 152, 179, 13, 152, - 89, 63, 37, 187, 224, 227, 159, 120, 152, 59, 239, 184, 149, 24, 96, 88, 27, 176, 192, 24, 48, 16, 204, 5, 48, 235, 167, 76, 167, 83, 84, 133, - 37, 84, 3, 85, 133, 45, 108, 97, 204, 234, 218, 132, 3, 7, 14, 146, 153, 216, 102, 46, 2, 36, 81, 85, 12, 195, 128, 36, 48, 96, 99, 192, - 50, 54, 68, 4, 96, 34, 130, 140, 68, 18, 17, 65, 68, 112, 228, 232, 113, 166, 179, 25, 115, 54, 88, 198, 54, 54, 248, 130, 233, 84, 216, 230, - 237, 146, 203, 49, 16, 44, 218, 110, 92, 112, 242, 228, 105, 206, 157, 91, 193, 134, 97, 24, 144, 140, 45, 192, 72, 162, 170, 24, 106, 160, 159, 13, - 212, 32, 206, 156, 57, 195, 129, 55, 14, 49, 153, 204, 128, 192, 4, 118, 160, 85, 56, 119, 104, 149, 115, 135, 87, 153, 157, 238, 185, 255, 158, 251, - 216, 189, 251, 106, 134, 217, 0, 6, 219, 216, 38, 35, 136, 8, 192, 68, 4, 17, 80, 26, 168, 26, 232, 251, 158, 205, 155, 55, 241, 131, 63, 248, - 8, 123, 246, 92, 205, 120, 212, 8, 243, 103, 204, 92, 182, 100, 97, 97, 204, 210, 210, 34, 45, 27, 37, 81, 42, 228, 194, 42, 130, 32, 8, 50, - 147, 195, 71, 143, 113, 224, 141, 35, 188, 37, 51, 201, 108, 100, 38, 223, 100, 250, 190, 71, 50, 146, 48, 6, 140, 100, 44, 19, 17, 200, 66, 22, - 65, 82, 130, 3, 7, 14, 33, 25, 8, 230, 36, 83, 37, 100, 35, 41, 86, 87, 2, 91, 188, 93, 114, 25, 14, 99, 46, 8, 192, 112, 250, 244, - 105, 14, 31, 62, 140, 84, 216, 92, 96, 134, 97, 160, 170, 176, 11, 187, 176, 11, 185, 48, 197, 233, 51, 167, 57, 123, 230, 44, 85, 133, 13, 182, - 177, 205, 156, 21, 184, 96, 121, 121, 29, 239, 125, 223, 187, 105, 45, 24, 212, 51, 212, 0, 54, 182, 169, 18, 85, 133, 108, 130, 192, 54, 17, 129, - 45, 250, 126, 198, 116, 58, 225, 218, 107, 119, 243, 3, 159, 248, 40, 215, 237, 217, 205, 198, 13, 203, 44, 140, 71, 116, 173, 49, 30, 117, 172, 95, - 183, 196, 230, 77, 235, 217, 185, 99, 27, 163, 209, 152, 42, 33, 9, 201, 24, 48, 38, 34, 176, 205, 179, 123, 95, 100, 50, 153, 162, 18, 153, 13, - 155, 139, 34, 130, 57, 219, 216, 198, 54, 198, 204, 89, 102, 206, 22, 145, 129, 44, 50, 146, 204, 68, 50, 43, 231, 215, 120, 227, 141, 67, 72, 66, - 18, 182, 193, 198, 54, 182, 176, 209, 234, 116, 130, 109, 222, 174, 227, 114, 12, 97, 144, 68, 107, 73, 245, 197, 171, 251, 95, 229, 250, 235, 247, 208, - 117, 141, 8, 144, 76, 215, 113, 129, 145, 68, 102, 146, 153, 72, 48, 157, 174, 49, 155, 205, 176, 205, 37, 193, 156, 109, 230, 108, 115, 195, 13, 215, - 115, 195, 13, 215, 209, 15, 61, 182, 201, 12, 140, 1, 67, 0, 1, 65, 64, 152, 136, 96, 78, 18, 85, 3, 195, 208, 35, 137, 219, 239, 184, 141, - 8, 248, 250, 227, 79, 112, 236, 248, 9, 38, 107, 83, 34, 96, 221, 210, 18, 187, 118, 109, 231, 198, 27, 111, 32, 2, 36, 161, 42, 164, 98, 206, - 152, 108, 201, 177, 99, 111, 242, 252, 243, 47, 19, 36, 173, 5, 174, 129, 8, 144, 132, 109, 108, 19, 17, 216, 134, 224, 207, 152, 136, 192, 134, 136, - 224, 34, 131, 49, 17, 65, 100, 227, 196, 137, 55, 57, 122, 244, 4, 153, 9, 24, 219, 204, 101, 6, 182, 177, 125, 230, 137, 39, 255, 4, 203, 188, - 93, 199, 101, 132, 184, 72, 37, 164, 194, 14, 246, 239, 127, 141, 123, 78, 158, 100, 219, 182, 45, 216, 38, 2, 164, 192, 54, 153, 137, 13, 146, 1, - 179, 176, 176, 64, 107, 73, 70, 80, 46, 32, 136, 8, 230, 194, 176, 176, 48, 230, 221, 15, 221, 207, 186, 117, 235, 24, 134, 129, 139, 28, 212, 208, - 83, 53, 166, 181, 129, 140, 6, 153, 72, 194, 54, 115, 153, 73, 85, 49, 212, 128, 52, 144, 4, 183, 223, 118, 11, 219, 183, 109, 225, 181, 87, 95, - 227, 212, 169, 147, 148, 196, 250, 245, 235, 185, 118, 207, 53, 92, 125, 205, 85, 72, 61, 182, 136, 4, 156, 96, 46, 16, 67, 153, 175, 125, 253, 105, - 206, 156, 57, 71, 4, 32, 8, 131, 37, 108, 19, 17, 68, 4, 17, 65, 102, 146, 153, 88, 98, 46, 50, 80, 137, 200, 192, 134, 200, 192, 54, 150, - 201, 113, 240, 210, 43, 251, 57, 119, 126, 133, 136, 68, 50, 173, 129, 109, 170, 68, 132, 80, 213, 217, 51, 167, 207, 98, 155, 183, 235, 184, 44, 99, - 3, 1, 25, 193, 80, 197, 241, 227, 39, 121, 118, 239, 243, 124, 207, 7, 223, 139, 84, 124, 83, 210, 154, 169, 42, 90, 107, 216, 102, 211, 198, 141, - 108, 219, 190, 149, 215, 14, 28, 164, 175, 1, 108, 36, 136, 128, 209, 168, 113, 195, 13, 123, 120, 224, 254, 251, 1, 35, 9, 219, 68, 4, 82, 33, - 21, 195, 80, 100, 152, 200, 100, 46, 34, 136, 8, 50, 19, 219, 168, 138, 161, 6, 40, 211, 50, 217, 190, 99, 59, 219, 183, 111, 99, 168, 1, 219, - 180, 214, 145, 25, 88, 133, 36, 108, 99, 27, 155, 139, 50, 130, 151, 247, 189, 206, 51, 79, 63, 135, 109, 8, 232, 85, 72, 98, 46, 34, 152, 139, - 8, 108, 115, 145, 161, 36, 36, 33, 153, 200, 32, 8, 100, 1, 193, 69, 1, 179, 89, 207, 222, 189, 47, 32, 153, 174, 131, 204, 64, 18, 182, 177, - 132, 36, 151, 244, 166, 44, 94, 125, 253, 13, 222, 46, 185, 12, 217, 216, 194, 50, 17, 129, 36, 50, 131, 103, 158, 121, 150, 163, 71, 143, 99, 27, - 73, 84, 9, 169, 24, 134, 1, 91, 72, 98, 24, 138, 165, 165, 37, 222, 243, 158, 247, 176, 121, 243, 38, 90, 38, 4, 180, 46, 89, 92, 90, 96, - 215, 149, 59, 249, 232, 199, 30, 102, 215, 149, 87, 48, 12, 3, 85, 3, 195, 48, 80, 53, 32, 23, 170, 194, 22, 146, 81, 9, 201, 24, 147, 145, - 72, 34, 34, 176, 141, 74, 12, 195, 64, 63, 12, 12, 195, 64, 97, 218, 104, 196, 104, 97, 129, 236, 26, 146, 40, 21, 182, 193, 32, 153, 8, 147, - 25, 156, 58, 117, 150, 127, 251, 197, 175, 194, 196, 203, 222, 0, 0, 32, 0, 73, 68, 65, 84, 48, 153, 204, 192, 129, 10, 178, 53, 200, 32, 91, - 35, 34, 168, 42, 190, 41, 144, 68, 63, 155, 17, 4, 216, 216, 134, 128, 32, 192, 96, 155, 214, 26, 135, 14, 29, 101, 255, 190, 215, 201, 72, 34, - 130, 185, 136, 64, 18, 6, 50, 98, 5, 124, 156, 119, 208, 113, 25, 150, 145, 189, 58, 194, 131, 236, 142, 11, 50, 147, 179, 103, 207, 243, 199, 127, - 252, 85, 62, 254, 241, 135, 89, 92, 92, 4, 140, 36, 34, 2, 48, 54, 23, 4, 153, 201, 3, 15, 61, 64, 180, 228, 171, 127, 242, 56, 7, 222, - 56, 192, 208, 247, 236, 220, 185, 131, 247, 127, 224, 189, 188, 251, 221, 15, 32, 13, 216, 198, 54, 17, 193, 48, 64, 63, 43, 70, 157, 104, 77, 68, - 64, 102, 34, 9, 149, 32, 160, 181, 164, 69, 16, 54, 97, 46, 178, 132, 128, 4, 108, 48, 16, 97, 108, 161, 18, 178, 137, 8, 34, 128, 8, 206, - 173, 174, 242, 249, 63, 250, 18, 135, 14, 31, 35, 34, 32, 32, 19, 100, 147, 17, 244, 85, 216, 69, 132, 0, 49, 39, 21, 195, 32, 250, 161, 144, - 5, 17, 68, 128, 36, 50, 18, 27, 50, 3, 8, 158, 120, 226, 25, 78, 159, 57, 71, 107, 13, 27, 36, 17, 209, 32, 184, 168, 164, 21, 201, 71, - 9, 115, 57, 29, 151, 97, 11, 236, 73, 16, 195, 208, 247, 157, 36, 136, 100, 238, 133, 231, 95, 226, 170, 43, 175, 224, 129, 7, 239, 67, 226, 162, - 136, 192, 54, 146, 200, 76, 32, 137, 8, 30, 122, 247, 131, 220, 115, 207, 221, 156, 58, 121, 146, 126, 232, 89, 183, 110, 29, 219, 182, 109, 165, 181, - 198, 48, 20, 96, 108, 19, 17, 128, 169, 234, 169, 234, 169, 161, 145, 217, 40, 21, 150, 176, 197, 92, 70, 35, 51, 201, 76, 50, 2, 1, 6, 74, - 194, 24, 59, 200, 108, 88, 162, 84, 216, 230, 18, 19, 1, 231, 206, 175, 241, 232, 23, 255, 152, 151, 95, 218, 71, 68, 32, 21, 85, 3, 146, 128, - 64, 18, 153, 9, 85, 100, 54, 36, 19, 17, 100, 38, 4, 96, 46, 138, 128, 32, 152, 51, 16, 1, 153, 201, 137, 55, 79, 243, 248, 227, 79, 98, - 27, 219, 204, 101, 6, 115, 54, 72, 2, 251, 84, 223, 247, 199, 34, 184, 172, 142, 203, 176, 141, 237, 53, 225, 33, 91, 35, 29, 24, 136, 8, 250, - 94, 60, 246, 216, 87, 89, 94, 191, 142, 91, 110, 185, 153, 136, 96, 206, 22, 6, 44, 33, 7, 65, 195, 54, 173, 5, 59, 175, 216, 78, 68, 96, - 7, 85, 162, 74, 100, 6, 182, 121, 75, 132, 25, 106, 160, 52, 80, 53, 96, 139, 104, 201, 48, 12, 244, 179, 158, 190, 31, 144, 0, 7, 56, 48, - 23, 68, 128, 141, 37, 132, 177, 19, 48, 182, 145, 196, 92, 4, 16, 201, 177, 99, 111, 242, 232, 23, 255, 152, 87, 95, 61, 8, 52, 170, 122, 108, - 147, 153, 64, 32, 9, 219, 24, 51, 87, 85, 188, 69, 18, 227, 81, 71, 100, 16, 17, 216, 38, 51, 144, 64, 22, 38, 176, 197, 215, 30, 127, 146, - 131, 7, 143, 16, 17, 216, 38, 34, 136, 8, 32, 152, 139, 8, 100, 191, 90, 85, 231, 50, 147, 203, 233, 184, 140, 194, 24, 175, 150, 220, 119, 93, - 7, 97, 134, 190, 199, 230, 2, 115, 238, 236, 10, 159, 251, 189, 63, 164, 74, 220, 118, 219, 45, 24, 145, 110, 4, 16, 153, 68, 4, 25, 32, 21, - 115, 17, 65, 68, 48, 103, 155, 136, 64, 10, 34, 130, 57, 219, 68, 36, 85, 197, 202, 249, 21, 78, 245, 103, 57, 191, 178, 202, 249, 243, 231, 89, - 89, 89, 101, 58, 153, 34, 137, 204, 100, 212, 53, 198, 227, 96, 52, 78, 34, 6, 108, 97, 10, 28, 128, 169, 18, 96, 34, 146, 136, 100, 117, 50, - 229, 229, 151, 94, 228, 169, 111, 236, 229, 216, 241, 147, 212, 32, 100, 83, 37, 36, 19, 145, 192, 128, 36, 136, 0, 67, 102, 3, 68, 213, 128, 109, - 230, 100, 131, 33, 2, 236, 160, 100, 34, 0, 65, 100, 112, 226, 196, 105, 30, 125, 244, 49, 134, 161, 232, 186, 17, 111, 169, 18, 173, 5, 184, 17, - 36, 114, 61, 127, 227, 181, 55, 173, 236, 123, 99, 31, 151, 211, 113, 25, 178, 177, 125, 182, 164, 105, 200, 12, 253, 64, 149, 176, 197, 48, 12, 216, - 112, 252, 248, 73, 126, 235, 179, 191, 203, 185, 115, 231, 185, 251, 158, 59, 24, 141, 70, 204, 133, 130, 204, 134, 195, 204, 69, 36, 32, 34, 130, 185, - 136, 192, 134, 8, 243, 22, 201, 128, 120, 243, 196, 97, 14, 31, 62, 206, 155, 39, 79, 113, 230, 204, 89, 214, 214, 214, 152, 205, 102, 72, 34, 51, - 25, 143, 199, 44, 46, 45, 177, 113, 253, 50, 187, 119, 111, 99, 243, 166, 69, 2, 136, 8, 46, 49, 17, 9, 209, 88, 89, 89, 227, 224, 27, 135, - 120, 102, 239, 11, 28, 58, 124, 148, 26, 138, 97, 40, 8, 192, 38, 51, 145, 138, 185, 190, 31, 176, 69, 16, 152, 192, 54, 153, 137, 36, 108, 99, - 155, 170, 194, 54, 24, 164, 34, 8, 34, 147, 108, 13, 1, 127, 248, 135, 95, 226, 245, 215, 14, 67, 36, 182, 137, 8, 46, 49, 182, 137, 8, 36, - 203, 142, 103, 143, 28, 63, 202, 209, 163, 199, 185, 156, 142, 203, 144, 10, 73, 103, 236, 209, 164, 170, 40, 137, 170, 129, 136, 36, 34, 8, 32, 51, - 56, 119, 110, 133, 223, 251, 189, 207, 115, 244, 232, 49, 222, 243, 158, 7, 217, 186, 109, 11, 182, 176, 193, 97, 230, 34, 132, 13, 17, 16, 17, 68, - 4, 17, 193, 156, 13, 182, 152, 59, 117, 250, 60, 123, 159, 121, 153, 227, 199, 223, 228, 204, 153, 83, 156, 59, 119, 158, 213, 213, 85, 250, 190, 199, - 54, 151, 4, 27, 54, 108, 96, 219, 150, 205, 172, 223, 208, 177, 101, 243, 18, 198, 204, 69, 36, 231, 207, 175, 113, 252, 216, 155, 188, 113, 248, 8, - 175, 189, 250, 58, 167, 78, 157, 161, 202, 116, 93, 135, 29, 100, 38, 150, 17, 66, 18, 96, 44, 97, 11, 8, 34, 2, 169, 176, 185, 40, 51, 177, - 205, 92, 70, 64, 0, 17, 64, 16, 153, 148, 138, 209, 104, 204, 51, 207, 60, 207, 31, 253, 209, 151, 33, 18, 34, 152, 139, 8, 230, 34, 146, 204, - 100, 78, 82, 95, 85, 175, 172, 13, 3, 239, 164, 227, 50, 60, 8, 171, 86, 145, 78, 87, 137, 214, 18, 169, 97, 139, 57, 89, 180, 214, 33, 153, - 97, 86, 60, 246, 229, 175, 241, 242, 75, 251, 121, 255, 251, 30, 226, 182, 219, 111, 102, 253, 250, 117, 148, 5, 1, 4, 23, 152, 185, 204, 164, 69, - 195, 54, 182, 113, 128, 129, 32, 56, 123, 246, 44, 175, 31, 120, 157, 195, 135, 142, 114, 232, 208, 65, 250, 126, 32, 2, 140, 152, 77, 123, 78, 156, - 56, 65, 75, 184, 239, 222, 187, 185, 246, 158, 155, 185, 98, 199, 22, 44, 19, 17, 180, 214, 120, 241, 165, 215, 248, 252, 191, 249, 34, 167, 78, 157, - 166, 4, 153, 73, 107, 73, 68, 146, 145, 200, 34, 34, 24, 84, 188, 165, 101, 67, 37, 186, 110, 68, 85, 81, 42, 36, 49, 12, 34, 34, 200, 76, - 134, 97, 64, 50, 221, 66, 199, 210, 226, 24, 91, 100, 4, 115, 153, 141, 195, 71, 79, 240, 155, 255, 231, 191, 226, 236, 217, 85, 50, 19, 219, 204, - 217, 38, 51, 185, 196, 68, 6, 17, 76, 92, 58, 103, 204, 59, 233, 184, 12, 169, 168, 170, 169, 170, 142, 141, 198, 99, 196, 55, 85, 21, 125, 223, - 19, 17, 68, 4, 198, 84, 137, 3, 7, 14, 241, 47, 14, 255, 54, 187, 119, 95, 201, 61, 247, 220, 193, 173, 183, 220, 204, 150, 173, 155, 232, 186, - 134, 44, 34, 18, 75, 252, 223, 213, 193, 91, 240, 231, 247, 125, 223, 245, 231, 235, 253, 254, 252, 254, 199, 213, 238, 234, 96, 157, 173, 147, 79, 137, - 92, 199, 78, 161, 101, 154, 50, 147, 146, 25, 66, 153, 41, 229, 152, 97, 114, 65, 153, 97, 166, 189, 229, 146, 43, 110, 24, 46, 152, 1, 238, 128, - 14, 195, 5, 164, 153, 0, 197, 197, 83, 26, 55, 208, 184, 57, 214, 137, 237, 38, 150, 101, 71, 138, 117, 176, 180, 90, 89, 210, 106, 87, 218, 243, - 254, 79, 191, 239, 231, 253, 126, 177, 63, 41, 10, 30, 198, 146, 108, 147, 148, 244, 241, 88, 92, 72, 194, 221, 72, 66, 136, 182, 185, 251, 206, 59, - 120, 226, 177, 135, 184, 117, 227, 58, 135, 7, 55, 184, 120, 233, 45, 118, 118, 246, 56, 123, 246, 12, 203, 178, 240, 224, 67, 31, 225, 95, 249, 233, - 191, 196, 103, 62, 253, 41, 238, 190, 231, 110, 70, 6, 221, 69, 100, 112, 245, 234, 77, 190, 244, 171, 191, 197, 235, 111, 92, 100, 123, 123, 133, 36, - 64, 72, 193, 200, 4, 9, 33, 108, 3, 166, 102, 177, 209, 110, 218, 6, 140, 221, 204, 57, 217, 144, 68, 85, 81, 85, 188, 39, 34, 216, 221, 219, - 5, 27, 99, 66, 201, 173, 131, 35, 254, 247, 191, 247, 69, 94, 120, 241, 28, 82, 34, 9, 73, 188, 199, 54, 146, 216, 176, 27, 155, 19, 211, 39, - 182, 121, 63, 131, 247, 113, 243, 230, 225, 209, 222, 222, 238, 69, 4, 53, 27, 108, 64, 68, 4, 153, 73, 85, 1, 162, 170, 145, 132, 109, 142, 79, - 78, 120, 241, 197, 115, 188, 248, 226, 75, 220, 117, 247, 157, 60, 242, 200, 195, 60, 246, 216, 35, 60, 112, 223, 125, 220, 121, 215, 89, 118, 118, 86, - 172, 198, 32, 51, 201, 76, 66, 162, 108, 108, 179, 26, 193, 103, 63, 251, 41, 62, 246, 177, 135, 249, 169, 191, 244, 19, 60, 255, 194, 139, 124, 243, - 155, 207, 241, 246, 229, 235, 220, 127, 255, 93, 252, 244, 79, 255, 11, 60, 252, 224, 253, 40, 205, 156, 107, 114, 236, 160, 16, 54, 60, 253, 141, 103, - 120, 243, 205, 75, 140, 76, 108, 147, 153, 72, 162, 187, 209, 106, 240, 46, 209, 221, 72, 65, 68, 96, 160, 187, 17, 208, 109, 48, 216, 38, 51, 233, - 158, 72, 98, 163, 187, 137, 16, 123, 123, 187, 236, 237, 238, 210, 109, 20, 226, 120, 61, 249, 194, 23, 126, 133, 175, 124, 245, 235, 68, 36, 27, 221, - 77, 68, 176, 33, 137, 119, 137, 238, 166, 91, 140, 49, 144, 132, 109, 222, 207, 224, 125, 60, 244, 209, 251, 234, 228, 120, 253, 90, 85, 209, 213, 68, - 6, 85, 133, 16, 32, 64, 188, 203, 128, 137, 16, 115, 26, 133, 168, 130, 75, 23, 223, 230, 194, 27, 151, 248, 234, 87, 190, 206, 246, 246, 54, 219, - 219, 43, 78, 157, 222, 231, 212, 222, 62, 35, 7, 247, 220, 115, 55, 255, 242, 95, 254, 139, 220, 255, 192, 71, 0, 179, 49, 107, 178, 44, 199, 236, - 238, 38, 31, 255, 216, 131, 156, 218, 31, 60, 243, 204, 243, 220, 243, 145, 59, 217, 221, 9, 14, 15, 111, 161, 16, 85, 133, 27, 132, 185, 114, 237, - 58, 223, 120, 250, 15, 88, 102, 177, 181, 21, 136, 160, 219, 128, 201, 4, 204, 109, 166, 170, 168, 106, 196, 109, 130, 174, 162, 13, 8, 20, 66, 36, - 217, 201, 156, 197, 156, 133, 109, 36, 145, 153, 116, 55, 119, 222, 121, 150, 221, 189, 29, 114, 12, 110, 221, 58, 228, 239, 125, 225, 87, 248, 245, 95, - 255, 50, 221, 38, 34, 216, 176, 205, 134, 36, 254, 31, 70, 18, 54, 216, 2, 2, 73, 188, 159, 193, 247, 241, 235, 191, 253, 59, 252, 107, 63, 251, - 51, 148, 253, 138, 219, 29, 82, 148, 27, 73, 84, 55, 85, 19, 219, 72, 65, 183, 177, 65, 10, 4, 184, 77, 42, 32, 204, 156, 19, 12, 135, 71, - 39, 220, 188, 117, 200, 197, 75, 87, 216, 168, 42, 108, 243, 135, 223, 126, 158, 159, 255, 249, 127, 155, 143, 127, 236, 81, 170, 38, 115, 46, 204, 229, - 132, 147, 245, 49, 235, 245, 154, 213, 74, 124, 226, 19, 15, 33, 193, 250, 228, 132, 145, 43, 150, 165, 56, 58, 58, 38, 115, 197, 214, 106, 197, 243, - 207, 189, 196, 197, 75, 111, 99, 139, 110, 19, 1, 2, 186, 27, 9, 102, 21, 18, 84, 21, 96, 64, 84, 53, 179, 138, 141, 170, 194, 109, 170, 10, - 219, 108, 100, 38, 85, 69, 119, 227, 110, 78, 214, 107, 238, 190, 231, 46, 118, 119, 118, 185, 116, 233, 10, 255, 219, 231, 255, 1, 95, 253, 218, 83, - 116, 155, 136, 192, 54, 17, 129, 36, 108, 99, 27, 73, 72, 2, 68, 102, 18, 145, 216, 148, 77, 217, 226, 253, 12, 222, 199, 178, 94, 48, 188, 92, - 85, 107, 208, 78, 117, 33, 5, 115, 46, 216, 166, 219, 216, 147, 170, 34, 36, 26, 48, 208, 93, 8, 49, 103, 97, 243, 142, 136, 160, 187, 145, 68, - 68, 176, 81, 85, 156, 123, 229, 85, 126, 225, 239, 252, 93, 254, 195, 191, 241, 239, 243, 177, 39, 62, 74, 119, 115, 116, 124, 204, 141, 27, 55, 185, - 114, 229, 42, 151, 47, 95, 225, 230, 205, 27, 44, 203, 100, 181, 218, 102, 103, 123, 155, 179, 103, 239, 228, 145, 71, 30, 225, 244, 233, 51, 28, 28, - 28, 243, 244, 55, 158, 97, 89, 79, 198, 24, 116, 21, 206, 32, 98, 133, 16, 99, 12, 220, 205, 106, 123, 11, 27, 214, 235, 53, 17, 73, 183, 17, - 194, 54, 115, 22, 182, 89, 150, 133, 238, 198, 54, 18, 239, 152, 115, 98, 155, 173, 213, 138, 71, 30, 125, 152, 103, 190, 253, 34, 159, 255, 252, 63, - 224, 197, 23, 207, 33, 9, 73, 216, 70, 18, 221, 77, 68, 16, 17, 116, 55, 146, 176, 141, 36, 170, 10, 41, 144, 116, 36, 233, 8, 204, 251, 73, - 222, 199, 195, 15, 63, 68, 119, 239, 68, 232, 231, 16, 119, 180, 193, 221, 84, 23, 93, 13, 24, 119, 99, 140, 13, 203, 178, 96, 27, 219, 216, 96, - 55, 118, 99, 131, 219, 84, 55, 182, 145, 132, 109, 108, 99, 224, 250, 245, 155, 188, 114, 254, 187, 60, 242, 200, 67, 220, 115, 207, 93, 172, 215, 199, - 92, 185, 114, 133, 215, 94, 191, 192, 133, 11, 111, 241, 246, 219, 215, 184, 121, 243, 144, 245, 201, 194, 206, 206, 54, 15, 61, 120, 63, 15, 63, 252, - 16, 251, 251, 167, 248, 218, 215, 158, 226, 235, 95, 255, 38, 153, 43, 114, 12, 144, 176, 27, 183, 81, 136, 136, 96, 35, 51, 177, 161, 170, 153, 115, - 34, 192, 54, 146, 152, 53, 169, 106, 16, 116, 155, 170, 162, 202, 84, 21, 221, 13, 8, 219, 68, 4, 191, 246, 143, 127, 139, 215, 95, 127, 147, 136, - 64, 18, 239, 145, 68, 68, 176, 33, 9, 219, 72, 34, 51, 201, 76, 192, 128, 136, 136, 55, 109, 255, 79, 146, 110, 28, 28, 28, 240, 253, 12, 62, - 64, 87, 95, 4, 93, 168, 238, 7, 187, 27, 219, 100, 14, 108, 179, 177, 120, 66, 55, 85, 133, 221, 216, 198, 54, 110, 35, 132, 16, 229, 162, 91, - 216, 102, 163, 187, 145, 132, 36, 82, 73, 35, 206, 157, 251, 46, 191, 240, 119, 62, 207, 127, 240, 55, 254, 61, 30, 126, 240, 35, 60, 248, 224, 3, - 108, 111, 111, 241, 224, 3, 247, 113, 116, 120, 4, 152, 221, 189, 93, 206, 158, 61, 195, 153, 59, 78, 179, 179, 189, 197, 235, 175, 95, 228, 119, 191, - 242, 251, 44, 179, 136, 48, 138, 193, 24, 131, 170, 66, 17, 108, 116, 155, 204, 192, 54, 221, 141, 109, 192, 180, 205, 70, 117, 19, 145, 40, 26, 181, - 144, 64, 18, 17, 98, 189, 94, 179, 209, 93, 172, 215, 39, 124, 235, 155, 207, 18, 17, 140, 49, 248, 94, 182, 177, 141, 36, 54, 108, 35, 137, 136, - 0, 68, 85, 49, 70, 16, 17, 216, 190, 105, 251, 150, 36, 222, 79, 242, 62, 62, 250, 208, 131, 92, 189, 118, 125, 189, 183, 191, 247, 87, 36, 253, - 57, 219, 96, 110, 51, 54, 116, 23, 115, 78, 34, 130, 238, 166, 170, 217, 48, 198, 24, 219, 216, 70, 10, 186, 141, 36, 222, 83, 85, 216, 102, 195, - 54, 182, 185, 126, 253, 38, 231, 206, 189, 202, 71, 31, 126, 136, 187, 238, 60, 139, 4, 91, 219, 43, 246, 246, 119, 216, 223, 223, 229, 212, 169, 83, - 236, 237, 237, 177, 187, 183, 207, 193, 193, 49, 191, 252, 203, 95, 226, 252, 171, 111, 144, 25, 216, 38, 35, 177, 205, 198, 106, 12, 54, 50, 147, 204, - 164, 187, 232, 54, 27, 17, 73, 85, 81, 53, 193, 80, 221, 116, 55, 179, 138, 170, 137, 36, 230, 44, 186, 155, 238, 166, 170, 144, 196, 24, 3, 73, - 116, 55, 27, 221, 205, 134, 36, 222, 35, 9, 73, 108, 72, 66, 2, 73, 68, 136, 49, 18, 41, 158, 94, 175, 215, 191, 152, 153, 125, 112, 112, 192, - 247, 147, 188, 143, 143, 126, 244, 33, 238, 187, 239, 94, 47, 203, 242, 99, 153, 227, 103, 170, 138, 57, 39, 221, 205, 70, 87, 211, 221, 216, 208, 221, - 216, 77, 85, 99, 155, 119, 24, 12, 216, 198, 136, 141, 170, 162, 187, 233, 110, 54, 108, 51, 231, 68, 18, 27, 87, 175, 222, 224, 249, 231, 191, 195, - 238, 222, 46, 31, 249, 200, 221, 172, 182, 86, 100, 14, 182, 183, 118, 216, 218, 222, 1, 39, 175, 191, 246, 22, 255, 215, 255, 249, 155, 60, 255, 252, - 75, 40, 196, 70, 230, 64, 33, 16, 140, 49, 104, 155, 80, 96, 67, 102, 130, 1, 1, 54, 221, 141, 219, 216, 166, 170, 17, 48, 171, 88, 47, 107, - 170, 154, 13, 155, 119, 84, 21, 221, 77, 102, 34, 9, 73, 108, 216, 70, 18, 182, 249, 94, 17, 129, 109, 36, 177, 33, 9, 73, 216, 38, 34, 1, - 125, 233, 210, 165, 75, 255, 112, 127, 127, 159, 131, 131, 3, 190, 159, 228, 125, 124, 247, 181, 215, 121, 224, 254, 251, 232, 246, 61, 171, 213, 248, 183, - 128, 49, 70, 82, 213, 204, 185, 176, 209, 213, 108, 216, 96, 155, 119, 25, 119, 99, 27, 187, 193, 6, 137, 110, 211, 221, 116, 55, 182, 121, 143, 109, - 54, 36, 1, 230, 224, 224, 144, 231, 158, 251, 14, 175, 189, 246, 38, 235, 165, 88, 102, 115, 229, 234, 77, 190, 243, 226, 119, 249, 202, 239, 126, 131, - 223, 253, 202, 239, 115, 249, 242, 85, 20, 65, 230, 224, 61, 54, 100, 4, 57, 6, 27, 145, 73, 68, 16, 18, 109, 35, 137, 57, 139, 234, 6, 137, - 147, 147, 53, 85, 147, 89, 69, 119, 209, 54, 32, 230, 156, 128, 88, 150, 133, 57, 39, 182, 89, 173, 86, 124, 175, 136, 192, 54, 146, 136, 8, 54, - 108, 179, 33, 137, 136, 96, 35, 66, 68, 136, 136, 96, 140, 193, 109, 191, 116, 230, 204, 153, 175, 85, 21, 7, 7, 7, 124, 63, 131, 15, 96, 27, - 219, 207, 117, 251, 114, 68, 62, 184, 44, 107, 34, 68, 102, 82, 85, 204, 57, 65, 98, 206, 194, 110, 54, 108, 110, 19, 118, 97, 155, 101, 78, 20, - 73, 85, 209, 221, 216, 70, 18, 182, 169, 42, 50, 147, 170, 162, 187, 217, 144, 130, 101, 22, 207, 254, 225, 119, 120, 238, 249, 151, 89, 173, 2, 41, - 49, 224, 134, 72, 145, 17, 68, 4, 138, 6, 195, 200, 32, 199, 0, 137, 170, 98, 181, 90, 33, 9, 219, 108, 68, 136, 245, 122, 193, 109, 170, 38, - 110, 35, 241, 142, 49, 6, 179, 38, 27, 221, 133, 109, 192, 72, 194, 54, 99, 12, 54, 50, 147, 238, 230, 61, 17, 193, 123, 36, 97, 155, 238, 102, - 140, 129, 109, 36, 33, 5, 182, 217, 144, 226, 150, 221, 223, 182, 205, 165, 75, 151, 120, 63, 131, 15, 48, 231, 194, 156, 245, 250, 24, 227, 249, 49, - 242, 193, 57, 11, 219, 8, 17, 10, 222, 147, 25, 204, 217, 72, 252, 49, 41, 80, 192, 24, 131, 101, 54, 146, 136, 8, 54, 108, 179, 209, 221, 68, - 4, 146, 88, 150, 197, 85, 245, 150, 237, 206, 204, 123, 51, 51, 186, 77, 21, 183, 53, 118, 147, 153, 96, 176, 141, 109, 236, 38, 35, 105, 55, 234, - 194, 134, 213, 24, 72, 162, 187, 193, 70, 219, 91, 128, 145, 192, 128, 20, 156, 44, 199, 8, 144, 68, 119, 131, 65, 10, 64, 216, 32, 129, 36, 108, - 19, 17, 108, 216, 70, 18, 182, 217, 144, 132, 109, 170, 138, 204, 68, 18, 146, 216, 136, 72, 192, 216, 77, 166, 0, 211, 61, 223, 236, 230, 5, 219, - 124, 144, 224, 3, 44, 179, 249, 115, 159, 254, 228, 141, 170, 249, 7, 85, 133, 221, 108, 204, 42, 102, 53, 57, 6, 82, 16, 145, 216, 166, 219, 108, - 216, 166, 186, 233, 110, 20, 129, 36, 108, 99, 27, 219, 116, 55, 203, 178, 176, 81, 85, 172, 215, 107, 159, 156, 156, 252, 175, 221, 253, 87, 151, 101, - 249, 217, 101, 89, 254, 251, 170, 90, 115, 219, 156, 69, 85, 209, 109, 54, 50, 131, 119, 216, 132, 18, 73, 108, 84, 53, 96, 12, 204, 101, 193, 54, - 17, 129, 36, 108, 35, 5, 237, 198, 110, 34, 130, 234, 102, 163, 186, 152, 85, 44, 75, 209, 13, 17, 201, 156, 147, 245, 122, 189, 72, 42, 254, 72, - 85, 97, 155, 13, 219, 116, 55, 182, 249, 127, 179, 161, 219, 216, 16, 17, 68, 4, 153, 201, 109, 79, 207, 89, 23, 108, 243, 65, 146, 15, 112, 225, - 194, 155, 156, 58, 117, 138, 110, 223, 3, 250, 55, 193, 17, 18, 27, 85, 141, 13, 221, 133, 128, 57, 11, 219, 116, 55, 118, 35, 9, 27, 108, 3, - 98, 195, 54, 203, 178, 176, 145, 153, 100, 38, 221, 205, 241, 241, 241, 83, 221, 253, 183, 186, 251, 57, 73, 151, 186, 251, 183, 129, 251, 199, 24, 127, - 62, 51, 177, 141, 13, 99, 36, 96, 36, 145, 99, 96, 192, 109, 16, 100, 36, 25, 129, 34, 64, 16, 17, 100, 36, 17, 65, 119, 99, 155, 245, 122, - 205, 198, 156, 147, 141, 170, 194, 109, 204, 134, 168, 42, 186, 155, 170, 98, 206, 249, 173, 204, 140, 219, 78, 69, 4, 146, 176, 205, 134, 36, 34, 130, - 13, 73, 108, 72, 66, 18, 27, 17, 66, 18, 99, 36, 153, 1, 8, 219, 127, 123, 140, 252, 202, 155, 111, 94, 228, 131, 4, 31, 98, 189, 94, 152, - 115, 126, 203, 246, 91, 99, 12, 218, 102, 206, 201, 134, 36, 164, 160, 109, 192, 108, 216, 141, 13, 221, 102, 195, 54, 115, 78, 108, 99, 155, 49, 6, - 146, 168, 42, 150, 101, 97, 89, 22, 108, 255, 221, 204, 60, 47, 9, 219, 68, 196, 205, 170, 250, 47, 215, 203, 250, 133, 170, 66, 18, 99, 36, 54, - 216, 220, 38, 36, 177, 97, 160, 102, 33, 137, 182, 169, 154, 116, 27, 12, 109, 51, 231, 100, 206, 73, 85, 147, 145, 116, 55, 17, 65, 102, 82, 213, - 28, 31, 31, 83, 213, 216, 166, 187, 169, 42, 186, 251, 0, 248, 98, 132, 150, 204, 68, 18, 153, 137, 36, 36, 33, 9, 219, 72, 34, 34, 200, 76, - 34, 130, 204, 100, 181, 74, 50, 69, 166, 200, 12, 64, 68, 196, 5, 219, 191, 93, 85, 124, 152, 224, 67, 216, 80, 213, 175, 116, 247, 75, 199, 71, - 199, 204, 57, 201, 28, 72, 66, 2, 219, 204, 57, 233, 54, 221, 77, 183, 233, 110, 186, 139, 170, 162, 187, 137, 16, 115, 78, 230, 156, 72, 194, 54, - 146, 216, 168, 170, 235, 192, 151, 185, 205, 54, 27, 22, 216, 126, 177, 170, 254, 143, 238, 102, 67, 18, 221, 13, 4, 82, 178, 94, 79, 92, 32, 5, - 17, 194, 54, 146, 48, 48, 198, 32, 50, 201, 76, 186, 155, 185, 20, 235, 245, 194, 122, 89, 232, 106, 220, 102, 206, 137, 109, 36, 192, 102, 206, 201, - 187, 68, 151, 191, 177, 202, 124, 54, 34, 238, 144, 196, 134, 109, 34, 130, 136, 32, 34, 144, 132, 109, 34, 130, 136, 32, 66, 216, 133, 4, 146, 200, - 12, 64, 100, 174, 144, 242, 203, 115, 214, 243, 32, 62, 76, 240, 33, 186, 155, 175, 63, 245, 244, 77, 219, 79, 101, 38, 182, 177, 77, 205, 133, 101, - 89, 176, 141, 36, 54, 236, 70, 18, 221, 141, 36, 54, 34, 196, 156, 133, 36, 36, 209, 221, 72, 66, 18, 182, 185, 237, 130, 237, 215, 248, 30, 174, - 102, 140, 97, 204, 175, 74, 58, 144, 196, 134, 36, 186, 155, 182, 17, 2, 9, 187, 81, 4, 237, 38, 51, 201, 76, 186, 155, 174, 162, 187, 168, 106, - 34, 19, 108, 186, 139, 182, 169, 46, 108, 112, 55, 182, 105, 55, 138, 96, 140, 193, 109, 221, 230, 239, 175, 86, 91, 91, 224, 59, 248, 35, 146, 120, - 143, 36, 34, 130, 204, 228, 93, 198, 54, 17, 137, 20, 72, 34, 34, 1, 35, 105, 13, 124, 97, 127, 255, 212, 73, 55, 31, 42, 248, 16, 221, 205, - 191, 244, 23, 255, 188, 171, 230, 87, 21, 90, 86, 171, 65, 8, 20, 129, 36, 170, 38, 27, 182, 145, 132, 109, 108, 99, 243, 142, 101, 153, 116, 55, - 27, 17, 129, 36, 36, 97, 27, 219, 84, 213, 53, 219, 87, 186, 155, 199, 31, 251, 24, 143, 63, 250, 24, 143, 63, 250, 152, 94, 125, 234, 89, 34, - 226, 5, 219, 175, 74, 66, 18, 146, 216, 112, 55, 10, 97, 55, 180, 145, 130, 136, 100, 206, 137, 219, 84, 21, 203, 156, 84, 53, 96, 186, 27, 219, - 140, 49, 176, 77, 119, 51, 231, 164, 109, 186, 77, 87, 51, 151, 133, 245, 122, 205, 178, 44, 47, 111, 111, 109, 125, 25, 241, 241, 188, 45, 66, 68, - 4, 153, 73, 102, 146, 153, 72, 66, 18, 239, 145, 32, 51, 136, 72, 108, 144, 68, 119, 3, 194, 237, 111, 206, 57, 127, 227, 228, 228, 132, 183, 222, - 186, 196, 135, 9, 62, 196, 55, 158, 254, 22, 115, 22, 115, 246, 83, 115, 214, 155, 110, 83, 221, 128, 144, 130, 136, 68, 18, 171, 213, 138, 213, 88, - 177, 33, 137, 170, 162, 187, 17, 16, 17, 116, 55, 221, 77, 119, 211, 221, 116, 55, 2, 36, 85, 68, 244, 103, 126, 236, 211, 82, 207, 196, 94, 185, - 123, 235, 167, 254, 218, 207, 238, 158, 57, 117, 199, 173, 174, 122, 163, 187, 145, 132, 109, 36, 17, 17, 72, 66, 1, 229, 166, 170, 232, 42, 150, 101, - 97, 35, 51, 201, 76, 192, 216, 102, 206, 201, 172, 162, 102, 97, 27, 219, 116, 155, 89, 141, 9, 20, 73, 102, 98, 27, 236, 95, 191, 99, 127, 239, - 138, 228, 79, 70, 4, 82, 176, 97, 155, 141, 170, 162, 187, 145, 68, 68, 32, 9, 16, 27, 146, 201, 12, 34, 2, 99, 66, 242, 106, 140, 207, 239, - 140, 173, 139, 221, 205, 15, 34, 248, 1, 116, 55, 115, 206, 87, 109, 255, 65, 85, 97, 155, 238, 194, 54, 153, 129, 109, 108, 83, 221, 100, 38, 99, - 12, 70, 38, 238, 34, 34, 136, 16, 27, 182, 217, 176, 141, 36, 102, 21, 6, 237, 239, 237, 143, 91, 7, 183, 182, 218, 222, 118, 247, 142, 237, 157, - 238, 222, 221, 222, 222, 201, 136, 184, 32, 137, 238, 102, 195, 54, 223, 43, 51, 8, 137, 141, 144, 216, 144, 32, 66, 116, 53, 85, 13, 54, 17, 193, - 172, 162, 187, 176, 65, 17, 100, 14, 108, 51, 231, 164, 187, 89, 150, 229, 237, 49, 198, 111, 218, 125, 151, 34, 158, 224, 29, 6, 76, 119, 19, 33, - 50, 19, 219, 188, 71, 18, 18, 68, 8, 73, 188, 103, 100, 146, 153, 207, 85, 213, 23, 14, 79, 142, 216, 223, 221, 231, 137, 199, 158, 224, 195, 4, - 63, 128, 111, 60, 253, 7, 236, 237, 237, 28, 86, 213, 111, 42, 2, 219, 116, 27, 48, 235, 245, 194, 156, 147, 238, 98, 206, 133, 8, 97, 155, 234, - 162, 219, 116, 55, 182, 145, 132, 36, 54, 36, 241, 14, 9, 68, 108, 175, 86, 59, 221, 181, 211, 221, 187, 213, 189, 219, 221, 123, 93, 189, 7, 236, - 72, 186, 213, 221, 116, 55, 221, 205, 70, 85, 81, 53, 89, 150, 53, 27, 145, 73, 132, 136, 8, 186, 138, 170, 166, 170, 49, 32, 137, 118, 51, 231, - 66, 119, 179, 94, 175, 169, 154, 184, 155, 238, 166, 187, 169, 42, 214, 235, 53, 182, 127, 127, 103, 103, 231, 181, 234, 122, 56, 20, 143, 100, 38, 153, - 34, 51, 136, 0, 27, 108, 147, 153, 100, 38, 153, 137, 36, 34, 2, 73, 72, 34, 34, 136, 8, 86, 171, 45, 219, 253, 63, 175, 74, 231, 239, 216, - 63, 21, 1, 162, 139, 39, 30, 125, 156, 15, 50, 248, 1, 29, 159, 172, 177, 249, 39, 171, 149, 46, 71, 232, 110, 48, 115, 153, 84, 21, 85, 69, - 132, 144, 196, 178, 76, 170, 154, 57, 27, 69, 96, 68, 119, 1, 98, 195, 54, 221, 205, 70, 132, 88, 229, 216, 157, 85, 103, 203, 190, 233, 246, 176, - 157, 224, 180, 73, 64, 183, 29, 75, 162, 187, 89, 173, 86, 100, 38, 153, 9, 152, 110, 211, 109, 186, 155, 28, 3, 100, 54, 50, 147, 57, 39, 153, - 65, 68, 224, 54, 203, 178, 96, 64, 145, 116, 23, 221, 147, 110, 19, 17, 116, 21, 174, 62, 92, 229, 248, 178, 32, 192, 159, 24, 35, 239, 228, 54, - 219, 128, 145, 2, 137, 219, 154, 136, 68, 130, 8, 209, 13, 18, 72, 16, 17, 68, 136, 140, 68, 248, 27, 224, 255, 101, 108, 15, 149, 59, 64, 213, - 10, 132, 249, 32, 193, 15, 168, 219, 204, 89, 207, 44, 203, 242, 251, 85, 69, 119, 211, 54, 146, 200, 76, 34, 130, 80, 80, 93, 40, 68, 102, 50, - 198, 138, 13, 41, 176, 141, 36, 36, 33, 9, 219, 140, 28, 8, 206, 84, 213, 71, 220, 222, 177, 123, 215, 238, 221, 238, 222, 107, 247, 94, 119, 239, - 131, 182, 184, 77, 18, 153, 137, 36, 36, 81, 213, 8, 8, 9, 108, 150, 101, 97, 206, 66, 18, 221, 133, 109, 164, 96, 89, 47, 84, 55, 146, 176, - 161, 187, 169, 106, 230, 44, 230, 156, 84, 21, 115, 22, 221, 253, 252, 214, 106, 245, 74, 87, 239, 71, 198, 147, 153, 177, 189, 90, 37, 138, 32, 51, - 200, 12, 34, 130, 213, 106, 69, 132, 176, 27, 219, 100, 6, 146, 200, 76, 36, 200, 72, 34, 226, 176, 187, 255, 219, 17, 171, 215, 203, 29, 128, 16, - 18, 230, 195, 4, 63, 160, 170, 102, 127, 119, 235, 86, 119, 253, 67, 80, 71, 4, 171, 213, 138, 213, 24, 216, 166, 187, 105, 27, 41, 248, 94, 82, - 96, 27, 219, 108, 216, 198, 54, 239, 177, 57, 235, 246, 125, 118, 111, 87, 247, 110, 117, 239, 181, 189, 219, 221, 123, 213, 181, 111, 247, 25, 73, 68, - 4, 221, 77, 85, 81, 85, 68, 4, 57, 6, 198, 68, 136, 238, 162, 187, 1, 97, 131, 36, 106, 78, 102, 21, 33, 17, 145, 96, 179, 44, 11, 27, - 17, 129, 109, 54, 236, 94, 34, 226, 107, 72, 13, 156, 14, 197, 143, 75, 65, 230, 64, 130, 136, 96, 140, 65, 102, 32, 37, 17, 65, 102, 34, 137, - 8, 145, 153, 68, 36, 82, 16, 17, 216, 254, 130, 237, 47, 74, 4, 32, 254, 152, 0, 241, 65, 130, 31, 208, 179, 207, 254, 33, 199, 39, 107, 230, - 236, 95, 5, 206, 71, 4, 221, 77, 219, 100, 38, 54, 116, 55, 35, 19, 119, 35, 65, 132, 176, 139, 136, 32, 34, 168, 42, 108, 19, 17, 68, 4, - 182, 81, 232, 84, 211, 31, 45, 123, 167, 187, 119, 186, 189, 227, 238, 93, 119, 239, 85, 213, 190, 225, 78, 254, 72, 119, 35, 9, 73, 216, 166, 187, - 9, 5, 17, 193, 214, 214, 54, 91, 91, 91, 68, 136, 174, 98, 46, 11, 85, 69, 102, 98, 160, 187, 104, 27, 27, 170, 76, 85, 97, 155, 170, 194, - 246, 43, 91, 91, 91, 47, 218, 30, 202, 184, 127, 107, 103, 247, 209, 49, 182, 168, 134, 49, 182, 128, 4, 68, 68, 18, 33, 34, 146, 136, 224, 93, - 98, 53, 6, 35, 147, 145, 137, 224, 235, 180, 255, 235, 85, 172, 14, 176, 184, 205, 128, 217, 144, 248, 48, 193, 15, 161, 38, 220, 188, 113, 244, 98, - 85, 255, 74, 119, 51, 231, 68, 130, 238, 6, 76, 102, 0, 70, 226, 29, 221, 69, 102, 242, 30, 73, 68, 4, 27, 17, 65, 102, 18, 17, 163, 237, - 143, 119, 247, 142, 237, 29, 187, 119, 186, 122, 183, 187, 119, 186, 123, 223, 246, 221, 220, 38, 137, 136, 192, 54, 182, 145, 32, 4, 146, 168, 42, 236, - 6, 76, 85, 35, 9, 99, 12, 116, 55, 203, 178, 80, 85, 132, 2, 27, 36, 97, 131, 36, 230, 156, 5, 122, 42, 34, 142, 5, 219, 33, 61, 250, - 137, 79, 124, 226, 236, 125, 247, 63, 192, 131, 15, 62, 196, 24, 43, 238, 191, 255, 126, 246, 246, 246, 57, 125, 250, 12, 99, 172, 200, 76, 36, 17, - 17, 100, 38, 182, 1, 3, 62, 95, 213, 255, 77, 106, 188, 37, 148, 2, 27, 12, 24, 227, 173, 154, 216, 205, 7, 9, 126, 8, 221, 197, 233, 51, - 123, 93, 85, 191, 4, 92, 138, 8, 36, 129, 141, 219, 72, 194, 230, 29, 153, 9, 136, 238, 166, 187, 137, 8, 50, 147, 238, 102, 195, 54, 27, 153, - 73, 102, 126, 188, 230, 220, 119, 123, 203, 221, 219, 118, 111, 219, 222, 110, 247, 105, 73, 119, 74, 98, 67, 18, 153, 137, 36, 36, 33, 5, 221, 69, - 85, 99, 67, 68, 16, 17, 40, 2, 33, 186, 139, 154, 147, 170, 194, 134, 101, 153, 72, 162, 187, 177, 77, 85, 97, 251, 149, 213, 106, 245, 135, 64, - 70, 228, 174, 164, 211, 23, 46, 92, 200, 245, 250, 132, 157, 157, 29, 246, 246, 246, 184, 247, 222, 123, 57, 125, 250, 52, 247, 222, 123, 47, 71, 71, - 71, 204, 89, 68, 4, 171, 213, 138, 13, 73, 220, 246, 70, 205, 250, 69, 183, 223, 104, 247, 221, 192, 54, 82, 27, 186, 81, 163, 240, 58, 146, 115, - 175, 158, 231, 131, 36, 63, 132, 183, 47, 95, 230, 238, 187, 239, 98, 89, 47, 23, 115, 228, 227, 17, 241, 47, 118, 155, 28, 3, 69, 128, 33, 199, - 96, 86, 209, 93, 8, 48, 70, 10, 34, 130, 170, 34, 51, 169, 42, 222, 35, 137, 238, 118, 72, 191, 43, 81, 109, 111, 217, 94, 25, 70, 117, 223, - 135, 248, 87, 51, 115, 63, 51, 137, 8, 34, 2, 219, 100, 36, 153, 66, 18, 146, 144, 4, 134, 145, 9, 18, 216, 116, 155, 165, 38, 27, 85, 69, - 119, 19, 145, 116, 55, 238, 166, 103, 45, 192, 151, 86, 171, 213, 75, 66, 139, 4, 15, 62, 248, 208, 195, 183, 110, 222, 252, 204, 193, 193, 173, 184, - 118, 245, 42, 115, 78, 46, 95, 190, 204, 209, 209, 17, 87, 174, 92, 225, 228, 228, 4, 73, 140, 28, 8, 17, 138, 217, 246, 183, 215, 235, 229, 239, - 183, 121, 46, 20, 7, 138, 184, 21, 210, 77, 164, 99, 164, 6, 219, 152, 115, 175, 190, 194, 135, 73, 126, 72, 111, 189, 125, 153, 251, 30, 184, 175, - 221, 253, 122, 100, 254, 213, 64, 103, 109, 35, 160, 221, 84, 53, 203, 156, 132, 4, 152, 110, 131, 2, 219, 84, 21, 17, 129, 109, 186, 155, 204, 68, - 18, 85, 165, 219, 126, 39, 34, 14, 128, 149, 97, 24, 71, 187, 31, 31, 99, 252, 149, 213, 106, 53, 248, 35, 146, 144, 68, 102, 48, 198, 32, 51, - 145, 68, 68, 144, 17, 84, 55, 118, 83, 213, 72, 208, 109, 140, 233, 110, 218, 208, 109, 170, 138, 185, 44, 244, 236, 231, 182, 183, 183, 127, 45, 20, - 7, 130, 67, 164, 163, 204, 188, 188, 179, 189, 115, 243, 240, 224, 224, 12, 104, 107, 189, 94, 198, 178, 172, 181, 172, 23, 186, 155, 237, 237, 109, 86, - 171, 213, 146, 138, 91, 192, 185, 154, 243, 55, 150, 245, 252, 146, 164, 239, 100, 230, 91, 25, 113, 49, 35, 222, 82, 196, 117, 41, 22, 103, 88, 136, - 147, 48, 55, 175, 93, 231, 195, 12, 126, 4, 181, 76, 94, 120, 245, 252, 211, 79, 62, 241, 196, 223, 150, 244, 159, 27, 143, 57, 39, 109, 211, 110, - 50, 147, 141, 42, 131, 68, 40, 176, 77, 102, 82, 85, 100, 38, 221, 141, 109, 50, 19, 73, 219, 221, 125, 150, 228, 117, 64, 108, 152, 141, 135, 35, - 98, 123, 206, 73, 102, 18, 17, 100, 38, 146, 0, 209, 54, 33, 80, 4, 182, 81, 8, 170, 153, 101, 36, 81, 221, 44, 115, 98, 55, 221, 141, 20, - 72, 98, 163, 171, 15, 50, 243, 183, 71, 142, 171, 224, 35, 224, 8, 116, 120, 237, 234, 181, 183, 35, 116, 126, 172, 86, 95, 202, 200, 143, 2, 119, - 67, 110, 129, 19, 36, 33, 187, 250, 96, 218, 111, 185, 251, 34, 112, 101, 172, 198, 141, 80, 92, 85, 232, 74, 70, 92, 27, 210, 65, 75, 19, 133, - 163, 154, 151, 206, 159, 227, 7, 53, 248, 17, 92, 60, 127, 157, 79, 61, 246, 168, 151, 101, 249, 31, 86, 57, 254, 66, 142, 252, 119, 157, 1, 221, - 156, 172, 139, 8, 209, 221, 128, 200, 8, 20, 193, 178, 76, 108, 19, 17, 116, 55, 146, 136, 8, 186, 27, 73, 43, 236, 125, 65, 27, 10, 16, 144, - 146, 30, 1, 97, 55, 221, 77, 102, 82, 53, 137, 8, 198, 24, 96, 19, 49, 232, 46, 50, 18, 73, 68, 36, 166, 153, 115, 97, 89, 22, 54, 164, - 100, 195, 134, 101, 89, 179, 44, 11, 22, 95, 219, 217, 217, 121, 86, 161, 67, 208, 33, 112, 8, 28, 73, 58, 1, 234, 182, 55, 187, 251, 91, 66, - 72, 10, 133, 36, 48, 182, 5, 51, 34, 22, 101, 158, 32, 29, 11, 142, 20, 113, 28, 210, 90, 168, 44, 250, 47, 124, 234, 113, 254, 233, 115, 47, - 115, 238, 252, 43, 252, 48, 6, 63, 130, 123, 238, 63, 69, 157, 52, 63, 243, 115, 159, 188, 242, 91, 95, 120, 225, 63, 149, 185, 127, 53, 198, 95, - 70, 77, 196, 130, 0, 41, 16, 5, 18, 115, 22, 27, 146, 168, 42, 108, 19, 17, 140, 49, 144, 68, 85, 33, 41, 35, 2, 119, 79, 192, 183, 157, - 150, 244, 88, 102, 0, 38, 51, 129, 166, 187, 145, 192, 110, 148, 3, 48, 93, 197, 136, 100, 86, 209, 109, 186, 155, 101, 153, 44, 203, 66, 230, 138, - 136, 64, 50, 39, 39, 199, 44, 203, 66, 85, 189, 188, 183, 187, 247, 143, 34, 227, 26, 112, 44, 233, 16, 56, 4, 142, 129, 69, 82, 73, 154, 192, - 20, 154, 10, 77, 161, 10, 81, 146, 166, 164, 10, 152, 72, 37, 169, 128, 146, 84, 141, 220, 96, 117, 243, 181, 239, 92, 224, 149, 243, 175, 240, 195, - 74, 126, 4, 119, 157, 189, 19, 4, 231, 158, 125, 59, 14, 15, 214, 151, 35, 245, 117, 227, 79, 43, 244, 104, 68, 48, 171, 168, 154, 72, 65, 87, - 113, 199, 233, 51, 156, 57, 115, 134, 101, 89, 120, 228, 145, 71, 56, 58, 58, 226, 201, 39, 159, 228, 214, 173, 91, 252, 228, 79, 254, 36, 175, 191, - 254, 250, 113, 70, 252, 222, 24, 227, 138, 224, 4, 180, 238, 238, 79, 41, 227, 95, 143, 136, 149, 36, 50, 69, 102, 32, 137, 136, 32, 51, 16, 2, - 243, 142, 145, 131, 101, 153, 156, 172, 79, 0, 1, 166, 219, 204, 217, 204, 57, 145, 68, 119, 179, 44, 203, 173, 213, 106, 245, 75, 123, 187, 123, 207, - 6, 28, 41, 226, 86, 72, 7, 146, 14, 37, 29, 41, 98, 29, 138, 147, 144, 214, 82, 172, 35, 99, 137, 136, 69, 210, 58, 165, 69, 210, 18, 210, - 130, 52, 37, 77, 80, 129, 74, 33, 55, 197, 208, 224, 165, 243, 231, 184, 118, 245, 109, 126, 20, 131, 31, 153, 48, 246, 246, 206, 86, 156, 28, 215, - 51, 217, 245, 55, 35, 243, 63, 137, 204, 159, 3, 157, 18, 1, 134, 136, 100, 119, 119, 135, 199, 31, 127, 130, 91, 183, 110, 241, 227, 63, 254, 227, - 92, 186, 116, 137, 123, 239, 189, 151, 87, 207, 191, 202, 197, 55, 47, 50, 114, 220, 112, 247, 137, 164, 221, 200, 60, 176, 122, 161, 253, 185, 204, 177, - 27, 25, 224, 102, 140, 164, 170, 217, 144, 132, 13, 166, 129, 96, 140, 21, 179, 138, 200, 96, 197, 138, 170, 70, 10, 164, 192, 158, 116, 55, 182, 153, - 203, 82, 17, 241, 197, 83, 251, 251, 191, 19, 210, 145, 164, 35, 208, 145, 196, 17, 112, 2, 44, 66, 133, 84, 18, 133, 84, 192, 148, 212, 130, 146, - 84, 130, 66, 42, 65, 11, 25, 201, 220, 246, 157, 87, 206, 241, 39, 33, 249, 17, 156, 61, 123, 39, 33, 129, 4, 88, 10, 228, 230, 234, 156, 253, - 27, 93, 253, 124, 40, 238, 207, 200, 7, 164, 72, 110, 59, 58, 58, 164, 170, 185, 124, 249, 45, 230, 156, 92, 187, 118, 157, 27, 55, 110, 112, 116, - 120, 200, 229, 203, 151, 233, 234, 175, 142, 49, 158, 202, 136, 107, 146, 174, 172, 151, 245, 67, 18, 127, 51, 51, 239, 16, 38, 115, 176, 97, 131, 36, - 198, 72, 4, 140, 145, 116, 55, 182, 89, 150, 133, 89, 147, 238, 166, 219, 204, 89, 84, 21, 27, 221, 205, 122, 189, 118, 119, 255, 218, 233, 253, 83, - 191, 176, 26, 227, 154, 20, 7, 146, 110, 69, 198, 129, 164, 195, 144, 142, 36, 173, 35, 98, 157, 210, 146, 17, 235, 144, 214, 138, 152, 33, 45, 138, - 88, 80, 76, 164, 137, 212, 142, 52, 136, 151, 206, 159, 227, 202, 245, 107, 252, 73, 17, 63, 162, 187, 31, 122, 132, 51, 41, 12, 132, 20, 216, 1, - 72, 110, 150, 246, 67, 109, 255, 27, 134, 127, 39, 34, 126, 114, 246, 114, 186, 27, 173, 215, 39, 236, 238, 238, 114, 120, 116, 140, 128, 174, 238, 154, - 243, 247, 182, 183, 183, 127, 97, 123, 107, 251, 21, 227, 43, 93, 117, 180, 244, 252, 143, 87, 171, 213, 127, 180, 94, 175, 137, 8, 50, 19, 73, 128, - 217, 216, 218, 218, 194, 110, 50, 130, 110, 35, 137, 234, 102, 89, 22, 192, 84, 65, 119, 179, 81, 85, 156, 156, 156, 208, 221, 191, 115, 199, 254, 169, - 255, 106, 119, 119, 247, 2, 102, 65, 58, 150, 56, 1, 142, 5, 107, 73, 19, 104, 65, 133, 212, 64, 73, 106, 67, 11, 44, 100, 11, 115, 219, 75, - 231, 95, 225, 79, 139, 248, 255, 224, 241, 199, 158, 32, 49, 141, 144, 91, 216, 97, 8, 1, 182, 115, 153, 243, 158, 118, 127, 118, 186, 127, 234, 228, - 100, 253, 185, 49, 242, 225, 101, 153, 187, 64, 217, 190, 132, 249, 202, 222, 238, 238, 63, 94, 141, 241, 166, 205, 9, 176, 92, 189, 118, 245, 161, 159, - 248, 236, 79, 252, 143, 171, 173, 173, 79, 188, 250, 234, 121, 50, 147, 155, 55, 111, 145, 25, 116, 23, 146, 216, 222, 222, 38, 34, 16, 198, 134, 182, - 89, 150, 133, 170, 162, 170, 17, 162, 109, 132, 56, 62, 62, 242, 178, 204, 47, 239, 237, 237, 253, 23, 167, 246, 247, 95, 5, 166, 96, 45, 233, 4, - 233, 4, 88, 11, 166, 160, 5, 109, 169, 3, 89, 162, 185, 173, 52, 124, 237, 244, 3, 156, 190, 117, 137, 243, 47, 63, 207, 159, 54, 241, 39, 224, - 137, 71, 31, 167, 99, 69, 244, 130, 109, 9, 75, 16, 186, 109, 100, 82, 85, 99, 233, 222, 61, 62, 57, 57, 211, 213, 123, 17, 234, 49, 198, 173, - 213, 106, 117, 212, 221, 216, 14, 131, 70, 68, 95, 186, 114, 249, 167, 158, 120, 226, 137, 95, 60, 60, 60, 188, 227, 51, 159, 249, 12, 111, 188, 241, - 6, 27, 103, 207, 158, 229, 249, 231, 159, 231, 129, 7, 30, 224, 245, 215, 95, 35, 51, 176, 77, 85, 97, 155, 57, 155, 170, 162, 230, 36, 16, 182, - 89, 230, 156, 213, 245, 155, 251, 123, 251, 255, 221, 254, 222, 222, 183, 109, 31, 2, 235, 148, 22, 96, 45, 105, 1, 38, 96, 192, 128, 21, 233, 188, - 126, 139, 186, 243, 14, 190, 243, 242, 75, 252, 179, 54, 248, 19, 240, 242, 249, 115, 108, 124, 252, 177, 199, 177, 100, 57, 12, 182, 49, 235, 57, 5, - 56, 165, 121, 199, 222, 222, 77, 221, 102, 59, 170, 42, 220, 173, 128, 64, 82, 131, 70, 142, 14, 233, 198, 133, 11, 23, 214, 146, 184, 120, 241, 34, - 175, 190, 250, 42, 79, 62, 249, 36, 111, 189, 245, 22, 103, 206, 156, 225, 190, 251, 238, 227, 141, 55, 94, 163, 170, 144, 68, 119, 211, 93, 128, 136, - 8, 10, 49, 171, 152, 115, 94, 147, 244, 143, 78, 157, 186, 227, 151, 183, 183, 182, 222, 182, 221, 33, 221, 2, 142, 145, 166, 208, 148, 100, 41, 124, - 112, 120, 145, 83, 251, 15, 240, 194, 185, 23, 249, 99, 87, 47, 241, 255, 7, 241, 167, 232, 241, 71, 159, 224, 93, 6, 91, 41, 176, 45, 144, 192, - 226, 93, 178, 45, 64, 25, 193, 213, 27, 55, 118, 151, 154, 255, 153, 34, 254, 214, 169, 253, 253, 237, 131, 195, 67, 30, 120, 224, 1, 174, 95, 191, - 206, 238, 238, 46, 25, 201, 193, 225, 45, 186, 139, 238, 166, 109, 220, 13, 4, 85, 197, 92, 150, 195, 174, 126, 118, 140, 241, 27, 219, 219, 219, 223, - 202, 204, 75, 145, 121, 41, 35, 46, 14, 233, 42, 104, 177, 228, 163, 213, 142, 199, 92, 243, 221, 87, 94, 226, 207, 18, 241, 207, 208, 39, 31, 255, - 56, 118, 19, 26, 204, 94, 99, 54, 36, 113, 155, 13, 152, 207, 253, 216, 147, 254, 39, 95, 255, 189, 59, 142, 79, 78, 254, 58, 240, 243, 57, 198, - 231, 20, 186, 43, 51, 119, 186, 91, 171, 28, 108, 111, 111, 179, 94, 214, 172, 151, 5, 139, 118, 247, 81, 47, 117, 177, 219, 207, 103, 196, 211, 171, - 213, 234, 133, 28, 249, 86, 68, 92, 141, 136, 203, 17, 113, 57, 34, 174, 167, 98, 145, 18, 187, 121, 233, 252, 203, 252, 89, 36, 254, 140, 250, 220, - 103, 63, 199, 119, 95, 251, 238, 30, 240, 216, 241, 241, 241, 39, 247, 246, 246, 158, 152, 203, 124, 48, 35, 246, 70, 142, 81, 93, 89, 221, 199, 118, - 95, 150, 116, 33, 35, 223, 204, 204, 43, 17, 113, 32, 116, 168, 208, 77, 73, 183, 34, 226, 48, 164, 117, 219, 30, 17, 188, 116, 254, 21, 254, 44, - 19, 255, 28, 240, 23, 223, 64, 127, 237, 65, 62, 251, 233, 207, 228, 181, 27, 215, 87, 115, 206, 40, 125, 211, 16, 0, 0, 0, 35, 73, 68, 65, - 84, 149, 164, 204, 8, 133, 132, 13, 22, 190, 173, 132, 22, 133, 166, 164, 186, 251, 158, 143, 248, 248, 248, 136, 103, 158, 125, 134, 127, 94, 252, 223, - 160, 16, 125, 12, 251, 15, 241, 139, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130]) -let testJpg = new Uint8Array([255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 255, 219, 0, 67, 0, 6, 4, 4, 5, 4, 4, 6, - 5, 5, 5, 6, 6, 6, 7, 9, 14, 9, 9, 8, 8, 9, 18, 13, 13, 10, 14, 21, 18, 22, 22, 21, 18, 20, 20, 23, 26, 33, 28, 23, - 24, 31, 25, 20, 20, 29, 39, 29, 31, 34, 35, 37, 37, 37, 22, 28, 41, 44, 40, 36, 43, 33, 36, 37, 36, 255, 219, 0, 67, 1, 6, 6, - 6, 9, 8, 9, 17, 9, 9, 17, 36, 24, 20, 24, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, - 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 255, 194, - 0, 17, 8, 0, 134, 0, 200, 3, 1, 34, 0, 2, 17, 1, 3, 17, 1, 255, 196, 0, 27, 0, 0, 2, 3, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 3, 5, 0, 2, 4, 6, 1, 7, 255, 196, 0, 25, 1, 0, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 2, 3, 0, 4, 5, 255, 218, 0, 12, 3, 1, 0, 2, 16, 3, 16, 0, 0, 1, 228, 9, 152, 145, 134, 173, 24, 72, 155, - 105, 215, 68, 13, 44, 184, 169, 181, 80, 198, 145, 166, 191, 14, 53, 115, 16, 9, 170, 96, 157, 183, 164, 243, 213, 54, 23, 158, 46, 129, 56, 219, - 15, 57, 234, 91, 12, 97, 24, 172, 209, 230, 230, 64, 147, 117, 160, 203, 198, 198, 155, 45, 245, 151, 174, 169, 238, 202, 85, 58, 62, 137, 3, 159, - 82, 218, 134, 75, 131, 207, 162, 239, 7, 1, 242, 208, 244, 60, 223, 60, 71, 66, 251, 148, 53, 208, 185, 205, 232, 2, 49, 215, 48, 197, 111, 116, - 187, 242, 44, 167, 113, 172, 128, 215, 205, 153, 51, 58, 47, 62, 7, 222, 70, 222, 128, 78, 201, 53, 58, 171, 216, 237, 64, 226, 111, 167, 22, 22, - 232, 220, 106, 77, 229, 243, 185, 150, 141, 149, 20, 43, 207, 183, 29, 215, 33, 243, 218, 186, 210, 147, 51, 227, 128, 190, 125, 182, 219, 41, 100, 187, - 47, 82, 147, 227, 200, 79, 122, 126, 47, 222, 191, 163, 40, 216, 21, 113, 167, 116, 203, 228, 253, 218, 217, 207, 58, 215, 149, 132, 146, 49, 19, 190, - 38, 245, 43, 60, 16, 170, 239, 42, 14, 158, 45, 35, 200, 19, 180, 204, 49, 180, 38, 109, 238, 54, 31, 63, 144, 47, 95, 167, 97, 234, 141, 158, - 230, 149, 125, 21, 206, 197, 25, 118, 78, 128, 112, 175, 40, 197, 216, 209, 142, 137, 138, 95, 54, 66, 45, 183, 205, 243, 166, 239, 56, 197, 162, 172, - 236, 112, 219, 143, 24, 24, 202, 133, 113, 164, 99, 207, 106, 84, 126, 208, 205, 194, 110, 205, 199, 167, 38, 158, 166, 206, 3, 97, 147, 235, 115, 202, - 244, 232, 206, 83, 187, 28, 107, 151, 78, 67, 1, 207, 98, 176, 188, 121, 21, 146, 38, 181, 235, 114, 133, 207, 187, 112, 249, 246, 46, 110, 11, 143, - 56, 42, 61, 129, 151, 202, 29, 134, 116, 110, 164, 124, 205, 122, 119, 209, 93, 252, 239, 187, 133, 239, 201, 245, 220, 102, 39, 235, 56, 126, 156, 30, - 149, 59, 110, 9, 79, 64, 175, 74, 25, 200, 70, 244, 62, 124, 252, 218, 187, 59, 247, 116, 236, 80, 189, 133, 80, 34, 32, 59, 60, 236, 66, 109, - 229, 10, 57, 182, 85, 41, 175, 159, 98, 165, 145, 113, 109, 142, 245, 202, 98, 102, 103, 100, 222, 80, 108, 119, 200, 176, 166, 250, 63, 6, 193, 89, - 110, 135, 132, 48, 166, 158, 87, 223, 2, 24, 135, 195, 62, 190, 172, 188, 246, 24, 22, 121, 242, 26, 156, 250, 151, 90, 174, 190, 204, 241, 202, 93, - 146, 117, 109, 38, 146, 67, 219, 201, 36, 220, 89, 34, 254, 138, 65, 149, 201, 59, 20, 30, 200, 194, 90, 69, 215, 52, 147, 108, 217, 36, 161, 53, - 164, 109, 81, 201, 133, 164, 138, 127, 255, 196, 0, 36, 16, 0, 2, 2, 3, 0, 2, 2, 3, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2, 0, - 3, 4, 17, 18, 19, 33, 5, 34, 16, 20, 49, 65, 21, 50, 255, 218, 0, 8, 1, 1, 0, 1, 5, 2, 128, 192, 243, 201, 3, 78, 160, 51, - 251, 60, 123, 158, 50, 37, 100, 136, 46, 158, 93, 199, 34, 15, 115, 153, 238, 111, 242, 125, 194, 39, 27, 30, 56, 213, 206, 76, 209, 128, 24, 55, - 54, 103, 70, 7, 48, 89, 22, 217, 216, 48, 115, 63, 93, 200, 240, 180, 106, 204, 85, 34, 117, 3, 66, 194, 121, 4, 236, 77, 136, 88, 78, 245, - 5, 131, 109, 163, 22, 184, 41, 130, 129, 161, 72, 158, 37, 135, 28, 79, 4, 52, 79, 25, 149, 212, 206, 216, 127, 28, 181, 65, 194, 128, 4, 124, - 122, 172, 23, 124, 58, 153, 149, 129, 126, 50, 247, 25, 225, 99, 59, 51, 202, 103, 154, 53, 176, 89, 18, 239, 117, 184, 210, 48, 51, 212, 90, 250, - 134, 173, 19, 177, 1, 16, 232, 205, 8, 159, 87, 163, 34, 38, 154, 15, 198, 230, 210, 241, 242, 191, 28, 184, 231, 137, 196, 230, 20, 18, 193, 169, - 206, 231, 132, 194, 141, 176, 26, 7, 97, 6, 67, 74, 242, 204, 92, 173, 195, 122, 153, 245, 63, 141, 76, 74, 125, 216, 126, 244, 230, 42, 138, 178, - 67, 128, 211, 184, 87, 195, 111, 202, 229, 126, 213, 250, 51, 80, 172, 212, 116, 159, 195, 229, 158, 65, 181, 160, 9, 250, 224, 145, 134, 39, 234, 129, - 63, 90, 26, 88, 16, 27, 124, 60, 196, 195, 119, 54, 128, 20, 167, 223, 51, 26, 243, 71, 195, 99, 92, 49, 179, 25, 177, 241, 112, 30, 220, 154, - 242, 25, 69, 35, 68, 241, 56, 140, 178, 197, 135, 168, 202, 219, 10, 97, 26, 139, 105, 137, 100, 13, 63, 221, 137, 164, 97, 94, 39, 108, 152, 245, - 36, 99, 233, 142, 229, 227, 83, 30, 209, 170, 242, 107, 172, 87, 98, 90, 150, 30, 79, 203, 19, 226, 251, 44, 160, 249, 34, 209, 77, 139, 112, 241, - 63, 67, 103, 152, 120, 135, 136, 200, 166, 122, 34, 176, 12, 224, 193, 181, 158, 165, 117, 246, 202, 56, 4, 195, 44, 73, 106, 157, 35, 154, 142, 101, - 182, 217, 62, 58, 245, 76, 52, 126, 230, 109, 205, 109, 138, 173, 115, 46, 48, 165, 22, 149, 75, 51, 143, 118, 232, 71, 254, 15, 176, 113, 14, 196, - 91, 14, 150, 215, 137, 144, 218, 92, 158, 134, 57, 243, 26, 209, 107, 27, 132, 205, 207, 236, 106, 183, 31, 7, 215, 235, 148, 56, 244, 251, 36, 87, - 93, 129, 33, 175, 71, 91, 11, 143, 101, 53, 218, 157, 66, 162, 29, 111, 159, 187, 110, 55, 240, 87, 234, 133, 212, 41, 27, 28, 129, 138, 139, 85, - 97, 230, 224, 121, 254, 167, 45, 8, 155, 159, 173, 184, 181, 242, 217, 219, 0, 158, 32, 121, 74, 78, 67, 165, 203, 195, 178, 253, 77, 115, 128, 176, - 0, 65, 68, 103, 15, 233, 108, 58, 91, 73, 92, 94, 238, 134, 178, 34, 127, 58, 133, 226, 60, 164, 29, 241, 181, 43, 197, 189, 20, 0, 125, 110, - 201, 107, 91, 76, 239, 175, 120, 238, 52, 140, 117, 157, 81, 239, 135, 105, 239, 76, 158, 220, 21, 135, 108, 255, 0, 194, 187, 216, 162, 195, 40, 11, - 74, 1, 212, 21, 9, 98, 199, 149, 123, 152, 219, 128, 250, 40, 53, 115, 123, 186, 225, 85, 22, 88, 11, 22, 48, 95, 185, 79, 38, 177, 233, 89, - 5, 233, 144, 77, 86, 91, 146, 166, 53, 187, 158, 114, 99, 48, 105, 173, 204, 76, 186, 170, 85, 204, 12, 149, 223, 163, 139, 111, 81, 16, 52, 190, - 189, 45, 214, 114, 113, 14, 218, 159, 75, 95, 243, 254, 128, 149, 185, 51, 228, 108, 46, 254, 86, 22, 11, 8, 150, 183, 39, 15, 35, 69, 178, 91, - 164, 184, 214, 115, 244, 47, 113, 160, 227, 150, 68, 112, 124, 186, 42, 131, 167, 199, 246, 234, 213, 15, 59, 210, 112, 242, 186, 152, 89, 10, 201, 155, - 96, 226, 234, 124, 166, 176, 244, 54, 53, 222, 170, 97, 206, 37, 158, 82, 246, 248, 213, 242, 149, 229, 36, 52, 183, 110, 108, 255, 0, 198, 249, 152, - 148, 51, 139, 23, 245, 241, 110, 181, 172, 35, 178, 109, 94, 154, 191, 114, 234, 23, 172, 123, 64, 43, 113, 217, 11, 226, 241, 41, 93, 40, 148, 221, - 192, 108, 214, 118, 243, 9, 102, 65, 222, 43, 135, 149, 167, 85, 96, 238, 149, 201, 8, 113, 202, 146, 197, 248, 2, 221, 30, 153, 199, 46, 7, 198, - 222, 58, 202, 201, 108, 169, 101, 97, 154, 218, 252, 131, 86, 106, 194, 117, 99, 175, 73, 17, 249, 139, 246, 110, 248, 10, 224, 214, 24, 168, 98, 82, - 43, 177, 119, 115, 188, 108, 179, 73, 31, 49, 171, 50, 50, 133, 142, 114, 29, 167, 94, 144, 108, 145, 165, 248, 242, 58, 183, 161, 18, 210, 49, 171, - 179, 74, 110, 32, 187, 243, 22, 208, 90, 199, 216, 224, 105, 190, 178, 151, 38, 121, 72, 30, 126, 151, 161, 3, 237, 84, 232, 143, 69, 151, 112, 208, - 21, 44, 232, 203, 24, 232, 55, 115, 126, 188, 154, 125, 232, 37, 155, 159, 103, 133, 206, 187, 36, 163, 115, 1, 47, 18, 223, 185, 59, 179, 201, 220, - 255, 196, 0, 34, 17, 0, 2, 2, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 17, 16, 18, 3, 33, 4, 32, 49, - 65, 34, 48, 97, 255, 218, 0, 8, 1, 3, 1, 1, 63, 1, 253, 106, 172, 148, 41, 136, 172, 208, 162, 177, 165, 142, 214, 47, 27, 26, 179, 178, - 217, 121, 72, 95, 136, 251, 43, 210, 203, 46, 179, 86, 36, 181, 254, 147, 125, 30, 63, 22, 210, 239, 224, 242, 56, 210, 87, 139, 47, 29, 151, 120, - 72, 138, 44, 108, 225, 141, 179, 201, 119, 138, 53, 44, 100, 81, 66, 19, 30, 56, 225, 71, 36, 118, 62, 11, 44, 163, 82, 8, 174, 232, 146, 213, - 137, 147, 120, 82, 251, 54, 234, 217, 46, 217, 161, 69, 209, 98, 102, 204, 115, 127, 102, 200, 150, 54, 214, 8, 230, 228, 180, 151, 186, 31, 165, 225, - 231, 255, 196, 0, 36, 17, 0, 2, 2, 2, 2, 2, 2, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 17, 3, 33, 18, 19, 16, 49, - 4, 65, 34, 97, 20, 50, 81, 255, 218, 0, 8, 1, 2, 1, 1, 63, 1, 161, 164, 112, 177, 193, 143, 146, 56, 242, 250, 35, 142, 134, 135, 18, - 159, 135, 98, 200, 78, 114, 71, 115, 59, 153, 222, 200, 100, 183, 178, 171, 72, 100, 176, 192, 113, 173, 26, 34, 147, 56, 196, 120, 162, 206, 248, 191, - 100, 167, 137, 157, 112, 126, 142, 186, 62, 54, 6, 191, 41, 30, 199, 100, 157, 146, 201, 189, 156, 136, 50, 172, 164, 73, 35, 137, 24, 74, 114, 227, - 19, 15, 199, 88, 215, 239, 195, 149, 50, 79, 102, 89, 241, 67, 77, 198, 209, 13, 177, 81, 95, 178, 159, 250, 73, 35, 132, 89, 131, 227, 199, 18, - 253, 248, 114, 38, 236, 226, 124, 182, 220, 232, 221, 104, 198, 154, 217, 22, 118, 29, 201, 14, 22, 99, 248, 202, 95, 216, 145, 100, 137, 196, 244, 182, - 74, 219, 178, 184, 196, 175, 196, 161, 65, 138, 36, 115, 241, 103, 242, 20, 137, 207, 101, 234, 200, 190, 72, 145, 159, 81, 162, 144, 163, 170, 36, 183, - 72, 138, 59, 53, 161, 56, 178, 112, 26, 104, 228, 208, 178, 73, 35, 12, 184, 251, 50, 63, 184, 142, 77, 251, 41, 125, 158, 221, 35, 174, 94, 208, - 163, 36, 69, 81, 68, 137, 33, 146, 35, 39, 117, 229, 161, 162, 62, 43, 199, 255, 196, 0, 46, 16, 0, 2, 2, 1, 3, 2, 4, 5, 4, 3, - 1, 0, 0, 0, 0, 0, 0, 1, 2, 17, 33, 16, 18, 49, 65, 81, 32, 34, 50, 97, 3, 19, 48, 66, 113, 35, 64, 129, 145, 80, 82, 161, - 177, 255, 218, 0, 8, 1, 1, 0, 6, 63, 2, 255, 0, 9, 123, 93, 28, 63, 219, 40, 174, 75, 248, 143, 115, 41, 81, 193, 82, 130, 63, 74, - 123, 127, 38, 233, 37, 37, 221, 125, 26, 127, 73, 52, 84, 185, 47, 192, 224, 243, 221, 51, 124, 61, 47, 167, 213, 207, 135, 230, 75, 132, 90, 178, - 158, 11, 90, 252, 229, 233, 251, 143, 211, 126, 72, 175, 216, 238, 154, 168, 155, 82, 165, 166, 239, 129, 47, 48, 190, 127, 36, 231, 240, 224, 231, 40, - 174, 17, 25, 207, 225, 74, 23, 209, 146, 82, 244, 215, 135, 5, 125, 37, 140, 30, 157, 119, 104, 148, 164, 144, 167, 6, 165, 23, 212, 84, 84, 101, - 94, 218, 103, 8, 195, 169, 14, 18, 231, 199, 90, 94, 148, 138, 240, 215, 65, 56, 244, 35, 190, 94, 106, 200, 230, 123, 35, 108, 99, 147, 60, 146, - 146, 245, 51, 248, 241, 114, 96, 182, 100, 162, 151, 138, 244, 206, 184, 47, 116, 183, 27, 220, 155, 47, 195, 76, 178, 216, 145, 104, 93, 252, 23, 122, - 237, 44, 170, 35, 219, 75, 44, 161, 199, 91, 179, 36, 78, 116, 228, 218, 188, 87, 174, 77, 213, 145, 197, 255, 0, 26, 126, 53, 221, 209, 142, 184, - 70, 112, 197, 108, 119, 208, 230, 180, 242, 171, 23, 145, 164, 40, 196, 246, 250, 17, 28, 191, 161, 119, 209, 246, 49, 201, 200, 224, 108, 226, 139, 22, - 74, 122, 113, 193, 232, 167, 213, 235, 206, 180, 86, 179, 133, 102, 232, 201, 8, 110, 170, 40, 207, 246, 96, 218, 202, 68, 95, 36, 155, 61, 28, 158, - 231, 158, 243, 167, 177, 229, 87, 100, 148, 126, 215, 84, 126, 162, 228, 221, 173, 46, 74, 150, 12, 189, 37, 62, 236, 177, 62, 172, 221, 46, 16, 231, - 107, 103, 72, 136, 178, 199, 57, 126, 17, 207, 2, 146, 88, 35, 186, 57, 226, 201, 91, 199, 75, 45, 116, 16, 159, 247, 68, 182, 230, 242, 40, 203, - 43, 255, 0, 48, 74, 73, 116, 73, 22, 143, 51, 201, 113, 121, 171, 60, 221, 202, 37, 20, 234, 213, 27, 90, 219, 202, 162, 110, 253, 74, 149, 27, - 107, 40, 165, 252, 153, 26, 138, 193, 116, 232, 217, 60, 81, 73, 212, 107, 132, 200, 205, 127, 194, 254, 227, 253, 177, 86, 39, 213, 228, 181, 195, 187, - 215, 210, 209, 152, 212, 87, 99, 60, 123, 10, 75, 210, 94, 215, 125, 253, 138, 172, 25, 113, 166, 109, 172, 80, 171, 133, 255, 0, 79, 155, 12, 78, - 89, 145, 234, 224, 106, 185, 230, 141, 207, 29, 206, 125, 198, 231, 229, 139, 85, 108, 105, 122, 172, 248, 178, 226, 110, 145, 234, 228, 174, 190, 197, 243, - 252, 143, 191, 68, 52, 232, 189, 213, 236, 39, 220, 252, 119, 43, 177, 179, 237, 54, 113, 101, 46, 4, 229, 212, 149, 231, 105, 185, 215, 153, 95, 227, - 6, 222, 183, 201, 134, 149, 17, 86, 241, 219, 68, 215, 81, 71, 143, 198, 159, 129, 103, 135, 67, 254, 180, 199, 82, 228, 242, 81, 146, 154, 63, 255, - 196, 0, 38, 16, 1, 0, 2, 2, 2, 1, 3, 5, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 17, 33, 49, 65, 81, 97, 16, 113, 161, 129, - 145, 177, 225, 240, 193, 209, 241, 255, 218, 0, 8, 1, 1, 0, 1, 63, 33, 61, 231, 146, 57, 204, 61, 62, 187, 151, 68, 33, 147, 163, 232, 232, - 68, 8, 168, 98, 198, 161, 7, 120, 212, 113, 168, 33, 229, 33, 104, 195, 5, 132, 193, 196, 29, 32, 28, 74, 157, 122, 70, 24, 80, 153, 34, 96, - 126, 101, 71, 244, 83, 181, 19, 150, 33, 115, 9, 24, 11, 204, 243, 122, 68, 250, 6, 143, 16, 94, 32, 117, 51, 147, 155, 40, 226, 51, 33, 7, - 212, 168, 149, 106, 5, 57, 67, 131, 47, 28, 67, 72, 7, 81, 134, 149, 237, 47, 207, 244, 153, 52, 195, 89, 78, 215, 15, 12, 101, 30, 103, 98, - 87, 41, 230, 46, 43, 204, 85, 220, 218, 32, 242, 101, 84, 182, 86, 37, 173, 226, 107, 39, 66, 115, 161, 244, 26, 109, 67, 44, 12, 98, 47, 113, - 28, 184, 192, 103, 56, 68, 25, 233, 107, 199, 208, 197, 34, 141, 75, 80, 110, 83, 152, 72, 47, 113, 90, 204, 7, 44, 60, 56, 116, 112, 167, 113, - 1, 195, 22, 243, 44, 94, 20, 243, 40, 109, 150, 233, 131, 109, 68, 216, 130, 42, 92, 3, 204, 110, 187, 20, 22, 53, 15, 47, 44, 57, 9, 151, - 166, 173, 92, 183, 47, 164, 97, 22, 210, 12, 98, 94, 181, 21, 114, 165, 84, 88, 96, 154, 19, 48, 69, 194, 206, 97, 122, 79, 124, 204, 19, 17, - 177, 186, 243, 15, 137, 14, 74, 217, 53, 165, 174, 38, 48, 168, 220, 250, 65, 185, 135, 45, 158, 129, 84, 212, 0, 192, 234, 32, 220, 52, 225, 11, - 172, 51, 73, 13, 106, 84, 111, 136, 59, 130, 131, 2, 241, 129, 97, 35, 161, 132, 143, 113, 153, 48, 223, 153, 86, 19, 51, 18, 209, 211, 113, 21, - 226, 38, 225, 47, 115, 66, 16, 28, 202, 112, 220, 174, 216, 103, 180, 47, 182, 51, 109, 71, 204, 166, 167, 101, 196, 35, 66, 51, 90, 140, 193, 109, - 76, 156, 68, 172, 131, 141, 54, 184, 221, 67, 168, 212, 80, 206, 222, 103, 92, 115, 8, 4, 178, 82, 166, 107, 150, 3, 146, 41, 94, 199, 168, 176, - 213, 209, 149, 181, 76, 23, 204, 84, 230, 127, 4, 88, 215, 1, 10, 92, 129, 167, 157, 97, 115, 116, 14, 120, 33, 89, 208, 34, 196, 195, 8, 28, - 140, 80, 220, 237, 226, 97, 13, 32, 242, 243, 112, 204, 114, 204, 4, 99, 166, 185, 244, 217, 182, 230, 13, 206, 188, 199, 12, 199, 30, 35, 178, 49, - 18, 193, 9, 77, 89, 152, 173, 6, 102, 106, 227, 226, 44, 174, 106, 102, 229, 166, 142, 236, 150, 212, 231, 113, 86, 241, 15, 183, 21, 163, 136, 93, - 169, 129, 150, 247, 145, 113, 48, 169, 146, 93, 70, 152, 53, 165, 8, 151, 50, 203, 185, 154, 230, 16, 245, 51, 212, 132, 12, 18, 190, 49, 11, 94, - 18, 130, 213, 22, 178, 133, 62, 69, 87, 152, 187, 22, 241, 49, 88, 204, 181, 30, 247, 22, 95, 36, 183, 161, 49, 180, 89, 222, 153, 109, 199, 51, - 4, 107, 44, 121, 18, 203, 178, 89, 184, 51, 186, 134, 222, 165, 39, 137, 98, 138, 178, 193, 57, 162, 174, 91, 185, 72, 8, 216, 178, 48, 57, 196, - 79, 218, 225, 139, 53, 110, 18, 54, 12, 110, 48, 17, 56, 144, 199, 105, 115, 148, 133, 62, 37, 199, 40, 33, 77, 18, 152, 92, 18, 241, 166, 145, - 113, 44, 125, 98, 213, 156, 117, 26, 54, 70, 93, 121, 186, 159, 86, 55, 184, 202, 226, 165, 217, 16, 117, 137, 163, 56, 188, 238, 99, 27, 196, 190, - 51, 76, 36, 205, 12, 183, 133, 213, 14, 216, 168, 25, 117, 46, 97, 222, 24, 24, 185, 87, 188, 1, 119, 202, 149, 228, 71, 227, 158, 39, 48, 148, - 108, 25, 173, 195, 116, 162, 57, 142, 123, 239, 10, 173, 33, 118, 66, 149, 178, 40, 112, 8, 144, 193, 147, 209, 5, 254, 21, 50, 129, 137, 122, 253, - 101, 173, 183, 9, 147, 0, 21, 50, 135, 50, 144, 197, 76, 146, 184, 40, 67, 42, 59, 128, 40, 114, 75, 194, 137, 119, 21, 142, 140, 202, 158, 211, - 34, 220, 229, 32, 166, 100, 94, 105, 153, 106, 229, 189, 198, 173, 253, 165, 168, 82, 216, 130, 208, 91, 248, 133, 176, 90, 227, 226, 107, 166, 75, 198, - 9, 195, 176, 3, 247, 128, 22, 236, 149, 20, 81, 164, 202, 64, 153, 204, 168, 7, 113, 185, 70, 166, 222, 34, 53, 37, 185, 144, 226, 165, 3, 165, - 126, 101, 166, 148, 92, 173, 67, 114, 243, 22, 196, 193, 24, 196, 161, 198, 101, 104, 193, 138, 221, 204, 89, 219, 232, 25, 4, 183, 238, 49, 133, 167, - 74, 230, 90, 33, 165, 44, 27, 93, 237, 3, 146, 100, 164, 128, 19, 238, 103, 61, 128, 59, 153, 30, 135, 79, 79, 254, 196, 80, 166, 191, 143, 136, - 192, 193, 219, 147, 204, 52, 82, 107, 234, 126, 162, 194, 10, 0, 198, 10, 251, 254, 225, 181, 166, 106, 199, 23, 42, 54, 120, 74, 248, 216, 33, 216, - 174, 199, 82, 164, 69, 68, 78, 30, 172, 137, 8, 66, 8, 205, 141, 69, 131, 201, 202, 190, 165, 212, 128, 183, 60, 70, 176, 193, 242, 139, 157, 132, - 169, 119, 149, 201, 91, 153, 15, 50, 226, 13, 244, 43, 209, 93, 195, 22, 103, 30, 70, 229, 41, 99, 90, 91, 137, 184, 32, 198, 161, 102, 168, 87, - 143, 39, 51, 17, 58, 222, 223, 195, 50, 38, 71, 247, 39, 226, 114, 221, 117, 5, 241, 147, 108, 96, 86, 53, 87, 198, 33, 100, 80, 35, 176, 222, - 9, 97, 246, 15, 47, 226, 35, 118, 30, 90, 246, 175, 180, 210, 214, 89, 75, 174, 223, 26, 139, 251, 23, 124, 149, 5, 75, 214, 23, 79, 215, 233, - 1, 55, 179, 59, 187, 254, 251, 65, 22, 230, 87, 20, 238, 36, 219, 50, 115, 30, 112, 118, 47, 241, 52, 7, 44, 34, 202, 138, 103, 203, 29, 125, - 166, 35, 135, 178, 229, 29, 178, 255, 0, 36, 230, 19, 100, 28, 188, 115, 29, 78, 54, 235, 27, 127, 200, 167, 207, 6, 191, 189, 226, 227, 195, 107, - 36, 183, 108, 158, 63, 196, 181, 26, 20, 66, 245, 49, 174, 55, 226, 22, 154, 166, 82, 68, 208, 113, 148, 185, 40, 93, 56, 124, 65, 10, 21, 161, - 239, 11, 0, 170, 85, 84, 0, 72, 129, 60, 96, 197, 236, 150, 14, 211, 66, 25, 196, 92, 224, 54, 249, 117, 83, 28, 16, 4, 213, 33, 174, 73, - 194, 218, 150, 155, 14, 132, 21, 50, 219, 228, 212, 189, 146, 191, 236, 243, 133, 139, 234, 42, 166, 137, 129, 69, 96, 113, 46, 208, 121, 12, 91, 87, - 62, 166, 40, 220, 134, 30, 51, 12, 18, 224, 248, 155, 43, 60, 191, 189, 226, 109, 128, 149, 247, 148, 92, 103, 18, 192, 181, 248, 252, 70, 211, 168, - 79, 255, 218, 0, 12, 3, 1, 0, 2, 0, 3, 0, 0, 0, 16, 0, 11, 95, 201, 21, 11, 241, 117, 198, 54, 242, 102, 37, 18, 160, 46, 55, - 232, 31, 26, 46, 94, 202, 104, 93, 30, 207, 237, 127, 160, 44, 90, 233, 186, 230, 116, 172, 158, 127, 75, 184, 98, 203, 56, 43, 0, 199, 29, 10, - 105, 68, 54, 85, 245, 33, 248, 48, 20, 196, 66, 91, 122, 46, 42, 238, 241, 113, 12, 247, 110, 32, 121, 215, 215, 96, 159, 76, 126, 14, 0, 195, - 254, 24, 66, 13, 232, 125, 247, 255, 196, 0, 28, 17, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 17, 33, - 49, 65, 16, 81, 97, 255, 218, 0, 8, 1, 3, 1, 1, 63, 16, 187, 118, 237, 131, 121, 228, 171, 9, 246, 221, 182, 27, 64, 62, 69, 129, 216, - 17, 143, 39, 126, 217, 191, 146, 26, 88, 78, 28, 130, 99, 118, 212, 48, 167, 110, 88, 100, 79, 46, 201, 239, 145, 230, 64, 242, 93, 50, 214, 205, - 72, 50, 201, 7, 75, 185, 30, 165, 215, 127, 12, 167, 232, 120, 178, 197, 132, 198, 20, 99, 58, 95, 213, 139, 27, 68, 40, 13, 173, 132, 195, 243, - 38, 247, 228, 185, 254, 19, 106, 19, 58, 150, 121, 114, 252, 114, 217, 251, 32, 54, 81, 114, 211, 151, 65, 61, 99, 52, 174, 200, 204, 41, 150, 81, - 56, 140, 94, 55, 198, 28, 233, 115, 4, 116, 174, 196, 143, 133, 177, 11, 196, 247, 57, 210, 237, 178, 59, 52, 251, 33, 118, 72, 255, 0, 85, 219, - 138, 124, 237, 159, 63, 53, 249, 6, 147, 47, 47, 23, 152, 80, 159, 111, 164, 44, 159, 111, 59, 108, 95, 255, 196, 0, 29, 17, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 17, 33, 49, 65, 81, 16, 129, 161, 255, 218, 0, 8, 1, 2, 1, 1, 63, 16, - 98, 164, 79, 138, 92, 27, 125, 144, 22, 188, 149, 121, 49, 242, 3, 228, 104, 242, 71, 201, 51, 191, 192, 253, 99, 110, 54, 45, 140, 30, 64, 24, - 97, 1, 227, 51, 185, 140, 111, 81, 126, 20, 135, 36, 52, 103, 200, 184, 137, 29, 234, 202, 193, 177, 63, 204, 186, 182, 65, 176, 231, 228, 202, 131, - 222, 73, 236, 129, 172, 124, 172, 79, 32, 122, 70, 189, 88, 248, 247, 245, 62, 67, 219, 200, 254, 161, 213, 251, 228, 200, 37, 195, 116, 180, 230, 222, - 242, 20, 41, 230, 218, 255, 0, 54, 212, 103, 95, 101, 44, 161, 225, 176, 118, 211, 159, 39, 166, 188, 134, 211, 237, 244, 91, 7, 78, 216, 186, 95, - 20, 134, 142, 19, 14, 31, 199, 71, 45, 58, 123, 46, 138, 224, 75, 125, 214, 10, 103, 108, 7, 35, 120, 5, 201, 200, 51, 177, 240, 32, 220, 227, - 252, 91, 28, 238, 17, 84, 9, 113, 29, 109, 156, 62, 91, 40, 96, 174, 86, 188, 34, 54, 235, 165, 224, 64, 144, 255, 0, 178, 193, 204, 177, 103, - 135, 179, 157, 33, 204, 71, 193, 61, 79, 37, 149, 58, 89, 75, 236, 171, 18, 207, 166, 195, 144, 196, 200, 114, 96, 79, 32, 57, 100, 64, 64, 48, - 1, 128, 235, 99, 22, 243, 203, 255, 196, 0, 37, 16, 1, 0, 3, 0, 2, 2, 2, 2, 3, 1, 1, 1, 0, 0, 0, 0, 1, 0, 17, 33, - 49, 65, 81, 97, 113, 129, 145, 161, 177, 193, 240, 209, 241, 16, 255, 218, 0, 8, 1, 1, 0, 1, 63, 16, 168, 15, 41, 81, 118, 184, 149, 10, - 48, 123, 138, 188, 228, 56, 160, 52, 236, 194, 39, 42, 152, 197, 218, 83, 221, 146, 184, 86, 109, 18, 90, 84, 183, 141, 64, 119, 103, 238, 50, 240, - 228, 187, 2, 75, 139, 156, 148, 37, 47, 16, 143, 57, 30, 2, 40, 160, 113, 45, 237, 212, 106, 203, 156, 77, 129, 99, 185, 203, 92, 43, 156, 239, - 145, 101, 182, 74, 178, 228, 169, 169, 18, 46, 174, 16, 40, 155, 117, 140, 90, 48, 80, 3, 46, 211, 172, 174, 106, 27, 134, 52, 142, 52, 74, 106, - 169, 97, 26, 200, 15, 72, 95, 130, 19, 190, 32, 244, 37, 67, 89, 74, 101, 167, 148, 227, 34, 143, 9, 168, 43, 198, 65, 24, 25, 214, 18, 230, - 11, 20, 64, 113, 83, 17, 42, 98, 84, 86, 139, 114, 24, 114, 224, 88, 134, 74, 14, 145, 168, 90, 218, 225, 31, 131, 123, 194, 125, 159, 44, 162, - 77, 107, 204, 187, 91, 215, 83, 204, 129, 11, 247, 132, 114, 212, 180, 168, 31, 120, 142, 197, 133, 203, 80, 173, 44, 224, 38, 137, 104, 84, 79, 230, - 90, 1, 185, 102, 83, 204, 168, 12, 10, 63, 178, 58, 54, 119, 137, 193, 97, 134, 42, 9, 118, 74, 172, 106, 92, 254, 113, 81, 210, 171, 167, 187, - 231, 127, 21, 0, 167, 134, 249, 130, 21, 112, 50, 130, 206, 161, 187, 194, 128, 127, 80, 205, 243, 38, 191, 94, 178, 44, 219, 98, 66, 176, 66, 47, - 197, 197, 64, 243, 41, 135, 152, 83, 23, 45, 192, 217, 43, 185, 3, 76, 60, 244, 70, 199, 131, 168, 29, 43, 81, 171, 81, 106, 177, 29, 160, 95, - 204, 254, 248, 206, 58, 40, 117, 224, 156, 48, 96, 110, 6, 171, 61, 194, 0, 138, 27, 230, 94, 64, 60, 67, 96, 106, 22, 137, 139, 114, 85, 6, - 169, 228, 246, 74, 136, 90, 210, 135, 218, 63, 7, 212, 51, 180, 11, 74, 102, 185, 100, 218, 33, 2, 158, 225, 119, 244, 64, 46, 133, 29, 127, 243, - 83, 10, 249, 99, 85, 175, 137, 112, 66, 217, 139, 215, 169, 184, 47, 212, 113, 192, 119, 15, 131, 0, 110, 215, 20, 23, 67, 47, 198, 84, 208, 40, - 2, 37, 222, 188, 32, 130, 173, 131, 67, 249, 137, 42, 208, 243, 203, 205, 252, 70, 255, 0, 4, 215, 254, 57, 130, 217, 209, 205, 87, 205, 117, 124, - 192, 80, 6, 55, 188, 224, 150, 96, 99, 117, 18, 18, 31, 88, 64, 151, 73, 84, 51, 170, 142, 218, 217, 79, 90, 62, 160, 245, 211, 228, 130, 14, - 76, 58, 159, 88, 11, 125, 185, 2, 73, 177, 42, 163, 230, 5, 200, 57, 156, 75, 111, 117, 48, 102, 246, 16, 17, 243, 216, 184, 120, 80, 58, 33, - 19, 207, 203, 16, 219, 45, 129, 142, 109, 106, 185, 149, 197, 210, 199, 21, 119, 8, 24, 218, 108, 213, 127, 80, 70, 47, 161, 41, 249, 107, 60, 196, - 2, 101, 209, 83, 22, 181, 120, 35, 10, 187, 21, 173, 246, 75, 253, 159, 164, 243, 21, 84, 178, 225, 2, 3, 5, 65, 111, 113, 176, 220, 93, 35, - 32, 197, 5, 242, 69, 154, 41, 114, 29, 239, 217, 238, 121, 224, 166, 4, 23, 142, 65, 189, 163, 170, 20, 120, 16, 57, 31, 185, 99, 2, 92, 244, - 30, 73, 88, 20, 38, 222, 90, 12, 140, 217, 91, 98, 85, 103, 95, 36, 19, 165, 20, 211, 78, 140, 173, 234, 112, 112, 119, 209, 212, 97, 232, 160, - 236, 185, 114, 43, 235, 35, 218, 129, 160, 208, 46, 53, 232, 35, 122, 34, 174, 233, 153, 116, 115, 47, 166, 214, 31, 117, 46, 130, 89, 9, 175, 111, - 168, 228, 91, 30, 217, 205, 60, 202, 26, 236, 121, 149, 41, 190, 79, 152, 133, 138, 71, 76, 74, 92, 151, 60, 50, 141, 8, 119, 194, 32, 181, 189, - 87, 152, 2, 214, 32, 56, 164, 201, 11, 212, 70, 229, 6, 181, 212, 69, 148, 231, 37, 6, 198, 198, 67, 93, 153, 84, 85, 111, 137, 156, 199, 210, - 114, 158, 237, 211, 8, 192, 28, 132, 63, 115, 93, 61, 33, 158, 32, 35, 186, 94, 96, 28, 2, 4, 15, 34, 48, 228, 174, 143, 48, 69, 48, 126, - 229, 232, 42, 134, 199, 186, 165, 240, 75, 91, 224, 158, 37, 2, 2, 63, 185, 119, 178, 244, 62, 101, 68, 140, 151, 113, 117, 111, 146, 9, 77, 159, - 135, 153, 76, 110, 198, 67, 42, 31, 19, 184, 244, 39, 155, 54, 49, 175, 130, 201, 88, 80, 133, 167, 136, 85, 22, 241, 46, 96, 114, 81, 13, 106, - 41, 210, 177, 13, 182, 232, 71, 69, 143, 22, 0, 224, 176, 179, 137, 178, 162, 12, 220, 186, 191, 81, 118, 133, 20, 84, 27, 207, 52, 182, 36, 60, - 96, 44, 26, 160, 112, 64, 36, 90, 211, 143, 81, 238, 149, 87, 7, 153, 171, 6, 21, 55, 17, 230, 241, 26, 150, 111, 126, 32, 16, 42, 30, 72, - 109, 16, 35, 103, 117, 94, 94, 98, 11, 106, 220, 245, 4, 101, 64, 3, 204, 191, 32, 121, 20, 134, 64, 186, 148, 109, 217, 233, 238, 52, 20, 50, - 170, 31, 40, 49, 111, 234, 95, 154, 147, 92, 122, 141, 1, 171, 74, 205, 1, 121, 47, 82, 158, 92, 129, 238, 0, 0, 84, 198, 55, 12, 240, 233, - 150, 17, 104, 110, 177, 185, 64, 14, 248, 148, 16, 188, 83, 203, 24, 96, 144, 250, 57, 8, 134, 207, 241, 247, 5, 5, 151, 229, 40, 83, 92, 2, - 227, 205, 57, 27, 104, 191, 48, 177, 46, 135, 200, 242, 203, 32, 117, 75, 231, 238, 49, 31, 248, 71, 192, 253, 227, 193, 115, 136, 149, 108, 10, 106, - 61, 5, 10, 45, 128, 23, 78, 71, 215, 26, 221, 143, 215, 161, 197, 81, 59, 48, 81, 228, 224, 132, 160, 185, 124, 24, 96, 123, 207, 62, 216, 77, - 104, 104, 94, 107, 25, 21, 90, 111, 163, 48, 255, 0, 119, 42, 161, 224, 33, 218, 176, 169, 233, 158, 50, 85, 59, 8, 165, 91, 30, 89, 146, 150, - 16, 108, 241, 156, 74, 148, 35, 124, 113, 222, 162, 123, 216, 63, 71, 19, 82, 14, 147, 130, 185, 148, 96, 50, 22, 165, 213, 254, 226, 117, 2, 78, - 222, 203, 177, 184, 252, 115, 122, 174, 203, 12, 34, 234, 171, 243, 9, 114, 168, 96, 149, 224, 203, 243, 16, 195, 182, 108, 114, 92, 85, 238, 194, 216, - 177, 195, 71, 190, 6, 11, 248, 253, 192, 69, 1, 203, 232, 133, 60, 84, 151, 233, 144, 237, 91, 6, 176, 247, 18, 210, 2, 252, 122, 249, 137, 140, - 61, 72, 203, 65, 45, 43, 91, 43, 132, 46, 144, 120, 128, 49, 12, 39, 82, 182, 88, 211, 126, 184, 252, 164, 122, 156, 144, 15, 164, 100, 96, 21, - 5, 212, 243, 55, 137, 83, 134, 18, 244, 133, 192, 61, 64, 42, 133, 114, 45, 134, 11, 243, 103, 231, 238, 51, 182, 5, 6, 130, 214, 103, 191, 196, - 64, 237, 58, 122, 22, 253, 93, 149, 246, 248, 158, 75, 67, 19, 1, 119, 178, 145, 179, 54, 89, 81, 52, 104, 85, 220, 61, 77, 175, 124, 190, 224, - 121, 250, 146, 107, 219, 175, 93, 203, 166, 171, 117, 200, 195, 213, 129, 54, 178, 13, 219, 22, 126, 33, 158, 42, 64, 112, 91, 39, 27, 132, 119, 224, - 148, 52, 228, 7, 209, 190, 35, 211, 68, 199, 42, 247, 115, 143, 196, 3, 205, 244, 94, 104, 113, 85, 171, 0, 89, 69, 0, 40, 158, 201, 99, 0, - 26, 43, 166, 106, 122, 249, 238, 80, 201, 40, 53, 76, 35, 181, 130, 137, 191, 74, 94, 123, 143, 128, 205, 72, 187, 13, 190, 170, 47, 56, 232, 106, - 181, 223, 2, 86, 241, 196, 64, 119, 144, 86, 45, 175, 121, 81, 74, 162, 77, 222, 173, 254, 18, 50, 60, 250, 184, 197, 141, 252, 1, 62, 101, 48, - 153, 5, 245, 11, 227, 139, 31, 200, 25, 81, 20, 65, 79, 224, 216, 183, 126, 235, 136, 24, 165, 184, 29, 37, 143, 92, 2, 178, 185, 128, 184, 4, - 182, 98, 219, 219, 221, 94, 185, 201, 64, 98, 9, 155, 19, 128, 228, 47, 247, 76, 87, 122, 164, 228, 35, 123, 94, 255, 0, 184, 224, 185, 138, 149, - 191, 251, 251, 140, 76, 177, 109, 21, 195, 94, 171, 235, 38, 181, 167, 134, 171, 247, 45, 251, 41, 212, 128, 253, 78, 19, 195, 145, 17, 188, 134, 241, - 31, 105, 49, 68, 142, 1, 229, 95, 227, 196, 174, 129, 10, 50, 216, 189, 105, 89, 238, 52, 221, 80, 235, 233, 221, 85, 125, 205, 228, 218, 53, 125, - 232, 16, 14, 75, 105, 180, 246, 191, 238, 227, 236, 218, 148, 59, 92, 255, 0, 184, 151, 109, 51, 31, 107, 246, 253, 67, 120, 192, 130, 158, 22, 174, - 129, 92, 154, 139, 77, 45, 77, 1, 240, 143, 203, 17, 1, 175, 16, 124, 133, 83, 238, 4, 238, 18, 212, 4, 118, 251, 137, 203, 14, 171, 86, 161, - 71, 213, 30, 111, 196, 187, 10, 181, 94, 76, 255, 0, 47, 77, 121, 137, 81, 155, 87, 179, 206, 71, 202, 59, 57, 157, 79, 60, 93, 215, 252, 171, - 137, 5, 21, 149, 16, 166, 152, 243, 126, 105, 189, 89, 184, 186, 192, 22, 12, 166, 130, 185, 245, 232, 129, 213, 64, 242, 130, 128, 221, 186, 216, 250, - 209, 194, 60, 6, 75, 188, 62, 7, 171, 91, 224, 247, 173, 169, 129, 32, 6, 140, 206, 177, 224, 57, 186, 192, 228, 73, 173, 9, 104, 59, 56, 175, - 99, 206, 195, 106, 212, 101, 162, 55, 163, 27, 250, 94, 228, 167, 247, 101, 192, 180, 175, 214, 25, 14, 189, 179, 105, 176, 64, 3, 180, 3, 227, 113, - 142, 178, 12, 42, 186, 93, 103, 20, 241, 21, 171, 35, 178, 160, 0, 28, 247, 127, 221, 75, 39, 218, 220, 175, 55, 99, 250, 236, 151, 44, 5, 233, - 109, 18, 86, 43, 105, 191, 246, 26, 242, 1, 89, 113, 92, 80, 229, 102, 92, 165, 198, 91, 59, 165, 31, 207, 252, 139, 89, 112, 36, 66, 219, 202, - 183, 143, 168, 94, 47, 176, 0, 160, 136, 22, 149, 154, 227, 54, 224, 209, 178, 235, 88, 45, 13, 127, 234, 216, 131, 8, 65, 134, 190, 2, 232, 104, - 174, 119, 122, 156, 248, 30, 107, 16, 180, 242, 107, 124, 225, 223, 4, 0, 209, 26, 247, 93, 243, 182, 239, 7, 218, 59, 30, 138, 84, 41, 30, 141, - 77, 255, 0, 177, 26, 211, 119, 82, 155, 229, 27, 176, 227, 191, 204, 37, 128, 0, 29, 96, 212, 60, 116, 129, 39, 110, 108, 47, 230, 102, 236, 112, - 178, 181, 222, 159, 223, 113, 237, 178, 158, 142, 236, 222, 110, 98, 138, 212, 222, 237, 243, 198, 100, 118, 5, 86, 88, 1, 162, 171, 226, 108, 182, 90, - 69, 22, 214, 199, 201, 71, 153, 191, 170, 54, 26, 21, 43, 174, 155, 178, 253, 192, 33, 200, 10, 0, 66, 138, 186, 110, 139, 173, 30, 136, 193, 176, - 222, 214, 237, 32, 165, 213, 237, 110, 252, 74, 3, 227, 102, 43, 85, 207, 61, 65, 224, 84, 178, 176, 43, 85, 71, 113, 44, 1, 192, 30, 151, 248, - 139, 22, 111, 83, 129, 106, 231, 167, 243, 59, 201, 32, 171, 247, 246, 126, 137, 92, 71, 131, 127, 123, 26, 197, 76, 56, 28, 58, 59, 229, 134, 1, - 106, 39, 179, 195, 215, 44, 215, 211, 74, 217, 217, 254, 246, 202, 198, 182, 182, 168, 28, 103, 204, 190, 32, 52, 105, 201, 66, 222, 243, 141, 249, 151, - 64, 21, 155, 165, 71, 63, 67, 4, 30, 225, 197, 148, 117, 0, 157, 45, 138, 162, 146, 158, 25, 207, 60, 202, 196, 55, 200, 8, 156, 122, 227, 241, - 63, 255, 217]) - - export default {testPng, testJpg} \ No newline at end of file +/* + * Copyright (C) 2022 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. + */ +let testJpg = new Uint8Array([255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1, 1, 0, 96, 0, 96, 0, 0, 255, + 219, 0, 67, 0, 2, 1, 1, 2, 1, 1, 2, + 2, 2, 2, 2, 2, 2, 2, 3, 5, 3, 3, 3, 3, 3, 6, 4, 4, 3, 5, 7, 6, 7, 7, 7, 6, 7, 7, 8, 9, 11, 9, 8, + 8, 10, 8, 7, 7, 10, 13, 10, 10, 11, 12, 12, 12, 12, 7, 9, 14, 15, 13, 12, 14, 11, 12, 12, 12, 255, 219, 0, 67, 1, 2, 2, + 2, 3, 3, 3, 6, 3, 3, 6, 12, 8, 7, 8, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 255, 192, + 0, 17, 8, 0, 226, 1, 216, 3, 1, 34, 0, 2, 17, 1, 3, 17, 1, 255, 196, 0, 31, 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 255, 196, 0, 181, 16, 0, 2, 1, 3, 3, 2, 4, 3, 5, + 5, 4, 4, 0, 0, 1, 125, 1, 2, 3, 0, 4, 17, 5, 18, 33, 49, 65, 6, 19, 81, 97, 7, 34, 113, 20, 50, 129, 145, 161, 8, 35, + 66, 177, 193, 21, 82, 209, 240, 36, 51, 98, 114, 130, 9, 10, 22, 23, 24, 25, 26, 37, 38, 39, 40, 41, 42, 52, 53, 54, 55, 56, 57, 58, + 67, 68, 69, 70, 71, 72, 73, 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, + 131, 132, 133, 134, 135, 136, 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, + 184, 185, 186, 194, 195, 196, 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 241, + 242, 243, 244, 245, 246, 247, 248, 249, 250, 255, 196, 0, 31, 1, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 255, 196, 0, 181, 17, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119, 0, + 1, 2, 3, 17, 4, 5, 33, 49, 6, 18, 65, 81, 7, 97, 113, 19, 34, 50, 129, 8, 20, 66, 145, 161, 177, 193, 9, 35, 51, 82, 240, 21, + 98, 114, 209, 10, 22, 36, 52, 225, 37, 241, 23, 24, 25, 26, 38, 39, 40, 41, 42, 53, 54, 55, 56, 57, 58, 67, 68, 69, 70, 71, 72, 73, + 74, 83, 84, 85, 86, 87, 88, 89, 90, 99, 100, 101, 102, 103, 104, 105, 106, 115, 116, 117, 118, 119, 120, 121, 122, 130, 131, 132, 133, 134, 135, 136, + 137, 138, 146, 147, 148, 149, 150, 151, 152, 153, 154, 162, 163, 164, 165, 166, 167, 168, 169, 170, 178, 179, 180, 181, 182, 183, 184, 185, 186, 194, 195, 196, + 197, 198, 199, 200, 201, 202, 210, 211, 212, 213, 214, 215, 216, 217, 218, 226, 227, 228, 229, 230, 231, 232, 233, 234, 242, 243, 244, 245, 246, 247, 248, 249, + 250, 255, 218, 0, 12, 3, 1, 0, 2, 17, 3, 17, 0, 63, 0, 253, 16, 162, 138, 43, 252, 99, 63, 170, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, + 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 2, 138, 40, 160, 15, 255, 217]) +let testPng = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 100, 0, 0, 0, 100, 8, 6, 0, 0, 0, 112, 226, 149, + 84, 0, 0, 32, 0, 73, 68, 65, 84, 120, 1, 212, 193, 123, 176, 231, 247, 93, 223, 247, 231, 251, 253, 249, 254, 126, 231, 156, 61, 123, 191, 105, + 37, 173, 180, 186, 95, 173, 187, 228, 43, 166, 182, 133, 109, 44, 108, 160, 6, 154, 105, 157, 116, 104, 50, 64, 72, 155, 41, 195, 64, 167, 13, 80, + 218, 73, 166, 76, 254, 104, 254, 104, 167, 51, 253, 39, 51, 45, 52, 77, 161, 36, 29, 19, 2, 24, 98, 140, 28, 91, 24, 91, 150, 44, 164, 213, + 93, 187, 146, 86, 123, 95, 237, 253, 156, 243, 251, 253, 190, 223, 247, 235, 213, 253, 237, 34, 220, 106, 86, 182, 105, 160, 99, 30, 143, 224, 175, 177, + 31, 251, 145, 31, 102, 101, 109, 133, 133, 241, 194, 174, 42, 253, 224, 108, 54, 123, 100, 24, 250, 235, 135, 161, 178, 239, 251, 67, 17, 241, 149, 42, + 253, 238, 100, 50, 121, 178, 117, 76, 207, 31, 221, 194, 243, 7, 30, 229, 187, 89, 240, 215, 212, 15, 253, 208, 167, 24, 47, 108, 98, 186, 118, 242, + 253, 165, 250, 135, 150, 62, 176, 178, 178, 186, 208, 247, 61, 146, 232, 103, 61, 173, 235, 4, 62, 106, 243, 175, 165, 250, 159, 108, 61, 149, 153, 126, + 252, 235, 79, 241, 221, 42, 248, 107, 232, 83, 159, 252, 126, 90, 27, 1, 250, 158, 217, 172, 255, 167, 171, 107, 43, 183, 204, 102, 61, 179, 233, 140, + 201, 100, 66, 149, 176, 4, 1, 173, 53, 70, 163, 17, 173, 181, 87, 128, 255, 102, 54, 27, 254, 143, 214, 114, 248, 198, 83, 79, 243, 221, 168, 241, + 215, 208, 237, 183, 221, 66, 102, 94, 93, 195, 240, 63, 207, 102, 211, 251, 214, 86, 39, 172, 156, 91, 101, 101, 117, 194, 249, 149, 53, 250, 97, 96, + 50, 157, 113, 254, 252, 10, 67, 153, 201, 116, 74, 149, 182, 70, 196, 71, 50, 242, 108, 102, 62, 177, 107, 231, 14, 31, 57, 122, 140, 239, 54, 141, + 191, 160, 237, 91, 55, 51, 30, 141, 216, 182, 109, 235, 120, 211, 198, 13, 235, 150, 214, 45, 141, 186, 46, 180, 113, 227, 6, 175, 174, 174, 241, 87, + 237, 83, 159, 122, 132, 79, 127, 252, 251, 121, 97, 223, 190, 191, 63, 235, 251, 31, 95, 91, 155, 196, 233, 211, 167, 89, 93, 153, 176, 54, 153, 48, + 212, 192, 80, 66, 18, 85, 98, 54, 155, 49, 157, 78, 137, 8, 76, 44, 142, 70, 221, 123, 35, 120, 153, 244, 179, 87, 238, 216, 195, 145, 99, 135, + 248, 110, 210, 241, 29, 186, 239, 190, 123, 233, 103, 253, 226, 120, 220, 30, 176, 253, 48, 196, 93, 147, 201, 100, 199, 80, 53, 93, 92, 92, 124, 117, + 109, 109, 237, 209, 141, 27, 55, 254, 193, 245, 215, 95, 127, 124, 239, 222, 189, 12, 195, 192, 95, 133, 8, 248, 151, 127, 240, 185, 235, 134, 161, 255, + 143, 38, 147, 181, 56, 123, 246, 12, 179, 217, 140, 201, 108, 74, 169, 232, 135, 129, 140, 4, 155, 204, 100, 174, 170, 88, 93, 93, 69, 18, 227, 81, + 183, 117, 97, 60, 254, 197, 136, 120, 146, 54, 125, 133, 239, 50, 29, 223, 198, 189, 247, 220, 197, 179, 207, 189, 196, 226, 194, 232, 254, 229, 117, 139, + 63, 11, 60, 50, 244, 195, 150, 217, 48, 208, 186, 14, 19, 100, 22, 227, 241, 194, 143, 75, 254, 234, 139, 47, 190, 248, 143, 134, 97, 248, 131, 204, + 212, 5, 252, 101, 75, 155, 176, 63, 58, 153, 206, 110, 155, 76, 166, 172, 172, 174, 49, 153, 206, 24, 134, 1, 99, 144, 113, 136, 204, 196, 54, 153, + 201, 92, 85, 49, 157, 78, 89, 89, 93, 163, 181, 188, 167, 139, 246, 31, 63, 249, 141, 39, 126, 249, 129, 251, 31, 224, 137, 39, 159, 230, 187, 69, + 242, 45, 188, 255, 125, 239, 37, 91, 151, 239, 125, 207, 253, 63, 178, 180, 180, 244, 235, 227, 209, 232, 51, 150, 183, 204, 102, 51, 214, 214, 86, 89, + 91, 155, 176, 178, 178, 198, 116, 58, 163, 239, 135, 113, 149, 190, 39, 34, 254, 151, 174, 235, 62, 35, 41, 248, 75, 246, 233, 79, 125, 146, 197, 241, + 186, 5, 75, 223, 95, 67, 181, 233, 116, 202, 116, 50, 101, 24, 6, 108, 97, 153, 214, 26, 17, 193, 91, 108, 51, 215, 90, 35, 34, 152, 205, 102, + 72, 34, 51, 31, 121, 224, 254, 7, 183, 65, 240, 221, 164, 227, 29, 124, 240, 131, 239, 103, 113, 221, 152, 209, 180, 251, 248, 226, 120, 252, 63, 88, + 190, 106, 101, 117, 149, 181, 181, 53, 86, 86, 87, 153, 245, 51, 250, 190, 152, 78, 103, 72, 98, 24, 6, 134, 97, 32, 34, 118, 117, 93, 247, 43, + 85, 117, 40, 51, 63, 95, 85, 252, 165, 137, 160, 52, 236, 138, 200, 123, 38, 211, 9, 125, 223, 51, 87, 85, 64, 144, 25, 204, 69, 4, 146, 200, + 76, 230, 36, 49, 55, 12, 3, 17, 48, 12, 3, 195, 208, 174, 109, 173, 93, 11, 188, 201, 119, 145, 142, 119, 176, 184, 48, 198, 131, 239, 88, 183, + 184, 244, 143, 9, 174, 90, 89, 91, 97, 50, 153, 178, 58, 153, 50, 157, 245, 204, 102, 61, 85, 98, 78, 18, 195, 48, 48, 23, 17, 116, 93, 119, + 181, 164, 95, 152, 205, 102, 79, 3, 199, 184, 140, 255, 226, 231, 126, 158, 151, 95, 126, 153, 135, 191, 239, 225, 118, 195, 13, 215, 143, 55, 109, 222, + 180, 28, 17, 203, 4, 75, 24, 108, 97, 27, 75, 171, 42, 77, 215, 38, 107, 43, 215, 93, 119, 195, 228, 23, 254, 193, 127, 185, 222, 25, 155, 185, + 96, 54, 155, 209, 15, 3, 85, 34, 51, 177, 185, 40, 34, 152, 179, 205, 219, 169, 68, 63, 155, 49, 30, 143, 151, 34, 189, 17, 155, 239, 38, 29, + 151, 241, 177, 143, 62, 76, 223, 15, 227, 117, 235, 22, 255, 243, 209, 168, 187, 107, 229, 252, 10, 125, 223, 51, 157, 245, 12, 67, 49, 157, 245, 244, + 179, 30, 219, 204, 101, 38, 173, 53, 102, 179, 25, 17, 65, 215, 117, 116, 93, 247, 189, 125, 223, 255, 141, 241, 120, 252, 63, 78, 167, 83, 126, 255, + 115, 191, 203, 71, 63, 246, 253, 60, 250, 232, 23, 214, 173, 91, 183, 124, 205, 194, 120, 124, 71, 55, 234, 238, 24, 141, 186, 155, 33, 174, 109, 45, + 183, 69, 198, 186, 140, 88, 144, 205, 156, 36, 106, 24, 214, 84, 53, 147, 106, 165, 239, 215, 142, 255, 237, 191, 243, 183, 103, 191, 246, 107, 255, 219, + 50, 113, 2, 8, 44, 19, 209, 184, 28, 219, 188, 197, 54, 195, 48, 48, 26, 141, 48, 38, 34, 107, 227, 198, 205, 62, 124, 248, 48, 255, 221, 63, + 250, 21, 254, 193, 47, 254, 87, 124, 55, 232, 120, 155, 77, 159, 249, 40, 221, 73, 104, 109, 116, 111, 215, 181, 31, 150, 204, 116, 54, 99, 58, 157, + 49, 155, 205, 152, 205, 102, 212, 48, 80, 85, 100, 38, 85, 69, 85, 49, 215, 90, 35, 51, 145, 68, 187, 228, 111, 76, 167, 211, 127, 246, 244, 51, + 79, 158, 95, 89, 89, 187, 243, 217, 103, 159, 126, 248, 154, 107, 118, 127, 100, 52, 30, 223, 213, 117, 221, 14, 240, 66, 107, 13, 73, 16, 96, 155, + 0, 100, 19, 128, 36, 172, 17, 86, 97, 25, 89, 220, 112, 195, 117, 220, 121, 231, 237, 28, 56, 112, 128, 204, 36, 91, 226, 161, 199, 134, 136, 96, + 46, 34, 136, 8, 36, 17, 17, 100, 38, 146, 200, 76, 50, 131, 42, 113, 197, 21, 59, 151, 127, 241, 151, 126, 241, 31, 110, 221, 182, 245, 137, 243, + 231, 206, 125, 227, 87, 255, 215, 127, 122, 240, 153, 167, 159, 62, 182, 119, 239, 222, 67, 207, 61, 255, 210, 217, 67, 135, 143, 206, 214, 173, 91, 226, + 228, 201, 147, 252, 255, 169, 227, 109, 62, 112, 2, 214, 111, 88, 100, 50, 233, 63, 156, 25, 59, 167, 211, 158, 97, 24, 24, 134, 1, 169, 24, 106, + 192, 54, 17, 129, 109, 170, 10, 73, 216, 166, 181, 70, 102, 98, 67, 102, 50, 26, 141, 238, 254, 91, 127, 235, 51, 127, 127, 58, 153, 221, 186, 121, + 243, 166, 143, 108, 216, 176, 113, 231, 120, 52, 138, 11, 32, 192, 54, 24, 162, 5, 146, 136, 72, 230, 194, 5, 1, 68, 16, 145, 68, 66, 89, 96, + 179, 176, 176, 192, 35, 143, 124, 130, 190, 239, 249, 220, 231, 254, 128, 51, 103, 206, 48, 244, 61, 217, 26, 93, 215, 17, 17, 216, 102, 46, 34, 152, + 155, 205, 102, 84, 21, 17, 1, 4, 216, 220, 127, 255, 125, 163, 235, 174, 223, 243, 189, 182, 190, 119, 221, 226, 130, 55, 172, 95, 158, 94, 123, 237, + 53, 167, 239, 190, 231, 174, 35, 251, 247, 237, 123, 229, 200, 161, 67, 207, 156, 59, 119, 246, 107, 131, 227, 233, 126, 82, 135, 178, 197, 240, 235, 191, + 249, 47, 249, 171, 214, 120, 155, 219, 111, 185, 153, 67, 175, 29, 203, 205, 91, 55, 252, 116, 73, 119, 77, 38, 83, 38, 147, 9, 147, 201, 132, 201, + 108, 74, 85, 81, 37, 170, 138, 97, 24, 136, 8, 50, 147, 185, 136, 192, 54, 182, 129, 196, 214, 194, 35, 143, 124, 226, 131, 119, 222, 121, 199, 221, + 235, 214, 173, 91, 191, 110, 105, 41, 50, 27, 115, 153, 73, 70, 227, 146, 32, 35, 9, 130, 224, 146, 8, 200, 76, 8, 192, 129, 205, 69, 182, 88, + 183, 110, 29, 119, 220, 113, 7, 119, 221, 117, 23, 235, 215, 47, 115, 228, 240, 97, 222, 60, 121, 18, 201, 64, 48, 103, 27, 73, 84, 21, 146, 176, + 77, 102, 178, 48, 30, 179, 107, 215, 21, 252, 196, 79, 254, 36, 187, 174, 184, 2, 213, 64, 215, 90, 100, 102, 183, 254, 130, 43, 175, 188, 114, 215, + 158, 61, 187, 239, 216, 182, 125, 219, 135, 218, 104, 244, 239, 163, 250, 161, 104, 220, 23, 65, 222, 114, 203, 205, 39, 206, 157, 247, 234, 67, 15, 220, + 195, 254, 253, 251, 249, 171, 208, 120, 155, 219, 110, 185, 153, 174, 235, 218, 120, 113, 244, 119, 74, 190, 233, 252, 202, 10, 147, 201, 148, 201, 116, 194, + 116, 58, 101, 58, 235, 25, 250, 1, 73, 84, 21, 182, 153, 147, 132, 109, 34, 130, 204, 96, 46, 51, 248, 208, 135, 62, 148, 55, 223, 124, 51, 219, + 182, 109, 103, 52, 26, 17, 17, 68, 64, 102, 99, 46, 34, 200, 76, 34, 32, 51, 177, 77, 107, 13, 99, 36, 147, 145, 32, 99, 204, 92, 4, 23, + 101, 6, 59, 118, 236, 224, 190, 251, 238, 225, 193, 119, 63, 200, 116, 54, 227, 229, 151, 94, 102, 50, 153, 50, 30, 143, 176, 77, 85, 81, 85, 84, + 21, 153, 73, 215, 53, 150, 151, 215, 241, 31, 252, 216, 143, 242, 177, 143, 125, 148, 57, 169, 192, 198, 54, 17, 129, 44, 70, 227, 17, 59, 118, 238, + 224, 154, 107, 174, 25, 109, 221, 190, 117, 219, 116, 50, 185, 119, 229, 252, 202, 15, 73, 254, 200, 85, 87, 109, 95, 159, 45, 14, 62, 255, 252, 139, + 103, 127, 247, 243, 191, 207, 193, 215, 223, 224, 47, 83, 227, 109, 110, 186, 233, 6, 206, 158, 95, 99, 105, 221, 248, 135, 250, 26, 238, 152, 78, 167, + 172, 173, 173, 49, 157, 205, 232, 251, 129, 201, 100, 74, 13, 133, 109, 108, 83, 85, 204, 117, 221, 136, 136, 96, 110, 54, 155, 97, 155, 135, 30, 122, + 128, 31, 251, 177, 31, 229, 166, 155, 110, 98, 97, 97, 76, 102, 35, 51, 201, 76, 32, 120, 75, 102, 146, 25, 204, 101, 6, 178, 201, 76, 46, 49, + 17, 1, 17, 68, 4, 17, 129, 109, 36, 33, 21, 17, 176, 109, 251, 22, 222, 253, 238, 7, 185, 118, 247, 110, 94, 124, 241, 69, 78, 157, 58, 141, + 109, 50, 19, 12, 17, 65, 215, 53, 70, 163, 17, 215, 93, 183, 135, 159, 248, 201, 159, 96, 231, 206, 157, 72, 133, 106, 160, 170, 176, 141, 109, 140, + 177, 133, 100, 108, 179, 101, 235, 22, 246, 92, 183, 135, 133, 165, 133, 238, 244, 169, 83, 187, 39, 147, 181, 143, 102, 196, 71, 126, 253, 127, 255, 103, + 53, 38, 247, 221, 117, 231, 237, 147, 231, 94, 124, 137, 191, 44, 141, 183, 185, 241, 198, 235, 89, 191, 97, 209, 67, 213, 13, 195, 48, 124, 223, 100, + 50, 101, 232, 7, 166, 179, 25, 211, 217, 12, 201, 88, 38, 51, 105, 173, 33, 137, 136, 96, 52, 26, 33, 153, 190, 239, 217, 180, 105, 19, 63, 250, + 163, 159, 230, 231, 126, 238, 103, 185, 251, 238, 187, 89, 88, 24, 3, 65, 4, 23, 101, 38, 17, 129, 109, 34, 130, 8, 200, 108, 92, 18, 68, 4, + 16, 16, 92, 18, 16, 17, 68, 38, 193, 5, 22, 223, 148, 168, 68, 215, 37, 183, 220, 122, 51, 119, 220, 126, 27, 123, 247, 62, 203, 177, 99, 199, + 200, 72, 90, 235, 232, 90, 99, 52, 234, 88, 90, 28, 211, 247, 61, 207, 61, 247, 28, 235, 55, 172, 103, 215, 174, 157, 180, 214, 144, 196, 156, 36, + 164, 66, 22, 82, 17, 128, 109, 90, 107, 236, 220, 185, 157, 171, 174, 186, 138, 243, 231, 207, 230, 233, 211, 167, 174, 12, 226, 227, 209, 229, 157, 147, + 89, 191, 111, 251, 142, 157, 135, 111, 191, 237, 86, 246, 237, 219, 207, 191, 171, 198, 219, 188, 252, 202, 62, 174, 191, 238, 58, 192, 107, 54, 159, 236, + 251, 217, 198, 217, 108, 198, 80, 133, 36, 230, 84, 98, 206, 54, 153, 73, 102, 50, 153, 76, 168, 42, 62, 240, 129, 247, 243, 203, 191, 252, 75, 252, + 248, 143, 255, 56, 187, 119, 95, 67, 102, 0, 65, 107, 73, 102, 35, 34, 152, 203, 12, 50, 147, 204, 4, 76, 68, 2, 6, 2, 219, 68, 4, 17, + 96, 155, 57, 27, 108, 17, 4, 145, 129, 101, 8, 136, 224, 34, 203, 216, 102, 215, 174, 157, 220, 118, 199, 109, 28, 56, 112, 128, 55, 79, 158, 100, + 212, 37, 59, 118, 108, 227, 193, 135, 238, 103, 195, 134, 245, 156, 58, 117, 134, 55, 222, 56, 200, 151, 191, 252, 37, 206, 157, 59, 207, 205, 183, 220, + 194, 242, 242, 50, 150, 152, 179, 5, 97, 36, 3, 193, 220, 48, 244, 68, 152, 165, 229, 101, 174, 187, 126, 15, 37, 113, 232, 240, 209, 110, 24, 234, + 182, 136, 252, 216, 104, 212, 206, 175, 77, 39, 207, 222, 120, 227, 245, 195, 171, 251, 95, 227, 223, 69, 227, 50, 174, 191, 238, 90, 52, 232, 168, 131, + 205, 217, 242, 123, 134, 126, 136, 42, 49, 155, 206, 232, 135, 162, 159, 13, 204, 101, 38, 146, 153, 78, 39, 44, 175, 95, 230, 239, 254, 244, 79, 241, + 75, 191, 244, 11, 220, 123, 223, 189, 116, 221, 136, 136, 32, 51, 128, 36, 179, 49, 23, 17, 100, 38, 54, 68, 4, 151, 4, 223, 20, 68, 4, 23, + 5, 216, 38, 34, 137, 224, 162, 0, 36, 1, 6, 2, 219, 72, 194, 6, 35, 170, 6, 182, 111, 223, 202, 189, 247, 222, 195, 174, 93, 59, 185, 250, + 170, 43, 121, 224, 129, 123, 185, 247, 190, 187, 216, 115, 221, 53, 28, 120, 253, 0, 231, 206, 157, 103, 214, 207, 120, 234, 169, 63, 101, 255, 171, 175, + 114, 251, 109, 183, 178, 188, 188, 76, 213, 128, 109, 36, 17, 201, 69, 85, 69, 85, 1, 102, 168, 129, 214, 117, 92, 117, 213, 46, 22, 23, 23, 56, + 240, 218, 27, 244, 125, 191, 57, 91, 126, 95, 215, 229, 122, 13, 122, 252, 198, 27, 175, 155, 236, 219, 255, 26, 255, 95, 53, 46, 99, 223, 254, 215, + 216, 189, 231, 106, 151, 244, 188, 237, 123, 250, 126, 184, 81, 85, 24, 51, 244, 3, 17, 65, 107, 141, 214, 26, 125, 223, 179, 105, 211, 70, 254, 235, + 95, 250, 69, 126, 234, 167, 126, 130, 141, 27, 54, 98, 65, 68, 16, 193, 5, 65, 102, 71, 68, 2, 65, 68, 146, 217, 128, 32, 34, 137, 72, 90, + 235, 136, 8, 230, 34, 2, 219, 204, 5, 193, 156, 13, 216, 4, 193, 156, 13, 118, 96, 23, 150, 33, 184, 32, 48, 34, 2, 108, 179, 97, 253, 50, + 183, 220, 114, 51, 123, 246, 92, 67, 235, 26, 163, 81, 199, 246, 237, 219, 216, 178, 121, 51, 47, 60, 255, 34, 253, 48, 96, 155, 125, 175, 236, 231, + 165, 23, 95, 226, 214, 91, 111, 101, 243, 150, 77, 88, 96, 27, 169, 144, 10, 187, 176, 141, 109, 176, 177, 12, 152, 93, 187, 174, 96, 113, 105, 145, + 87, 247, 191, 74, 223, 207, 70, 153, 249, 158, 204, 184, 186, 134, 225, 177, 155, 111, 190, 126, 101, 180, 48, 226, 196, 137, 147, 252, 69, 53, 222, 193, + 85, 187, 175, 68, 131, 206, 75, 250, 211, 174, 181, 251, 193, 87, 151, 69, 16, 64, 96, 155, 217, 108, 198, 194, 194, 152, 159, 255, 249, 159, 227, 111, + 254, 205, 207, 48, 26, 143, 136, 8, 34, 130, 136, 32, 51, 137, 8, 50, 27, 17, 65, 68, 144, 153, 68, 4, 153, 73, 102, 18, 17, 204, 69, 152, + 136, 224, 45, 17, 65, 68, 96, 131, 45, 140, 177, 141, 101, 100, 17, 17, 128, 145, 69, 68, 32, 9, 171, 176, 141, 109, 108, 99, 139, 165, 165, 37, + 54, 108, 88, 79, 102, 208, 90, 227, 202, 171, 174, 224, 220, 249, 243, 188, 254, 218, 27, 68, 36, 115, 7, 15, 30, 228, 197, 23, 95, 226, 206, 119, + 189, 139, 205, 155, 55, 33, 9, 91, 84, 21, 17, 193, 91, 36, 35, 21, 115, 182, 216, 177, 99, 59, 75, 75, 75, 188, 252, 242, 126, 250, 126, 200, + 150, 121, 87, 100, 187, 106, 58, 12, 95, 218, 184, 97, 227, 234, 171, 251, 95, 227, 47, 170, 241, 14, 222, 56, 112, 144, 173, 155, 183, 48, 30, 181, + 163, 150, 190, 38, 124, 147, 97, 79, 215, 186, 28, 134, 129, 217, 108, 198, 250, 245, 235, 249, 217, 159, 253, 25, 62, 243, 153, 255, 144, 209, 104, 4, + 17, 180, 76, 50, 147, 204, 36, 34, 200, 12, 32, 153, 203, 76, 34, 130, 136, 32, 51, 137, 8, 222, 98, 155, 75, 204, 156, 109, 108, 115, 73, 96, + 155, 136, 192, 54, 115, 17, 96, 27, 8, 230, 108, 48, 38, 194, 72, 102, 24, 10, 48, 96, 90, 107, 44, 45, 45, 50, 30, 143, 24, 47, 140, 217, + 190, 109, 59, 207, 62, 251, 60, 103, 207, 157, 7, 76, 68, 114, 232, 208, 97, 14, 29, 60, 200, 61, 247, 220, 205, 242, 242, 50, 182, 136, 48, 182, + 168, 26, 176, 141, 109, 36, 17, 17, 216, 98, 110, 231, 206, 157, 200, 197, 171, 251, 95, 165, 74, 145, 173, 189, 43, 35, 54, 206, 166, 179, 71, 175, + 191, 110, 207, 236, 181, 215, 14, 240, 23, 209, 248, 22, 142, 30, 59, 198, 198, 13, 203, 196, 168, 29, 173, 97, 248, 125, 219, 71, 183, 108, 218, 116, + 237, 21, 59, 119, 236, 184, 249, 230, 155, 248, 233, 191, 247, 119, 249, 244, 143, 124, 154, 241, 194, 136, 204, 32, 72, 34, 130, 204, 36, 34, 136, 8, + 50, 147, 204, 36, 34, 137, 8, 34, 130, 204, 36, 34, 176, 77, 68, 96, 27, 155, 11, 2, 169, 0, 19, 145, 128, 177, 185, 36, 192, 64, 96, 34, + 130, 32, 144, 10, 108, 100, 35, 21, 198, 204, 73, 5, 24, 16, 54, 23, 24, 48, 182, 176, 204, 250, 245, 203, 156, 61, 115, 150, 23, 94, 120, 9, + 99, 48, 100, 118, 28, 56, 112, 144, 147, 39, 79, 241, 192, 253, 247, 50, 26, 53, 108, 83, 85, 216, 2, 2, 73, 100, 114, 145, 36, 108, 176, 205, + 206, 157, 59, 56, 117, 242, 36, 135, 14, 29, 37, 35, 35, 91, 222, 29, 48, 153, 76, 214, 30, 187, 238, 186, 61, 126, 253, 192, 27, 124, 167, 26, + 223, 198, 241, 19, 39, 57, 124, 232, 40, 191, 250, 107, 191, 186, 242, 145, 143, 124, 100, 239, 39, 63, 249, 3, 31, 249, 129, 71, 30, 185, 229, 147, + 159, 250, 36, 119, 190, 235, 93, 100, 75, 178, 53, 130, 32, 35, 200, 76, 230, 34, 160, 181, 198, 92, 102, 146, 153, 180, 214, 176, 77, 68, 48, 23, + 17, 204, 73, 34, 34, 184, 196, 68, 128, 109, 222, 34, 21, 127, 78, 198, 128, 45, 100, 97, 132, 108, 2, 144, 4, 8, 201, 128, 1, 99, 131, 84, + 72, 66, 18, 17, 73, 68, 176, 113, 211, 70, 158, 123, 246, 121, 206, 159, 95, 37, 162, 17, 17, 24, 216, 191, 111, 63, 227, 209, 136, 119, 189, 235, + 14, 108, 99, 11, 219, 204, 217, 194, 54, 182, 128, 192, 22, 96, 50, 147, 29, 59, 182, 179, 111, 223, 126, 206, 157, 59, 79, 16, 173, 107, 237, 222, + 214, 186, 231, 118, 108, 223, 250, 194, 166, 205, 155, 121, 227, 141, 131, 124, 39, 146, 239, 208, 149, 87, 94, 193, 246, 237, 91, 127, 96, 215, 174, 157, + 31, 222, 185, 115, 7, 203, 203, 235, 80, 21, 216, 96, 46, 138, 72, 164, 194, 54, 115, 182, 153, 139, 72, 34, 130, 203, 145, 68, 102, 146, 153, 128, + 153, 139, 8, 254, 159, 108, 176, 13, 54, 68, 32, 9, 73, 24, 227, 8, 8, 254, 156, 36, 34, 130, 136, 196, 54, 182, 0, 19, 1, 17, 9, 24, + 73, 92, 113, 197, 14, 238, 124, 215, 237, 100, 54, 90, 107, 216, 38, 35, 176, 204, 111, 252, 250, 191, 224, 241, 175, 61, 65, 132, 145, 140, 36, 36, + 1, 129, 109, 108, 83, 85, 216, 198, 54, 132, 216, 177, 115, 27, 239, 123, 223, 131, 216, 102, 24, 122, 100, 109, 203, 204, 255, 246, 232, 241, 55, 111, + 24, 143, 70, 124, 167, 26, 223, 129, 47, 252, 225, 239, 115, 246, 244, 233, 77, 155, 55, 111, 254, 149, 165, 165, 117, 183, 102, 36, 68, 210, 90, 66, + 4, 217, 146, 140, 196, 230, 162, 214, 146, 136, 192, 134, 204, 36, 34, 176, 33, 34, 136, 8, 50, 147, 214, 26, 182, 249, 127, 51, 118, 17, 145, 216, + 6, 204, 156, 36, 108, 17, 128, 36, 28, 38, 8, 176, 40, 21, 24, 44, 35, 21, 145, 96, 11, 169, 144, 138, 57, 219, 84, 21, 182, 144, 140, 100, + 2, 51, 234, 70, 60, 245, 141, 167, 233, 251, 129, 42, 97, 27, 34, 56, 191, 178, 202, 225, 35, 135, 121, 240, 161, 7, 88, 94, 183, 12, 24, 169, + 176, 69, 4, 84, 137, 170, 1, 219, 72, 2, 11, 89, 108, 218, 188, 145, 67, 7, 143, 112, 236, 232, 9, 32, 232, 186, 182, 43, 35, 125, 246, 236, + 217, 63, 188, 238, 218, 107, 244, 198, 193, 67, 124, 59, 141, 111, 227, 119, 126, 251, 179, 108, 218, 180, 145, 174, 235, 62, 182, 126, 253, 250, 159, 233, + 90, 55, 142, 76, 8, 46, 138, 8, 34, 147, 136, 4, 67, 215, 117, 68, 4, 16, 180, 214, 0, 19, 209, 200, 76, 34, 130, 185, 136, 192, 54, 115, + 182, 121, 139, 109, 108, 51, 103, 27, 73, 204, 217, 134, 0, 89, 4, 1, 6, 169, 48, 198, 50, 82, 17, 128, 45, 108, 99, 27, 73, 128, 145, 140, + 36, 108, 99, 11, 219, 204, 73, 197, 186, 165, 37, 94, 122, 121, 31, 39, 142, 191, 73, 73, 188, 37, 51, 56, 116, 232, 48, 155, 54, 109, 228, 206, + 59, 111, 71, 18, 182, 144, 4, 4, 96, 230, 108, 99, 155, 108, 129, 84, 140, 186, 17, 93, 55, 226, 249, 231, 95, 64, 50, 153, 73, 102, 222, 212, + 186, 246, 39, 227, 241, 248, 213, 173, 219, 182, 112, 248, 240, 81, 190, 149, 228, 219, 24, 141, 70, 124, 245, 79, 30, 111, 11, 11, 11, 63, 220, 186, + 92, 150, 141, 100, 34, 146, 204, 4, 2, 149, 80, 21, 17, 96, 27, 219, 68, 112, 129, 137, 72, 108, 97, 27, 73, 204, 217, 70, 18, 182, 105, 173, + 49, 103, 155, 185, 204, 64, 18, 96, 50, 147, 185, 214, 26, 173, 37, 115, 146, 192, 64, 4, 24, 146, 32, 34, 33, 76, 68, 128, 3, 27, 34, 130, + 136, 0, 140, 13, 17, 193, 55, 153, 185, 165, 165, 69, 110, 187, 245, 102, 50, 147, 204, 68, 18, 96, 108, 3, 201, 231, 126, 239, 243, 28, 58, 120, + 24, 48, 182, 153, 147, 10, 219, 68, 4, 111, 145, 140, 13, 170, 226, 198, 27, 246, 176, 123, 247, 213, 244, 179, 25, 179, 217, 20, 169, 182, 183, 214, + 254, 211, 217, 172, 95, 94, 90, 90, 226, 219, 73, 190, 141, 108, 112, 219, 237, 55, 95, 51, 234, 186, 15, 102, 36, 17, 144, 105, 112, 97, 27, 91, + 24, 51, 103, 155, 8, 136, 0, 27, 36, 3, 198, 22, 118, 97, 23, 146, 176, 141, 36, 108, 83, 85, 84, 21, 85, 3, 32, 108, 176, 141, 109, 108, + 19, 1, 146, 80, 153, 57, 89, 148, 197, 69, 6, 99, 176, 145, 140, 109, 34, 32, 2, 108, 115, 73, 16, 17, 216, 38, 34, 176, 141, 84, 128, 32, + 204, 77, 55, 94, 199, 104, 220, 97, 23, 173, 5, 17, 92, 96, 198, 227, 17, 111, 28, 56, 200, 23, 190, 240, 40, 96, 36, 243, 150, 170, 162, 74, + 24, 99, 138, 26, 122, 40, 225, 18, 227, 81, 227, 93, 119, 220, 138, 129, 26, 196, 48, 12, 4, 254, 104, 102, 124, 111, 215, 26, 223, 78, 242, 109, + 44, 45, 45, 49, 30, 47, 220, 215, 186, 182, 199, 54, 182, 144, 132, 44, 170, 6, 108, 131, 65, 18, 85, 66, 50, 16, 188, 165, 74, 84, 21, 85, + 133, 109, 164, 162, 170, 136, 224, 2, 35, 21, 182, 200, 12, 192, 216, 102, 174, 74, 216, 66, 50, 85, 3, 165, 66, 50, 153, 137, 45, 84, 194, 54, + 182, 145, 4, 2, 99, 74, 133, 36, 230, 170, 4, 4, 17, 96, 27, 201, 216, 226, 45, 42, 177, 243, 138, 237, 92, 121, 229, 14, 50, 131, 136, 0, + 76, 102, 163, 181, 198, 220, 163, 143, 126, 137, 19, 39, 78, 146, 13, 36, 33, 137, 136, 192, 22, 150, 176, 5, 54, 17, 65, 112, 201, 245, 55, 92, + 203, 134, 245, 203, 76, 166, 19, 250, 126, 64, 210, 198, 204, 248, 204, 217, 243, 231, 199, 239, 126, 207, 3, 124, 43, 201, 183, 240, 220, 115, 207, 114, + 195, 13, 123, 232, 186, 238, 193, 136, 24, 219, 198, 54, 146, 176, 77, 68, 18, 17, 128, 201, 76, 50, 19, 91, 72, 162, 170, 152, 139, 128, 214, 146, + 136, 96, 206, 22, 32, 134, 161, 167, 170, 7, 132, 45, 164, 66, 50, 182, 137, 8, 50, 131, 136, 224, 146, 32, 34, 136, 0, 3, 153, 13, 2, 108, + 33, 137, 57, 99, 108, 99, 155, 57, 219, 216, 70, 18, 182, 153, 179, 69, 68, 48, 103, 153, 185, 229, 229, 37, 174, 185, 230, 106, 108, 211, 90, 3, + 130, 57, 73, 116, 221, 136, 3, 175, 31, 228, 79, 159, 122, 6, 219, 72, 162, 170, 168, 42, 170, 10, 219, 216, 252, 185, 136, 192, 18, 155, 55, 109, + 228, 202, 171, 175, 96, 24, 6, 134, 97, 96, 24, 138, 11, 30, 94, 88, 24, 223, 213, 90, 227, 91, 73, 190, 133, 87, 246, 189, 196, 231, 191, 240, + 229, 133, 209, 104, 116, 71, 102, 98, 155, 32, 136, 8, 144, 209, 48, 96, 153, 32, 176, 133, 93, 12, 53, 96, 139, 57, 73, 204, 217, 6, 140, 109, + 34, 2, 91, 72, 66, 18, 54, 68, 4, 182, 145, 10, 91, 72, 194, 6, 219, 216, 34, 18, 108, 99, 131, 101, 84, 3, 168, 176, 184, 32, 176, 193, + 22, 96, 230, 108, 144, 4, 24, 16, 146, 1, 51, 103, 27, 99, 108, 131, 69, 6, 92, 187, 251, 106, 70, 93, 135, 109, 90, 107, 204, 217, 6, 204, + 172, 31, 248, 202, 87, 191, 206, 172, 47, 36, 17, 17, 72, 34, 49, 137, 73, 192, 50, 150, 40, 137, 185, 214, 53, 174, 189, 230, 106, 230, 170, 68, + 213, 128, 228, 93, 45, 242, 145, 43, 175, 220, 193, 67, 15, 222, 207, 59, 73, 190, 5, 73, 44, 173, 91, 220, 16, 25, 187, 249, 51, 178, 176, 141, + 13, 198, 204, 73, 194, 54, 102, 206, 148, 6, 108, 35, 137, 97, 24, 24, 134, 162, 170, 144, 132, 84, 216, 96, 27, 201, 216, 194, 54, 146, 145, 140, + 100, 108, 35, 139, 170, 66, 18, 85, 3, 82, 97, 11, 108, 2, 19, 54, 145, 208, 50, 1, 99, 132, 109, 108, 3, 193, 156, 205, 159, 49, 54, 23, + 25, 3, 102, 78, 42, 84, 3, 187, 118, 237, 100, 121, 121, 153, 136, 32, 2, 50, 147, 136, 128, 8, 34, 147, 103, 159, 125, 158, 147, 39, 79, 49, + 103, 131, 109, 192, 96, 99, 137, 136, 192, 64, 4, 216, 66, 42, 118, 94, 177, 157, 174, 107, 12, 195, 192, 48, 20, 82, 113, 193, 199, 95, 127, 245, + 208, 102, 219, 188, 147, 228, 91, 24, 141, 58, 22, 198, 11, 75, 192, 14, 219, 216, 198, 50, 146, 176, 133, 109, 36, 97, 27, 12, 182, 49, 96, 115, + 129, 137, 8, 170, 132, 109, 36, 3, 198, 6, 169, 136, 8, 108, 51, 12, 133, 36, 164, 34, 2, 108, 35, 23, 118, 225, 48, 229, 226, 146, 192, 54, + 210, 192, 225, 195, 135, 120, 230, 153, 167, 121, 225, 133, 231, 57, 118, 252, 24, 114, 145, 17, 216, 66, 42, 108, 17, 1, 17, 32, 25, 73, 72, 133, + 109, 130, 96, 206, 24, 12, 178, 217, 188, 121, 35, 203, 203, 75, 64, 0, 65, 107, 141, 214, 26, 151, 152, 227, 199, 79, 240, 250, 107, 175, 147, 153, + 72, 194, 54, 16, 148, 132, 13, 182, 177, 4, 4, 82, 97, 196, 230, 45, 155, 88, 92, 92, 64, 85, 84, 13, 12, 195, 128, 237, 59, 51, 243, 142, + 204, 224, 157, 116, 124, 11, 163, 174, 195, 242, 250, 8, 22, 165, 129, 200, 14, 34, 176, 205, 156, 109, 170, 6, 130, 70, 89, 180, 174, 35, 72, 44, + 81, 12, 200, 34, 34, 176, 141, 109, 34, 184, 32, 201, 12, 170, 10, 201, 204, 101, 6, 146, 1, 35, 9, 219, 148, 138, 136, 196, 18, 24, 130, 11, + 100, 158, 254, 198, 55, 248, 173, 223, 254, 44, 71, 14, 31, 165, 4, 91, 54, 109, 230, 246, 59, 110, 229, 193, 135, 30, 228, 202, 171, 174, 36, 34, + 168, 42, 36, 81, 85, 128, 1, 243, 22, 169, 168, 42, 108, 99, 140, 37, 70, 227, 17, 155, 54, 111, 228, 240, 145, 227, 16, 102, 46, 34, 136, 8, + 34, 146, 26, 6, 246, 237, 123, 141, 123, 239, 126, 23, 184, 8, 11, 243, 103, 108, 50, 130, 146, 168, 42, 48, 80, 98, 121, 105, 137, 197, 165, 5, + 78, 159, 62, 75, 14, 73, 215, 4, 205, 155, 51, 121, 223, 194, 194, 226, 99, 239, 126, 232, 94, 190, 250, 181, 111, 240, 118, 29, 239, 224, 7, 30, + 249, 56, 88, 188, 242, 202, 43, 55, 222, 183, 241, 238, 245, 94, 24, 97, 11, 57, 104, 36, 146, 201, 228, 2, 33, 65, 107, 13, 11, 8, 99, 12, + 134, 48, 36, 137, 84, 68, 4, 32, 106, 16, 163, 241, 8, 2, 108, 17, 17, 92, 20, 70, 26, 144, 141, 109, 108, 3, 6, 131, 74, 204, 157, 124, + 243, 77, 126, 231, 119, 254, 53, 127, 250, 212, 94, 206, 157, 95, 101, 24, 6, 146, 198, 222, 103, 159, 227, 235, 143, 127, 157, 135, 31, 254, 48, 247, + 63, 120, 31, 163, 241, 2, 146, 177, 3, 91, 216, 102, 78, 18, 54, 216, 198, 18, 150, 49, 166, 181, 198, 120, 60, 38, 2, 186, 236, 152, 14, 61, + 115, 54, 100, 38, 195, 96, 94, 123, 245, 0, 53, 244, 128, 1, 19, 17, 72, 166, 170, 104, 173, 97, 46, 176, 177, 141, 92, 68, 4, 75, 139, 11, + 84, 137, 42, 161, 18, 170, 66, 248, 125, 199, 79, 188, 185, 48, 234, 186, 41, 151, 209, 241, 14, 178, 5, 63, 253, 247, 254, 179, 117, 63, 242, 233, + 31, 254, 79, 238, 190, 231, 206, 101, 73, 100, 38, 216, 24, 131, 133, 20, 68, 4, 151, 4, 32, 108, 209, 90, 67, 18, 9, 84, 152, 32, 56, 115, + 234, 20, 79, 61, 249, 4, 47, 189, 242, 10, 235, 214, 45, 243, 61, 223, 243, 65, 246, 236, 185, 14, 147, 12, 85, 204, 25, 99, 137, 57, 219, 148, + 6, 194, 32, 137, 140, 224, 141, 131, 7, 121, 225, 165, 87, 56, 125, 230, 28, 147, 217, 12, 167, 32, 130, 213, 179, 107, 156, 223, 187, 194, 177, 227, + 39, 56, 118, 252, 56, 15, 127, 223, 135, 25, 47, 44, 0, 198, 54, 146, 169, 42, 36, 97, 11, 217, 4, 96, 46, 48, 100, 4, 11, 139, 11, 4, + 1, 152, 214, 26, 195, 48, 144, 25, 64, 80, 85, 28, 63, 118, 130, 233, 100, 202, 226, 210, 24, 8, 108, 192, 134, 8, 74, 66, 85, 16, 193, 92, + 56, 104, 153, 44, 44, 44, 82, 85, 216, 66, 54, 146, 136, 204, 59, 22, 198, 227, 45, 16, 71, 184, 140, 142, 119, 48, 110, 141, 219, 110, 190, 233, + 190, 233, 116, 242, 33, 219, 216, 66, 18, 17, 1, 81, 32, 200, 108, 132, 131, 204, 164, 170, 128, 36, 34, 176, 1, 131, 109, 144, 56, 124, 248, 16, + 159, 253, 236, 255, 197, 147, 95, 127, 130, 147, 167, 78, 209, 151, 248, 218, 227, 95, 231, 103, 126, 230, 103, 184, 254, 250, 235, 81, 9, 115, 65, 128, + 36, 108, 176, 69, 73, 132, 185, 192, 148, 138, 35, 71, 15, 115, 238, 220, 121, 102, 195, 140, 133, 205, 29, 59, 174, 217, 201, 120, 97, 204, 137, 163, + 39, 56, 125, 240, 44, 7, 15, 31, 229, 247, 62, 247, 111, 200, 22, 124, 232, 195, 255, 30, 173, 107, 84, 21, 182, 128, 128, 0, 91, 96, 99, 9, + 91, 216, 166, 36, 250, 217, 64, 169, 144, 76, 102, 71, 102, 34, 9, 219, 100, 54, 78, 158, 60, 197, 100, 50, 101, 97, 113, 140, 84, 216, 92, 96, + 34, 192, 18, 182, 152, 179, 140, 44, 140, 137, 12, 84, 69, 149, 168, 42, 134, 128, 110, 60, 222, 158, 153, 87, 3, 71, 184, 140, 228, 50, 126, 240, + 83, 159, 96, 235, 230, 141, 140, 23, 198, 31, 30, 250, 126, 107, 213, 0, 4, 146, 144, 10, 187, 176, 11, 91, 204, 85, 21, 182, 169, 234, 177, 6, + 108, 33, 21, 200, 28, 57, 116, 144, 95, 255, 231, 255, 156, 47, 124, 225, 139, 236, 59, 240, 58, 167, 166, 167, 89, 141, 21, 190, 241, 220, 147, 252, + 198, 111, 254, 6, 171, 171, 171, 88, 198, 18, 150, 128, 32, 50, 104, 93, 71, 102, 98, 27, 91, 216, 197, 234, 234, 121, 134, 26, 136, 81, 114, 199, + 125, 119, 242, 209, 135, 63, 198, 13, 55, 220, 194, 109, 247, 220, 206, 134, 157, 235, 25, 106, 224, 248, 137, 147, 252, 209, 23, 190, 200, 222, 189, 123, + 177, 140, 84, 216, 198, 54, 82, 97, 21, 150, 168, 18, 146, 32, 2, 108, 102, 179, 25, 173, 53, 34, 130, 170, 66, 18, 153, 137, 109, 90, 75, 86, + 86, 86, 153, 76, 103, 128, 177, 132, 85, 84, 21, 118, 81, 26, 48, 2, 12, 22, 152, 139, 102, 211, 41, 6, 36, 49, 235, 123, 6, 9, 73, 27, + 171, 106, 183, 36, 46, 39, 185, 12, 219, 188, 126, 248, 248, 82, 68, 190, 123, 54, 155, 49, 157, 78, 121, 139, 109, 170, 10, 219, 72, 194, 54, 16, + 128, 33, 12, 97, 164, 30, 44, 206, 156, 62, 197, 191, 250, 173, 207, 242, 229, 199, 190, 194, 145, 19, 199, 89, 220, 182, 196, 109, 15, 189, 139, 59, + 31, 186, 135, 93, 55, 93, 201, 87, 158, 248, 99, 246, 238, 125, 22, 34, 144, 196, 48, 12, 16, 208, 181, 70, 70, 50, 234, 58, 186, 174, 67, 18, + 182, 105, 173, 209, 117, 29, 163, 197, 17, 91, 55, 110, 99, 247, 230, 107, 57, 245, 250, 73, 22, 218, 2, 155, 182, 110, 196, 36, 125, 63, 112, 232, + 232, 81, 30, 251, 242, 99, 156, 57, 125, 138, 57, 73, 72, 133, 36, 108, 35, 137, 57, 27, 176, 233, 251, 129, 149, 213, 21, 130, 160, 235, 58, 34, + 2, 219, 68, 4, 182, 177, 205, 48, 12, 172, 172, 172, 128, 193, 22, 178, 80, 21, 85, 198, 6, 219, 72, 194, 152, 204, 196, 130, 149, 149, 85, 44, + 97, 9, 219, 216, 198, 246, 66, 68, 236, 204, 12, 238, 184, 253, 86, 222, 46, 185, 140, 22, 201, 66, 215, 109, 25, 117, 163, 91, 170, 138, 213, 149, + 85, 134, 161, 71, 42, 170, 10, 73, 216, 32, 137, 170, 98, 24, 122, 164, 194, 22, 146, 24, 106, 96, 152, 205, 248, 234, 87, 190, 204, 99, 143, 125, + 133, 227, 111, 158, 34, 70, 112, 195, 237, 55, 241, 137, 135, 63, 201, 117, 219, 111, 96, 195, 120, 19, 238, 204, 87, 190, 242, 37, 166, 147, 53, 164, + 98, 46, 51, 105, 109, 68, 215, 117, 100, 54, 34, 130, 185, 42, 177, 115, 199, 118, 182, 109, 221, 68, 20, 60, 245, 196, 83, 252, 247, 255, 228, 159, + 240, 248, 19, 95, 231, 141, 131, 7, 56, 127, 102, 5, 44, 108, 51, 89, 235, 217, 183, 239, 85, 94, 126, 233, 101, 192, 96, 97, 21, 72, 216, 6, + 11, 169, 8, 32, 34, 56, 123, 238, 28, 43, 231, 87, 137, 12, 50, 147, 204, 32, 34, 136, 8, 70, 163, 17, 17, 129, 108, 134, 190, 71, 18, 230, + 2, 155, 136, 0, 12, 152, 32, 152, 179, 77, 4, 204, 102, 61, 231, 206, 173, 80, 18, 37, 1, 70, 50, 146, 136, 136, 45, 139, 139, 75, 128, 121, + 187, 228, 50, 50, 147, 214, 186, 43, 91, 230, 214, 201, 218, 132, 179, 231, 206, 97, 23, 85, 61, 85, 3, 182, 169, 42, 84, 133, 36, 36, 161, 18, + 42, 83, 37, 112, 112, 228, 216, 17, 254, 237, 151, 31, 227, 240, 145, 99, 244, 253, 64, 118, 29, 145, 240, 252, 222, 23, 57, 248, 202, 33, 78, 188, + 113, 2, 15, 226, 245, 215, 95, 229, 220, 217, 211, 168, 138, 136, 0, 130, 136, 32, 72, 130, 164, 101, 71, 70, 99, 24, 6, 110, 190, 229, 22, 30, + 254, 190, 135, 89, 236, 22, 57, 119, 234, 44, 125, 78, 217, 184, 115, 153, 55, 143, 188, 201, 153, 35, 103, 120, 75, 73, 156, 61, 187, 194, 190, 125, + 251, 25, 102, 83, 194, 194, 26, 176, 132, 101, 176, 176, 197, 92, 100, 114, 234, 228, 105, 166, 147, 25, 173, 117, 216, 32, 153, 204, 36, 34, 136, 8, + 50, 147, 140, 128, 0, 169, 176, 5, 1, 132, 137, 0, 12, 4, 151, 68, 16, 145, 156, 59, 191, 194, 202, 234, 20, 3, 178, 40, 11, 169, 168, 42, + 134, 161, 182, 92, 125, 213, 46, 170, 196, 219, 117, 92, 86, 96, 188, 35, 34, 150, 135, 26, 56, 126, 236, 56, 183, 220, 114, 35, 153, 73, 4, 12, + 67, 79, 102, 16, 209, 48, 102, 212, 141, 48, 194, 6, 27, 236, 224, 185, 189, 207, 240, 210, 43, 175, 176, 186, 54, 1, 139, 217, 234, 148, 253, 47, + 191, 202, 243, 123, 95, 228, 232, 254, 35, 140, 23, 199, 108, 221, 180, 153, 171, 175, 186, 134, 241, 226, 34, 165, 129, 116, 71, 70, 48, 151, 153, 216, + 6, 76, 182, 196, 54, 24, 62, 240, 190, 247, 243, 218, 254, 3, 252, 206, 231, 126, 159, 129, 162, 95, 233, 169, 89, 193, 192, 5, 1, 8, 28, 244, + 125, 241, 230, 137, 147, 172, 173, 173, 177, 184, 184, 136, 205, 69, 182, 144, 204, 37, 6, 7, 135, 14, 29, 161, 170, 176, 133, 84, 204, 217, 38, 34, + 152, 107, 173, 163, 27, 117, 188, 69, 18, 115, 182, 129, 192, 54, 182, 201, 72, 140, 48, 230, 212, 201, 83, 172, 156, 95, 193, 6, 73, 72, 66, 18, + 150, 32, 98, 116, 231, 29, 215, 243, 228, 55, 158, 230, 237, 146, 203, 48, 6, 123, 83, 85, 45, 16, 193, 241, 227, 199, 25, 134, 162, 170, 144, 10, + 169, 176, 65, 18, 146, 40, 21, 146, 40, 21, 178, 88, 89, 89, 225, 185, 103, 159, 227, 212, 169, 51, 148, 4, 4, 158, 193, 155, 7, 78, 226, 126, + 96, 231, 238, 109, 44, 46, 45, 178, 97, 113, 35, 31, 250, 208, 135, 25, 141, 58, 36, 129, 33, 34, 136, 8, 34, 130, 174, 235, 152, 179, 13, 152, + 89, 63, 37, 187, 224, 227, 159, 120, 152, 59, 239, 184, 149, 24, 96, 88, 27, 176, 192, 24, 48, 16, 204, 5, 48, 235, 167, 76, 167, 83, 84, 133, + 37, 84, 3, 85, 133, 45, 108, 97, 204, 234, 218, 132, 3, 7, 14, 146, 153, 216, 102, 46, 2, 36, 81, 85, 12, 195, 128, 36, 48, 96, 99, 192, + 50, 54, 68, 4, 96, 34, 130, 140, 68, 18, 17, 65, 68, 112, 228, 232, 113, 166, 179, 25, 115, 54, 88, 198, 54, 54, 248, 130, 233, 84, 216, 230, + 237, 146, 203, 49, 16, 44, 218, 110, 92, 112, 242, 228, 105, 206, 157, 91, 193, 134, 97, 24, 144, 140, 45, 192, 72, 162, 170, 24, 106, 160, 159, 13, + 212, 32, 206, 156, 57, 195, 129, 55, 14, 49, 153, 204, 128, 192, 4, 118, 160, 85, 56, 119, 104, 149, 115, 135, 87, 153, 157, 238, 185, 255, 158, 251, + 216, 189, 251, 106, 134, 217, 0, 6, 219, 216, 38, 35, 136, 8, 192, 68, 4, 17, 80, 26, 168, 26, 232, 251, 158, 205, 155, 55, 241, 131, 63, 248, + 8, 123, 246, 92, 205, 120, 212, 8, 243, 103, 204, 92, 182, 100, 97, 97, 204, 210, 210, 34, 45, 27, 37, 81, 42, 228, 194, 42, 130, 32, 8, 50, + 147, 195, 71, 143, 113, 224, 141, 35, 188, 37, 51, 201, 108, 100, 38, 223, 100, 250, 190, 71, 50, 146, 48, 6, 140, 100, 44, 19, 17, 200, 66, 22, + 65, 82, 130, 3, 7, 14, 33, 25, 8, 230, 36, 83, 37, 100, 35, 41, 86, 87, 2, 91, 188, 93, 114, 25, 14, 99, 46, 8, 192, 112, 250, 244, + 105, 14, 31, 62, 140, 84, 216, 92, 96, 134, 97, 160, 170, 176, 11, 187, 176, 11, 185, 48, 197, 233, 51, 167, 57, 123, 230, 44, 85, 133, 13, 182, + 177, 205, 156, 21, 184, 96, 121, 121, 29, 239, 125, 223, 187, 105, 45, 24, 212, 51, 212, 0, 54, 182, 169, 18, 85, 133, 108, 130, 192, 54, 17, 129, + 45, 250, 126, 198, 116, 58, 225, 218, 107, 119, 243, 3, 159, 248, 40, 215, 237, 217, 205, 198, 13, 203, 44, 140, 71, 116, 173, 49, 30, 117, 172, 95, + 183, 196, 230, 77, 235, 217, 185, 99, 27, 163, 209, 152, 42, 33, 9, 201, 24, 48, 38, 34, 176, 205, 179, 123, 95, 100, 50, 153, 162, 18, 153, 13, + 155, 139, 34, 130, 57, 219, 216, 198, 54, 198, 204, 89, 102, 206, 22, 145, 129, 44, 50, 146, 204, 68, 50, 43, 231, 215, 120, 227, 141, 67, 72, 66, + 18, 182, 193, 198, 54, 182, 176, 209, 234, 116, 130, 109, 222, 174, 227, 114, 12, 97, 144, 68, 107, 73, 245, 197, 171, 251, 95, 229, 250, 235, 247, 208, + 117, 141, 8, 144, 76, 215, 113, 129, 145, 68, 102, 146, 153, 72, 48, 157, 174, 49, 155, 205, 176, 205, 37, 193, 156, 109, 230, 108, 115, 195, 13, 215, + 115, 195, 13, 215, 209, 15, 61, 182, 201, 12, 140, 1, 67, 0, 1, 65, 64, 152, 136, 96, 78, 18, 85, 3, 195, 208, 35, 137, 219, 239, 184, 141, + 8, 248, 250, 227, 79, 112, 236, 248, 9, 38, 107, 83, 34, 96, 221, 210, 18, 187, 118, 109, 231, 198, 27, 111, 32, 2, 36, 161, 42, 164, 98, 206, + 152, 108, 201, 177, 99, 111, 242, 252, 243, 47, 19, 36, 173, 5, 174, 129, 8, 144, 132, 109, 108, 19, 17, 216, 134, 224, 207, 152, 136, 192, 134, 136, + 224, 34, 131, 49, 17, 65, 100, 227, 196, 137, 55, 57, 122, 244, 4, 153, 9, 24, 219, 204, 101, 6, 182, 177, 125, 230, 137, 39, 255, 4, 203, 188, + 93, 199, 101, 132, 184, 72, 37, 164, 194, 14, 246, 239, 127, 141, 123, 78, 158, 100, 219, 182, 45, 216, 38, 2, 164, 192, 54, 153, 137, 13, 146, 1, + 179, 176, 176, 64, 107, 73, 70, 80, 46, 32, 136, 8, 230, 194, 176, 176, 48, 230, 221, 15, 221, 207, 186, 117, 235, 24, 134, 129, 139, 28, 212, 208, + 83, 53, 166, 181, 129, 140, 6, 153, 72, 194, 54, 115, 153, 73, 85, 49, 212, 128, 52, 144, 4, 183, 223, 118, 11, 219, 183, 109, 225, 181, 87, 95, + 227, 212, 169, 147, 148, 196, 250, 245, 235, 185, 118, 207, 53, 92, 125, 205, 85, 72, 61, 182, 136, 4, 156, 96, 46, 16, 67, 153, 175, 125, 253, 105, + 206, 156, 57, 71, 4, 32, 8, 131, 37, 108, 19, 17, 68, 4, 17, 65, 102, 146, 153, 88, 98, 46, 50, 80, 137, 200, 192, 134, 200, 192, 54, 150, + 201, 113, 240, 210, 43, 251, 57, 119, 126, 133, 136, 68, 50, 173, 129, 109, 170, 68, 132, 80, 213, 217, 51, 167, 207, 98, 155, 183, 235, 184, 44, 99, + 3, 1, 25, 193, 80, 197, 241, 227, 39, 121, 118, 239, 243, 124, 207, 7, 223, 139, 84, 124, 83, 210, 154, 169, 42, 90, 107, 216, 102, 211, 198, 141, + 108, 219, 190, 149, 215, 14, 28, 164, 175, 1, 108, 36, 136, 128, 209, 168, 113, 195, 13, 123, 120, 224, 254, 251, 1, 35, 9, 219, 68, 4, 82, 33, + 21, 195, 80, 100, 152, 200, 100, 46, 34, 136, 8, 50, 19, 219, 168, 138, 161, 6, 40, 211, 50, 217, 190, 99, 59, 219, 183, 111, 99, 168, 1, 219, + 180, 214, 145, 25, 88, 133, 36, 108, 99, 27, 155, 139, 50, 130, 151, 247, 189, 206, 51, 79, 63, 135, 109, 8, 232, 85, 72, 98, 46, 34, 152, 139, + 8, 108, 115, 145, 161, 36, 36, 33, 153, 200, 32, 8, 100, 1, 193, 69, 1, 179, 89, 207, 222, 189, 47, 32, 153, 174, 131, 204, 64, 18, 182, 177, + 132, 36, 151, 244, 166, 44, 94, 125, 253, 13, 222, 46, 185, 12, 217, 216, 194, 50, 17, 129, 36, 50, 131, 103, 158, 121, 150, 163, 71, 143, 99, 27, + 73, 84, 9, 169, 24, 134, 1, 91, 72, 98, 24, 138, 165, 165, 37, 222, 243, 158, 247, 176, 121, 243, 38, 90, 38, 4, 180, 46, 89, 92, 90, 96, + 215, 149, 59, 249, 232, 199, 30, 102, 215, 149, 87, 48, 12, 3, 85, 3, 195, 48, 80, 53, 32, 23, 170, 194, 22, 146, 81, 9, 201, 24, 147, 145, + 72, 34, 34, 176, 141, 74, 12, 195, 64, 63, 12, 12, 195, 64, 97, 218, 104, 196, 104, 97, 129, 236, 26, 146, 40, 21, 182, 193, 32, 153, 8, 147, + 25, 156, 58, 117, 150, 127, 251, 197, 175, 194, 196, 203, 222, 0, 0, 32, 0, 73, 68, 65, 84, 48, 153, 204, 192, 129, 10, 178, 53, 200, 32, 91, + 35, 34, 168, 42, 190, 41, 144, 68, 63, 155, 17, 4, 216, 216, 134, 128, 32, 192, 96, 155, 214, 26, 135, 14, 29, 101, 255, 190, 215, 201, 72, 34, + 130, 185, 136, 64, 18, 6, 50, 98, 5, 124, 156, 119, 208, 113, 25, 150, 145, 189, 58, 194, 131, 236, 142, 11, 50, 147, 179, 103, 207, 243, 199, 127, + 252, 85, 62, 254, 241, 135, 89, 92, 92, 4, 140, 36, 34, 2, 48, 54, 23, 4, 153, 201, 3, 15, 61, 64, 180, 228, 171, 127, 242, 56, 7, 222, + 56, 192, 208, 247, 236, 220, 185, 131, 247, 127, 224, 189, 188, 251, 221, 15, 32, 13, 216, 198, 54, 17, 193, 48, 64, 63, 43, 70, 157, 104, 77, 68, + 64, 102, 34, 9, 149, 32, 160, 181, 164, 69, 16, 54, 97, 46, 178, 132, 128, 4, 108, 48, 16, 97, 108, 161, 18, 178, 137, 8, 34, 128, 8, 206, + 173, 174, 242, 249, 63, 250, 18, 135, 14, 31, 35, 34, 32, 32, 19, 100, 147, 17, 244, 85, 216, 69, 132, 0, 49, 39, 21, 195, 32, 250, 161, 144, + 5, 17, 68, 128, 36, 50, 18, 27, 50, 3, 8, 158, 120, 226, 25, 78, 159, 57, 71, 107, 13, 27, 36, 17, 209, 32, 184, 168, 164, 21, 201, 71, + 9, 115, 57, 29, 151, 97, 11, 236, 73, 16, 195, 208, 247, 157, 36, 136, 100, 238, 133, 231, 95, 226, 170, 43, 175, 224, 129, 7, 239, 67, 226, 162, + 136, 192, 54, 146, 200, 76, 32, 137, 8, 30, 122, 247, 131, 220, 115, 207, 221, 156, 58, 121, 146, 126, 232, 89, 183, 110, 29, 219, 182, 109, 165, 181, + 198, 48, 20, 96, 108, 19, 17, 128, 169, 234, 169, 234, 169, 161, 145, 217, 40, 21, 150, 176, 197, 92, 70, 35, 51, 201, 76, 50, 2, 1, 6, 74, + 194, 24, 59, 200, 108, 88, 162, 84, 216, 230, 18, 19, 1, 231, 206, 175, 241, 232, 23, 255, 152, 151, 95, 218, 71, 68, 32, 21, 85, 3, 146, 128, + 64, 18, 153, 9, 85, 100, 54, 36, 19, 17, 100, 38, 4, 96, 46, 138, 128, 32, 152, 51, 16, 1, 153, 201, 137, 55, 79, 243, 248, 227, 79, 98, + 27, 219, 204, 101, 6, 115, 54, 72, 2, 251, 84, 223, 247, 199, 34, 184, 172, 142, 203, 176, 141, 237, 53, 225, 33, 91, 35, 29, 24, 136, 8, 250, + 94, 60, 246, 216, 87, 89, 94, 191, 142, 91, 110, 185, 153, 136, 96, 206, 22, 6, 44, 33, 7, 65, 195, 54, 173, 5, 59, 175, 216, 78, 68, 96, + 7, 85, 162, 74, 100, 6, 182, 121, 75, 132, 25, 106, 160, 52, 80, 53, 96, 139, 104, 201, 48, 12, 244, 179, 158, 190, 31, 144, 0, 7, 56, 48, + 23, 68, 128, 141, 37, 132, 177, 19, 48, 182, 145, 196, 92, 4, 16, 201, 177, 99, 111, 242, 232, 23, 255, 152, 87, 95, 61, 8, 52, 170, 122, 108, + 147, 153, 64, 32, 9, 219, 24, 51, 87, 85, 188, 69, 18, 227, 81, 71, 100, 16, 17, 216, 38, 51, 144, 64, 22, 38, 176, 197, 215, 30, 127, 146, + 131, 7, 143, 16, 17, 216, 38, 34, 136, 8, 32, 152, 139, 8, 100, 191, 90, 85, 231, 50, 147, 203, 233, 184, 140, 194, 24, 175, 150, 220, 119, 93, + 7, 97, 134, 190, 199, 230, 2, 115, 238, 236, 10, 159, 251, 189, 63, 164, 74, 220, 118, 219, 45, 24, 145, 110, 4, 16, 153, 68, 4, 25, 32, 21, + 115, 17, 65, 68, 48, 103, 155, 136, 64, 10, 34, 130, 57, 219, 68, 36, 85, 197, 202, 249, 21, 78, 245, 103, 57, 191, 178, 202, 249, 243, 231, 89, + 89, 89, 101, 58, 153, 34, 137, 204, 100, 212, 53, 198, 227, 96, 52, 78, 34, 6, 108, 97, 10, 28, 128, 169, 18, 96, 34, 146, 136, 100, 117, 50, + 229, 229, 151, 94, 228, 169, 111, 236, 229, 216, 241, 147, 212, 32, 100, 83, 37, 36, 19, 145, 192, 128, 36, 136, 0, 67, 102, 3, 68, 213, 128, 109, + 230, 100, 131, 33, 2, 236, 160, 100, 34, 0, 65, 100, 112, 226, 196, 105, 30, 125, 244, 49, 134, 161, 232, 186, 17, 111, 169, 18, 173, 5, 184, 17, + 36, 114, 61, 127, 227, 181, 55, 173, 236, 123, 99, 31, 151, 211, 113, 25, 178, 177, 125, 182, 164, 105, 200, 12, 253, 64, 149, 176, 197, 48, 12, 216, + 112, 252, 248, 73, 126, 235, 179, 191, 203, 185, 115, 231, 185, 251, 158, 59, 24, 141, 70, 204, 133, 130, 204, 134, 195, 204, 69, 36, 32, 34, 130, 185, + 136, 192, 134, 8, 243, 22, 201, 128, 120, 243, 196, 97, 14, 31, 62, 206, 155, 39, 79, 113, 230, 204, 89, 214, 214, 214, 152, 205, 102, 72, 34, 51, + 25, 143, 199, 44, 46, 45, 177, 113, 253, 50, 187, 119, 111, 99, 243, 166, 69, 2, 136, 8, 46, 49, 17, 9, 209, 88, 89, 89, 227, 224, 27, 135, + 120, 102, 239, 11, 28, 58, 124, 148, 26, 138, 97, 40, 8, 192, 38, 51, 145, 138, 185, 190, 31, 176, 69, 16, 152, 192, 54, 153, 137, 36, 108, 99, + 155, 170, 194, 54, 24, 164, 34, 8, 34, 147, 108, 13, 1, 127, 248, 135, 95, 226, 245, 215, 14, 67, 36, 182, 137, 8, 46, 49, 182, 137, 8, 36, + 203, 142, 103, 143, 28, 63, 202, 209, 163, 199, 185, 156, 142, 203, 144, 10, 73, 103, 236, 209, 164, 170, 40, 137, 170, 129, 136, 36, 34, 8, 32, 51, + 56, 119, 110, 133, 223, 251, 189, 207, 115, 244, 232, 49, 222, 243, 158, 7, 217, 186, 109, 11, 182, 176, 193, 97, 230, 34, 132, 13, 17, 16, 17, 68, + 4, 17, 193, 156, 13, 182, 152, 59, 117, 250, 60, 123, 159, 121, 153, 227, 199, 223, 228, 204, 153, 83, 156, 59, 119, 158, 213, 213, 85, 250, 190, 199, + 54, 151, 4, 27, 54, 108, 96, 219, 150, 205, 172, 223, 208, 177, 101, 243, 18, 198, 204, 69, 36, 231, 207, 175, 113, 252, 216, 155, 188, 113, 248, 8, + 175, 189, 250, 58, 167, 78, 157, 161, 202, 116, 93, 135, 29, 100, 38, 150, 17, 66, 18, 96, 44, 97, 11, 8, 34, 2, 169, 176, 185, 40, 51, 177, + 205, 92, 70, 64, 0, 17, 64, 16, 153, 148, 138, 209, 104, 204, 51, 207, 60, 207, 31, 253, 209, 151, 33, 18, 34, 152, 139, 8, 230, 34, 146, 204, + 100, 78, 82, 95, 85, 175, 172, 13, 3, 239, 164, 227, 50, 60, 8, 171, 86, 145, 78, 87, 137, 214, 18, 169, 97, 139, 57, 89, 180, 214, 33, 153, + 97, 86, 60, 246, 229, 175, 241, 242, 75, 251, 121, 255, 251, 30, 226, 182, 219, 111, 102, 253, 250, 117, 148, 5, 1, 4, 23, 152, 185, 204, 164, 69, + 195, 54, 182, 113, 128, 129, 32, 56, 123, 246, 44, 175, 31, 120, 157, 195, 135, 142, 114, 232, 208, 65, 250, 126, 32, 2, 140, 152, 77, 123, 78, 156, + 56, 65, 75, 184, 239, 222, 187, 185, 246, 158, 155, 185, 98, 199, 22, 44, 19, 17, 180, 214, 120, 241, 165, 215, 248, 252, 191, 249, 34, 167, 78, 157, + 166, 4, 153, 73, 107, 73, 68, 146, 145, 200, 34, 34, 24, 84, 188, 165, 101, 67, 37, 186, 110, 68, 85, 81, 42, 36, 49, 12, 34, 34, 200, 76, + 134, 97, 64, 50, 221, 66, 199, 210, 226, 24, 91, 100, 4, 115, 153, 141, 195, 71, 79, 240, 155, 255, 231, 191, 226, 236, 217, 85, 50, 19, 219, 204, + 217, 38, 51, 185, 196, 68, 6, 17, 76, 92, 58, 103, 204, 59, 233, 184, 12, 169, 168, 170, 169, 170, 142, 141, 198, 99, 196, 55, 85, 21, 125, 223, + 19, 17, 68, 4, 198, 84, 137, 3, 7, 14, 241, 47, 14, 255, 54, 187, 119, 95, 201, 61, 247, 220, 193, 173, 183, 220, 204, 150, 173, 155, 232, 186, + 134, 44, 34, 18, 75, 252, 223, 213, 193, 91, 240, 231, 247, 125, 223, 245, 231, 235, 253, 254, 252, 254, 199, 213, 238, 234, 96, 157, 173, 147, 79, 137, + 92, 199, 78, 161, 101, 154, 50, 147, 146, 25, 66, 153, 41, 229, 152, 97, 114, 65, 153, 97, 166, 189, 229, 146, 43, 110, 24, 46, 152, 1, 238, 128, + 14, 195, 5, 164, 153, 0, 197, 197, 83, 26, 55, 208, 184, 57, 214, 137, 237, 38, 150, 101, 71, 138, 117, 176, 180, 90, 89, 210, 106, 87, 218, 243, + 254, 79, 191, 239, 231, 253, 126, 177, 63, 41, 10, 30, 198, 146, 108, 147, 148, 244, 241, 88, 92, 72, 194, 221, 72, 66, 136, 182, 185, 251, 206, 59, + 120, 226, 177, 135, 184, 117, 227, 58, 135, 7, 55, 184, 120, 233, 45, 118, 118, 246, 56, 123, 246, 12, 203, 178, 240, 224, 67, 31, 225, 95, 249, 233, + 191, 196, 103, 62, 253, 41, 238, 190, 231, 110, 70, 6, 221, 69, 100, 112, 245, 234, 77, 190, 244, 171, 191, 197, 235, 111, 92, 100, 123, 123, 133, 36, + 64, 72, 193, 200, 4, 9, 33, 108, 3, 166, 102, 177, 209, 110, 218, 6, 140, 221, 204, 57, 217, 144, 68, 85, 81, 85, 188, 39, 34, 216, 221, 219, + 5, 27, 99, 66, 201, 173, 131, 35, 254, 247, 191, 247, 69, 94, 120, 241, 28, 82, 34, 9, 73, 188, 199, 54, 146, 216, 176, 27, 155, 19, 211, 39, + 182, 121, 63, 131, 247, 113, 243, 230, 225, 209, 222, 222, 238, 69, 4, 53, 27, 108, 64, 68, 4, 153, 73, 85, 1, 162, 170, 145, 132, 109, 142, 79, + 78, 120, 241, 197, 115, 188, 248, 226, 75, 220, 117, 247, 157, 60, 242, 200, 195, 60, 246, 216, 35, 60, 112, 223, 125, 220, 121, 215, 89, 118, 118, 86, + 172, 198, 32, 51, 201, 76, 66, 162, 108, 108, 179, 26, 193, 103, 63, 251, 41, 62, 246, 177, 135, 249, 169, 191, 244, 19, 60, 255, 194, 139, 124, 243, + 155, 207, 241, 246, 229, 235, 220, 127, 255, 93, 252, 244, 79, 255, 11, 60, 252, 224, 253, 40, 205, 156, 107, 114, 236, 160, 16, 54, 60, 253, 141, 103, + 120, 243, 205, 75, 140, 76, 108, 147, 153, 72, 162, 187, 209, 106, 240, 46, 209, 221, 72, 65, 68, 96, 160, 187, 17, 208, 109, 48, 216, 38, 51, 233, + 158, 72, 98, 163, 187, 137, 16, 123, 123, 187, 236, 237, 238, 210, 109, 20, 226, 120, 61, 249, 194, 23, 126, 133, 175, 124, 245, 235, 68, 36, 27, 221, + 77, 68, 176, 33, 137, 119, 137, 238, 166, 91, 140, 49, 144, 132, 109, 222, 207, 224, 125, 60, 244, 209, 251, 234, 228, 120, 253, 90, 85, 209, 213, 68, + 6, 85, 133, 16, 32, 64, 188, 203, 128, 137, 16, 115, 26, 133, 168, 130, 75, 23, 223, 230, 194, 27, 151, 248, 234, 87, 190, 206, 246, 246, 54, 219, + 219, 43, 78, 157, 222, 231, 212, 222, 62, 35, 7, 247, 220, 115, 55, 255, 242, 95, 254, 139, 220, 255, 192, 71, 0, 179, 49, 107, 178, 44, 199, 236, + 238, 38, 31, 255, 216, 131, 156, 218, 31, 60, 243, 204, 243, 220, 243, 145, 59, 217, 221, 9, 14, 15, 111, 161, 16, 85, 133, 27, 132, 185, 114, 237, + 58, 223, 120, 250, 15, 88, 102, 177, 181, 21, 136, 160, 219, 128, 201, 4, 204, 109, 166, 170, 168, 106, 196, 109, 130, 174, 162, 13, 8, 20, 66, 36, + 217, 201, 156, 197, 156, 133, 109, 36, 145, 153, 116, 55, 119, 222, 121, 150, 221, 189, 29, 114, 12, 110, 221, 58, 228, 239, 125, 225, 87, 248, 245, 95, + 255, 50, 221, 38, 34, 216, 176, 205, 134, 36, 254, 31, 70, 18, 54, 216, 2, 2, 73, 188, 159, 193, 247, 241, 235, 191, 253, 59, 252, 107, 63, 251, + 51, 148, 253, 138, 219, 29, 82, 148, 27, 73, 84, 55, 85, 19, 219, 72, 65, 183, 177, 65, 10, 4, 184, 77, 42, 32, 204, 156, 19, 12, 135, 71, + 39, 220, 188, 117, 200, 197, 75, 87, 216, 168, 42, 108, 243, 135, 223, 126, 158, 159, 255, 249, 127, 155, 143, 127, 236, 81, 170, 38, 115, 46, 204, 229, + 132, 147, 245, 49, 235, 245, 154, 213, 74, 124, 226, 19, 15, 33, 193, 250, 228, 132, 145, 43, 150, 165, 56, 58, 58, 38, 115, 197, 214, 106, 197, 243, + 207, 189, 196, 197, 75, 111, 99, 139, 110, 19, 1, 2, 186, 27, 9, 102, 21, 18, 84, 21, 96, 64, 84, 53, 179, 138, 141, 170, 194, 109, 170, 10, + 219, 108, 100, 38, 85, 69, 119, 227, 110, 78, 214, 107, 238, 190, 231, 46, 118, 119, 118, 185, 116, 233, 10, 255, 219, 231, 255, 1, 95, 253, 218, 83, + 116, 155, 136, 192, 54, 17, 129, 36, 108, 99, 27, 73, 72, 2, 68, 102, 18, 145, 216, 148, 77, 217, 226, 253, 12, 222, 199, 178, 94, 48, 188, 92, + 85, 107, 208, 78, 117, 33, 5, 115, 46, 216, 166, 219, 216, 147, 170, 34, 36, 26, 48, 208, 93, 8, 49, 103, 97, 243, 142, 136, 160, 187, 145, 68, + 68, 176, 81, 85, 156, 123, 229, 85, 126, 225, 239, 252, 93, 254, 195, 191, 241, 239, 243, 177, 39, 62, 74, 119, 115, 116, 124, 204, 141, 27, 55, 185, + 114, 229, 42, 151, 47, 95, 225, 230, 205, 27, 44, 203, 100, 181, 218, 102, 103, 123, 155, 179, 103, 239, 228, 145, 71, 30, 225, 244, 233, 51, 28, 28, + 28, 243, 244, 55, 158, 97, 89, 79, 198, 24, 116, 21, 206, 32, 98, 133, 16, 99, 12, 220, 205, 106, 123, 11, 27, 214, 235, 53, 17, 73, 183, 17, + 194, 54, 115, 22, 182, 89, 150, 133, 238, 198, 54, 18, 239, 152, 115, 98, 155, 173, 213, 138, 71, 30, 125, 152, 103, 190, 253, 34, 159, 255, 252, 63, + 224, 197, 23, 207, 33, 9, 73, 216, 70, 18, 221, 77, 68, 16, 17, 116, 55, 146, 176, 141, 36, 170, 10, 41, 144, 116, 36, 233, 8, 204, 251, 73, + 222, 199, 195, 15, 63, 68, 119, 239, 68, 232, 231, 16, 119, 180, 193, 221, 84, 23, 93, 13, 24, 119, 99, 140, 13, 203, 178, 96, 27, 219, 216, 96, + 55, 118, 99, 131, 219, 84, 55, 182, 145, 132, 109, 108, 99, 224, 250, 245, 155, 188, 114, 254, 187, 60, 242, 200, 67, 220, 115, 207, 93, 172, 215, 199, + 92, 185, 114, 133, 215, 94, 191, 192, 133, 11, 111, 241, 246, 219, 215, 184, 121, 243, 144, 245, 201, 194, 206, 206, 54, 15, 61, 120, 63, 15, 63, 252, + 16, 251, 251, 167, 248, 218, 215, 158, 226, 235, 95, 255, 38, 153, 43, 114, 12, 144, 176, 27, 183, 81, 136, 136, 96, 35, 51, 177, 161, 170, 153, 115, + 34, 192, 54, 146, 152, 53, 169, 106, 16, 116, 155, 170, 162, 202, 84, 21, 221, 13, 8, 219, 68, 4, 191, 246, 143, 127, 139, 215, 95, 127, 147, 136, + 64, 18, 239, 145, 68, 68, 176, 33, 9, 219, 72, 34, 51, 201, 76, 192, 128, 136, 136, 55, 109, 255, 79, 146, 110, 28, 28, 28, 240, 253, 12, 62, + 64, 87, 95, 4, 93, 168, 238, 7, 187, 27, 219, 100, 14, 108, 179, 177, 120, 66, 55, 85, 133, 221, 216, 198, 54, 110, 35, 132, 16, 229, 162, 91, + 216, 102, 163, 187, 145, 132, 36, 82, 73, 35, 206, 157, 251, 46, 191, 240, 119, 62, 207, 127, 240, 55, 254, 61, 30, 126, 240, 35, 60, 248, 224, 3, + 108, 111, 111, 241, 224, 3, 247, 113, 116, 120, 4, 152, 221, 189, 93, 206, 158, 61, 195, 153, 59, 78, 179, 179, 189, 197, 235, 175, 95, 228, 119, 191, + 242, 251, 44, 179, 136, 48, 138, 193, 24, 131, 170, 66, 17, 108, 116, 155, 204, 192, 54, 221, 141, 109, 192, 180, 205, 70, 117, 19, 145, 40, 26, 181, + 144, 64, 18, 17, 98, 189, 94, 179, 209, 93, 172, 215, 39, 124, 235, 155, 207, 18, 17, 140, 49, 248, 94, 182, 177, 141, 36, 54, 108, 35, 137, 136, + 0, 68, 85, 49, 70, 16, 17, 216, 190, 105, 251, 150, 36, 222, 79, 242, 62, 62, 250, 208, 131, 92, 189, 118, 125, 189, 183, 191, 247, 87, 36, 253, + 57, 219, 96, 110, 51, 54, 116, 23, 115, 78, 34, 130, 238, 166, 170, 217, 48, 198, 24, 219, 216, 70, 10, 186, 141, 36, 222, 83, 85, 216, 102, 195, + 54, 182, 185, 126, 253, 38, 231, 206, 189, 202, 71, 31, 126, 136, 187, 238, 60, 139, 4, 91, 219, 43, 246, 246, 119, 216, 223, 223, 229, 212, 169, 83, + 236, 237, 237, 177, 187, 183, 207, 193, 193, 49, 191, 252, 203, 95, 226, 252, 171, 111, 144, 25, 216, 38, 35, 177, 205, 198, 106, 12, 54, 50, 147, 204, + 164, 187, 232, 54, 27, 17, 73, 85, 81, 53, 193, 80, 221, 116, 55, 179, 138, 170, 137, 36, 230, 44, 186, 155, 238, 166, 170, 144, 196, 24, 3, 73, + 116, 55, 27, 221, 205, 134, 36, 222, 35, 9, 73, 108, 72, 66, 2, 73, 68, 136, 49, 18, 41, 158, 94, 175, 215, 191, 152, 153, 125, 112, 112, 192, + 247, 147, 188, 143, 143, 126, 244, 33, 238, 187, 239, 94, 47, 203, 242, 99, 153, 227, 103, 170, 138, 57, 39, 221, 205, 70, 87, 211, 221, 216, 208, 221, + 216, 77, 85, 99, 155, 119, 24, 12, 216, 198, 136, 141, 170, 162, 187, 233, 110, 54, 108, 51, 231, 68, 18, 27, 87, 175, 222, 224, 249, 231, 191, 195, + 238, 222, 46, 31, 249, 200, 221, 172, 182, 86, 100, 14, 182, 183, 118, 216, 218, 222, 1, 39, 175, 191, 246, 22, 255, 215, 255, 249, 155, 60, 255, 252, + 75, 40, 196, 70, 230, 64, 33, 16, 140, 49, 104, 155, 80, 96, 67, 102, 130, 1, 1, 54, 221, 141, 219, 216, 166, 170, 17, 48, 171, 88, 47, 107, + 170, 154, 13, 155, 119, 84, 21, 221, 77, 102, 34, 9, 73, 108, 216, 70, 18, 182, 249, 94, 17, 129, 109, 36, 177, 33, 9, 73, 216, 38, 34, 1, + 125, 233, 210, 165, 75, 255, 112, 127, 127, 159, 131, 131, 3, 190, 159, 228, 125, 124, 247, 181, 215, 121, 224, 254, 251, 232, 246, 61, 171, 213, 248, 183, + 128, 49, 70, 82, 213, 204, 185, 176, 209, 213, 108, 216, 96, 155, 119, 25, 119, 99, 27, 187, 193, 6, 137, 110, 211, 221, 116, 55, 182, 121, 143, 109, + 54, 36, 1, 230, 224, 224, 144, 231, 158, 251, 14, 175, 189, 246, 38, 235, 165, 88, 102, 115, 229, 234, 77, 190, 243, 226, 119, 249, 202, 239, 126, 131, + 223, 253, 202, 239, 115, 249, 242, 85, 20, 65, 230, 224, 61, 54, 100, 4, 57, 6, 27, 145, 73, 68, 16, 18, 109, 35, 137, 57, 139, 234, 6, 137, + 147, 147, 53, 85, 147, 89, 69, 119, 209, 54, 32, 230, 156, 128, 88, 150, 133, 57, 39, 182, 89, 173, 86, 124, 175, 136, 192, 54, 146, 136, 8, 54, + 108, 179, 33, 137, 136, 96, 35, 66, 68, 136, 136, 96, 140, 193, 109, 191, 116, 230, 204, 153, 175, 85, 21, 7, 7, 7, 124, 63, 131, 15, 96, 27, + 219, 207, 117, 251, 114, 68, 62, 184, 44, 107, 34, 68, 102, 82, 85, 204, 57, 65, 98, 206, 194, 110, 54, 108, 110, 19, 118, 97, 155, 101, 78, 20, + 73, 85, 209, 221, 216, 70, 18, 182, 169, 42, 50, 147, 170, 162, 187, 217, 144, 130, 101, 22, 207, 254, 225, 119, 120, 238, 249, 151, 89, 173, 2, 41, + 49, 224, 134, 72, 145, 17, 68, 4, 138, 6, 195, 200, 32, 199, 0, 137, 170, 98, 181, 90, 33, 9, 219, 108, 68, 136, 245, 122, 193, 109, 170, 38, + 110, 35, 241, 142, 49, 6, 179, 38, 27, 221, 133, 109, 192, 72, 194, 54, 99, 12, 54, 50, 147, 238, 230, 61, 17, 193, 123, 36, 97, 155, 238, 102, + 140, 129, 109, 36, 33, 5, 182, 217, 144, 226, 150, 221, 223, 182, 205, 165, 75, 151, 120, 63, 131, 15, 48, 231, 194, 156, 245, 250, 24, 227, 249, 49, + 242, 193, 57, 11, 219, 8, 17, 10, 222, 147, 25, 204, 217, 72, 252, 49, 41, 80, 192, 24, 131, 101, 54, 146, 136, 8, 54, 108, 179, 209, 221, 68, + 4, 146, 88, 150, 197, 85, 245, 150, 237, 206, 204, 123, 51, 51, 186, 77, 21, 183, 53, 118, 147, 153, 96, 176, 141, 109, 236, 38, 35, 105, 55, 234, + 194, 134, 213, 24, 72, 162, 187, 193, 70, 219, 91, 128, 145, 192, 128, 20, 156, 44, 199, 8, 144, 68, 119, 131, 65, 10, 64, 216, 32, 129, 36, 108, + 19, 17, 108, 216, 70, 18, 182, 217, 144, 132, 109, 170, 138, 204, 68, 18, 146, 216, 136, 72, 192, 216, 77, 166, 0, 211, 61, 223, 236, 230, 5, 219, + 124, 144, 224, 3, 44, 179, 249, 115, 159, 254, 228, 141, 170, 249, 7, 85, 133, 221, 108, 204, 42, 102, 53, 57, 6, 82, 16, 145, 216, 166, 219, 108, + 216, 166, 186, 233, 110, 20, 129, 36, 108, 99, 27, 219, 116, 55, 203, 178, 176, 81, 85, 172, 215, 107, 159, 156, 156, 252, 175, 221, 253, 87, 151, 101, + 249, 217, 101, 89, 254, 251, 170, 90, 115, 219, 156, 69, 85, 209, 109, 54, 50, 131, 119, 216, 132, 18, 73, 108, 84, 53, 96, 12, 204, 101, 193, 54, + 17, 129, 36, 108, 35, 5, 237, 198, 110, 34, 130, 234, 102, 163, 186, 152, 85, 44, 75, 209, 13, 17, 201, 156, 147, 245, 122, 189, 72, 42, 254, 72, + 85, 97, 155, 13, 219, 116, 55, 182, 249, 127, 179, 161, 219, 216, 16, 17, 68, 4, 153, 201, 109, 79, 207, 89, 23, 108, 243, 65, 146, 15, 112, 225, + 194, 155, 156, 58, 117, 138, 110, 223, 3, 250, 55, 193, 17, 18, 27, 85, 141, 13, 221, 133, 128, 57, 11, 219, 116, 55, 118, 35, 9, 27, 108, 3, + 98, 195, 54, 203, 178, 176, 145, 153, 100, 38, 221, 205, 241, 241, 241, 83, 221, 253, 183, 186, 251, 57, 73, 151, 186, 251, 183, 129, 251, 199, 24, 127, + 62, 51, 177, 141, 13, 99, 36, 96, 36, 145, 99, 96, 192, 109, 16, 100, 36, 25, 129, 34, 64, 16, 17, 100, 36, 17, 65, 119, 99, 155, 245, 122, + 205, 198, 156, 147, 141, 170, 194, 109, 204, 134, 168, 42, 186, 155, 170, 98, 206, 249, 173, 204, 140, 219, 78, 69, 4, 146, 176, 205, 134, 36, 34, 130, + 13, 73, 108, 72, 66, 18, 27, 17, 66, 18, 99, 36, 153, 1, 8, 219, 127, 123, 140, 252, 202, 155, 111, 94, 228, 131, 4, 31, 98, 189, 94, 152, + 115, 126, 203, 246, 91, 99, 12, 218, 102, 206, 201, 134, 36, 164, 160, 109, 192, 108, 216, 141, 13, 221, 102, 195, 54, 115, 78, 108, 99, 155, 49, 6, + 146, 168, 42, 150, 101, 97, 89, 22, 108, 255, 221, 204, 60, 47, 9, 219, 68, 196, 205, 170, 250, 47, 215, 203, 250, 133, 170, 66, 18, 99, 36, 54, + 216, 220, 38, 36, 177, 97, 160, 102, 33, 137, 182, 169, 154, 116, 27, 12, 109, 51, 231, 100, 206, 73, 85, 147, 145, 116, 55, 17, 65, 102, 82, 213, + 28, 31, 31, 83, 213, 216, 166, 187, 169, 42, 186, 251, 0, 248, 98, 132, 150, 204, 68, 18, 153, 137, 36, 36, 33, 9, 219, 72, 34, 34, 200, 76, + 34, 130, 204, 100, 181, 74, 50, 69, 166, 200, 12, 64, 68, 196, 5, 219, 191, 93, 85, 124, 152, 224, 67, 216, 80, 213, 175, 116, 247, 75, 199, 71, + 199, 204, 57, 201, 28, 72, 66, 2, 219, 204, 57, 233, 54, 221, 77, 183, 233, 110, 186, 139, 170, 162, 187, 137, 16, 115, 78, 230, 156, 72, 194, 54, + 146, 216, 168, 170, 235, 192, 151, 185, 205, 54, 27, 22, 216, 126, 177, 170, 254, 143, 238, 102, 67, 18, 221, 13, 4, 82, 178, 94, 79, 92, 32, 5, + 17, 194, 54, 146, 48, 48, 198, 32, 50, 201, 76, 186, 155, 185, 20, 235, 245, 194, 122, 89, 232, 106, 220, 102, 206, 137, 109, 36, 192, 102, 206, 201, + 187, 68, 151, 191, 177, 202, 124, 54, 34, 238, 144, 196, 134, 109, 34, 130, 136, 32, 34, 144, 132, 109, 34, 130, 136, 32, 66, 216, 133, 4, 146, 200, + 12, 64, 100, 174, 144, 242, 203, 115, 214, 243, 32, 62, 76, 240, 33, 186, 155, 175, 63, 245, 244, 77, 219, 79, 101, 38, 182, 177, 77, 205, 133, 101, + 89, 176, 141, 36, 54, 236, 70, 18, 221, 141, 36, 54, 34, 196, 156, 133, 36, 36, 209, 221, 72, 66, 18, 182, 185, 237, 130, 237, 215, 248, 30, 174, + 102, 140, 97, 204, 175, 74, 58, 144, 196, 134, 36, 186, 155, 182, 17, 2, 9, 187, 81, 4, 237, 38, 51, 201, 76, 186, 155, 174, 162, 187, 168, 106, + 34, 19, 108, 186, 139, 182, 169, 46, 108, 112, 55, 182, 105, 55, 138, 96, 140, 193, 109, 221, 230, 239, 175, 86, 91, 91, 224, 59, 248, 35, 146, 120, + 143, 36, 34, 130, 204, 228, 93, 198, 54, 17, 137, 20, 72, 34, 34, 1, 35, 105, 13, 124, 97, 127, 255, 212, 73, 55, 31, 42, 248, 16, 221, 205, + 191, 244, 23, 255, 188, 171, 230, 87, 21, 90, 86, 171, 65, 8, 20, 129, 36, 170, 38, 27, 182, 145, 132, 109, 108, 99, 243, 142, 101, 153, 116, 55, + 27, 17, 129, 36, 36, 97, 27, 219, 84, 213, 53, 219, 87, 186, 155, 199, 31, 251, 24, 143, 63, 250, 24, 143, 63, 250, 152, 94, 125, 234, 89, 34, + 226, 5, 219, 175, 74, 66, 18, 146, 216, 112, 55, 10, 97, 55, 180, 145, 130, 136, 100, 206, 137, 219, 84, 21, 203, 156, 84, 53, 96, 186, 27, 219, + 140, 49, 176, 77, 119, 51, 231, 164, 109, 186, 77, 87, 51, 151, 133, 245, 122, 205, 178, 44, 47, 111, 111, 109, 125, 25, 241, 241, 188, 45, 66, 68, + 4, 153, 73, 102, 146, 153, 72, 66, 18, 239, 145, 32, 51, 136, 72, 108, 144, 68, 119, 3, 194, 237, 111, 206, 57, 127, 227, 228, 228, 132, 183, 222, + 186, 196, 135, 9, 62, 196, 55, 158, 254, 22, 115, 22, 115, 246, 83, 115, 214, 155, 110, 83, 221, 128, 144, 130, 136, 68, 18, 171, 213, 138, 213, 88, + 177, 33, 137, 170, 162, 187, 17, 16, 17, 116, 55, 221, 77, 119, 211, 221, 116, 55, 2, 36, 85, 68, 244, 103, 126, 236, 211, 82, 207, 196, 94, 185, + 123, 235, 167, 254, 218, 207, 238, 158, 57, 117, 199, 173, 174, 122, 163, 187, 145, 132, 109, 36, 17, 17, 72, 66, 1, 229, 166, 170, 232, 42, 150, 101, + 97, 35, 51, 201, 76, 192, 216, 102, 206, 201, 172, 162, 102, 97, 27, 219, 116, 155, 89, 141, 9, 20, 73, 102, 98, 27, 236, 95, 191, 99, 127, 239, + 138, 228, 79, 70, 4, 82, 176, 97, 155, 141, 170, 162, 187, 145, 68, 68, 32, 9, 16, 27, 146, 201, 12, 34, 2, 99, 66, 242, 106, 140, 207, 239, + 140, 173, 139, 221, 205, 15, 34, 248, 1, 116, 55, 115, 206, 87, 109, 255, 65, 85, 97, 155, 238, 194, 54, 153, 129, 109, 108, 83, 221, 100, 38, 99, + 12, 70, 38, 238, 34, 34, 136, 16, 27, 182, 217, 176, 141, 36, 102, 21, 6, 237, 239, 237, 143, 91, 7, 183, 182, 218, 222, 118, 247, 142, 237, 157, + 238, 222, 221, 222, 222, 201, 136, 184, 32, 137, 238, 102, 195, 54, 223, 43, 51, 8, 137, 141, 144, 216, 144, 32, 66, 116, 53, 85, 13, 54, 17, 193, + 172, 162, 187, 176, 65, 17, 100, 14, 108, 51, 231, 164, 187, 89, 150, 229, 237, 49, 198, 111, 218, 125, 151, 34, 158, 224, 29, 6, 76, 119, 19, 33, + 50, 19, 219, 188, 71, 18, 18, 68, 8, 73, 188, 103, 100, 146, 153, 207, 85, 213, 23, 14, 79, 142, 216, 223, 221, 231, 137, 199, 158, 224, 195, 4, + 63, 128, 111, 60, 253, 7, 236, 237, 237, 28, 86, 213, 111, 42, 2, 219, 116, 27, 48, 235, 245, 194, 156, 147, 238, 98, 206, 133, 8, 97, 155, 234, + 162, 219, 116, 55, 182, 145, 132, 36, 54, 36, 241, 14, 9, 68, 108, 175, 86, 59, 221, 181, 211, 221, 187, 213, 189, 219, 221, 123, 93, 189, 7, 236, + 72, 186, 213, 221, 116, 55, 221, 205, 70, 85, 81, 53, 89, 150, 53, 27, 145, 73, 132, 136, 8, 186, 138, 170, 166, 170, 49, 32, 137, 118, 51, 231, + 66, 119, 179, 94, 175, 169, 154, 184, 155, 238, 166, 187, 169, 42, 214, 235, 53, 182, 127, 127, 103, 103, 231, 181, 234, 122, 56, 20, 143, 100, 38, 153, + 34, 51, 136, 0, 27, 108, 147, 153, 100, 38, 153, 137, 36, 34, 2, 73, 72, 34, 34, 136, 8, 86, 171, 45, 219, 253, 63, 175, 74, 231, 239, 216, + 63, 21, 1, 162, 139, 39, 30, 125, 156, 15, 50, 248, 1, 29, 159, 172, 177, 249, 39, 171, 149, 46, 71, 232, 110, 48, 115, 153, 84, 21, 85, 69, + 132, 144, 196, 178, 76, 170, 154, 57, 27, 69, 96, 68, 119, 1, 98, 195, 54, 221, 205, 70, 132, 88, 229, 216, 157, 85, 103, 203, 190, 233, 246, 176, + 157, 224, 180, 73, 64, 183, 29, 75, 162, 187, 89, 173, 86, 100, 38, 153, 9, 152, 110, 211, 109, 186, 155, 28, 3, 100, 54, 50, 147, 57, 39, 153, + 65, 68, 224, 54, 203, 178, 96, 64, 145, 116, 23, 221, 147, 110, 19, 17, 116, 21, 174, 62, 92, 229, 248, 178, 32, 192, 159, 24, 35, 239, 228, 54, + 219, 128, 145, 2, 137, 219, 154, 136, 68, 130, 8, 209, 13, 18, 72, 16, 17, 68, 136, 140, 68, 248, 27, 224, 255, 101, 108, 15, 149, 59, 64, 213, + 10, 132, 249, 32, 193, 15, 168, 219, 204, 89, 207, 44, 203, 242, 251, 85, 69, 119, 211, 54, 146, 200, 76, 34, 130, 80, 80, 93, 40, 68, 102, 50, + 198, 138, 13, 41, 176, 141, 36, 36, 33, 9, 219, 140, 28, 8, 206, 84, 213, 71, 220, 222, 177, 123, 215, 238, 221, 238, 222, 107, 247, 94, 119, 239, + 131, 182, 184, 77, 18, 153, 137, 36, 36, 81, 213, 8, 8, 9, 108, 150, 101, 97, 206, 66, 18, 221, 133, 109, 164, 96, 89, 47, 84, 55, 146, 176, + 161, 187, 169, 106, 230, 44, 230, 156, 84, 21, 115, 22, 221, 253, 252, 214, 106, 245, 74, 87, 239, 71, 198, 147, 153, 177, 189, 90, 37, 138, 32, 51, + 200, 12, 34, 130, 213, 106, 69, 132, 176, 27, 219, 100, 6, 146, 200, 76, 36, 200, 72, 34, 226, 176, 187, 255, 219, 17, 171, 215, 203, 29, 128, 16, + 18, 230, 195, 4, 63, 160, 170, 102, 127, 119, 235, 86, 119, 253, 67, 80, 71, 4, 171, 213, 138, 213, 24, 216, 166, 187, 105, 27, 41, 248, 94, 82, + 96, 27, 219, 108, 216, 198, 54, 239, 177, 57, 235, 246, 125, 118, 111, 87, 247, 110, 117, 239, 181, 189, 219, 221, 123, 213, 181, 111, 247, 25, 73, 68, + 4, 221, 77, 85, 81, 85, 68, 4, 57, 6, 198, 68, 136, 238, 162, 187, 1, 97, 131, 36, 106, 78, 102, 21, 33, 17, 145, 96, 179, 44, 11, 27, + 17, 129, 109, 54, 236, 94, 34, 226, 107, 72, 13, 156, 14, 197, 143, 75, 65, 230, 64, 130, 136, 96, 140, 65, 102, 32, 37, 17, 65, 102, 34, 137, + 8, 145, 153, 68, 36, 82, 16, 17, 216, 254, 130, 237, 47, 74, 4, 32, 254, 152, 0, 241, 65, 130, 31, 208, 179, 207, 254, 33, 199, 39, 107, 230, + 236, 95, 5, 206, 71, 4, 221, 77, 219, 100, 38, 54, 116, 55, 35, 19, 119, 35, 65, 132, 176, 139, 136, 32, 34, 168, 42, 108, 19, 17, 68, 4, + 182, 81, 232, 84, 211, 31, 45, 123, 167, 187, 119, 186, 189, 227, 238, 93, 119, 239, 85, 213, 190, 225, 78, 254, 72, 119, 35, 9, 73, 216, 166, 187, + 9, 5, 17, 193, 214, 214, 54, 91, 91, 91, 68, 136, 174, 98, 46, 11, 85, 69, 102, 98, 160, 187, 104, 27, 27, 170, 76, 85, 97, 155, 170, 194, + 246, 43, 91, 91, 91, 47, 218, 30, 202, 184, 127, 107, 103, 247, 209, 49, 182, 168, 134, 49, 182, 128, 4, 68, 68, 18, 33, 34, 146, 136, 224, 93, + 98, 53, 6, 35, 147, 145, 137, 224, 235, 180, 255, 235, 85, 172, 14, 176, 184, 205, 128, 217, 144, 248, 48, 193, 15, 161, 38, 220, 188, 113, 244, 98, + 85, 255, 74, 119, 51, 231, 68, 130, 238, 6, 76, 102, 0, 70, 226, 29, 221, 69, 102, 242, 30, 73, 68, 4, 27, 17, 65, 102, 18, 17, 163, 237, + 143, 119, 247, 142, 237, 29, 187, 119, 186, 122, 183, 187, 119, 186, 123, 223, 246, 221, 220, 38, 137, 136, 192, 54, 182, 145, 32, 4, 146, 168, 42, 236, + 6, 76, 85, 35, 9, 99, 12, 116, 55, 203, 178, 80, 85, 132, 2, 27, 36, 97, 131, 36, 230, 156, 5, 122, 42, 34, 142, 5, 219, 33, 61, 250, + 137, 79, 124, 226, 236, 125, 247, 63, 192, 131, 15, 62, 196, 24, 43, 238, 191, 255, 126, 246, 246, 246, 57, 125, 250, 12, 99, 172, 200, 76, 36, 17, + 17, 100, 38, 182, 1, 3, 62, 95, 213, 255, 77, 106, 188, 37, 148, 2, 27, 12, 24, 227, 173, 154, 216, 205, 7, 9, 126, 8, 221, 197, 233, 51, + 123, 93, 85, 191, 4, 92, 138, 8, 36, 129, 141, 219, 72, 194, 230, 29, 153, 9, 136, 238, 166, 187, 137, 8, 50, 147, 238, 102, 195, 54, 27, 153, + 73, 102, 126, 188, 230, 220, 119, 123, 203, 221, 219, 118, 111, 219, 222, 110, 247, 105, 73, 119, 74, 98, 67, 18, 153, 137, 36, 36, 33, 5, 221, 69, + 85, 99, 67, 68, 16, 17, 40, 2, 33, 186, 139, 154, 147, 170, 194, 134, 101, 153, 72, 162, 187, 177, 77, 85, 97, 251, 149, 213, 106, 245, 135, 64, + 70, 228, 174, 164, 211, 23, 46, 92, 200, 245, 250, 132, 157, 157, 29, 246, 246, 246, 184, 247, 222, 123, 57, 125, 250, 52, 247, 222, 123, 47, 71, 71, + 71, 204, 89, 68, 4, 171, 213, 138, 13, 73, 220, 246, 70, 205, 250, 69, 183, 223, 104, 247, 221, 192, 54, 82, 27, 186, 81, 163, 240, 58, 146, 115, + 175, 158, 231, 131, 36, 63, 132, 183, 47, 95, 230, 238, 187, 239, 98, 89, 47, 23, 115, 228, 227, 17, 241, 47, 118, 155, 28, 3, 69, 128, 33, 199, + 96, 86, 209, 93, 8, 48, 70, 10, 34, 130, 170, 34, 51, 169, 42, 222, 35, 137, 238, 118, 72, 191, 43, 81, 109, 111, 217, 94, 25, 70, 117, 223, + 135, 248, 87, 51, 115, 63, 51, 137, 8, 34, 2, 219, 100, 36, 153, 66, 18, 146, 144, 4, 134, 145, 9, 18, 216, 116, 155, 165, 38, 27, 85, 69, + 119, 19, 145, 116, 55, 238, 166, 103, 45, 192, 151, 86, 171, 213, 75, 66, 139, 4, 15, 62, 248, 208, 195, 183, 110, 222, 252, 204, 193, 193, 173, 184, + 118, 245, 42, 115, 78, 46, 95, 190, 204, 209, 209, 17, 87, 174, 92, 225, 228, 228, 4, 73, 140, 28, 8, 17, 138, 217, 246, 183, 215, 235, 229, 239, + 183, 121, 46, 20, 7, 138, 184, 21, 210, 77, 164, 99, 164, 6, 219, 152, 115, 175, 190, 194, 135, 73, 126, 72, 111, 189, 125, 153, 251, 30, 184, 175, + 221, 253, 122, 100, 254, 213, 64, 103, 109, 35, 160, 221, 84, 53, 203, 156, 132, 4, 152, 110, 131, 2, 219, 84, 21, 17, 129, 109, 186, 155, 204, 68, + 18, 85, 165, 219, 126, 39, 34, 14, 128, 149, 97, 24, 71, 187, 31, 31, 99, 252, 149, 213, 106, 53, 248, 35, 146, 144, 68, 102, 48, 198, 32, 51, + 145, 68, 68, 144, 17, 84, 55, 118, 83, 213, 72, 208, 109, 140, 233, 110, 218, 208, 109, 170, 138, 185, 44, 244, 236, 231, 182, 183, 183, 127, 45, 20, + 7, 130, 67, 164, 163, 204, 188, 188, 179, 189, 115, 243, 240, 224, 224, 12, 104, 107, 189, 94, 198, 178, 172, 181, 172, 23, 186, 155, 237, 237, 109, 86, + 171, 213, 146, 138, 91, 192, 185, 154, 243, 55, 150, 245, 252, 146, 164, 239, 100, 230, 91, 25, 113, 49, 35, 222, 82, 196, 117, 41, 22, 103, 88, 136, + 147, 48, 55, 175, 93, 231, 195, 12, 126, 4, 181, 76, 94, 120, 245, 252, 211, 79, 62, 241, 196, 223, 150, 244, 159, 27, 143, 57, 39, 109, 211, 110, + 50, 147, 141, 42, 131, 68, 40, 176, 77, 102, 82, 85, 100, 38, 221, 141, 109, 50, 19, 73, 219, 221, 125, 150, 228, 117, 64, 108, 152, 141, 135, 35, + 98, 123, 206, 73, 102, 18, 17, 100, 38, 146, 0, 209, 54, 33, 80, 4, 182, 81, 8, 170, 153, 101, 36, 81, 221, 44, 115, 98, 55, 221, 141, 20, + 72, 98, 163, 171, 15, 50, 243, 183, 71, 142, 171, 224, 35, 224, 8, 116, 120, 237, 234, 181, 183, 35, 116, 126, 172, 86, 95, 202, 200, 143, 2, 119, + 67, 110, 129, 19, 36, 33, 187, 250, 96, 218, 111, 185, 251, 34, 112, 101, 172, 198, 141, 80, 92, 85, 232, 74, 70, 92, 27, 210, 65, 75, 19, 133, + 163, 154, 151, 206, 159, 227, 7, 53, 248, 17, 92, 60, 127, 157, 79, 61, 246, 168, 151, 101, 249, 31, 86, 57, 254, 66, 142, 252, 119, 157, 1, 221, + 156, 172, 139, 8, 209, 221, 128, 200, 8, 20, 193, 178, 76, 108, 19, 17, 116, 55, 146, 136, 8, 186, 27, 73, 43, 236, 125, 65, 27, 10, 16, 144, + 146, 30, 1, 97, 55, 221, 77, 102, 82, 53, 137, 8, 198, 24, 96, 19, 49, 232, 46, 50, 18, 73, 68, 36, 166, 153, 115, 97, 89, 22, 54, 164, + 100, 195, 134, 101, 89, 179, 44, 11, 22, 95, 219, 217, 217, 121, 86, 161, 67, 208, 33, 112, 8, 28, 73, 58, 1, 234, 182, 55, 187, 251, 91, 66, + 72, 10, 133, 36, 48, 182, 5, 51, 34, 22, 101, 158, 32, 29, 11, 142, 20, 113, 28, 210, 90, 168, 44, 250, 47, 124, 234, 113, 254, 233, 115, 47, + 115, 238, 252, 43, 252, 48, 6, 63, 130, 123, 238, 63, 69, 157, 52, 63, 243, 115, 159, 188, 242, 91, 95, 120, 225, 63, 149, 185, 127, 53, 198, 95, + 70, 77, 196, 130, 0, 41, 16, 5, 18, 115, 22, 27, 146, 168, 42, 108, 19, 17, 140, 49, 144, 68, 85, 33, 41, 35, 2, 119, 79, 192, 183, 157, + 150, 244, 88, 102, 0, 38, 51, 129, 166, 187, 145, 192, 110, 148, 3, 48, 93, 197, 136, 100, 86, 209, 109, 186, 155, 101, 153, 44, 203, 66, 230, 138, + 136, 64, 50, 39, 39, 199, 44, 203, 66, 85, 189, 188, 183, 187, 247, 143, 34, 227, 26, 112, 44, 233, 16, 56, 4, 142, 129, 69, 82, 73, 154, 192, + 20, 154, 10, 77, 161, 10, 81, 146, 166, 164, 10, 152, 72, 37, 169, 128, 146, 84, 141, 220, 96, 117, 243, 181, 239, 92, 224, 149, 243, 175, 240, 195, + 74, 126, 4, 119, 157, 189, 19, 4, 231, 158, 125, 59, 14, 15, 214, 151, 35, 245, 117, 227, 79, 43, 244, 104, 68, 48, 171, 168, 154, 72, 65, 87, + 113, 199, 233, 51, 156, 57, 115, 134, 101, 89, 120, 228, 145, 71, 56, 58, 58, 226, 201, 39, 159, 228, 214, 173, 91, 252, 228, 79, 254, 36, 175, 191, + 254, 250, 113, 70, 252, 222, 24, 227, 138, 224, 4, 180, 238, 238, 79, 41, 227, 95, 143, 136, 149, 36, 50, 69, 102, 32, 137, 136, 32, 51, 16, 2, + 243, 142, 145, 131, 101, 153, 156, 172, 79, 0, 1, 166, 219, 204, 217, 204, 57, 145, 68, 119, 179, 44, 203, 173, 213, 106, 245, 75, 123, 187, 123, 207, + 6, 28, 41, 226, 86, 72, 7, 146, 14, 37, 29, 41, 98, 29, 138, 147, 144, 214, 82, 172, 35, 99, 137, 136, 69, 210, 58, 165, 69, 210, 18, 210, + 130, 52, 37, 77, 80, 129, 74, 33, 55, 197, 208, 224, 165, 243, 231, 184, 118, 245, 109, 126, 20, 131, 31, 153, 48, 246, 246, 206, 86, 156, 28, 215, + 51, 217, 245, 55, 35, 243, 63, 137, 204, 159, 3, 157, 18, 1, 134, 136, 100, 119, 119, 135, 199, 31, 127, 130, 91, 183, 110, 241, 227, 63, 254, 227, + 92, 186, 116, 137, 123, 239, 189, 151, 87, 207, 191, 202, 197, 55, 47, 50, 114, 220, 112, 247, 137, 164, 221, 200, 60, 176, 122, 161, 253, 185, 204, 177, + 27, 25, 224, 102, 140, 164, 170, 217, 144, 132, 13, 166, 129, 96, 140, 21, 179, 138, 200, 96, 197, 138, 170, 70, 10, 164, 192, 158, 116, 55, 182, 153, + 203, 82, 17, 241, 197, 83, 251, 251, 191, 19, 210, 145, 164, 35, 208, 145, 196, 17, 112, 2, 44, 66, 133, 84, 18, 133, 84, 192, 148, 212, 130, 146, + 84, 130, 66, 42, 65, 11, 25, 201, 220, 246, 157, 87, 206, 241, 39, 33, 249, 17, 156, 61, 123, 39, 33, 129, 4, 88, 10, 228, 230, 234, 156, 253, + 27, 93, 253, 124, 40, 238, 207, 200, 7, 164, 72, 110, 59, 58, 58, 164, 170, 185, 124, 249, 45, 230, 156, 92, 187, 118, 157, 27, 55, 110, 112, 116, + 120, 200, 229, 203, 151, 233, 234, 175, 142, 49, 158, 202, 136, 107, 146, 174, 172, 151, 245, 67, 18, 127, 51, 51, 239, 16, 38, 115, 176, 97, 131, 36, + 198, 72, 4, 140, 145, 116, 55, 182, 89, 150, 133, 89, 147, 238, 166, 219, 204, 89, 84, 21, 27, 221, 205, 122, 189, 118, 119, 255, 218, 233, 253, 83, + 191, 176, 26, 227, 154, 20, 7, 146, 110, 69, 198, 129, 164, 195, 144, 142, 36, 173, 35, 98, 157, 210, 146, 17, 235, 144, 214, 138, 152, 33, 45, 138, + 88, 80, 76, 164, 137, 212, 142, 52, 136, 151, 206, 159, 227, 202, 245, 107, 252, 73, 17, 63, 162, 187, 31, 122, 132, 51, 41, 12, 132, 20, 216, 1, + 72, 110, 150, 246, 67, 109, 255, 27, 134, 127, 39, 34, 126, 114, 246, 114, 186, 27, 173, 215, 39, 236, 238, 238, 114, 120, 116, 140, 128, 174, 238, 154, + 243, 247, 182, 183, 183, 127, 97, 123, 107, 251, 21, 227, 43, 93, 117, 180, 244, 252, 143, 87, 171, 213, 127, 180, 94, 175, 137, 8, 50, 19, 73, 128, + 217, 216, 218, 218, 194, 110, 50, 130, 110, 35, 137, 234, 102, 89, 22, 192, 84, 65, 119, 179, 81, 85, 156, 156, 156, 208, 221, 191, 115, 199, 254, 169, + 255, 106, 119, 119, 247, 2, 102, 65, 58, 150, 56, 1, 142, 5, 107, 73, 19, 104, 65, 133, 212, 64, 73, 106, 67, 11, 44, 100, 11, 115, 219, 75, + 231, 95, 225, 79, 139, 248, 255, 224, 241, 199, 158, 32, 49, 141, 144, 91, 216, 97, 8, 1, 182, 115, 153, 243, 158, 118, 127, 118, 186, 127, 234, 228, + 100, 253, 185, 49, 242, 225, 101, 153, 187, 64, 217, 190, 132, 249, 202, 222, 238, 238, 63, 94, 141, 241, 166, 205, 9, 176, 92, 189, 118, 245, 161, 159, + 248, 236, 79, 252, 143, 171, 173, 173, 79, 188, 250, 234, 121, 50, 147, 155, 55, 111, 145, 25, 116, 23, 146, 216, 222, 222, 38, 34, 16, 198, 134, 182, + 89, 150, 133, 170, 162, 170, 17, 162, 109, 132, 56, 62, 62, 242, 178, 204, 47, 239, 237, 237, 253, 23, 167, 246, 247, 95, 5, 166, 96, 45, 233, 4, + 233, 4, 88, 11, 166, 160, 5, 109, 169, 3, 89, 162, 185, 173, 52, 124, 237, 244, 3, 156, 190, 117, 137, 243, 47, 63, 207, 159, 54, 241, 39, 224, + 137, 71, 31, 167, 99, 69, 244, 130, 109, 9, 75, 16, 186, 109, 100, 82, 85, 99, 233, 222, 61, 62, 57, 57, 211, 213, 123, 17, 234, 49, 198, 173, + 213, 106, 117, 212, 221, 216, 14, 131, 70, 68, 95, 186, 114, 249, 167, 158, 120, 226, 137, 95, 60, 60, 60, 188, 227, 51, 159, 249, 12, 111, 188, 241, + 6, 27, 103, 207, 158, 229, 249, 231, 159, 231, 129, 7, 30, 224, 245, 215, 95, 35, 51, 176, 77, 85, 97, 155, 57, 155, 170, 162, 230, 36, 16, 182, + 89, 230, 156, 213, 245, 155, 251, 123, 251, 255, 221, 254, 222, 222, 183, 109, 31, 2, 235, 148, 22, 96, 45, 105, 1, 38, 96, 192, 128, 21, 233, 188, + 126, 139, 186, 243, 14, 190, 243, 242, 75, 252, 179, 54, 248, 19, 240, 242, 249, 115, 108, 124, 252, 177, 199, 177, 100, 57, 12, 182, 49, 235, 57, 5, + 56, 165, 121, 199, 222, 222, 77, 221, 102, 59, 170, 42, 220, 173, 128, 64, 82, 131, 70, 142, 14, 233, 198, 133, 11, 23, 214, 146, 184, 120, 241, 34, + 175, 190, 250, 42, 79, 62, 249, 36, 111, 189, 245, 22, 103, 206, 156, 225, 190, 251, 238, 227, 141, 55, 94, 163, 170, 144, 68, 119, 211, 93, 128, 136, + 8, 10, 49, 171, 152, 115, 94, 147, 244, 143, 78, 157, 186, 227, 151, 183, 183, 182, 222, 182, 221, 33, 221, 2, 142, 145, 166, 208, 148, 100, 41, 124, + 112, 120, 145, 83, 251, 15, 240, 194, 185, 23, 249, 99, 87, 47, 241, 255, 7, 241, 167, 232, 241, 71, 159, 224, 93, 6, 91, 41, 176, 45, 144, 192, + 226, 93, 178, 45, 64, 25, 193, 213, 27, 55, 118, 151, 154, 255, 153, 34, 254, 214, 169, 253, 253, 237, 131, 195, 67, 30, 120, 224, 1, 174, 95, 191, + 206, 238, 238, 46, 25, 201, 193, 225, 45, 186, 139, 238, 166, 109, 220, 13, 4, 85, 197, 92, 150, 195, 174, 126, 118, 140, 241, 27, 219, 219, 219, 223, + 202, 204, 75, 145, 121, 41, 35, 46, 14, 233, 42, 104, 177, 228, 163, 213, 142, 199, 92, 243, 221, 87, 94, 226, 207, 18, 241, 207, 208, 39, 31, 255, + 56, 118, 19, 26, 204, 94, 99, 54, 36, 113, 155, 13, 152, 207, 253, 216, 147, 254, 39, 95, 255, 189, 59, 142, 79, 78, 254, 58, 240, 243, 57, 198, + 231, 20, 186, 43, 51, 119, 186, 91, 171, 28, 108, 111, 111, 179, 94, 214, 172, 151, 5, 139, 118, 247, 81, 47, 117, 177, 219, 207, 103, 196, 211, 171, + 213, 234, 133, 28, 249, 86, 68, 92, 141, 136, 203, 17, 113, 57, 34, 174, 167, 98, 145, 18, 187, 121, 233, 252, 203, 252, 89, 36, 254, 140, 250, 220, + 103, 63, 199, 119, 95, 251, 238, 30, 240, 216, 241, 241, 241, 39, 247, 246, 246, 158, 152, 203, 124, 48, 35, 246, 70, 142, 81, 93, 89, 221, 199, 118, + 95, 150, 116, 33, 35, 223, 204, 204, 43, 17, 113, 32, 116, 168, 208, 77, 73, 183, 34, 226, 48, 164, 117, 219, 30, 17, 188, 116, 254, 21, 254, 44, + 19, 255, 28, 240, 23, 223, 64, 127, 237, 65, 62, 251, 233, 207, 228, 181, 27, 215, 87, 115, 206, 40, 125, 211, 16, 0, 0, 0, 35, 73, 68, 65, + 84, 149, 164, 204, 8, 133, 132, 13, 22, 190, 173, 132, 22, 133, 166, 164, 186, 251, 158, 143, 248, 248, 248, 136, 103, 158, 125, 134, 127, 94, 252, 223, + 160, 16, 125, 12, 251, 15, 241, 139, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130]) + + + export {testPng, testJpg} \ No newline at end of file diff --git a/multimedia/media/media_js_standard/audioDecoder/Test.json b/multimedia/media/media_js_standard/audioDecoder/Test.json index a668990d5b18edfb2b37c79d218ad5024041e958..e25486fa9ec9c78b674479dcfb4fc8ef8d201493 100644 --- a/multimedia/media/media_js_standard/audioDecoder/Test.json +++ b/multimedia/media/media_js_standard/audioDecoder/Test.json @@ -22,13 +22,12 @@ { "type": "ShellKit", "run-command": [ + "rm -R /data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiodecoder/results", "mkdir -p /data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiodecoder/results/", "chmod 777 -R /data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiodecoder", - "chmod 777 /data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiodecoder/*", - "setenforce 0" + "chmod 777 /data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audiodecoder/*" ], "teardown-command":[ - "setenforce 1" ] }, { diff --git a/multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderEnumTest.test.js b/multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderEnumTest.test.js index 255d3e7d39ea652a0e9c209e144353d546591918..d4ada052345b46ee57a5eae5d5f2fa5809ff6142 100644 --- a/multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderEnumTest.test.js +++ b/multimedia/media/media_js_standard/audioDecoder/src/main/js/test/AudioDecoderEnumTest.test.js @@ -184,14 +184,9 @@ describe('AudioDecoderEnum', function () { * @tc.level : Level0 */ it('SUB_MEDIA_AUDIO_DECODER_ENUM_CodecMimeType_0100', 0, async function (done) { - expect(media.CodecMimeType.AUDIO_AMR_NB).assertEqual('audio/3gpp'); - expect(media.CodecMimeType.AUDIO_AMR_WB).assertEqual('audio/amr-wb'); - expect(media.CodecMimeType.AUDIO_MPEG).assertEqual('audio/mpeg'); expect(media.CodecMimeType.AUDIO_AAC).assertEqual('audio/mp4a-latm'); expect(media.CodecMimeType.AUDIO_VORBIS).assertEqual('audio/vorbis'); - expect(media.CodecMimeType.AUDIO_OPUS).assertEqual('audio/opus'); expect(media.CodecMimeType.AUDIO_FLAC).assertEqual('audio/flac'); - expect(media.CodecMimeType.AUDIO_RAW).assertEqual('audio/raw'); done(); }) }) \ No newline at end of file diff --git a/multimedia/media/media_js_standard/audioEncoder/Test.json b/multimedia/media/media_js_standard/audioEncoder/Test.json index b62a060a506c7ba54baca3f54ebdcb813bd93248..dea08584c4e4fffff1fc9a42a2b0f4a4439d4e72 100644 --- a/multimedia/media/media_js_standard/audioEncoder/Test.json +++ b/multimedia/media/media_js_standard/audioEncoder/Test.json @@ -19,13 +19,12 @@ { "type": "ShellKit", "run-command": [ + "rm -R /data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/results", "mkdir -p /data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/results/", "chmod 777 -R /data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder", - "chmod 777 /data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/*", - "setenforce 0" + "chmod 777 /data/accounts/account_0/appdata/ohos.acts.multimedia.audio.audioencoder/*" ], "teardown-command":[ - "setenforce 1" ] }, { diff --git a/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioAPI.test.js b/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioAPI.test.js index ed359ce2e2051c98d2a7ffd0210dd5668293cf47..e246bd6e37e6ca18332075989d3ae221c4ba98f3 100644 --- a/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioAPI.test.js +++ b/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioAPI.test.js @@ -32,7 +32,7 @@ describe('RecorderLocalTestAudioAPI', function () { const SOURCE_TYPE = 1; const ENCORDER_AACLC = 3; const CHANNEL_TWO = 2; - const RECORDER_TIME = 1000; + const RECORDER_TIME = 3000; let fdPath; let fileAsset; let fdNumber; diff --git a/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioFUNC.test.js b/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioFUNC.test.js index b642f18a74d404b004d587efb6ee93ba45bcf9da..01c91211913ddd3c39733777807a3ebd84c6930a 100644 --- a/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioFUNC.test.js +++ b/multimedia/media/media_js_standard/audioRecorder/src/main/js/test/RecorderLocalTestAudioFUNC.test.js @@ -31,7 +31,7 @@ describe('RecorderLocalTestAudioFUNC', function () { const RESET_STATE = 6; const RELEASE_STATE = 7; const ERROR_STATE = 8; - const RECORDER_TIME = 1000; + const RECORDER_TIME = 3000; const CHANNEL_ONE = 1; const CHANNEL_TWO = 2; const FORMAT_MP4 = 2; diff --git a/multimedia/media/media_js_standard/videoDecoder/BUILD.gn b/multimedia/media/media_js_standard/videoDecoder/BUILD.gn index 221525ca01232dfe21c5f4f5568b1a78d638f8d5..8bb072212852ab76136869f84f11452dfe04a712 100644 --- a/multimedia/media/media_js_standard/videoDecoder/BUILD.gn +++ b/multimedia/media/media_js_standard/videoDecoder/BUILD.gn @@ -20,7 +20,7 @@ ohos_js_hap_suite("video_decoder_js_hap") { ":video_decoder_resources", ] certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "VideoDecoderJsTest" + hap_name = "ActsVideoDecoderJsTest" } ohos_js_assets("video_decoder_js_assets") { source_dir = "./src/main/js/default" diff --git a/multimedia/media/media_js_standard/videoDecoder/Test.json b/multimedia/media/media_js_standard/videoDecoder/Test.json index 9cffa6f1721499aee187f6954872ebe91b23f813..1597d451ac2c51b5244e919e17a92e5e8c6e6010 100644 --- a/multimedia/media/media_js_standard/videoDecoder/Test.json +++ b/multimedia/media/media_js_standard/videoDecoder/Test.json @@ -3,7 +3,7 @@ "driver": { "type": "JSUnitTest", "test-timeout": "2000000", - "package": "ohos.acts.multimedia.videodecoder", + "package": "ohos.acts.multimedia.video.videodecoder", "shell-timeout": "60000" }, "kits": [ @@ -12,26 +12,24 @@ "pre-push": [ ], "push": [ - "./resource/media/es/out_1920_1080_30fps_3s.h264 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/", - "./resource/media/es/h263_1408_1152.es ->/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/", - "./resource/media/es/MPEG2_720_480.es ->/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/", - "./resource/media/es/mpeg4_320_240.es ->/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/", - "./resource/media/es/out_320_240_10s.h264 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/" + "./resource/media/es/out_1920_1080_30fps_3s.h264 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/", + "./resource/media/es/h263_1408_1152.es ->/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/", + "./resource/media/es/MPEG2_720_480.es ->/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/", + "./resource/media/es/mpeg4_320_240.es ->/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/", + "./resource/media/es/out_320_240_10s.h264 ->/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/" ] }, { "type": "ShellKit", "run-command": [ - "mkdir -p /data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/", - "setenforce 0" + "mkdir -p /data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/" ], "teardown-command":[ - "setenforce 1" ] }, { "test-file-name": [ - "MediaVideoDecoderJsTest.hap" + "ActsVideoDecoderJsTest.hap" ], "type": "AppInstallKit", "cleanup-apps": true diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/config.json b/multimedia/media/media_js_standard/videoDecoder/src/main/config.json index 47d898fd6b7b3364c9658f0f8663ebbb477d7223..55c8b32a6cb68bdaab164fc98474746455bea8aa 100644 --- a/multimedia/media/media_js_standard/videoDecoder/src/main/config.json +++ b/multimedia/media/media_js_standard/videoDecoder/src/main/config.json @@ -6,7 +6,7 @@ "target": 7 }, "vendor": "acts", - "bundleName": "ohos.acts.multimedia.videodecoder", + "bundleName": "ohos.acts.multimedia.video.videodecoder", "version": { "code": 1000000, "name": "1.0.0" @@ -35,7 +35,7 @@ "visible": true, "labelId": 16777216, "icon": "$media:icon", - "name": "ohos.acts.multimedia.videodecoder.MainAbility", + "name": "ohos.acts.multimedia.video.videodecoder.MainAbility", "description": "$string:mainability_description", "label": "$string:entry_MainAbility", "type": "page", @@ -49,14 +49,14 @@ "tv", "wearable" ], - "mainAbility": "ohos.acts.multimedia.videodecoder.MainAbility", + "mainAbility": "ohos.acts.multimedia.video.videodecoder.MainAbility", "distro": { "moduleType": "entry", "installationFree": false, "deliveryWithInstall": true, "moduleName": "entry" }, - "package": "ohos.acts.multimedia.videodecoder", + "package": "ohos.acts.multimedia.video.videodecoder", "name": ".MyApplication", "js": [ { diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderEnumTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderEnumTest.test.js index 9853bbb8829d9eec5ccd033f8fe7f806b3f6c1f7..6c2ac9bf254f696969cce4d1feedd90d1f465a38 100644 --- a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderEnumTest.test.js +++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderEnumTest.test.js @@ -15,6 +15,7 @@ import media from '@ohos.multimedia.media' import Fileio from '@ohos.fileio' +import router from '@system.router' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' @@ -32,17 +33,21 @@ describe('VideoDecoderEnum', function () { let surfaceID = ''; const events = require('events'); const eventEmitter = new events.EventEmitter(); - const BASIC_PATH = '/data/media/'; + const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/'; let ES_FRAME_SIZE = []; - const H264_FRAME_SIZE_30FPS_1080 = - [ 3491, 115184]; + const H264_FRAME_SIZE_60FPS_320 = + [ 2106, 11465]; beforeAll(function() { console.info('beforeAll case'); // getSurfaceID(); }) - beforeEach(function() { + beforeEach(async function() { console.info('beforeEach case'); + await toDisplayPage().then(() => { + }, failCallback).catch(failCatch); + await msleep(1000).then(() => { + }, failCallback).catch(failCatch); frameCountIn = 0; frameCountOut = 0; timestamp = 0; @@ -50,6 +55,7 @@ describe('VideoDecoderEnum', function () { outputQueue = []; isCodecData = false; inputEosFlag = false; + surfaceID = globalThis.value; }) afterEach(async function() { @@ -60,14 +66,11 @@ describe('VideoDecoderEnum', function () { }, failCallback).catch(failCatch); videoDecodeProcessor = null; } - if (videoPlayer != null) { - await videoPlayer.release().then(() => { - console.info('in case : videoPlayer release success'); - }, failCallback).catch(failCatch); - videoPlayer = null; - } + await router.clear().then(() => { + }, failCallback).catch(failCatch); }) + afterAll(function() { console.info('afterAll case'); }) @@ -90,6 +93,22 @@ describe('VideoDecoderEnum', function () { } } + function msleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); + } + + async function toDisplayPage() { + let path = 'pages/display/display'; + let options = { + uri: path, + } + try { + await router.push(options); + } catch (e) { + console.error('in case toDisplayPage' + e); + } + } + function getContent(buf, len) { console.info('start get content, len ' + len + ' buf.byteLength ' + buf.byteLength); let lengthReal = -1; @@ -293,52 +312,30 @@ describe('VideoDecoderEnum', function () { }, failCallback).catch(failCatch); } - /* * - * @tc.number : SUB_MEDIA_VIDEO_DECODER_ENUM_AVCProfile_0100 - * @tc.name : 001.AVCProfile - * @tc.desc : Test Enumerate AVCProfile - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level0 - */ - it('SUB_MEDIA_VIDEO_DECODER_ENUM_AVCProfile_0100', 0, async function (done) { - expect(media.AVCProfile.AVC_PROFILE_BASELINE).assertEqual(0); - expect(media.AVCProfile.AVC_PROFILE_CONSTRAINED_BASELINE).assertEqual(1); - expect(media.AVCProfile.AVC_PROFILE_CONSTRAINED_HIGH).assertEqual(2); - expect(media.AVCProfile.AVC_PROFILE_EXTENDED).assertEqual(3); - expect(media.AVCProfile.AVC_PROFILE_HIGH).assertEqual(4); - expect(media.AVCProfile.AVC_PROFILE_HIGH_10).assertEqual(5); - expect(media.AVCProfile.AVC_PROFILE_HIGH_422).assertEqual(6); - expect(media.AVCProfile.AVC_PROFILE_HIGH_444).assertEqual(7); - expect(media.AVCProfile.AVC_PROFILE_MAIN).assertEqual(8); - done(); - }) - /* * * @tc.number : SUB_MEDIA_VIDEO_DECODER_ENUM_CodecBuffer_0100 - * @tc.name : 002.CodecBuffer + * @tc.name : 001.CodecBuffer * @tc.desc : Test Interface CodecBuffer * @tc.size : MediumTest * @tc.type : Function test * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_DECODER_ENUM_CodecBuffer_0100', 0, async function (done) { - ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080; + ES_FRAME_SIZE = H264_FRAME_SIZE_60FPS_320; isCodecData = true; - let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264'; + let srcPath = BASIC_PATH + 'out_320_240_10s.h264'; let mediaDescription = { 'track_type': 1, 'codec_mime': 'video/avc', - 'width': 1920, - 'height': 1080, + 'width': 320, + 'height': 240, 'pixel_format': 4, - 'frame_rate': 30.00, + 'frame_rate': 60.00, 'max_input_size': 150000, } await toCreateVideoDecoderByMime('video/avc', done); await toGetVideoDecoderCaps(); await toConfigure(mediaDescription, srcPath); - await setSurfaceID(done); await toSetOutputSurface(true); setCallback( function(){eventEmitter.emit('nextStep', done);} @@ -349,7 +346,7 @@ describe('VideoDecoderEnum', function () { /* * * @tc.number : SUB_MEDIA_VIDEO_DECODER_ENUM_CodecMimeType_0100 - * @tc.name : 003.CodecMimeType + * @tc.name : 002.CodecMimeType * @tc.desc : Test Enumerate CodecMimeType * @tc.size : MediumTest * @tc.type : Function test @@ -359,107 +356,9 @@ describe('VideoDecoderEnum', function () { expect(media.CodecMimeType.VIDEO_H263).assertEqual('video/h263'); expect(media.CodecMimeType.VIDEO_AVC).assertEqual('video/avc'); expect(media.CodecMimeType.VIDEO_MPEG2).assertEqual('video/mpeg2'); - expect(media.CodecMimeType.VIDEO_HEVC).assertEqual('video/hevc'); expect(media.CodecMimeType.VIDEO_MPEG4).assertEqual('video/mp4v-es'); expect(media.CodecMimeType.VIDEO_VP8).assertEqual('video/x-vnd.on2.vp8'); - expect(media.CodecMimeType.VIDEO_VP9).assertEqual('video/x-vnd.on2.vp9'); - done(); - }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_DECODER_ENUM_H263Profile_0100 - * @tc.name : 004.H263Profile - * @tc.desc : Test Enumerate H263Profile - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level0 - */ - it('SUB_MEDIA_VIDEO_DECODER_ENUM_H263Profile_0100', 0, async function (done) { - expect(media.H263Profile.H263_PROFILE_BACKWARD_COMPATIBLE).assertEqual(0); - expect(media.H263Profile.H263_PROFILE_BASELINE).assertEqual(1); - expect(media.H263Profile.H263_PROFILE_H320_CODING).assertEqual(2); - expect(media.H263Profile.H263_PROFILE_HIGH_COMPRESSION).assertEqual(3); - expect(media.H263Profile.H263_PROFILE_HIGH_LATENCY).assertEqual(4); - expect(media.H263Profile.H263_PROFILE_ISW_V2).assertEqual(5); - expect(media.H263Profile.H263_PROFILE_ISW_V3).assertEqual(6); - expect(media.H263Profile.H263_PROFILE_INTERLACE).assertEqual(7); - expect(media.H263Profile.H263_PROFILE_INTERNET).assertEqual(8); done(); }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_DECODER_ENUM_MPEG2Profile_0100 - * @tc.name : 006.MPEG2Profile - * @tc.desc : Test Enumerate MPEG2Profile - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level0 - */ - it('SUB_MEDIA_VIDEO_DECODER_ENUM_MPEG2Profile_0100', 0, async function (done) { - expect(media.MPEG2Profile.MPEG2_PROFILE_422).assertEqual(0); - expect(media.MPEG2Profile.MPEG2_PROFILE_HIGH).assertEqual(1); - expect(media.MPEG2Profile.MPEG2_PROFILE_MAIN).assertEqual(2); - expect(media.MPEG2Profile.MPEG2_PROFILE_SNR).assertEqual(3); - expect(media.MPEG2Profile.MPEG2_PROFILE_SIMPLE).assertEqual(4); - expect(media.MPEG2Profile.MPEG2_PROFILE_SPATIAL).assertEqual(5); - done(); - }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_DECODER_ENUM_MPEG4Profile_0100 - * @tc.name : 007.MPEG4Profile - * @tc.desc : Test Enumerate MPEG4Profile - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level0 - */ - it('SUB_MEDIA_VIDEO_DECODER_ENUM_MPEG4Profile_0100', 0, async function (done) { - expect(media.MPEG4Profile.MPEG4_PROFILE_ADVANCED_CODING).assertEqual(0); - expect(media.MPEG4Profile.MPEG4_PROFILE_ADVANCED_CORE).assertEqual(1); - expect(media.MPEG4Profile.MPEG4_PROFILE_ADVANCED_REAL_TIME).assertEqual(2); - expect(media.MPEG4Profile.MPEG4_PROFILE_ADVANCED_SCALABLE).assertEqual(3); - expect(media.MPEG4Profile.MPEG4_PROFILE_ADVANCED_SIMPLE).assertEqual(4); - expect(media.MPEG4Profile.MPEG4_PROFILE_BASIC_ANIMATED).assertEqual(5); - expect(media.MPEG4Profile.MPEG4_PROFILE_CORE).assertEqual(6); - expect(media.MPEG4Profile.MPEG4_PROFILE_CORE_SCALABLE).assertEqual(7); - expect(media.MPEG4Profile.MPEG4_PROFILE_HYBRID).assertEqual(8); - expect(media.MPEG4Profile.MPEG4_PROFILE_MAIN).assertEqual(9); - expect(media.MPEG4Profile.MPEG4_PROFILE_NBIT).assertEqual(10); - expect(media.MPEG4Profile.MPEG4_PROFILE_SCALABLE_TEXXTURE).assertEqual(11); - expect(media.MPEG4Profile.MPEG4_PROFILE_SIMPLE).assertEqual(12); - expect(media.MPEG4Profile.MPEG4_PROFILE_SIMPLE_FBA).assertEqual(13); - expect(media.MPEG4Profile.MPEG4_PROFILE_SIMPLE_FACE).assertEqual(14); - expect(media.MPEG4Profile.MPEG4_PROFILE_SIMPLE_SCALABLE).assertEqual(15); - done(); - }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_DECODER_ENUM_VideoPixelFormat_0100 - * @tc.name : 009.VideoPixelFormat - * @tc.desc : Test Enumerate VideoPixelFormat - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level0 - */ - it('SUB_MEDIA_VIDEO_DECODER_ENUM_VideoPixelFormat_0100', 0, async function (done) { - expect(media.VideoPixelFormat.YUVI420).assertEqual(1); - expect(media.VideoPixelFormat.NV12).assertEqual(2); - expect(media.VideoPixelFormat.NV21).assertEqual(3); - expect(media.VideoPixelFormat.SURFACE_FORMAT).assertEqual(4); - done(); - }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_DECODER_ENUM_VP8Profile_0100 - * @tc.name : 010.VP8Profile - * @tc.desc : Test Enumerate VP8Profile - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level0 - */ - it('SUB_MEDIA_VIDEO_DECODER_ENUM_VP8Profile_0100', 0, async function (done) { - expect(media.VP8Profile.VP8_PROFILE_MAIN).assertEqual(0); - done(); - }) }) diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncCallbackTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncCallbackTest.test.js index 4fc7a63f66b97576b3dd3c2f45bc25056e27b1cf..f67f03ef82b1c72409c5089b50aee0ebff406635 100644 --- a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncCallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncCallbackTest.test.js @@ -31,15 +31,24 @@ describe('VideoDecoderFuncCallbackTest', function () { let surfaceID = ''; const events = require('events'); const eventEmitter = new events.EventEmitter(); - const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/'; + const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/'; let ES_FRAME_SIZE = []; - const H264_FRAME_SIZE_30FPS_1080 = - [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463, - 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784, - 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935, - 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277, - 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785, - 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937]; + const H264_FRAME_SIZE_60FPS_320 = + [ 2106, 11465, 321, 72, 472, 68, 76, 79, 509, 90, 677, 88, 956, 99, 347, 77, 452, 681, 81, 1263, 94, 106, 97, + 998, 97, 797, 93, 1343, 150, 116, 117, 926, 1198, 128, 110, 78, 1582, 158, 135, 112, 1588, 165, 132, + 128, 1697, 168, 149, 117, 1938, 170, 141, 142, 1830, 106, 161, 122, 1623, 160, 154, 156, 1998, 230, + 177, 139, 1650, 186, 128, 134, 1214, 122, 1411, 120, 1184, 128, 1591, 195, 145, 105, 1587, 169, 140, + 118, 1952, 177, 150, 161, 1437, 159, 123, 1758, 180, 165, 144, 1936, 214, 191, 175, 2122, 180, 179, + 160, 1927, 161, 184, 119, 1973, 218, 210, 129, 1962, 196, 127, 154, 2308, 173, 127, 1572, 142, 122, + 2065, 262, 159, 206, 2251, 269, 179, 170, 2056, 308, 168, 191, 2090, 303, 191, 110, 1932, 272, 162, + 122, 1877, 245, 167, 141, 1908, 294, 162, 118, 1493, 132, 1782, 273, 184, 133, 1958, 274, 180, 149, + 2070, 216, 169, 143, 1882, 224, 149, 139, 1749, 277, 184, 139, 2141, 197, 170, 140, 2002, 269, 162, + 140, 1862, 202, 179, 131, 1868, 214, 164, 140, 1546, 226, 150, 130, 1707, 162, 146, 1824, 181, 147, + 130, 1898, 209, 143, 131, 1805, 180, 148, 106, 1776, 147, 141, 1572, 177, 130, 105, 1776, 178, 144, + 122, 1557, 142, 124, 114, 1436, 143, 126, 1326, 127, 1755, 169, 127, 105, 1807, 177, 131, 134, 1613, + 187, 137, 136, 1314, 134, 118, 2005, 194, 129, 147, 1566, 185, 132, 131, 1236, 174, 137, 106, 11049, + 574, 126, 1242, 188, 130, 119, 1450, 187, 137, 141, 1116, 124, 1848, 138, 122, 1605, 186, 127, 140, + 1798, 170, 124, 121, 1666, 157, 128, 130, 1678, 135, 118, 1804, 169, 135, 125, 1837, 168, 124, 124]; const H263_FRAME_SIZE = [ 96618, 3515, 4132, 4336, 4646, 3497, 4430, 5437, 7560, 4613, 4876, 4734, 53617, 4079, 4507, 5222, 6244, 5843, 6601, 6622, 6751, 6539, 7666, 7706, 53977, 7311, 12906, 10308, 26791, 15983, 34794, 22110, 37165, @@ -122,13 +131,16 @@ describe('VideoDecoderFuncCallbackTest', function () { console.info(`in case error failCallback called, errMessage is ${error.message}`); expect(err).assertUndefined(); } + let failCatch = function(err) { console.info(`in case error failCatch called,errMessage is ${error.message}`); expect(err).assertUndefined(); } + function msleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); } + async function toDisplayPage() { let path = 'pages/display/display'; let options = { @@ -140,6 +152,7 @@ describe('VideoDecoderFuncCallbackTest', function () { console.error('in case toDisplayPage' + e); } } + function readFile(path){ console.info('in case : read file start execution'); try { @@ -343,51 +356,19 @@ describe('VideoDecoderFuncCallbackTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_DECODER_H264_CALLBACK_0100', 0, async function (done) { - ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080; + ES_FRAME_SIZE = H264_FRAME_SIZE_60FPS_320; isCodecData = true; - let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264'; + let srcPath = BASIC_PATH + 'out_320_240_10s.h264'; let mediaDescription = { 'track_type': 1, 'codec_mime': 'video/avc', - 'width': 1920, - 'height': 1080, - 'pixel_format': 4, - 'frame_rate': 30.00, - 'max_input_size': 150000, - } - media.createVideoDecoderByMime('video/avc', (err, processor) => { - expect(err).assertUndefined(); - console.info('in case : createVideoDecoderByMime success'); - videoDecodeProcessor = processor; - eventEmitter.emit('configure', mediaDescription, srcPath, - function() { - eventEmitter.emit('stop', done); - }, - done); - }); - }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_DECODER_H263_CALLBACK_0100 - * @tc.name : 001.basic Video decode function - * @tc.desc : start-> EOS -> stop -> reset - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level0 - */ - it('SUB_MEDIA_VIDEO_DECODER_H263_CALLBACK_0100', 0, async function (done) { - ES_FRAME_SIZE = H263_FRAME_SIZE; - let srcPath = BASIC_PATH + 'h263_1408_1152.es'; - let mediaDescription = { - 'track_type': 1, - 'codec_mime': 'video/h263', - 'width': 1408, - 'height': 1152, + 'width': 320, + 'height': 240, 'pixel_format': 4, 'frame_rate': 60.00, 'max_input_size': 150000, } - media.createVideoDecoderByMime('video/h263', (err, processor) => { + media.createVideoDecoderByMime('video/avc', (err, processor) => { expect(err).assertUndefined(); console.info('in case : createVideoDecoderByMime success'); videoDecodeProcessor = processor; diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncPromiseTest.test.js index 0466853560d1e2fc31d7e755144a69104be82952..2abefa06ac4664459139a85d11d0ae06726d6fa3 100644 --- a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncPromiseTest.test.js +++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderFuncPromiseTest.test.js @@ -32,15 +32,24 @@ describe('VideoDecoderFuncPromiseTest', function () { let surfaceID = ''; const events = require('events'); const eventEmitter = new events.EventEmitter(); - const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/'; + const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/'; let ES_FRAME_SIZE = []; - const H264_FRAME_SIZE_30FPS_1080 = - [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463, - 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784, - 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935, - 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277, - 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785, - 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937]; + const H264_FRAME_SIZE_60FPS_320 = + [ 2106, 11465, 321, 72, 472, 68, 76, 79, 509, 90, 677, 88, 956, 99, 347, 77, 452, 681, 81, 1263, 94, 106, 97, + 998, 97, 797, 93, 1343, 150, 116, 117, 926, 1198, 128, 110, 78, 1582, 158, 135, 112, 1588, 165, 132, + 128, 1697, 168, 149, 117, 1938, 170, 141, 142, 1830, 106, 161, 122, 1623, 160, 154, 156, 1998, 230, + 177, 139, 1650, 186, 128, 134, 1214, 122, 1411, 120, 1184, 128, 1591, 195, 145, 105, 1587, 169, 140, + 118, 1952, 177, 150, 161, 1437, 159, 123, 1758, 180, 165, 144, 1936, 214, 191, 175, 2122, 180, 179, + 160, 1927, 161, 184, 119, 1973, 218, 210, 129, 1962, 196, 127, 154, 2308, 173, 127, 1572, 142, 122, + 2065, 262, 159, 206, 2251, 269, 179, 170, 2056, 308, 168, 191, 2090, 303, 191, 110, 1932, 272, 162, + 122, 1877, 245, 167, 141, 1908, 294, 162, 118, 1493, 132, 1782, 273, 184, 133, 1958, 274, 180, 149, + 2070, 216, 169, 143, 1882, 224, 149, 139, 1749, 277, 184, 139, 2141, 197, 170, 140, 2002, 269, 162, + 140, 1862, 202, 179, 131, 1868, 214, 164, 140, 1546, 226, 150, 130, 1707, 162, 146, 1824, 181, 147, + 130, 1898, 209, 143, 131, 1805, 180, 148, 106, 1776, 147, 141, 1572, 177, 130, 105, 1776, 178, 144, + 122, 1557, 142, 124, 114, 1436, 143, 126, 1326, 127, 1755, 169, 127, 105, 1807, 177, 131, 134, 1613, + 187, 137, 136, 1314, 134, 118, 2005, 194, 129, 147, 1566, 185, 132, 131, 1236, 174, 137, 106, 11049, + 574, 126, 1242, 188, 130, 119, 1450, 187, 137, 141, 1116, 124, 1848, 138, 122, 1605, 186, 127, 140, + 1798, 170, 124, 121, 1666, 157, 128, 130, 1678, 135, 118, 1804, 169, 135, 125, 1837, 168, 124, 124]; const H263_FRAME_SIZE = [ 96618, 3515, 4132, 4336, 4646, 3497, 4430, 5437, 7560, 4613, 4876, 4734, 53617, 4079, 4507, 5222, 6244, 5843, 6601, 6622, 6751, 6539, 7666, 7706, 53977, 7311, 12906, 10308, 26791, 15983, 34794, 22110, 37165, @@ -341,50 +350,19 @@ describe('VideoDecoderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_DECODER_H264_PROMISE_0100', 0, async function (done) { - ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080; + ES_FRAME_SIZE = H264_FRAME_SIZE_60FPS_320; isCodecData = true; - let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264'; + let srcPath = BASIC_PATH + 'out_320_240_10s.h264'; let mediaDescription = { 'track_type': 1, 'codec_mime': 'video/avc', - 'width': 1920, - 'height': 1080, - 'pixel_format': 4, - 'frame_rate': 30.00, - 'max_input_size': 150000, - } - await toCreateVideoDecoderByMime('video/avc', done); - await toGetVideoDecoderCaps(); - await toConfigure(mediaDescription, srcPath); - await toSetOutputSurface(true); - setCallback( - function(){eventEmitter.emit('nextStep', done);} - ); - await toPrepare(); - await toStart(); - }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_DECODER_H263_PROMISE_0100 - * @tc.name : 001.basic Video decode function - * @tc.desc : start-> EOS -> stop -> reset - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level0 - */ - it('SUB_MEDIA_VIDEO_DECODER_H263_PROMISE_0100', 0, async function (done) { - ES_FRAME_SIZE = H263_FRAME_SIZE; - let srcPath = BASIC_PATH + 'h263_1408_1152.es'; - let mediaDescription = { - 'track_type': 1, - 'codec_mime': 'video/h263', - 'width': 1408, - 'height': 1152, + 'width': 320, + 'height': 240, 'pixel_format': 4, 'frame_rate': 60.00, 'max_input_size': 150000, } - await toCreateVideoDecoderByMime('video/h263', done); + await toCreateVideoDecoderByMime('video/avc', done); await toGetVideoDecoderCaps(); await toConfigure(mediaDescription, srcPath); await toSetOutputSurface(true); @@ -466,16 +444,16 @@ describe('VideoDecoderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_DECODER_MULTIINSTANCE_PROMISE_0100', 0, async function (done) { - ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080; + ES_FRAME_SIZE = H264_FRAME_SIZE_60FPS_320; isCodecData = true; - let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264'; + let srcPath = BASIC_PATH + 'out_320_240_10s.h264'; let mediaDescription = { 'track_type': 1, 'codec_mime': 'video/avc', - 'width': 1920, - 'height': 1080, + 'width': 320, + 'height': 240, 'pixel_format': 4, - 'frame_rate': 30.00, + 'frame_rate': 60.00, 'max_input_size': 150000, } let array = new Array(); diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliCallbackTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliCallbackTest.test.js index f5cbc5228a6ffa1e1cd8cb53c5dfe7d75b271ad1..0ef3478d564148726b73f49519e92549427ef2f1 100644 --- a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliCallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliCallbackTest.test.js @@ -46,26 +46,34 @@ describe('VideoDecoderReliCallbackTest', function () { let inputEosFlag = false; let workdoneAtEOS = false; let surfaceID = ''; - const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/'; - const SRCPATH = BASIC_PATH + 'out_1920_1080_30fps_3s.h264'; + const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/'; + const SRCPATH = BASIC_PATH + 'out_320_240_10s.h264'; let mediaDescription = { 'track_type': 1, 'codec_mime': 'video/avc', - 'width': 1920, - 'height': 1080, + 'width': 320, + 'height': 240, 'pixel_format': 4, - 'frame_rate': 30, + 'frame_rate': 60, 'max_input_size': 150000, } - - const H264_FRAME_SIZE_30FPS_1080 = - [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463, - 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784, - 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935, - 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277, - 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785, - 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937]; - let ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080; + const H264_FRAME_SIZE_60FPS_320 = + [ 2106, 11465, 321, 72, 472, 68, 76, 79, 509, 90, 677, 88, 956, 99, 347, 77, 452, 681, 81, 1263, 94, 106, 97, + 998, 97, 797, 93, 1343, 150, 116, 117, 926, 1198, 128, 110, 78, 1582, 158, 135, 112, 1588, 165, 132, + 128, 1697, 168, 149, 117, 1938, 170, 141, 142, 1830, 106, 161, 122, 1623, 160, 154, 156, 1998, 230, + 177, 139, 1650, 186, 128, 134, 1214, 122, 1411, 120, 1184, 128, 1591, 195, 145, 105, 1587, 169, 140, + 118, 1952, 177, 150, 161, 1437, 159, 123, 1758, 180, 165, 144, 1936, 214, 191, 175, 2122, 180, 179, + 160, 1927, 161, 184, 119, 1973, 218, 210, 129, 1962, 196, 127, 154, 2308, 173, 127, 1572, 142, 122, + 2065, 262, 159, 206, 2251, 269, 179, 170, 2056, 308, 168, 191, 2090, 303, 191, 110, 1932, 272, 162, + 122, 1877, 245, 167, 141, 1908, 294, 162, 118, 1493, 132, 1782, 273, 184, 133, 1958, 274, 180, 149, + 2070, 216, 169, 143, 1882, 224, 149, 139, 1749, 277, 184, 139, 2141, 197, 170, 140, 2002, 269, 162, + 140, 1862, 202, 179, 131, 1868, 214, 164, 140, 1546, 226, 150, 130, 1707, 162, 146, 1824, 181, 147, + 130, 1898, 209, 143, 131, 1805, 180, 148, 106, 1776, 147, 141, 1572, 177, 130, 105, 1776, 178, 144, + 122, 1557, 142, 124, 114, 1436, 143, 126, 1326, 127, 1755, 169, 127, 105, 1807, 177, 131, 134, 1613, + 187, 137, 136, 1314, 134, 118, 2005, 194, 129, 147, 1566, 185, 132, 131, 1236, 174, 137, 106, 11049, + 574, 126, 1242, 188, 130, 119, 1450, 187, 137, 141, 1116, 124, 1848, 138, 122, 1605, 186, 127, 140, + 1798, 170, 124, 121, 1666, 157, 128, 130, 1678, 135, 118, 1804, 169, 135, 125, 1837, 168, 124, 124]; + let ES_FRAME_SIZE = H264_FRAME_SIZE_60FPS_320; beforeAll(function() { console.info('beforeAll case'); }) diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliPromiseTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliPromiseTest.test.js index 82825c3f64ca89a5d9ccc72e5c6b48c2eab2dbc9..606a3c2f2f657b6f671c27e5ff07c0c4138908b2 100644 --- a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliPromiseTest.test.js +++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderReliPromiseTest.test.js @@ -46,25 +46,34 @@ describe('VideoDecoderReliPromiseTest', function () { let inputEosFlag = false; let workdoneAtEOS = false; let surfaceID = ''; - const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/'; - const SRCPATH = BASIC_PATH + 'out_1920_1080_30fps_3s.h264'; + const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/'; + const SRCPATH = BASIC_PATH + 'out_320_240_10s.h264'; let mediaDescription = { 'track_type': 1, 'codec_mime': 'video/avc', - 'width': 1920, - 'height': 1080, + 'width': 320, + 'height': 240, 'pixel_format': 4, - 'frame_rate': 30, + 'frame_rate': 60, 'max_input_size': 150000, } - const H264_FRAME_SIZE_30FPS_1080 = - [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463, - 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784, - 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935, - 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277, - 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785, - 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937]; - let ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080; + const H264_FRAME_SIZE_60FPS_320 = + [2106, 11465, 321, 72, 472, 68, 76, 79, 509, 90, 677, 88, 956, 99, 347, 77, 452, 681, 81, 1263, 94, 106, 97, + 998, 97, 797, 93, 1343, 150, 116, 117, 926, 1198, 128, 110, 78, 1582, 158, 135, 112, 1588, 165, 132, + 128, 1697, 168, 149, 117, 1938, 170, 141, 142, 1830, 106, 161, 122, 1623, 160, 154, 156, 1998, 230, + 177, 139, 1650, 186, 128, 134, 1214, 122, 1411, 120, 1184, 128, 1591, 195, 145, 105, 1587, 169, 140, + 118, 1952, 177, 150, 161, 1437, 159, 123, 1758, 180, 165, 144, 1936, 214, 191, 175, 2122, 180, 179, + 160, 1927, 161, 184, 119, 1973, 218, 210, 129, 1962, 196, 127, 154, 2308, 173, 127, 1572, 142, 122, + 2065, 262, 159, 206, 2251, 269, 179, 170, 2056, 308, 168, 191, 2090, 303, 191, 110, 1932, 272, 162, + 122, 1877, 245, 167, 141, 1908, 294, 162, 118, 1493, 132, 1782, 273, 184, 133, 1958, 274, 180, 149, + 2070, 216, 169, 143, 1882, 224, 149, 139, 1749, 277, 184, 139, 2141, 197, 170, 140, 2002, 269, 162, + 140, 1862, 202, 179, 131, 1868, 214, 164, 140, 1546, 226, 150, 130, 1707, 162, 146, 1824, 181, 147, + 130, 1898, 209, 143, 131, 1805, 180, 148, 106, 1776, 147, 141, 1572, 177, 130, 105, 1776, 178, 144, + 122, 1557, 142, 124, 114, 1436, 143, 126, 1326, 127, 1755, 169, 127, 105, 1807, 177, 131, 134, 1613, + 187, 137, 136, 1314, 134, 118, 2005, 194, 129, 147, 1566, 185, 132, 131, 1236, 174, 137, 106, 11049, + 574, 126, 1242, 188, 130, 119, 1450, 187, 137, 141, 1116, 124, 1848, 138, 122, 1605, 186, 127, 140, + 1798, 170, 124, 121, 1666, 157, 128, 130, 1678, 135, 118, 1804, 169, 135, 125, 1837, 168, 124, 124]; + let ES_FRAME_SIZE = H264_FRAME_SIZE_60FPS_320; beforeAll(function() { console.info('beforeAll case'); }) diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncCallbackTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncCallbackTest.test.js index 4f6762748a3f29112198ab09e4847f7eb2787a57..aedb2ddfe3f1cee2176472763e7b95fe7e3d4570 100644 --- a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncCallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncCallbackTest.test.js @@ -31,7 +31,7 @@ describe('VideoDecoderFuncCallbackTest', function () { let surfaceID = ''; const events = require('events'); const eventEmitter = new events.EventEmitter(); - const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/'; + const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/'; let ES_FRAME_SIZE = []; const H264_FRAME_SIZE_240 = [ 2106, 11465, 321, 72, 472, 68, 76, 79, 509, 90, 677, 88, 956, 99, 347, 77, 452, 681, 81, 1263, 94, 106, 97, @@ -65,13 +65,6 @@ describe('VideoDecoderFuncCallbackTest', function () { 295, 213, 170, 3568, 305, 198, 166, 3641, 297, 172, 148, 3608, 301, 200, 159, 3693, 322, 209, 166, 3453, 318, 206, 162, 3696, 341, 200, 176, 3386, 320, 192, 176, 3903, 373, 207, 187, 3305, 361, 200, 202, 3110, 367, 220, 197, 2357, 332, 196, 201, 1827, 377, 187, 199, 860, 472, 173, 223, 238]; - const H264_FRAME_SIZE_30FPS_1080 = - [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463, - 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784, - 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935, - 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277, - 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785, - 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937]; const H263_FRAME_SIZE = [ 96618, 3515, 4132, 4336, 4646, 3497, 4430, 5437, 7560, 4613, 4876, 4734, 53617, 4079, 4507, 5222, 6244, 5843, 6601, 6622, 6751, 6539, 7666, 7706, 53977, 7311, 12906, 10308, 26791, 15983, 34794, 22110, 37165, @@ -336,50 +329,19 @@ describe('VideoDecoderFuncCallbackTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_H264_CALLBACK_0100', 0, async function (done) { - ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080; + ES_FRAME_SIZE = H264_FRAME_SIZE_240; isCodecData = true; - let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264'; + let srcPath = BASIC_PATH + 'out_320_240_10s.h264'; let mediaDescription = { 'track_type': 1, 'codec_mime': 'video/avc', - 'width': 1920, - 'height': 1080, - 'pixel_format': 3, - 'frame_rate': 30.00, - 'max_input_size': 150000, - } - media.createVideoDecoderByName('avdec_h264', (err, processor) => { - expect(err).assertUndefined(); - console.info('in case : createVideoDecoderByName success'); - videoDecodeProcessor = processor; - eventEmitter.emit('configure', mediaDescription, srcPath, - function() { - eventEmitter.emit('stop', done); - }, done); - }); - }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_H263_CALLBACK_0100 - * @tc.name : 001.basic Video decode function - * @tc.desc : start-> EOS -> stop -> reset - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level0 - */ - it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_H263_CALLBACK_0100', 0, async function (done) { - ES_FRAME_SIZE = H263_FRAME_SIZE; - let srcPath = BASIC_PATH + 'h263_1408_1152.es'; - let mediaDescription = { - 'track_type': 1, - 'codec_mime': 'video/h263', - 'width': 1408, - 'height': 1152, + 'width': 320, + 'height': 240, 'pixel_format': 3, 'frame_rate': 60.00, 'max_input_size': 150000, } - media.createVideoDecoderByName('avdec_h263', (err, processor) => { + media.createVideoDecoderByName('avdec_h264', (err, processor) => { expect(err).assertUndefined(); console.info('in case : createVideoDecoderByName success'); videoDecodeProcessor = processor; @@ -461,14 +423,14 @@ describe('VideoDecoderFuncCallbackTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0600', 0, async function (done) { - ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080; + ES_FRAME_SIZE = H264_FRAME_SIZE_240; isCodecData = true; - let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264'; + let srcPath = BASIC_PATH + 'out_320_240_10s.h264'; let mediaDescription = { 'track_type': 1, 'codec_mime': 'video/avc', - 'width': 1920, - 'height': 1080, + 'width': 320, + 'height': 240, 'pixel_format': 3, 'frame_rate': 60.00, 'max_input_size': 150000, @@ -523,16 +485,16 @@ describe('VideoDecoderFuncCallbackTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_CALLBACK_01_0700', 0, async function (done) { - ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080; + ES_FRAME_SIZE = H264_FRAME_SIZE_240; isCodecData = true; - let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264'; + let srcPath = BASIC_PATH + 'out_320_240_10s.h264'; let mediaDescription = { 'track_type': 1, 'codec_mime': 'video/avc', - 'width': 1920, - 'height': 1080, + 'width': 320, + 'height': 240, 'pixel_format': 3, - 'frame_rate': 30.00, + 'frame_rate': 60.00, 'max_input_size': 150000, } eventEmitter.on('stop_for_callback_01_0700', (done) => { diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncPromiseTest.test.js index 14fc597ad65fc677d00de659fd0ba85243d8986b..02076de3985b4808a96aed8d3d8248557f8d16d0 100644 --- a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncPromiseTest.test.js +++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareFuncPromiseTest.test.js @@ -32,7 +32,7 @@ describe('VideoDecoderFuncPromiseTest', function () { let surfaceID = ''; const events = require('events'); const eventEmitter = new events.EventEmitter(); - const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/'; + const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/'; let ES_FRAME_SIZE = []; const H264_FRAME_SIZE_240 = [ 2106, 11465, 321, 72, 472, 68, 76, 79, 509, 90, 677, 88, 956, 99, 347, 77, 452, 681, 81, 1263, 94, 106, 97, @@ -66,13 +66,6 @@ describe('VideoDecoderFuncPromiseTest', function () { 295, 213, 170, 3568, 305, 198, 166, 3641, 297, 172, 148, 3608, 301, 200, 159, 3693, 322, 209, 166, 3453, 318, 206, 162, 3696, 341, 200, 176, 3386, 320, 192, 176, 3903, 373, 207, 187, 3305, 361, 200, 202, 3110, 367, 220, 197, 2357, 332, 196, 201, 1827, 377, 187, 199, 860, 472, 173, 223, 238]; - const H264_FRAME_SIZE_30FPS_1080 = - [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463, - 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784, - 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935, - 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277, - 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785, - 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937]; const H263_FRAME_SIZE = [ 96618, 3515, 4132, 4336, 4646, 3497, 4430, 5437, 7560, 4613, 4876, 4734, 53617, 4079, 4507, 5222, 6244, 5843, 6601, 6622, 6751, 6539, 7666, 7706, 53977, 7311, 12906, 10308, 26791, 15983, 34794, 22110, 37165, @@ -338,49 +331,19 @@ describe('VideoDecoderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_H264_PROMISE_0100', 0, async function (done) { - ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080; + ES_FRAME_SIZE = H264_FRAME_SIZE_240; isCodecData = true; - let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264'; + let srcPath = BASIC_PATH + 'out_320_240_10s.h264'; let mediaDescription = { 'track_type': 1, 'codec_mime': 'video/avc', - 'width': 1920, - 'height': 1080, - 'pixel_format': 3, - 'frame_rate': 30.00, - 'max_input_size': 150000, - } - await toCreateVideoDecoderByName('avdec_h264', done); - await toConfigure(mediaDescription, srcPath); - await toSetOutputSurface(true); - setCallback( - function(){eventEmitter.emit('nextStep', done);} - ); - await toPrepare(); - await toStart(); - }) - - /* * - * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_DECODER_H263_PROMISE_0100 - * @tc.name : 001.basic Video decode function - * @tc.desc : start-> EOS -> stop -> reset - * @tc.size : MediumTest - * @tc.type : Function test - * @tc.level : Level0 - */ - it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_H263_PROMISE_0100', 0, async function (done) { - ES_FRAME_SIZE = H263_FRAME_SIZE; - let srcPath = BASIC_PATH + 'h263_1408_1152.es'; - let mediaDescription = { - 'track_type': 1, - 'codec_mime': 'video/h263', - 'width': 1408, - 'height': 1152, + 'width': 320, + 'height': 240, 'pixel_format': 3, 'frame_rate': 60.00, 'max_input_size': 150000, } - await toCreateVideoDecoderByName('avdec_h263', done); + await toCreateVideoDecoderByName('avdec_h264', done); await toConfigure(mediaDescription, srcPath); await toSetOutputSurface(true); setCallback( @@ -459,16 +422,16 @@ describe('VideoDecoderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0600', 0, async function (done) { - ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080; + ES_FRAME_SIZE = H264_FRAME_SIZE_240; isCodecData = true; - let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264'; + let srcPath = BASIC_PATH + 'out_320_240_10s.h264'; let mediaDescription = { 'track_type': 1, 'codec_mime': 'video/avc', - 'width': 1920, - 'height': 1080, + 'width': 320, + 'height': 240, 'pixel_format': 3, - 'frame_rate': 30.00, + 'frame_rate': 60.00, 'max_input_size': 150000, } await toCreateVideoDecoderByName('avdec_h264', done); @@ -519,14 +482,14 @@ describe('VideoDecoderFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_SOFTWARE_DECODER_FUNCTION_PROMISE_01_0700', 0, async function (done) { - ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080; + ES_FRAME_SIZE = H264_FRAME_SIZE_240; isCodecData = true; - let srcPath = BASIC_PATH + 'out_1920_1080_30fps_3s.h264'; + let srcPath = BASIC_PATH + 'out_320_240_10s.h264'; let mediaDescription = { 'track_type': 1, 'codec_mime': 'video/avc', - 'width': 1920, - 'height': 1080, + 'width': 320, + 'height': 240, 'pixel_format': 3, 'frame_rate': 60.00, 'max_input_size': 150000, diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliCallbackTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliCallbackTest.test.js index 7d9f7ff9716e963dd46ae3d8aecc21a19400c962..56ebc6776ea3d497b2f03193d7bf897311e908ea 100644 --- a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliCallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliCallbackTest.test.js @@ -46,26 +46,34 @@ describe('VideoDecoderSoftwareReliCallbackTest', function () { let inputEosFlag = false; let workdoneAtEOS = false; let surfaceID = ''; - const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/'; - const SRCPATH = BASIC_PATH + 'out_1920_1080_30fps_3s.h264'; + const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/'; + const SRCPATH = BASIC_PATH + 'out_320_240_10s.h264'; let mediaDescription = { 'track_type': 1, 'codec_mime': 'video/avc', - 'width': 1920, - 'height': 1080, + 'width': 320, + 'height': 240, 'pixel_format': 3, - 'frame_rate': 30, + 'frame_rate': 60, 'max_input_size': 150000, } - - const H264_FRAME_SIZE_30FPS_1080 = - [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463, - 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784, - 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935, - 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277, - 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785, - 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937]; - let ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080; + const H264_FRAME_SIZE_60FPS_320 = + [ 2106, 11465, 321, 72, 472, 68, 76, 79, 509, 90, 677, 88, 956, 99, 347, 77, 452, 681, 81, 1263, 94, 106, 97, + 998, 97, 797, 93, 1343, 150, 116, 117, 926, 1198, 128, 110, 78, 1582, 158, 135, 112, 1588, 165, 132, + 128, 1697, 168, 149, 117, 1938, 170, 141, 142, 1830, 106, 161, 122, 1623, 160, 154, 156, 1998, 230, + 177, 139, 1650, 186, 128, 134, 1214, 122, 1411, 120, 1184, 128, 1591, 195, 145, 105, 1587, 169, 140, + 118, 1952, 177, 150, 161, 1437, 159, 123, 1758, 180, 165, 144, 1936, 214, 191, 175, 2122, 180, 179, + 160, 1927, 161, 184, 119, 1973, 218, 210, 129, 1962, 196, 127, 154, 2308, 173, 127, 1572, 142, 122, + 2065, 262, 159, 206, 2251, 269, 179, 170, 2056, 308, 168, 191, 2090, 303, 191, 110, 1932, 272, 162, + 122, 1877, 245, 167, 141, 1908, 294, 162, 118, 1493, 132, 1782, 273, 184, 133, 1958, 274, 180, 149, + 2070, 216, 169, 143, 1882, 224, 149, 139, 1749, 277, 184, 139, 2141, 197, 170, 140, 2002, 269, 162, + 140, 1862, 202, 179, 131, 1868, 214, 164, 140, 1546, 226, 150, 130, 1707, 162, 146, 1824, 181, 147, + 130, 1898, 209, 143, 131, 1805, 180, 148, 106, 1776, 147, 141, 1572, 177, 130, 105, 1776, 178, 144, + 122, 1557, 142, 124, 114, 1436, 143, 126, 1326, 127, 1755, 169, 127, 105, 1807, 177, 131, 134, 1613, + 187, 137, 136, 1314, 134, 118, 2005, 194, 129, 147, 1566, 185, 132, 131, 1236, 174, 137, 106, 11049, + 574, 126, 1242, 188, 130, 119, 1450, 187, 137, 141, 1116, 124, 1848, 138, 122, 1605, 186, 127, 140, + 1798, 170, 124, 121, 1666, 157, 128, 130, 1678, 135, 118, 1804, 169, 135, 125, 1837, 168, 124, 124]; + let ES_FRAME_SIZE = H264_FRAME_SIZE_60FPS_320; beforeAll(function() { console.info('beforeAll case'); }) diff --git a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliPromiseTest.test.js b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliPromiseTest.test.js index 693243b8ffc1b28e6702a34042b12ca2ff001cd2..c2e258df264e452d1d38f546dc2386ca0099a3fa 100644 --- a/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliPromiseTest.test.js +++ b/multimedia/media/media_js_standard/videoDecoder/src/main/js/test/VideoDecoderSoftwareReliPromiseTest.test.js @@ -46,25 +46,35 @@ describe('VideoDecoderSoftwareReliPromiseTest', function () { let inputEosFlag = false; let workdoneAtEOS = false; let surfaceID = ''; - const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.videodecoder/shared/'; - const SRCPATH = BASIC_PATH + 'out_1920_1080_30fps_3s.h264'; + const BASIC_PATH = '/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videodecoder/shared/'; + const SRCPATH = BASIC_PATH + 'out_320_240_10s.h264'; let mediaDescription = { 'track_type': 1, 'codec_mime': 'video/avc', - 'width': 1920, - 'height': 1080, + 'width': 320, + 'height': 240, 'pixel_format': 3, - 'frame_rate': 30, + 'frame_rate': 60, 'max_input_size': 150000, } - const H264_FRAME_SIZE_30FPS_1080 = - [ 3491, 115184, 9423, 1046, 19038, 2059, 2306, 28773, 4815, 1670, 31464, 6322, 2969, 3518, 38279, 8419, 4463, - 4554, 35457, 7848, 3870, 4235, 32523, 7606, 3992, 4132, 58148, 10144, 7625, 6051, 38774, 8929, 5309, 5784, - 45250, 8696, 5511, 5224, 36732, 8221, 4885, 5103, 40075, 9799, 5259, 5373, 39394, 10406, 5016, 5572, 60935, - 13292, 6469, 7040, 45344, 12370, 5825, 6712, 47052, 12502, 6800, 7453, 52653, 14088, 7257, 8931, 46638, 13277, - 7612, 8663, 44022, 13672, 7763, 7784, 51638, 14118, 8112, 6458, 41013, 12910, 6759, 6974, 38409, 12813, 6785, - 6934, 33390, 12910, 6825, 6954, 21092, 13599, 6968, 7937]; - let ES_FRAME_SIZE = H264_FRAME_SIZE_30FPS_1080; + const H264_FRAME_SIZE_60FPS_320 = + [ 2106, 11465, 321, 72, 472, 68, 76, 79, 509, 90, 677, 88, 956, 99, 347, 77, 452, 681, 81, 1263, 94, 106, 97, + 998, 97, 797, 93, 1343, 150, 116, 117, 926, 1198, 128, 110, 78, 1582, 158, 135, 112, 1588, 165, 132, + 128, 1697, 168, 149, 117, 1938, 170, 141, 142, 1830, 106, 161, 122, 1623, 160, 154, 156, 1998, 230, + 177, 139, 1650, 186, 128, 134, 1214, 122, 1411, 120, 1184, 128, 1591, 195, 145, 105, 1587, 169, 140, + 118, 1952, 177, 150, 161, 1437, 159, 123, 1758, 180, 165, 144, 1936, 214, 191, 175, 2122, 180, 179, + 160, 1927, 161, 184, 119, 1973, 218, 210, 129, 1962, 196, 127, 154, 2308, 173, 127, 1572, 142, 122, + 2065, 262, 159, 206, 2251, 269, 179, 170, 2056, 308, 168, 191, 2090, 303, 191, 110, 1932, 272, 162, + 122, 1877, 245, 167, 141, 1908, 294, 162, 118, 1493, 132, 1782, 273, 184, 133, 1958, 274, 180, 149, + 2070, 216, 169, 143, 1882, 224, 149, 139, 1749, 277, 184, 139, 2141, 197, 170, 140, 2002, 269, 162, + 140, 1862, 202, 179, 131, 1868, 214, 164, 140, 1546, 226, 150, 130, 1707, 162, 146, 1824, 181, 147, + 130, 1898, 209, 143, 131, 1805, 180, 148, 106, 1776, 147, 141, 1572, 177, 130, 105, 1776, 178, 144, + 122, 1557, 142, 124, 114, 1436, 143, 126, 1326, 127, 1755, 169, 127, 105, 1807, 177, 131, 134, 1613, + 187, 137, 136, 1314, 134, 118, 2005, 194, 129, 147, 1566, 185, 132, 131, 1236, 174, 137, 106, 11049, + 574, 126, 1242, 188, 130, 119, 1450, 187, 137, 141, 1116, 124, 1848, 138, 122, 1605, 186, 127, 140, + 1798, 170, 124, 121, 1666, 157, 128, 130, 1678, 135, 118, 1804, 169, 135, 125, 1837, 168, 124, 124]; + let ES_FRAME_SIZE = H264_FRAME_SIZE_60FPS_320; + beforeAll(function() { console.info('beforeAll case'); }) diff --git a/multimedia/media/media_js_standard/videoEncoder/Test.json b/multimedia/media/media_js_standard/videoEncoder/Test.json index 9f308640a56c09373d31ae943373e23f0c29b475..205dd92efbeac607087a427bcbdd664f2b78ae60 100644 --- a/multimedia/media/media_js_standard/videoEncoder/Test.json +++ b/multimedia/media/media_js_standard/videoEncoder/Test.json @@ -17,13 +17,12 @@ { "type": "ShellKit", "run-command": [ + "rm -R /data/accounts/account_0/appdata/ohos.acts.multimedia.video.videoencoder/results", "mkdir -p /data/accounts/account_0/appdata/ohos.acts.multimedia.video.videoencoder/results/", "chmod 777 -R /data/accounts/account_0/appdata/ohos.acts.multimedia.video.videoencoder", - "chmod 777 /data/accounts/account_0/appdata/ohos.acts.multimedia.video.videoencoder/*", - "setenforce 0" + "chmod 777 /data/accounts/account_0/appdata/ohos.acts.multimedia.video.videoencoder/*" ], "teardown-command":[ - "setenforce 1" ] }, { diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderMultiInstancesTest.test.js b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderMultiInstancesTest.test.js index 94b5a7ed42e40333a06a526e7fad15049c25949c..fbc8246fd54a223d20f7507ad50ca9eaf371a3f5 100644 --- a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderMultiInstancesTest.test.js +++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderMultiInstancesTest.test.js @@ -272,9 +272,9 @@ describe('videoEncoderSoftwareMultiInstances', function () { console.info("case test multiple encoder instances"); let savepath = BASIC_PATH + '0100.es'; let mime = 'video/mp4v-es'; - let width = 720; - let height = 480; - let framerate = 60; + let width = 320; + let height = 240; + let framerate = 30; let mediaDescription = { "width": width, "height": height, diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncCallbackTest.test.js b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncCallbackTest.test.js index 5bc7c5d7840c38ce58c6a5827ff45ca8ccea7185..50cdc815a74847fd027e229eaea65a1fa8ade39d 100644 --- a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncCallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncCallbackTest.test.js @@ -268,10 +268,10 @@ describe('VideoEncoderSoftwareFuncCallbackTest', function () { let mime = 'video/mp4v-es'; let mediaDescription = { "codec_mime": 'video/mp4v-es', - 'width': 720, - 'height': 480, + 'width': 320, + 'height': 240, 'pixel_format': 3, - 'frame_rate': 60, + 'frame_rate': 30, } media.getMediaCapability((err, mediaCaps) => { expect(err).assertUndefined(); @@ -329,10 +329,10 @@ describe('VideoEncoderSoftwareFuncCallbackTest', function () { let decPath = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0100.es'; let name= 'avenc_mpeg4'; let mediaDescription = { - 'width': 720, - 'height': 480, + 'width': 320, + 'height': 240, 'pixel_format': 3, - 'frame_rate': 60.00, + 'frame_rate': 30.00, } finalFrameId = 50; media.createVideoEncoderByName(name, (err, processor) => { @@ -365,10 +365,10 @@ describe('VideoEncoderSoftwareFuncCallbackTest', function () { let decPath = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0200.es'; let name= 'avenc_mpeg4'; let mediaDescription = { - 'width': 720, - 'height': 480, + 'width': 320, + 'height': 240, 'pixel_format': 3, - 'frame_rate': 60.00, + 'frame_rate': 30.00, } reStart = true; media.createVideoEncoderByName(name, (err, processor) => { @@ -401,10 +401,10 @@ describe('VideoEncoderSoftwareFuncCallbackTest', function () { let decPath = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0300.es'; let name= 'avenc_mpeg4'; let mediaDescription = { - 'width': 720, - 'height': 480, + 'width': 320, + 'height': 240, 'pixel_format': 3, - 'frame_rate': 60.00, + 'frame_rate': 30.00, } finalFrameId = 50; reStart = true; @@ -438,10 +438,10 @@ describe('VideoEncoderSoftwareFuncCallbackTest', function () { let decPath = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0400.es'; let name= 'avenc_mpeg4'; let mediaDescription = { - 'width': 720, - 'height': 480, + 'width': 320, + 'height': 240, 'pixel_format': 3, - 'frame_rate': 60.00, + 'frame_rate': 30.00, } finalFrameId = 50; media.createVideoEncoderByName(name, (err, processor) => { @@ -474,10 +474,10 @@ describe('VideoEncoderSoftwareFuncCallbackTest', function () { let decPath = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0500.es'; let name= 'avenc_mpeg4'; let mediaDescription = { - 'width': 720, - 'height': 480, + 'width': 320, + 'height': 240, 'pixel_format': 3, - 'frame_rate': 60.00, + 'frame_rate': 30.00, } media.createVideoEncoderByName(name, (err, processor) => { expect(err).assertUndefined(); @@ -509,15 +509,15 @@ describe('VideoEncoderSoftwareFuncCallbackTest', function () { let decPath = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0600.es'; let name= 'avenc_mpeg4'; let mediaDescription = { - 'width': 720, - 'height': 480, + 'width': 320, + 'height': 240, 'pixel_format': 3, - 'frame_rate': 60.00, + 'frame_rate': 30.00, } let decPath2 = BASIC_PATH + 'SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_FUNCTION_CALLBACK_01_0600_2.es'; let mediaDescription2 = { - 'width': 1920, - 'height': 1080, + 'width': 320, + 'height': 240, 'pixel_format': 3, 'frame_rate': 30.00, } diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncPromiseTest.test.js index 9bb82cf7da996056119ffa781ef22529b268c08b..dc7450cb7248236c3d1eff378164bb1734c520a4 100644 --- a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncPromiseTest.test.js +++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareFuncPromiseTest.test.js @@ -331,9 +331,9 @@ describe('videoSoftwareEncoderFuncPromise', function () { console.info("case test stop after last frame"); let savepath = BASIC_PATH + '0000.es'; let name= 'avenc_mpeg4'; - let width = 720; - let height = 480; - let framerate = 60; + let width = 320; + let height = 240; + let framerate = 30; let mediaDescription = { "codec_mime": 'video/mp4v-es', "width": width, @@ -396,9 +396,9 @@ describe('videoSoftwareEncoderFuncPromise', function () { console.info("case test stop at runnning state and reset"); let savepath = BASIC_PATH + '0100.es'; let mime = 'video/mp4v-es'; - let width = 720; - let height = 480; - let framerate = 60; + let width = 320; + let height = 240; + let framerate = 30; let mediaDescription = { "width": width, "height": height, @@ -435,9 +435,9 @@ describe('videoSoftwareEncoderFuncPromise', function () { console.info("test stop at end of stream and restart"); let savepath = BASIC_PATH + '0200.es'; let mime = 'video/mp4v-es'; - let width = 720; - let height = 480; - let framerate = 60; + let width = 320; + let height = 240; + let framerate = 30; let mediaDescription = { "width": width, "height": height, @@ -475,9 +475,9 @@ describe('videoSoftwareEncoderFuncPromise', function () { console.info("test stop at runnning state and restart"); let savepath = BASIC_PATH + '0300.es'; let mime = 'video/mp4v-es'; - let width = 720; - let height = 480; - let framerate = 60; + let width = 320; + let height = 240; + let framerate = 30; let mediaDescription = { "width": width, "height": height, @@ -516,16 +516,16 @@ describe('videoSoftwareEncoderFuncPromise', function () { console.info("case test flush at running state"); let savepath = BASIC_PATH + '0400.es'; let mime = 'video/mp4v-es'; - let width = 720; - let height = 480; - let framerate = 60; + let width = 320; + let height = 240; + let framerate = 30; let mediaDescription = { "width": width, "height": height, "pixel_format": 3, "frame_rate" : framerate, } - frameTotal = 1000; + frameTotal = 500; await toCreateByMime(mime, done); await toGetVideoEncoderCaps(width, height); toCreateStream(); @@ -536,7 +536,7 @@ describe('videoSoftwareEncoderFuncPromise', function () { await toPrepare(); toStartStream(); await toStart(); - await sleep(1000); + await sleep(500); await toFlush(); }) @@ -552,9 +552,9 @@ describe('videoSoftwareEncoderFuncPromise', function () { console.info("case test flush at end of stream"); let savepath = BASIC_PATH + '0500.es'; let mime = 'video/mp4v-es'; - let width = 720; - let height = 480; - let framerate = 60; + let width = 320; + let height = 240; + let framerate = 30; let mediaDescription = { "width": width, "height": height, @@ -574,7 +574,6 @@ describe('videoSoftwareEncoderFuncPromise', function () { toStartStream(); await toStart(); await sleep(5000); - toStopStream(); resetParam(); toSetStreamParam(width, height, framerate, frameTotal); toStartStream(); @@ -592,9 +591,9 @@ describe('videoSoftwareEncoderFuncPromise', function () { console.info("case test reconfigure"); let savepath = BASIC_PATH + '0600.es'; let mime = 'video/mp4v-es'; - let width = 720; - let height = 480; - let framerate = 60; + let width = 320; + let height = 240; + let framerate = 30; let mediaDescription = { "width": width, "height": height, @@ -614,10 +613,9 @@ describe('videoSoftwareEncoderFuncPromise', function () { toStartStream(); await toStart(); await sleep(5000); - toStopStream(); resetParam(); - width = 720; - height = 480; + width = 320; + height = 240; framerate = 30; let mediaDescription2 = { "width": width, @@ -647,9 +645,9 @@ describe('videoSoftwareEncoderFuncPromise', function () { console.info("case test recreate videoencoder"); let savepath = BASIC_PATH + '0700.es'; let mime = 'video/mp4v-es'; - let width = 720; - let height = 480; - let framerate = 60; + let width = 320; + let height = 240; + let framerate = 30; let mediaDescription = { "width": width, "height": height, @@ -669,11 +667,10 @@ describe('videoSoftwareEncoderFuncPromise', function () { toStartStream(); await toStart(); await sleep(5000); - toStopStream(); await toRelease(); resetParam(); - width = 720; - height = 480; + width = 320; + height = 240; framerate = 30; let mediaDescription2 = { "width": width, diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareReliabilityCallbackTest.test.js b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareReliabilityCallbackTest.test.js index 157a309ab384953e0258b158c7552564bfaf09d5..0603dfb13da4d25d3ef5d9751cad7d654e3d219a 100644 --- a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareReliabilityCallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareReliabilityCallbackTest.test.js @@ -53,10 +53,10 @@ describe('VideoEncoderSoftwareReliCallbackTest', function () { const ROOT = '/data/accounts/account_0/appdata/ohos.acts.multimedia.video.videoencoder/results/'; const BASIC_PATH = ROOT + 'video_reliability_callback_'; let mediaDescription = { - 'width': 720, - 'height': 480, + 'width': 320, + 'height': 240, 'pixel_format': 3, - 'frame_rate': 60, + 'frame_rate': 30, } beforeAll(function() { console.info('beforeAll case'); @@ -1447,14 +1447,14 @@ describe('VideoEncoderSoftwareReliCallbackTest', function () { }) /* * - * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_TOOPLOOP_CALLBACK_0100 + * @tc.number : SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_TOTALLOOP_CALLBACK_0100 * @tc.name : 001. total loop for 50 times * @tc.desc : Reliability Test * @tc.size : MediumTest * @tc.type : Reliability * @tc.level : Level2 */ - it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CREATE-RELEASE_CALLBACK_0100', 0, async function (done) { + it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_TOTALLOOP_CALLBACK_0100', 0, async function (done) { let name = 'avenc_mpeg4'; let events = require('events'); let eventEmitter = new events.EventEmitter(); diff --git a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareReliabilityPromiseTest.test.js b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareReliabilityPromiseTest.test.js index c78cbab60cdac99ec76b328f43fca7f546ac50ab..16ea7a48d9500e812848bfedd67e24e2631aa007 100644 --- a/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareReliabilityPromiseTest.test.js +++ b/multimedia/media/media_js_standard/videoEncoder/src/main/js/test/VideoEncoderSoftwareReliabilityPromiseTest.test.js @@ -49,9 +49,9 @@ describe('videoEncoderReliabilityPromise', function () { const WAITFORALLOUTS = 14; const JUDGE_EOS = 15; const WAITTIME = 3000; - let width = 720; - let height = 480; - let framerate = 60; + let width = 320; + let height = 240; + let framerate = 30; let mediaDescription = { "width": width, "height": height, @@ -75,9 +75,9 @@ describe('videoEncoderReliabilityPromise', function () { sawOutputEOS = false; needGetMediaDes = false; workdoneAtEOS = false; - width = 720; - height = 480; - framerate = 60; + width = 320; + height = 240; + framerate = 30; frameTotal = 100; }) @@ -459,7 +459,7 @@ describe('videoEncoderReliabilityPromise', function () { */ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_CONFIGURE_PROMISE_0200', 0, async function (done) { let savepath = BASIC_PATH + 'configure_0200.es'; - let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, CONFIGURE, ERROR, STOPSTREAM, END); + let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, CONFIGURE, ERROR, END); createVideoEncoder(savepath, mySteps, done); }) @@ -590,7 +590,7 @@ describe('videoEncoderReliabilityPromise', function () { */ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0200', 0, async function (done) { let savepath = BASIC_PATH + 'prepare_0200.es'; - let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, STOPSTREAM, END); + let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, END); createVideoEncoder(savepath, mySteps, done); }) @@ -604,7 +604,7 @@ describe('videoEncoderReliabilityPromise', function () { */ it('SUB_MEDIA_VIDEO_SOFTWARE_ENCODER_API_PREPARE_PROMISE_0300', 0, async function (done) { let savepath = BASIC_PATH + 'prepare_0300.es'; - let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, PREPARE, ERROR, STOPSTREAM, END); + let mySteps = new Array(CONFIGURE, GETSURFACE, SETSTREAMPARAM, PREPARE, PREPARE, ERROR, END); createVideoEncoder(savepath, mySteps, done); }) diff --git a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js index a9d8a3f14262947827afd11a6d1e6e3b94b7127f..178a4d1506fa0f01ec803c2fb955e1ef93afc065 100644 --- a/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js +++ b/multimedia/media/media_js_standard/videoPlayer/src/main/js/test/VideoPlayerFuncPromiseTest.test.js @@ -127,31 +127,96 @@ describe('VideoPlayerFuncPromiseTest', function () { /* * * @tc.number : SUB_MEDIA_PLAYER_MULTIPLE_0100 - * @tc.name : 001.Multi-instance (16 promise) + * @tc.name : 001.Multi-instance (2 videoPlayer promise) * @tc.desc : Video playback control test * @tc.size : MediumTest * @tc.type : Function test * @tc.level : Level2 */ it('SUB_MEDIA_PLAYER_MULTIPLE_0100', 0, async function (done) { - let arr = new Array(); - for (let i = 0; i < 14; i++) { + await getFd(); + setTimeout(async function() { + surfaceID = globalThis.value; + console.info('case new surfaceID is ' + surfaceID); + let testVideoPlayer1 = null; + let testVideoPlayer2 = null; await media.createVideoPlayer().then((video) => { if (typeof (video) != 'undefined') { - arr[i] = video - console.info('case createVideoPlayer success ' + i); + testVideoPlayer1 = video + console.info('case createVideoPlayer success '); } else { console.info('case createVideoPlayer is failed'); expect().assertFail(); } - }, failureCallback).catch(catchCallback); - } - for (let j = 0; j < 14;j++) { - await arr[j].release().then(() => { - console.info('case release success ' + j); }, failureCallback).catch(catchCallback); - } - done(); + + testVideoPlayer1.url = fdPath; + await testVideoPlayer1.setDisplaySurface(surfaceID).then(() => { + console.info('case setDisplaySurface success'); + expect(testVideoPlayer1.state).assertEqual('idle'); + }, failureCallback).catch(catchCallback); + + await testVideoPlayer1.prepare().then(() => { + console.info('case prepare called!!'); + expect(testVideoPlayer1.state).assertEqual('prepared'); + expect(testVideoPlayer1.duration).assertEqual(DURATION_TIME); + expect(testVideoPlayer1.width).assertEqual(WIDTH_VALUE); + expect(testVideoPlayer1.height).assertEqual(HEIGHT_VALUE); + }, failureCallback).catch(catchCallback); + + let startTime = testVideoPlayer1.currentTime; + await testVideoPlayer1.play().then(() => { + console.info('case play called!!'); + sleep(PLAY_TIME); + expect(testVideoPlayer1.state).assertEqual('playing'); + }, failureCallback).catch(catchCallback); + let endTime = testVideoPlayer1.currentTime; + expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); + + await testVideoPlayer1.release().then(() => { + console.info('case release called!!'); + }, failureCallback).catch(catchCallback); + testVideoPlayer1 = null; + + await media.createVideoPlayer().then((video) => { + if (typeof (video) != 'undefined') { + testVideoPlayer2 = video + console.info('case createVideoPlayer success '); + } else { + console.info('case createVideoPlayer is failed'); + expect().assertFail(); + } + }, failureCallback).catch(catchCallback); + + testVideoPlayer2.url = fdPath; + await testVideoPlayer2.setDisplaySurface(surfaceID).then(() => { + console.info('case setDisplaySurface success'); + expect(testVideoPlayer2.state).assertEqual('idle'); + }, failureCallback).catch(catchCallback); + + await testVideoPlayer2.prepare().then(() => { + console.info('case prepare called!!'); + expect(testVideoPlayer2.state).assertEqual('prepared'); + expect(testVideoPlayer2.duration).assertEqual(DURATION_TIME); + expect(testVideoPlayer2.width).assertEqual(WIDTH_VALUE); + expect(testVideoPlayer2.height).assertEqual(HEIGHT_VALUE); + }, failureCallback).catch(catchCallback); + + startTime = testVideoPlayer2.currentTime; + await testVideoPlayer2.play().then(() => { + console.info('case play called!!'); + sleep(PLAY_TIME); + expect(testVideoPlayer2.state).assertEqual('playing'); + }, failureCallback).catch(catchCallback); + endTime = testVideoPlayer2.currentTime; + expect(endTime - startTime).assertClose(PLAY_TIME, DELTA_TIME); + + await testVideoPlayer2.release().then(() => { + console.info('case release called!!'); + }, failureCallback).catch(catchCallback); + testVideoPlayer2 = null; + done(); + }, 1000); }) /* * @@ -163,7 +228,6 @@ describe('VideoPlayerFuncPromiseTest', function () { * @tc.level : Level0 */ it('SUB_MEDIA_VIDEO_PLAYER_FUNCTION_PROMISE_0100', 0, async function (done) { - await getFd(); setTimeout(async function() { surfaceID = globalThis.value; console.info('case new surfaceID is ' + surfaceID); diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js index 32f4bace07a6eccb438714ea94f5ec0462dd0ae4..31020098e88eed3267aa34d15be2f72bc694d678 100644 --- a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js +++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderAPICallbackTest.test.js @@ -44,6 +44,8 @@ describe('VideoRecorderAPICallbackTest', function () { let videoOutput; let surfaceID; let fdPath; + let fileAsset; + let fdNumber; let events = require('events'); let eventEmitter = new events.EventEmitter(); @@ -130,8 +132,8 @@ describe('VideoRecorderAPICallbackTest', function () { selectionArgs : [args], } let fetchFileResult = await mediaTest.getFileAssets(fetchOp); - let fileAsset = await fetchFileResult.getAllObject(); - let fdNumber = await fileAsset[0].open('Rw'); + fileAsset = await fetchFileResult.getAllObject(); + fdNumber = await fileAsset[0].open('Rw'); fdPath = "fd://" + fdNumber.toString(); } } diff --git a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js index 4b1279a5303ba3051e0d1256e9ad27fbe7e4db94..ed5e21b5456533b5f86875953faf9901996d7dcf 100644 --- a/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js +++ b/multimedia/media/media_js_standard/videoRecorder/src/main/js/test/VideoRecorderFuncPromiseTest.test.js @@ -25,6 +25,8 @@ describe('VideoRecorderFuncPromiseTest', function () { let cameras; let captureSession; let fdPath; + let fileAsset; + let fdNumber; let configFile = { audioBitrate : 48000, audioChannels : 2, @@ -164,8 +166,8 @@ describe('VideoRecorderFuncPromiseTest', function () { selectionArgs : [args], } let fetchFileResult = await mediaTest.getFileAssets(fetchOp); - let fileAsset = await fetchFileResult.getAllObject(); - let fdNumber = await fileAsset[0].open('Rw'); + fileAsset = await fetchFileResult.getAllObject(); + fdNumber = await fileAsset[0].open('Rw'); fdPath = "fd://" + fdNumber.toString(); } } diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/FileAssetGetThumbnailCallBack.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/FileAssetGetThumbnailCallBack.test.js index dba320bb9a82d06bb24625c8eb1fb4b8fd36bc04..b546df920d555d99fbdb7aad1cee7df2fdbc28b8 100644 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/FileAssetGetThumbnailCallBack.test.js +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/FileAssetGetThumbnailCallBack.test.js @@ -1,727 +1,731 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import image from '@@ohos.multimedia.image'; -import featureAbility from '@ohos.ability.featureAbility'; - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; - -describe('GetFileAssets_GetCount_GetAllObjects', function () { - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - - var URI; - var name; - var result1; - var albumName; - var albumId; - var i; - var fileAsset; - var MAXNUM = 100; - var PATH = 'data'; - var MEDIA_TYPE = 'media_type'; - let fileKeyObj = mediaLibrary.FileKey; - - let type = mediaLibrary.MediaType.IMAGE; - let videoType = mediaLibrary.MediaType.VIDEO; - let audioType = mediaLibrary.MediaType.AUDIO; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '=?', - selectionArgs: [type.toString()], - order: fileKeyObj.dateAdded, - }; - let videoFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '=?', - selectionArgs: [videoType.toString()], - order: fileKeyObj.dateAdded, - }; - let audioFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '=?', - selectionArgs: [audioType.toString()], - order: fileKeyObj.dateAdded, - }; - beforeAll(function () { - }); - - beforeEach(function () { - }); - afterEach(function () { - }); - afterAll(function () { - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_01 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by fetchOp & { width: 80, height: 80 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_01', 0, async function (done) { - media.getFileAssets(fetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 80, height: 80 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == 80).assertTrue(); - expect(info.size.height == 80).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_02 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by fetchOp & { width: 400, height: 400 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_02', 0, async function (done) { - media.getFileAssets(fetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 400, height: 400 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == 400).assertTrue(); - expect(info.size.height == 400).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_03 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by videoFetchOp & { width: 80, height: 80 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_03', 0, async function (done) { - media.getFileAssets(videoFetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 80, height: 80 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == 80).assertTrue(); - expect(info.size.height == 80).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_04 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by videoFetchOp & { width: 400, height: 400 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_04', 0, async function (done) { - media.getFileAssets(videoFetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 400, height: 400 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == 400).assertTrue(); - expect(info.size.height == 400).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_05 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by audioFetchOp & { width: 400, height: 400 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_05', 0, async function (done) { - media.getFileAssets(audioFetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 80, height: 80 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == 80).assertTrue(); - expect(info.size.height == 80).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_06 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by audioFetchOp & { width: 400, height: 400 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_06', 0, async function (done) { - media.getFileAssets(audioFetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 400, height: 400 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == 400).assertTrue(); - expect(info.size.height == 400).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_07 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by fetchOp & & The default size - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_07', 0, async function (done) { - media.getFileAssets(fetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 256, height: 256 }; - data1.getThumbnail((err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_08 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by fetchOp & { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_08', 0, async function (done) { - media.getFileAssets(fetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 1, height: 1 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_09 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by fetchOp & { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_08', 0, async function (done) { - media.getFileAssets(fetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 0, height: 0 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(false).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(true).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_010 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by fetchOp & { width: -80, height: -80 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_09', 0, async function (done) { - media.getFileAssets(fetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: -80, height: -80 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(false).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(true).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_011 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by videoFetchOp & & The default size - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_07', 0, async function (done) { - media.getFileAssets(videoFetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 256, height: 256 }; - data1.getThumbnail((err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_012 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by videoFetchOp & { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_012', 0, async function (done) { - media.getFileAssets(videoFetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 1, height: 1 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_013 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by videoFetchOp & { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_013', 0, async function (done) { - media.getFileAssets(videoFetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 0, height: 0 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(false).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(true).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_014 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by videoFetchOp & { width: -80, height: -80 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_014', 0, async function (done) { - media.getFileAssets(videoFetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: -80, height: -80 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(false).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(true).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_015 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by audioFetchOp & & The default size - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_015', 0, async function (done) { - media.getFileAssets(audioFetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 256, height: 256 }; - data1.getThumbnail((err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_016 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by audioFetchOp & { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_016', 0, async function (done) { - media.getFileAssets(audioFetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 1, height: 1 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_017 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by audioFetchOp & { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_017', 0, async function (done) { - media.getFileAssets(audioFetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: 0, height: 0 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(false).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(true).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_018 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by audioFetchOp & { width: -80, height: -80 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_018', 0, async function (done) { - media.getFileAssets(audioFetchOp, (error, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - data.getFirstObject((err1, data1) => { - if (data1 != undefined) { - let size = { width: -80, height: -80 }; - data1.getThumbnail(size, (err2, pixelmap) => { - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - pixelmap.getImageInfo((error, info) => { - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(false).assertTrue(); - done(); - }); - }); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(true).assertTrue(); - done(); - } - }); - }); -}); +/* + * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import image from '@@ohos.multimedia.image'; +import featureAbility from '@ohos.ability.featureAbility'; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; + +describe('fileAssetGetThumbnailCallBack.test.js', function () { + var context = featureAbility.getContext(); + console.info('MediaLibraryTest : getMediaLibrary IN'); + var media = mediaLibrary.getMediaLibrary(context); + console.info('MediaLibraryTest : getMediaLibrary OUT'); + + var URI; + var name; + var result1; + var albumName; + var albumId; + var i; + var fileAsset; + var MAXNUM = 100; + var PATH = 'data'; + var MEDIA_TYPE = 'media_type'; + let fileKeyObj = mediaLibrary.FileKey; + + let type = mediaLibrary.MediaType.IMAGE; + let videoType = mediaLibrary.MediaType.VIDEO; + let audioType = mediaLibrary.MediaType.AUDIO; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '=?', + selectionArgs: [type.toString()], + order: fileKeyObj.dateAdded, + }; + let videoFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '=?', + selectionArgs: [videoType.toString()], + order: fileKeyObj.dateAdded, + }; + let audioFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '=?', + selectionArgs: [audioType.toString()], + order: fileKeyObj.dateAdded, + }; + beforeAll(function () { + //onsole.info('beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.'); + }); + + beforeEach(function () { + //console.info('MediaLibraryTest: beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.'); + }); + afterEach(function () { + //console.info('MediaLibraryTest: afterEach: Test case-level clearance conditions, which are executed after each test case is executed.'); + }); + afterAll(function () { + //console.info('MediaLibraryTest: afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed'); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_01 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by fetchOp & { width: 80, height: 80 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_01', 0, async function (done) { + media.getFileAssets(fetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 80, height: 80 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(info.size.width == 80).assertTrue(); + expect(info.size.height == 80).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_02 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by fetchOp & { width: 400, height: 400 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_02', 0, async function (done) { + media.getFileAssets(fetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 400, height: 400 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(info.size.width == 400).assertTrue(); + expect(info.size.height == 400).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_03 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by videoFetchOp & { width: 80, height: 80 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_03', 0, async function (done) { + media.getFileAssets(videoFetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 80, height: 80 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(info.size.width == 80).assertTrue(); + expect(info.size.height == 80).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_04 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by videoFetchOp & { width: 400, height: 400 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_04', 0, async function (done) { + media.getFileAssets(videoFetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 400, height: 400 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(info.size.width == 400).assertTrue(); + expect(info.size.height == 400).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_05 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by audioFetchOp & { width: 400, height: 400 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_05', 0, async function (done) { + media.getFileAssets(audioFetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 80, height: 80 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(info.size.width == 80).assertTrue(); + expect(info.size.height == 80).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_06 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by audioFetchOp & { width: 400, height: 400 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_06', 0, async function (done) { + media.getFileAssets(audioFetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 400, height: 400 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(info.size.width == 400).assertTrue(); + expect(info.size.height == 400).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_07 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by fetchOp & & The default size + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_07', 0, async function (done) { + media.getFileAssets(fetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 256, height: 256 }; + data1.getThumbnail((err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(info.size.width == size.width).assertTrue(); + expect(info.size.height == size.height).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_08 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by fetchOp & { width: 1, height: 1 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_08', 0, async function (done) { + media.getFileAssets(fetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 1, height: 1 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(info.size.width == size.width).assertTrue(); + expect(info.size.height == size.height).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_09 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by fetchOp & { width: 0, height: 0 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_08', 0, async function (done) { + media.getFileAssets(fetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 0, height: 0 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(false).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(true).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_010 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by fetchOp & { width: -80, height: -80 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_09', 0, async function (done) { + media.getFileAssets(fetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: -80, height: -80 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(false).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(true).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_011 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by videoFetchOp & & The default size + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_07', 0, async function (done) { + media.getFileAssets(videoFetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 256, height: 256 }; + data1.getThumbnail((err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(info.size.width == size.width).assertTrue(); + expect(info.size.height == size.height).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_012 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by videoFetchOp & { width: 1, height: 1 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_012', 0, async function (done) { + media.getFileAssets(videoFetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 1, height: 1 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(info.size.width == size.width).assertTrue(); + expect(info.size.height == size.height).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_013 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by videoFetchOp & { width: 0, height: 0 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_013', 0, async function (done) { + media.getFileAssets(videoFetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 0, height: 0 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(false).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(true).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_014 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by videoFetchOp & { width: -80, height: -80 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_014', 0, async function (done) { + media.getFileAssets(videoFetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: -80, height: -80 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(false).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(true).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_015 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by audioFetchOp & & The default size + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_015', 0, async function (done) { + media.getFileAssets(audioFetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 256, height: 256 }; + data1.getThumbnail((err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(info.size.width == size.width).assertTrue(); + expect(info.size.height == size.height).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_016 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by audioFetchOp & { width: 1, height: 1 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_016', 0, async function (done) { + media.getFileAssets(audioFetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 1, height: 1 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(info.size.width == size.width).assertTrue(); + expect(info.size.height == size.height).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_017 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by audioFetchOp & { width: 0, height: 0 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_017', 0, async function (done) { + media.getFileAssets(audioFetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: 0, height: 0 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(false).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(true).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_018 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail by audioFetchOp & { width: -80, height: -80 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GET_getThumbnail_018', 0, async function (done) { + media.getFileAssets(audioFetchOp, (error, data) => { + if (data != undefined) { + console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); + data.getFirstObject((err1, data1) => { + if (data1 != undefined) { + let size = { width: -80, height: -80 }; + data1.getThumbnail(size, (err2, pixelmap) => { + console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); + pixelmap.getImageInfo((error, info) => { + console.info('MediaLibraryTest : pixel image info ' + info); + console.info('MediaLibraryTest : pixel width ' + info.size.width); + console.info('MediaLibraryTest : pixel height ' + info.size.height); + expect(false).assertTrue(); + done(); + }); + }); + } + }); + } else { + console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); + console.info('MediaLibraryTest : getFileAssets :FAIL'); + expect(true).assertTrue(); + done(); + } + }); + }); +}); diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/FileAssetGetThumbnailPromise.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/FileAssetGetThumbnailPromise.test.js index a3eb95957fac7a2bad5c21784e8ffb2cda44ada5..a1c19f938b0e6ea99ae5456d4f14ce1623b9ede9 100644 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/FileAssetGetThumbnailPromise.test.js +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/FileAssetGetThumbnailPromise.test.js @@ -1,601 +1,759 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import image from '@@ohos.multimedia.image'; -import featureAbility from '@ohos.ability.featureAbility'; - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; - -describe('GetFileAssets_GetCount_GetAllObjects', function () { - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - - var URI; - var name; - var result1; - var albumName; - var albumId; - var i; - var fileAsset; - var MAXNUM = 100; - var PATH = 'data'; - var MEDIA_TYPE = 'media_type'; - let fileKeyObj = mediaLibrary.FileKey; - - let type = mediaLibrary.MediaType.IMAGE; - let videoType = mediaLibrary.MediaType.VIDEO; - let audioType = mediaLibrary.MediaType.AUDIO; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '=?', - selectionArgs: [type.toString()], - order: fileKeyObj.dateAdded, - }; - let videoFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '=?', - selectionArgs: [videoType.toString()], - order: fileKeyObj.dateAdded, - }; - let audioFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '=?', - selectionArgs: [audioType.toString()], - order: fileKeyObj.dateAdded, - }; - beforeAll(function () { - }); - - beforeEach(function () { - }); - afterEach(function () { - }); - afterAll(function () { - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_01 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by fetchOp & { width: 80, height: 80 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_01', 0, async function (done) { - try { - const data = await media.getFileAssets(fetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 80, height: 80 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_02 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by fetchOp & { width: 400, height: 400 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_02', 0, async function (done) { - try { - const data = await media.getFileAssets(fetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 400, height: 400 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_03 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by videoFetchOp & { width: 80, height: 80 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_03', 0, async function (done) { - try { - const data = await media.getFileAssets(videoFetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 80, height: 80 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_04 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by videoFetchOp & { width: 400, height: 400 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_04', 0, async function (done) { - try { - const data = await media.getFileAssets(videoFetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 400, height: 400 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_05 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by audioFetchOp & { width: 80, height: 80 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_05', 0, async function (done) { - try { - const data = await media.getFileAssets(audioFetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 80, height: 80 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_06 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by audioFetchOp & { width: 400, height: 400 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_06', 0, async function (done) { - try { - const data = await media.getFileAssets(audioFetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 400, height: 400 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_07 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by fetchOp & The default size - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_07', 0, async function (done) { - try { - const data = await media.getFileAssets(fetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 256, height: 256 }; - const pixelmap = await data1.getThumbnail(); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_08 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by fetchOp & { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_08', 0, async function (done) { - try { - const data = await media.getFileAssets(fetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 1, height: 1 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_09 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by fetchOp & { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_09', 0, async function (done) { - try { - const data = await media.getFileAssets(fetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 0, height: 0 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(false).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_010 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by fetchOp & { width: -80, height: -80 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_010', 0, async function (done) { - try { - const data = await media.getFileAssets(fetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: -80, height: -80 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(false).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_011 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by videoFetchOp & The default size - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_011', 0, async function (done) { - try { - const data = await media.getFileAssets(videoFetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 256, height: 256 }; - const pixelmap = await data1.getThumbnail(); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_012 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by videoFetchOp & { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_012', 0, async function (done) { - try { - const data = await media.getFileAssets(videoFetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 1, height: 1 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_013 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by videoFetchOp & { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_013', 0, async function (done) { - try { - const data = await media.getFileAssets(videoFetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 0, height: 0 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(false).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_014 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by videoFetchOp & { width: -80, height: -80 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_014', 0, async function (done) { - try { - const data = await media.getFileAssets(videoFetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: -80, height: -80 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(false).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_015 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by audioFetchOp & The default size - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_015', 0, async function (done) { - try { - const data = await media.getFileAssets(audioFetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 256, height: 256 }; - const pixelmap = await data1.getThumbnail(); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_016 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by audioFetchOp & { width: 1, height: 1 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_016', 0, async function (done) { - try { - const data = await media.getFileAssets(audioFetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 1, height: 1 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(info.size.width == size.width).assertTrue(); - expect(info.size.height == size.height).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_017 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by audioFetchOp & { width: 0, height: 0 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_017', 0, async function (done) { - try { - const data = await media.getFileAssets(audioFetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: 0, height: 0 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(false).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(true).assertTrue(); - } - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_018 - * @tc.name : getThumbnail - * @tc.desc : getThumbnail by audioFetchOp & { width: -80, height: -80 } - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_GETTHUMBNAIL_PROMISE_018', 0, async function (done) { - try { - const data = await media.getFileAssets(audioFetchOp); - console.info('MediaLibraryTest : getFileAssets Successfull ' + data.getCount()); - const data1 = await data.getFirstObject(); - let size = { width: -80, height: -80 }; - const pixelmap = await data1.getThumbnail(size); - console.info('MediaLibraryTest : getThumbnail Successfull ' + pixelmap); - const info = pixelmap.getImageInfo(); - console.info('MediaLibraryTest : pixel image info ' + info); - console.info('MediaLibraryTest : pixel width ' + info.size.width); - console.info('MediaLibraryTest : pixel height ' + info.size.height); - expect(false).assertTrue(); - } catch (error) { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + error.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(true).assertTrue(); - } - done(); - }); -}); +/* + * Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import image from '@ohos.multimedia.image'; +import featureAbility from '@ohos.ability.featureAbility'; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; + +describe('FileAssetGetThumbnailPromise.test.js', function () { + var context = featureAbility.getContext(); + console.info('MediaLibraryTest : getMediaLibrary IN'); + var media = mediaLibrary.getMediaLibrary(context); + console.info('MediaLibraryTest : getMediaLibrary OUT'); + let fileKeyObj = mediaLibrary.FileKey; + let imagetype = mediaLibrary.MediaType.IMAGE; + let videoType = mediaLibrary.MediaType.VIDEO; + let audioType = mediaLibrary.MediaType.AUDIO; + let imageFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '=?', + selectionArgs: [imagetype.toString()], + order: fileKeyObj.DATE_ADDED, + }; + let videoFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '=?', + selectionArgs: [videoType.toString()], + order: fileKeyObj.DATE_ADDED, + }; + let audioFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '=?', + selectionArgs: [audioType.toString()], + order: fileKeyObj.DATE_ADDED, + }; + beforeAll(function () {}); + beforeEach(function () {}); + afterEach(function () {}); + afterAll(function () {}); + + // ------------------------------ image type start ----------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_01 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: 128, height: 128 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_01', 0, async function (done) { + try { + const fetchFileResult = await media.getFileAssets(imageFetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + let size = { width: 128, height: 128 }; + const pixelmap = await asset.getThumbnail(size); + const info = await pixelmap.getImageInfo(); + console.info('MediaLibraryTest : 001_01 pixel image info ' + info); + console.info('MediaLibraryTest : 001_01 pixel width ' + info.size.width); + console.info('MediaLibraryTest : 001_01 pixel height ' + info.size.height); + expect(info.size.width == size.width).assertTrue(); + expect(info.size.height == size.height).assertTrue(); + if (info.size.width == size.width && info.size.height == size.height) { + expect(true).assertTrue(); + console.info('MediaLibraryTest : getThumbnail 001_01 passed'); + done(); + } else { + expect(false).assertTrue(); + console.info('MediaLibraryTest : getThumbnail 001_01 failed'); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : getThumbnail 001_01 failed ' + error.message); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_02 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: 128, height: 256 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_02', 0, async function (done) { + try { + const fetchFileResult = await media.getFileAssets(imageFetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + let size = { width: 128, height: 256 }; + const pixelmap = await asset.getThumbnail(size); + const info = await pixelmap.getImageInfo(); + console.info('MediaLibraryTest : 001_02 pixel image info ' + info); + console.info('MediaLibraryTest : 001_02 pixel width ' + info.size.width); + console.info('MediaLibraryTest : 001_02 pixel height ' + info.size.height); + if (info.size.width == size.width && info.size.height == size.height) { + expect(true).assertTrue(); + console.info('MediaLibraryTest : getThumbnail 001_02 passed'); + done(); + } else { + expect(false).assertTrue(); + console.info('MediaLibraryTest : getThumbnail 001_02 failed'); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : getThumbnail 001_02 failed ' + error.message); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_03 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_03', 0, async function (done) { + try { + const fetchFileResult = await media.getFileAssets(imageFetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + let size = { width: 256, height: 256 }; + const pixelmap = await asset.getThumbnail(); + const info = await pixelmap.getImageInfo(); + console.info('MediaLibraryTest : 001_03 pixel image info ' + info); + console.info('MediaLibraryTest : 001_03 pixel width ' + info.size.width); + console.info('MediaLibraryTest : 001_03 pixel height ' + info.size.height); + if (info.size.width == size.width && info.size.height == size.height) { + expect(true).assertTrue(); + console.info('MediaLibraryTest : getThumbnail 001_03 passed'); + done(); + } else { + expect(false).assertTrue(); + console.info('MediaLibraryTest : getThumbnail 001_03 failed'); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : getThumbnail 001_03 failed ' + error.message); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_04 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: 1, height: 1 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_04', 0, async function (done) { + try { + const fetchFileResult = await media.getFileAssets(imageFetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + let size = { width: 1, height: 1 }; + const pixelmap = await asset.getThumbnail(size); + const info = await pixelmap.getImageInfo(); + console.info('MediaLibraryTest : 001_04 pixel image info ' + info); + console.info('MediaLibraryTest : 001_04 pixel width ' + info.size.width); + console.info('MediaLibraryTest : 001_04 pixel height ' + info.size.height); + if (info.size.width == size.width && info.size.height == size.height) { + expect(true).assertTrue(); + console.info('MediaLibraryTest : getThumbnail 001_04 passed'); + done(); + } else { + expect(false).assertTrue(); + console.info('MediaLibraryTest : getThumbnail 001_04 failed'); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : getFileAssets 001_04 failed ' + error.message); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_05 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: 0, height: 0 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_05', 0, async function (done) { + try { + const fetchFileResult = await media.getFileAssets(imageFetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + let size = { width: 0, height: 0 }; + const pixelmap = await asset.getThumbnail(size); + const info = await pixelmap.getImageInfo(); + console.info('MediaLibraryTest : 001_05 pixel image info ' + info); + console.info('MediaLibraryTest : 001_05 pixel width ' + info.size.width); + console.info('MediaLibraryTest : 001_05 pixel height ' + info.size.height); + expect(true).assertTrue(); + console.info('MediaLibraryTest : getFileAssets 001_05 failed'); + done(); + } catch (error) { + console.info('MediaLibraryTest : getFileAssets 001_05 passed'); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_06 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(image) by { width: -128, height: -128 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_06', 0, async function (done) { + try { + const fetchFileResult = await media.getFileAssets(imageFetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + let size = { width: -128, height: -128 }; + const pixelmap = await asset.getThumbnail(size); + const info = await pixelmap.getImageInfo(); + console.info('MediaLibraryTest : 001_06 pixel image info ' + info); + console.info('MediaLibraryTest : 001_06 pixel width ' + info.size.width); + console.info('MediaLibraryTest : 001_06 pixel height ' + info.size.height); + expect(true).assertTrue(); + console.info('MediaLibraryTest : getThumbnail 001_06 failed'); + done(); + } catch (error) { + console.info('MediaLibraryTest : getFileAssets 001_06 passed '); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_07 + * @tc.name : getThumbnail + * @tc.desc : getThumbnail(audio) by { width: 1024, height: 1024 } + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_001_07', 0, async function (done) { + try { + const fetchFileResult = await media.getFileAssets(imageFetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + let size = { width: 1024, height: 1024 }; + const pixelmap = await asset.getThumbnail(size); + const info = await pixelmap.getImageInfo(); + console.info('MediaLibraryTest : 003_06 pixel image info ' + info); + console.info('MediaLibraryTest : 003_06 pixel width ' + info.size.width); + console.info('MediaLibraryTest : 003_06 pixel height ' + info.size.height); + if (info.size.width == size.width && info.size.height == size.height) { + expect(true).assertTrue(); + console.info('MediaLibraryTest : getThumbnail 001_07 passed'); + done(); + } else { + expect(false).assertTrue(); + console.info('MediaLibraryTest : getThumbnail 001_07 failed'); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : getThumbnail 001_07 failed ' + error.message); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------image type end-------------------------- + + // // ------------------------------video type start ----------------------- + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_01 + // * @tc.name : getThumbnail + // * @tc.desc : getThumbnail(video) by { width: 128, height: 128 } + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_01', 0, async function (done) { + // try { + // const fetchFileResult = await media.getFileAssets(videoFetchOp); + // const dataList = await fetchFileResult.getAllObject(); + // const asset = dataList[0]; + // let size = { width: 128, height: 128 }; + // const pixelmap = await asset.getThumbnail(size); + // const info = await pixelmap.getImageInfo(); + // console.info('MediaLibraryTest : 002_01 pixel image info ' + info); + // console.info('MediaLibraryTest : 002_01 pixel width ' + info.size.width); + // console.info('MediaLibraryTest : 002_01 pixel height ' + info.size.height); + // if (info.size.width == size.width && info.size.height == size.height) { + // expect(true).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 002_01 passed'); + // done(); + // } else { + // expect(false).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 002_01 failed'); + // done(); + // } + // } catch (error) { + // console.info('MediaLibraryTest : getThumbnail 002_01 failed ' + error.message); + // expect(false).assertTrue(); + // done(); + // } + // }); + + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_02 + // * @tc.name : getThumbnail + // * @tc.desc : getThumbnail(video) by { width: 128, height: 256 } + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_02', 0, async function (done) { + // try { + // const fetchFileResult = await media.getFileAssets(videoFetchOp); + // const dataList = await fetchFileResult.getAllObject(); + // const asset = dataList[0]; + // let size = { width: 128, height: 256 }; + // const pixelmap = await asset.getThumbnail(size); + // const info = await pixelmap.getImageInfo(); + // console.info('MediaLibraryTest : 002_02 pixel image info ' + info); + // console.info('MediaLibraryTest : 002_02 pixel width ' + info.size.width); + // console.info('MediaLibraryTest : 002_02 pixel height ' + info.size.height); + // if (info.size.width == size.width && info.size.height == size.height) { + // expect(true).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 002_02 passed'); + // done(); + // } else { + // expect(false).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 002_02 failed'); + // done(); + // } + // } catch (error) { + // console.info('MediaLibraryTest : getThumbnail 002_02 failed ' + error.message); + // expect(false).assertTrue(); + // done(); + // } + // }); + + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_03 + // * @tc.name : getThumbnail + // * @tc.desc : getThumbnail(video) by no arg + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_03', 0, async function (done) { + // try { + // const fetchFileResult = await media.getFileAssets(videoFetchOp); + // const dataList = await fetchFileResult.getAllObject(); + // const asset = dataList[0]; + // let size = { width: 256, height: 256 }; + // const pixelmap = await asset.getThumbnail(); + // console.info('MediaLibraryTest : getThumbnail 002_03 Successfull ' + pixelmap); + // const info = await pixelmap.getImageInfo(); + // console.info('MediaLibraryTest : 002_03 pixel image info ' + info); + // console.info('MediaLibraryTest : 002_03 pixel width ' + info.size.width); + // console.info('MediaLibraryTest : 002_03 pixel height ' + info.size.height); + // if (info.size.width == size.width && info.size.height == size.height) { + // expect(true).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 002_03 passed'); + // done(); + // } else { + // expect(false).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 002_03 failed'); + // done(); + // } + // } catch (error) { + // console.info('MediaLibraryTest : getThumbnail 002_03 failed ' + error.message); + // expect(false).assertTrue(); + // done(); + // } + // }); + + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_04 + // * @tc.name : getThumbnail + // * @tc.desc : getThumbnail(video) by { width: 1, height: 1 } + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_04', 0, async function (done) { + // try { + // const fetchFileResult = await media.getFileAssets(videoFetchOp); + // const dataList = await fetchFileResult.getAllObject(); + // const asset = dataList[0]; + // let size = { width: 1, height: 1 }; + // const pixelmap = await asset.getThumbnail(size); + // const info = await pixelmap.getImageInfo(); + // console.info('MediaLibraryTest : 002_04 pixel image info ' + info); + // console.info('MediaLibraryTest : 002_04 pixel width ' + info.size.width); + // console.info('MediaLibraryTest : 002_04 pixel height ' + info.size.height); + // if (info.size.width == size.width && info.size.height == size.height) { + // expect(true).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 001_05 passed'); + // done(); + // } else { + // expect(false).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 001_05 failed'); + // done(); + // } + // } catch (error) { + // console.info('MediaLibraryTest : getThumbnail 002_04 failed ' + error.message); + // expect(false).assertTrue(); + // done(); + // } + // }); + + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_05 + // * @tc.name : getThumbnail + // * @tc.desc : getThumbnail(video) by { width: 0, height: 0 } + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_05', 0, async function (done) { + // try { + // const fetchFileResult = await media.getFileAssets(videoFetchOp); + // const dataList = await fetchFileResult.getAllObject(); + // const asset = dataList[0]; + // let size = { width: 0, height: 0 }; + // const pixelmap = await asset.getThumbnail(size); + // const info = await pixelmap.getImageInfo(); + // console.info('MediaLibraryTest : 002_05 pixel image info ' + info); + // console.info('MediaLibraryTest : 002_05 pixel width ' + info.size.width); + // console.info('MediaLibraryTest : 002_05 pixel height ' + info.size.height); + // console.info('MediaLibraryTest : getThumbnail 002_05 failed'); + // expect(true).assertTrue(); + // done(); + // } catch (error) { + // console.info('MediaLibraryTest : getThumbnail 002_05 passed'); + // expect(false).assertTrue(); + // done(); + // } + // }); + + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_06 + // * @tc.name : getThumbnail + // * @tc.desc : getThumbnail(video) by { width: -128, height: -128 } + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_06', 0, async function (done) { + // try { + // const fetchFileResult = await media.getFileAssets(videoFetchOp); + // const dataList = await fetchFileResult.getAllObject(); + // const asset = dataList[0]; + // let size = { width: -128, height: -128 }; + // const pixelmap = await asset.getThumbnail(size); + // const info = await pixelmap.getImageInfo(); + // console.info('MediaLibraryTest : 002_06 pixel image info ' + info); + // console.info('MediaLibraryTest : 002_06 pixel width ' + info.size.width); + // console.info('MediaLibraryTest : 002_06 pixel height ' + info.size.height); + // console.info('MediaLibraryTest : getThumbnail 003_01 failed'); + // expect(true).assertTrue(); + // done(); + // } catch (error) { + // console.info('MediaLibraryTest : getThumbnail 002_06 passed'); + // expect(false).assertTrue(); + // done(); + // } + // }); + + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_07 + // * @tc.name : getThumbnail + // * @tc.desc : getThumbnail(audio) by { width: 1024, height: 1024 } + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_002_07', 0, async function (done) { + // try { + // const fetchFileResult = await media.getFileAssets(videoFetchOp); + // const dataList = await fetchFileResult.getAllObject(); + // const asset = dataList[0]; + // let size = { width: 1024, height: 1024 }; + // const pixelmap = await asset.getThumbnail(size); + // const info = await pixelmap.getImageInfo(); + // console.info('MediaLibraryTest : 003_06 pixel image info ' + info); + // console.info('MediaLibraryTest : 003_06 pixel width ' + info.size.width); + // console.info('MediaLibraryTest : 003_06 pixel height ' + info.size.height); + // if (info.size.width == size.width && info.size.height == size.height) { + // expect(true).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 002_07 passed'); + // done(); + // } else { + // expect(false).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 002_07 failed'); + // done(); + // } + // } catch (error) { + // console.info('MediaLibraryTest : getThumbnail 002_07 failed ' + error.message); + // expect(false).assertTrue(); + // done(); + // } + // }); + // // ------------------------------video type end-------------------------- + + // // ------------------------------audio type start ----------------------- + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_01 + // * @tc.name : getThumbnail + // * @tc.desc : getThumbnail(audio) by { width: 128, height: 128 } + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_01', 0, async function (done) { + // try { + // const fetchFileResult = await media.getFileAssets(audioFetchOp); + // const dataList = await fetchFileResult.getAllObject(); + // const asset = dataList[0]; + // let size = { width: 128, height: 128 }; + // const pixelmap = await asset.getThumbnail(size); + // const info = await pixelmap.getImageInfo(); + // console.info('MediaLibraryTest : 003_01 pixel image info ' + info); + // console.info('MediaLibraryTest : 003_01 pixel width ' + info.size.width); + // console.info('MediaLibraryTest : 003_01 pixel height ' + info.size.height); + // if (info.size.width == size.width && info.size.height == size.height) { + // expect(true).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 003_01 passed'); + // done(); + // } else { + // expect(false).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 003_01 failed'); + // done(); + // } + // } catch (error) { + // console.info('MediaLibraryTest : getThumbnail 003_01 failed ' + error.message); + // expect(false).assertTrue(); + // done(); + // } + // }); + + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_02 + // * @tc.name : getThumbnail + // * @tc.desc : getThumbnail(audio) by { width: 128, height: 256 } + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_02', 0, async function (done) { + // try { + // const fetchFileResult = await media.getFileAssets(audioFetchOp); + // const dataList = await fetchFileResult.getAllObject(); + // const asset = dataList[0]; + // let size = { width: 128, height: 256 }; + // const pixelmap = await asset.getThumbnail(size); + // const info = await pixelmap.getImageInfo(); + // console.info('MediaLibraryTest : 003_02 pixel image info ' + info); + // console.info('MediaLibraryTest : 003_02 pixel width ' + info.size.width); + // console.info('MediaLibraryTest : 003_02 pixel height ' + info.size.height); + // if (info.size.width == size.width && info.size.height == size.height) { + // expect(true).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 003_02 passed'); + // done(); + // } else { + // expect(false).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 003_02 failed'); + // done(); + // } + // } catch (error) { + // console.info('MediaLibraryTest : getThumbnail 003_02 failed ' + error.message); + // expect(false).assertTrue(); + // done(); + // } + // }); + + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_03 + // * @tc.name : getThumbnail + // * @tc.desc : getThumbnail(audio) by no arg + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_03', 0, async function (done) { + // try { + // const fetchFileResult = await media.getFileAssets(audioFetchOp); + // const dataList = await fetchFileResult.getAllObject(); + // const asset = dataList[0]; + // let size = { width: 256, height: 256 }; + // const pixelmap = await asset.getThumbnail(); + // const info = await pixelmap.getImageInfo(); + // console.info('MediaLibraryTest : 003_03 pixel image info ' + info); + // console.info('MediaLibraryTest : 003_03 pixel width ' + info.size.width); + // console.info('MediaLibraryTest : 003_03 pixel height ' + info.size.height); + // if (info.size.width == size.width && info.size.height == size.height) { + // expect(true).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 003_03 passed'); + // done(); + // } else { + // expect(false).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 003_03 failed'); + // done(); + // } + // } catch (error) { + // console.info('MediaLibraryTest : getThumbnail 003_03 failed ' + error.message); + // expect(false).assertTrue(); + // done(); + // } + // }); + + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_04 + // * @tc.name : getThumbnail + // * @tc.desc : getThumbnail(audio) by { width: 1, height: 1 } + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_04', 0, async function (done) { + // try { + // const fetchFileResult = await media.getFileAssets(audioFetchOp); + // const dataList = await fetchFileResult.getAllObject(); + // const asset = dataList[0]; + // let size = { width: 1, height: 1 }; + // const pixelmap = await asset.getThumbnail(size); + // const info = await pixelmap.getImageInfo(); + // console.info('MediaLibraryTest : 003_04 pixel image info ' + info); + // console.info('MediaLibraryTest : 003_04 pixel width ' + info.size.width); + // console.info('MediaLibraryTest : 003_04 pixel height ' + info.size.height); + // if (info.size.width == size.width && info.size.height == size.height) { + // expect(true).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 003_04 passed'); + // done(); + // } else { + // expect(false).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 003_04 failed'); + // done(); + // } + // } catch (error) { + // console.info('MediaLibraryTest : getThumbnail 003_04 failed ' + error.message); + // expect(false).assertTrue(); + // done(); + // } + // }); + + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_05 + // * @tc.name : getThumbnail + // * @tc.desc : getThumbnail(audio) by { width: 0, height: 0 } + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_05', 0, async function (done) { + // try { + // const fetchFileResult = await media.getFileAssets(audioFetchOp); + // const dataList = await fetchFileResult.getAllObject(); + // const asset = dataList[0]; + // let size = { width: 0, height: 0 }; + // const pixelmap = await asset.getThumbnail(size); + // const info = await pixelmap.getImageInfo(); + // console.info('MediaLibraryTest : getThumbnail 003_06 failed'); + // console.info('MediaLibraryTest : 003_05 pixel image info ' + info); + // console.info('MediaLibraryTest : 003_05 pixel width ' + info.size.width); + // console.info('MediaLibraryTest : 003_05 pixel height ' + info.size.height); + // expect(true).assertTrue(); + // done(); + // } catch (error) { + // console.info('MediaLibraryTest : getThumbnail 003_05 passed'); + // expect(false).assertTrue(); + // done(); + // } + // }); + + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_06 + // * @tc.name : getThumbnail + // * @tc.desc : getThumbnail(audio) by { width: -128, height: -128 } + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_06', 0, async function (done) { + // try { + // const fetchFileResult = await media.getFileAssets(audioFetchOp); + // const dataList = await fetchFileResult.getAllObject(); + // const asset = dataList[0]; + // let size = { width: -128, height: -128 }; + // const pixelmap = await asset.getThumbnail(size); + // const info = await pixelmap.getImageInfo(); + // console.info('MediaLibraryTest : 003_06 pixel image info ' + info); + // console.info('MediaLibraryTest : 003_06 pixel width ' + info.size.width); + // console.info('MediaLibraryTest : 003_06 pixel height ' + info.size.height); + // console.info('MediaLibraryTest : getThumbnail 003_06 failed'); + + // expect(true).assertTrue(); + // done(); + // } catch (error) { + // console.info('MediaLibraryTest : getThumbnail 003_06 passed'); + // expect(false).assertTrue(); + // done(); + // } + // }); + + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_07 + // * @tc.name : getThumbnail + // * @tc.desc : getThumbnail(audio) by { width: 1024, height: 1024 } + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_GETTHUMBNAIL_PROMISE_003_07', 0, async function (done) { + // try { + // const fetchFileResult = await media.getFileAssets(audioFetchOp); + // const dataList = await fetchFileResult.getAllObject(); + // const asset = dataList[0]; + // let size = { width: 1024, height: 1024 }; + // const pixelmap = await asset.getThumbnail(size); + // const info = await pixelmap.getImageInfo(); + // console.info('MediaLibraryTest : 003_06 pixel image info ' + info); + // console.info('MediaLibraryTest : 003_06 pixel width ' + info.size.width); + // console.info('MediaLibraryTest : 003_06 pixel height ' + info.size.height); + // if (info.size.width == size.width && info.size.height == size.height) { + // expect(true).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 003_07 passed'); + // done(); + // } else { + // expect(false).assertTrue(); + // console.info('MediaLibraryTest : getThumbnail 003_07 failed'); + // done(); + // } + // } catch (error) { + // console.info('MediaLibraryTest : getThumbnail 003_07 failed ' + error.message); + // expect(false).assertTrue(); + // done(); + // } + // }); + // ------------------------------audio type end-------------------------- +}); diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/List.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/List.test.js index 0c2c72f8ea243de9e6880cc367660523cd926946..d122d3828f309f39da758aeeaab9604fc0199624 100644 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/List.test.js +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/List.test.js @@ -1,23 +1,37 @@ -/* - * Copyright (C) 2021 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. - */ -require('./favoriteTestCallBack.test.js') -require('./fileTestPromise.test.js') -require('./favoriteTestPromise.test.js') -require('./fileAsset2.test.js') -require('./fileAssetTestPromise.test.js') -require('./mediaLibraryTestPromise.test.js') -require('./albumGetFileAssetsPromise.test.js') -require('./albumTestPromise.test.js') - +/* + * Copyright (C) 2021 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. + */ +require('./FileAssetGetThumbnailCallBack.test.js') +require('./FileAssetGetThumbnailPromise.test.js') +require('./albumGetFileAssetsPromise.test.js') +require('./albumTestCallBack.test.js') +require('./albumTestPromise.test.js') +require('./distributed.test.js') +require('./favoriteTestCallBack.test.js') +require('./favoriteTestPromise.test.js') +require('./fetchFileResultCallBack.test.js') +require('./fetchFileResultPromise.test.js') +require('./fileAsset2.test.js') +require('./fileAssetTestPromise.test.js') +require('./fileAssetUriTestCallBack.test.js') +require('./fileTestCallBack.test.js') +require('./fileTestPromise.test.js') +require('./filekeyTestPromise.test.js') +require('./getAllPeersDeviceTestPromise.test.js') +require('./getAllPeersTestPromise.test.js') +require('./mediaLibraryTestPromise.test.js') +require('./mediaLibraryTestPromiseOnOff.test.js') +require('./favtrashTestCallBack.test.js') +require('./favtrashTestPromise.test.js') + diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumGetFileAssetsPromise.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumGetFileAssetsPromise.test.js index 73bc633a82b56e5ee34ee69bf75b44fb0b1c74ab..f7d775f1381a3e9d49aa2b19b32f805c80add5e0 100644 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumGetFileAssetsPromise.test.js +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumGetFileAssetsPromise.test.js @@ -16,7 +16,7 @@ import mediaLibrary from '@ohos.multimedia.medialibrary'; import featureAbility from '@ohos.ability.featureAbility'; import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -describe('fileAssetTestPromise.test.js', async function () { +describe('albumGetFileAssetsPromise.test.js', async function () { var context = featureAbility.getContext(); console.info('MediaLibraryTest : getMediaLibrary IN'); var media = mediaLibrary.getMediaLibrary(context); diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumTestCallBack.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumTestCallBack.test.js index fc508a42ef32f6af1b9e5da8d472beda9ee19ff7..c31f4bbfe6d3ce7a798317fbf8279ad7f58b41cc 100644 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumTestCallBack.test.js +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumTestCallBack.test.js @@ -1,633 +1,633 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility'; - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -let fileKeyObj = mediaLibrary.FileKey; -let mediaType = mediaLibrary.MediaType.IMAGE; -let AlbumNoArgsfetchOp = { - selections: '', - selectionArgs: [], -}; -let AlbumHasArgsfetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [mediaType.toString()], -}; - -let fileHasArgsfetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [mediaType.toString()], -}; -let fileNoArgsfetchOp = { - selections: '', - selectionArgs: [], -}; - -describe('album.callback.test.js', function () { - let path = 'Pictures/'; - console.info('MediaLibraryTest : Delete begin'); - let fetchFileResult = await media.getFileAssets(fileNoArgsfetchOp); - let assetList = await fetchFileResult.getAllObject(); - assetList.forEach(getAllObjectInfoDelete); - console.info('MediaLibraryTest : Delete end'); - await media.createAsset(mediaType, 'imageAlbum0003.jpg', path); - await media.createAsset(mediaType2, 'imageAlbum0004.avi', path); - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - var album; - beforeAll(function () { - onsole.info('Album Callback MediaLibraryTest: beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.'); - }); - beforeEach(function () { - console.info('Album Callback MediaLibraryTest: beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.'); - }); - afterEach(function () { - console.info('Album Callback MediaLibraryTest: afterEach: Test case-level clearance conditions, which are executed after each test case is executed.'); - }); - afterAll(function () { - console.info('Album Callback MediaLibraryTest: afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed'); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01 - * @tc.name : media.getAlbums - * @tc.desc : Get Album by AlbumNoArgsfetchOp - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01', 0, async function (done) { - media.getAlbums(AlbumNoArgsfetchOp, (err, albumList) => { - if (albumList != undefined) { - const album = albumList[0]; - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_01 album.albumName = ' + album.albumName); - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_01 album.count = ' + album.count); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_01 fail, message = ' + err); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_02 - * @tc.name : media.getAlbums - * @tc.desc : Get Album by null - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_02', 0, async function (done) { - media.getAlbums(null, (err, albumList) => { - if (albumList != undefined) { - const album = albumList[0]; - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_02 album.albumName = ' + album.albumName); - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_02 album.count = ' + album.count); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_02 fail, message = ' + err); - expect(true).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_01 - * @tc.name : media.getAlbums - * @tc.desc : Get Album by AlbumHasArgsfetchOp - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_01', 0, async function (done) { - media.getAlbums(AlbumHasArgsfetchOp, (err, albumList) => { - if (albumList != undefined) { - const album = albumList[0]; - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_01 album.albumName = ' + album.albumName); - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_01 album.count = ' + album.count); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_01 fail, message = ' + err); - expect(false).assertTrue(); - done(); - } - }); - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_02 - * @tc.name : media.getAlbums - * @tc.desc : Get Album by 666 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_02', 0, async function (done) { - media.getAlbums(666, (err, albumList) => { - if (albumList != undefined) { - const album = albumList[0]; - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_02 album.albumName = ' + album.albumName); - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_02 album.count = ' + album.count); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_02 fail, message = ' + err); - expect(true).assertTrue(); - done(); - } - }); - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_03 - * @tc.name : media.getAlbums - * @tc.desc : Get Album by '666' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_03', 0, async function (done) { - media.getAlbums('666', (err, albumList) => { - if (albumList != undefined) { - const album = albumList[0]; - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_03 album.albumName = ' + album.albumName); - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_03 album.count = ' + album.count); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_03 fail, message = ' + err); - expect(true).assertTrue(); - done(); - } - }); - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_04 - * @tc.name : media.getAlbums - * @tc.desc : Get Album by 0.666 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_04', 0, async function (done) { - media.getAlbums(0.666, (err, albumList) => { - if (albumList != undefined) { - const album = albumList[0]; - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_04 album.albumName = ' + album.albumName); - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_04 album.count = ' + album.count); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_04 fail, message = ' + err); - expect(true).assertTrue(); - done(); - } - }); - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_05 - * @tc.name : media.getAlbums - * @tc.desc : Get Album true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_05', 0, async function (done) { - media.getAlbums(true, (err, albumList) => { - if (albumList != undefined) { - const album = albumList[0]; - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_05 album.albumName = ' + album.albumName); - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_05 album.count = ' + album.count); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_05 fail, message = ' + err); - expect(true).assertTrue(); - done(); - } - }); - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_01 - * @tc.name : album.commitModify - * @tc.desc : Modify Album name 'hello' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_01', 0, async function (done) { - const albumList = await media.getAlbums(AlbumNoArgsfetchOp); - const album = albumList[0]; - console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_01 album.albumName(old) = ' + album.albumName); - album.albumName = 'hello'; - album.commitModify((err) => { - if (err == undefined) { - console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_01 album.albumName(new) = ' + album.albumName); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_01 fail, message = ' + err); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_02 - * @tc.name : album.commitModify - * @tc.desc : Modify Album name '' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_02', 0, async function (done) { - const albumList = await media.getAlbums(AlbumNoArgsfetchOp); - const album = albumList[0]; - console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_01 album.albumName(old) = ' + album.albumName); - album.albumName = ''; - album.commitModify((err) => { - if (err == undefined) { - console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_02 album.albumName(new) = ' + album.albumName); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_02 fail, message = ' + err); - expect(true).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_03 - * @tc.name : album.commitModify - * @tc.desc : Modify Album name '?*hello' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_03', 0, async function (done) { - const albumList = await media.getAlbums(AlbumNoArgsfetchOp); - const album = albumList[0]; - console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_01 album.albumName(old) = ' + album.albumName); - album.albumName = '?*hello'; - album.commitModify((err) => { - if (err == undefined) { - console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_03 album.albumName(new) = ' + album.albumName); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_03 fail, message = ' + err); - expect(true).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_04 - * @tc.name : album.commitModify - * @tc.desc : Modify Album name 'i123456...119' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_04', 0, async function (done) { - const albumList = await media.getAlbums(AlbumNoArgsfetchOp); - const album = albumList[0]; - console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_01 album.albumName(old) = ' + album.albumName); - var name = 'i'; - for (var i = 0; i < 120; i++) { - title += 'i'; - } - album.albumName = name; - album.commitModify((err) => { - if (err == undefined) { - console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_03 album.albumName(new) = ' + album.albumName); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_03 fail, message = ' + err); - expect(true).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_004_01 - * @tc.name : album.getFileAssets - * @tc.desc : Get Album Assets by fileNoArgsfetchOp - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_004_01', 0, async function (done) { - album.getFileAssets(fileNoArgsfetchOp, (err, albumFetchFileResult) => { - if (albumFetchFileResult != undefined) { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets success'); - albumFetchFileResult.getAllObject((err1, data1) => { - if (data1 != undefined) { - data1.forEach(getAllObjectInfo); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_01 success'); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_01 getAllObject :PASS'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_01 fail, message = ' + err1); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_01 getFileAssets :No data'); - expect(false).assertTrue(); - done(); - } - }); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_01 fail, message = ' + err); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_004_01 - * @tc.name : album.getFileAssets - * @tc.desc : Get Album Assets by null - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_004_02', 0, async function (done) { - album.getFileAssets(null, (err, albumFetchFileResult) => { - if (albumFetchFileResult != undefined) { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets success'); - albumFetchFileResult.getAllObject((err1, data1) => { - if (data1 != undefined) { - data1.forEach(getAllObjectInfo); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_02 success'); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_02 getAllObject :PASS'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_02 fail, message = ' + err1); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_02 getFileAssets :No data'); - expect(false).assertTrue(); - done(); - } - }); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_02 fail, message = ' + err); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_01 - * @tc.name : album.getFileAssets - * @tc.desc : Get Album Assets by fileHasArgsfetchOp - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_01', 0, async function (done) { - album.getFileAssets(fileHasArgsfetchOp, (err, albumFetchFileResult) => { - if (albumFetchFileResult != undefined) { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets success'); - albumFetchFileResult.getAllObject((err1, data1) => { - if (data1 != undefined) { - data1.forEach(getAllObjectInfo); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_01 success'); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_01 getAllObject :PASS'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_01 fail, message = ' + err1); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_01 getFileAssets :No data'); - expect(false).assertTrue(); - done(); - } - }); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_01 fail, message = ' + err); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_02 - * @tc.name : album.getFileAssets - * @tc.desc : Get Album Assets by fileHasArgsfetchOp2 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_02', 0, async function (done) { - let type2 = mediaLibrary.MediaType.VIDEO; - let fileHasArgsfetchOp2 = { - selections: fileKeyObj.MEDIA_TYPE + ' = ?', - selectionArgs: [type2.toString()], - }; - album.getFileAssets(fileHasArgsfetchOp2, (err, albumFetchFileResult) => { - if (albumFetchFileResult != undefined) { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets success'); - albumFetchFileResult.getAllObject((err1, data1) => { - if (data1 != undefined) { - data1.forEach(getAllObjectInfo); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_02 success'); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_02 getAllObject :PASS'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_02 fail, message = ' + err1); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_02 getFileAssets :No data'); - expect(false).assertTrue(); - done(); - } - }); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_02 fail, message = ' + err); - expect(false).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_03 - * @tc.name : album.getFileAssets - * @tc.desc : Get Album Assets by fileHasArgsfetchOp3 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_03', 0, async function (done) { - let fileHasArgsfetchOp3 = { - selections: fileKeyObj.MEDIA_TYPE + ' = ?', - selectionArgs: ['666'], - }; - album.getFileAssets(fileHasArgsfetchOp3, (err, albumFetchFileResult) => { - if (albumFetchFileResult != undefined) { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets success'); - albumFetchFileResult.getAllObject((err1, data1) => { - if (data1 != undefined) { - data1.forEach(getAllObjectInfo); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 success'); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 getAllObject :PASS'); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 fail, message = ' + err1); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 getFileAssets :No data'); - expect(false).assertTrue(); - done(); - } - }); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 fail, message = ' + err); - expect(true).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_04 - * @tc.name : album.getFileAssets - * @tc.desc : Get Album Assets by fileHasArgsfetchOp4 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_04', 0, async function (done) { - let type4 = mediaLibrary.MediaType.VIDEO; - let fileHasArgsfetchOp4 = { - selections: '666' + '= ?', - selectionArgs: [type4.toString()], - }; - album.getFileAssets(fileHasArgsfetchOp4, (err, albumFetchFileResult) => { - if (albumFetchFileResult != undefined) { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets success'); - albumFetchFileResult.getAllObject((err1, data1) => { - if (data1 != undefined) { - data1.forEach(getAllObjectInfo); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 success'); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 getAllObject :PASS'); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 fail, message = ' + err1); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 getFileAssets :No data'); - expect(false).assertTrue(); - done(); - } - }); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 fail, message = ' + err); - expect(true).assertTrue(); - done(); - } - }); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_05 - * @tc.name : album.getFileAssets - * @tc.desc : Get Album Assets by fileHasArgsfetchOp5 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_05', 0, async function (done) { - let fileHasArgsfetchOp5 = { - selections: '666' + '= ?', - selectionArgs: ['666'], - }; - album.getFileAssets(fileHasArgsfetchOp5, (err, albumFetchFileResult) => { - if (albumFetchFileResult != undefined) { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets success'); - albumFetchFileResult.getAllObject((err1, data1) => { - if (data1 != undefined) { - data1.forEach(getAllObjectInfo); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 success'); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 getAllObject :PASS'); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 fail, message = ' + err1); - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 getFileAssets :No data'); - expect(false).assertTrue(); - done(); - } - }); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 fail, message = ' + err); - expect(true).assertTrue(); - done(); - } - }); - }); - - function getAllObjectInfo(data) { - if (data != undefined) { - console.info('MediaLibraryTest : ALBUM_CALLBACK id is ' + data.id); - console.info('MediaLibraryTest : ALBUM_CALLBACK uri is ' + data.uri); - console.info('MediaLibraryTest : ALBUM_CALLBACK displayName is ' + data.displayName); - console.info('MediaLibraryTest : ALBUM_CALLBACK mediaType is ' + data.title); - console.info('MediaLibraryTest : ALBUM_CALLBACK relativePath is ' + data.relativePath); - } else { - console.info('MediaLibraryTest : ALBUM_CALLBACK getAllObjectInfo no album'); - } - } -}); +/* + * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import featureAbility from '@ohos.ability.featureAbility'; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +let fileKeyObj = mediaLibrary.FileKey; +let mediaType = mediaLibrary.MediaType.IMAGE; +let AlbumNoArgsfetchOp = { + selections: '', + selectionArgs: [], +}; +let AlbumHasArgsfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [mediaType.toString()], +}; + +let fileHasArgsfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [mediaType.toString()], +}; +let fileNoArgsfetchOp = { + selections: '', + selectionArgs: [], +}; + +describe('album.callback.test.js', async function () { + let path = 'Pictures/'; + console.info('MediaLibraryTest : Delete begin'); + let fetchFileResult = await media.getFileAssets(fileNoArgsfetchOp); + let assetList = await fetchFileResult.getAllObject(); + assetList.forEach(getAllObjectInfoDelete); + console.info('MediaLibraryTest : Delete end'); + await media.createAsset(mediaType, 'imageAlbum0003.jpg', path); + await media.createAsset(mediaType2, 'imageAlbum0004.avi', path); + var context = featureAbility.getContext(); + console.info('MediaLibraryTest : getMediaLibrary IN'); + var media = mediaLibrary.getMediaLibrary(context); + console.info('MediaLibraryTest : getMediaLibrary OUT'); + var album; + beforeAll(function () { + onsole.info('Album Callback MediaLibraryTest: beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.'); + }); + beforeEach(function () { + console.info('Album Callback MediaLibraryTest: beforeEach: Prerequisites at the test case level, which are executed before each test case is executed.'); + }); + afterEach(function () { + console.info('Album Callback MediaLibraryTest: afterEach: Test case-level clearance conditions, which are executed after each test case is executed.'); + }); + afterAll(function () { + console.info('Album Callback MediaLibraryTest: afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed'); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01 + * @tc.name : media.getAlbums + * @tc.desc : Get Album by AlbumNoArgsfetchOp + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_01', 0, async function (done) { + media.getAlbums(AlbumNoArgsfetchOp, (err, albumList) => { + if (albumList != undefined) { + const album = albumList[0]; + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_01 album.albumName = ' + album.albumName); + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_01 album.count = ' + album.count); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_01 fail, message = ' + err); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_02 + * @tc.name : media.getAlbums + * @tc.desc : Get Album by null + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_001_02', 0, async function (done) { + media.getAlbums(null, (err, albumList) => { + if (albumList != undefined) { + const album = albumList[0]; + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_02 album.albumName = ' + album.albumName); + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_02 album.count = ' + album.count); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_02 fail, message = ' + err); + expect(true).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_01 + * @tc.name : media.getAlbums + * @tc.desc : Get Album by AlbumHasArgsfetchOp + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_01', 0, async function (done) { + media.getAlbums(AlbumHasArgsfetchOp, (err, albumList) => { + if (albumList != undefined) { + const album = albumList[0]; + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_01 album.albumName = ' + album.albumName); + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_01 album.count = ' + album.count); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_01 fail, message = ' + err); + expect(false).assertTrue(); + done(); + } + }); + done(); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_02 + * @tc.name : media.getAlbums + * @tc.desc : Get Album by 666 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_02', 0, async function (done) { + media.getAlbums(666, (err, albumList) => { + if (albumList != undefined) { + const album = albumList[0]; + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_02 album.albumName = ' + album.albumName); + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_02 album.count = ' + album.count); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_02 fail, message = ' + err); + expect(true).assertTrue(); + done(); + } + }); + done(); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_03 + * @tc.name : media.getAlbums + * @tc.desc : Get Album by '666' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_03', 0, async function (done) { + media.getAlbums('666', (err, albumList) => { + if (albumList != undefined) { + const album = albumList[0]; + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_03 album.albumName = ' + album.albumName); + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_03 album.count = ' + album.count); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 001_03 fail, message = ' + err); + expect(true).assertTrue(); + done(); + } + }); + done(); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_04 + * @tc.name : media.getAlbums + * @tc.desc : Get Album by 0.666 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_04', 0, async function (done) { + media.getAlbums(0.666, (err, albumList) => { + if (albumList != undefined) { + const album = albumList[0]; + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_04 album.albumName = ' + album.albumName); + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_04 album.count = ' + album.count); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_04 fail, message = ' + err); + expect(true).assertTrue(); + done(); + } + }); + done(); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_05 + * @tc.name : media.getAlbums + * @tc.desc : Get Album true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_GETALBUM_CALLBACK_002_05', 0, async function (done) { + media.getAlbums(true, (err, albumList) => { + if (albumList != undefined) { + const album = albumList[0]; + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_05 album.albumName = ' + album.albumName); + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_05 album.count = ' + album.count); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getAlbum 002_05 fail, message = ' + err); + expect(true).assertTrue(); + done(); + } + }); + done(); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_01 + * @tc.name : album.commitModify + * @tc.desc : Modify Album name 'hello' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_01', 0, async function (done) { + const albumList = await media.getAlbums(AlbumNoArgsfetchOp); + const album = albumList[0]; + console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_01 album.albumName(old) = ' + album.albumName); + album.albumName = 'hello'; + album.commitModify((err) => { + if (err == undefined) { + console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_01 album.albumName(new) = ' + album.albumName); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_01 fail, message = ' + err); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_02 + * @tc.name : album.commitModify + * @tc.desc : Modify Album name '' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_02', 0, async function (done) { + const albumList = await media.getAlbums(AlbumNoArgsfetchOp); + const album = albumList[0]; + console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_01 album.albumName(old) = ' + album.albumName); + album.albumName = ''; + album.commitModify((err) => { + if (err == undefined) { + console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_02 album.albumName(new) = ' + album.albumName); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_02 fail, message = ' + err); + expect(true).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_03 + * @tc.name : album.commitModify + * @tc.desc : Modify Album name '?*hello' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_03', 0, async function (done) { + const albumList = await media.getAlbums(AlbumNoArgsfetchOp); + const album = albumList[0]; + console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_01 album.albumName(old) = ' + album.albumName); + album.albumName = '?*hello'; + album.commitModify((err) => { + if (err == undefined) { + console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_03 album.albumName(new) = ' + album.albumName); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_03 fail, message = ' + err); + expect(true).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_04 + * @tc.name : album.commitModify + * @tc.desc : Modify Album name 'i123456...119' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_MODIFYALBUM_CALLBACK_003_04', 0, async function (done) { + const albumList = await media.getAlbums(AlbumNoArgsfetchOp); + const album = albumList[0]; + console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_01 album.albumName(old) = ' + album.albumName); + var name = 'i'; + for (var i = 0; i < 120; i++) { + title += 'i'; + } + album.albumName = name; + album.commitModify((err) => { + if (err == undefined) { + console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_03 album.albumName(new) = ' + album.albumName); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK Modify 003_03 fail, message = ' + err); + expect(true).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_004_01 + * @tc.name : album.getFileAssets + * @tc.desc : Get Album Assets by fileNoArgsfetchOp + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_004_01', 0, async function (done) { + album.getFileAssets(fileNoArgsfetchOp, (err, albumFetchFileResult) => { + if (albumFetchFileResult != undefined) { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets success'); + albumFetchFileResult.getAllObject((err1, data1) => { + if (data1 != undefined) { + data1.forEach(getAllObjectInfo); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_01 success'); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_01 getAllObject :PASS'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_01 fail, message = ' + err1); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_01 getFileAssets :No data'); + expect(false).assertTrue(); + done(); + } + }); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_01 fail, message = ' + err); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_004_01 + * @tc.name : album.getFileAssets + * @tc.desc : Get Album Assets by null + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_004_02', 0, async function (done) { + album.getFileAssets(null, (err, albumFetchFileResult) => { + if (albumFetchFileResult != undefined) { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets success'); + albumFetchFileResult.getAllObject((err1, data1) => { + if (data1 != undefined) { + data1.forEach(getAllObjectInfo); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_02 success'); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_02 getAllObject :PASS'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_02 fail, message = ' + err1); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_02 getFileAssets :No data'); + expect(false).assertTrue(); + done(); + } + }); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 004_02 fail, message = ' + err); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_01 + * @tc.name : album.getFileAssets + * @tc.desc : Get Album Assets by fileHasArgsfetchOp + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_01', 0, async function (done) { + album.getFileAssets(fileHasArgsfetchOp, (err, albumFetchFileResult) => { + if (albumFetchFileResult != undefined) { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets success'); + albumFetchFileResult.getAllObject((err1, data1) => { + if (data1 != undefined) { + data1.forEach(getAllObjectInfo); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_01 success'); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_01 getAllObject :PASS'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_01 fail, message = ' + err1); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_01 getFileAssets :No data'); + expect(false).assertTrue(); + done(); + } + }); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_01 fail, message = ' + err); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_02 + * @tc.name : album.getFileAssets + * @tc.desc : Get Album Assets by fileHasArgsfetchOp2 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_02', 0, async function (done) { + let type2 = mediaLibrary.MediaType.VIDEO; + let fileHasArgsfetchOp2 = { + selections: fileKeyObj.MEDIA_TYPE + ' = ?', + selectionArgs: [type2.toString()], + }; + album.getFileAssets(fileHasArgsfetchOp2, (err, albumFetchFileResult) => { + if (albumFetchFileResult != undefined) { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets success'); + albumFetchFileResult.getAllObject((err1, data1) => { + if (data1 != undefined) { + data1.forEach(getAllObjectInfo); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_02 success'); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_02 getAllObject :PASS'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_02 fail, message = ' + err1); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_02 getFileAssets :No data'); + expect(false).assertTrue(); + done(); + } + }); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_02 fail, message = ' + err); + expect(false).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_03 + * @tc.name : album.getFileAssets + * @tc.desc : Get Album Assets by fileHasArgsfetchOp3 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_03', 0, async function (done) { + let fileHasArgsfetchOp3 = { + selections: fileKeyObj.MEDIA_TYPE + ' = ?', + selectionArgs: ['666'], + }; + album.getFileAssets(fileHasArgsfetchOp3, (err, albumFetchFileResult) => { + if (albumFetchFileResult != undefined) { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets success'); + albumFetchFileResult.getAllObject((err1, data1) => { + if (data1 != undefined) { + data1.forEach(getAllObjectInfo); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 success'); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 getAllObject :PASS'); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 fail, message = ' + err1); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 getFileAssets :No data'); + expect(false).assertTrue(); + done(); + } + }); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 fail, message = ' + err); + expect(true).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_04 + * @tc.name : album.getFileAssets + * @tc.desc : Get Album Assets by fileHasArgsfetchOp4 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_04', 0, async function (done) { + let type4 = mediaLibrary.MediaType.VIDEO; + let fileHasArgsfetchOp4 = { + selections: '666' + '= ?', + selectionArgs: [type4.toString()], + }; + album.getFileAssets(fileHasArgsfetchOp4, (err, albumFetchFileResult) => { + if (albumFetchFileResult != undefined) { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets success'); + albumFetchFileResult.getAllObject((err1, data1) => { + if (data1 != undefined) { + data1.forEach(getAllObjectInfo); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 success'); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 getAllObject :PASS'); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 fail, message = ' + err1); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 getFileAssets :No data'); + expect(false).assertTrue(); + done(); + } + }); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 fail, message = ' + err); + expect(true).assertTrue(); + done(); + } + }); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_05 + * @tc.name : album.getFileAssets + * @tc.desc : Get Album Assets by fileHasArgsfetchOp5 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + + it('SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_CALLBACK_005_05', 0, async function (done) { + let fileHasArgsfetchOp5 = { + selections: '666' + '= ?', + selectionArgs: ['666'], + }; + album.getFileAssets(fileHasArgsfetchOp5, (err, albumFetchFileResult) => { + if (albumFetchFileResult != undefined) { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets success'); + albumFetchFileResult.getAllObject((err1, data1) => { + if (data1 != undefined) { + data1.forEach(getAllObjectInfo); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 success'); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 getAllObject :PASS'); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 fail, message = ' + err1); + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 getFileAssets :No data'); + expect(false).assertTrue(); + done(); + } + }); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getFileAssets 005_03 fail, message = ' + err); + expect(true).assertTrue(); + done(); + } + }); + }); + + function getAllObjectInfo(data) { + if (data != undefined) { + console.info('MediaLibraryTest : ALBUM_CALLBACK id is ' + data.id); + console.info('MediaLibraryTest : ALBUM_CALLBACK uri is ' + data.uri); + console.info('MediaLibraryTest : ALBUM_CALLBACK displayName is ' + data.displayName); + console.info('MediaLibraryTest : ALBUM_CALLBACK mediaType is ' + data.title); + console.info('MediaLibraryTest : ALBUM_CALLBACK relativePath is ' + data.relativePath); + } else { + console.info('MediaLibraryTest : ALBUM_CALLBACK getAllObjectInfo no album'); + } + } +}); diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumTestPromise.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumTestPromise.test.js index 5f5f2485f1e45f4b5df034df2804ebbfcf502299..dcc4519c62b3139421883cf18d45cfb59d9c6523 100644 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumTestPromise.test.js +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/albumTestPromise.test.js @@ -75,7 +75,7 @@ function checkAlbumAttr(done, album) { } } -describe('album.promise.test.js', async function () { +describe('albumTestPromise.test.js', async function () { var context = featureAbility.getContext(); var media = mediaLibrary.getMediaLibrary(context); beforeAll(function () {}); @@ -392,9 +392,7 @@ describe('album.promise.test.js', async function () { }; try { const albumList = await media.getAlbums(fileHasArgsfetchOp3); - console.info( - 'SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_06 length:' + albumList.length - ); + console.info('GETALBUMASSETS_PROMISE_002_06 length:' + albumList.length); expect(albumList.length == 0).assertTrue(); done(); } catch (error) { @@ -419,9 +417,7 @@ describe('album.promise.test.js', async function () { }; try { const albumList = await media.getAlbums(fileHasArgsfetchOp4); - console.info( - 'SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_07 length:' + albumList.length - ); + console.info('GETALBUMASSETS_PROMISE_002_07 length:' + albumList.length); expect(albumList.length == 0).assertTrue(); done(); } catch (error) { @@ -447,9 +443,7 @@ describe('album.promise.test.js', async function () { try { const albumList = await media.getAlbums(fileHasArgsfetchOp5); - console.info( - 'SUB_MEDIA_MEDIALIBRARY_GETALBUMASSETS_PROMISE_002_08 length:' + albumList.length - ); + console.info('GETALBUMASSETS_PROMISE_002_08 length:' + albumList.length); expect(albumList.length == 0).assertTrue(); done(); } catch (error) { diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/createFileAssets.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/createFileAssets.test.js deleted file mode 100644 index 0803af5642ccd304f03ce8c4c8bc4168c6803861..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/createFileAssets.test.js +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - - -describe('Create_File_Assets.test.js', function () { - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - - - beforeAll(function () { - onsole.info('MediaLibraryTest: beforeAll'); - - }) - - beforeEach(function () { - console.info('MediaLibraryTest: beforeEach'); - - }) - afterEach(function () { - console.info('MediaLibraryTest: afterEach'); - - }) - afterAll(function () { - console.info('MediaLibraryTest: afterAll'); - console.info('MediaLibraryTest : createAsset : release begin'); - if (media != undefined) { - media.release(); - } - console.info('MediaLibraryTest : createAsset : release end'); - }) - - /** - * @tc.number : 01 - * @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 - * @tc.desc : Create an image file asset in predefined relative path - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 begin'); - it('SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01', 0, async function (done) { - if (media == null || media == undefined) { - console.info('MediaLibraryTest : media == null'); - } else { - let mediaType = mediaLibrary.MediaType.IMAGE; - let displayName = "02image.jpg"; - let rp = "Pictures/"; - console.info('MediaLibraryTest : createAsset begin'); - media.createAsset(mediaType, displayName, rp, (createAssetErr, fileObj) => { - if (fileObj != undefined) { - console.info('MediaLibraryTest : createAsset Successfull file uri = ' + fileObj.uri); - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : PASS'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : createAsset Unsuccessfull ' + createAssetErr.message); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : FAIL'); - expect(false).assertTrue(); - done(); - } - }); - console.info('MediaLibraryTest : createAsset end'); - } - }); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 end'); - - /** - * @tc.number : 02 - * @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02 - * @tc.desc : Create an image file asset in not predefined relative path - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02 begin'); - it('SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02', 0, async function (done) { - if (media == null || media == undefined) { - console.info('MediaLibraryTest : media == null'); - } else { - let mediaType = mediaLibrary.MediaType.IMAGE; - let displayName = "02image.jpg"; - let rp = "Pictures/test/001/"; - console.info('MediaLibraryTest : createAsset begin'); - media.createAsset(mediaType, displayName, rp, (createAssetErr, fileObj) => { - if (fileObj != undefined) { - console.info('MediaLibraryTest : createAsset Successfull file uri = ' + fileObj.uri); - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02 : PASS'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : createAsset Unsuccessfull ' + createAssetErr.message); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02 : FAIL'); - expect(false).assertTrue(); - done(); - } - }); - console.info('MediaLibraryTest : createAsset end'); - } - }); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_02 end'); - - /** - * @tc.number : 03 - * @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03 - * @tc.desc : Repeat to create same image file asset expect return error - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03 begin'); - it('SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03', 0, async function (done) { - if (media == null || media == undefined) { - console.info('MediaLibraryTest : media == null'); - } else { - let mediaType = mediaLibrary.MediaType.IMAGE; - let displayName = "02image.jpg"; - let rp = "Pictures/test/001/"; - console.info('MediaLibraryTest : createAsset begin'); - media.createAsset(mediaType, displayName, rp, (createAssetErr, fileObj) => { - if (fileObj == undefined) { - console.info('MediaLibraryTest : createAsset Unsuccessfull ' + createAssetErr.message); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03 : PASS'); - expect(true).assertTrue(); - done(); - } - console.info('MediaLibraryTest : createAsset : FAIL'); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03 : FAIL'); - expect(false).assertTrue(); - done(); - }); - console.info('MediaLibraryTest : createAsset end'); - } - }); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03 end'); - - - /** - * @tc.number : 04 - * @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04 - * @tc.desc : Create image file asset in invalid relative path expect return error - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04 begin'); - it('SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04', 0, async function (done) { - if (media == null || media == undefined) { - console.info('MediaLibraryTest : media == null'); - } else { - let mediaType = mediaLibrary.MediaType.IMAGE; - let displayName = "04image.jpg"; - let rp = "test/"; - console.info('MediaLibraryTest : createAsset begin'); - media.createAsset(mediaType, displayName, rp, (createAssetErr, fileObj) => { - if (createAssetErr != undefined) { - console.info('MediaLibraryTest : createAsset Unsuccessfull ' + createAssetErr.message); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04 : PASS'); - expect(true).assertTrue(); - done(); - } - console.info('MediaLibraryTest : createAsset : FAIL'); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04 : FAIL'); - expect(false).assertTrue(); - done(); - }); - console.info('MediaLibraryTest : createAsset end'); - } - }); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_04 end'); - - /** - * @tc.number : 07 - * @tc.name : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 - * @tc.desc : After create an image file asset, open and close it - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 begin'); - it('SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07', 0, async function (done) { - if (media == null || media == undefined) { - console.info('MediaLibraryTest : media == null'); - } else { - let mediaType = mediaLibrary.MediaType.IMAGE; - let displayName = "03image.jpg"; - - media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE, (err, rp) => { - if (rp != undefined) { - console.info('MediaLibraryTest : getPublicDirectory Successfull ' + rp); - console.info('MediaLibraryTest : createAsset begin'); - media.createAsset(mediaType, displayName, rp, (createAssetErr, data) => { - if (data != undefined) { - console.info('MediaLibraryTest : createAsset Successfull '); - getObjectInfo(data); - - } else { - console.info('MediaLibraryTest : createAsset Unsuccessfull ' + createAssetErr.message); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : FAIL'); - expect(false).assertTrue(); - done(); - } - }); - console.info('MediaLibraryTest : createAsset end'); - - } else { - console.info('MediaLibraryTest : getPublicDirectory : FAIL'); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : FAIL'); - expect(false).assertTrue(); - done(); - } - }); - - } - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 end'); - }); - - function getObjectInfo(fileAsset) { - console.info('MediaLibraryTest : getObjectInfo uri is ' + fileAsset.uri); - - console.info("==========================fileAsset.open begin=======================>"); - fileAsset.open('Rw').then((openError, fd) => { - if (openError == undefined) { - console.info('MediaLibraryTest : open : FAIL ' + openError.message); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : FAIL'); - expect(false).assertTrue(); - done(); - } - console.info("==========================fileAsset.open success=======================>"); - console.debug("open success fd = " + JSON.stringify(fd)); - console.info("==========================fileAsset.close begin=======================>"); - fileAsset.close(fd).then((closeErr) => { - if (closeErr == undefined) { - console.info('MediaLibraryTest : close : FAIL ' + closeErr.message); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : FAIL'); - expect(false).assertTrue(); - done(); - } - console.info("==========================fileAsset.close success=======================>"); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_07 : PASS'); - expect(true).assertTrue(); - done(); - }); - console.info("==========================fileAsset.close end=======================>"); - }); - console.info("==========================fileAsset.open end=======================>"); - } -}); \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/createFileAssetsPerformance.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/createFileAssetsPerformance.test.js deleted file mode 100644 index c274ebebbad6190db75462d9e597c87d6290e92f..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/createFileAssetsPerformance.test.js +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - - -describe('createFileAssetsPerformance.test.js', function () { - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - let times = 100; - - beforeAll(function () { - onsole.info('MediaLibraryTest: beforeAll'); - - }) - - beforeEach(function () { - console.info('MediaLibraryTest: beforeEach'); - - }) - afterEach(function () { - console.info('MediaLibraryTest: afterEach'); - - }) - afterAll(function () { - console.info('MediaLibraryTest: afterAll'); - }) - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_03 - * @tc.name : Create an image file asset in predefined path - * @tc.desc : Create an image file asset in predefined path - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 begin'); - it('SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01', 0, async function (done) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 begin1'); - if (media == null || media == undefined) { - console.info('MediaLibraryTest : media == null'); - } else { - let mediaType = mediaLibrary.MediaType.IMAGE; - let displayNamePrefix = "image"; - let extendStr = ".jpg" - let rp = "Pictures/"; - let displayName; - let conteEnd = 0; - for (let i = 0; i < times; i++) { - displayName = displayNamePrefix + i + extendStr; - console.info('MediaLibraryTest : createAsset begin'); - media.createAsset(mediaType, displayName, rp).then((fileObj) => { - if (fileObj != undefined) { - console.info('MediaLibraryTest : createAsset Successfull file uri = ' + fileObj.uri); - conteEnd++; - if (conteEnd == times) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 : PASS'); - expect(true).assertTrue(); - done(); - } else if (i == times) { - console.info('MediaLibraryTest : createAsset has error'); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 :Partial success'); - expect(false).assertTrue(); - done(); - } - } else { - console.info('MediaLibraryTest : createAsset Unsuccessfull '); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 : FAIL'); - expect(false).assertTrue(); - done(); - } - }); - console.info('MediaLibraryTest : createAsset end'); - } - } - }); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_PERFORMANCE_01 end'); -}); \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/deleteFileAssetsPerformance.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/deleteFileAssetsPerformance.test.js deleted file mode 100644 index 235bd2e3faad65f1d4d0ceaa437436bf4ecb9003..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/deleteFileAssetsPerformance.test.js +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - - -describe('deleteFileAssetsPerformance.test.js', function () { - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - - let fileList_; - let fileKeyObj = mediaLibrary.FileKey - let type = mediaLibrary.MediaType.IMAGE - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + " = ? ", - selectionArgs: [type.toString()], - order: fileKeyObj.DATE_ADDED, - } - beforeAll(function () { - onsole.info('MediaLibraryTest: beforeAll'); - }) - - beforeEach(function () { - console.info('MediaLibraryTest: beforeEach'); - }) - afterEach(function () { - console.info('MediaLibraryTest: afterEach'); - }) - afterAll(function () { - console.info('MediaLibraryTest: afterAll'); - }) - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01 - * @tc.name : Create an image file asset in predefined path - * @tc.desc : Create an image file asset in predefined path - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01 begin'); - it('SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01', 0, async function (done) { - media.getFileAssets(fetchOp, (getFileAssetsErr, queryResultSet) => { - if (queryResultSet != undefined) { - console.info('MediaLibraryTest : getAllObject Successfull ' + queryResultSet.getCount()); - if (queryResultSet.getCount() > 0) { - queryResultSet.getAllObject((getAllObjectErr, fileList) => { - if (fileList != undefined) { - fileList_ = fileList; - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01 :PASS'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01 :FAIL' - + getAllObjectErr.message); - expect(false).assertTrue(); - done(); - } - }); - } else { - console.info('MediaLibraryTest : getFileAssets :No data'); - expect(true).assertTrue(); - done(); - } - } else { - console.info('MediaLibraryTest : getFileAssets Unsuccessfull ' + getFileAssetsErr.message); - console.info('MediaLibraryTest : getFileAssets :FAIL'); - expect(false).assertTrue(); - done(); - } - }); - }); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_FOR_DELETE_01 end'); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_ASSET_01 - * @tc.name : Create an image file asset in predefined path - * @tc.desc : Create an image file asset in predefined path - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 begin'); - it('SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01', 0, async function (done) { - if (fileList_ != undefined) { - let counteEnd = 0; - for (let i = 0; i < fileList_.length; i++) { - let fileAsset = fileList_[i]; - console.info('MediaLibraryTest : uri is ' + fileAsset.uri); - media.deleteAsset(fileAsset.uri, (deleteAssetErr, deleteRows) => { - if (deleteRows >= 0) { - console.info('MediaLibraryTest : Delete Asset Successfull ' + deleteRows); - counteEnd++; - if (counteEnd == fileList_.length) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 : PASS'); - expect(true).assertTrue(); - done(); - } else if (i == fileList_.length - 1) { - console.info('MediaLibraryTest : delete has error'); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 :Partial success'); - expect(false).assertTrue(); - done(); - } - } else { - console.info('MediaLibraryTest : delete error ' + deleteAssetErr.message); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 :FAIL'); - expect(false).assertTrue(); - done(); - } - }); - } - } else { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 :FAIL' - + getAllObjectErr.message); - expect(false).assertTrue(); - done(); - } - }); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DELETE_FILE_PERFORMANCE_01 end'); -}); \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/distributed.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/distributed.test.js new file mode 100644 index 0000000000000000000000000000000000000000..f92d9ed33a400f6a1833c31039495af05871b3db --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/distributed.test.js @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import featureAbility from '@ohos.ability.featureAbility' +import image from '@ohos.multimedia.image'; + +import { + describe, + beforeAll, + beforeEach, + afterEach, + afterAll, + it, + expect +} from 'deccjsunit/index' +describe('distributed.promise.test.js', function () { + var context = featureAbility.getContext(); + console.info('MediaLibraryTest : getMediaLibrary IN'); + var media = mediaLibrary.getMediaLibrary(context); + console.info('MediaLibraryTest : getMediaLibrary OUT'); + beforeAll(function () { + onsole.info('Distributed. Promise MediaLibraryTest: beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.'); + + }) + + beforeEach(function () { + console.info('Distributed. Promise MediaLibraryTest: beforeEach:Prerequisites at the test case level, which are executed before each test case is executed.'); + + }) + afterEach(function () { + console.info('Distributed. Promise MediaLibraryTest: afterEach: Test case-level clearance conditions, which are executed after each test case is executed.'); + + }) + afterAll(function () { + console.info('Distributed. Promise MediaLibraryTest: afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed'); + + }) + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_distributed_001_01 + * @tc.name : getActivePeers + * @tc.desc : getActivePeers + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_001_01', 0, async function (done) { + try { + done(); + console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_001_01 begin'); + let peers = await media.getActivePeers(); + console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_001_01 done'); + done(); + } catch (error) { + console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_001_01 fail, message = ' + error); + done(); + } + done(); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_001_02 + * @tc.name : getAllPeers + * @tc.desc : getAllPeers + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_001_02', 0, async function (done) { + try { + done(); + let peers = await media.getAllPeers(); + done(); + } catch (error) { + console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_DISTRIBUTED_001_02 fail, message = ' + error); + done(); + } + done(); + }); +}) \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favTestCallBack.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favTestCallBack.test.js deleted file mode 100644 index 9518e8a68163fe568a390f5a9480bb85d5fac5cc..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favTestCallBack.test.js +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - -describe('favSmartAlbum.promise.test.js', function () { - - let mediaType = mediaLibrary.MediaType.IMAGE; - let path = "Pictures/" - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - var asset; - var favSmartAlbum; - beforeAll(function () { - console.info('Smart Album Callback MediaLibraryTest: beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.'); - }) - - beforeEach(function () { - console.info('Smart Album Callback MediaLibraryTest: beforeEach:Prerequisites at the test case level, which are executed before each test case is executed.'); - }) - afterEach(function () { - console.info('Smart Album Callback MediaLibraryTest: afterEach: Test case-level clearance conditions, which are executed after each test case is executed.'); - }) - afterAll(function () { - console.info('Smart Album Callback MediaLibraryTest: afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed'); - }) - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_CALLBACK_001 - * @tc.name : Get PrivateSmartAlbum by fav - * @tc.desc : Get PrivateSmartAlbum by fav - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_CALLBACK_001', 0, async function (done) { - try { - asset = await media.createAsset(mediaType, "imagefavtest.jpg", path); - media.getPrivateAlbum(mediaLibrary.PrivateAlbumType.TYPE_FAVORITE, getPrivateAlbumCallBack); - done(); - } catch (error) { - console.info('MediaLibraryTest : CALLBACK_001 getPrivateAlbum fail, message = ' + error); - done(); - } - }); - - function getPrivateAlbumCallBack(err, favSmartAlbums) { - if (favSmartAlbums != undefined) { - console.info('MediaLibraryTest : SMARTALBUM_CALLBACK getPrivateAlbum favSmartAlbums'); - console.info('MediaLibraryTest : SMARTALBUM_CALLBACK favSmartAlbums ' + favSmartAlbums[0].albumName); - console.info('MediaLibraryTest : SMARTALBUM_CALLBACK favSmartAlbums ' + favSmartAlbums[0].albumCapacity); - favSmartAlbum = favSmartAlbums[0]; - favSmartAlbum.addAsset(asset.uri, addAssetCallBack); - done(); - } else { - console.info('MediaLibraryTest : SMARTALBUM_CALLBACK getPrivateAlbumCallBack Unsuccessfull ' + err); - console.info('MediaLibraryTest : SMARTALBUM_CALLBACK getPrivateAlbumCallBack : FAIL'); - done(); - } - } - - function addAssetCallBack(err, data) { - if (data != undefined) { - console.info('MediaLibraryTest : SMARTALBUM_CALLBACK fav addAsset success'); - favSmartAlbum.getFileAssets(getFileAssetsCallBack); - favSmartAlbum.removeAsset(asset.uri, removeAssetCallBack); - done(); - } else { - console.info('MediaLibraryTest : SMARTALBUM_CALLBACK addAssetCallBack Unsuccessfull ' + err); - console.info('MediaLibraryTest : SMARTALBUM_CALLBACK addAssetCallBack : FAIL'); - done(); - } - } - function removeAssetCallBack(err, data) { - if (data != undefined) { - console.info('MediaLibraryTest : SMARTALBUM_CALLBACK fav removeAsset success'); - favSmartAlbum.getFileAssets(getFileAssetsCallBack); - done(); - } else { - console.info('MediaLibraryTest : SMARTALBUM_CALLBACK removeAssetCallBack Unsuccessfull ' + err); - console.info('MediaLibraryTest : SMARTALBUM_CALLBACK getPrivateremoveAssetCallBackAlbumCallBack : FAIL'); - done(); - } - } - function getFileAssetsCallBack(err, fSmartFetchFileResult) { - if (fSmartFetchFileResult != undefined) { - console.info('MediaLibraryTest : SMARTALBUM_CALLBACK getFileAssetsCallBack Successfull fSmartFetchFileResult = ' + - fSmartFetchFileResult.getCount()); - done(); - } else { - console.info('MediaLibraryTest : SMARTALBUM_CALLBACK getFileAssetsCallBack Unsuccessfull ' + err); - console.info('MediaLibraryTest : SMARTALBUM_CALLBACK getFileAssetsCallBack : FAIL'); - done(); - } - } -}) diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favTestPromise.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favTestPromise.test.js deleted file mode 100644 index 054273d8f888ef8b56c4e8bb80b0ae5029d0e71c..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favTestPromise.test.js +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - -describe('favSmartAlbum.promise.test.js', function () { - - let mediaType = mediaLibrary.MediaType.IMAGE; - let path = "Pictures/" - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - var asset; - var favSmartAlbum; - var trashSmartAlbum; - beforeAll(function () { - onsole.info('Smart Album Promise MediaLibraryTest: beforeAll: Prerequisites at the test suite level, which are executed before the test suite is executed.'); - - }) - - beforeEach(function () { - console.info('Smart Album Promise MediaLibraryTest: beforeEach:Prerequisites at the test case level, which are executed before each test case is executed.'); - - }) - afterEach(function () { - console.info('Smart Album Promise MediaLibraryTest: afterEach: Test case-level clearance conditions, which are executed after each test case is executed.'); - - }) - afterAll(function () { - console.info('Smart Album Promise MediaLibraryTest: afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed'); - - }) - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_PROMISE_001 - * @tc.name : Get PrivateSmartAlbum by fav - * @tc.desc : Get PrivateSmartAlbum by fav - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_PROMISE_001_01', 0, async function (done) { - try { - asset = await media.createAsset(mediaType, "imageGetPrivatealbum002.jpg", path); - const favSmartAlbums = await media.getPrivateAlbum(mediaLibrary.PrivateAlbumType.TYPE_FAVORITE); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getPrivateAlbum favSmartAlbums 001_01'); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE favSmartAlbums 001_01 ' + favSmartAlbums[0].albumName); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE favSmartAlbums 001_01 ' + - favSmartAlbums[0].albumCapacity); - favSmartAlbum = favSmartAlbums[0]; - expect(true).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getPrivateAlbum 001_01 fail, message = ' + error); - expect(false).assertTrue(); - done(); - } - done(); - }); - - it('SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_PROMISE_001_02', 0, async function (done) { - try { - const trashSmartAlbums = await media.getPrivateAlbum(mediaLibrary.PrivateAlbumType.TYPE_TRASH); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getPrivateAlbum trashSmartAlbums 001_02'); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE trashSmartAlbums 001_02 ' + - trashSmartAlbums[0].albumName); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE trashSmartAlbums 001_02 ' + - trashSmartAlbums[0].albumCapacity); - trashSmartAlbum = trashSmartAlbums[0]; - expect(true).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getPrivateAlbum 001_02 fail, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - it('SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_PROMISE_001_03', 0, async function (done) { - try { - const favSmartAlbums = await media.getPrivateAlbum(666); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getPrivateAlbum 001_03 success'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getPrivateAlbum 001_03 fail, message = ' + error); - expect(true).assertTrue(); - done(); - } - }); - - it('SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_PROMISE_001_04', 0, async function (done) { - try { - const favSmartAlbums = await media.getPrivateAlbum("666"); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getPrivateAlbum success 001_04'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getPrivateAlbum 001_04 fail, message = ' + error); - expect(true).assertTrue(); - done(); - } - }); - - it('SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_PROMISE_001_05', 0, async function (done) { - try { - const favSmartAlbums = await media.getPrivateAlbum(6.66666); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getPrivateAlbum success 001_05'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getPrivateAlbum 001_05 fail, message = ' + error); - expect(true).assertTrue(); - done(); - } - }); - - it('SUB_MEDIA_MEDIALIBRARY_GETPRIVATEALBUM_PROMISE_001_06', 0, async function (done) { - try { - const favSmartAlbums = await media.getPrivateAlbum(); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getPrivateAlbum success 001_06'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getPrivateAlbum 001_06 fail, message = ' + error); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ADDASSET_PROMISE_002 - * @tc.name : Add asset - * @tc.desc : Add asset - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_ADDASSET_PROMISE_002_01', 0, async function (done) { - try { - await favSmartAlbum.addAsset(asset.uri); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav addAsset 002_01 uri = ', asset.uri); - let fSmartFetchFileResult = await favSmartAlbum.getFileAssets(); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getFileAssets 002_01 Successfull fSmartFetchFileResult = ' - + fSmartFetchFileResult.getCount()); - expect(true).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav addAsset 002_01 fail, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - it('SUB_MEDIA_MEDIALIBRARY_ADDASSET_PROMISE_002_02', 0, async function (done) { - try { - await favSmartAlbum.addAsset(666); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav addAsset 002_02 fail, message = ' + error); - expect(true).assertTrue(); - done(); - } - }); - - it('SUB_MEDIA_MEDIALIBRARY_ADDASSET_PROMISE_002_03', 0, async function (done) { - try { - await favSmartAlbum.addAsset("666"); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav addAsset 002_03 fail, message = ' + error); - expect(true).assertTrue(); - done(); - } - }); - - it('SUB_MEDIA_MEDIALIBRARY_ADDASSET_PROMISE_002_04', 0, async function (done) { - try { - await favSmartAlbum.addAsset(0.666); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav addAsset 002_04 fail, message = ' + error); - expect(true).assertTrue(); - done(); - } - }); - - it('SUB_MEDIA_MEDIALIBRARY_ADDASSET_PROMISE_002_05', 0, async function (done) { - try { - await favSmartAlbum.addAsset(); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav addAsset 002_05 fail, message = ' + error); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_REMOVEASSET_PROMISE_003 - * @tc.name : Remove asset - * @tc.desc : Remove asset - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_REMOVEASSET_PROMISE_003_01', 0, async function (done) { - try { - await favSmartAlbum.removeAsset(asset.uri); - let fSmartFetchFileResultNew = await favSmartAlbum.getFileAssets(); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getFileAssets Successfull removeAsset 003_01 fSmartFetchFileResultNew = ' + - fSmartFetchFileResultNew.getCount()); - await media.deleteAsset(asset.uri); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav removeAsset 003_01 fail, message = ' + error); - } - }); - - it('SUB_MEDIA_MEDIALIBRARY_REMOVEASSET_PROMISE_003_02', 0, async function (done) { - try { - await favSmartAlbum.removeAsset(666); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav removeAsset 003_02 success'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav removeAsset 003_02 fail, message = ' + error); - expect(true).assertTrue(); - done(); - } - }); - - it('SUB_MEDIA_MEDIALIBRARY_REMOVEASSET_PROMISE_003_03', 0, async function (done) { - try { - await favSmartAlbum.removeAsset("666"); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav removeAsset 003_03 success'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav removeAsset 003_03 fail, message = ' + error); - expect(true).assertTrue(); - done(); - } - }); - - it('SUB_MEDIA_MEDIALIBRARY_REMOVEASSET_PROMISE_003_04', 0, async function (done) { - try { - await favSmartAlbum.removeAsset(0.666); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav removeAsset 003_04 success'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav removeAsset 003_04 fail, message = ' + error); - expect(true).assertTrue(); - done(); - } - }); - - it('SUB_MEDIA_MEDIALIBRARY_REMOVEASSET_PROMISE_003_05', 0, async function (done) { - try { - await favSmartAlbum.removeAsset(); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav removeAsset 003_05 success'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav removeAsset 003_05 fail, message = ' + error); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GETASSET_PROMISE_004 - * @tc.name : get FileAssets - * @tc.desc : get FileAssets - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GETASSET_PROMISE_004_01', 0, async function (done) { - try { - let fSmartFetchFileResultGet = await favSmartAlbum.getFileAssets(); - console.info('MediaLibraryTest : SMARTALBUM_PROMISE getFileAssets Successfull 004_01 fSmartFetchFileResultGet = ' + - fSmartFetchFileResultGet.getCount()); - expect(true).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : SMARTALBUM_PROMISE fav getFileAssets 004_01 fail, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); -}) diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favoriteTestCallBack.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favoriteTestCallBack.test.js index 3b2776a01135449057f3a5220ae2c82fbddbd5a9..1c94e83fb468db259c4a04a05fc15124cb476c63 100644 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favoriteTestCallBack.test.js +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favoriteTestCallBack.test.js @@ -1,1389 +1,1375 @@ -/* - * Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility'; - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -const fileKeyObj = mediaLibrary.FileKey; -const fileType = mediaLibrary.MediaType.FILE; -const imageType = mediaLibrary.MediaType.IMAGE; -const videoType = mediaLibrary.MediaType.VIDEO; -const audioType = mediaLibrary.MediaType.AUDIO; -const fileFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [fileType.toString()], -}; -const imageFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [imageType.toString()], -}; -const videoFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [videoType.toString()], -}; -const audioFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [audioType.toString()], -}; - -describe('file.callback.test.js', function () { - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - beforeAll(function () {}); - beforeEach(function () {}); - afterEach(function () {}); - afterAll(function () {}); - - // ------------------------------ file type start ------------------------ - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_01 - * @tc.name : favorite - * @tc.desc : favorite(file) by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_01', 0, async function (done) { - try { - media.getFileAssets(fileFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - asset.favorite(false, () => { - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_01 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - } - asset.favorite(true, () => { - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_01 success'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_01 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - }); - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_01 fail, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_02 - * @tc.name : favorite - * @tc.desc : favorite(file) by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_02', 0, async function (done) { - try { - media.getFileAssets(fileFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.isFavorite((err1, isFavorite) => { - if (!isFavorite) { - asset.favorite(true, () => { - asset.isFavorite((err1, isFavorite) => { - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_02 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - } - asset.favorite(false, () => { - asset.isFavorite((err1, isFavorite) => { - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_02 pass'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_02 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - - }); - }); - - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_02 fail, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_03 - * @tc.name : favorite - * @tc.desc : favorite(file) by 'true' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_03', 0, async function (done) { - try { - media.getFileAssets(fileFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite('true', () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_03 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_03 pass'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_03 pass'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_04 - * @tc.name : favorite - * @tc.desc : favorite(file) by 'false' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_04', 0, async function (done) { - try { - media.getFileAssets(fileFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite('false', () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_04 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_04 pass'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_04 pass'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_05 - * @tc.name : favorite - * @tc.desc : favorite(file) by 'fav' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_05', 0, async function (done) { - try { - media.getFileAssets(fileFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite('fav', () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_05 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_05 pass'); - expect(true).assertTrue(); - done(); - } - }); - - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_05 pass'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_06 - * @tc.name : favorite - * @tc.desc : favorite(file) by 666 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_06', 0, async function (done) { - try { - media.getFileAssets(fileFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite(666, () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_06 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_06 pass'); - expect(true).assertTrue(); - done(); - } - }); - - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_06 pass'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_07 - * @tc.name : favorite - * @tc.desc : favorite(file) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_07', 0, async function (done) { - try { - media.getFileAssets(fileFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite(() => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_07 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_07 pass'); - expect(true).assertTrue(); - done(); - } - }); - - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_07 pass'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_08 - * @tc.name : isFavorite - * @tc.desc : isFavorite(file) result false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_08', 0, async function (done) { - try { - media.getFileAssets(fileFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_08 fail'); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_08 pass'); - expect(true).assertTrue(); - done(); - } - }) - }); - - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_08 fail, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_09 - * @tc.name : isFavorite - * @tc.desc : isFavorite(file) result true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_09', 0, async function (done) { - try { - media.getFileAssets(fileFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.favorite(true, () => { - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_09 pass'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_09 fail'); - expect(false).assertTrue(); - done(); - } - }) - }); - }); - - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 001_09 fail, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - // ------------------------------ file type end ------------------------ - - - // ------------------------------ image type start ------------------------ - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_01 - * @tc.name : favorite - * @tc.desc : favorite(image) by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_01', 0, async function (done) { - try { - media.getFileAssets(imageFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - asset.favorite(false, () => { - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_01 failed'); - expect(false).assertTrue(); - done(); - } - }); - }); - } - asset.favorite(true, () => { - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_01 success'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_01 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - }); - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_01 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_02 - * @tc.name : favorite - * @tc.desc : favorite(image) by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_02', 0, async function (done) { - try { - media.getFileAssets(imageFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.isFavorite((err1, isFavorite) => { - if (!isFavorite) { - asset.favorite(true, () => { - asset.isFavorite((err1, isFavorite) => { - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_02 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - } - asset.favorite(false, () => { - asset.isFavorite((err1, isFavorite) => { - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_02 pass'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_02 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - - }); - }); - - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_02 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_03 - * @tc.name : favorite - * @tc.desc : favorite(image) by 'true' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_03', 0, async function (done) { - try { - media.getFileAssets(imageFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite('true', () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_03 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_03 passed'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_03 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_04 - * @tc.name : favorite - * @tc.desc : favorite(image) by 'false' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_04', 0, async function (done) { - try { - media.getFileAssets(imageFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite('false', () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_04 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_04 passed'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_04 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_05 - * @tc.name : favorite - * @tc.desc : favorite(image) by 'fav' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_05', 0, async function (done) { - try { - media.getFileAssets(imageFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite('fav', () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_05 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_05 passed'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_05 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_06 - * @tc.name : favorite - * @tc.desc : favorite(image) by 666 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_06', 0, async function (done) { - try { - media.getFileAssets(imageFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite(666, () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_06 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_06 passed'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_06 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_07 - * @tc.name : favorite - * @tc.desc : favorite(image) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_07', 0, async function (done) { - try { - media.getFileAssets(imageFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite(() => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_07 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_07 passed'); - expect(true).assertTrue(); - done(); - } - }); - - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_07 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_08 - * @tc.name : isFavorite - * @tc.desc : isFavorite(image) result false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_08', 0, async function (done) { - try { - media.getFileAssets(imageFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_08 fail'); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_08 pass'); - expect(true).assertTrue(); - done(); - } - }) - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_08 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_09 - * @tc.name : isFavorite - * @tc.desc : isFavorite(image) result true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_09', 0, async function (done) { - try { - media.getFileAssets(imageFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.favorite(true, () => { - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_09 pass'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_09 fail'); - expect(false).assertTrue(); - done(); - } - }) - }); - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 002_09 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - // ------------------------------ image type end ------------------------ - - // ------------------------------ video type start ------------------------ - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_01 - * @tc.name : favorite - * @tc.desc : favorite(video) by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_01', 0, async function (done) { - try { - media.getFileAssets(videoFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - asset.favorite(false, () => { - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_01 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - } - asset.favorite(true, () => { - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_01 success'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_01 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - - }); - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_01 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_02 - * @tc.name : favorite - * @tc.desc : favorite(video) by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_02', 0, async function (done) { - try { - media.getFileAssets(videoFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.isFavorite((err1, isFavorite) => { - if (!isFavorite) { - asset.favorite(true, () => { - asset.isFavorite((err1, isFavorite) => { - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_02 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - } - asset.favorite(false, () => { - asset.isFavorite((err1, isFavorite) => { - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_02 pass'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_02 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - }); - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_02 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_03 - * @tc.name : favorite - * @tc.desc : favorite(video) by 'true' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_03', 0, async function (done) { - try { - media.getFileAssets(videoFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite('true', () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_03 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_03 passed'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_03 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_04 - * @tc.name : favorite - * @tc.desc : favorite(video) by 'false' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_04', 0, async function (done) { - try { - media.getFileAssets(videoFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite('false', () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_04 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_04 passed'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_04 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_05 - * @tc.name : favorite - * @tc.desc : favorite(video) by 'fav' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_05', 0, async function (done) { - try { - media.getFileAssets(videoFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite('fav', () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_05 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_05 passed'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_05 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_06 - * @tc.name : favorite - * @tc.desc : favorite(video) by 666 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_06', 0, async function (done) { - try { - media.getFileAssets(videoFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite(666, () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_06 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_06 passed'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_06 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_07 - * @tc.name : favorite - * @tc.desc : favorite(video) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_07', 0, async function (done) { - try { - media.getFileAssets(videoFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite(() => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_07 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_07 passed'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_07 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_08 - * @tc.name : isFavorite - * @tc.desc : isFavorite(video) result false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_08', 0, async function (done) { - try { - media.getFileAssets(videoFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_08 fail'); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_08 pass'); - expect(true).assertTrue(); - done(); - } - }) - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_08 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_09 - * @tc.name : isFavorite - * @tc.desc : isFavorite(video) result true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_09', 0, async function (done) { - try { - media.getFileAssets(videoFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.favorite(true, () => { - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_09 pass'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_09 fail'); - expect(false).assertTrue(); - done(); - } - }) - }); - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 003_09 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - // ------------------------------ video type end ------------------------ - - // ------------------------------ audio type start ------------------------ - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_01 - * @tc.name : favorite - * @tc.desc : favorite(audio) by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_01', 0, async function (done) { - try { - media.getFileAssets(audioFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - asset.favorite(false, () => { - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_01 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - } - asset.favorite(true, () => { - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_01 success'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_01 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - - }); - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_01 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_02 - * @tc.name : favorite - * @tc.desc : favorite(audio) by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_02', 0, async function (done) { - try { - media.getFileAssets(audioFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.isFavorite((err1, isFavorite) => { - if (!isFavorite) { - asset.favorite(true, () => { - asset.isFavorite((err1, isFavorite) => { - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_02 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - } - asset.favorite(false, () => { - asset.isFavorite((err1, isFavorite) => { - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_02 pass'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_02 fail'); - expect(false).assertTrue(); - done(); - } - }); - }); - }); - }); - - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_02 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_03 - * @tc.name : favorite - * @tc.desc : favorite(audio) by 'true' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_03', 0, async function (done) { - try { - media.getFileAssets(audioFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite('true', () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_03 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_03 passed'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_03 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_04 - * @tc.name : favorite - * @tc.desc : favorite(audio) by 'false' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_04', 0, async function (done) { - try { - media.getFileAssets(audioFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite('false', () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_04 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_04 passed'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_04 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_05 - * @tc.name : favorite - * @tc.desc : favorite(audio) by 'fav' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_05', 0, async function (done) { - try { - media.getFileAssets(audioFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite('fav', () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_05 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_05 passed'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_05 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_06 - * @tc.name : favorite - * @tc.desc : favorite(audio) by 666 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_06', 0, async function (done) { - try { - media.getFileAssets(audioFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite(666, () => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_06 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_06 passed'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_06 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_07 - * @tc.name : favorite - * @tc.desc : favorite(audio) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_07', 0, async function (done) { - try { - media.getFileAssets(audioFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - try { - asset.favorite(() => { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_07 fail'); - expect(false).assertTrue(); - done(); - }) - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_07 passed'); - expect(true).assertTrue(); - done(); - } - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_07 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_08 - * @tc.name : isFavorite - * @tc.desc : isFavorite(audio) result false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_08', 0, async function (done) { - try { - media.getFileAssets(audioFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_08 fail'); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_08 pass'); - expect(true).assertTrue(); - done(); - } - }) - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_08 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_09 - * @tc.name : isFavorite - * @tc.desc : isFavorite(audio) result true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_09', 0, async function (done) { - try { - media.getFileAssets(audioFetchOp, (error, fileAssets) => { - fileAssets.getAllObject((error, dataList) =>{ - const asset = dataList[0]; - asset.favorite(true, () => { - asset.isFavorite((err1, isFavorite) => { - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_09 pass'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_09 fail'); - expect(false).assertTrue(); - done(); - } - }) - }); - }); - }); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_CALLBACK 004_09 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - // ------------------------------ audio type end ------------------------ -}); +/* + * Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import featureAbility from '@ohos.ability.featureAbility'; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +const fileKeyObj = mediaLibrary.FileKey; +const fileType = mediaLibrary.MediaType.FILE; +const imageType = mediaLibrary.MediaType.IMAGE; +const videoType = mediaLibrary.MediaType.VIDEO; +const audioType = mediaLibrary.MediaType.AUDIO; +const fileFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], +}; +const imageFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], +}; +const videoFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [videoType.toString()], +}; +const audioFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [audioType.toString()], +}; + +describe('favoriteTestCallBack.test.js', function () { + var context = featureAbility.getContext(); + console.info('getMediaLibrary IN'); + var media = mediaLibrary.getMediaLibrary(context); + console.info('getMediaLibrary OUT'); + beforeAll(function () {}); + beforeEach(function () {}); + afterEach(function () {}); + afterAll(function () {}); + + // ------------------------------ file type start ------------------------ + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_01 + * @tc.name : favorite + * @tc.desc : favorite(file) by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_01', 0, async function (done) { + try { + media.getFileAssets(fileFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + asset.favorite(false, () => { + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 001_01 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + } + asset.favorite(true, () => { + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 001_01 success'); + expect(true).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 001_01 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 001_01 fail, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_02 + * @tc.name : favorite + * @tc.desc : favorite(file) by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_02', 0, async function (done) { + try { + media.getFileAssets(fileFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.isFavorite((err1, isFavorite) => { + if (!isFavorite) { + asset.favorite(true, () => { + asset.isFavorite((err1, isFavorite) => { + if (!isFavorite) { + console.info('FAV_ASSET_CALLBACK 001_02 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + } + asset.favorite(false, () => { + asset.isFavorite((err1, isFavorite) => { + if (!isFavorite) { + console.info('FAV_ASSET_CALLBACK 001_02 pass'); + expect(true).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 001_02 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 001_02 fail, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_03 + * @tc.name : favorite + * @tc.desc : favorite(file) by 'true' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_03', 0, async function (done) { + try { + media.getFileAssets(fileFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite('true', () => { + console.info('FAV_ASSET_CALLBACK 001_03 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 001_03 pass'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 001_03 pass'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_04 + * @tc.name : favorite + * @tc.desc : favorite(file) by 'false' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_04', 0, async function (done) { + try { + media.getFileAssets(fileFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite('false', () => { + console.info('FAV_ASSET_CALLBACK 001_04 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 001_04 pass'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 001_04 pass'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_05 + * @tc.name : favorite + * @tc.desc : favorite(file) by 'fav' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_05', 0, async function (done) { + try { + media.getFileAssets(fileFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite('fav', () => { + console.info('FAV_ASSET_CALLBACK 001_05 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 001_05 pass'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 001_05 pass'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_06 + * @tc.name : favorite + * @tc.desc : favorite(file) by 666 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_06', 0, async function (done) { + try { + media.getFileAssets(fileFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite(666, () => { + console.info('FAV_ASSET_CALLBACK 001_06 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 001_06 pass'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 001_06 pass'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_07 + * @tc.name : favorite + * @tc.desc : favorite(file) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_07', 0, async function (done) { + try { + media.getFileAssets(fileFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite(() => { + console.info('FAV_ASSET_CALLBACK 001_07 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 001_07 pass'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 001_07 pass'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_08 + * @tc.name : isFavorite + * @tc.desc : isFavorite(file) result false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_08', 0, async function (done) { + try { + media.getFileAssets(fileFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 001_08 fail'); + expect(false).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 001_08 pass'); + expect(true).assertTrue(); + done(); + } + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 001_08 fail, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_09 + * @tc.name : isFavorite + * @tc.desc : isFavorite(file) result true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_001_09', 0, async function (done) { + try { + media.getFileAssets(fileFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.favorite(true, () => { + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 001_09 pass'); + expect(true).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 001_09 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 001_09 fail, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ file type end ------------------------ + + // ------------------------------ image type start ------------------------ + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_01 + * @tc.name : favorite + * @tc.desc : favorite(image) by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_01', 0, async function (done) { + try { + media.getFileAssets(imageFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + asset.favorite(false, () => { + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 002_01 failed'); + expect(false).assertTrue(); + done(); + } + }); + }); + } + asset.favorite(true, () => { + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 002_01 success'); + expect(true).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 002_01 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 002_01 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_02 + * @tc.name : favorite + * @tc.desc : favorite(image) by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_02', 0, async function (done) { + try { + media.getFileAssets(imageFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.isFavorite((err1, isFavorite) => { + if (!isFavorite) { + asset.favorite(true, () => { + asset.isFavorite((err1, isFavorite) => { + if (!isFavorite) { + console.info('FAV_ASSET_CALLBACK 002_02 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + } + asset.favorite(false, () => { + asset.isFavorite((err1, isFavorite) => { + if (!isFavorite) { + console.info('FAV_ASSET_CALLBACK 002_02 pass'); + expect(true).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 002_02 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 002_02 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_03 + * @tc.name : favorite + * @tc.desc : favorite(image) by 'true' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_03', 0, async function (done) { + try { + media.getFileAssets(imageFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite('true', () => { + console.info('FAV_ASSET_CALLBACK 002_03 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 002_03 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 002_03 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_04 + * @tc.name : favorite + * @tc.desc : favorite(image) by 'false' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_04', 0, async function (done) { + try { + media.getFileAssets(imageFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite('false', () => { + console.info('FAV_ASSET_CALLBACK 002_04 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 002_04 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 002_04 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_05 + * @tc.name : favorite + * @tc.desc : favorite(image) by 'fav' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_05', 0, async function (done) { + try { + media.getFileAssets(imageFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite('fav', () => { + console.info('FAV_ASSET_CALLBACK 002_05 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 002_05 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 002_05 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_06 + * @tc.name : favorite + * @tc.desc : favorite(image) by 666 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_06', 0, async function (done) { + try { + media.getFileAssets(imageFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite(666, () => { + console.info('FAV_ASSET_CALLBACK 002_06 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 002_06 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 002_06 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_07 + * @tc.name : favorite + * @tc.desc : favorite(image) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_07', 0, async function (done) { + try { + media.getFileAssets(imageFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite(() => { + console.info('FAV_ASSET_CALLBACK 002_07 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 002_07 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 002_07 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_08 + * @tc.name : isFavorite + * @tc.desc : isFavorite(image) result false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_08', 0, async function (done) { + try { + media.getFileAssets(imageFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 002_08 fail'); + expect(false).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 002_08 pass'); + expect(true).assertTrue(); + done(); + } + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 002_08 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_09 + * @tc.name : isFavorite + * @tc.desc : isFavorite(image) result true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_002_09', 0, async function (done) { + try { + media.getFileAssets(imageFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.favorite(true, () => { + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 002_09 pass'); + expect(true).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 002_09 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 002_09 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ image type end ------------------------ + + // ------------------------------ video type start ------------------------ + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_01 + * @tc.name : favorite + * @tc.desc : favorite(video) by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_01', 0, async function (done) { + try { + media.getFileAssets(videoFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + asset.favorite(false, () => { + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 003_01 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + } + asset.favorite(true, () => { + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 003_01 success'); + expect(true).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 003_01 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 003_01 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_02 + * @tc.name : favorite + * @tc.desc : favorite(video) by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_02', 0, async function (done) { + try { + media.getFileAssets(videoFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.isFavorite((err1, isFavorite) => { + if (!isFavorite) { + asset.favorite(true, () => { + asset.isFavorite((err1, isFavorite) => { + if (!isFavorite) { + console.info('FAV_ASSET_CALLBACK 003_02 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + } + asset.favorite(false, () => { + asset.isFavorite((err1, isFavorite) => { + if (!isFavorite) { + console.info('FAV_ASSET_CALLBACK 003_02 pass'); + expect(true).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 003_02 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 003_02 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_03 + * @tc.name : favorite + * @tc.desc : favorite(video) by 'true' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_03', 0, async function (done) { + try { + media.getFileAssets(videoFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite('true', () => { + console.info('FAV_ASSET_CALLBACK 003_03 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 003_03 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 003_03 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_04 + * @tc.name : favorite + * @tc.desc : favorite(video) by 'false' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_04', 0, async function (done) { + try { + media.getFileAssets(videoFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite('false', () => { + console.info('FAV_ASSET_CALLBACK 003_04 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 003_04 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 003_04 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_05 + * @tc.name : favorite + * @tc.desc : favorite(video) by 'fav' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_05', 0, async function (done) { + try { + media.getFileAssets(videoFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite('fav', () => { + console.info('FAV_ASSET_CALLBACK 003_05 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 003_05 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 003_05 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_06 + * @tc.name : favorite + * @tc.desc : favorite(video) by 666 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_06', 0, async function (done) { + try { + media.getFileAssets(videoFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite(666, () => { + console.info('FAV_ASSET_CALLBACK 003_06 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 003_06 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 003_06 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_07 + * @tc.name : favorite + * @tc.desc : favorite(video) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_07', 0, async function (done) { + try { + media.getFileAssets(videoFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite(() => { + console.info('FAV_ASSET_CALLBACK 003_07 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 003_07 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 003_07 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_08 + * @tc.name : isFavorite + * @tc.desc : isFavorite(video) result false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_08', 0, async function (done) { + try { + media.getFileAssets(videoFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 003_08 fail'); + expect(false).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 003_08 pass'); + expect(true).assertTrue(); + done(); + } + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 003_08 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_09 + * @tc.name : isFavorite + * @tc.desc : isFavorite(video) result true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_003_09', 0, async function (done) { + try { + media.getFileAssets(videoFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.favorite(true, () => { + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 003_09 pass'); + expect(true).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 003_09 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 003_09 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ video type end ------------------------ + + // ------------------------------ audio type start ------------------------ + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_01 + * @tc.name : favorite + * @tc.desc : favorite(audio) by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_01', 0, async function (done) { + try { + media.getFileAssets(audioFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + asset.favorite(false, () => { + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 004_01 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + } + asset.favorite(true, () => { + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 004_01 success'); + expect(true).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 004_01 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 004_01 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_02 + * @tc.name : favorite + * @tc.desc : favorite(audio) by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_02', 0, async function (done) { + try { + media.getFileAssets(audioFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.isFavorite((err1, isFavorite) => { + if (!isFavorite) { + asset.favorite(true, () => { + asset.isFavorite((err1, isFavorite) => { + if (!isFavorite) { + console.info('FAV_ASSET_CALLBACK 004_02 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + } + asset.favorite(false, () => { + asset.isFavorite((err1, isFavorite) => { + if (!isFavorite) { + console.info('FAV_ASSET_CALLBACK 004_02 pass'); + expect(true).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 004_02 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 004_02 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_03 + * @tc.name : favorite + * @tc.desc : favorite(audio) by 'true' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_03', 0, async function (done) { + try { + media.getFileAssets(audioFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite('true', () => { + console.info('FAV_ASSET_CALLBACK 004_03 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 004_03 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 004_03 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_04 + * @tc.name : favorite + * @tc.desc : favorite(audio) by 'false' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_04', 0, async function (done) { + try { + media.getFileAssets(audioFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite('false', () => { + console.info('FAV_ASSET_CALLBACK 004_04 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 004_04 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 004_04 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_05 + * @tc.name : favorite + * @tc.desc : favorite(audio) by 'fav' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_05', 0, async function (done) { + try { + media.getFileAssets(audioFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite('fav', () => { + console.info('FAV_ASSET_CALLBACK 004_05 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 004_05 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 004_05 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_06 + * @tc.name : favorite + * @tc.desc : favorite(audio) by 666 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_06', 0, async function (done) { + try { + media.getFileAssets(audioFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite(666, () => { + console.info('FAV_ASSET_CALLBACK 004_06 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 004_06 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 004_06 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_07 + * @tc.name : favorite + * @tc.desc : favorite(audio) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_07', 0, async function (done) { + try { + media.getFileAssets(audioFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + try { + asset.favorite(() => { + console.info('FAV_ASSET_CALLBACK 004_07 fail'); + expect(false).assertTrue(); + done(); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 004_07 passed'); + expect(true).assertTrue(); + done(); + } + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 004_07 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_08 + * @tc.name : isFavorite + * @tc.desc : isFavorite(audio) result false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_08', 0, async function (done) { + try { + media.getFileAssets(audioFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 004_08 fail'); + expect(false).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 004_08 pass'); + expect(true).assertTrue(); + done(); + } + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 004_08 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_09 + * @tc.name : isFavorite + * @tc.desc : isFavorite(audio) result true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_004_09', 0, async function (done) { + try { + media.getFileAssets(audioFetchOp, (error, fileAssets) => { + fileAssets.getAllObject((error, dataList) => { + const asset = dataList[0]; + asset.favorite(true, () => { + asset.isFavorite((err1, isFavorite) => { + if (isFavorite) { + console.info('FAV_ASSET_CALLBACK 004_09 pass'); + expect(true).assertTrue(); + done(); + } else { + console.info('FAV_ASSET_CALLBACK 004_09 fail'); + expect(false).assertTrue(); + done(); + } + }); + }); + }); + }); + } catch (error) { + console.info('FAV_ASSET_CALLBACK 004_09 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ audio type end ------------------------ +}); diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favoriteTestPromise.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favoriteTestPromise.test.js index e9ce86074c6b6b3bdb55ad546a0c6482e6aed90e..a180a8414c97ac04f4ce576a79fb39432495513c 100644 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favoriteTestPromise.test.js +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/favoriteTestPromise.test.js @@ -1,1112 +1,1112 @@ -/* - * Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility'; - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -const fileKeyObj = mediaLibrary.FileKey; -const fileType = mediaLibrary.MediaType.FILE; -const imageType = mediaLibrary.MediaType.IMAGE; -const videoType = mediaLibrary.MediaType.VIDEO; -const audioType = mediaLibrary.MediaType.AUDIO; -const fileFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [fileType.toString()], -}; -const imageFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [imageType.toString()], -}; -const videoFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [videoType.toString()], -}; -const audioFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [audioType.toString()], -}; - -describe('file.promise.test.js', function () { - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - beforeAll(function () {}); - beforeEach(function () {}); - afterEach(function () {}); - afterAll(function () {}); - - // ------------------------------ file type start ------------------------ - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_01 - * @tc.name : favorite - * @tc.desc : favorite(file) by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_01', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(fileFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - let isFavorite = await asset.isFavorite(); - if (isFavorite) { - await asset.favorite(false); - isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_01 failed'); - expect(false).assertTrue(); - done(); - } - } - await asset.favorite(true); - isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_01 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_01 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_01 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_02 - * @tc.name : favorite - * @tc.desc : favorite(file) by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_02', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(fileFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - let isFavorite = await asset.isFavorite(); - if (!isFavorite) { - await asset.favorite(true); - isFavorite = await asset.isFavorite(); - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_02 failed'); - expect(false).assertTrue(); - done(); - } - } - await asset.favorite(false); - isFavorite = await asset.isFavorite(); - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_02 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_02 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_02 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_03 - * @tc.name : favorite - * @tc.desc : favorite(file) by 'true' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_03', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(fileFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite('true'); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_03 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_03 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_04 - * @tc.name : favorite - * @tc.desc : favorite(file) by 'false' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_04', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(fileFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite('false'); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_04 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_04 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_05 - * @tc.name : favorite - * @tc.desc : favorite(file) by 'fav' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_05', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(fileFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite('fav'); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_05 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_05 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_06 - * @tc.name : favorite - * @tc.desc : favorite(file) by 666 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_06', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(fileFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite(666); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_06 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_06 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_07 - * @tc.name : favorite - * @tc.desc : favorite(file) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_07', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(fileFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite(); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_07 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_07 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_08 - * @tc.name : isFavorite - * @tc.desc : isFavorite(file) result false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_08', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(fileFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - let isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_08 failed'); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_08 passed'); - expect(true).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_08 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_09 - * @tc.name : isFavorite - * @tc.desc : isFavorite(file) result true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_09', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(fileFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite(true); - let isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_09 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_09 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_09 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - // ------------------------------ file type end ------------------------ - - // ------------------------------ image type start ------------------------ - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_01 - * @tc.name : favorite - * @tc.desc : favorite(image) by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_01', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(imageFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - let isFavorite = await asset.isFavorite(); - if (isFavorite) { - await asset.favorite(false); - isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_01 failed'); - expect(false).assertTrue(); - done(); - } - } - await asset.favorite(true); - isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_01 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_01 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_01 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_02 - * @tc.name : favorite - * @tc.desc : favorite(image) by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_02', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(imageFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - let isFavorite = await asset.isFavorite(); - if (!isFavorite) { - await asset.favorite(true); - isFavorite = await asset.isFavorite(); - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_02 failed'); - expect(false).assertTrue(); - done(); - } - } - await asset.favorite(false); - isFavorite = await asset.isFavorite(); - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_02 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_02 failed'); - - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_02 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_03 - * @tc.name : favorite - * @tc.desc : favorite(image) by 'true' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_03', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(imageFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite('true'); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_03 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_03 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_04 - * @tc.name : favorite - * @tc.desc : favorite(image) by 'false' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_04', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(imageFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite('false'); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_04 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_04 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_05 - * @tc.name : favorite - * @tc.desc : favorite(image) by 'fav' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_05', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(imageFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite('fav'); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_05 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_05 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_06 - * @tc.name : favorite - * @tc.desc : favorite(image) by 666 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_06', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(imageFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite(666); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_06 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_06 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_07 - * @tc.name : favorite - * @tc.desc : favorite(image) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_07', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(imageFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite(); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_07 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_07 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_08 - * @tc.name : isFavorite - * @tc.desc : isFavorite(image) result false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_08', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(imageFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - let isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_08 failed'); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_08 passed'); - expect(true).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_08 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_09 - * @tc.name : isFavorite - * @tc.desc : isFavorite(image) result true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_09', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(imageFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite(true); - let isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_09 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_09 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_09 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - // ------------------------------ image type end ------------------------ - - // ------------------------------ video type start ------------------------ - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_01 - * @tc.name : favorite - * @tc.desc : favorite(video) by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_01', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(videoFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - let isFavorite = await asset.isFavorite(); - if (isFavorite) { - await asset.favorite(false); - isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_01 failed'); - expect(false).assertTrue(); - done(); - } - } - await asset.favorite(true); - isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_01 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_01 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_01 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_02 - * @tc.name : favorite - * @tc.desc : favorite(video) by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_02', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(videoFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - let isFavorite = await asset.isFavorite(); - if (!isFavorite) { - await asset.favorite(true); - isFavorite = await asset.isFavorite(); - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_02 failed'); - expect(false).assertTrue(); - done(); - } - } - await asset.favorite(false); - isFavorite = await asset.isFavorite(); - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_02 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_02 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_02 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_03 - * @tc.name : favorite - * @tc.desc : favorite(video) by 'true' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_03', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(videoFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite('true'); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_03 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_03 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_04 - * @tc.name : favorite - * @tc.desc : favorite(video) by 'false' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_04', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(videoFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite('false'); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_04 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_04 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_05 - * @tc.name : favorite - * @tc.desc : favorite(video) by 'fav' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_05', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(videoFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite('fav'); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_05 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_05 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_06 - * @tc.name : favorite - * @tc.desc : favorite(video) by 666 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_06', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(videoFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite(666); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_06 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_06 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_07 - * @tc.name : favorite - * @tc.desc : favorite(video) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_07', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(videoFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite(); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_07 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_07 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_08 - * @tc.name : isFavorite - * @tc.desc : isFavorite(video) result false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_08', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(videoFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - let isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_08 failed'); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_08 passed'); - expect(true).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_08 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_09 - * @tc.name : isFavorite - * @tc.desc : isFavorite(video) result true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_09', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(videoFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite(true); - let isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_09 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_09 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_09 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - // ------------------------------ video type end ------------------------ - - // ------------------------------ audio type start ------------------------ - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_01 - * @tc.name : favorite - * @tc.desc : favorite(audio) by true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_01', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(audioFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - let isFavorite = await asset.isFavorite(); - if (isFavorite) { - await asset.favorite(false); - isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_01 failed'); - expect(false).assertTrue(); - done(); - } - } - await asset.favorite(true); - isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_01 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_01 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_01 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_02 - * @tc.name : favorite - * @tc.desc : favorite(audio) by false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_02', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(audioFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - let isFavorite = await asset.isFavorite(); - if (!isFavorite) { - await asset.favorite(true); - isFavorite = await asset.isFavorite(); - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_02 failed'); - expect(false).assertTrue(); - done(); - } - } - await asset.favorite(false); - isFavorite = await asset.isFavorite(); - if (!isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_02 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_02 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_02 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_03 - * @tc.name : favorite - * @tc.desc : favorite(audio) by 'true' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_03', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(audioFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite('true'); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_03 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_03 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_04 - * @tc.name : favorite - * @tc.desc : favorite(audio) by 'false' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_04', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(audioFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite('false'); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_04 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_04 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_05 - * @tc.name : favorite - * @tc.desc : favorite(audio) by 'fav' - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_05', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(audioFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite('fav'); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_05 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_05 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_06 - * @tc.name : favorite - * @tc.desc : favorite(audio) by 666 - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_06', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(audioFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite(666); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_06 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_06 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_07 - * @tc.name : favorite - * @tc.desc : favorite(audio) by no arg - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_07', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(audioFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite(); - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_07 failed'); - expect(false).assertTrue(); - done(); - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_07 passed'); - expect(true).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_08 - * @tc.name : isFavorite - * @tc.desc : isFavorite(audio) result false - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_08', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(audioFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - let isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_08 failed'); - expect(false).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_08 passed'); - expect(true).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_08 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_09 - * @tc.name : isFavorite - * @tc.desc : isFavorite(audio) result true - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_09', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(audioFetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - await asset.favorite(true); - let isFavorite = await asset.isFavorite(); - if (isFavorite) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_09 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_09 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_09 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - // ------------------------------ audio type end ------------------------ -}); +/* + * Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import featureAbility from '@ohos.ability.featureAbility'; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +const fileKeyObj = mediaLibrary.FileKey; +const fileType = mediaLibrary.MediaType.FILE; +const imageType = mediaLibrary.MediaType.IMAGE; +const videoType = mediaLibrary.MediaType.VIDEO; +const audioType = mediaLibrary.MediaType.AUDIO; +const fileFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], +}; +const imageFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], +}; +const videoFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [videoType.toString()], +}; +const audioFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [audioType.toString()], +}; + +describe('favoriteTestPromise.test.js', function () { + var context = featureAbility.getContext(); + console.info('MediaLibraryTest : getMediaLibrary IN'); + var media = mediaLibrary.getMediaLibrary(context); + console.info('MediaLibraryTest : getMediaLibrary OUT'); + beforeAll(function () {}); + beforeEach(function () {}); + afterEach(function () {}); + afterAll(function () {}); + + // ------------------------------ file type start ------------------------ + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_01 + * @tc.name : favorite + * @tc.desc : favorite(file) by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_01', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(fileFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + let isFavorite = await asset.isFavorite(); + if (isFavorite) { + await asset.favorite(false); + isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_01 failed'); + expect(false).assertTrue(); + done(); + } + } + await asset.favorite(true); + isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_01 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_01 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_01 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_02 + * @tc.name : favorite + * @tc.desc : favorite(file) by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_02', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(fileFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + let isFavorite = await asset.isFavorite(); + if (!isFavorite) { + await asset.favorite(true); + isFavorite = await asset.isFavorite(); + if (!isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_02 failed'); + expect(false).assertTrue(); + done(); + } + } + await asset.favorite(false); + isFavorite = await asset.isFavorite(); + if (!isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_02 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_02 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_02 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_03 + * @tc.name : favorite + * @tc.desc : favorite(file) by 'true' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_03', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(fileFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite('true'); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_03 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_03 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_04 + * @tc.name : favorite + * @tc.desc : favorite(file) by 'false' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_04', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(fileFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite('false'); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_04 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_04 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_05 + * @tc.name : favorite + * @tc.desc : favorite(file) by 'fav' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_05', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(fileFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite('fav'); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_05 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_05 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_06 + * @tc.name : favorite + * @tc.desc : favorite(file) by 666 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_06', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(fileFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite(666); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_06 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_06 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_07 + * @tc.name : favorite + * @tc.desc : favorite(file) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_07', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(fileFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite(); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_07 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_07 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_08 + * @tc.name : isFavorite + * @tc.desc : isFavorite(file) result false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_08', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(fileFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + let isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_08 failed'); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_08 passed'); + expect(true).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_08 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_09 + * @tc.name : isFavorite + * @tc.desc : isFavorite(file) result true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_001_09', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(fileFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite(true); + let isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_09 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_09 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 001_09 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ file type end ------------------------ + + // ------------------------------ image type start ------------------------ + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_01 + * @tc.name : favorite + * @tc.desc : favorite(image) by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_01', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(imageFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + let isFavorite = await asset.isFavorite(); + if (isFavorite) { + await asset.favorite(false); + isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_01 failed'); + expect(false).assertTrue(); + done(); + } + } + await asset.favorite(true); + isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_01 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_01 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_01 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_02 + * @tc.name : favorite + * @tc.desc : favorite(image) by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_02', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(imageFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + let isFavorite = await asset.isFavorite(); + if (!isFavorite) { + await asset.favorite(true); + isFavorite = await asset.isFavorite(); + if (!isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_02 failed'); + expect(false).assertTrue(); + done(); + } + } + await asset.favorite(false); + isFavorite = await asset.isFavorite(); + if (!isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_02 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_02 failed'); + + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_02 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_03 + * @tc.name : favorite + * @tc.desc : favorite(image) by 'true' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_03', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(imageFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite('true'); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_03 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_03 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_04 + * @tc.name : favorite + * @tc.desc : favorite(image) by 'false' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_04', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(imageFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite('false'); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_04 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_04 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_05 + * @tc.name : favorite + * @tc.desc : favorite(image) by 'fav' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_05', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(imageFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite('fav'); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_05 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_05 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_06 + * @tc.name : favorite + * @tc.desc : favorite(image) by 666 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_06', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(imageFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite(666); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_06 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_06 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_07 + * @tc.name : favorite + * @tc.desc : favorite(image) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_07', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(imageFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite(); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_07 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_07 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_08 + * @tc.name : isFavorite + * @tc.desc : isFavorite(image) result false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_08', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(imageFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + let isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_08 failed'); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_08 passed'); + expect(true).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_08 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_09 + * @tc.name : isFavorite + * @tc.desc : isFavorite(image) result true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_002_09', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(imageFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite(true); + let isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_09 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_09 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 002_09 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ image type end ------------------------ + + // ------------------------------ video type start ------------------------ + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_01 + * @tc.name : favorite + * @tc.desc : favorite(video) by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_01', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(videoFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + let isFavorite = await asset.isFavorite(); + if (isFavorite) { + await asset.favorite(false); + isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_01 failed'); + expect(false).assertTrue(); + done(); + } + } + await asset.favorite(true); + isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_01 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_01 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_01 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_02 + * @tc.name : favorite + * @tc.desc : favorite(video) by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_02', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(videoFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + let isFavorite = await asset.isFavorite(); + if (!isFavorite) { + await asset.favorite(true); + isFavorite = await asset.isFavorite(); + if (!isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_02 failed'); + expect(false).assertTrue(); + done(); + } + } + await asset.favorite(false); + isFavorite = await asset.isFavorite(); + if (!isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_02 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_02 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_02 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_03 + * @tc.name : favorite + * @tc.desc : favorite(video) by 'true' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_03', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(videoFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite('true'); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_03 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_03 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_04 + * @tc.name : favorite + * @tc.desc : favorite(video) by 'false' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_04', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(videoFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite('false'); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_04 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_04 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_05 + * @tc.name : favorite + * @tc.desc : favorite(video) by 'fav' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_05', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(videoFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite('fav'); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_05 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_05 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_06 + * @tc.name : favorite + * @tc.desc : favorite(video) by 666 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_06', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(videoFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite(666); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_06 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_06 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_07 + * @tc.name : favorite + * @tc.desc : favorite(video) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_07', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(videoFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite(); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_07 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_07 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_08 + * @tc.name : isFavorite + * @tc.desc : isFavorite(video) result false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_08', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(videoFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + let isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_08 failed'); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_08 passed'); + expect(true).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_08 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_09 + * @tc.name : isFavorite + * @tc.desc : isFavorite(video) result true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_003_09', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(videoFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite(true); + let isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_09 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_09 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 003_09 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ video type end ------------------------ + + // ------------------------------ audio type start ------------------------ + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_01 + * @tc.name : favorite + * @tc.desc : favorite(audio) by true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_01', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(audioFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + let isFavorite = await asset.isFavorite(); + if (isFavorite) { + await asset.favorite(false); + isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_01 failed'); + expect(false).assertTrue(); + done(); + } + } + await asset.favorite(true); + isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_01 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_01 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_01 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_02 + * @tc.name : favorite + * @tc.desc : favorite(audio) by false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_02', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(audioFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + let isFavorite = await asset.isFavorite(); + if (!isFavorite) { + await asset.favorite(true); + isFavorite = await asset.isFavorite(); + if (!isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_02 failed'); + expect(false).assertTrue(); + done(); + } + } + await asset.favorite(false); + isFavorite = await asset.isFavorite(); + if (!isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_02 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_02 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_02 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_03 + * @tc.name : favorite + * @tc.desc : favorite(audio) by 'true' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_03', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(audioFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite('true'); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_03 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_03 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_04 + * @tc.name : favorite + * @tc.desc : favorite(audio) by 'false' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_04', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(audioFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite('false'); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_04 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_04 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_05 + * @tc.name : favorite + * @tc.desc : favorite(audio) by 'fav' + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_05', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(audioFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite('fav'); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_05 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_05 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_06 + * @tc.name : favorite + * @tc.desc : favorite(audio) by 666 + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_06', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(audioFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite(666); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_06 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_06 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_07 + * @tc.name : favorite + * @tc.desc : favorite(audio) by no arg + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_07', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(audioFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite(); + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_07 failed'); + expect(false).assertTrue(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_07 passed'); + expect(true).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_08 + * @tc.name : isFavorite + * @tc.desc : isFavorite(audio) result false + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_08', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(audioFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + let isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_08 failed'); + expect(false).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_08 passed'); + expect(true).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_08 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_09 + * @tc.name : isFavorite + * @tc.desc : isFavorite(audio) result true + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_PROMISE_004_09', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(audioFetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + await asset.favorite(true); + let isFavorite = await asset.isFavorite(); + if (isFavorite) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_09 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_09 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('MediaLibraryTest : FAV_ASSET_PROMISE 004_09 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ audio type end ------------------------ +}); diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fetchFileResultCallBack.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fetchFileResultCallBack.test.js new file mode 100644 index 0000000000000000000000000000000000000000..bb7bfde9eeb8e59197c683a0eaca529fd9587cf2 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fetchFileResultCallBack.test.js @@ -0,0 +1,733 @@ +/* + * Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import featureAbility from '@ohos.ability.featureAbility'; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +let fileKeyObj = mediaLibrary.FileKey; +let fileType = mediaLibrary.MediaType.IMAGE; +let imageType = mediaLibrary.MediaType.IMAGE; +let videoType = mediaLibrary.MediaType.VIDEO; +let audioType = mediaLibrary.MediaType.AUDIO; + +let getFileCountOneOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + order: fileKeyObj.DATE_ADDED, + extendArgs: 'LIMIT 0,1', +}; + +let getFileCountTwoOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + order: fileKeyObj.DATE_ADDED, + extendArgs: 'LIMIT 0,2', +}; + +let getFileCountTenOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + order: fileKeyObj.DATE_ADDED, + extendArgs: 'LIMIT 0,10', +}; + +let getFileCountOneHundredOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + order: fileKeyObj.DATE_ADDED, + extendArgs: 'LIMIT 0,100', +}; + +let getFirstObjectOp = { + selections: fileKeyObj.RELATIVE_PATH + '= ?', + selectionArgs: ['camera/'], + order: fileKeyObj.ID, + extendArgs: 'LIMIT 0,5', +}; + +let getAllObjectLimitOneOp = { + selections: fileKeyObj.RELATIVE_PATH + '= ?', + selectionArgs: ['camera/'], + order: fileKeyObj.ID, + extendArgs: 'LIMIT 0,1', +}; + +let getAllObjectLimitTwoOp = { + selections: fileKeyObj.RELATIVE_PATH + '= ?', + selectionArgs: ['camera/'], + order: fileKeyObj.ID, + extendArgs: 'LIMIT 0,1', +}; + +let getAllObjectLimitOneHundredOp = { + selections: fileKeyObj.RELATIVE_PATH + '= ?', + selectionArgs: ['camera/'], + order: fileKeyObj.ID, + extendArgs: 'LIMIT 0,100', +}; + +let getFileCountZeroOp = { + selections: + fileKeyObj.DISPLAY_NAME + + '= "The world has kissed my soul with its pain, asking for its return in songs."', +}; + +let targetAttrs = { + 3: { + id: 3, + // uri: 'dataability:///media/audio', + mimeType: 'audio/*', + mediaType: videoType, + displayName: '01.mp3', + title: '01', + relativePath: 'camera/', + parent: 1, + size: 3513962, + dateAdded: 1501923717, + dateModified: 1501923708, + dateTaken: 0, + // artist: '', + // audioAlbum: '', + width: 0, + height: 0, + orientation: 0, + duration: 0, + albumId: 0, + albumUri: '', + // albumName: '', + }, + 4: { + id: 4, + // uri: 'dataability:///media/audio', + mimeType: 'image/*', + mediaType: imageType, + displayName: '02.jpg', + title: '02', + relativePath: 'camera/', + parent: 1, + size: 348113, + dateAdded: 1501923717, + dateModified: 1501923707, + dateTaken: 0, + // artist: '', + // audioAlbum: '', + width: 1279, + height: 1706, + orientation: 0, + duration: 0, + // albumId: 0, + // albumUri: '', + // albumName: '', + }, + 9: { + id: 9, + // uri: 'dataability:///media/audio', + mimeType: 'audio/*', + mediaType: audioType, + displayName: '02.mp3', + title: '02', + relativePath: 'camera/', + parent: 1, + size: 3513962, + dateAdded: 1501923717, + dateModified: 1501923710, + dateTaken: 0, + // artist: '', + // audioAlbum: '', + width: 0, + height: 0, + orientation: 0, + duration: 0, + // albumId: 0, + // albumUri: '', + // albumName: '', + }, +}; + +function checkAssetAttr(done, asset, attr, test_num) { + if ( + !( + ( + asset.id == attr.id && + // asset.uri == attr.uri && + asset.mimeType == attr.mimeType && + asset.mediaType == attr.mediaType && + asset.displayName == attr.displayName && + asset.title == attr.title && + asset.relativePath == attr.relativePath && + asset.parent == attr.parent && + asset.size == attr.size && + asset.dateAdded == attr.dateAdded && + asset.dateModified == attr.dateModified && + asset.dateTaken == attr.dateTaken && + // asset.artist == attr.artist && + // asset.audioAlbum == attr.audioAlbum && + asset.width == attr.width && + asset.height == attr.height && + asset.orientation == attr.orientation && + asset.duration == attr.duration + ) + // asset.albumId == attr.albumId && + // asset.albumUri == attr.albumUri && + // asset.albumName == attr.albumName + ) + ) { + console.info(`MediaLibraryTest : ASSET_CHECK ${test_num} failed`); + expect(false).assertTrue(); + } +} + +function objectCheckCallback(err, targetObject) { + if (err) { + expect(false).assertTrue(); + } + if (targetObject == undefined) { + expect(false).assertTrue(); + } + var targetAttr = targetAttrs[targetObject.id.toString()]; + checkAssetAttr(targetObject, targetAttr, ''); + expect(true).assertTrue(); +} + +function objectCheckErrorCallback(err, targetObject) { + if (targetObject == undefined) { + expect(true).assertTrue(); + } else { + expect(false).assertTrue(); + } +} + +function AllObjectCheckCallback(err, targetObjects) { + if (err) { + expect(false).assertTrue(); + } else if (targetObjects == undefined) { + expect(false).assertTrue(); + } else if (targetObjects.length > 0) { + for (var i = 0; i < targetObjects.length; i++) { + var targetObject = targetObjects[i]; + let targetAttr = attrs[i]; + checkAssetAttr(targetObject, targetAttr, ''); + } + expect(true).assertTrue(); + } else { + expect(false).assertTrue(); + } +} + +function AllObjectCheckOneCallback(err, targetObjects) { + if (err) { + expect(false).assertTrue(); + } else if (targetObjects == undefined) { + expect(false).assertTrue(); + } else if (targetObjects.length > 0) { + var targetObject = targetObjects[0]; + let targetAttr = attrs[i]; + checkAssetAttr(targetObject, targetAttr, ''); + expect(true).assertTrue(); + } else { + expect(false).assertTrue(); + } +} + +describe('fetch.file.result.callback.test.js', async function () { + var context = featureAbility.getContext(); + var media = mediaLibrary.getMediaLibrary(context); + beforeAll(function () { }); + beforeEach(function () { }); + afterEach(function () { }); + afterAll(function () { }); + + // ------------------------------ 001 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_01 + * @tc.name : getCount + * @tc.desc : Get FetchResult by getFileCountOneOp, check the return value of the interface (by Call'ba'c'k) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_01', 0, async function (done) { + try { + console.info('MediaLibraryTest : Get Count begin'); + let fetchFileResult = await media.getFileAssets(getFileCountOneOp); + const fetchCount = fetchFileResult.getCount(); + console.info('MediaLibraryTest : count:' + fetchCount); + expect(fetchCount == 1).assertTrue(); + console.info('MediaLibraryTest : Get Count end'); + fetchFileResult.close(); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT getCount 001_01 failed, message = ' + error + ); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_02 + * @tc.name : getCount + * @tc.desc : Get FetchResult by getFileCountTwoOp, check the return value of the interface (by Callback) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_02', 0, async function (done) { + try { + console.info('MediaLibraryTest : Get Count begin'); + let fetchFileResult = await media.getFileAssets(getFileCountTwoOp); + const fetchCount = fetchFileResult.getCount(); + console.info('MediaLibraryTest : count:' + fetchCount); + expect(fetchCount == 2).assertTrue(); + console.info('MediaLibraryTest : Get Count end'); + fetchFileResult.close(); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT getCount 001_02 failed, message = ' + error + ); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_03 + * @tc.name : getCount + * @tc.desc : Get FetchResult by getFileCountOneHundredOp, check the return value of the interface (by Callback) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_03', 0, async function (done) { + try { + console.info('MediaLibraryTest : Get Count begin'); + let fetchFileResult = await media.getFileAssets(getFileCountOneHundredOp); + const fetchCount = fetchFileResult.getCount(); + console.info('MediaLibraryTest : count:' + fetchCount); + expect(fetchCount == 100).assertTrue(); + console.info('MediaLibraryTest : Get Count end'); + fetchFileResult.close(); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT getCount 001_03 failed, message = ' + error + ); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_04 + * @tc.name : getCount + * @tc.desc : Get FetchResult by getFileCountZeroOp, check the return value of the interface (by Callback) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_CALLBACK_001_04', 0, async function (done) { + try { + console.info('MediaLibraryTest : Get Count begin'); + let fetchFileResult = await media.getFileAssets(getFileCountZeroOp); + const fetchCount = fetchFileResult.getCount(); + console.info('MediaLibraryTest : count:' + fetchCount); + expect(fetchCount == 0).assertTrue(); + console.info('MediaLibraryTest : Get Count end'); + fetchFileResult.close(); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT getCount 001_04 failed, message = ' + error + ); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ 001 test end ------------------------- + + // ------------------------------ 002 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_ISAFTERLAST_CALLBACK_002 + * @tc.name : getCount + * @tc.desc : Get FetchResult by getFileCountTenOp, check the return value of the interface (by Callback) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_ISAFTERLAST_CALLBACK_002', 0, async function (done) { + try { + console.info('MediaLibraryTest : isAfterLast begin'); + let fetchFileResult = await media.getFileAssets(getFileCountTenOp); + const fetchCount = fetchFileResult.getCount(); + console.info('MediaLibraryTest : count:' + fetchCount); + let fileAsset = await fetchFileResult.getFirstObject(); + for (var i = 1; i < fetchCount; i++) { + fileAsset = await fetchFileResult.getNextObject(); + if (i == fetchCount - 1) { + console.info('MediaLibraryTest : isLast'); + var result = fetchFileResult.isAfterLast(); + console.info('MediaLibraryTest : isAfterLast:' + result); + expect(true).assertTrue(); + console.info('MediaLibraryTest : isAfterLast end'); + fetchFileResult.close(); + done(); + } + } + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT isAfterLast 002 failed, message = ' + error + ); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ 002 test end ------------------------- + + // ------------------------------ 003 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_CLOSE_CALLBACK_003 + * @tc.name : getCount + * @tc.desc : Get FetchResult, close it, check if result closed + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_CLOSE_CALLBACK_003', 0, async function (done) { + try { + console.info('MediaLibraryTest : CLOSE begin'); + let fetchFileResult = await media.getFileAssets(getFileCountTenOp); + fetchFileResult.close(); + try { + fetchFileResult.getCount(); + console.info('MediaLibraryTest : CLOSE failed'); + expect(false).assertTrue(); + done(); + } catch { + console.info('MediaLibraryTest : CLOSE closed'); + expect(true).assertTrue(); + done(); + } + console.info('MediaLibraryTest : CLOSE end'); + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT close 003 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ 003 test end ------------------------- + + // ------------------------------ 004 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_CALLBACK_004 + * @tc.name : getFirstObject + * @tc.desc : Get FetchResult, get first object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_CALLBACK_004', 0, async function (done) { + try { + console.info('MediaLibraryTest : GETFIRSTOBJECT begin'); + let fetchFileResult = await media.getFileAssets(getFirstObjectOp); + fetchFileResult.getFirstObject(objectCheckCallback); + fetchFileResult.close(); + console.info('MediaLibraryTest : GETFIRSTOBJECT end'); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT getFirstObject 004 failed, message = ' + error + ); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ 004 test end ------------------------- + + // ------------------------------ 005 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_CALLBACK_005 + * @tc.name : getNextObject + * @tc.desc : Get FetchResult, get first object, get next object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_CALLBACK_005', 0, async function (done) { + try { + console.info('MediaLibraryTest : GETNEXTOBJECT begin'); + let fetchFileResult = await media.getFileAssets(getFirstObjectOp); + let firstObject = await fetchFileResult.getFirstObject(); + fetchFileResult.getNextObject(objectCheckCallback); + fetchFileResult.close(); + done(); + console.info('MediaLibraryTest : GETNEXTOBJECT end'); + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT getNextObject 005 failed, message = ' + error + ); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ 005 test end ------------------------- + + // ------------------------------ 006 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_CALLBACK_006 + * @tc.name : getNextObject + * @tc.desc : Get FetchResult, get first object, get next object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_CALLBACK_006', 0, async function (done) { + try { + console.info('MediaLibraryTest : GETLASTOBJECT begin'); + let fetchFileResult = await media.getFileAssets(getFirstObjectOp); + fetchFileResult.getLastObject(objectCheckCallback); + fetchFileResult.close(); + done(); + console.info('MediaLibraryTest : GETLASTOBJECT end'); + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT getLastObject 006 failed, message = ' + error + ); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ 006 test end ------------------------- + + // ------------------------------ 007 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_01 + * @tc.name : getPositionObject + * @tc.desc : Get FetchResult, get position 0 object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it( + 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_01', + 0, + async function (done) { + try { + console.info('MediaLibraryTest : GETPOSITIONOBJECT 0 begin'); + let fetchFileResult = await media.getFileAssets(getFirstObjectOp); + fetchFileResult.getPositionObject(0, objectCheckCallback); + fetchFileResult.close(); + done(); + console.info('MediaLibraryTest : GETPOSITIONOBJECT 0 end'); + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT getPositionObject 007_01 failed, message = ' + + error + ); + expect(false).assertTrue(); + done(); + } + } + ); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_02 + * @tc.name : getPositionObject + * @tc.desc : Get FetchResult, get position 1 object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it( + 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_02', + 0, + async function (done) { + try { + nowDone = done; + console.info('MediaLibraryTest : GETPOSITIONOBJECT 1 begin'); + let fetchFileResult = await media.getFileAssets(getFirstObjectOp); + fetchFileResult.getPositionObject(1, objectCheckCallback); + fetchFileResult.close(); + done(); + console.info('MediaLibraryTest : GETPOSITIONOBJECT 1 end'); + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT getPositionObject 007_02 failed, message = ' + + error + ); + expect(false).assertTrue(); + done(); + } + } + ); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_02 + * @tc.name : getPositionObject + * @tc.desc : Get FetchResult, get position 1 object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it( + 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_03', + 0, + async function (done) { + try { + nowDone = done; + console.info('MediaLibraryTest : GETPOSITIONOBJECT last begin'); + let fetchFileResult = await media.getFileAssets(getFirstObjectOp); + const count = fetchFileResult.getCount(); + fetchFileResult.getPositionObject(count - 1, objectCheckCallback); + fetchFileResult.close(); + done(); + console.info('MediaLibraryTest : GETPOSITIONOBJECT last end'); + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT getPositionObject 007_03 failed, message = ' + + error + ); + expect(false).assertTrue(); + done(); + } + } + ); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_04 + * @tc.name : getPositionObject + * @tc.desc : Get FetchResult, get position 1 object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it( + 'SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_CALLBACK_007_04', + 0, + async function (done) { + try { + nowDone = done; + console.info('MediaLibraryTest : GETPOSITIONOBJECT out of index begin'); + let fetchFileResult = await media.getFileAssets(getFirstObjectOp); + const count = fetchFileResult.getCount(); + try { + fetchFileResult.getPositionObject(count + 100, objectCheckErrorCallback); + if (targetObject == undefined) { + expect(true).assertTrue(); + fetchFileResult.close(); + done(); + } + expect(false).assertTrue(); + fetchFileResult.close(); + done(); + } catch (err) { + expect(true).assertTrue(); + fetchFileResult.close(); + done(); + } + console.info('MediaLibraryTest : GETPOSITIONOBJECT out of index end'); + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT getPositionObject 007_04 failed, message = ' + + error + ); + expect(false).assertTrue(); + done(); + } + } + ); + // ------------------------------ 007 test end ------------------------- + + // ------------------------------ 008 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_01 + * @tc.name : getAllObject + * @tc.desc : Get FetchResult, get all object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_01', 0, async function (done) { + try { + nowDone = done; + console.info('MediaLibraryTest : GETALLOBJECT begin'); + let fetchFileResult = await media.getFileAssets(getAllObjectLimitOneOp); + fetchFileResult.getAllObject(AllObjectCheckCallback); + console.info('MediaLibraryTest : GETALLOBJECT end'); + fetchFileResult.close(); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT getAllObject 008_01 failed, message = ' + error + ); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_02 + * @tc.name : getAllObject + * @tc.desc : Get FetchResult, get all object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_02', 0, async function (done) { + try { + nowDone = done; + console.info('MediaLibraryTest : GETALLOBJECT begin'); + let fetchFileResult = await media.getFileAssets(getAllObjectLimitTwoOp); + fetchFileResult.getAllObject(AllObjectCheckCallback); + console.info('MediaLibraryTest : GETALLOBJECT end'); + fetchFileResult.close(); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT getAllObject 008_02 failed, message = ' + error + ); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_03 + * @tc.name : getAllObject + * @tc.desc : Get FetchResult, get all object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_CALLBACK_008_03', 0, async function (done) { + try { + console.info('MediaLibraryTest : GETALLOBJECT begin'); + let fetchFileResult = await media.getFileAssets(getAllObjectLimitOneHundredOp); + fetchFileResult.getAllObject(AllObjectCheckOneCallback); + fetchFileResult.close(); + done(); + console.info('MediaLibraryTest : GETALLOBJECT end'); + } catch (error) { + console.info( + 'MediaLibraryTest : FETCHRESULT getAllObject 008_03 failed, message = ' + error + ); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ 008 test end ------------------------- +}); diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fetchFileResultPromise.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fetchFileResultPromise.test.js new file mode 100644 index 0000000000000000000000000000000000000000..bd53ff35e830e91a48cd426b66c51f98799475a3 --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fetchFileResultPromise.test.js @@ -0,0 +1,822 @@ +/* + * Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import featureAbility from '@ohos.ability.featureAbility'; + +import { + describe, + beforeAll, + beforeEach, + afterEach, + afterAll, + it, + expect +} from 'deccjsunit/index'; +let fileKeyObj = mediaLibrary.FileKey; +let fileType = mediaLibrary.MediaType.FILE; +let imageType = mediaLibrary.MediaType.IMAGE; +let videoType = mediaLibrary.MediaType.VIDEO; +let audioType = mediaLibrary.MediaType.AUDIO; + +let getFileCountOneOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC LIMIT 0,1", + extendArgs: "", +}; + +let getFileCountTwoOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC LIMIT 0,2", + extendArgs: "", +}; + +let getFileCountTenOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC LIMIT 0,10", + extendArgs: "", +}; + +let getFileCountOneHundredOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + order: fileKeyObj.DATE_ADDED + " DESC LIMIT 0,100", + extendArgs: "", +}; + +let getFirstObjectOp = { + selections: fileKeyObj.RELATIVE_PATH + '= ?', + selectionArgs: ['camera/'], + order: fileKeyObj.ID + " DESC LIMIT 0,5", + extendArgs: "", +} + +let getAllObjectLimitOneOp = { + selections: fileKeyObj.RELATIVE_PATH + '= ?', + selectionArgs: ['camera/'], + order: fileKeyObj.ID + " DESC LIMIT 0,1", + extendArgs: "", +} + +let getAllObjectLimitTwoOp = { + selections: fileKeyObj.RELATIVE_PATH + '= ?', + selectionArgs: ['camera/'], + order: fileKeyObj.ID + " DESC LIMIT 0,1", + extendArgs: "", +} + +let getAllObjectLimitOneHundredOp = { + selections: fileKeyObj.RELATIVE_PATH + '= ?', + selectionArgs: ['camera/'], + order: fileKeyObj.ID + " DESC LIMIT 0,100", + extendArgs: "", +} + +let getFileCountZeroOp = { + selections: fileKeyObj.DISPLAY_NAME + '=?', + selectionArgs: ['The world has kissed my soul with its pain, asking for its return in songs.'], +}; + +function checkAssetAttr(done, asset, attr, test_num) { + expect(asset.id != undefined).assertTrue(); + expect(asset.mimeType != undefined).assertTrue(); + expect(asset.displayName != undefined).assertTrue(); + expect(asset.title != undefined).assertTrue(); + expect(asset.relativePath != undefined).assertTrue(); + expect(asset.parent != undefined).assertTrue(); + expect(asset.size != undefined).assertTrue(); + expect(asset.dateAdded != undefined).assertTrue(); + expect(asset.dateModified != undefined).assertTrue(); + expect(asset.dateTaken != undefined).assertTrue(); + expect(asset.width != undefined).assertTrue(); + expect(asset.height != undefined).assertTrue(); + expect(asset.orientation != undefined).assertTrue(); + expect(asset.duration != undefined).assertTrue(); + done(); +} + +describe('fetch.file.result.promise.test.js', async function () { + var context = featureAbility.getContext(); + var media = mediaLibrary.getMediaLibrary(context); + beforeAll(function () {}); + beforeEach(function () {}); + afterEach(function () {}); + afterAll(function () {}); + + + // ------------------------------ 001 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_01 + * @tc.name : getCount + * @tc.desc : Get FetchResult by getFileCountOneOp, check the return value of the interface (by Promise) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_01', 0, async function (done) { + try { + console.info('MediaLibraryTest : Get Count begin'); + let fetchFileResult = await media.getFileAssets(getFileCountOneOp); + const fetchCount = await fetchFileResult.getCount(); + console.info('MediaLibraryTest : count:' + fetchCount); + expect(fetchCount == 1).assertTrue(); + console.info('MediaLibraryTest : Get Count end'); + // fetchFileResult.close(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT getCount 001_01 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_02 + * @tc.name : getCount + * @tc.desc : Get FetchResult by getFileCountTwoOp, check the return value of the interface (by Promise) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_02', 0, async function (done) { + try { + console.info('MediaLibraryTest : Get Count begin'); + let fetchFileResult = await media.getFileAssets(getFileCountTwoOp); + const fetchCount = await fetchFileResult.getCount(); + console.info('MediaLibraryTest : count:' + fetchCount); + expect(fetchCount == 2).assertTrue(); + console.info('MediaLibraryTest : Get Count end'); + // fetchFileResult.close(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT getCount 001_02 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + + + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_03 + * @tc.name : getCount + * @tc.desc : Get FetchResult by getFileCountOneHundredOp, check the return value of the interface (by Promise) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_03', 0, async function (done) { + try { + console.info('MediaLibraryTest : Get Count begin'); + let fetchFileResult = await media.getFileAssets(getFileCountOneHundredOp); + const fetchCount = await fetchFileResult.getCount(); + console.info('MediaLibraryTest : count:' + fetchCount); + expect(fetchCount <= 100).assertTrue(); + console.info('MediaLibraryTest : Get Count end'); + // fetchFileResult.close(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT getCount 001_03 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_04 + * @tc.name : getCount + * @tc.desc : Get FetchResult by getFileCountZeroOp, check the return value of the interface (by Promise) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETCOUNT_PROMISE_001_04', 0, async function (done) { + try { + console.info('MediaLibraryTest : Get Count begin'); + let fetchFileResult = await media.getFileAssets(getFileCountZeroOp); + const fetchCount = await fetchFileResult.getCount(); + console.info('MediaLibraryTest : count:' + fetchCount); + expect(fetchCount == 0).assertTrue(); + console.info('MediaLibraryTest : Get Count end'); + // fetchFileResult.close(); + done(); + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT getCount 001_04 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + // ------------------------------ 001 test end ------------------------- + + + // ------------------------------ 002 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_ISAFTERLAST_PROMISE_002 + * @tc.name : getCount + * @tc.desc : Get FetchResult by getFileCountTenOp, check the return value of the interface (by Promise) + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_ISAFTERLAST_PROMISE_002', 0, async function (done) { + try { + console.info('MediaLibraryTest : isAfterLast begin'); + let fetchFileResult = await media.getFileAssets(getFileCountTenOp); + const fetchCount = await fetchFileResult.getCount(); + console.info('MediaLibraryTest : count:' + fetchCount); + let fileAsset = await fetchFileResult.getFirstObject(); + for (var i = 1; i < fetchCount; i++) { + fileAsset = await fetchFileResult.getNextObject(); + if (i == fetchCount - 1) { + console.info('MediaLibraryTest : isLast'); + var result = fetchFileResult.isAfterLast(); + console.info('MediaLibraryTest : isAfterLast:' + result); + expect(true).assertTrue(); + console.info('MediaLibraryTest : isAfterLast end'); + // fetchFileResult.close(); + done(); + } + } + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT isAfterLast 002 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ 002 test end ------------------------- + + // // ------------------------------ 003 test start ------------------------- + // /** + // * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_CLOSE_PROMISE_003 + // * @tc.name : getCount + // * @tc.desc : Get FetchResult, close it, check if result closed + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_CLOSE_PROMISE_003', 0, async function (done) { + // try { + // console.info('MediaLibraryTest : CLOSE begin'); + // let fetchFileResult = await media.getFileAssets(getFileCountTenOp); + // // fetchFileResult.close(); + // try { + // await fetchFileResult.getCount(); + // console.info('MediaLibraryTest : CLOSE failed'); + // expect(false).assertTrue(); + // done(); + // } catch { + // console.info('MediaLibraryTest : CLOSE closed'); + // expect(true).assertTrue(); + // done(); + // } + // console.info('MediaLibraryTest : CLOSE end'); + // } catch (error) { + // console.info('MediaLibraryTest : FETCHRESULT close 003 failed, message = ' + error); + // expect(false).assertTrue(); + // done(); + // } + // }); + + // ------------------------------ 003 test end ------------------------- + + // ------------------------------ 004 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_PROMISE_004 + * @tc.name : getFirstObject + * @tc.desc : Get FetchResult, get first object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETFIRSTOBJECT_PROMISE_004', 0, async function (done) { + try { + console.info('MediaLibraryTest : GETFIRSTOBJECT begin'); + let fetchFileResult = await media.getFileAssets(getFirstObjectOp); + let firstObject = await fetchFileResult.getFirstObject(); + let targetAttr = { + id: 3, + // uri: 'dataability:///media/audio', + mimeType: 'audio/*', + mediaType: videoType, + displayName: '01.mp3', + title: '01', + relativePath: 'camera/', + parent: 1, + size: 3513962, + dateAdded: 1501923717, + dateModified: 1501923708, + dateTaken: 0, + // artist: '', + // audioAlbum: '', + width: 0, + height: 0, + orientation: 0, + duration: 0, + albumId: 0, + albumUri: '', + // albumName: '', + } + checkAssetAttr(done, firstObject, targetAttr, '004'); + expect(true).assertTrue(); + // fetchFileResult.close(); + done(); + console.info('MediaLibraryTest : GETFIRSTOBJECT end'); + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT getFirstObject 004 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + + // ------------------------------ 004 test end ------------------------- + + // ------------------------------ 005 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_PROMISE_005 + * @tc.name : getNextObject + * @tc.desc : Get FetchResult, get first object, get next object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETNEXTOBJECT_PROMISE_005', 0, async function (done) { + try { + console.info('MediaLibraryTest : GETNEXTOBJECT begin'); + let fetchFileResult = await media.getFileAssets(getFirstObjectOp); + let firstObject = await fetchFileResult.getFirstObject(); + let nextObject = await fetchFileResult.getNextObject(); + let targetAttr = { + id: 4, + // uri: 'dataability:///media/audio', + mimeType: 'image/*', + mediaType: imageType, + displayName: '02.jpg', + title: '02', + relativePath: 'camera/', + parent: 1, + size: 348113, + dateAdded: 1501923717, + dateModified: 1501923707, + dateTaken: 0, + // artist: '', + // audioAlbum: '', + width: 1279, + height: 1706, + orientation: 0, + duration: 0, + // albumId: 0, + // albumUri: '', + // albumName: '', + } + checkAssetAttr(done, nextObject, targetAttr, '005'); + expect(true).assertTrue(); + // fetchFileResult.close(); + done(); + console.info('MediaLibraryTest : GETNEXTOBJECT end'); + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT getNextObject 005 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ 005 test end ------------------------- + + // ------------------------------ 006 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_PROMISE_006 + * @tc.name : getNextObject + * @tc.desc : Get FetchResult, get first object, get next object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETLASTOBJECT_PROMISE_006', 0, async function (done) { + try { + console.info('MediaLibraryTest : GETLASTOBJECT begin'); + let fetchFileResult = await media.getFileAssets(getFirstObjectOp); + let lastObject = await fetchFileResult.getLastObject(); + let targetAttr = { + id: 9, + // uri: 'dataability:///media/audio', + mimeType: 'audio/*', + mediaType: audioType, + displayName: '02.mp3', + title: '02', + relativePath: 'camera/', + parent: 1, + size: 3513962, + dateAdded: 1501923717, + dateModified: 1501923710, + dateTaken: 0, + // artist: '', + // audioAlbum: '', + width: 0, + height: 0, + orientation: 0, + duration: 0, + // albumId: 0, + // albumUri: '', + // albumName: '', + } + checkAssetAttr(done, lastObject, targetAttr, '006'); + expect(true).assertTrue(); + done(); + // fetchFileResult.close(); + console.info('MediaLibraryTest : GETLASTOBJECT end'); + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT getLastObject 006 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ 006 test end ------------------------- + + // ------------------------------ 007 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_01 + * @tc.name : getPositionObject + * @tc.desc : Get FetchResult, get position 0 object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_01', 0, async function (done) { + try { + console.info('MediaLibraryTest : GETPOSITIONOBJECT 0 begin'); + let fetchFileResult = await media.getFileAssets(getFirstObjectOp); + let targetObject = await fetchFileResult.getPositionObject(0); + let targetAttr = { + id: 3, + // uri: 'dataability:///media/audio', + mimeType: 'audio/*', + mediaType: videoType, + displayName: '01.mp3', + title: '01', + relativePath: 'camera/', + parent: 1, + size: 3513962, + dateAdded: 1501923717, + dateModified: 1501923708, + dateTaken: 0, + // artist: '', + // audioAlbum: '', + width: 0, + height: 0, + orientation: 0, + duration: 0, + albumId: 0, + albumUri: '', + // albumName: '', + } + checkAssetAttr(done, targetObject, targetAttr, '007_01'); + expect(true).assertTrue(); + // fetchFileResult.close(); + done(); + console.info('MediaLibraryTest : GETPOSITIONOBJECT 0 end'); + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT getPositionObject 007_01 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_02 + * @tc.name : getPositionObject + * @tc.desc : Get FetchResult, get position 1 object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_02', 0, async function (done) { + try { + console.info('MediaLibraryTest : GETPOSITIONOBJECT 1 begin'); + let fetchFileResult = await media.getFileAssets(getFirstObjectOp); + let targetObject = await fetchFileResult.getPositionObject(1); + let targetAttr = { + id: 4, + // uri: 'dataability:///media/audio', + mimeType: 'image/*', + mediaType: imageType, + displayName: '02.jpg', + title: '02', + relativePath: 'camera/', + parent: 1, + size: 348113, + dateAdded: 1501923717, + dateModified: 1501923707, + dateTaken: 0, + // artist: '', + // audioAlbum: '', + width: 1279, + height: 1706, + orientation: 0, + duration: 0, + // albumId: 0, + // albumUri: '', + // albumName: '', + } + checkAssetAttr(done, targetObject, targetAttr, '007_02'); + expect(true).assertTrue(); + // fetchFileResult.close(); + done(); + console.info('MediaLibraryTest : GETPOSITIONOBJECT 1 end'); + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT getPositionObject 007_02 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_02 + * @tc.name : getPositionObject + * @tc.desc : Get FetchResult, get position 1 object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_03', 0, async function (done) { + try { + console.info('MediaLibraryTest : GETPOSITIONOBJECT last begin'); + let fetchFileResult = await media.getFileAssets(getFirstObjectOp); + const count = await fetchFileResult.getCount(); + let targetObject = await fetchFileResult.getPositionObject(count - 1); + let targetAttr = { + id: 9, + // uri: 'dataability:///media/audio', + mimeType: 'audio/*', + mediaType: audioType, + displayName: '02.mp3', + title: '02', + relativePath: 'camera/', + parent: 1, + size: 3513962, + dateAdded: 1501923717, + dateModified: 1501923710, + dateTaken: 0, + // artist: '', + // audioAlbum: '', + width: 0, + height: 0, + orientation: 0, + duration: 0, + // albumId: 0, + // albumUri: '', + // albumName: '', + } + checkAssetAttr(done, targetObject, targetAttr, '007_03'); + expect(true).assertTrue(); + // fetchFileResult.close(); + done(); + console.info('MediaLibraryTest : GETPOSITIONOBJECT last end'); + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT getPositionObject 007_03 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_04 + * @tc.name : getPositionObject + * @tc.desc : Get FetchResult, get position 1 object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETPOSITIONOBJECT_PROMISE_007_04', 0, async function (done) { + try { + console.info('MediaLibraryTest : GETPOSITIONOBJECT out of index begin'); + let fetchFileResult = await media.getFileAssets(getFirstObjectOp); + const count = await fetchFileResult.getCount(); + try { + let targetObject = await fetchFileResult.getPositionObject(count + 100); + if (targetObject == undefined) { + expect(true).assertTrue(); + // fetchFileResult.close(); + done(); + } + expect(false).assertTrue(); + // fetchFileResult.close(); + done(); + } catch (err) { + expect(true).assertTrue(); + // fetchFileResult.close(); + done(); + } + console.info('MediaLibraryTest : GETPOSITIONOBJECT out of index end'); + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT getPositionObject 007_04 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ 007 test end ------------------------- + + // ------------------------------ 008 test start ------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_01 + * @tc.name : getAllObject + * @tc.desc : Get FetchResult, get all object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_01', 0, async function (done) { + try { + console.info('MediaLibraryTest : GETALLOBJECT begin'); + let fetchFileResult = await media.getFileAssets(getAllObjectLimitOneOp); + var targetObjects = await fetchFileResult.getAllObject(); + if (targetObjects.length > 0) { + var targetObject = targetObjects[0]; + let targetAttr = { + id: 3, + // uri: 'dataability:///media/audio', + mimeType: 'audio/*', + mediaType: videoType, + displayName: '01.mp3', + title: '01', + relativePath: 'camera/', + parent: 1, + size: 3513962, + dateAdded: 1501923717, + dateModified: 1501923708, + dateTaken: 0, + // artist: '', + // audioAlbum: '', + width: 0, + height: 0, + orientation: 0, + duration: 0, + albumId: 0, + albumUri: '', + // albumName: '', + } + checkAssetAttr(done, targetObject, targetAttr, '008_01'); + expect(true).assertTrue(); + // fetchFileResult.close(); + done(); + } + console.info('MediaLibraryTest : GETALLOBJECT end'); + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT getAllObject 008_01 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_02 + * @tc.name : getAllObject + * @tc.desc : Get FetchResult, get all object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_02', 0, async function (done) { + try { + console.info('MediaLibraryTest : GETALLOBJECT begin'); + let fetchFileResult = await media.getFileAssets(getAllObjectLimitTwoOp); + var targetObjects = await fetchFileResult.getAllObject(); + var targetAttrs = [{ + id: 3, + // uri: 'dataability:///media/audio', + mimeType: 'audio/*', + mediaType: videoType, + displayName: '01.mp3', + title: '01', + relativePath: 'camera/', + parent: 1, + size: 3513962, + dateAdded: 1501923717, + dateModified: 1501923708, + dateTaken: 0, + // artist: '', + // audioAlbum: '', + width: 0, + height: 0, + orientation: 0, + duration: 0, + albumId: 0, + albumUri: '', + // albumName: '', + }, + { + id: 4, + // uri: 'dataability:///media/audio', + mimeType: 'image/*', + mediaType: imageType, + displayName: '02.jpg', + title: '02', + relativePath: 'camera/', + parent: 1, + size: 348113, + dateAdded: 1501923717, + dateModified: 1501923707, + dateTaken: 0, + // artist: '', + // audioAlbum: '', + width: 1279, + height: 1706, + orientation: 0, + duration: 0, + // albumId: 0, + // albumUri: '', + // albumName: '', + }, + ]; + + console.info('MediaLibraryTest : targetObjects.length:' + targetObjects.length); + if (targetObjects.length >= 1) { + for (var i = 0; i < targetObjects.length; i++) { + var targetObject = targetObjects[i]; + let targetAttr = targetAttrs[i]; + checkAssetAttr(done, targetObject, targetAttr, '008_02'); + } + expect(true).assertTrue(); + // fetchFileResult.close(); + done(); + } + console.info('MediaLibraryTest : GETALLOBJECT end'); + } catch (error) { + console.info('MediaLibraryTest : ==5='); + console.info('MediaLibraryTest : FETCHRESULT getAllObject 008_02 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_03 + * @tc.name : getAllObject + * @tc.desc : Get FetchResult, get all object, check result + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_FETCHRESULT_GETALLOBJECT_PROMISE_008_03', 0, async function (done) { + try { + console.info('MediaLibraryTest : GETALLOBJECT begin'); + let fetchFileResult = await media.getFileAssets(getAllObjectLimitOneHundredOp); + var targetObjects = await fetchFileResult.getAllObject(); + if (targetObjects.length > 0) { + var targetObject = targetObjects[0]; + let targetAttr = { + id: 3, + // uri: 'dataability:///media/audio', + mimeType: 'audio/*', + mediaType: videoType, + displayName: '01.mp3', + title: '01', + relativePath: 'camera/', + parent: 1, + size: 3513962, + dateAdded: 1501923717, + dateModified: 1501923708, + dateTaken: 0, + // artist: '', + // audioAlbum: '', + width: 0, + height: 0, + orientation: 0, + duration: 0, + albumId: 0, + albumUri: '', + // albumName: '', + } + checkAssetAttr(done, targetObject, targetAttr, '008_03'); + expect(true).assertTrue(); + // fetchFileResult.close(); + done(); + } + console.info('MediaLibraryTest : GETALLOBJECT end'); + } catch (error) { + console.info('MediaLibraryTest : FETCHRESULT getAllObject 008_03 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + // ------------------------------ 008 test end ------------------------- + +}); \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAssetTestPromise.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAssetTestPromise.test.js index 357671896e6b01e8c946d59d438573cf275926d5..7f320b423d4b4246d8f05fa9a8ba095cc1e1bddb 100644 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAssetTestPromise.test.js +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAssetTestPromise.test.js @@ -1,893 +1,952 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility' -import fileio from '@ohos.fileio'; -import { - describe, - beforeAll, - beforeEach, - afterEach, - afterAll, - it, - expect -} from 'deccjsunit/index'; - -describe('fileAsset.test.js', async function () { - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - const fileKeyObj = mediaLibrary.FileKey; - - //======================== FILE BEGIN ================================== - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01 - * @tc.name : open('rw') - * @tc.desc : open -rw the type of FILE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01', 0, async function (done) { - let asset; - let asset1; - let fd; - let fd1; - try { - let fileType = mediaLibrary.MediaType.FILE; - let fileFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [fileType.toString()], - }; - let fetchFileResult = await media.getFileAssets(fileFetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('rw'); - expect(fd > 0).assertTrue(); - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd, buf); - expect(res.bytesRead > 0).assertTrue(); - asset1 = dataList[1]; - fd1 = await asset1.open('r'); - let buf2 = new ArrayBuffer(4096); - let res2 = await fileio.read(fd1, buf2); - let write = await fileio.write(fd, buf2); - expect(write > 0).assertTrue(); - - await asset.close(fd); - await asset1.close(fd1); - - if (fd > 0 && res.bytesRead > 0 && write > 0) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01 success'); - done(); - } else { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01 failed'); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01 error' + error); - await asset.close(fd); - await asset1.close(fd1); - expect(false).assertTrue(); - done(); - } - }); - - - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_02 - * @tc.name : open('r') - * @tc.desc : open -r the type of FILE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_02', 0, async function (done) { - let asset; - let fd; - try { - - let type = mediaLibrary.MediaType.FILE; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('r'); - expect(fd > 0).assertTrue(); - - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd, buf); - expect(res.bytesRead > 0).assertTrue(); - let write = await fileio.write(fd, buf); - await asset.close(fd); - done(); - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_02 error:' + error); - if (fd > 0) { - expect(true).assertTrue(); - } - await asset.close(fd); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03 - * @tc.name : open('w') - * @tc.desc : open -w the type of FILE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03', 0, async function (done) { - let asset; - let asset1; - let fd; - let fd1; - try { - - let type = mediaLibrary.MediaType.FILE; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - asset1 = dataList[1]; - - fd = await asset.open('w'); - expect(fd > 0).assertTrue(); - fd1 = await asset1.open('r'); - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd1, buf); - let write = await fileio.write(fd, buf); - - let buf1 = new ArrayBuffer(4096); - let res1 = await fileio.read(fd, buf1); - done(); - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03 error:' + error); - expect(true).assertTrue(); - await asset.close(fd); - await asset1.close(fd1); - done(); - } - }); - - //======================== FILE END ================================== - - //======================== ALBUM BEGIN ================================== - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_04 - * @tc.name : open('rw') - * @tc.desc : open -rw the type of ALBUM - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_04', 0, async function (done) { - let asset; - let fd; - try { - - let type = mediaLibrary.MediaType.ALBUM; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('rw'); - done(); - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03 error:' + error); - expect(true).assertTrue(); - if (fd > 0) { - asset.close(fd); - } - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_05 - * @tc.name : open('r') - * @tc.desc : open -r the type of ALBUM - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_05', 0, async function (done) { - let asset; - let fd; - try { - - let type = mediaLibrary.MediaType.ALBUM; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('r'); - done(); - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_05 error:' + error); - expect(true).assertTrue(); - if (fd > 0) { - asset.close(fd); - } - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_05 - * @tc.name : open('w') - * @tc.desc : open -w the type of ALBUM - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_06', 0, async function (done) { - let asset; - let fd; - try { - - let type = mediaLibrary.MediaType.ALBUM; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('r'); - done(); - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_06 error:' + error); - expect(true).assertTrue(); - if (fd > 0) { - asset.close(fd); - } - done(); - } - }); - - //======================== ALBUM END ================================== - - //======================== IMAGE BEGIN ================================== - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07 - * @tc.name : open('rw') - * @tc.desc : open -rw the type of IMAGE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07', 0, async function (done) { - let asset; - let asset1; - let fd; - let fd1; - try { - let fileType = mediaLibrary.MediaType.IMAGE; - let fileFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [fileType.toString()], - }; - let fetchFileResult = await media.getFileAssets(fileFetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('rw'); - expect(fd > 0).assertTrue(); - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd, buf); - expect(res.bytesRead > 0).assertTrue(); - asset1 = dataList[1]; - fd1 = await asset1.open('r'); - let buf2 = new ArrayBuffer(4096); - let res2 = await fileio.read(fd1, buf2); - let write = await fileio.write(fd, buf2); - expect(write > 0).assertTrue(); - - await asset.close(fd); - await asset1.close(fd1); - - if (fd > 0 && res.bytesRead > 0 && write > 0) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07 success'); - done(); - } else { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07 failed'); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07 error' + error); - await asset.close(fd); - await asset1.close(fd1); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_08 - * @tc.name : open('r') - * @tc.desc : open -r the type of IMAGE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_08', 0, async function (done) { - let asset; - let fd; - try { - - let type = mediaLibrary.MediaType.IMAGE; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('r'); - expect(fd > 0).assertTrue(); - - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd, buf); - expect(res.bytesRead > 0).assertTrue(); - let write = await fileio.write(fd, buf); - await asset.close(fd); - done(); - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_08 error:' + error); - if (fd > 0) { - expect(true).assertTrue(); - } - await asset.close(fd); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_09 - * @tc.name : open('w') - * @tc.desc : open -w the type of IMAGE - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_09', 0, async function (done) { - let asset; - let asset1; - let fd; - let fd1; - try { - - let type = mediaLibrary.MediaType.IMAGE; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - asset1 = dataList[1]; - - fd = await asset.open('w'); - expect(fd > 0).assertTrue(); - fd1 = await asset1.open('r'); - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd1, buf); - let write = await fileio.write(fd, buf); - - let buf1 = new ArrayBuffer(4096); - let res1 = await fileio.read(fd, buf1); - done(); - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_09 error:' + error); - expect(true).assertTrue(); - await asset.close(fd); - await asset1.close(fd1); - done(); - } - }); - - - //======================== IMAGE END ================================== - - //======================== AUDIO BEGIN ================================== - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10 - * @tc.name : open('rw') - * @tc.desc : open -rw the type of AUDIO - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10', 0, async function (done) { - let asset; - let asset1; - let fd; - let fd1; - try { - let fileType = mediaLibrary.MediaType.AUDIO; - let fileFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [fileType.toString()], - }; - let fetchFileResult = await media.getFileAssets(fileFetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('rw'); - expect(fd > 0).assertTrue(); - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd, buf); - expect(res.bytesRead > 0).assertTrue(); - asset1 = dataList[1]; - fd1 = await asset1.open('r'); - let buf2 = new ArrayBuffer(4096); - let res2 = await fileio.read(fd1, buf2); - let write = await fileio.write(fd, buf2); - expect(write > 0).assertTrue(); - - await asset.close(fd); - await asset1.close(fd1); - - if (fd > 0 && res.bytesRead > 0 && write > 0) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10 success'); - done(); - } else { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10 failed'); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10 error' + error); - await asset.close(fd); - await asset1.close(fd1); - expect(false).assertTrue(); - done(); - } - }); - - - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_11 - * @tc.name : open('r') - * @tc.desc : open -r the type of AUDIO - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_11', 0, async function (done) { - let asset; - let fd; - try { - - let type = mediaLibrary.MediaType.AUDIO; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('r'); - expect(fd > 0).assertTrue(); - - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd, buf); - expect(res.bytesRead > 0).assertTrue(); - let write = await fileio.write(fd, buf); - await asset.close(fd); - done(); - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_11 error:' + error); - if (fd > 0) { - expect(true).assertTrue(); - } - await asset.close(fd); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_12 - * @tc.name : open('w') - * @tc.desc : open -w the type of AUDIO - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_12', 0, async function (done) { - let asset; - let asset1; - let fd; - let fd1; - try { - - let type = mediaLibrary.MediaType.AUDIO; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - asset1 = dataList[1]; - - fd = await asset.open('w'); - expect(fd > 0).assertTrue(); - fd1 = await asset1.open('r'); - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd1, buf); - let write = await fileio.write(fd, buf); - - let buf1 = new ArrayBuffer(4096); - let res1 = await fileio.read(fd, buf1); - done(); - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_12 error:' + error); - expect(true).assertTrue(); - await asset.close(fd); - await asset1.close(fd1); - done(); - } - }); - - //======================== AUDIO END ================================== - - - //======================== VIDEO BEGIN ================================== - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13 - * @tc.name : open('rw') - * @tc.desc : open -rw the type of VIDEO - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13', 0, async function (done) { - let asset; - let asset1; - let fd; - let fd1; - try { - let fileType = mediaLibrary.MediaType.VIDEO; - let fileFetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [fileType.toString()], - }; - let fetchFileResult = await media.getFileAssets(fileFetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('rw'); - expect(fd > 0).assertTrue(); - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd, buf); - expect(res.bytesRead > 0).assertTrue(); - asset1 = dataList[1]; - fd1 = await asset1.open('r'); - let buf2 = new ArrayBuffer(4096); - let res2 = await fileio.read(fd1, buf2); - let write = await fileio.write(fd, buf2); - expect(write > 0).assertTrue(); - - await asset.close(fd); - await asset1.close(fd1); - - if (fd > 0 && res.bytesRead > 0 && write > 0) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13 success'); - done(); - } else { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13 failed'); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13 error' + error); - await asset.close(fd); - await asset1.close(fd1); - expect(false).assertTrue(); - done(); - } - }); - - - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_14 - * @tc.name : open('r') - * @tc.desc : open -r the type of VIDEO - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_14', 0, async function (done) { - let asset; - let fd; - try { - - let type = mediaLibrary.MediaType.VIDEO; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('r'); - expect(fd > 0).assertTrue(); - - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd, buf); - expect(res.bytesRead > 0).assertTrue(); - let write = await fileio.write(fd, buf); - await asset.close(fd); - done(); - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_14 error:' + error); - if (fd > 0) { - expect(true).assertTrue(); - } - await asset.close(fd); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_15 - * @tc.name : open('w') - * @tc.desc : open -w the type of VIDEO - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_15', 0, async function (done) { - let asset; - let asset1; - let fd; - let fd1; - try { - - let type = mediaLibrary.MediaType.VIDEO; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - asset1 = dataList[1]; - - fd = await asset.open('w'); - expect(fd > 0).assertTrue(); - fd1 = await asset1.open('r'); - let buf = new ArrayBuffer(4096); - let res = await fileio.read(fd1, buf); - let write = await fileio.write(fd, buf); - - let buf1 = new ArrayBuffer(4096); - let res1 = await fileio.read(fd, buf1); - done(); - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_15 error:' + error); - expect(true).assertTrue(); - await asset.close(fd); - await asset1.close(fd1); - done(); - } - }); - - //======================== VIDEO END ================================== - - - //======================== CLOSE BEGIN ================================ - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31 - * @tc.name : close - * @tc.desc : asset close the type of file - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31', 0, async function (done) { - let asset; - let fd; - let fd1; - try { - let type = mediaLibrary.MediaType.FILE; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('r'); - - console.info('MediaLibraryTest : ==1 fd:' + fd); - await asset.close(fd); - - fd1 = await asset.open('r'); - console.info('MediaLibraryTest : ==2 fd2:' + fd1); - await asset.close(fd1); - if (fd > 0 && fd1 > 0) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31 success'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31 false'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31 error' + error); - await asset.close(fd); - await asset.close(fd1); - expect(false).assertTrue(); - done(); - } - }); - - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33 - * @tc.name : close - * @tc.desc : asset close the type of image - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33', 0, async function (done) { - let asset; - let fd; - let fd1; - try { - let type = mediaLibrary.MediaType.IMAGE; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('r'); - - console.info('MediaLibraryTest : ==1 fd:' + fd); - await asset.close(fd); - - fd1 = await asset.open('r'); - console.info('MediaLibraryTest : ==2 fd2:' + fd1); - await asset.close(fd1); - if (fd > 0 && fd1 > 0) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33 success'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33 false'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33 error' + error); - await asset.close(fd); - await asset.close(fd1); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34 - * @tc.name : close - * @tc.desc : asset close the type of audio - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34', 0, async function (done) { - let asset; - let fd; - let fd1; - try { - let type = mediaLibrary.MediaType.AUDIO; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('r'); - await asset.close(fd); - fd1 = await asset.open('r'); - await asset.close(fd1); - if (fd > 0 && fd1 > 0) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34 success'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34 false'); - expect(false).assertTrue(); - done(); - } - done - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34 error' + error); - await asset.close(fd); - await asset.close(fd1); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35 - * @tc.name : close - * @tc.desc : asset close the type of video - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35', 0, async function (done) { - let asset; - let fd; - let fd1; - try { - let type = mediaLibrary.MediaType.VIDEO; - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [type.toString()], - }; - let fetchFileResult = await media.getFileAssets(fetchOp); - const dataList = await fetchFileResult.getAllObject(); - asset = dataList[0]; - fd = await asset.open('r'); - await asset.close(fd); - fd1 = await asset.open('r'); - await asset.close(fd1); - if (fd > 0 && fd1 > 0) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35 success'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35 false'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35 error' + error); - await asset.close(fd); - await asset.close(fd1); - expect(false).assertTrue(); - done(); - } - }); - - //======================== CLOSE BEGIN ================================ - -}); \ No newline at end of file +/* + * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import featureAbility from '@ohos.ability.featureAbility'; +import fileio from '@ohos.fileio'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; + +describe('fileAssetTestPromise.test.js', async function () { + var context = featureAbility.getContext(); + console.info('MediaLibraryTest : getMediaLibrary IN'); + var media = mediaLibrary.getMediaLibrary(context); + console.info('MediaLibraryTest : getMediaLibrary OUT'); + const fileKeyObj = mediaLibrary.FileKey; + + //======================== FILE BEGIN ================================== + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01 + * @tc.name : open('rw') + * @tc.desc : open -rw the type of FILE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01', 0, async function (done) { + let asset; + let asset1; + let fd; + let fd1; + try { + let fileType = mediaLibrary.MediaType.FILE; + let fileFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + }; + let fetchFileResult = await media.getFileAssets(fileFetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('rw'); + expect(fd > 0).assertTrue(); + let buf = new ArrayBuffer(4096); + let res = await fileio.read(fd, buf); + expect(res.bytesRead > 0).assertTrue(); + asset1 = dataList[1]; + fd1 = await asset1.open('r'); + let buf2 = new ArrayBuffer(4096); + let res2 = await fileio.read(fd1, buf2); + let write = await fileio.write(fd, buf2); + expect(write > 0).assertTrue(); + + await asset.close(fd); + await asset1.close(fd1); + + if (fd > 0 && res.bytesRead > 0 && write > 0) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01 success' + ); + done(); + } else { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01 failed' + ); + done(); + } + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_01 error' + + error + ); + await asset.close(fd); + await asset1.close(fd1); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_02 + * @tc.name : open('r') + * @tc.desc : open -r the type of FILE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_02', 0, async function (done) { + let asset; + let fd; + try { + let type = mediaLibrary.MediaType.FILE; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('r'); + expect(fd > 0).assertTrue(); + + let buf = new ArrayBuffer(4096); + let res = await fileio.read(fd, buf); + expect(res.bytesRead > 0).assertTrue(); + let write = await fileio.write(fd, buf); + await asset.close(fd); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_02 error:' + + error + ); + if (fd > 0) { + expect(true).assertTrue(); + } + await asset.close(fd); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03 + * @tc.name : open('w') + * @tc.desc : open -w the type of FILE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03', 0, async function (done) { + let asset; + let asset1; + let fd; + let fd1; + try { + let type = mediaLibrary.MediaType.FILE; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + asset1 = dataList[1]; + + fd = await asset.open('w'); + expect(fd > 0).assertTrue(); + fd1 = await asset1.open('r'); + let buf = new ArrayBuffer(4096); + let res = await fileio.read(fd1, buf); + let write = await fileio.write(fd, buf); + + let buf1 = new ArrayBuffer(4096); + let res1 = await fileio.read(fd, buf1); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03 error:' + + error + ); + expect(true).assertTrue(); + await asset.close(fd); + await asset1.close(fd1); + done(); + } + }); + + //======================== FILE END ================================== + + //======================== ALBUM BEGIN ================================== + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_04 + * @tc.name : open('rw') + * @tc.desc : open -rw the type of ALBUM + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_04', 0, async function (done) { + let asset; + let fd; + try { + let type = mediaLibrary.MediaType.ALBUM; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('rw'); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_03 error:' + + error + ); + expect(true).assertTrue(); + if (fd > 0) { + asset.close(fd); + } + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_05 + * @tc.name : open('r') + * @tc.desc : open -r the type of ALBUM + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_05', 0, async function (done) { + let asset; + let fd; + try { + let type = mediaLibrary.MediaType.ALBUM; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('r'); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_05 error:' + + error + ); + expect(true).assertTrue(); + if (fd > 0) { + asset.close(fd); + } + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_05 + * @tc.name : open('w') + * @tc.desc : open -w the type of ALBUM + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_06', 0, async function (done) { + let asset; + let fd; + try { + let type = mediaLibrary.MediaType.ALBUM; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('r'); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_06 error:' + + error + ); + expect(true).assertTrue(); + if (fd > 0) { + asset.close(fd); + } + done(); + } + }); + + //======================== ALBUM END ================================== + + //======================== IMAGE BEGIN ================================== + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07 + * @tc.name : open('rw') + * @tc.desc : open -rw the type of IMAGE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07', 0, async function (done) { + let asset; + let asset1; + let fd; + let fd1; + try { + let fileType = mediaLibrary.MediaType.IMAGE; + let fileFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + }; + let fetchFileResult = await media.getFileAssets(fileFetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('rw'); + expect(fd > 0).assertTrue(); + let buf = new ArrayBuffer(4096); + let res = await fileio.read(fd, buf); + expect(res.bytesRead > 0).assertTrue(); + asset1 = dataList[1]; + fd1 = await asset1.open('r'); + let buf2 = new ArrayBuffer(4096); + let res2 = await fileio.read(fd1, buf2); + let write = await fileio.write(fd, buf2); + expect(write > 0).assertTrue(); + + await asset.close(fd); + await asset1.close(fd1); + + if (fd > 0 && res.bytesRead > 0 && write > 0) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07 success' + ); + done(); + } else { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07 failed' + ); + done(); + } + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_07 error' + + error + ); + await asset.close(fd); + await asset1.close(fd1); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_08 + * @tc.name : open('r') + * @tc.desc : open -r the type of IMAGE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_08', 0, async function (done) { + let asset; + let fd; + try { + let type = mediaLibrary.MediaType.IMAGE; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('r'); + expect(fd > 0).assertTrue(); + + let buf = new ArrayBuffer(4096); + let res = await fileio.read(fd, buf); + expect(res.bytesRead > 0).assertTrue(); + let write = await fileio.write(fd, buf); + await asset.close(fd); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_08 error:' + + error + ); + if (fd > 0) { + expect(true).assertTrue(); + } + await asset.close(fd); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_09 + * @tc.name : open('w') + * @tc.desc : open -w the type of IMAGE + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_09', 0, async function (done) { + let asset; + let asset1; + let fd; + let fd1; + try { + let type = mediaLibrary.MediaType.IMAGE; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + asset1 = dataList[1]; + + fd = await asset.open('w'); + expect(fd > 0).assertTrue(); + fd1 = await asset1.open('r'); + let buf = new ArrayBuffer(4096); + let res = await fileio.read(fd1, buf); + let write = await fileio.write(fd, buf); + + let buf1 = new ArrayBuffer(4096); + let res1 = await fileio.read(fd, buf1); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_09 error:' + + error + ); + expect(true).assertTrue(); + await asset.close(fd); + await asset1.close(fd1); + done(); + } + }); + + //======================== IMAGE END ================================== + + //======================== AUDIO BEGIN ================================== + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10 + * @tc.name : open('rw') + * @tc.desc : open -rw the type of AUDIO + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10', 0, async function (done) { + let asset; + let asset1; + let fd; + let fd1; + try { + let fileType = mediaLibrary.MediaType.AUDIO; + let fileFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + }; + let fetchFileResult = await media.getFileAssets(fileFetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('rw'); + expect(fd > 0).assertTrue(); + let buf = new ArrayBuffer(4096); + let res = await fileio.read(fd, buf); + expect(res.bytesRead > 0).assertTrue(); + asset1 = dataList[1]; + fd1 = await asset1.open('r'); + let buf2 = new ArrayBuffer(4096); + let res2 = await fileio.read(fd1, buf2); + let write = await fileio.write(fd, buf2); + expect(write > 0).assertTrue(); + + await asset.close(fd); + await asset1.close(fd1); + + if (fd > 0 && res.bytesRead > 0 && write > 0) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10 success' + ); + done(); + } else { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10 failed' + ); + done(); + } + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_10 error' + + error + ); + await asset.close(fd); + await asset1.close(fd1); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_11 + * @tc.name : open('r') + * @tc.desc : open -r the type of AUDIO + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_11', 0, async function (done) { + let asset; + let fd; + try { + let type = mediaLibrary.MediaType.AUDIO; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('r'); + expect(fd > 0).assertTrue(); + + let buf = new ArrayBuffer(4096); + let res = await fileio.read(fd, buf); + expect(res.bytesRead > 0).assertTrue(); + let write = await fileio.write(fd, buf); + await asset.close(fd); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_11 error:' + + error + ); + if (fd > 0) { + expect(true).assertTrue(); + } + await asset.close(fd); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_12 + * @tc.name : open('w') + * @tc.desc : open -w the type of AUDIO + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_12', 0, async function (done) { + let asset; + let asset1; + let fd; + let fd1; + try { + let type = mediaLibrary.MediaType.AUDIO; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + asset1 = dataList[1]; + + fd = await asset.open('w'); + expect(fd > 0).assertTrue(); + fd1 = await asset1.open('r'); + let buf = new ArrayBuffer(4096); + let res = await fileio.read(fd1, buf); + let write = await fileio.write(fd, buf); + + let buf1 = new ArrayBuffer(4096); + let res1 = await fileio.read(fd, buf1); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_12 error:' + + error + ); + expect(true).assertTrue(); + await asset.close(fd); + await asset1.close(fd1); + done(); + } + }); + + //======================== AUDIO END ================================== + + //======================== VIDEO BEGIN ================================== + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13 + * @tc.name : open('rw') + * @tc.desc : open -rw the type of VIDEO + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13', 0, async function (done) { + let asset; + let asset1; + let fd; + let fd1; + try { + let fileType = mediaLibrary.MediaType.VIDEO; + let fileFetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + }; + let fetchFileResult = await media.getFileAssets(fileFetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('rw'); + expect(fd > 0).assertTrue(); + let buf = new ArrayBuffer(4096); + let res = await fileio.read(fd, buf); + expect(res.bytesRead > 0).assertTrue(); + asset1 = dataList[1]; + fd1 = await asset1.open('r'); + let buf2 = new ArrayBuffer(4096); + let res2 = await fileio.read(fd1, buf2); + let write = await fileio.write(fd, buf2); + expect(write > 0).assertTrue(); + + await asset.close(fd); + await asset1.close(fd1); + + if (fd > 0 && res.bytesRead > 0 && write > 0) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13 success' + ); + done(); + } else { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13 failed' + ); + done(); + } + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_13 error' + + error + ); + await asset.close(fd); + await asset1.close(fd1); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_14 + * @tc.name : open('r') + * @tc.desc : open -r the type of VIDEO + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_14', 0, async function (done) { + let asset; + let fd; + try { + let type = mediaLibrary.MediaType.VIDEO; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('r'); + expect(fd > 0).assertTrue(); + + let buf = new ArrayBuffer(4096); + let res = await fileio.read(fd, buf); + expect(res.bytesRead > 0).assertTrue(); + let write = await fileio.write(fd, buf); + await asset.close(fd); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_14 error:' + + error + ); + if (fd > 0) { + expect(true).assertTrue(); + } + await asset.close(fd); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_15 + * @tc.name : open('w') + * @tc.desc : open -w the type of VIDEO + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_15', 0, async function (done) { + let asset; + let asset1; + let fd; + let fd1; + try { + let type = mediaLibrary.MediaType.VIDEO; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + asset1 = dataList[1]; + + fd = await asset.open('w'); + expect(fd > 0).assertTrue(); + fd1 = await asset1.open('r'); + let buf = new ArrayBuffer(4096); + let res = await fileio.read(fd1, buf); + let write = await fileio.write(fd, buf); + + let buf1 = new ArrayBuffer(4096); + let res1 = await fileio.read(fd, buf1); + done(); + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_15 error:' + + error + ); + expect(true).assertTrue(); + await asset.close(fd); + await asset1.close(fd1); + done(); + } + }); + + //======================== VIDEO END ================================== + + //======================== CLOSE BEGIN ================================ + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31 + * @tc.name : close + * @tc.desc : asset close the type of file + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31', 0, async function (done) { + let asset; + let fd; + let fd1; + try { + let type = mediaLibrary.MediaType.FILE; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('r'); + + console.info('MediaLibraryTest : ==1 fd:' + fd); + await asset.close(fd); + + fd1 = await asset.open('r'); + console.info('MediaLibraryTest : ==2 fd2:' + fd1); + await asset.close(fd1); + if (fd > 0 && fd1 > 0) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31 success' + ); + expect(true).assertTrue(); + done(); + } else { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31 false' + ); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_31 error' + + error + ); + await asset.close(fd); + await asset.close(fd1); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33 + * @tc.name : close + * @tc.desc : asset close the type of image + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33', 0, async function (done) { + let asset; + let fd; + let fd1; + try { + let type = mediaLibrary.MediaType.IMAGE; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('r'); + + console.info('MediaLibraryTest : ==1 fd:' + fd); + await asset.close(fd); + + fd1 = await asset.open('r'); + console.info('MediaLibraryTest : ==2 fd2:' + fd1); + await asset.close(fd1); + if (fd > 0 && fd1 > 0) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33 success' + ); + expect(true).assertTrue(); + done(); + } else { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33 false' + ); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_33 error' + + error + ); + await asset.close(fd); + await asset.close(fd1); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34 + * @tc.name : close + * @tc.desc : asset close the type of audio + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34', 0, async function (done) { + let asset; + let fd; + let fd1; + try { + let type = mediaLibrary.MediaType.AUDIO; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('r'); + await asset.close(fd); + fd1 = await asset.open('r'); + await asset.close(fd1); + if (fd > 0 && fd1 > 0) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34 success' + ); + expect(true).assertTrue(); + done(); + } else { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34 false' + ); + expect(false).assertTrue(); + done(); + } + done; + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_34 error' + + error + ); + await asset.close(fd); + await asset.close(fd1); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35 + * @tc.name : close + * @tc.desc : asset close the type of video + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35', 0, async function (done) { + let asset; + let fd; + let fd1; + try { + let type = mediaLibrary.MediaType.VIDEO; + let fetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + let fetchFileResult = await media.getFileAssets(fetchOp); + const dataList = await fetchFileResult.getAllObject(); + asset = dataList[0]; + fd = await asset.open('r'); + await asset.close(fd); + fd1 = await asset.open('r'); + await asset.close(fd1); + if (fd > 0 && fd1 > 0) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35 success' + ); + expect(true).assertTrue(); + done(); + } else { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35 false' + ); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info( + 'MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_PROMISE_005_35 error' + + error + ); + await asset.close(fd); + await asset.close(fd1); + expect(false).assertTrue(); + done(); + } + }); + + //======================== CLOSE BEGIN ================================ +}); diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAssetUriTestCallBack.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAssetUriTestCallBack.test.js new file mode 100644 index 0000000000000000000000000000000000000000..2938d54262bfba597e6418e2c9b8a8fa503cfdfb --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileAssetUriTestCallBack.test.js @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import featureAbility from '@ohos.ability.featureAbility' +import fileio from '@ohos.fileio'; +import { + describe, + it, + expect +} from 'deccjsunit/index'; + +describe('fileAsset.callback.test.js', async function () { + var context = featureAbility.getContext(); + console.info('MediaLibraryTest : getMediaLibrary IN'); + var media = mediaLibrary.getMediaLibrary(context); + console.info('MediaLibraryTest : getMediaLibrary OUT'); + const fileKeyObj = mediaLibrary.FileKey; + + function executeAtError(testNum, bool, error, done) { + console.info( + `SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK${testNum} failed, error: ${error}` + ); + expect(bool).assertTrue(); + if (typeof done === "function") { + done(); + } + } + //======================== FILE BEGIN ================================== + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_35 + * @tc.name : close + * @tc.desc : asset close the type of video + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK_005_35', 0, async function (done) { + const testNum = "_005_35"; + let asset; + let fd; + let fd1; + try { + let type = mediaLibrary.MediaType.VIDEO; + let fetchOp = { + uri: 'dataability://123456789/media/external/images/media/10', + networkId: '123456789', + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [type.toString()], + }; + media.getFileAssets(fetchOp, (error, fetchFileResult) => { + try{ + console.info(`MediaLibraryTest : ==1==`); + fetchFileResult.getAllObject((error, dataList) => { + console.info(`MediaLibraryTest : ==2==`); + try{ + console.info(`MediaLibraryTest : ==3==`); + asset = dataList[0]; + console.info(`MediaLibraryTest : ==4==`); + asset.open('r', (error, innerFd) => { + fd = innerFd; + try{ + asset.close(fd, (error) => { + try{ + asset.open('r', (error, innerFd1) => { + fd1 = innerFd1; + try{ + asset.close(fd1, (error) => { + try{ + if (fd > 0 && fd1 > 0) { + console.info(`MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK${testNum} success`); + expect(true).assertTrue(); + done(); + } else { + console.info(`MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK${testNum} failed`); + expect(false).assertTrue(); + done(); + } + }catch(error){ + executeAtError(testNum, false, error, done); + } + }); + }catch(error){ + executeAtError(testNum, false, error, done); + } + }); + }catch(error){ + executeAtError(testNum, false, error, done); + } + }); + }catch(error){ + executeAtError(testNum, false, error, done); + } + }); + }catch(error){ + executeAtError(testNum, true, error, done); + } + }); + }catch(error){ + executeAtError(testNum, true, error, done); + } + }); + } catch (error) { + console.info(`MediaLibraryTest : ==5==`); + console.info(`MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_OPENANDCLOSE_ASSET_CALLBACK${testNum} error:${error}`); + asset.close(fd, () =>{ + try{ + console.info(`MediaLibraryTest : ==6==`); + asset1.close(fd1, () => { + console.info(`MediaLibraryTest : ==7==`); + expect(false).assertTrue(); + done(); + }); + }catch(error){ + console.info(`MediaLibraryTest : ==8==`); + expect(false).assertTrue(); + done(); + } + }); + } + }); + + //======================== CLOSE BEGIN ================================ + +}); \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileTestCallBack.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileTestCallBack.test.js index 4a2d6c475aa57a297632cb47d6c77e3979f1a7b9..f47abdd4791c1745600cb406756336aff06d0469 100644 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileTestCallBack.test.js +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileTestCallBack.test.js @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (C) 2022 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 @@ -14,787 +14,3041 @@ */ import mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' -let fileKeyObj = mediaLibrary.FileKey -let type1 = mediaLibrary.MediaType.IMAGE -let fileHasArgsfetchOp = { - selections: fileKeyObj.MEDIA_TYPE + "= ?", - selectionArgs: [type1.toString()], -} -let fileNoArgsfetchOp = { - selections: "", - selectionArgs: [], +import featureAbility from '@ohos.ability.featureAbility'; +import fileio from '@ohos.fileio'; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +let fileKeyObj = mediaLibrary.FileKey; +let fileType = mediaLibrary.MediaType.FILE; +let imageType = mediaLibrary.MediaType.IMAGE; +let videoType = mediaLibrary.MediaType.VIDEO; +let audioType = mediaLibrary.MediaType.AUDIO; + +let imagesfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], +}; +let videosfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [videoType.toString()], +}; +let audiosfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [audioType.toString()], +}; +let filesfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], +}; + +function checkAssetAttr(done, attr, test_num, asset, checkType) { + if (checkType && asset[attr] != checkType) { + console.info(`MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed`); + expect(false).assertTrue(); + done(); + } else if (asset[attr] == undefined) { + console.info(`MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed`); + expect(false).assertTrue(); + done(); + } } -describe('file.callback.test.js', function () { - var asset; - var asset1; - var asset2; - var asset3; +function executeAtError(test_num, error, done) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed, message = ${error}` + ); + expect(false).assertTrue(); + if (typeof done === 'function') { + done(); + } +} +describe('fileTestCallBack.test', function () { var context = featureAbility.getContext(); console.info('MediaLibraryTest : getMediaLibrary IN'); var media = mediaLibrary.getMediaLibrary(context); console.info('MediaLibraryTest : getMediaLibrary OUT'); - beforeAll(function () { - console.info('File Callback MediaLibraryTest: beforeAll : Prerequisites at the test suite level, which are executed before the test suite is executed.'); - }) + beforeAll(function () { }); + beforeEach(function () { }); + afterEach(function () { }); + afterAll(function () { }); - beforeEach(function () { - console.info('File Callback MediaLibraryTest: beforeEach:Prerequisites at the test case level, which are executed before each test case is executed.'); - }) - afterEach(function () { - console.info('File Callback MediaLibraryTest: afterEach: Test case-level clearance conditions, which are executed after each test case is executed.'); - }) - afterAll(function () { - console.info('File Callback MediaLibraryTest: afterAll: Test suite-level cleanup condition, which is executed after the test suite is executed'); - }) + function copyFile(fd1, fd2, test_num, done, callback) { + try { + fileio.fstat(fd1, (error, stat) => { + let buf = new ArrayBuffer(stat.size); + try { + fileio.read(fd1, buf, () => { + try { + fileio.write(fd2, buf, () => { + try { + if (typeof callback === 'function') { + callback(); + } + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + } + // ------------------------------- image type start ---------------------------- /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001 - * @tc.name : Create an asset in predefined path - * @tc.desc : Create an asset in predefined path + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_01 + * @tc.name : createAsset + * @tc.desc : Insert two database records, read a unique identifier, expectations are not equal * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ - - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001', 0, async function (done) { + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_01', 0, async function (done) { + const test_num = '001_01'; try { - console.info('MediaLibraryTest : Delete begin'); - let fetchFileResult = await media.getFileAssets(fileNoArgsfetchOp); - let assetList = await fetchFileResult.getAllObject(); - assetList.forEach(getAllObjectInfoDelete); - console.info('MediaLibraryTest : Delete end'); - let mediaType = mediaLibrary.MediaType.IMAGE; - let path = "Pictures/"; - media.createAsset(mediaType, "imageCallBack000001.jpg", path, createAssetCallBack); + media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE, (error, path) => { + try { + media.getFileAssets(imagesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const asset1 = dataList[0]; + media.createAsset( + imageType, + 'image03.jpg', + path, + (error, creatAsset1) => { + try { + asset1.open('rw', (error, fd1) => { + try { + creatAsset1.open( + 'rw', + (error, creatAssetFd1) => { + try { + copyFile( + fd1, + creatAssetFd1, + test_num, + done, + () => { + try { + creatAsset1.close( + creatAssetFd1, + () => { + try { + asset1.close( + fd1, + () => { + try { + const asset2 = + dataList[1]; + media.createAsset( + imageType, + 'image04.jpg', + path, + ( + error, + creatAsset2 + ) => { + try { + asset2.open( + 'rw', + ( + error, + fd2 + ) => { + try { + creatAsset2.open( + 'rw', + ( + error, + creatAssetFd2 + ) => { + try { + copyFile( + fd2, + creatAssetFd2, + test_num, + done, + () => { + creatAsset2.close( + creatAssetFd2, + () => { + asset2.close( + fd2, + () => { + if ( + creatAsset1.id != + creatAsset2.id + ) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect( + true + ).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect( + false + ).assertTrue(); + done(); + } + } + ); + } + ); + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK createasset 001_01 fail, message = ' + error); + executeAtError(test_num, error, done); } - done(); }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_MODIFY_ASSET_CALLBACK_002 - * @tc.name : Modify asset - * @tc.desc : Modify asset + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_02 + * @tc.name : createAsset + * @tc.desc : Access to the file displayName and validation is not undefined * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ - - it('SUB_MEDIA_MEDIALIBRARY_MODIFY_ASSET_CALLBACK_002_01', 0, async function (done) { + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_02', 0, async function (done) { + const test_num = '001_02'; try { - let mediaType = mediaLibrary.MediaType.IMAGE; - let path = "Pictures/"; - let pathMove = "Pictures/Move/"; - asset = await media.createAsset(mediaType, "image0000111.jpg", path); - await media.createAsset(mediaType, "imageMove00001.jpg", pathMove); - asset.title = "image00003"; - asset.relativePath = "Pictures/Move/"; - asset.displayName = "image0000222.jpg"; - asset.orientation = 1000; - asset.commitModify(commitModifyCallBack); - console.info('MediaLibraryTest : ASSET_CALLBACK commitModify 002_01 success'); - done(); + media.getFileAssets(imagesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'displayName', test_num, firstAsset); + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'displayName', test_num, midAsset); + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'displayName', test_num, lastAsset); + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK commitModify 002_01 fail, message = ' + error); - done(); + executeAtError(test_num, error, done); } }); - it('SUB_MEDIA_MEDIALIBRARY_MODIFY_ASSET_CALLBACK_002_02', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_03 + * @tc.name : createAsset + * @tc.desc : Access to the file relativePath and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_03', 0, async function (done) { + const test_num = '001_03'; try { - asset.title = "image0000444"; - asset.commitModify(commitModifyCallBack); - console.info('MediaLibraryTest : ASSET_CALLBACK commitModify 002_02 success'); - done(); + media.getFileAssets(imagesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'relativePath', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'relativePath', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'relativePath', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK commitModify 002_02 fail, message = ' + error); - done(); + executeAtError(test_num, error, done); } }); - it('SUB_MEDIA_MEDIALIBRARY_MODIFY_ASSET_CALLBACK_002_03', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_04 + * @tc.name : createAsset + * @tc.desc : Access to the file size and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_04', 0, async function (done) { + const test_num = '001_04'; try { - let mediaType = mediaLibrary.MediaType.IMAGE; - let pathMoveCallback = "Pictures/Move/Callback/"; - await media.createAsset(mediaType, "imageMoveCallBack00001.jpg", pathMoveCallback); - asset.relativePath = "Pictures/Move/Callback/"; - asset.commitModify(commitModifyCallBack); - console.info('MediaLibraryTest : ASSET_CALLBACK commitModify 002_03 success'); - done(); + media.getFileAssets(imagesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'size', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'size', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'size', test_num, lastAsset); + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK commitModify 002_03 fail, message = ' + error); - done(); + executeAtError(test_num, error, done); } }); - it('SUB_MEDIA_MEDIALIBRARY_MODIFY_ASSET_CALLBACK_002_04', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_05 + * @tc.name : createAsset + * @tc.desc : Access to the file dateAdded and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_05', 0, async function (done) { + const test_num = '001_05'; try { - asset.displayName = "image0000333.jpg"; - asset.commitModify(commitModifyCallBack); - console.info('MediaLibraryTest : ASSET_CALLBACK commitModify 002_04 success'); - done(); + media.getFileAssets(imagesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'dateAdded', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'dateAdded', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'dateAdded', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK commitModify 002_04 fail, message = ' + error); - done(); + executeAtError(test_num, error, done); } }); - it('SUB_MEDIA_MEDIALIBRARY_MODIFY_ASSET_CALLBACK_002_05', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_07 + * @tc.name : createAsset + * @tc.desc : Access to the file dateModified and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_07', 0, async function (done) { + const test_num = '001_07'; try { - asset.orientation = 2000; - asset.commitModify(commitModifyCallBack); - console.info('MediaLibraryTest : ASSET_CALLBACK commitModify 002_05 success'); - done(); + media.getFileAssets(imagesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const asset = dataList[0]; + asset.title = `title_${new Date().getTime()}`; + asset.commitModify(() => { + try { + const id = asset.id; + const idOP = { + selections: fileKeyObj.ID + '= ?', + selectionArgs: ['' + id], + }; + media.getFileAssets(idOP, (error, newAssets) => { + try { + newAssets.getAllObject((error, newdataList) => { + try { + const newAsset = newdataList[0]; + if (asset.dateModified != undefined) { + if ( + newAsset.dateModified != + asset.dateModified + ) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect(false).assertTrue(); + done(); + } + } else if (newAsset.dateModified != undefined) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect(false).assertTrue(); + done(); + } + + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK commitModify 002_05 fail, message = ' + error); - done(); + executeAtError(test_num, error, done); } }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_ASSET_CALLBACK_003 - * @tc.name : Get assetList By NoArgsfetchOp - * @tc.desc : Get assetList By NoArgsfetchOp + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_08 + * @tc.name : createAsset + * @tc.desc : Insert a picture record, the retrieve attributes for images * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ - - it('SUB_MEDIA_MEDIALIBRARY_GET_ASSET_CALLBACK_003', 0, async function (done) { - media.getFileAssets(fileNoArgsfetchOp, getFileAssetsCallBack); - done(); + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_08', 0, async function (done) { + const test_num = '001_08'; + try { + media.getFileAssets(imagesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'mediaType', test_num, firstAsset, imageType); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'mediaType', test_num, midAsset, imageType); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'mediaType', test_num, lastAsset, imageType); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_ASSET_CALLBACK_004 - * @tc.name : Get assetList By HasArgsfetchOp - * @tc.desc : Get assetList By HasArgsfetchOp + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_09 + * @tc.name : createAsset + * @tc.desc : Get the width attribute * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ - - it('SUB_MEDIA_MEDIALIBRARY_GET_ASSET_CALLBACK_004', 0, async function (done) { - media.getFileAssets(fileHasArgsfetchOp, getFileAssetsCallBack); - done(); + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_09', 0, async function (done) { + const test_num = '001_09'; + try { + media.getFileAssets(imagesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'width', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'width', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'width', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OPEN_ASSET_CALLBACK_005 - * @tc.name : Open asset - * @tc.desc : Open asset + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_10 + * @tc.name : createAsset + * @tc.desc : Get the height attribute * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ - - it('SUB_MEDIA_MEDIALIBRARY_OPEN_ASSET_CALLBACK_005_01', 0, async function (done) { + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_10', 0, async function (done) { + const test_num = '001_10'; try { - asset.open('Rw', openCallBack); - console.info('MediaLibraryTest : ASSET_CALLBACK open 005_01 success'); - done(); + media.getFileAssets(imagesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'height', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'height', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'height', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK open 005_01 fail, message = ' + error); - done(); + executeAtError(test_num, error, done); } }); - it('SUB_MEDIA_MEDIALIBRARY_OPEN_ASSET_CALLBACK_005_02', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_11 + * @tc.name : createAsset + * @tc.desc : Get the orientaion attribute + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_11', 0, async function (done) { + const test_num = '001_11'; try { - let mediaType = mediaLibrary.MediaType.IMAGE; - asset1 = await media.createAsset(mediaType, "image00001.jpg", path); - asset1.open('w', openCallBack1); - console.info('MediaLibraryTest : ASSET_CALLBACK open 005_02 success'); - done(); + media.getFileAssets(imagesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'orientation', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'orientation', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'orientation', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK open 005_02 fail, message = ' + error); - done(); + executeAtError(test_num, error, done); } }); - it('SUB_MEDIA_MEDIALIBRARY_OPEN_ASSET_CALLBACK_005_03', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_12 + * @tc.name : createAsset + * @tc.desc : Insert a picture record and get the property as picture + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_001_12', 0, async function (done) { + const test_num = '001_12'; try { - let mediaType = mediaLibrary.MediaType.IMAGE; - asset2 = await media.createAsset(mediaType, "image00002.jpg", path); - asset2.open('wts', openCallBack2); - console.info('MediaLibraryTest : ASSET_CALLBACK open 005_03 success'); - done(); + media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE, (error, path) => { + try { + media.getFileAssets(imagesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const asset1 = dataList[0]; + media.createAsset( + imageType, + 'image3.jpg', + path, + (error, creatAsset1) => { + try { + asset1.open('rw', (error, fd1) => { + try { + creatAsset1.open( + 'rw', + (error, creatAssetFd1) => { + try { + copyFile( + fd1, + creatAssetFd1, + test_num, + done, + () => { + try { + creatAsset1.close( + creatAssetFd1, + () => { + try { + asset1.close( + fd1, + () => { + if ( + creatAsset1.mediaType == + imageType + ) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect( + true + ).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect( + false + ).assertTrue(); + done(); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK open 005_03 fail, message = ' + error); - done(); + executeAtError(test_num, error, done); } }); + // ------------------------------- image type end ----------------------------- - it('SUB_MEDIA_MEDIALIBRARY_OPEN_ASSET_CALLBACK_005_04', 0, async function (done) { + // ------------------------------- video type start ---------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_01 + * @tc.name : createAsset + * @tc.desc : Insert two database records, read a unique identifier, expectations are not equal + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_01', 0, async function (done) { + const test_num = '002_01'; try { - let mediaType = mediaLibrary.MediaType.IMAGE; - asset3 = await media.createAsset(mediaType, "image00003.jpg", path); - asset3.open('wa', openCallBack3); - console.info('MediaLibraryTest : ASSET_CALLBACK open 005_04 success'); - done(); + media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO, (error, path) => { + try { + media.getFileAssets(videosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const asset1 = dataList[0]; + media.createAsset( + videoType, + 'video03.mp4', + path, + (error, creatAsset1) => { + try { + asset1.open('rw', (error, fd1) => { + try { + creatAsset1.open( + 'rw', + (error, creatAssetFd1) => { + try { + copyFile( + fd1, + creatAssetFd1, + test_num, + done, + () => { + try { + creatAsset1.close( + creatAssetFd1, + () => { + try { + asset1.close( + fd1, + () => { + try { + const asset2 = + dataList[0]; + media.createAsset( + videoType, + 'video04.mp4', + path, + ( + error, + creatAsset2 + ) => { + try { + asset2.open( + 'rw', + ( + error, + fd2 + ) => { + try { + creatAsset2.open( + 'rw', + ( + error, + creatAssetFd2 + ) => { + try { + copyFile( + fd2, + creatAssetFd2, + test_num, + done, + () => { + try { + creatAsset2.close( + creatAssetFd2, + () => { + try { + asset2.close( + fd2, + () => { + try { + if ( + creatAsset1.id != + creatAsset2.id + ) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect( + true + ).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect( + false + ).assertTrue(); + done(); + } + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK open 005_04 fail, message = ' + error); - done(); + executeAtError(test_num, error, done); } }); - it('SUB_MEDIA_MEDIALIBRARY_OPEN_ASSET_CALLBACK_005_05', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_02 + * @tc.name : createAsset + * @tc.desc : Access to the file displayName and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_02', 0, async function (done) { + const test_num = '002_02'; try { - let mediaType = mediaLibrary.MediaType.IMAGE; - var asset4 = await media.createAsset(mediaType, "image00004.jpg", path); - asset4.open('', openCallBack4); - console.info('MediaLibraryTest : ASSET_CALLBACK open 005_05 success'); - done(); + media.getFileAssets(videosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'displayName', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'displayName', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'displayName', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK open 005_05 fail, message = ' + error); - expect(true).assertTrue(); - done(); + executeAtError(test_num, error, done); } }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CLOSE_ASSET_CALLBACK_006 - * @tc.name : Close asset - * @tc.desc : Close asset + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_03 + * @tc.name : createAsset + * @tc.desc : Access to the file relativePath and validation is not undefined * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ - - it('SUB_MEDIA_MEDIALIBRARY_CLOSE_ASSET_CALLBACK_006_01', 0, async function (done) { + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_03', 0, async function (done) { + const test_num = '002_03'; try { - let mediaType = mediaLibrary.MediaType.IMAGE; - var asset5 = await media.createAsset(mediaType, "image00005.jpg", path); - fd = await asset5.open('Rw'); - asset5.close(-1, closeCallBack); - console.info('MediaLibraryTest : ASSET_CALLBACK close 006_01 success'); - expect(true).assertTrue(); - done(); + media.getFileAssets(videosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'relativePath', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'relativePath', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'relativePath', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK close 006_01 fail, message = ' + error); - expect(true).assertTrue(); - done(); + executeAtError(test_num, error, done); } }); - it('SUB_MEDIA_MEDIALIBRARY_CLOSE_ASSET_CALLBACK_006_02', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_04 + * @tc.name : createAsset + * @tc.desc : Access to the file size and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_04', 0, async function (done) { + const test_num = '002_04'; try { - let mediaType = mediaLibrary.MediaType.IMAGE; - var asset6 = await media.createAsset(mediaType, "image00006.jpg", path); - fd = await asset6.open('Rw'); - asset6.close(0, closeCallBack); - console.info('MediaLibraryTest : ASSET_CALLBACK close 006_02 success'); - done(); + media.getFileAssets(videosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'size', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'size', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'size', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK close 006_02 fail, message = ' + error); - expect(true).assertTrue(); - done(); + executeAtError(test_num, error, done); } }); - it('SUB_MEDIA_MEDIALIBRARY_CLOSE_ASSET_CALLBACK_006_03', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_05 + * @tc.name : createAsset + * @tc.desc : Access to the file dateAdded and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_05', 0, async function (done) { + const test_num = '002_05'; try { - let mediaType = mediaLibrary.MediaType.IMAGE; - var asset7 = await media.createAsset(mediaType, "image00007.jpg", pathMove); - fd = await asset7.open('Rw'); - asset7.close("666", closeCallBack); - console.info('MediaLibraryTest : ASSET_CALLBACK close 006_03 success'); - done(); + media.getFileAssets(videosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'dateAdded', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'dateAdded', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'dateAdded', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK close 006_03 fail, message = ' + error); - expect(true).assertTrue(); - done(); + executeAtError(test_num, error, done); } }); - it('SUB_MEDIA_MEDIALIBRARY_CLOSE_ASSET_CALLBACK_006_04', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_07 + * @tc.name : createAsset + * @tc.desc : Access to the file dateModified and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_07', 0, async function (done) { + const test_num = '002_07'; try { - let mediaType = mediaLibrary.MediaType.IMAGE; - var asset8 = await media.createAsset(mediaType, "image00008.jpg", pathMoveCallback); - fd = await asset8.open('Rw'); - asset8.close(closeCallBack); - console.info('MediaLibraryTest : ASSET_CALLBACK close 006_04 success'); - done(); + media.getFileAssets(videosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const asset = dataList[0]; + asset.title = `title_${new Date().getTime()}`; + asset.commitModify(() => { + try { + const id = asset.id; + const idOP = { + selections: fileKeyObj.ID + '= ?', + selectionArgs: ['' + id], + }; + media.getFileAssets(idOP, (error, newAssets) => { + try { + newAssets.getAllObject((error, newdataList) => { + try { + const newAsset = newdataList[0]; + if (asset.dateModified != undefined) { + if ( + newAsset.dateModified != + asset.dateModified + ) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect(false).assertTrue(); + done(); + } + } else if (newAsset.dateModified != undefined) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect(false).assertTrue(); + done(); + } + + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK close 006_04 fail, message = ' + error); - expect(true).assertTrue(); - done(); + executeAtError(test_num, error, done); } }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_007 - * @tc.name : Favourite - * @tc.desc : Favourite + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_08 + * @tc.name : createAsset + * @tc.desc : Insert a picture record, the retrieve attributes for images * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ - - it('SUB_MEDIA_MEDIALIBRARY_FAV_ASSET_CALLBACK_007_01', 0, async function (done) { + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_08', 0, async function (done) { + const test_num = '002_08'; try { - asset.isFavorite(isFavoriteCallBack); - console.info('MediaLibraryTest : ASSET_CALLBACK favourite 007_01 success'); - done(); + media.getFileAssets(videosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'mediaType', test_num, firstAsset, videoType); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'mediaType', test_num, midAsset, videoType); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'mediaType', test_num, lastAsset, videoType); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK favourite 007_01 fail, message = ' + error); - done(); + executeAtError(test_num, error, done); } }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_TRASH_ASSET_CALLBACK_008 - * @tc.name : Trash - * @tc.desc : Trash + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_09 + * @tc.name : createAsset + * @tc.desc : Get the width attribute * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ - - it('SSUB_MEDIA_MEDIALIBRARY_TRASH_ASSET_CALLBACK_008_01', 0, async function (done) { + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_09', 0, async function (done) { + const test_num = '002_09'; try { - asset.isTrash(isTrashCallBack); - console.info('MediaLibraryTest : ASSET_CALLBACK trash 008_01 success'); - done(); + media.getFileAssets(videosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'width', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'width', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'width', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK trash 008_01 fail, message = ' + error); - done(); + executeAtError(test_num, error, done); } }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_DIR_ASSET_CALLBACK_009 - * @tc.name : dir - * @tc.desc : dir + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_10 + * @tc.name : createAsset + * @tc.desc : Get the height attribute * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ - - it('SUB_MEDIA_MEDIALIBRARY_DIR_ASSET_CALLBACK_009_01', 0, async function (done) { + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_10', 0, async function (done) { + const test_num = '002_10'; try { - asset.isDirectory(isDirectoryCallBack); - console.info('MediaLibraryTest : ASSET_CALLBACK dir 009_01 success'); - done(); + media.getFileAssets(videosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'height', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'height', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'height', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); } catch (error) { - console.info('MediaLibraryTest : ASSET_CALLBACK dir 009_01 fail, message = ' + error); - done(); + executeAtError(test_num, error, done); } }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_ON_CALLBACK_010 - * @tc.name : On - * @tc.desc : On + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_11 + * @tc.name : createAsset + * @tc.desc : Get the orientaion attribute * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ - - it('SUB_MEDIA_MEDIALIBRARY_ON_CALLBACK_010_01', 0, async function (done) { + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_11', 0, async function (done) { + const test_num = '002_11'; try { - media.on(['image'], function (mediaChangeListener) { - console.log('MediaLibraryTest on mediaChangeListener 010_01 success'); + media.getFileAssets(videosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'orientation', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'orientation', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'orientation', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } }); - expect(true).assertTrue(); - done(); } catch (error) { - console.log('MediaLibraryTest on mediaChangeListener 010_01 fail, message = ' + error); - expect(false).assertTrue(); - done(); + executeAtError(test_num, error, done); } }); - it('SUB_MEDIA_MEDIALIBRARY_ON_CALLBACK_010_02', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_12 + * @tc.name : createAsset + * @tc.desc : Get the duration attribute + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_12', 0, async function (done) { + const test_num = '002_12'; try { - media.on(['file'], function (mediaChangeListener) { - console.log('MediaLibraryTest on mediaChangeListener 010_02 success'); + media.getFileAssets(videosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'duration', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'duration', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'duration', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } }); - expect(true).assertTrue(); - done(); } catch (error) { - console.log('MediaLibraryTest on mediaChangeListener 010_02 fail, message = ' + error); - expect(false).assertTrue(); - done(); + executeAtError(test_num, error, done); } - }); - it('SUB_MEDIA_MEDIALIBRARY_ON_CALLBACK_010_03', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_13 + * @tc.name : createAsset + * @tc.desc : Insert a picture record and get the property as picture + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_002_13', 0, async function (done) { + const test_num = '002_13'; try { - media.on(['audio'], function (mediaChangeListener) { - console.log('MediaLibraryTest on mediaChangeListener 010_03 success'); + media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO, (error, path) => { + try { + media.getFileAssets(videosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const asset1 = dataList[0]; + media.createAsset( + videoType, + 'video3.mp4', + path, + (error, creatAsset1) => { + try { + asset1.open('rw', (error, fd1) => { + try { + creatAsset1.open( + 'rw', + (error, creatAssetFd1) => { + try { + copyFile( + fd1, + creatAssetFd1, + test_num, + done, + () => { + try { + creatAsset1.close( + creatAssetFd1, + () => { + try { + asset1.close( + fd1, + () => { + try { + if ( + creatAsset1.mediaType == + videoType + ) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect( + true + ).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect( + false + ).assertTrue(); + done(); + } + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } }); - expect(true).assertTrue(); - done(); } catch (error) { - console.log('MediaLibraryTest on mediaChangeListener 010_03 fail, message = ' + error); - expect(false).assertTrue(); - done(); + executeAtError(test_num, error, done); } - }); + // ------------------------------- video type end ----------------------------- - it('SUB_MEDIA_MEDIALIBRARY_ON_CALLBACK_010_04', 0, async function (done) { + // ------------------------------- audio type start ---------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_01 + * @tc.name : createAsset + * @tc.desc : Insert two database records, read a unique identifier, expectations are not equal + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_01', 0, async function (done) { + const test_num = '003_01'; try { - media.on(['video', "smartalbum", "device"], function (mediaChangeListener) { - console.log('MediaLibraryTest on mediaChangeListener 010_04 success'); + media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO, (error, path) => { + try { + media.getFileAssets(audiosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const asset1 = dataList[0]; + media.createAsset( + audioType, + 'audio03.mp3', + path, + (error, creatAsset1) => { + try { + asset1.open('rw', (error, fd1) => { + try { + creatAsset1.open( + 'rw', + (error, creatAssetFd1) => { + try { + copyFile( + fd1, + creatAssetFd1, + test_num, + done, + () => { + try { + creatAsset1.close( + creatAssetFd1, + () => { + try { + asset1.close( + fd1, + () => { + try { + const asset2 = + dataList[0]; + media.createAsset( + audioType, + 'audio04.mp3', + path, + ( + error, + creatAsset2 + ) => { + try { + asset2.open( + 'rw', + ( + error, + fd2 + ) => { + try { + creatAsset2.open( + 'rw', + ( + error, + creatAssetFd2 + ) => { + try { + copyFile( + fd2, + creatAssetFd2, + test_num, + done, + () => { + try { + creatAsset2.close( + creatAssetFd2, + () => { + try { + asset2.close( + fd2, + () => { + try { + if ( + creatAsset1.id != + creatAsset2.id + ) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect( + true + ).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect( + false + ).assertTrue(); + done(); + } + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } }); - expect(true).assertTrue(); - done(); } catch (error) { - console.log('MediaLibraryTest on mediaChangeListener 010_04 fail, message = ' + error); - expect(false).assertTrue(); - done(); + executeAtError(test_num, error, done); } }); - it('SUB_MEDIA_MEDIALIBRARY_ON_CALLBACK_010_05', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_02 + * @tc.name : createAsset + * @tc.desc : Access to the file name and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_02', 0, async function (done) { + const test_num = '003_02'; try { - media.on(function (mediaChangeListener) { - console.log('MediaLibraryTest on mediaChangeListener 010_05 success'); + media.getFileAssets(audiosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'displayName', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'displayName', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'displayName', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } }); - expect(false).assertTrue(); - done(); } catch (error) { - console.log('MediaLibraryTest on mediaChangeListener 010_05 fail, message = ' + error); - expect(true).assertTrue(); - done(); + executeAtError(test_num, error, done); } }); /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_OFF_CALLBACK_011 - * @tc.name : Off - * @tc.desc : Off + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_03 + * @tc.name : createAsset + * @tc.desc : Access to the file relativePath and validation is not undefined * @tc.size : MEDIUM * @tc.type : Function * @tc.level : Level 0 */ - - it('SUB_MEDIA_MEDIALIBRARY_OFF_CALLBACK_011_01', 0, async function (done) { + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_03', 0, async function (done) { + const test_num = '003_03'; try { - media.off(['image'], function (mediaChangeListener) { - console.log('MediaLibraryTest off mediaChangeListener 011_01 success'); + media.getFileAssets(audiosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'relativePath', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'relativePath', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'relativePath', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } }); - expect(true).assertTrue(); - done(); } catch (error) { - console.log('MediaLibraryTest off mediaChangeListener 011_01 fail, message = ' + error); - expect(false).assertTrue(); - done(); + executeAtError(test_num, error, done); } }); - it('SUB_MEDIA_MEDIALIBRARY_OFF_CALLBACK_011_02', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_04 + * @tc.name : createAsset + * @tc.desc : Access to the file size and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_04', 0, async function (done) { + const test_num = '003_04'; try { - media.off(['file'], function (mediaChangeListener) { - console.log('MediaLibraryTest off mediaChangeListener 011_02 success'); + media.getFileAssets(filesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'size', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'size', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'size', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } }); - expect(true).assertTrue(); - done(); } catch (error) { - console.log('MediaLibraryTest off mediaChangeListener 011_02 fail, message = ' + error); - expect(false).assertTrue(); - done(); + executeAtError(test_num, error, done); } - }); - it('SUB_MEDIA_MEDIALIBRARY_OFF_CALLBACK_011_03', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_05 + * @tc.name : createAsset + * @tc.desc : Access to the file dateAdded and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_05', 0, async function (done) { + const test_num = '003_05'; try { - media.off(['audio'], function (mediaChangeListener) { - console.log('MediaLibraryTest off mediaChangeListener 011_03 success'); + media.getFileAssets(audiosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'dateAdded', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'dateAdded', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'dateAdded', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } }); - expect(true).assertTrue(); - done(); } catch (error) { - console.log('MediaLibraryTest off mediaChangeListener 011_03 fail, message = ' + error); - expect(false).assertTrue(); - done(); + executeAtError(test_num, error, done); } - }); - it('SUB_MEDIA_MEDIALIBRARY_OFF_CALLBACK_011_04', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_07 + * @tc.name : createAsset + * @tc.desc : Access to the file dateModified and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_07', 0, async function (done) { + const test_num = '003_07'; try { - media.off(['video', "smartalbum", "device"], function (mediaChangeListener) { - console.log('MediaLibraryTest off mediaChangeListener 011_04 success'); + media.getFileAssets(audiosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const asset = dataList[0]; + asset.title = `title_${new Date().getTime()}`; + asset.commitModify(() => { + try { + const id = asset.id; + const idOP = { + selections: fileKeyObj.ID + '= ?', + selectionArgs: ['' + id], + }; + media.getFileAssets(idOP, (error, newAssets) => { + try { + newAssets.getAllObject((error, newdataList) => { + try { + const newAsset = newdataList[0]; + if (asset.dateModified != undefined) { + if ( + newAsset.dateModified != + asset.dateModified + ) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect(false).assertTrue(); + done(); + } + } else if (newAsset.dateModified != undefined) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect(false).assertTrue(); + done(); + } + + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } }); - expect(true).assertTrue(); - done(); } catch (error) { - console.log('MediaLibraryTest off mediaChangeListener 011_04 fail, message = ' + error); - expect(false).assertTrue(); - done(); + executeAtError(test_num, error, done); } }); - it('SUB_MEDIA_MEDIALIBRARY_OFF_CALLBACK_011_05', 0, async function (done) { + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_08 + * @tc.name : createAsset + * @tc.desc : Insert a picture record, the retrieve attributes for images + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_08', 0, async function (done) { + const test_num = '003_08'; try { - media.off(['666'], function (mediaChangeListener) { - console.log('MediaLibraryTest off mediaChangeListener 011_05 success'); + media.getFileAssets(audiosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'mediaType', test_num, firstAsset, audioType); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'mediaType', test_num, midAsset, audioType); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'mediaType', test_num, lastAsset, audioType); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } }); - //expect(false).assertTrue(); - done(); } catch (error) { - console.log('MediaLibraryTest off mediaChangeListener 011_05 fail, message = ' + error); - //expect(true).assertTrue(); - done(); + executeAtError(test_num, error, done); } }); - - function getAllObjectInfo(data) { - if (data != undefined) { - console.info('MediaLibraryTest : ASSET_CALLBACK id is ' + data.id); - console.info('MediaLibraryTest : ASSET_CALLBACK uri is ' + data.uri); - console.info('MediaLibraryTest : ASSET_CALLBACK displayName is ' + data.displayName); - console.info('MediaLibraryTest : ASSET_CALLBACK mediaType is ' + data.title); - console.info('MediaLibraryTest : ASSET_CALLBACK relativePath is ' + data.relativePath); - } else { - console.info('MediaLibraryTest : ASSET_CALLBACK getAllObjectInfo no assets'); + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_09 + * @tc.name : createAsset + * @tc.desc : Get the artist attribute + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_09', 0, async function (done) { + const test_num = '003_09'; + try { + media.getFileAssets(audiosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'width', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'width', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'width', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); } - } + }); - function createAssetCallBack(err, asset) { - if (asset != undefined) { - console.info('MediaLibraryTest : ASSET_CALLBACK createAsset Successfull ' + asset.uri); - console.info('MediaLibraryTest : ASSET_CALLBACK createAsset : PASS'); - media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE, getPublicDirectory); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ASSET_CALLBACK createAsset Unsuccessfull ' + err); - console.info('MediaLibraryTest : ASSET_CALLBACK createAsset : FAIL'); - expect(false).assertTrue(); - done(); + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_10 + * @tc.name : createAsset + * @tc.desc : Get the album attribute + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_10', 0, async function (done) { + const test_num = '003_10'; + try { + media.getFileAssets(audiosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'albumName', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'albumName', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'albumName', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); } + }); - } - - function getPublicDirectory(err, publicDirectory) { - if (publicDirectory != undefined) { - console.info('MediaLibraryTest : ASSET_CALLBACK publicDirectory = ' + publicDirectory); - media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE); - done(); - } else { - console.info('MediaLibraryTest : ASSET_CALLBACK publicDirectory Unsuccessfull = ' + err); - console.info('MediaLibraryTest : ASSET_CALLBACK publicDirectory : FAIL'); - done(); + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_11 + * @tc.name : createAsset + * @tc.desc : Get the duration attribute + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_11', 0, async function (done) { + const test_num = '003_11'; + try { + media.getFileAssets(audiosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'duration', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'duration', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'duration', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); } + }); - } - - function commitModifyCallBack(err, commitModify) { - if (commitModify != undefined) { - console.info('MediaLibraryTest : ASSET_CALLBACK commitModify success'); - expect(true).assertTrue(); - done(); - } else { - console.info('MediaLibraryTest : ASSET_CALLBACK commitModify Unsuccessfull = ' + err); - console.info('MediaLibraryTest : ASSET_CALLBACK commitModify : FAIL'); - expect(false).assertTrue(); - done(); + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_12 + * @tc.name : createAsset + * @tc.desc : Insert a picture record and get the property as picture + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_003_12', 0, async function (done) { + const test_num = '003_12'; + try { + media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO, (error, path) => { + media.getFileAssets(audiosfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const asset1 = dataList[0]; + media.createAsset( + audioType, + 'audio3.mp3', + path, + (error, creatAsset1) => { + try { + asset1.open('rw', (error, fd1) => { + try { + creatAsset1.open( + 'rw', + (error, creatAssetFd1) => { + try { + copyFile( + fd1, + creatAssetFd1, + test_num, + done, + () => { + try { + creatAsset1.close( + creatAssetFd1, + () => { + try { + asset1.close( + fd1, + () => { + try { + if ( + creatAsset1.mediaType == + audioType + ) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect( + true + ).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect( + false + ).assertTrue(); + done(); + } + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + }); + } catch (error) { + executeAtError(test_num, error, done); } + }); + // ------------------------------- audio type end ----------------------------- - } - - function getFileAssetsCallBack(err, fetchFileResult) { - if (fetchFileResult != undefined) { - console.info('MediaLibraryTest : ASSET_CALLBACK fetchFileResult success'); - fetchFileResult.getAllObject((err1, data1) => { - if (data1 != undefined) { - data1.forEach(getAllObjectInfo); - console.info('MediaLibraryTest : getAllObject :PASS'); - expect(true).assertTrue(); - done(); - } - console.info('MediaLibraryTest : getFileAssets :No data'); - done(); - }); - } else { - console.info('MediaLibraryTest : ASSET_CALLBACK fetchFileResult Unsuccessfull = ' + err); - console.info('MediaLibraryTest : ASSET_CALLBACK fetchFileResult : FAIL'); - expect(false).assertTrue(); - done(); + // ------------------------------- file type start ---------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_01 + * @tc.name : createAsset + * @tc.desc : Insert two database records, read a unique identifier, expectations are not equal + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_01', 0, async function (done) { + const test_num = '004_01'; + try { + media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOWNLOAD, (error, path) => { + try { + media.getFileAssets(filesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const asset1 = dataList[0]; + media.createAsset( + fileType, + 'file03.txt', + path, + (error, creatAsset1) => { + try { + asset1.open('rw', (error, fd1) => { + try { + creatAsset1.open( + 'rw', + (error, creatAssetFd1) => { + try { + copyFile( + fd1, + creatAssetFd1, + test_num, + done, + () => { + try { + creatAsset1.close( + creatAssetFd1, + () => { + try { + asset1.close( + fd1, + () => { + try { + const asset2 = + dataList[0]; + media.createAsset( + fileType, + 'file04.txt', + path, + ( + error, + creatAsset2 + ) => { + try { + asset2.open( + 'rw', + ( + error, + fd2 + ) => { + try { + creatAsset2.open( + 'rw', + ( + error, + creatAssetFd2 + ) => { + try { + copyFile( + fd2, + creatAssetFd2, + test_num, + done, + () => { + try { + creatAsset2.close( + creatAssetFd2, + () => { + try { + asset2.close( + fd2, + () => { + try { + if ( + creatAsset1.id != + creatAsset2.id + ) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect( + true + ).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect( + false + ).assertTrue(); + done(); + } + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); } - } + }); - function openCallBack(openError, fd) { - if (openError != undefined) { - console.info('MediaLibraryTest : open : FAIL ' + openError.message); - console.info('MediaLibraryTest : ASSET_CALLBACK : FAIL'); - expect(false).assertTrue(); - done(); - } else { - console.info("==========================asset.open success=======================>"); - console.debug("open success fd = " + JSON.stringify(fd)); - console.info("==========================asset.close begin=======================>"); - asset.close(fd, closeCallBack); - console.info("==========================asset.close end=======================>"); - expect(true).assertTrue(); - done(); - } - } - function openCallBack(openError, fd) { - if (openError != undefined) { - console.info('MediaLibraryTest : open : FAIL ' + openError.message); - console.info('MediaLibraryTest : ASSET_CALLBACK : FAIL'); - expect(false).assertTrue(); - done(); - } else { - console.info("==========================asset.open success=======================>"); - console.debug("open success fd = " + JSON.stringify(fd)); - console.info("==========================asset.close begin=======================>"); - asset.close(fd, closeCallBack); - console.info("==========================asset.close end=======================>"); - expect(true).assertTrue(); - done(); - } - } - function openCallBack1(openError, fd) { - if (openError != undefined) { - console.info('MediaLibraryTest : open : FAIL ' + openError.message); - console.info('MediaLibraryTest : ASSET_CALLBACK : FAIL'); - expect(false).assertTrue(); - done(); - } else { - console.info("==========================asset.open success=======================>"); - console.debug("open success fd = " + JSON.stringify(fd)); - console.info("==========================asset.close begin=======================>"); - asset1.close(fd, closeCallBack); - console.info("==========================asset.close end=======================>"); - expect(true).assertTrue(); - done(); - } - } - function openCallBack2(openError, fd) { - if (openError != undefined) { - console.info('MediaLibraryTest : open : FAIL ' + openError.message); - console.info('MediaLibraryTest : ASSET_CALLBACK : FAIL'); - expect(false).assertTrue(); - done(); - } else { - console.info("==========================asset.open success=======================>"); - console.debug("open success fd = " + JSON.stringify(fd)); - console.info("==========================asset.close begin=======================>"); - asset2.close(fd, closeCallBack); - console.info("==========================asset.close end=======================>"); - expect(true).assertTrue(); - done(); - } - } - function openCallBack3(openError, fd) { - if (openError != undefined) { - console.info('MediaLibraryTest : open : FAIL ' + openError.message); - console.info('MediaLibraryTest : ASSET_CALLBACK : FAIL'); - expect(false).assertTrue(); - done(); - } else { - console.info("==========================asset.open success=======================>"); - console.debug("open success fd = " + JSON.stringify(fd)); - console.info("==========================asset.close begin=======================>"); - asset3.close(fd, closeCallBack); - console.info("==========================asset.close end=======================>"); - expect(true).assertTrue(); - done(); - } - } - function openCallBack4(openError, fd) { - if (openError != undefined) { - console.info('MediaLibraryTest : open : FAIL ' + openError.message); - console.info('MediaLibraryTest : ASSET_CALLBACK : FAIL'); - done(); - } else { - done(); + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_02 + * @tc.name : createAsset + * @tc.desc : Access to the file name and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_02', 0, async function (done) { + const test_num = '004_02'; + try { + media.getFileAssets(filesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'displayName', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'displayName', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'displayName', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); } - } + }); - function closeCallBack(closeErr) { - if (closeErr != undefined) { - console.info('MediaLibraryTest : close : FAIL ' + closeErr.message); - console.info('MediaLibraryTest : ASSET_CALLBACK : FAIL'); - done(); - } else { - console.info("==========================asset.close success=======================>"); - done(); - } - } - function isDirectoryCallBack(err, isDirectory) { - if (isDirectory != undefined) { - console.info('MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isDirectory = ' + isDirectory); - done(); - } else { - console.info('MediaLibraryTest : ASSET_CALLBACK isDirectory Unsuccessfull = ' + err); - console.info('MediaLibraryTest : ASSET_CALLBACK isDirectory : FAIL'); - done(); + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_03 + * @tc.name : createAsset + * @tc.desc : Access to the file relativePath and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_03', 0, async function (done) { + const test_num = '004_03'; + try { + media.getFileAssets(filesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'relativePath', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'relativePath', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'relativePath', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); } + }); - } - function favoriteCallBack(err, favorite) { - console.info('MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK favorite'); - done(); + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_04 + * @tc.name : createAsset + * @tc.desc : Access to the file size and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_04', 0, async function (done) { + const test_num = '004_04'; + try { + media.getFileAssets(filesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'size', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'size', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'size', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); - } - function isFavoriteCallBack(err, isFavorite) { - if (isFavorite != undefined) { - console.info('MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isFavorite = ' + isFavorite); - asset.favorite(true, favoriteCallBack); - done(); - } else { - console.info('MediaLibraryTest : ASSET_CALLBACK isFavorite Unsuccessfull = ' + err); - console.info('MediaLibraryTest : ASSET_CALLBACK isFavorite : FAIL'); - done(); + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_05 + * @tc.name : createAsset + * @tc.desc : Access to the file dateAdded and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_05', 0, async function (done) { + const test_num = '004_05'; + try { + media.getFileAssets(filesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'dateAdded', test_num, firstAsset); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'dateAdded', test_num, midAsset); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'dateAdded', test_num, lastAsset); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset 004_05 failed, message = ${error}` + ); + expect(false).assertTrue(); + done(); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); } + }); - } - function trashCallBack(err, trash) { - console.info('MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK trash'); - done(); - } - function isTrashCallBack(err, isTrash) { - if (isTrash != undefined) { - console.info('MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isTrash = ' + isTrash); - asset.trash(true, trashCallBack); - done(); - } else { - console.info('MediaLibraryTest : ASSET_CALLBACK isTrash Unsuccessfull = ' + err); - console.info('MediaLibraryTest : ASSET_CALLBACK isTrash : FAIL'); - done(); + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_07 + * @tc.name : createAsset + * @tc.desc : Access to the file dateModified and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_07', 0, async function (done) { + const test_num = '004_07'; + try { + media.getFileAssets(filesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const asset = dataList[0]; + asset.title = `title_${new Date().getTime()}`; + asset.commitModify(() => { + const id = asset.id; + const idOP = { + selections: fileKeyObj.ID + '= ?', + selectionArgs: ['' + id], + }; + media.getFileAssets(idOP, (error, newAssets) => { + try { + newAssets.getAllObject((error, newdataList) => { + try { + const newAsset = newdataList[0]; + if (asset.dateModified != undefined) { + if ( + newAsset.dateModified != asset.dateModified + ) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect(false).assertTrue(); + done(); + } + } else if (newAsset.dateModified != undefined) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect(false).assertTrue(); + done(); + } + + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); } - } - function getAllObjectInfoDelete(data3) { - console.info('MediaLibraryTest : id is ' + data3.id); - console.info('MediaLibraryTest : uri is ' + data3.uri); - console.info('MediaLibraryTest : displayName is ' + data3.displayName); - console.info('MediaLibraryTest : mediaType is ' + data3.mediaType); - - media.deleteAsset(data3.uri, (err4, data4) => { - if (data4 == 0) { - console.info('MediaLibraryTest : Delete Album Successfull ' + data4); - console.info('MediaLibraryTest : Delete Asset : PASS'); - } else { - console.info('MediaLibraryTest : Album is not modified ' + err4.message); - console.info('MediaLibraryTest : Modify Asset : FAIL'); - } - }); - } - function deleteAssetCallBack(err, deleteAsset) { - if (deleteAsset != undefined) { - console.info('MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK deleteAssetCode = ' + deleteAsset); - console.info('MediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK deleteAssetCode success'); - done(); - } else { - console.info('MediaLibraryTest : ASSET_CALLBACK deleteAsset Unsuccessfull = ' + err); - console.info('MediaLibraryTest : ASSET_CALLBACK deleteAsset : FAIL'); - done(); + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_08 + * @tc.name : createAsset + * @tc.desc : Insert a picture record, the retrieve attributes for images + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_08', 0, async function (done) { + const test_num = '004_08'; + try { + media.getFileAssets(filesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const firstAsset = dataList[0]; + checkAssetAttr(done, 'mediaType', test_num, firstAsset, fileType); + + const midAsset = dataList[Math.floor(dataList.length / 2)]; + checkAssetAttr(done, 'mediaType', test_num, midAsset, fileType); + + const lastAsset = dataList[dataList.length - 1]; + checkAssetAttr(done, 'mediaType', test_num, lastAsset, fileType); + + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect(true).assertTrue(); + done(); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); } - } + }); -}) + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_09 + * @tc.name : createAsset + * @tc.desc : Insert two database records, read a unique identifier, expectations are not equal + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_CALLBACK_004_09', 0, async function (done) { + const test_num = '004_09'; + try { + media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOWNLOAD, (error, path) => { + try { + media.getFileAssets(filesfetchOp, (error, fileAssets) => { + try { + fileAssets.getAllObject((error, dataList) => { + try { + const asset1 = dataList[0]; + media.createAsset( + fileType, + 'file3.txt', + path, + (error, creatAsset1) => { + try { + asset1.open('rw', (error, fd1) => { + try { + creatAsset1.open( + 'rw', + (error, creatAssetFd1) => { + try { + copyFile( + fd1, + creatAssetFd1, + test_num, + done, + () => { + try { + creatAsset1.close( + creatAssetFd1, + () => { + try { + asset1.close( + fd1, + () => { + try { + if ( + creatAsset1.mediaType == + fileType + ) { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} passed` + ); + expect( + true + ).assertTrue(); + done(); + } else { + console.info( + `MediaLibraryTest : ASSET_CALLBACK createAsset ${test_num} failed` + ); + expect( + false + ).assertTrue(); + done(); + } + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError( + test_num, + error, + done + ); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + } + ); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + } catch (error) { + executeAtError(test_num, error, done); + } + }); + // ------------------------------- file type end ----------------------------- +}); diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileTestPromise.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileTestPromise.test.js index ab64bfe344385a861a68d6bb41a29ff2626efd47..87184929201867efc3897edd0f4bda4f1ba24c46 100644 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileTestPromise.test.js +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/fileTestPromise.test.js @@ -1,729 +1,728 @@ -/* - * Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility'; -import fileio from '@ohos.fileio'; - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; -let fileKeyObj = mediaLibrary.FileKey; -let fileType = mediaLibrary.MediaType.FILE; -let imageType = mediaLibrary.MediaType.IMAGE; -let videoType = mediaLibrary.MediaType.VIDEO; -let audioType = mediaLibrary.MediaType.AUDIO; - -let imagesfetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [imageType.toString()], -}; -let videosfetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [videoType.toString()], -}; -let audiosfetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [audioType.toString()], -}; -let filesfetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [fileType.toString()], -}; - -function checkAssetAttr(done, attr, testNum, asset, checkType) { - if (checkType && asset[attr] != checkType) { - console.info(`ASSET_PROMISE getFileAssets ${testNum} failed`); - expect(false).assertTrue(); - done(); - } else if (asset[attr] == undefined) { - console.info(`ASSET_PROMISE getFileAssets ${testNum} failed`); - expect(false).assertTrue(); - done(); - } -} - -let path; -let presetAsset; -let displayName; -let id; -let mediaType; -let orientation = 0; -describe('fileTestPromise.test.js', function () { - var context = featureAbility.getContext(); - console.info('getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('getMediaLibrary OUT'); - beforeAll(function () {}); - beforeEach(function () {}); - afterEach(function () {}); - afterAll(function () {}); - - async function copyFile(fd1, fd2) { - let stat = await fileio.fstat(fd1); - let buf = new ArrayBuffer(stat.size); - await fileio.read(fd1, buf); - await fileio.write(fd2, buf); - } - - // ------------------------------- image type start ---------------------------- - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_01 - * @tc.name : createAsset - * @tc.desc : Insert two database records, read a unique identifier, expectations are not equal - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_01', 0, async function (done) { - try { - path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE); - const fileAssets = await media.getFileAssets(imagesfetchOp); - const dataList = await fileAssets.getAllObject(); - const asset1 = dataList[0]; - presetAsset = asset1; - const creatAsset1 = await media.createAsset( - imageType, - `${new Date().getTime()}.jpg`, - path - ); - const fd1 = await asset1.open('rw'); - const creatAssetFd1 = await creatAsset1.open('rw'); - await copyFile(fd1, creatAssetFd1); - await creatAsset1.close(creatAssetFd1); - await asset1.close(fd1); - displayName = `${new Date().getTime()}.jpg`; - const asset2 = dataList[1]; - const creatAsset2 = await media.createAsset(imageType, displayName, path); - const fd2 = await asset2.open('rw'); - const creatAssetFd2 = await creatAsset2.open('rw'); - await copyFile(fd2, creatAssetFd2); - await creatAsset2.close(creatAssetFd2); - await asset2.close(fd2); - id = creatAsset2.id; - mediaType = imageType; - expect(creatAsset1.id != creatAsset2.id).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE createAsset 001_01 failed, message = ' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_02 - * @tc.name : getFileAssets - * @tc.desc : Access to the file displayName and validation is not undefined - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_02', 0, async function (done) { - try { - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const fileAssets = await media.getFileAssets(idOP); - const asset = await fileAssets.getFirstObject(); - - expect(asset.displayName == displayName).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE getFileAssets 001_02 failed, message = ' + error); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_03 - * @tc.name : getFileAssets - * @tc.desc : Access to the file relativePath and validation is not undefined - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_03', 0, async function (done) { - try { - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const fileAssets = await media.getFileAssets(idOP); - const asset = await fileAssets.getFirstObject(); - expect(asset.relativePath == path).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE getFileAssets 001_03 failed, message = ' + error); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_07 - * @tc.name : getFileAssets - * @tc.desc : Access to the file dateModified and validation is not undefined - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_07', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(imagesfetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - asset.title = `title_${new Date().getTime()}`; - await asset.commitModify(); - const id = asset.id; - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const newAssets = await media.getFileAssets(idOP); - const newdataList = await newAssets.getAllObject(); - const newAsset = newdataList[0]; - - if (asset.dateModified != undefined) { - if (newAsset.dateModified != asset.dateModified) { - console.info('ASSET_PROMISE getFileAssets 001_07 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('ASSET_PROMISE getFileAssets 001_07 failed'); - expect(false).assertTrue(); - done(); - } - } else if (newAsset.dateModified != undefined) { - console.info('ASSET_PROMISE getFileAssets 001_07 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('ASSET_PROMISE getFileAssets 001_07 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('ASSET_PROMISE getFileAssets 001_07 failed, message = ' + error); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_08 - * @tc.name : createAsset - * @tc.desc : Insert a picture record, the retrieve attributes for images - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_08', 0, async function (done) { - try { - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const fileAssets = await media.getFileAssets(idOP); - const asset = await fileAssets.getFirstObject(); - expect(asset.mediaType == mediaType).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE createAsset 001_08 failed, message = ' + error); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_11 - * @tc.name : createAsset - * @tc.desc : Get the orientaion attribute - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_11', 0, async function (done) { - try { - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const fileAssets = await media.getFileAssets(idOP); - const asset = await fileAssets.getFirstObject(); - expect(asset.orientation == orientation).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE createAsset 001_11 failed, message = ' + error); - } - }); - - // ------------------------------- image type end ----------------------------- - - // ------------------------------- video type start ---------------------------- - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_01 - * @tc.name : createAsset - * @tc.desc : Insert two database records, read a unique identifier, expectations are not equal - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_01', 0, async function (done) { - try { - path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); - const fileAssets = await media.getFileAssets(videosfetchOp); - const dataList = await fileAssets.getAllObject(); - const asset1 = dataList[0]; - const creatAsset1 = await media.createAsset( - videoType, - `${new Date().getTime()}.mp4`, - path - ); - const fd1 = await asset1.open('rw'); - const creatAssetFd1 = await creatAsset1.open('rw'); - await copyFile(fd1, creatAssetFd1); - await creatAsset1.close(creatAssetFd1); - await asset1.close(fd1); - displayName = `${new Date().getTime()}.mp4`; - const asset2 = dataList[0]; - const creatAsset2 = await media.createAsset(videoType, displayName, path); - const fd2 = await asset2.open('rw'); - const creatAssetFd2 = await creatAsset2.open('rw'); - await copyFile(fd2, creatAssetFd2); - await creatAsset2.close(creatAssetFd2); - await asset2.close(fd2); - id = creatAsset2.id; - mediaType = videoType; - - expect(creatAsset1.id != creatAsset2.id).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE createAsset 002_01 failed' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_02 - * @tc.name : getFileAssets - * @tc.desc : Access to the file displayName and validation is not undefined - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_02', 0, async function (done) { - try { - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const fileAssets = await media.getFileAssets(idOP); - const asset = await fileAssets.getFirstObject(); - - expect(asset.displayName == displayName).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE getFileAssets 002_02 failed, message = ' + error); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_03 - * @tc.name : getFileAssets - * @tc.desc : Access to the file relativePath and validation is not undefined - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_03', 0, async function (done) { - try { - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const fileAssets = await media.getFileAssets(idOP); - const asset = await fileAssets.getFirstObject(); - - expect(asset.relativePath == path).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE getFileAssets 002_03 failed, message = ' + error); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_07 - * @tc.name : getFileAssets - * @tc.desc : Access to the file dateModified and validation is not undefined - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_07', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(videosfetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - asset.title = `title_${new Date().getTime()}`; - await asset.commitModify(); - const id = asset.id; - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const newAssets = await media.getFileAssets(idOP); - const newdataList = await newAssets.getAllObject(); - const newAsset = newdataList[0]; - - if (asset.dateModified != undefined) { - if (newAsset.dateModified != asset.dateModified) { - console.info('ASSET_PROMISE getFileAssets 002_07 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('ASSET_PROMISE getFileAssets 002_07 failed'); - expect(false).assertTrue(); - done(); - } - } else if (newAsset.dateModified != undefined) { - console.info('ASSET_PROMISE getFileAssets 002_07 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('ASSET_PROMISE getFileAssets 002_07 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('ASSET_PROMISE getFileAssets 002_07 failed, message = ' + error); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_08 - * @tc.name : createAsset - * @tc.desc : Insert a picture record, the retrieve attributes for images - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_08', 0, async function (done) { - try { - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const fileAssets = await media.getFileAssets(idOP); - const asset = await fileAssets.getFirstObject(); - expect(asset.mediaType == mediaType).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE createAsset 002_08 failed, message = ' + error); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_11 - * @tc.name : createAsset - * @tc.desc : Get the orientaion attribute - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_11', 0, async function (done) { - try { - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const fileAssets = await media.getFileAssets(idOP); - const asset = await fileAssets.getFirstObject(); - expect(asset.orientation == orientation).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE createAsset 002_11 failed, message = ' + error); - } - }); - // ------------------------------- video type end ----------------------------- - - // ------------------------------- audio type start ---------------------------- - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_01 - * @tc.name : createAsset - * @tc.desc : Insert two database records, read a unique identifier, expectations are not equal - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_01', 0, async function (done) { - try { - path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO); - const fileAssets = await media.getFileAssets(audiosfetchOp); - const dataList = await fileAssets.getAllObject(); - const asset1 = dataList[0]; - const creatAsset1 = await media.createAsset( - audioType, - `${new Date().getTime()}.mp3`, - path - ); - const fd1 = await asset1.open('rw'); - const creatAssetFd1 = await creatAsset1.open('rw'); - await copyFile(fd1, creatAssetFd1); - await creatAsset1.close(creatAssetFd1); - await asset1.close(fd1); - displayName = `${new Date().getTime()}.mp3`; - const asset2 = dataList[0]; - const creatAsset2 = await media.createAsset(audioType, displayName, path); - const fd2 = await asset2.open('rw'); - const creatAssetFd2 = await creatAsset2.open('rw'); - await copyFile(fd2, creatAssetFd2); - await creatAsset2.close(creatAssetFd2); - await asset2.close(fd2); - id = creatAsset2.id; - mediaType = audioType; - expect(creatAsset1.id != creatAsset2.id).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE createAsset 003_01 failed'); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_02 - * @tc.name : getFileAssets - * @tc.desc : Access to the file name and validation is not undefined - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_02', 0, async function (done) { - try { - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const fileAssets = await media.getFileAssets(idOP); - const asset = await fileAssets.getFirstObject(); - expect(asset.displayName == displayName).assertTrue(); - - done(); - } catch (error) { - console.info('ASSET_PROMISE getFileAssets 003_02 failed, message = ' + error); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_03 - * @tc.name : getFileAssets - * @tc.desc : Access to the file relativePath and validation is not undefined - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_03', 0, async function (done) { - try { - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const fileAssets = await media.getFileAssets(idOP); - const asset = await fileAssets.getFirstObject(); - expect(asset.relativePath == path).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE getFileAssets 003_03 failed, message = ' + error); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_07 - * @tc.name : getFileAssets - * @tc.desc : Access to the file dateModified and validation is not undefined - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_07', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(audiosfetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - asset.title = `title_${new Date().getTime()}`; - await asset.commitModify(); - - const id = asset.id; - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const newAssets = await media.getFileAssets(idOP); - const newdataList = await newAssets.getAllObject(); - const newAsset = newdataList[0]; - - if (asset.dateModified != undefined) { - if (newAsset.dateModified != asset.dateModified) { - console.info('ASSET_PROMISE getFileAssets 003_07 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('ASSET_PROMISE getFileAssets 003_07 failed'); - expect(false).assertTrue(); - done(); - } - } else if (newAsset.dateModified != undefined) { - console.info('ASSET_PROMISE getFileAssets 003_07 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('ASSET_PROMISE getFileAssets 003_07 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('ASSET_PROMISE getFileAssets 003_07 failed, message = ' + error); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_08 - * @tc.name : createAsset - * @tc.desc : Insert a picture record, the retrieve attributes for images - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_08', 0, async function (done) { - try { - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const fileAssets = await media.getFileAssets(idOP); - const asset = await fileAssets.getFirstObject(); - expect(asset.mediaType == mediaType).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE createAsset 003_08 failed, message = ' + error); - } - }); - - // ------------------------------- audio type end ----------------------------- - - // ------------------------------ file type start ---------------------------- - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_01 - * @tc.name : createAsset - * @tc.desc : Insert two database records, read a unique identifier, expectations are not equal - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_01', 0, async function (done) { - try { - path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOWNLOAD); - const fileAssets = await media.getFileAssets(filesfetchOp); - const dataList = await fileAssets.getAllObject(); - const asset1 = dataList[0]; - const creatAsset1 = await media.createAsset( - fileType, - `${new Date().getTime()}.bat`, - path - ); - const fd1 = await asset1.open('rw'); - const creatAssetFd1 = await creatAsset1.open('rw'); - await copyFile(fd1, creatAssetFd1); - await creatAsset1.close(creatAssetFd1); - await asset1.close(fd1); - displayName = `${new Date().getTime()}.bat`; - const asset2 = dataList[0]; - const creatAsset2 = await media.createAsset(fileType, displayName, path); - const fd2 = await asset2.open('rw'); - const creatAssetFd2 = await creatAsset2.open('rw'); - await copyFile(fd2, creatAssetFd2); - await creatAsset2.close(creatAssetFd2); - await asset2.close(fd2); - id = creatAsset2.id; - mediaType = fileType; - expect(creatAsset1.id != creatAsset2.id).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE createAsset 004_01 failed' + error); - expect(false).assertTrue(); - done(); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_02 - * @tc.name : getFileAssets - * @tc.desc : Access to the file name and validation is not undefined - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_02', 0, async function (done) { - try { - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const fileAssets = await media.getFileAssets(idOP); - const asset = await fileAssets.getFirstObject(); - expect(asset.displayName == displayName).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE getFileAssets 004_02 failed, message = ' + error); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_03 - * @tc.name : getFileAssets - * @tc.desc : Access to the file relativePath and validation is not undefined - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_03', 0, async function (done) { - try { - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const fileAssets = await media.getFileAssets(idOP); - const asset = await fileAssets.getFirstObject(); - expect(asset.relativePath == path).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE getFileAssets 004_03 failed, message = ' + error); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_07 - * @tc.name : getFileAssets - * @tc.desc : Access to the file dateModified and validation is not undefined - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_07', 0, async function (done) { - try { - const fileAssets = await media.getFileAssets(filesfetchOp); - const dataList = await fileAssets.getAllObject(); - const asset = dataList[0]; - asset.title = `title_${new Date().getTime()}`; - await asset.commitModify(); - const id = asset.id; - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const newAssets = await media.getFileAssets(idOP); - const newdataList = await newAssets.getAllObject(); - const newAsset = newdataList[0]; - - if (asset.dateModified != undefined) { - if (newAsset.dateModified != asset.dateModified) { - console.info('ASSET_PROMISE getFileAssets 004_07 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('ASSET_PROMISE getFileAssets 004_07 failed'); - expect(false).assertTrue(); - done(); - } - } else if (newAsset.dateModified != undefined) { - console.info('ASSET_PROMISE getFileAssets 004_07 passed'); - expect(true).assertTrue(); - done(); - } else { - console.info('ASSET_PROMISE getFileAssets 004_07 failed'); - expect(false).assertTrue(); - done(); - } - } catch (error) { - console.info('ASSET_PROMISE getFileAssets 004_07 failed, message = ' + error); - } - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_08 - * @tc.name : createAsset - * @tc.desc : Insert a picture record, the retrieve attributes for images - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_08', 0, async function (done) { - try { - const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; - const fileAssets = await media.getFileAssets(idOP); - const asset = await fileAssets.getFirstObject(); - expect(asset.mediaType == mediaType).assertTrue(); - done(); - } catch (error) { - console.info('ASSET_PROMISE createAsset 004_08 failed, message = ' + error); - } - }); - - // ------------------------------- file type end ----------------------------- -}); - +/* + * Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import featureAbility from '@ohos.ability.featureAbility'; +import fileio from '@ohos.fileio'; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +let fileKeyObj = mediaLibrary.FileKey; +let fileType = mediaLibrary.MediaType.FILE; +let imageType = mediaLibrary.MediaType.IMAGE; +let videoType = mediaLibrary.MediaType.VIDEO; +let audioType = mediaLibrary.MediaType.AUDIO; + +let imagesfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], +}; +let videosfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [videoType.toString()], +}; +let audiosfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [audioType.toString()], +}; +let filesfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], +}; + +function checkAssetAttr(done, attr, testNum, asset, checkType) { + if (checkType && asset[attr] != checkType) { + console.info(`ASSET_PROMISE getFileAssets ${testNum} failed`); + expect(false).assertTrue(); + done(); + } else if (asset[attr] == undefined) { + console.info(`ASSET_PROMISE getFileAssets ${testNum} failed`); + expect(false).assertTrue(); + done(); + } +} + +let path; +let presetAsset; +let displayName; +let id; +let mediaType; +let orientation = 0; +describe('fileTestPromise.test.js', function () { + var context = featureAbility.getContext(); + console.info('getMediaLibrary IN'); + var media = mediaLibrary.getMediaLibrary(context); + console.info('getMediaLibrary OUT'); + beforeAll(function () {}); + beforeEach(function () {}); + afterEach(function () {}); + afterAll(function () {}); + + async function copyFile(fd1, fd2) { + let stat = await fileio.fstat(fd1); + let buf = new ArrayBuffer(stat.size); + await fileio.read(fd1, buf); + await fileio.write(fd2, buf); + } + + // ------------------------------- image type start ---------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_01 + * @tc.name : createAsset + * @tc.desc : Insert two database records, read a unique identifier, expectations are not equal + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_01', 0, async function (done) { + try { + path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_IMAGE); + const fileAssets = await media.getFileAssets(imagesfetchOp); + const dataList = await fileAssets.getAllObject(); + const asset1 = dataList[0]; + presetAsset = asset1; + const creatAsset1 = await media.createAsset( + imageType, + `${new Date().getTime()}.jpg`, + path + ); + const fd1 = await asset1.open('rw'); + const creatAssetFd1 = await creatAsset1.open('rw'); + await copyFile(fd1, creatAssetFd1); + await creatAsset1.close(creatAssetFd1); + await asset1.close(fd1); + displayName = `${new Date().getTime()}.jpg`; + const asset2 = dataList[1]; + const creatAsset2 = await media.createAsset(imageType, displayName, path); + const fd2 = await asset2.open('rw'); + const creatAssetFd2 = await creatAsset2.open('rw'); + await copyFile(fd2, creatAssetFd2); + await creatAsset2.close(creatAssetFd2); + await asset2.close(fd2); + id = creatAsset2.id; + mediaType = imageType; + expect(creatAsset1.id != creatAsset2.id).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE createAsset 001_01 failed, message = ' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_02 + * @tc.name : getFileAssets + * @tc.desc : Access to the file displayName and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_02', 0, async function (done) { + try { + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const fileAssets = await media.getFileAssets(idOP); + const asset = await fileAssets.getFirstObject(); + + expect(asset.displayName == displayName).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE getFileAssets 001_02 failed, message = ' + error); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_03 + * @tc.name : getFileAssets + * @tc.desc : Access to the file relativePath and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_03', 0, async function (done) { + try { + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const fileAssets = await media.getFileAssets(idOP); + const asset = await fileAssets.getFirstObject(); + expect(asset.relativePath == path).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE getFileAssets 001_03 failed, message = ' + error); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_07 + * @tc.name : getFileAssets + * @tc.desc : Access to the file dateModified and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_07', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(imagesfetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + asset.title = `title_${new Date().getTime()}`; + await asset.commitModify(); + const id = asset.id; + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const newAssets = await media.getFileAssets(idOP); + const newdataList = await newAssets.getAllObject(); + const newAsset = newdataList[0]; + + if (asset.dateModified != undefined) { + if (newAsset.dateModified != asset.dateModified) { + console.info('ASSET_PROMISE getFileAssets 001_07 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('ASSET_PROMISE getFileAssets 001_07 failed'); + expect(false).assertTrue(); + done(); + } + } else if (newAsset.dateModified != undefined) { + console.info('ASSET_PROMISE getFileAssets 001_07 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('ASSET_PROMISE getFileAssets 001_07 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('ASSET_PROMISE getFileAssets 001_07 failed, message = ' + error); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_08 + * @tc.name : createAsset + * @tc.desc : Insert a picture record, the retrieve attributes for images + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_08', 0, async function (done) { + try { + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const fileAssets = await media.getFileAssets(idOP); + const asset = await fileAssets.getFirstObject(); + expect(asset.mediaType == mediaType).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE createAsset 001_08 failed, message = ' + error); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_11 + * @tc.name : createAsset + * @tc.desc : Get the orientaion attribute + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_001_11', 0, async function (done) { + try { + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const fileAssets = await media.getFileAssets(idOP); + const asset = await fileAssets.getFirstObject(); + expect(asset.orientation == orientation).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE createAsset 001_11 failed, message = ' + error); + } + }); + + // ------------------------------- image type end ----------------------------- + + // ------------------------------- video type start ---------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_01 + * @tc.name : createAsset + * @tc.desc : Insert two database records, read a unique identifier, expectations are not equal + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_01', 0, async function (done) { + try { + path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_VIDEO); + const fileAssets = await media.getFileAssets(videosfetchOp); + const dataList = await fileAssets.getAllObject(); + const asset1 = dataList[0]; + const creatAsset1 = await media.createAsset( + videoType, + `${new Date().getTime()}.mp4`, + path + ); + const fd1 = await asset1.open('rw'); + const creatAssetFd1 = await creatAsset1.open('rw'); + await copyFile(fd1, creatAssetFd1); + await creatAsset1.close(creatAssetFd1); + await asset1.close(fd1); + displayName = `${new Date().getTime()}.mp4`; + const asset2 = dataList[0]; + const creatAsset2 = await media.createAsset(videoType, displayName, path); + const fd2 = await asset2.open('rw'); + const creatAssetFd2 = await creatAsset2.open('rw'); + await copyFile(fd2, creatAssetFd2); + await creatAsset2.close(creatAssetFd2); + await asset2.close(fd2); + id = creatAsset2.id; + mediaType = videoType; + + expect(creatAsset1.id != creatAsset2.id).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE createAsset 002_01 failed' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_02 + * @tc.name : getFileAssets + * @tc.desc : Access to the file displayName and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_02', 0, async function (done) { + try { + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const fileAssets = await media.getFileAssets(idOP); + const asset = await fileAssets.getFirstObject(); + + expect(asset.displayName == displayName).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE getFileAssets 002_02 failed, message = ' + error); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_03 + * @tc.name : getFileAssets + * @tc.desc : Access to the file relativePath and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_03', 0, async function (done) { + try { + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const fileAssets = await media.getFileAssets(idOP); + const asset = await fileAssets.getFirstObject(); + + expect(asset.relativePath == path).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE getFileAssets 002_03 failed, message = ' + error); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_07 + * @tc.name : getFileAssets + * @tc.desc : Access to the file dateModified and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_07', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(videosfetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + asset.title = `title_${new Date().getTime()}`; + await asset.commitModify(); + const id = asset.id; + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const newAssets = await media.getFileAssets(idOP); + const newdataList = await newAssets.getAllObject(); + const newAsset = newdataList[0]; + + if (asset.dateModified != undefined) { + if (newAsset.dateModified != asset.dateModified) { + console.info('ASSET_PROMISE getFileAssets 002_07 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('ASSET_PROMISE getFileAssets 002_07 failed'); + expect(false).assertTrue(); + done(); + } + } else if (newAsset.dateModified != undefined) { + console.info('ASSET_PROMISE getFileAssets 002_07 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('ASSET_PROMISE getFileAssets 002_07 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('ASSET_PROMISE getFileAssets 002_07 failed, message = ' + error); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_08 + * @tc.name : createAsset + * @tc.desc : Insert a picture record, the retrieve attributes for images + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_08', 0, async function (done) { + try { + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const fileAssets = await media.getFileAssets(idOP); + const asset = await fileAssets.getFirstObject(); + expect(asset.mediaType == mediaType).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE createAsset 002_08 failed, message = ' + error); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_11 + * @tc.name : createAsset + * @tc.desc : Get the orientaion attribute + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_002_11', 0, async function (done) { + try { + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const fileAssets = await media.getFileAssets(idOP); + const asset = await fileAssets.getFirstObject(); + expect(asset.orientation == orientation).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE createAsset 002_11 failed, message = ' + error); + } + }); + // ------------------------------- video type end ----------------------------- + + // ------------------------------- audio type start ---------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_01 + * @tc.name : createAsset + * @tc.desc : Insert two database records, read a unique identifier, expectations are not equal + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_01', 0, async function (done) { + try { + path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_AUDIO); + const fileAssets = await media.getFileAssets(audiosfetchOp); + const dataList = await fileAssets.getAllObject(); + const asset1 = dataList[0]; + const creatAsset1 = await media.createAsset( + audioType, + `${new Date().getTime()}.mp3`, + path + ); + const fd1 = await asset1.open('rw'); + const creatAssetFd1 = await creatAsset1.open('rw'); + await copyFile(fd1, creatAssetFd1); + await creatAsset1.close(creatAssetFd1); + await asset1.close(fd1); + displayName = `${new Date().getTime()}.mp3`; + const asset2 = dataList[0]; + const creatAsset2 = await media.createAsset(audioType, displayName, path); + const fd2 = await asset2.open('rw'); + const creatAssetFd2 = await creatAsset2.open('rw'); + await copyFile(fd2, creatAssetFd2); + await creatAsset2.close(creatAssetFd2); + await asset2.close(fd2); + id = creatAsset2.id; + mediaType = audioType; + expect(creatAsset1.id != creatAsset2.id).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE createAsset 003_01 failed'); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_02 + * @tc.name : getFileAssets + * @tc.desc : Access to the file name and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_02', 0, async function (done) { + try { + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const fileAssets = await media.getFileAssets(idOP); + const asset = await fileAssets.getFirstObject(); + expect(asset.displayName == displayName).assertTrue(); + + done(); + } catch (error) { + console.info('ASSET_PROMISE getFileAssets 003_02 failed, message = ' + error); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_03 + * @tc.name : getFileAssets + * @tc.desc : Access to the file relativePath and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_03', 0, async function (done) { + try { + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const fileAssets = await media.getFileAssets(idOP); + const asset = await fileAssets.getFirstObject(); + expect(asset.relativePath == path).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE getFileAssets 003_03 failed, message = ' + error); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_07 + * @tc.name : getFileAssets + * @tc.desc : Access to the file dateModified and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_07', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(audiosfetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + asset.title = `title_${new Date().getTime()}`; + await asset.commitModify(); + + const id = asset.id; + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const newAssets = await media.getFileAssets(idOP); + const newdataList = await newAssets.getAllObject(); + const newAsset = newdataList[0]; + + if (asset.dateModified != undefined) { + if (newAsset.dateModified != asset.dateModified) { + console.info('ASSET_PROMISE getFileAssets 003_07 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('ASSET_PROMISE getFileAssets 003_07 failed'); + expect(false).assertTrue(); + done(); + } + } else if (newAsset.dateModified != undefined) { + console.info('ASSET_PROMISE getFileAssets 003_07 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('ASSET_PROMISE getFileAssets 003_07 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('ASSET_PROMISE getFileAssets 003_07 failed, message = ' + error); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_08 + * @tc.name : createAsset + * @tc.desc : Insert a picture record, the retrieve attributes for images + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_003_08', 0, async function (done) { + try { + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const fileAssets = await media.getFileAssets(idOP); + const asset = await fileAssets.getFirstObject(); + expect(asset.mediaType == mediaType).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE createAsset 003_08 failed, message = ' + error); + } + }); + + // ------------------------------- audio type end ----------------------------- + + // ------------------------------ file type start ---------------------------- + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_01 + * @tc.name : createAsset + * @tc.desc : Insert two database records, read a unique identifier, expectations are not equal + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_01', 0, async function (done) { + try { + path = await media.getPublicDirectory(mediaLibrary.DirectoryType.DIR_DOWNLOAD); + const fileAssets = await media.getFileAssets(filesfetchOp); + const dataList = await fileAssets.getAllObject(); + const asset1 = dataList[0]; + const creatAsset1 = await media.createAsset( + fileType, + `${new Date().getTime()}.bat`, + path + ); + const fd1 = await asset1.open('rw'); + const creatAssetFd1 = await creatAsset1.open('rw'); + await copyFile(fd1, creatAssetFd1); + await creatAsset1.close(creatAssetFd1); + await asset1.close(fd1); + displayName = `${new Date().getTime()}.bat`; + const asset2 = dataList[0]; + const creatAsset2 = await media.createAsset(fileType, displayName, path); + const fd2 = await asset2.open('rw'); + const creatAssetFd2 = await creatAsset2.open('rw'); + await copyFile(fd2, creatAssetFd2); + await creatAsset2.close(creatAssetFd2); + await asset2.close(fd2); + id = creatAsset2.id; + mediaType = fileType; + expect(creatAsset1.id != creatAsset2.id).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE createAsset 004_01 failed' + error); + expect(false).assertTrue(); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_02 + * @tc.name : getFileAssets + * @tc.desc : Access to the file name and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_02', 0, async function (done) { + try { + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const fileAssets = await media.getFileAssets(idOP); + const asset = await fileAssets.getFirstObject(); + expect(asset.displayName == displayName).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE getFileAssets 004_02 failed, message = ' + error); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_03 + * @tc.name : getFileAssets + * @tc.desc : Access to the file relativePath and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_03', 0, async function (done) { + try { + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const fileAssets = await media.getFileAssets(idOP); + const asset = await fileAssets.getFirstObject(); + expect(asset.relativePath == path).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE getFileAssets 004_03 failed, message = ' + error); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_07 + * @tc.name : getFileAssets + * @tc.desc : Access to the file dateModified and validation is not undefined + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_07', 0, async function (done) { + try { + const fileAssets = await media.getFileAssets(filesfetchOp); + const dataList = await fileAssets.getAllObject(); + const asset = dataList[0]; + asset.title = `title_${new Date().getTime()}`; + await asset.commitModify(); + const id = asset.id; + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const newAssets = await media.getFileAssets(idOP); + const newdataList = await newAssets.getAllObject(); + const newAsset = newdataList[0]; + + if (asset.dateModified != undefined) { + if (newAsset.dateModified != asset.dateModified) { + console.info('ASSET_PROMISE getFileAssets 004_07 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('ASSET_PROMISE getFileAssets 004_07 failed'); + expect(false).assertTrue(); + done(); + } + } else if (newAsset.dateModified != undefined) { + console.info('ASSET_PROMISE getFileAssets 004_07 passed'); + expect(true).assertTrue(); + done(); + } else { + console.info('ASSET_PROMISE getFileAssets 004_07 failed'); + expect(false).assertTrue(); + done(); + } + } catch (error) { + console.info('ASSET_PROMISE getFileAssets 004_07 failed, message = ' + error); + } + }); + + /** + * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_08 + * @tc.name : createAsset + * @tc.desc : Insert a picture record, the retrieve attributes for images + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MEDIALIBRARY_CREATEASSET_PROMISE_004_08', 0, async function (done) { + try { + const idOP = { selections: fileKeyObj.ID + '= ?', selectionArgs: ['' + id] }; + const fileAssets = await media.getFileAssets(idOP); + const asset = await fileAssets.getFirstObject(); + expect(asset.mediaType == mediaType).assertTrue(); + done(); + } catch (error) { + console.info('ASSET_PROMISE createAsset 004_08 failed, message = ' + error); + } + }); + + // ------------------------------- file type end ----------------------------- +}); diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/filekeyTestPromise.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/filekeyTestPromise.test.js new file mode 100644 index 0000000000000000000000000000000000000000..a6a490e2214f98d9b28376b3ab440b62fa9e1b2d --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/filekeyTestPromise.test.js @@ -0,0 +1,283 @@ +/* + * Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import featureAbility from '@ohos.ability.featureAbility'; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +let fileKeyObj = mediaLibrary.FileKey; + +let fileType = mediaLibrary.MediaType.FILE; +let imageType = mediaLibrary.MediaType.IMAGE; +let videoType = mediaLibrary.MediaType.VIDEO; +let audioType = mediaLibrary.MediaType.AUDIO; + +let imagesfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], +}; + +let videosfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [videoType.toString()], +}; + +let audiosfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [audioType.toString()], +}; +let allsfetchOp = { + selections: '', + selectionArgs: [], +}; + +const context = featureAbility.getContext(); +const media = mediaLibrary.getMediaLibrary(context); + +const filekeys = { + // parent: 'PARENT', + mimeType: 'MIME_TYPE', + size: 'SIZE', + dateAdded: 'DATE_ADDED', + title: 'TITLE', + // duration: 'DURATION', + // width: 'WIDTH', + // height: 'HEIGHT', + // orientation: 'ORIENTATION', + albumId: 'ALBUM_ID', + albumName: 'ALBUM_NAME', + artist: 'ARTIST', + // audioAlbum: 'AUDIOALBUM', + dateModified: 'DATE_MODIFIED', + // dateTaken: 'DATE_TAKEN', +} + +async function getFileAssetsBy(done, type) { + let assetOp = imagesfetchOp + if(type == 'audioAlbum' || type == 'artist' || type == 'duration') { + assetOp = audiosfetchOp + } + const fetchFileResult = await media.getFileAssets(assetOp); + const asset = await fetchFileResult.getFirstObject(); + let Op = { + selections: fileKeyObj[filekeys[type]] + '= ?', + selectionArgs: [asset[type] + ''], + }; + + try { + let fetchFileResult = await media.getFileAssets(Op); + const fetchCount = fetchFileResult.getCount(); + if(type == 'audioAlbum' || type == 'parent') { + expect(fetchCount == 0).assertTrue(); + } else{ + expect(fetchCount > 0).assertTrue(); + } + done(); + } catch (error) { + expect(false).assertTrue(); + done(); + } +} +function printAttr (done, asset, tNum) { + +} +describe('filekeyTestPromise.test.js', async function () { + beforeAll(function () {}); + beforeEach(function () {}); + afterEach(function () {}); + afterAll(function () {}); + + // /** + // * @tc.number : test_fileKey_001 + // * @tc.name : getFileAssets + // * @tc.desc : filekey parentOp + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + + // it('test_fileKey_001', 0, async function (done) { + // getFileAssetsBy(done, 'parent'); + // }); + + /** + * @tc.number : test_fileKey_002 + * @tc.name : getFileAssets + * @tc.desc : filekey mimeTypeOp + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('test_fileKey_002', 0, async function (done) { + getFileAssetsBy(done, 'mimeType'); + }); + + /** + * @tc.number : test_fileKey_003 + * @tc.name : getFileAssets + * @tc.desc : filekey sizeOp + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('test_fileKey_003', 0, async function (done) { + getFileAssetsBy(done, 'size'); + }); + + /** + * @tc.number : test_fileKey_004 + * @tc.name : getFileAssets + * @tc.desc : filekey dateAddedOp + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('test_fileKey_004', 0, async function (done) { + + getFileAssetsBy(done, 'dateAdded'); + }); + + /** + * @tc.number : test_fileKey_005 + * @tc.name : getFileAssets + * @tc.desc : filekey dateModifiedOp + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('test_fileKey_005', 0, async function (done) { + getFileAssetsBy(done, 'dateModified'); + }); + + // /** + // * @tc.number : test_fileKey_006 + // * @tc.name : getFileAssets + // * @tc.desc : filekey dateTakenOp + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('test_fileKey_006', 0, async function (done) { + // getFileAssetsBy(done, 'dateTaken'); + // }); + + /** + * @tc.number : test_fileKey_007 + * @tc.name : getFileAssets + * @tc.desc : filekey titleOp + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('test_fileKey_007', 0, async function (done) { + getFileAssetsBy(done, 'title'); + }); + + // /** + // * @tc.number : test_fileKey_008 + // * @tc.name : getFileAssets + // * @tc.desc : filekey durationOp + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('test_fileKey_008', 0, async function (done) { + // getFileAssetsBy(done, 'duration'); + // }); + + // /** + // * @tc.number : test_fileKey_009 + // * @tc.name : getFileAssets + // * @tc.desc : filekey widthOp + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('test_fileKey_009', 0, async function (done) { + // getFileAssetsBy(done, 'width'); + // }); + + // /** + // * @tc.number : test_fileKey_010 + // * @tc.name : getFileAssets + // * @tc.desc : filekey heightOp + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('test_fileKey_010', 0, async function (done) { + // getFileAssetsBy(done, 'height'); + // }); + + // /** + // * @tc.number : test_fileKey_011 + // * @tc.name : getFileAssets + // * @tc.desc : filekey orientationOp + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('test_fileKey_011', 0, async function (done) { + // getFileAssetsBy(done, 'orientation'); + // }); + + /** + * @tc.number : test_fileKey_012 + * @tc.name : getFileAssets + * @tc.desc : filekey widthOp + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('test_fileKey_012', 0, async function (done) { + getFileAssetsBy(done, 'albumId'); + }); + + /** + * @tc.number : test_fileKey_0013 + * @tc.name : getFileAssets + * @tc.desc : filekey albumNameOp + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('test_fileKey_0013', 0, async function (done) { + getFileAssetsBy(done, 'albumName'); + }); + + /** + * @tc.number : test_fileKey_0014 + * @tc.name : getFileAssets + * @tc.desc : filekey artistOp + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('test_fileKey_0014', 0, async function (done) { + getFileAssetsBy(done, 'artist'); + }); + + // /** + // * @tc.number : test_fileKey_0015 + // * @tc.name : getFileAssets + // * @tc.desc : filekey audioAlbumOp + // * @tc.size : MEDIUM + // * @tc.type : Function + // * @tc.level : Level 0 + // */ + // it('test_fileKey_0015', 0, async function (done) { + // getFileAssetsBy(done, 'audioAlbum'); + // }); +}); diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getAlbumsPerformance.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getAlbumsPerformance.test.js deleted file mode 100644 index baefb1da3c49e6368dc4e9f6e8ad755c403173f8..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getAlbumsPerformance.test.js +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - - -describe('getAlbumsPerformance.test.js', function () { - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - - let times = 25; - - let AlbumNoArgsfetchOp = { - selections: "", - selectionArgs: [""], - } - - beforeAll(function () { - onsole.info('MediaLibraryTest: beforeAll'); - }) - - beforeEach(function () { - console.info('MediaLibraryTest: beforeEach'); - }) - afterEach(function () { - console.info('MediaLibraryTest: afterEach'); - }) - afterAll(function () { - console.info('MediaLibraryTest: afterAll'); - }) - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01 - * @tc.name : - * @tc.desc : - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01 begin'); - it('SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01', 0, async function (done) { - for (let i = 0; i < times; i++) { - const albumArray = await media.getAlbums(AlbumNoArgsfetchOp); - if (albumArray != undefined) { - console.info('MediaLibraryTest : getAlbums : PASS ' + albumArray.length); - expect(true).assertTrue(); - } else { - console.info('MediaLibraryTest : getAlbums : FAIL'); - expect(false).assertTrue(); - } - } - console.info('MediaLibraryTest : for : end'); - done(); - }); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01 end'); -}); \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getAllPeersDeviceTestPromise.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getAllPeersDeviceTestPromise.test.js new file mode 100644 index 0000000000000000000000000000000000000000..af84459b2994b0bf81447e68374173345bbeb59d --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getAllPeersDeviceTestPromise.test.js @@ -0,0 +1,295 @@ +/* + * Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import featureAbility from '@ohos.ability.featureAbility'; + +import { + describe, + beforeAll, + beforeEach, + afterEach, + afterAll, + it, + expect +} from 'deccjsunit/index'; + +describe('file.promise.test.js', function () { + var context = featureAbility.getContext(); + console.info('MediaLibraryTest : getMediaLibrary IN'); + var media = mediaLibrary.getMediaLibrary(context); + console.info('MediaLibraryTest : getMediaLibrary OUT'); + beforeAll(function () {}); + beforeEach(function () {}); + afterEach(function () {}); + afterAll(function () {}); + + + console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_ALL_PEER_DEVICETYPE_PROMISE_001_02 begin'); + it('SUB_MEDIA_MEDIALIBRARY_ALL_PEER_DEVICETYPE_PROMISE_001_02', 0, async function (done) { + done(); + let allPeerList = await media.getAllPeers(); + expect(allPeerList[1].DeviceType.TYPE_UNKNOWN).assertEqual(0); + expect(allPeerList[1].DeviceType.TYPE_LAPTOP).assertEqual(1); + expect(allPeerList[1].DeviceType.TYPE_PHONE).assertEqual(2); + expect(allPeerList[1].DeviceType.TYPE_TABLET).assertEqual(3); + expect(allPeerList[1].DeviceType.TYPE_WATCH).assertEqual(4); + expect(allPeerList[1].DeviceType.TYPE_CAR).assertEqual(5); + expect(allPeerList[1].DeviceType.TYPE_TV).assertEqual(6); + done(); + }); + + // it('SUB_MEDIA_MEDIALIBRARY_ALL_PEER_DEVICETYPE_PROMISE_001_03', 0, async function (done) { + // try { + // let allPeerList = await media.getAllPeers(); + // deviceType = allPeerList[1].deviceType; + // console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_03 peer.deviceType = ' + deviceType); + // if(deviceType == mediaLibrary.DeviceType.TYPE_UNKNOWN + // || deviceType == mediaLibrary.DeviceType.TYPE_LAPTOP + // || deviceType == mediaLibrary.DeviceType.TYPE_PHONE + // || deviceType == mediaLibrary.DeviceType.TYPE_TABLET + // || deviceType == mediaLibrary.DeviceType.TYPE_WATCH + // || deviceType == mediaLibrary.DeviceType.TYPE_CAR + // || deviceType == mediaLibrary.DeviceType.TYPE_TV) { + // expect(true).assertTrue(); + // done(); + // } + // } catch (error) { + // expect(false).assertTrue(); + // done(); + // } + // }); + + + // it('SUB_MEDIA_MEDIALIBRARY_ALL_PEER_DEVICETYPE_PROMISE_001_04', 0, async function (done) { + // try { + // let allPeerList = await media.getAllPeers(); + // deviceType = allPeerList[2].deviceType; + // console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_04 peer.deviceType = ' + deviceType); + // if(deviceType == mediaLibrary.DeviceType.TYPE_UNKNOWN + // || deviceType == mediaLibrary.DeviceType.TYPE_LAPTOP + // || deviceType == mediaLibrary.DeviceType.TYPE_PHONE + // || deviceType == mediaLibrary.DeviceType.TYPE_TABLET + // || deviceType == mediaLibrary.DeviceType.TYPE_WATCH + // || deviceType == mediaLibrary.DeviceType.TYPE_CAR + // || deviceType == mediaLibrary.DeviceType.TYPE_TV) { + // expect(true).assertTrue(); + // done(); + // } + // } catch (error) { + // expect(false).assertTrue(); + // done(); + // } + // }); + + + + // it('SUB_MEDIA_MEDIALIBRARY_ALL_PEER_DEVICETYPE_PROMISE_001_05', 0, async function (done) { + // try { + // let allPeerList = await media.getAllPeers(); + // deviceType = allPeerList[3].deviceType; + // console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_05 peer.deviceType = ' + deviceType); + // if(deviceType == mediaLibrary.DeviceType.TYPE_UNKNOWN + // || deviceType == mediaLibrary.DeviceType.TYPE_LAPTOP + // || deviceType == mediaLibrary.DeviceType.TYPE_PHONE + // || deviceType == mediaLibrary.DeviceType.TYPE_TABLET + // || deviceType == mediaLibrary.DeviceType.TYPE_WATCH + // || deviceType == mediaLibrary.DeviceType.TYPE_CAR + // || deviceType == mediaLibrary.DeviceType.TYPE_TV) { + // expect(true).assertTrue(); + // done(); + // } + // } catch (error) { + // expect(false).assertTrue(); + // done(); + // } + // }); + + // it('SUB_MEDIA_MEDIALIBRARY_ALL_PEER_DEVICETYPE_PROMISE_001_06', 0, async function (done) { + // try { + // let allPeerList = await media.getAllPeers(); + // deviceType = allPeerList[4].deviceType; + // console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_06 peer.deviceType = ' + deviceType); + // if(deviceType == mediaLibrary.DeviceType.TYPE_UNKNOWN + // || deviceType == mediaLibrary.DeviceType.TYPE_LAPTOP + // || deviceType == mediaLibrary.DeviceType.TYPE_PHONE + // || deviceType == mediaLibrary.DeviceType.TYPE_TABLET + // || deviceType == mediaLibrary.DeviceType.TYPE_WATCH + // || deviceType == mediaLibrary.DeviceType.TYPE_CAR + // || deviceType == mediaLibrary.DeviceType.TYPE_TV) { + // expect(true).assertTrue(); + // done(); + // } + // } catch (error) { + // expect(false).assertTrue(); + // done(); + // } + // }); + + + + + // it('SUB_MEDIA_MEDIALIBRARY_ACTIVE_PEER_DEVICETYPE_PROMISE_001_02', 0, async function (done) { + // try { + // let allPeerList = await media.getActivePeers(); + // deviceType = allPeerList[0].deviceType; + // console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_02 peer.deviceType = ' + deviceType); + // if(deviceType == mediaLibrary.DeviceType.TYPE_UNKNOWN + // || deviceType == mediaLibrary.DeviceType.TYPE_LAPTOP + // || deviceType == mediaLibrary.DeviceType.TYPE_PHONE + // || deviceType == mediaLibrary.DeviceType.TYPE_TABLET + // || deviceType == mediaLibrary.DeviceType.TYPE_WATCH + // || deviceType == mediaLibrary.DeviceType.TYPE_CAR + // || deviceType == mediaLibrary.DeviceType.TYPE_TV) { + // expect(true).assertTrue(); + // done(); + // } + // } catch (error) { + // expect(false).assertTrue(); + // done(); + // } + // }); + + it('SUB_MEDIA_MEDIALIBRARY_ACTIVE_PEER_NETWORKID_PROMISE_001_02', 0, async function (done) { + try { + done(); + let allPeerList = await media.getActivePeers(); + networkId = allPeerList[0].networkId; + console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_01 peer.networkId = ' + networkId); + } catch (error) { + done(); + } + }); + + + it('SUB_MEDIA_MEDIALIBRARY_ACTIVE_PEER_NETWORKID_ISONLINE_PROMISE_001_02', 0, async function (done) { + try { + done(); + let allPeerList = await media.getActivePeers(); + isOnline = allPeerList[0].isOnline; + console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_01 peer.isOnline = ' + isOnline); + } catch (error) { + done(); + } + }); + + + // it('SUB_MEDIA_MEDIALIBRARY_ACTIVE_PEER_DEVICETYPE_PROMISE_001_03', 0, async function (done) { + // try { + // done(); + // let allPeerList = await media.getActivePeers(); + // deviceType = allPeerList[1].deviceType; + // console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_03 peer.deviceType = ' + deviceType); + // if(deviceType == mediaLibrary.DeviceType.TYPE_UNKNOWN + // || deviceType == mediaLibrary.DeviceType.TYPE_LAPTOP + // || deviceType == mediaLibrary.DeviceType.TYPE_PHONE + // || deviceType == mediaLibrary.DeviceType.TYPE_TABLET + // || deviceType == mediaLibrary.DeviceType.TYPE_WATCH + // || deviceType == mediaLibrary.DeviceType.TYPE_CAR + // || deviceType == mediaLibrary.DeviceType.TYPE_TV) { + // expect(true).assertTrue(); + // done(); + // } + // } catch (error) { + // expect(false).assertTrue(); + // done(); + // } + // }); + + + // it('SUB_MEDIA_MEDIALIBRARY_ACTIVE_PEER_NETWORKID_PROMISE_001_03', 0, async function (done) { + // try { + // let allPeerList = await media.getActivePeers(); + // networkId = allPeerList[1].networkId; + // console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_03 peer.networkId = ' + networkId); + // if(networkId != undefined && networkId != '') { + // expect(true).assertTrue(); + // done(); + // } + // } catch (error) { + // expect(false).assertTrue(); + // done(); + // } + // }); + + + // it('SUB_MEDIA_MEDIALIBRARY_ACTIVE_PEER_NETWORKID_ISONLINE_PROMISE_001_03', 0, async function (done) { + // try { + // let allPeerList = await media.getActivePeers(); + // isOnline = allPeerList[1].isOnline; + // console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_03 peer.isOnline = ' + isOnline); + // if(isOnline) { + // expect(true).assertTrue(); + // done(); + // } + // } catch (error) { + // expect(false).assertTrue(); + // done(); + // } + // }); + + + // it('SUB_MEDIA_MEDIALIBRARY_ACTIVE_PEER_DEVICETYPE_PROMISE_001_04', 0, async function (done) { + // try { + // let allPeerList = await media.getActivePeers(); + // deviceType = allPeerList[2].deviceType; + // console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_04 peer.deviceType = ' + deviceType); + // if(deviceType == mediaLibrary.DeviceType.TYPE_UNKNOWN + // || deviceType == mediaLibrary.DeviceType.TYPE_LAPTOP + // || deviceType == mediaLibrary.DeviceType.TYPE_PHONE + // || deviceType == mediaLibrary.DeviceType.TYPE_TABLET + // || deviceType == mediaLibrary.DeviceType.TYPE_WATCH + // || deviceType == mediaLibrary.DeviceType.TYPE_CAR + // || deviceType == mediaLibrary.DeviceType.TYPE_TV) { + // expect(true).assertTrue(); + // done(); + // } + // } catch (error) { + // expect(false).assertTrue(); + // done(); + // } + // }); + + // it('SUB_MEDIA_MEDIALIBRARY_ACTIVE_PEER_NETWORKID_PROMISE_001_04', 0, async function (done) { + // try { + // let allPeerList = await media.getActivePeers(); + // networkId = allPeerList[2].networkId; + // console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_04 peer.networkId = ' + networkId); + // if(networkId != undefined && networkId != '') { + // expect(true).assertTrue(); + // done(); + // } + // } catch (error) { + // expect(false).assertTrue(); + // done(); + // } + // }); + + + // it('SUB_MEDIA_MEDIALIBRARY_ACTIVE_PEER_NETWORKID_ISONLINE_PROMISE_001_04', 0, async function (done) { + // try { + // let allPeerList = await media.getActivePeers(); + // isOnline = allPeerList[2].isOnline; + // console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_04 peer.isOnline = ' + isOnline); + // if(isOnline) { + // expect(true).assertTrue(); + // done(); + // } + // } catch (error) { + // expect(false).assertTrue(); + // done(); + // } + // }); +}); \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getAllPeersTestPromise.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getAllPeersTestPromise.test.js new file mode 100644 index 0000000000000000000000000000000000000000..a697d7e4d06468a351197e82b6ccfede4fc75f8d --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getAllPeersTestPromise.test.js @@ -0,0 +1,164 @@ +/* + * Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import featureAbility from '@ohos.ability.featureAbility'; + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; + +describe('file.promise.test.js', function () { + var context = featureAbility.getContext(); + console.info('MediaLibraryTest : getMediaLibrary IN'); + var media = mediaLibrary.getMediaLibrary(context); + console.info('MediaLibraryTest : getMediaLibrary OUT'); + beforeAll(function () {}); + beforeEach(function () {}); + afterEach(function () {}); + afterAll(function () {}); + + + + it('SUB_MEDIA_MEDIALIBRARY_ALL_PEER_PROMISE_001_01', 0, async function (done) { + try { + done(); + let allPeerList = await media.getAllPeers(); + console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_01 peer.deviceName = ' + peer.deviceName); + done(); + } catch (error) { + console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_01 fail, message = ' + error); + done(); + } + }); + + + it('SUB_MEDIA_MEDIALIBRARY_ALL_PEER_PROMISE_001_02', 0, async function (done) { + try { + done(); + let allPeerList = await media.getAllPeers(); + peer = allPeerList[0]; + console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_02 peer.deviceName = ' + peer.deviceName); + done(); + } catch (error) { + console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_02 fail, message = ' + error); + done(); + } + }); + + it('SUB_MEDIA_MEDIALIBRARY_ALL_PEER_PROMISE_001_03', 0, async function (done) { + try { + done(); + let allPeerList = await media.getAllPeers(); + peer = allPeerList[1]; + console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_03 peer.deviceName = ' + peer.deviceName); + done(); + } catch (error) { + console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_03 fail, message = ' + error); + done(); + } + }); + + it('SUB_MEDIA_MEDIALIBRARY_ALL_PEER_PROMISE_001_04', 0, async function (done) { + try { + done(); + let allPeerList = await media.getAllPeers(); + peer = allPeerList[2]; + console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_04 peer.deviceName = ' + peer.deviceName); + done(); + } catch (error) { + console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_04 fail, message = ' + error); + done(); + } + }); + + + it('SUB_MEDIA_MEDIALIBRARY_ALL_PEER_PROMISE_001_05', 0, async function (done) { + try { + done(); + let allPeerList = await media.getAllPeers(); + peer = allPeerList[3]; + console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_05 peer.deviceName = ' + peer.deviceName); + done(); + } catch (error) { + console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_05 fail, message = ' + error); + done(); + } + }); + + it('SUB_MEDIA_MEDIALIBRARY_ALL_PEER_PROMISE_001_06', 0, async function (done) { + try { + done(); + let allPeerList = await media.getAllPeers(); + peer = allPeerList[4]; + console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_06 peer.deviceName = ' + peer.deviceName); + done(); + } catch (error) { + console.info('MediaLibraryTest : ALL_PEER_PROMISE getAllPeers 001_06 fail, message = ' + error); + done(); + } + }); + + + it('SUB_MEDIA_MEDIALIBRARY_ACTIVE_PEER_PROMISE_001_01', 0, async function (done) { + try { + done(); + let activePeerList = await media.getActivePeers(); + activePeer = activePeerList[0]; + console.info('MediaLibraryTest : ACTIVE_PEER_PROMISE getActivePeers 001_01 activePeer.deviceName = ' + activePeer.deviceName); + } catch (error) { + console.info('MediaLibraryTest : ACTIVE_PEER_PROMISE getActivePeers 001_01 fail, message = ' + error); + done(); + } + }); + + it('SUB_MEDIA_MEDIALIBRARY_ACTIVE_PEER_PROMISE_001_02', 0, async function (done) { + try { + done(); + let activePeerList = await media.getActivePeers(); + activePeer = activePeerList[0]; + console.info('MediaLibraryTest : ACTIVE_PEER_PROMISE getActivePeers 001_02 activePeer.deviceName = ' + activePeer.deviceName); + done(); + } catch (error) { + console.info('MediaLibraryTest : ACTIVE_PEER_PROMISE getActivePeers 001_02 fail, message = ' + error); + done(); + } + }); + + it('SUB_MEDIA_MEDIALIBRARY_ACTIVE_PEER_PROMISE_001_03', 0, async function (done) { + try { + done(); + let activePeerList = await media.getActivePeers(); + activePeer = activePeerList[1]; + console.info('MediaLibraryTest : ACTIVE_PEER_PROMISE getActivePeers 001_03 activePeer.deviceName = ' + activePeer.deviceName); + done(); + } catch (error) { + console.info('MediaLibraryTest : ACTIVE_PEER_PROMISE getActivePeers 001_03 fail, message = ' + error); + done(); + } + }); + + + it('SUB_MEDIA_MEDIALIBRARY_ACTIVE_PEER_PROMISE_001_04', 0, async function (done) { + try { + done(); + let activePeerList = await media.getActivePeers(); + activePeer = activePeerList[2]; + console.info('MediaLibraryTest : ACTIVE_PEER_PROMISE getActivePeers 001_04 activePeer.deviceName = ' + activePeer.deviceName); + done(); + } catch (error) { + console.info('MediaLibraryTest : ACTIVE_PEER_PROMISE getActivePeers 001_04 fail, message = ' + error); + done(); + } + }); +}); \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getFileAssetsPerformance.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getFileAssetsPerformance.test.js deleted file mode 100644 index 1a87a92686976630b504564fd9892f8679a11ebb..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getFileAssetsPerformance.test.js +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - - -describe('getFileAssetsPerformance.test.js', function () { - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - - let times = 25; - let queryResultSet_; - let fileList_; - let fileKeyObj = mediaLibrary.FileKey - let type = mediaLibrary.MediaType.IMAGE - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + " = ? ", - selectionArgs: [type.toString()], - order: fileKeyObj.DATE_ADDED, - } - beforeAll(function () { - onsole.info('MediaLibraryTest: beforeAll'); - }) - - beforeEach(function () { - console.info('MediaLibraryTest: beforeEach'); - }) - afterEach(function () { - console.info('MediaLibraryTest: afterEach'); - }) - afterAll(function () { - console.info('MediaLibraryTest: afterAll'); - }) - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_PERFORMANCE_01 - * @tc.name : Create an image file asset in predefined path - * @tc.desc : Create an image file asset in predefined path - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_PERFORMANCE_01 begin'); - it('SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_PERFORMANCE_01', 0, async function (done) { - for (let i = 0; i < times; i++) { - const queryResultSet = await media.getFileAssets(fetchOp); - if (queryResultSet != undefined) { - console.info('MediaLibraryTest : getFileAssets : PASS ' + queryResultSet.getCount()); - expect(true).assertTrue(); - } else { - console.info('MediaLibraryTest : getFileAssets : FAIL'); - expect(false).assertTrue(); - } - } - console.info('MediaLibraryTest : for : end'); - done(); - }); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_PERFORMANCE_01 end'); -}); \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getFileAssetsPerformance_object.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getFileAssetsPerformance_object.test.js deleted file mode 100644 index 5df5e6bd9ac37d7a661dd7ade596adcd15e579d0..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getFileAssetsPerformance_object.test.js +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - - -describe('getFileAssetsPerformance_object.test.js', function () { - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - - let times = 100; - let queryResultSet_; - let fileList_; - let fileKeyObj = mediaLibrary.FileKey - let type = mediaLibrary.MediaType.IMAGE - let fetchOp = { - selections: fileKeyObj.MEDIA_TYPE + " = ? ", - selectionArgs: [type.toString()], - order: fileKeyObj.DATE_ADDED, - } - beforeAll(function () { - onsole.info('MediaLibraryTest: beforeAll'); - }) - - beforeEach(function () { - console.info('MediaLibraryTest: beforeEach'); - }) - afterEach(function () { - console.info('MediaLibraryTest: afterEach'); - }) - afterAll(function () { - console.info('MediaLibraryTest: afterAll'); - }) - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_ALL_OBJECT_PERFORMANCE_01 - * @tc.name : - * @tc.desc : - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALL_OBJECT_PERFORMANCE_01 begin'); - it('SUB_MEDIA_MEDIALIBRARY_GET_ALL_OBJECT_PERFORMANCE_01', 0, async function (done) { - console.info('MediaLibraryTest : getFileAssets begin'); - const queryResultSet = await media.getFileAssets(fetchOp); - queryResultSet_ = queryResultSet; - console.info('MediaLibraryTest : getFileAssets after'); - if (queryResultSet_ == undefined) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALL_OBJECT_PERFORMANCE_01 : FAIL'); - expect(false).assertTrue(); - done(); - } else { - for (let i = 0; i < 3; i++) { - console.info('MediaLibraryTest : getAllObject begin :times: ' + i); - const data1 = await queryResultSet_.getAllObject(); - if (data1 != undefined) { - console.info('MediaLibraryTest : getAllObject :PASS times: ' + i); - expect(true).assertTrue(); - } else { - console.info('MediaLibraryTest : getAllObject :FAIL times: ' + i); - expect(false).assertTrue(); - } - - console.info('MediaLibraryTest : getAllObject after :times: ' + i); - } - } - - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALL_OBJECT_PERFORMANCE_01 end'); - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FIRST_OBJECT_PERFORMANCE_01 - * @tc.name : - * @tc.desc : - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FIRST_OBJECT_PERFORMANCE_01 begin'); - it('SUB_MEDIA_MEDIALIBRARY_GET_FIRST_OBJECT_PERFORMANCE_01', 0, async function (done) { - if (queryResultSet_ == undefined) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FIRST_OBJECT_PERFORMANCE_01 : FAIL'); - expect(false).assertTrue(); - done(); - } else { - for (let i = 0; i < times; i++) { - console.info('MediaLibraryTest : getFirstObject begin :times: ' + i); - const fileAsset = await queryResultSet_.getFirstObject(); - if (fileAsset != undefined) { - console.info('MediaLibraryTest : getFirstObject :PASS times: ' + i); - expect(true).assertTrue(); - } else { - console.info('MediaLibraryTest : getFirstObject :FAIL times: ' + i); - expect(false).assertTrue(); - } - - console.info('MediaLibraryTest : getFirstObject after :times: ' + i); - } - } - - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_FIRST_OBJECT_PERFORMANCE_01 end'); - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_IS_AFTER_LAST_PERFORMANCE_01 - * @tc.name : - * @tc.desc : - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_IS_AFTER_LAST_PERFORMANCE_01 begin'); - it('SUB_MEDIA_MEDIALIBRARY_IS_AFTER_LAST_PERFORMANCE_01', 0, async function (done) { - if (queryResultSet_ == undefined) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_IS_AFTER_LAST_PERFORMANCE_01 : FAIL'); - expect(false).assertTrue(); - done(); - } else { - for (let i = 0; i < times; i++) { - console.info('MediaLibraryTest : isAfterLast begin :times: ' + i); - const isAfterLastBool = queryResultSet_.isAfterLast(); - expect(!isAfterLastBool).assertTrue(); - - console.info('MediaLibraryTest : isAfterLast after :times: ' + i); - } - } - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_IS_AFTER_LAST_PERFORMANCE_01 end'); - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_LAST_OBJECT_PERFORMANCE_01 - * @tc.name : - * @tc.desc : - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_LAST_OBJECT_PERFORMANCE_01 begin'); - it('SUB_MEDIA_MEDIALIBRARY_GET_LAST_OBJECT_PERFORMANCE_01', 0, async function (done) { - if (queryResultSet_ == undefined) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_LAST_OBJECT_PERFORMANCE_01 : FAIL'); - expect(false).assertTrue(); - done(); - } else { - for (let i = 0; i < times; i++) { - console.info('MediaLibraryTest : getLastObject begin :times: ' + i); - const fileAsset = await queryResultSet_.getLastObject(); - if (fileAsset != undefined) { - console.info('MediaLibraryTest : getLastObject :PASS times: ' + i); - expect(true).assertTrue(); - } else { - console.info('MediaLibraryTest : getLastObject :FAIL times: ' + i); - expect(false).assertTrue(); - } - - console.info('MediaLibraryTest : getLastObject after :times: ' + i); - } - } - - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_LAST_OBJECT_PERFORMANCE_01 end'); - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_POSITION_OBJECT_PERFORMANCE_01 - * @tc.name : - * @tc.desc : - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_POSITION_OBJECT_PERFORMANCE_01 begin'); - it('SUB_MEDIA_MEDIALIBRARY_GET_POSITION_OBJECT_PERFORMANCE_01', 0, async function (done) { - if (queryResultSet_ == undefined) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_POSITION_OBJECT_PERFORMANCE_01 : FAIL'); - expect(false).assertTrue(); - done(); - } else { - for (let i = 0; i < times; i++) { - console.info('MediaLibraryTest : getPositionObject begin :times: ' + i); - const fileAsset = await queryResultSet_.getPositionObject(i); - if (fileAsset != undefined) { - console.info('MediaLibraryTest : getPositionObject :PASS times: ' + i); - expect(true).assertTrue(); - } else { - console.info('MediaLibraryTest : getPositionObject :FAIL times: ' + i); - expect(false).assertTrue(); - } - - console.info('MediaLibraryTest : getPositionObject after :times: ' + i); - } - } - - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_POSITION_OBJECT_PERFORMANCE_01 end'); - done(); - }); - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_NEXT_OBJECT_PERFORMANCE_01 - * @tc.name : - * @tc.desc : - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_NEXT_OBJECT_PERFORMANCE_01 begin'); - it('SUB_MEDIA_MEDIALIBRARY_GET_NEXT_OBJECT_PERFORMANCE_01', 0, async function (done) { - console.info('MediaLibraryTest : getFileAssets begin'); - const queryResultSet = await media.getFileAssets(fetchOp); - console.info('MediaLibraryTest : getFileAssets after'); - if (queryResultSet == undefined) { - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_NEXT_OBJECT_PERFORMANCE_01 : FAIL'); - expect(false).assertTrue(); - done(); - } else { - for (let i = 0; i < times; i++) { - console.info('MediaLibraryTest : getNextObject begin :times: ' + i); - const fileAsset = await queryResultSet.getNextObject(); - if (fileAsset != undefined) { - console.info('MediaLibraryTest : getNextObject :PASS times: ' + i); - expect(true).assertTrue(); - } else { - console.info('MediaLibraryTest : getNextObject :FAIL isAfterLast: ' + queryResultSet_.isAfterLast()); - console.info('MediaLibraryTest : getNextObject :FAIL times: ' + i); - expect(false).assertTrue(); - } - - console.info('MediaLibraryTest : getNextObject after :times: ' + i); - } - } - - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_NEXT_OBJECT_PERFORMANCE_01 end'); - done(); - }); -}); \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getMediaFileAssetStatus.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getMediaFileAssetStatus.test.js deleted file mode 100644 index 64c98ad2d3c33dafd9ac8909e085e2c91b6fa9c5..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getMediaFileAssetStatus.test.js +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -let fileKeyObj = mediaLibrary.FileKey -let type = mediaLibrary.MediaType.IMAGE -let fetchOp = { - selections : fileKeyObj.MEDIA_TYPE + " = ? ", - selectionArgs : [type.toString()], - order : fileKeyObj.DATE_ADDED, -} - -describe('getMediaFileAssetStatus', function () { - console.info("MediaLibraryTest Instance before"); - const media = mediaLibrary.getMediaLibrary(); - console.info("MediaLibraryTest Instance after"); - - /* - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_01 - * @tc.name : judge file asset trash or not - * @tc.desc : judge file asset trash or not - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - it('SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_01', 0, async function () { - try { - let mediaType = mediaLibrary.MediaType.IMAGE; - const cur = Date.now() - let displayName = "FILE_ASSETS_TRASH_STATUS_01.jpg" + cur; - let rp = "Pictures/"; - console.info('MediaLibraryTest : createAsset begin'); - media.createAsset(mediaType, displayName, rp, (createAssetErr, fileAsset) => { - if (fileAsset != undefined) { - console.info('MediaLibraryTest : createAsset Successfull file uri = ' + fileAsset.uri); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : PASS'); - fileAsset.isTrash((err, istrash) => { - console.info("MediaLibraryTest SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_01 " +istrash) - expect(istrash == false).assertTrue; - done(); - }) - } else { - console.info('MediaLibraryTest : createAsset Unsuccessfull ' + createAssetErr.message); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : FAIL'); - expect(false).assertTrue(); - done(); - } - }); - } - catch (e) { - console.log('MediaLibraryTest has failed for ' + e); - expect(null).assertFail(); - } - }); - - /* - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_02 - * @tc.name : judge file asset trash or not - * @tc.desc : judge file asset trash or not - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_02', 0, async function () { - try { - let mediaType = mediaLibrary.MediaType.IMAGE; - const cur = Date.now() - let displayName = "FILE_ASSETS_TRASH_STATUS_02.jpg" + cur; - let rp = "Pictures/"; - console.info('MediaLibraryTest : createAsset begin'); - media.createAsset(mediaType, displayName, rp, (createAssetErr, fileAsset) => { - if (fileAsset != undefined) { - console.info('MediaLibraryTest : createAsset Successfull file uri = ' + fileAsset.uri); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : PASS'); - - fileAsset.trash(true, (err) => { - fileAsset.isTrash((err, istrash) => { - console.info("MediaLibraryTest SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_02 " +istrash) - expect(istrash == true).assertTrue; - done(); - }) - }) - } else { - console.info('MediaLibraryTest : createAsset Unsuccessfull ' + createAssetErr.message); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : FAIL'); - expect(false).assertTrue(); - done(); - } - }); - } - catch (e) { - console.log('MediaLibraryTest has failed for ' + e); - expect(null).assertFail(); - } - }); - - /* - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_03 - * @tc.name : judge file asset trash or not - * @tc.desc : judge file asset trash or not - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_03', 0, async function () { - try { - let mediaType = mediaLibrary.MediaType.IMAGE; - const cur = Date.now() - let displayName = "FILE_ASSETS_TRASH_STATUS_03.jpg" + cur; - let rp = "Pictures/"; - console.info('MediaLibraryTest : createAsset begin'); - media.createAsset(mediaType, displayName, rp, (createAssetErr, fileAsset) => { - if (fileAsset != undefined) { - console.info('MediaLibraryTest : createAsset Successfull file uri = ' + fileAsset.uri); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : PASS'); - - fileAsset.trash(false, (err) => { - fileAsset.isTrash((err, istrash) => { - console.info("MediaLibraryTest SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_03 " +istrash) - expect(istrash == false).assertTrue; - done(); - }) - }) - - } else { - console.info('MediaLibraryTest : createAsset Unsuccessfull ' + createAssetErr.message); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : FAIL'); - expect(false).assertTrue(); - done(); - } - }); - } - catch (e) { - console.log('MediaLibraryTest has failed for ' + e); - expect(null).assertFail(); - } - }); - - - /* - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_04 - * @tc.name : judge file asset trash or not - * @tc.desc : judge file asset trash or not - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - it('SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_04', 0, async function () { - try { - let mediaType = mediaLibrary.MediaType.IMAGE; - const cur = Date.now() - let displayName = "FILE_ASSETS_TRASH_STATUS_03.jpg" + cur; - let rp = "Pictures/"; - console.info('MediaLibraryTest : createAsset begin'); - media.createAsset(mediaType, displayName, rp, (createAssetErr, fileAsset) => { - if (fileAsset != undefined) { - console.info('MediaLibraryTest : createAsset Successfull file uri = ' + fileAsset.uri); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : PASS'); - - fileAsset.trash(true, (err) => { - fileAsset.isTrash((err, istrash) => { - console.info("SUB_MEDIA_MEDIALIBRARY_GET_FILE_ASSETS_TRASH_STATUS_04 istrash " +istrash) - expect(istrash == false).assertFalse; - done(); - }) - }) - - } else { - console.info('MediaLibraryTest : createAsset Unsuccessfull ' + createAssetErr.message); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_FILE_01 : FAIL'); - expect(false).assertTrue(); - done(); - } - }); - } - catch (e) { - console.log('MediaLibraryTest has failed for ' + e); - expect(null).assertFail(); - } - }); - - -}); diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getPrivateAlbumsPerformance.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getPrivateAlbumsPerformance.test.js deleted file mode 100644 index 767820f0a01e685793fca83c8ec073f65e069048..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/getPrivateAlbumsPerformance.test.js +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - - -describe('getPrivateAlbumsPerformance.test.js', function () { - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - - let times = 50; - - beforeAll(function () { - onsole.info('MediaLibraryTest: beforeAll'); - }) - - beforeEach(function () { - console.info('MediaLibraryTest: beforeEach'); - }) - afterEach(function () { - console.info('MediaLibraryTest: afterEach'); - }) - afterAll(function () { - console.info('MediaLibraryTest: afterAll'); - }) - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01 - * @tc.name : - * @tc.desc : - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01 begin'); - it('SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01', 0, async function (done) { - for (let i = 0; i < times; i++) { - const albums = await media.getPrivateAlbum(mediaLibrary.PrivateAlbumType.TYPE_TRASH); - if (albums != undefined) { - console.info('MediaLibraryTest : getAlbums : PASS ' + albums[0].albumName); - expect(true).assertTrue(); - } else { - console.info('MediaLibraryTest : getAlbums : FAIL'); - expect(false).assertTrue(); - } - } - console.info('MediaLibraryTest : for : end'); - done(); - }); - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_GET_ALBUMS_PERFORMANCE_01 end'); -}); \ No newline at end of file diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/mediaLibraryTestPromise.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/mediaLibraryTestPromise.test.js index 7847858cb312c8aec0329303618e226e725352a5..afc5187ad6b9625695d53c6d0d54b7b652f84165 100644 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/mediaLibraryTestPromise.test.js +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/mediaLibraryTestPromise.test.js @@ -52,9 +52,9 @@ let filesfetchOp = { selectionArgs: [fileType.toString()], }; -let imageAndAudiofetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ', - selectionArgs: [imageType.toString(), audioType.toString()], +let imageAndVideofetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ? or ' + fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString(), videoType.toString()], }; let imageAndVideoAndfilefetchOp = { selections: @@ -96,7 +96,7 @@ async function copyFile(fd1, fd2) { await fileio.write(fd2, buf); } -describe('GET_ALBUM.test.js', function () { +describe('mediaLibraryTestPromise.test.js', function () { const context = featureAbility.getContext(); const media = mediaLibrary.getMediaLibrary(context); @@ -130,8 +130,6 @@ describe('GET_ALBUM.test.js', function () { } }); - - /** * @tc.number : SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_001 * @tc.name : getFileAssets @@ -222,7 +220,7 @@ describe('GET_ALBUM.test.js', function () { */ it('SUB__MEDIA_MIDIALIBRARY_PROMISE_GETFILEASSETS_005', 0, async function (done) { try { - const fetchFileResult = await media.getFileAssets(imageAndAudiofetchOp); + const fetchFileResult = await media.getFileAssets(imageAndVideofetchOp); expect(fetchFileResult != undefined).assertTrue(); done(); } catch (error) { @@ -396,11 +394,11 @@ describe('GET_ALBUM.test.js', function () { */ it('SUB__MEDIA_MIDIALIBRARY_PROMISE_GETPUBLICDIRECTORY_001', 0, async function (done) { try { - let DIR_CAMERA = mediaLibrary.DirectoryType.DIR_CAMERA; + let DIR_CDSA = mediaLibrary.DirectoryType.DIR_CDSA; - const dicResult = await media.getPublicDirectory(DIR_CAMERA); + const dicResult = await media.getPublicDirectory(DIR_CDSA); - expect(dicResult == 'Camera/').assertTrue(); + expect(dicResult == 'CDSA/').assertTrue(); done(); } catch (error) { console.info(`MediaLibraryTest : getPublicDirectory 001 failed, error: ${error}`); @@ -423,7 +421,7 @@ describe('GET_ALBUM.test.js', function () { const dicResult = await media.getPublicDirectory(DIR_VIDEO); console.log(dicResult); - expect(dicResult == 'Videos/').assertTrue(); + expect(dicResult == 'Movies/').assertTrue(); done(); } catch (error) { console.info(`MediaLibraryTest : getPublicDirectory 002 failed, error: ${error}`); @@ -830,5 +828,4 @@ describe('GET_ALBUM.test.js', function () { done(); } }); - }); diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/mediaLibraryTestPromiseOnOff.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/mediaLibraryTestPromiseOnOff.test.js new file mode 100644 index 0000000000000000000000000000000000000000..776264207de269e490a0d5f491b0309358d9a62d --- /dev/null +++ b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/mediaLibraryTestPromiseOnOff.test.js @@ -0,0 +1,550 @@ +/* + * Copyright (C) 2022 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 mediaLibrary from '@ohos.multimedia.medialibrary'; +import featureAbility from '@ohos.ability.featureAbility'; +import fileio from '@ohos.fileio'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; + +describe('mediaLibraryTestPromiseOnOff.test.js', async function () { + const context = featureAbility.getContext(); + const media = mediaLibrary.getMediaLibrary(context); + + let fileKeyObj = mediaLibrary.FileKey; + let imageType = mediaLibrary.MediaType.IMAGE; + let videoType = mediaLibrary.MediaType.VIDEO; + let audioType = mediaLibrary.MediaType.AUDIO; + let fileType = mediaLibrary.MediaType.FILE; + + let imagesfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [imageType.toString()], + }; + let videosfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [videoType.toString()], + }; + let audiosfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [audioType.toString()], + }; + let filesfetchOp = { + selections: fileKeyObj.MEDIA_TYPE + '= ?', + selectionArgs: [fileType.toString()], + }; + + /** + * @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_001 + * @tc.name : ON + * @tc.desc : ON Image ASSET + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_001', 0, async function (done) { + try { + let conut = 0; + media.on('imageChange', () => { + conut++; + }); + const fetchFileResult = await media.getFileAssets(imagesfetchOp); + + const dataList = await fetchFileResult.getAllObject(); + + const asset = dataList[0]; + asset.title = 'changename'; + await asset.commitModify(); + await new Promise((res) => setTimeout(() => res(), 3000)); + + expect(conut > 0).assertTrue(); + media.off('imageChange'); + done(); + } catch (error) { + console.info(`MediaLibraryTest : on 001 failed, error: ${error}`); + expect(false).assertTrue(); + media.off('imageChange'); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_002 + * @tc.name : ON + * @tc.desc : ON Video ASSET + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_002', 0, async function (done) { + try { + let conut = 0; + media.on('videoChange', () => { + conut++; + }); + const fetchFileResult = await media.getFileAssets(videosfetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + asset.title = 'changename'; + await asset.commitModify(); + await new Promise((res) => setTimeout(() => res(), 3000)); + expect(conut == 1).assertTrue(); + media.off('videoChange'); + done(); + } catch (error) { + console.info(`MediaLibraryTest : on 002 failed, error: ${error}`); + expect(false).assertTrue(); + media.off('videoChange'); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_003 + * @tc.name : ON + * @tc.desc : ON Audio ASSET + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_003', 0, async function (done) { + try { + let conut = 0; + media.on('audioChange', () => { + conut++; + }); + const fetchFileResult = await media.getFileAssets(audiosfetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + asset.title = 'changename'; + await asset.commitModify(); + await new Promise((res) => setTimeout(() => res(), 3000)); + expect(conut == 1).assertTrue(); + media.off('audioChange'); + done(); + } catch (error) { + console.info(`MediaLibraryTest : on 003 failed, error: ${error}`); + expect(false).assertTrue(); + media.off('audioChange'); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_004 + * @tc.name : ON + * @tc.desc : ON File ASSET + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_004', 0, async function (done) { + try { + let conut = 0; + media.on('fileChange', () => { + conut++; + }); + const fetchFileResult = await media.getFileAssets(filesfetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + asset.title = 'changename'; + await asset.commitModify(); + await new Promise((res) => setTimeout(() => res(), 3000)); + expect(conut == 1).assertTrue(); + media.off('fileChange'); + done(); + } catch (error) { + console.info(`MediaLibraryTest : on 004 failed, error: ${error}`); + expect(false).assertTrue(); + media.off('fileChange'); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_005 + * @tc.name : ON + * @tc.desc : ON ALBUM ASSET + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_005', 0, async function (done) { + try { + let conut = 0; + media.on('albumChange', () => { + conut++; + }); + const fetchFileResult = await media.getFileAssets(filesfetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + asset.title = 'changename'; + await asset.commitModify(); + await new Promise((res) => setTimeout(() => res(), 3000)); + expect(conut == 0).assertTrue(); + media.off('albumChange'); + done(); + } catch (error) { + console.info(`MediaLibraryTest : on 005 failed, error: ${error}`); + expect(false).assertTrue(); + media.off('albumChange'); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_006 + * @tc.name : ON + * @tc.desc : ON DEVICE ASSET + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_006', 0, async function (done) { + try { + let conut = 0; + expect(true).assertTrue(); + done(); + media.on('deviceChange', () => { + conut++; + }); + const fetchFileResult = await media.getFileAssets(filesfetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + asset.title = 'changename'; + await asset.commitModify(); + await new Promise((res) => setTimeout(() => res(), 3000)); + expect(conut == 0).assertTrue(); + media.off('deviceChange'); + done(); + } catch (error) { + console.info(`MediaLibraryTest : on 006 failed, error: ${error}`); + expect(false).assertTrue(); + media.off('deviceChange'); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_006 + * @tc.name : ON + * @tc.desc : ON REMOTE_FILE ASSET + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MIDIALIBRARY_PROMISE_ON_007', 0, async function (done) { + try { + let conut = 0; + expect(true).assertTrue(); + done(); + media.on('remoteFileChange', () => { + conut++; + }); + const fetchFileResult = await media.getFileAssets(filesfetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + asset.title = 'changename'; + await asset.commitModify(); + await new Promise((res) => setTimeout(() => res(), 3000)); + expect(conut == 0).assertTrue(); + media.off('remoteFileChange'); + done(); + } catch (error) { + console.info(`MediaLibraryTest : on 006 failed, error: ${error}`); + expect(false).assertTrue(); + media.off('remoteFileChange'); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_001 + * @tc.name : off + * @tc.desc : off Image ASSET + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_001', 0, async function (done) { + try { + media.on('imageChange', () => { + console.info('MediaLibraryTest : off 001 failed'); + expect(false).assertTrue(); + media.off('imageChange'); + done(); + }); + + media.off('imageChange'); + const fetchFileResult = await media.getFileAssets(imagesfetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + asset.title = 'changename'; + await asset.commitModify(); + + await new Promise((res) => setTimeout(() => res(), 3000)); + + console.info('MediaLibraryTest : off 001 passed'); + expect(true).assertTrue(); + done(); + } catch (error) { + console.info(`MediaLibraryTest : off 001 failed, error: ${error}`); + expect(false).assertTrue(); + media.off('imageChange'); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_002 + * @tc.name : off + * @tc.desc : off video ASSET + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_002', 0, async function (done) { + try { + media.on('videoChange', () => { + console.info('MediaLibraryTest : off 002 failed'); + expect(false).assertTrue(); + media.off('videoChange'); + done(); + }); + + media.off('videoChange'); + const fetchFileResult = await media.getFileAssets(videosfetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + asset.title = 'changename'; + await asset.commitModify(); + + await new Promise((res) => setTimeout(() => res(), 3000)); + + console.info('MediaLibraryTest : off 002 passed'); + expect(true).assertTrue(); + done(); + } catch (error) { + console.info(`MediaLibraryTest : off 002 failed, error: ${error}`); + expect(false).assertTrue(); + media.off('videoChange'); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_003 + * @tc.name : off + * @tc.desc : off audio ASSET + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_003', 0, async function (done) { + try { + media.on('audioChange', () => { + console.info('MediaLibraryTest : off 003 failed'); + expect(false).assertTrue(); + media.off('audioChange'); + done(); + }); + + media.off('audioChange'); + const fetchFileResult = await media.getFileAssets(audiosfetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + asset.title = 'changename'; + await asset.commitModify(); + + await new Promise((res) => setTimeout(() => res(), 3000)); + + console.info('MediaLibraryTest : off 003 passed'); + expect(true).assertTrue(); + done(); + } catch (error) { + console.info(`MediaLibraryTest : off 003 failed, error: ${error}`); + expect(false).assertTrue(); + media.off('audioChange'); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_004 + * @tc.name : off + * @tc.desc : off file ASSET + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_004', 0, async function (done) { + try { + media.on('fileChange', () => { + console.info('MediaLibraryTest : off 004 failed'); + expect(false).assertTrue(); + media.off('fileChange'); + done(); + }); + + media.off('fileChange'); + const fetchFileResult = await media.getFileAssets(videosfetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + asset.title = 'changename'; + await asset.commitModify(); + + await new Promise((res) => setTimeout(() => res(), 3000)); + + console.info('MediaLibraryTest : off 004 passed'); + expect(true).assertTrue(); + done(); + } catch (error) { + console.info(`MediaLibraryTest : off 004 failed, error: ${error}`); + expect(false).assertTrue(); + media.off('fileChange'); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_005 + * @tc.name : off + * @tc.desc : off album ASSET + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_005', 0, async function (done) { + try { + media.on('albumChange', () => { + console.info('MediaLibraryTest : off 004 failed'); + expect(false).assertTrue(); + media.off('albumChange'); + done(); + }); + + media.off('albumChange'); + const fetchFileResult = await media.getFileAssets(videosfetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + asset.title = 'albumChange'; + await asset.commitModify(); + + await new Promise((res) => setTimeout(() => res(), 3000)); + + console.info('MediaLibraryTest : off 005 passed'); + expect(true).assertTrue(); + done(); + } catch (error) { + console.info(`MediaLibraryTest : off 005 failed, error: ${error}`); + expect(false).assertTrue(); + media.off('fileChange'); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_006 + * @tc.name : off + * @tc.desc : off device ASSET + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_006', 0, async function (done) { + try { + media.on('deviceChange', () => { + console.info('MediaLibraryTest : off 004 failed'); + expect(false).assertTrue(); + media.off('deviceChange'); + done(); + }); + + media.off('deviceChange'); + const fetchFileResult = await media.getFileAssets(videosfetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + asset.title = 'deviceChange'; + await asset.commitModify(); + + await new Promise((res) => setTimeout(() => res(), 3000)); + + console.info('MediaLibraryTest : off 006 passed'); + expect(true).assertTrue(); + done(); + } catch (error) { + console.info(`MediaLibraryTest : off 006 failed, error: ${error}`); + expect(false).assertTrue(); + media.off('fileChange'); + done(); + } + }); + + /** + * @tc.number : SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_007 + * @tc.name : off + * @tc.desc : off remoteFile ASSET + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB_MEDIA_MIDIALIBRARY_PROMISE_OFF_007', 0, async function (done) { + try { + media.on('remoteFileChange', () => { + console.info('MediaLibraryTest : off 004 failed'); + expect(false).assertTrue(); + media.off('remoteFileChange'); + done(); + }); + + media.off('remoteFileChange'); + const fetchFileResult = await media.getFileAssets(videosfetchOp); + const dataList = await fetchFileResult.getAllObject(); + const asset = dataList[0]; + asset.title = 'remoteFileChange'; + await asset.commitModify(); + + await new Promise((res) => setTimeout(() => res(), 3000)); + + console.info('MediaLibraryTest : off 007 passed'); + expect(true).assertTrue(); + done(); + } catch (error) { + console.info(`MediaLibraryTest : off 006 failed, error: ${error}`); + expect(false).assertTrue(); + media.off('fileChange'); + done(); + } + }); + + /** + * @tc.number : SUB__MEDIA_MIDIALIBRARY_PROMISE_RELEASE_001 + * @tc.name : release + * @tc.desc : Release MediaLibrary instance + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 0 + */ + it('SUB__MEDIA_MIDIALIBRARY_PROMISE_RELEASE_001', 0, async function (done) { + try { + await media.release(); + console.info('MediaLibraryTest : release 001 passed'); + expect(true).assertTrue(); + done(); + } catch (error) { + console.info(`MediaLibraryTest : release 001 failed, error: ${error}`); + expect(false).assertTrue(); + done(); + } + }); +}); diff --git a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/smartAlbumOperatePerformance_object.test.js b/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/smartAlbumOperatePerformance_object.test.js deleted file mode 100644 index 0c41b61da97672d065255dc470324349cdb7d626..0000000000000000000000000000000000000000 --- a/multimedia/medialibrary/mediaLibrary_js_standard/src/main/js/test/smartAlbumOperatePerformance_object.test.js +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2021 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 mediaLibrary from '@ohos.multimedia.medialibrary'; -import featureAbility from '@ohos.ability.featureAbility' - -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - - -describe('smartAlbumOperatePerformance_object.test.js', async function () { - var context = featureAbility.getContext(); - console.info('MediaLibraryTest : getMediaLibrary IN'); - var media = mediaLibrary.getMediaLibrary(context); - console.info('MediaLibraryTest : getMediaLibrary OUT'); - - let times = 50; - - beforeAll(function () { - onsole.info('MediaLibraryTest: beforeAll'); - }) - - beforeEach(function () { - console.info('MediaLibraryTest: beforeEach'); - }) - afterEach(function () { - console.info('MediaLibraryTest: afterEach'); - }) - afterAll(function () { - console.info('MediaLibraryTest: afterAll'); - }) - - /** - * @tc.number : SUB_MEDIA_MEDIALIBRARY_CREATE_SMARTALBUM_PERFORMANCE_01 - * @tc.name : - * @tc.desc : - * @tc.size : MEDIUM - * @tc.type : Function - * @tc.level : Level 0 - */ - - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_SMARTALBUM_PERFORMANCE_01 begin'); - it('SUB_MEDIA_MEDIALIBRARY_CREATE_SMARTALBUM_PERFORMANCE_01', 0, async function (done) { - for (let i = 0; i < times; i++) { - console.info('MediaLibraryTest : createSmartAlbum begin :times: ' + i); - const smartAlbum = await media.createSmartAlbum("laoxu886"); - if (smartAlbum != undefined) { - console.info('MediaLibraryTest : createSmartAlbum albumuri ' + smartAlbum.albumUri); - console.info('MediaLibraryTest : createSmartAlbum :PASS times: ' + i); - expect(true).assertTrue(); - } else { - console.info('MediaLibraryTest : createSmartAlbum : FAIL'); - expect(false).assertTrue(); - } - console.info('MediaLibraryTest : createSmartAlbum after :times: ' + i); - } - console.info('MediaLibraryTest : SUB_MEDIA_MEDIALIBRARY_CREATE_SMARTALBUM_PERFORMANCE_01 end'); - done(); - }); -}); \ No newline at end of file diff --git a/storage/storagefilemanagerjstest/Test.json b/storage/storagefilemanagerjstest/Test.json index 134ec259b21353a1dbfe5a7ad4f26485cf283e75..52381044561c97e63d2b16f92edd7855d340c3bf 100644 --- a/storage/storagefilemanagerjstest/Test.json +++ b/storage/storagefilemanagerjstest/Test.json @@ -10,26 +10,26 @@ { "type": "ShellKit", "run-command": [ - "mkdir /storage/media/100/local/files/photo", - "mkdir /storage/media/100/local/files/document", - "mkdir /storage/media/100/local/files/video", - "mkdir /storage/media/100/local/files/audio", - "mkdir /storage/media/100/local/files/photo/weixin", + "mkdir -p /storage/media/100/local/files/photo", + "mkdir -p /storage/media/100/local/files/document", + "mkdir -p /storage/media/100/local/files/video", + "mkdir -p /storage/media/100/local/files/audio", + "mkdir -p /storage/media/100/local/files/photo/weixin", "touch /storage/media/100/local/files/photo/weixin/1.jpg", "touch /storage/media/100/local/files/photo/weixin/2.jpg", "touch /storage/media/100/local/files/photo/weixin/3.jpg", "touch /storage/media/100/local/files/photo/weixin/1.mp3", "touch /storage/media/100/local/files/photo/weixin/1.mp4", - "mkdir /storage/media/100/local/files/photo/taobao", + "mkdir -p /storage/media/100/local/files/photo/taobao", "touch /storage/media/100/local/files/photo/taobao/1.mp4", - "mkdir /storage/media/100/local/files/taobao", + "mkdir -p /storage/media/100/local/files/taobao", "touch /storage/media/100/local/files/taobao/1.jpg", - "mkdir /storage/media/100/local/files/image", + "mkdir -p /storage/media/100/local/files/image", "touch /storage/media/100/local/files/image/1.jpg", "touch /storage/media/100/local/files/image/2.jpg", - "mkdir /storage/media/100/local/files/alarms", + "mkdir -p /storage/media/100/local/files/alarms", "touch /storage/media/100/local/files/alarms/tree.mp3", - "mkdir /storage/media/100/local/files/wps", + "mkdir -p /storage/media/100/local/files/wps", "touch /storage/media/100/local/files/wps/news.pdf", "touch /storage/media/100/local/files/wps/introduce.doc", "killall com.ohos.medialibrary.MediaScannerAbilityA", diff --git a/storage/storagefilemanagerjstest/src/main/js/default/test/filemanager.test.js b/storage/storagefilemanagerjstest/src/main/js/default/test/filemanager.test.js index 7ebf4e1408ea8a95783dc402cd6c0dee3ea40908..e2ad87d59cf496efbb7b362ecb9d1f0c5cbe37ed 100644 --- a/storage/storagefilemanagerjstest/src/main/js/default/test/filemanager.test.js +++ b/storage/storagefilemanagerjstest/src/main/js/default/test/filemanager.test.js @@ -35,6 +35,7 @@ let FILE_ROOT = ""; let AUDIO_ROOT = ""; let IMAGE_ALBUM = ""; let LOG_ = "FMS_XTS_TEXT: "; +let LENGTH = 0; describe("filemanager_test", function () { /** @@ -242,10 +243,16 @@ describe("filemanager_test", function () { it("filemanager_test_list_file_async_002", 0, async function (done) { try { let path = FILE_ROOT; - filemanager.listFile(path, "file", function(error,fileInfos){ - expect(Array.isArray(fileInfos)).assertTrue(); - done(); - }); + let options = { + dev:{ + "name":"local" + }, + offset:0 + }; + let fileInfos = await filemanager.listFile(path, "file",options); + LENGTH = fileInfos.length; + expect(Array.isArray(fileInfos)).assertTrue(); + done(); } catch (error) { console.log("filemanager_test_list_file_async_002 has failed for " + error); expect(null).assertFail(); @@ -302,6 +309,7 @@ describe("filemanager_test", function () { }; filemanager.listFile(path, "file", options, function(error,fileInfos){ expect(Array.isArray(fileInfos)).assertTrue(); + expect(fileInfos.length == LENGTH-2).assertTrue(); done(); }); } catch (error) { diff --git a/telephony/telephonyjstest/BUILD.gn b/telephony/telephonyjstest/BUILD.gn index 97520ef460d2295aaf9703107c00a1745168ae41..a4e956d92b194386db411e736309a3bc96d2b4f2 100644 --- a/telephony/telephonyjstest/BUILD.gn +++ b/telephony/telephonyjstest/BUILD.gn @@ -16,7 +16,14 @@ group("telephonyjstest") { deps = [ "call_manager:call_manager", "cellular_data:cellular_data", + "contact_function:ActsContactFunctionEtsTest", + "contact_function_merge:ActsContactFunctionMergeEtsTest", + "contact_performance:ActsContactPerformanceEtsTest", + "contact_stability:ActsContactStabilityEtsTest", + "netmanager_http:ActsNetManagerHttpEtsTest", + "netmanager_socket:ActsNetManagerSocketEtsTest", "network_search:network_search", + "new_add:ActsNewAddEtsTest", "sim:sim", "sms_mms:sms_mms", ] diff --git a/telephony/telephonyjstest/contact_function/BUILD.gn b/telephony/telephonyjstest/contact_function/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b02f559e300048dd7ea6a8e4335c7684f0e21d6a --- /dev/null +++ b/telephony/telephonyjstest/contact_function/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 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("ActsContactFunctionEtsTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":ace_demo_ets_assets", + ":ace_demo_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsContactFunctionEtsTest" +} +ohos_js_assets("ace_demo_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("ace_demo_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/telephony/telephonyjstest/contact_function/Test.json b/telephony/telephonyjstest/contact_function/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ebe415586abc266ca2513a634c63c3631ab843e1 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "1800000", + "package": "com.ohos.contactfunction", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsContactFunctionEtsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/config.json b/telephony/telephonyjstest/contact_function/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..a3efcbc97582ca06a09b37baccf8a39c27a7b7ff --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/config.json @@ -0,0 +1,93 @@ +{ + "app": { + "bundleName": "com.ohos.contactfunction", + "vendor": "open", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.contactfunction", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/Button", + "pages/Blank", + "pages/DataPanel", + "pages/Divider", + "pages/Text", + "pages/RowSplit", + "pages/Scroll", + "pages/Stack", + "pages/Image", + "pages/Progress", + "pages/Qrcode", + "pages/Rating", + "pages/Span", + "pages/Slider", + "pages/Badge", + "pages/Column", + "pages/ColumnSplit", + "pages/Counter", + "pages/Flex", + "pages/GridContainer" + + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/app.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..261fadca29ff0ea310a8bc105ddd1af65e2dd2f6 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Badge.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Badge.ets new file mode 100644 index 0000000000000000000000000000000000000000..66de6f8e3b9c0360931602dd25d1511878ac63ab --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Badge.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct badge { + @State counts: number = 33 + @State message: string = 'new' + @State active: boolean = false + private content: string = "badge Page"; + + onPageShow() { + console.info('badge page show called'); + } + + onBuildDone() { + console.info('badge page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Scroll() { + Column() { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Badge({ + count: this.counts, + position: BadgePosition.Right, + maxCount: 99, + style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge') + + Text("BadgePosition.RightTop").fontSize(16) + Badge({ + count: this.counts, + position: BadgePosition.RightTop, + maxCount: 99, + style: { color: 0xFFFFFF, fontSize: '16', badgeSize: '20', badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge1') + + Text("BadgePosition.Left").fontSize(16) + Badge({ + count: this.counts, + position: BadgePosition.Left, + maxCount: 99, + style: { color: Color.Pink, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge2') + } + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Blank.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Blank.ets new file mode 100644 index 0000000000000000000000000000000000000000..a50fc719e09ab27c91f9705ac06008e936830f33 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Blank.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct blank_testcase { + @State Color: Color = Color.Pink + @State active: boolean = false + private content: string = "Blank Page" + + onPageShow() { + console.info('Blank page show called'); + } + + onBuildDone() { + console.info('Blank page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Blank(100) + .color(this.Color) + .key('blank') + Text('on/off').fontSize(18).height(60) + } + .key('flex') + .width('100%') + .height('100%') + + + } +} diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Button.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Button.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac2271ea3a13664bbbb6afe4f173abae9e66f867 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Button.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct button_testcase { + @State stateEffect: boolean = true + @State ButtonType: ButtonType = ButtonType.Circle + private content: string = "Button Page"; + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button('1.value', { type: ButtonType.Circle, stateEffect: this.stateEffect }) + .fontSize(12) + .fontWeight(FontWeight.Bold) + .fontColor(0xCCCCCC) + .height(40) + .width(40) + .key('button') + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + .padding(10) + Button() { + Text("2.Capsule") + } + .type(ButtonType.Capsule) + .stateEffect(false) + .backgroundColor('#0D9FFB') + .padding(10) + .key('button1') + + Button() { + Text("3.Normal") + }.type(ButtonType.Normal) + .backgroundColor('#0D9FFB') + .key('button2') + + }.key('flex') + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Column.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Column.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9e5c84e21ccf25419be432d8f95418fac82070a --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Column.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct column { + @State active: boolean = false + private content: string = "Column Page" + + onPageShow() { + console.info('Column page show called'); + } + + onBuildDone() { + console.info('Column page build done called'); + } + + build() { + Column({ space: 5 }) { + Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Center).width('90%').border({ width: 1 }).key('column') + + Text('alignItems(Start)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column({ space: '5' }) { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Start).width('90%').border({ width: 1 }).key('column1') + + Text('alignItems(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.End).width('90%').border({ width: 1 }).key('column2') + }.width('100%').padding({ top: 5 }) + } +} diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb0597310a15be8ab4503a3ae89385e3708fac96 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct columnSplit { + private content: string = "ColumnSplit Page" + + onPageShow() { + console.info('ColumnSplit page show called'); + } + + onBuildDone() { + console.info('ColumnSplit page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Scroll() { + Column() { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Column() { + Text('ColumnSplit').fontSize(9).fontColor(0xCCCCCC).width('90%') + ColumnSplit() { + Text('1').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('2').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('3').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + }.key('columnSplit') + .resizeable(true) + .width('90%').height('60%') + + }.width("100%") + + Column() { + Text('ColumnSplit1').fontSize(9).fontColor(0xCCCCCC).width('90%') + ColumnSplit() { + Text('1').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('2').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('3').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + }.key('columnSplit1') + .resizeable(false) + .width('90%').height('60%') + + }.width("100%") + } + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Counter.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Counter.ets new file mode 100644 index 0000000000000000000000000000000000000000..ecdbfaf10393e7a348fd76098868e6455505b07f --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Counter.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct counter { + @State value: number = 0 + @State active: boolean = false + private content: string = "Counter Page" + + onPageShow() { + console.info('Counter page show called'); + } + + onBuildDone() { + console.info('Counter page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Counter() { + Text(this.value.toString()) + }.margin(100) + .key('counter') + .onInc(() => { + this.value++ + }) + .onDec(() => { + this.value-- + }) + }.width("100%") + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/DataPanel.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/DataPanel.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c624848482b22998b2a1d137796ddaedbcf198c --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/DataPanel.ets @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct dataPanel_testcase { + @State width: string= "200" + @State height: string= "100" + @State active: boolean = false + private content: string = "DataPanel Page" + + onPageShow() { + console.info('Blank page show called'); + } + + onBuildDone() { + console.info('Blank page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + DataPanel({ values: [20, 40, 20], max: 100, type: DataPanelType.Line }) + .width(this.width) + .height(this.height) + .key('DataPanel') + .onClick(() => { + router.back() + }) + .closeEffect(false) + + DataPanel({ values: [20, 40, 20], max: 100, type: DataPanelType.Circle}) + .width(this.width) + .height(this.height) + .key('DataPanel2') + .onClick(() => { + router.back() + }) + .closeEffect(true) + DataPanel({ values: [20, 40, 20], max: 100}) + .width(this.width) + .height(this.height) + .key('DataPanel3') + .onClick(() => { + router.back() + }) + .closeEffect(false) + } + .key('flex') + .width('100%') + .height('100%') + + } +} diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Divider.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Divider.ets new file mode 100644 index 0000000000000000000000000000000000000000..02bf60779418674d1fd58127907fdb3915bd8f8f --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Divider.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct divider_textcase { + @State vertical: boolean = true + @State color: Color = Color.Red + @State strokeWidth: number = 7 + @State lineCap: LineCapStyle = LineCapStyle.Butt + @State active: boolean = false + private content: string = "Divider Page"; + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + Divider() + .lineCap(LineCapStyle.Butt) + .strokeWidth(this.strokeWidth) + .color(this.color) + .vertical(this.vertical) + .height(150) + .key('divider') + .onClick(() => { + router.back() + }) + Divider() + .lineCap(LineCapStyle.Round) + .vertical(false) + .color(Color.Green) + .strokeWidth(10) + .height(150) + .key('divider1') + Divider() + .lineCap(LineCapStyle.Square) + .color(Color.Green) + .vertical(true) + .strokeWidth(10) + .height(150) + .key('divider2') + } + .key('flex') + .width('100%') + .height('100%') + } +} + + diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Flex.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Flex.ets new file mode 100644 index 0000000000000000000000000000000000000000..a0e21251e80008c5be9f29aa52074acc5eb24a78 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Flex.ets @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct flex { + private content: string = "Flex Page" + + onPageShow() { + console.info('Flex page show called'); + } + + onBuildDone() { + console.info('Flex page build done called'); + } + + build() { + Column() { + Column({ space : 2 }) { + Text('direction:Column').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Column, + wrap: FlexWrap.NoWrap, + justifyContent: FlexAlign.Center, + alignItems:ItemAlign.Start, + alignContent: FlexAlign.Start, + }) { + Text('1').width('100%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('100%').height(20).backgroundColor(0xD2B48C) + Text('3').width('100%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex') + .height(70) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('direction:Row').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.Start, + alignItems:ItemAlign.Start, + alignContent: FlexAlign.Center, + }) { + Text('1').width('20%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('20%').height(20).backgroundColor(0xD2B48C) + Text('3').width('20%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex1') + .height(70) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('direction:RowReverse').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.RowReverse, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.End, + alignItems:ItemAlign.End, + alignContent: FlexAlign.End, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex2') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent:SpaceBetween').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceBetween, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('100%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('100%').height(20).backgroundColor(0xD2B48C) + Text('3').width('100%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex3') + .height(100) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent AND alignContent').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceEvenly, + alignContent: FlexAlign.SpaceEvenly, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex4') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent AND alignContent').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceAround, + alignContent: FlexAlign.SpaceAround, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex5') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + }.width('100%').margin({ top: 5 }) + }.width('100%') + } +} diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/GridContainer.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/GridContainer.ets new file mode 100644 index 0000000000000000000000000000000000000000..57358110413406263e70a2a5f650cbfeb22a4387 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/GridContainer.ets @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct gridContainer { + @State sizeType: SizeType = SizeType.XS + @State active: boolean = false + private content: string = "GridContainer Page" + + onPageShow() { + console.info('GridContainer page show called'); + } + + onBuildDone() { + console.info('GridContainer page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Scroll() { + Column({ space: 5 }) { + GridContainer({ columns: 12, sizeType: this.sizeType, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer') + .width('90%') + .alignItems(HorizontalAlign.Start) + + Text('Click Simulate to change the device width').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() { + Button('XS') + .onClick(() => { + this.sizeType = SizeType.XS + }).backgroundColor(0x317aff) + Button('SM') + .onClick(() => { + this.sizeType = SizeType.SM + }).backgroundColor(0x317aff) + Button('MD') + .onClick(() => { + this.sizeType = SizeType.MD + }).backgroundColor(0x317aff) + Button('LG') + .onClick(() => { + this.sizeType = SizeType.LG + }).backgroundColor(0x317aff) + } + + GridContainer({ columns: "auto", sizeType: SizeType.MD, gutter: '10', margin: '20' }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer1') + .width('90%') + .alignItems(HorizontalAlign.Center) + + GridContainer({ columns: 12, sizeType: SizeType.SM, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer2') + .width('90%') + .alignItems(HorizontalAlign.End) + + GridContainer({ columns: 12, sizeType: SizeType.LG, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer3') + .width('90%') + .alignItems(HorizontalAlign.End) + + GridContainer({ columns: 12, sizeType: SizeType.Auto, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer4') + .width('90%') + .alignItems(HorizontalAlign.End) + + }.width('100%').margin({ top: 5 }) + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Image.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Image.ets new file mode 100644 index 0000000000000000000000000000000000000000..5cc583e931f51aa8e4f2bd55decfeeb14a40afb4 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Image.ets @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct image_textcase { + @State Width: number = 0 + @State height: number = 0 + + onPageShow() { + console.info('Image page show called'); + } + + onBuildDone() { + console.info('Image page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Image page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Image("/resources/rawfile/hand.png") + .matchTextDirection(false) + .fitOriginalSize(false) + .fillColor(0xCCCCCC) + .objectFit(ImageFit.Cover) + .objectRepeat(ImageRepeat.NoRepeat) + .interpolation(ImageInterpolation.None) + .renderMode(ImageRenderMode.Original) + .autoResize(false) + .syncLoad(false) + .sourceSize({ width: 200, height: 100 }) + .alt("/resources/rawfile/person.png") + .key('image1') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.Contain) + .objectRepeat(ImageRepeat.X) + .interpolation(ImageInterpolation.High) + .renderMode(ImageRenderMode.Template) + .key('image2') + .height(180) + .width(180) + .onComplete((msg: { + width: number, + height: number + }) => { + this.Width = msg.width + this.height = msg.height + console.info('Width ----' + this.Width) + console.info('height ----' + this.height) + }) + .onError(() => { + console.info('load image fail') + }) + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.Fill) + .objectRepeat(ImageRepeat.Y) + .interpolation(ImageInterpolation.Low) + .key('image3') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.None) + .objectRepeat(ImageRepeat.XY) + .interpolation(ImageInterpolation.Medium) + .key('image4') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.ScaleDown) + .key('image5') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(4) + } + } +} + + diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Navigator.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Navigator.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c50769cf2ab045cbe48b52e294b4105a21e1c3d --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Navigator.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct navigator_testcase { + @State active: boolean = false + @State params: Object = { text: 'news' } + + onPageShow() { + console.info('Navigator page show called'); + } + + onBuildDone() { + console.info('Navigator page build done called'); + } + + build() { + Column() { + Navigator({ target: "pages/index", type: NavigationType.Back }) { + Text('Navigator test in Navigator,back') + }.active(this.active) + .key('navigator') + .params({ + data: 24 + }) + + Navigator({ target: "pages/index", type: NavigationType.Push }) { + Text('Navigator test in Navigator,push') + }.active(this.active) + .key('navigator2') + .params({ + data: 24 + }) + + Navigator({ target: "pages/index", type: NavigationType.Replace }) { + Text('Navigator test in Navigator,replace') + }.active(this.active) + .key('navigator3') + .params({ + data: 24 + }) + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } +} diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Panel.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Panel.ets new file mode 100644 index 0000000000000000000000000000000000000000..32ddabbd1ccbae3805dd462e6f04b28364d6a1e7 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Panel.ets @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct PanelExample { + @State show: boolean = true + + onPageShow() { + console.info('Panel page show called'); + } + + onBuildDone() { + console.info('Panel page build done called'); + } + + build() { + Column() { + Text('2021-09-30 Today Calendar: 1.afternoon......Click for details') + .width('90%') + .height(50) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + .padding({ left: 20 }) + .onClick(() => { + this.show = !this.show + }) + Panel(this.show) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel') + .type(PanelType.Foldable) + .mode(PanelMode.Half) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + Panel(this.show) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel2') + .type(PanelType.Minibar) + .mode(PanelMode.Mini) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + Panel(false) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel3') + .type(PanelType.Temporary) + .mode(PanelMode.Full) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + }.width('100%').height('50%').backgroundColor(0xDCDCDC).padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Progress.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Progress.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8608089fe51e1988fd305fc49db028b6c2efe76 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Progress.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct progress_testcase { + onPageShow() { + console.info('Progress page show called'); + } + + onBuildDone() { + console.info('Progress page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Progress page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Progress({ value: 20, total: 40, style: ProgressStyle.Linear }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress') + + Progress({ value: 20, total: 40, style: ProgressStyle.Eclipse }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress2') + + Progress({ value: 20, total: 40, style: ProgressStyle.Ring }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress3') + + Progress({ value: 20, total: 40, style: ProgressStyle.ScaleRing }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress4') + + Progress({ value: 20, total: 40, style: ProgressStyle.Capsule }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress5') + + } + .width(400) + .height(400) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Qrcode.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Qrcode.ets new file mode 100644 index 0000000000000000000000000000000000000000..5c0dd84eff5a6653ee5fd940662d141025a1bb4e --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Qrcode.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct qrcode_textcase { + @State Color: Color = Color.Pink + + onPageShow() { + console.info('Qrcode page show called'); + } + + onBuildDone() { + console.info('Qrcode page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`Qrcode page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + QRCode('hello world') + .color("#FFFFC0CB") + .backgroundColor(this.Color) + .width("200") + .height("100") + .key('qrcode') + } + } +} + + diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Rating.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Rating.ets new file mode 100644 index 0000000000000000000000000000000000000000..b29e26a392fca6f15a5b7f0eb4156dd3bc767c3f --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Rating.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct rating_testcase { + @State rating: number = 2 + + onPageShow() { + console.info('Rating page show called'); + } + + onBuildDone() { + console.info('Rating page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Rating page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Rating({ rating: 2, indicator: false }) + .stepSize(0.5) + .stars(5) + .starStyle({ + backgroundUri: '/resources/rawfile/star-1-1.png', + foregroundUri: '/resources/rawfile/star-1-3.png', + secondaryUri: '/resources/rawfile/star-1-2.png' + }) + .onChange((value: number) => { + this.rating = value + }) + .key('rating1') + Rating({ rating: 2, indicator: true }) + .stepSize(0.5) + .stars(5) + .starStyle({ + backgroundUri: '/resources/rawfile/star-1-1.png', + foregroundUri: '/resources/rawfile/star-1-3.png', + secondaryUri: '/resources/rawfile/star-1-2.png' + }) + .key('rating2') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/RowSplit.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/RowSplit.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f4f397b13b83e98ac643633309b02858f337eb0 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/RowSplit.ets @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct rowSplit_testcase { + @State resizeable: boolean = false + private content: string = "rowSplit Page"; + + onPageShow() { + console.info('RowSplit page show called'); + } + + onBuildDone() { + console.info('RowSplit page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + RowSplit() { + Column() { + Text('Demo1.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + + Column() { + Text('Demo2.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + } + .height(100) + .key('rowSplit') + .resizeable(this.resizeable) + .onClick(() => { + router.back() + }) + + RowSplit() { + Column() { + Text('Demo3.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + + Column() { + Text('Demo4.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + }.height(100) + .key('rowSplit1') + .resizeable(true) + } + .key('flex') + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Scroll.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Scroll.ets new file mode 100644 index 0000000000000000000000000000000000000000..363089d22580febed16b983d8a4b2877cde52bec --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Scroll.ets @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct scroll_testcase { + @State scrollBarWidth: number = 20 + @State scrollable: ScrollDirection = ScrollDirection.None + @State scrollBarColor: Color = Color.Pink + @State scrollBar: BarState= BarState.On + private value1: Array = [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30] + @State edge: Edge= Edge.Top + private content: string = "Scroll Page"; + scroller: Scroller = new Scroller(); + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Scroll(this.scroller) { + Column() { + ForEach( + this.value1, + item => { + Text(`${item}`) + .fontSize(15) + .width(400) + .margin(10) + .height(70) + .backgroundColor(0xfff5deb3) + }, + item => item + ) + } + } + .scrollable(ScrollDirection.Vertical) + .scrollBar(this.scrollBar) + .scrollBarColor(this.scrollBarColor) + .scrollBarWidth(this.scrollBarWidth) + .key('scroll') + .width(400) + .height(200) + .onScroll((xOffset: number, yOffset: number) => { + console.info(` current offset is ${xOffset} ${yOffset}`) + }) + .onScrollEnd(() => { + console.info(` now on scroll end`) + }) + .onScrollEdge((side: Edge) => { + console.info(`To the edge`) + }) + Scroll() { + Row() { + Text('scroll uppppp') + .width(60) + .height(100) + .backgroundColor(Color.Yellow) + .margin({ + right: 5, + left: 5 + }) + .key('text') + + Text('scroll to') + .width(60) + .height(100) + .backgroundColor(Color.Green) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollTo({ + xOffset: 100, + yOffset: 100, + }) + }) + Text('scroll page') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollPage({ + next: true + }) + }) + Text('scroll Edge') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollEdge(Edge.Top) + }) + Text('scroll Edge') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.currentOffset() + }) + Text('scroll to index') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollToIndex(0) + console.info(` now on scroll end`) + }) + } + } + .key('scroll1') + .height(100) + .scrollable(ScrollDirection.Horizontal) + + Scroll() { + Column() { + Text("start").fontSize(30) + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + } + } + .padding(10) + .scrollable(ScrollDirection.None) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Red) + .scrollBarWidth(5) + .width(300) + .height(200) + .key('scroll2') + + Scroll() { + Column() { + Text("start").fontSize(30) + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + } + } + .padding(10) + .scrollable(ScrollDirection.Free) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Red) + .scrollBarWidth(5) + .width(300) + .height(200) + .key('scroll3') + } + .key('flex') + + } +} diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Slider.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Slider.ets new file mode 100644 index 0000000000000000000000000000000000000000..625cd02874f16e9debb7638322624f890e08fa62 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Slider.ets @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct slider { + @State inSetValue: number= 40 + @State outSetValue: number= 40 + @State direction: Axis= Axis.Horizontal + @State Begin: number = SliderChangeMode.Begin + + onPageShow() { + console.info('Slider page show called'); + } + + onBuildDone() { + console.info('Slider page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Slider page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Slider({ + value: this.outSetValue, + min: 0, + max: 100, + step: 1, + direction: Axis.Horizontal, + reverse: false, + style: SliderStyle.OutSet + }) + .blockColor('#FFFF0000') + .selectedColor('#FF0000FF') + .trackColor('#FF808080') + .minLabel('10') + .maxLabel('10') + .showTips(false) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + this.outSetValue = value + this.Begin = mode + console.info('value: ' + value + '---mode: ' + mode) + }) + .width("100") + .height("100") + .key('slider1') + Slider({ + value: 40, + min: 0, + max: 100, + step: 1, + style: SliderStyle.InSet + }) + .blockColor(Color.Red) + .selectedColor(Color.Blue) + .trackColor(Color.Gray) + .showTips(true) + .showSteps(true) + .key('slider2') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Span.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Span.ets new file mode 100644 index 0000000000000000000000000000000000000000..df5a71043f1ae000b822646f6b56df7ae103fa1f --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Span.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct span_textcase { + + onPageShow() { + console.info('Span page show called'); + } + + onBuildDone() { + console.info('Span page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text() { + Span('Test Span demo') + .decoration({ type: TextDecorationType.LineThrough, "color": Color.Red }) + .textCase(TextCase.UpperCase) + .fontColor(Color.Blue) + .fontSize("20fp") + .letterSpacing(5) + .fontFamily("sans-serif") + .fontWeight(FontWeight.Bold) + .fontStyle(FontStyle.Italic) + .key('span1') + Span('The second test Span demo') + .textCase(TextCase.LowerCase) + .fontColor(Color.Black) + .letterSpacing('5') + .fontSize(30) + .key('span2') + Span('The third test Span demo') + .textCase(TextCase.Normal) + .fontColor(Color.Yellow) + .fontSize("30fp") + .key('span3') + } + } + .width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(4) + } + } +} + + + diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Stack.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Stack.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a694889f0e768afbd3e3af6a17c3af9d8738cfb --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Stack.ets @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct stack_testcase { + @State alignContent: Alignment = Alignment.Bottom + private content: string = "Stack Page"; + + onPageShow() { + console.info('Stack page show called'); + } + + onBuildDone() { + console.info('Stack page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Stack({ alignContent: this.alignContent }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + } + .width('100%') + .height(80) + .margin({ top: 5 }) + .key('stack') + .onClick(() => { + router.back() + }) + + Stack({ alignContent: Alignment.BottomStart }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack1') + + Stack({ alignContent: Alignment.BottomEnd }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack2') + + Stack({ alignContent: Alignment.Start }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack3') + + Stack({ alignContent: Alignment.Center }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack4') + + Stack({ alignContent: Alignment.End }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack5') + + Stack({ alignContent: Alignment.Top }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack6') + + Stack({ alignContent: Alignment.TopStart }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack7') + + Stack({ alignContent: Alignment.TopEnd }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack8') + } + .key('flex') + .width('100%') + .height('100%') + + } +} + diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Text.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Text.ets new file mode 100644 index 0000000000000000000000000000000000000000..fbd1415dc815b0f1966476c430f7d69e28e587ee --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/Text.ets @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2021 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. + */ + +// @ts-nocheck +import router from '@system.router' + +var paramInfo = router.getParams() +console.info("cd paramInfo" + JSON.stringify(paramInfo)) + +@Entry +@Component +struct text_textcase { + @State textAlign: TextAlign= TextAlign.End + @State lineHeight: string= '15fp' + @State overflow: TextOverflow = TextOverflow.Ellipsis + @State textOverflow: textOverflow<{ "overflow": TextOverflow }> = { "overflow": this.overflow } + @State maxLines: number = 2 + @State baselineOffset: number = 0 + @State textCase: TextCase= TextCase.Normal + @State decoration: decoration<{ + type: TextDecorationType, + color: Color + }> = { type: TextDecorationType.Underline, color: Color.Red } + @State color: Color = Color.Red + @State width: string= "200" + @State height: string= "100" + @State size: size = { width: 200, height: 100 } + @State marginBottom: string = "10px" + @State marginTop: string = "10px" + @State marginLeft: string = "10px" + @State marginRingt: string= "10px" + @State paddingBottom: string= "5" + @State paddingTop: string= "5" + @State paddingLeft: string= "5" + @State paddingRingt: string= "5" + @State constraintSize: constraintSize = { minWidth: 20, maxWidth: 200, minHeight: 0, maxHeight: 50 } + @State layoutPriority: string= "9px" + @State layoutWeight: string = "10px" + @State align: Alignment = Alignment.Center + @State direction: Direction = Direction.Auto + @State position: position<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State markAnchor: markAnchor<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State offset: offset<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State flexGrow: number = 5 + @State flexShrink: number = 2 + @State flexBasis: number = 0 + @State alignSelf: ItemAlign = ItemAlign.Auto + @State borderStyle: BorderStyle = BorderStyle.Dashed + @State borderRadius: number = 10 + @State borderWidth: string= "4px" + @State borderColor: Color= Color.Blue + @State backgroundColor: Color = Color.Pink + @State backgroundImageSize: ImageSize = ImageSize.Cover + @State backgroundImagePosition: Alignment= Alignment.Center + @State opacity: number= 1 + @State visibility: Visibility= Visibility.Visible + @State enabled: boolean = false + @State zIndex: number = 1 + @State fontStyle: FontStyle = FontStyle.Italic + @State fontSize: number = 15 + @State minFontSize: number = 15 + @State maxFontSize: number = 15 + @State letterSpacing: number= 10 + @State fontWeight: FontWeight= FontWeight.Bold + @State fontColor: Color= Color.Black + @State active: boolean = false + private content: string = "Text Page"; + + onPageShow() { + console.info('Text page show called'); + } + + onBuildDone() { + console.info('Text page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .width(this.width) + .height(this.height) + .padding({ bottom: this.paddingBottom, top: this.paddingTop, right: this.paddingRingt, left: this.paddingLeft }) + .margin({ bottom: this.marginBottom, top: this.marginTop, right: this.marginRingt, left: this.marginLeft }) + .constraintSize(this.constraintSize) + .layoutWeight(this.layoutWeight) + .align(this.align) + .direction(this.direction) + .position(this.position) + .markAnchor(this.markAnchor) + .offset(this.offset) + .flexBasis(this.flexBasis) + .flexGrow(this.flexGrow) + .flexShrink(this.flexShrink) + .alignSelf(this.alignSelf) + .borderStyle(this.borderStyle) + .borderRadius(this.borderRadius) + .borderWidth(this.borderWidth) + .borderColor(this.borderColor) + .backgroundColor(this.backgroundColor) + .opacity(this.opacity) + .visibility(this.visibility) + .enabled(this.enabled) + .zIndex(this.zIndex) + .fontColor(this.fontColor) + .fontSize(this.fontSize) + .minFontSize(this.minFontSize) + .letterSpacing(this.letterSpacing) + .maxFontSize(this.maxFontSize) + .fontWeight(this.fontWeight) + .fontStyle(this.fontStyle) + .fontFamily("sans-serif") + .textAlign(this.textAlign) + .textOverflow(this.textOverflow) + .lineHeight(this.lineHeight) + .baselineOffset(this.baselineOffset) + .maxLines(2) + .textCase(this.textCase) + .decoration(this.decoration) + .aspectRatio(1) + .fontColor(Color.Black) + .key('Text') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .size({ width: 100, height: 50 }) + .padding({ bottom: 5, top: 5, right: 5, left: 10 }) + .margin({ bottom: 15, top: 10, right: 10, left: 10 }) + .fontSize('13') + .textAlign(TextAlign.Start) + .align(Alignment.Start) + .direction(Direction.Ltr) + .alignSelf(ItemAlign.Start) + .borderStyle(BorderStyle.Dotted) + .borderWidth(2) + .visibility(Visibility.Hidden) + .enabled(true) + .fontWeight(FontWeight.Normal) + .textAlign(TextAlign.Start) + .textOverflow(TextOverflow.Clip) + .maxLines(2) + .textCase(TextCase.LowerCase) + .decoration({ "type": TextDecorationType.LineThrough, "color": Color.Red }) + .fontColor(Color.White) + .key('Text1') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .width('100%') + .textAlign(TextAlign.Center) + .align(Alignment.TopEnd) + .direction(Direction.Rtl) + .alignSelf(ItemAlign.Center) + .borderStyle(BorderStyle.Solid) + .borderWidth(2) + .visibility(Visibility.None) + .fontWeight(FontWeight.Bolder) + .textAlign(TextAlign.Center) + .textOverflow(TextOverflow.None) + .textCase(TextCase.UpperCase) + .decoration({ "type": TextDecorationType.None, "color": Color.Red }) + .fontColor(Color.Blue) + .key('Text2') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.Top) + .alignSelf(ItemAlign.End) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Lighter) + .decoration({ type: TextDecorationType.Overline, color: Color.Red }) + .fontColor(Color.Gray) + .key('Text3') + Text('Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.TopStart) + .alignSelf(ItemAlign.Baseline) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Medium) + .fontColor(Color.Brown) + .key('Text4') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.End) + .alignSelf(ItemAlign.Stretch) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Regular) + .fontColor(Color.Grey) + .key('Text5') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.BottomEnd) + .width('100%') + .fontColor(Color.Orange) + .key('Text6') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.Bottom) + .width('100%') + .fontColor(Color.Yellow) + .key('Text7') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.BottomStart) + .width('100%') + .key('Text8') + + } + .key('flex') + .width('100%') + .height('100%') + } +} + + diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/index.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..10359134da915c9b44b0836ba4881bca71f43f33 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,65 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 file from '@system.file'; + +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; +import testsuite from "../test/List.test.ets"; +import featureAbility from "@ohos.ability.featureAbility"; + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + Want.parameters['timeout'] = 100000 + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('ACE ETS TEST') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/List.test.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0da9c54105c1cdd0a4120940982c7f065f00f911 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2021 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. + */ + +//contact import +import CalllogTest from './contact/Calllog_test.js' +import ContactCardTest from './contact/ContactCard_test.js' +import ContactsTest from './contact/Contacts_test.js' +import GroupsTest from './contact/Groups_test.js' +import ObjectInterfaceTest from './contact/ObjectInterface_test.js' +import RecoveryTest from './contact/recovery_test.js' +import VoicemailTest from './contact/Voicemail_test.js' +import ContactClassTest from './contact/ContactClass_test.js' +import ContacterTest from './contact/ContacterJsunit.ets' + +export default function testsuite() { + //contact + ContactClassTest(); + ContacterTest(); + CalllogTest(); + ContactCardTest(); + ContactsTest(); + GroupsTest(); + ObjectInterfaceTest(); + RecoveryTest(); + VoicemailTest(); +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/Utils.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..65f70088ddb62bcf80f4e0ec07dc841a8ab033f0 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,119 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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. + */ + +export default class Utils { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + static notCheck = true; + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } + + static async swipe(downX, downY, upX, upY, steps) { + console.info('start to swipe') + this.drags(downX, downY, upX, upY, steps, false) + } + + static async drag(downX, downY, upX, upY, steps) { + console.info('start to drag') + this.drags(downX, downY, upX, upY, steps, true) + } + + static async drags(downX, downY, upX, upY, steps, drag) { + var xStep; + var yStep; + var swipeSteps; + var ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + var downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('start to move') + if (drag) { + await this.sleep(500) + } + for (var i = 1;i <= swipeSteps; i++) { + var movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('start to up') + if (drag) { + await this.sleep(100) + } + var upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) + } +} + + + + diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/Calllog_test.js b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/Calllog_test.js new file mode 100644 index 0000000000000000000000000000000000000000..b1c43b9559b4d30b7d86dbc1b552607e38347efe --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/Calllog_test.js @@ -0,0 +1,1361 @@ +/* + * Copyright (c) 2021 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 featureAbility from '@ohos.ability.featureAbility'; +import ohosDataAbility from '@ohos.data.dataability'; +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'deccjsunit/index' + +const URI_CALLLOG = "dataability:///com.ohos.calllogability"; +const calllogUri = "dataability:///com.ohos.calllogability/calls/calllog"; +import common from './common.js'; + +export default function CalllogTest() { + describe('CalllogTest', function () { + console.log("----------CalllogTest is starting!----------"); + + async function calllogQueryForALL(map, tag) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info(tag + ': calllogQueryByInsert start ! DAHelper = ' + DAHelper); + var resultColumns = common.getCallLogResultColumns(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", map.get("id")); + try { + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + if (resultSet.rowCount > 0 && resultSet.goToFirstRow()) { + do { + for (var [key, value] of map) { + var dbresult = resultSet.getString(resultSet.getColumnIndex(key)); + console.info(tag + ' : logMessage calllogQueryByInsert key = ' + key + + ' dbResult :' + dbresult + ' value : ' + value); + console.info(tag + ' : logMessage calllogQueryByInsert value ' + (value == dbresult)); + expect(value == dbresult).assertEqual(true); + } + } while (resultSet.goToNextRow()); + } + console.info(tag + " :logMessage calllogQueryByInsert: end"); + resultSet.close(); + } catch (error) { + console.info(tag + " :logMessage calllogQueryByInsert: error = " + error); + } + } + + async function calllogQueryForDelete(map, tag) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info(tag + ': calllogQueryForDelete start ! DAHelper = ' + DAHelper); + var resultColumns = common.getCallLogResultColumns(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", map.get("id")); + try { + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + expect(resultSet.goToFirstRow() == false).assertTrue(); + console.info(tag + " :logMessage calllogQueryForDelete: goToFirstRow " + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info(tag + " :logMessage calllogQueryForDelete: error = " + error); + } + } + + async function calllogQueryForBatchInsert(array, tag) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info(tag + ': calllogQueryForBatchInsert start ! DAHelper = ' + DAHelper); + var resultColumns = common.getCallLogResultColumns(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("phone_number", array[0].get("phone_number")); + try { + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + var size = array.size(); + console.info(tag + ' : logMessage calllogQueryForBatchInsert: size' + size); + expect(resultSet.rowCount == size).assertEqual(true); + var i = 0; + if (resultSet.rowCount > 0 && resultSet.goToFirstRow()) { + do { + for (var [key, value] of array[i]) { + var dbresult = resultSet.getString(resultSet.getColumnIndex(key)); + console.info(tag + ' : logMessage calllogQueryForBatchInsert dbresult :' + dbresult + + ' value : ' + value); + console.info(tag + ' : logMessage calllogQueryForBatchInsert value ' + (value == dbresult)); + expect(value == dbresult).assertTrue(); + } + i++; + } while (resultSet.goToNextRow()); + } + + resultSet.close(); + } catch (error) { + console.info(tag + " :logMessage calllogQueryByInsert: error = " + error); + } + } + + async function callLogDelete(tag) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + var deleteCode = await DAHelper.delete(calllogUri, condition); + console.info(tag + ': callLogDelete deleteCode = ' + deleteCode); + expect(deleteCode == 0).assertTrue(); + } + + /** + * @tc.number calllog_insert_test_100 + * @tc.name Insert call log + * @tc.desc Function test + */ + it("calllog_insert_test_100", 0, async function (done) { + console.info("--------logMessage calllog_insert_test_100 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var calllogId = await DAHelper.insert(calllogUri, common.getCallLogInsert()); + console.info("logMessage calllog_insert_test_100: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + var map = common.getCallLogInsertMap() + map.set("id", calllogId.toString()); + await calllogQueryForALL(map, "calllog_insert_test_100"); + await callLogDelete("calllog_insert_test_100"); + done(); + } catch (error) { + console.info("logMessage calllog_insert_test_100: calllog insert error = " + error); + done(); + } + }); + + /** + * @tc.number calllog_update_test_400 + * @tc.name Single call log update + * @tc.desc Function test + */ + it("calllog_update_test_400", 0, async function (done) { + console.info("--------logMessage calllog_update_test_400 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + try { + var calllogId = await DAHelper.insert(calllogUri, common.getCallLogInsert()); + console.info("logMessage calllog_update_test_400: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + await updateOneCalllog(); + done(); + } catch (error) { + console.info("logMessage calllog_update_test_400: calllog insert error = " + error); + done(); + } + ; + + async function updateOneCalllog() { + try { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", calllogId.toString()); + var updateCode = await DAHelper.update(calllogUri, common.getCallLogUpdate(), condition); + console.info("logMessage calllog_update_test_400: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + var map = common.getCallLogUpdateMap(); + map.set("id", calllogId.toString()); + await calllogQueryForALL(map, "calllog_update_test_400"); + await callLogDelete("calllog_update_test_400"); + } catch (error) { + console.info("logMessage calllog_update_test_400: update error = " + error); + done(); + } + ; + } + }); + + /** + * @tc.number calllog_update_test_500 + * @tc.name Update all call logs + * @tc.desc Function test + */ + it("calllog_update_test_500", 0, async function (done) { + console.info("--------logMessage calllog_update_test_500 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "1122445566", "ring_duration": "500" + }; + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage calllog_update_test_500: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + await updateAllCalllog(); + done(); + } catch (error) { + console.info("logMessage calllog_update_test_500: calllog insert error = " + error); + done(); + } + ; + async function updateAllCalllog() { + var updateValues = { + "answer_state": "1" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + var updateCode = await DAHelper.update(calllogUri, updateValues, condition) + console.info("logMessage calllog_update_test_500: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map([["phone_number", "1122445566"], ["ring_duration", "500"]]) + map.set("id", calllogId.toString()); + map.set("answer_state", "1"); + await calllogQueryForALL(map, "calllog_update_test_500"); + await callLogDelete("calllog_update_test_500"); + } catch (error) { + console.info("logMessage calllog_update_test_500: update error = " + error); + done(); + } + } + }); + + /** + * @tc.number calllog_delete_test_1300 + * @tc.name Delete call log + * @tc.desc Function test + */ + it("calllog_delete_test_1300", 0, async function (done) { + console.info("--------logMessage calllog_delete_test_1300 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "123456", "ring_duration": "200" + }; + try { + var callLogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage calllog_delete_test_1300: callLogId = " + callLogId); + expect(callLogId > 0).assertTrue(); + await deleteOneCallLog(); + done(); + } catch (error) { + console.info("logMessage calllog_delete_test_1300: calllog insert error = " + error); + done(); + } + + async function deleteOneCallLog() { + try { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", calllogId.toString()); + var deleteCode = await DAHelper.delete(calllogUri, condition); + console.info("logMessage calllog_delete_test_1300: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + var map = new Map(); + map.set("id", calllogId.toString()); + await calllogQueryForDelete(map, "calllog_delete_test_1300"); + } catch (error) { + console.info("logMessage calllog_delete_test_1300: delete error = " + error); + done(); + } + } + }); + + /** + * @tc.number calllog_batchInset_test_1600 + * @tc.name Insert call logs in batches + * @tc.desc Function test + */ + it("calllog_batchInset_test_1600", 0, async function (done) { + console.info("--------logMessage calllog_batchInset_test_1600 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var addBulkValue1 = { + "phone_number": "1600", "ring_duration": "333" + }; + var addBulkValue2 = { + "phone_number": "1600", "ring_duration": "600" + }; + var addBulkValue3 = { + "phone_number": "1600", "ring_duration": "600" + }; + var addBulkValue4 = { + "phone_number": "1600", "ring_duration": "600" + }; + var addBulkValue5 = { + "phone_number": "1600", "ring_duration": "600" + }; + var listAddBluk = []; + listAddBluk[0] = addBulkValue1; + listAddBluk[1] = addBulkValue2; + listAddBluk[2] = addBulkValue3; + listAddBluk[3] = addBulkValue4; + listAddBluk[4] = addBulkValue5; + try { + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + console.info("logMessage calllog_batchInset_test_1600: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + await calllogQueryForBatchInsert(common.getCallLogBatchInsert(), "calllog_batchInset_test_1600"); + await callLogDelete("calllog_batchInset_test_1600"); + done(); + } catch (error) { + console.info("logMessage calllog_batchInset_test_1600: error = " + error); + done(); + } + }); + + /** + * @tc.number calllog_query_test_1200 + * @tc.name Query all call logs + * @tc.desc Function test + */ + it("calllog_query_test_1200", 0, async function (done) { + console.info("------------calllog_query_test_1200 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "123566456", "ring_duration": "200" + }; + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage calllog_query_test_1200: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + var map = new Map([["phone_number", "123566456"], ["ring_duration", "200"]]); + map.set("id", calllogId.toString()); + await calllogQueryForALL(map, "calllog_query_test_1200"); + await callLogDelete("calllog_query_test_1200"); + done(); + } catch (error) { + console.info("logMessage calllog_query_test_1200: calllog insert error = " + error); + } + }); + + /** + * @tc.number calllog_query_test_1100 + * @tc.name Query call logs of combined conditions + * @tc.desc Function test + */ + it("calllog_query_test_1100", 0, async function (done) { + console.info("------------calllog_query_test_1100 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertValues = { + "phone_number": "44325008", "ring_duration": "100" + }; + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage calllog_query_test_1100: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + await queryCalllog(); + await callLogDelete("calllog_query_test_1100"); + done() + } catch (error) { + console.info("logMessage calllog_query_test_1100: calllog insert error = " + error); + done(); + } + + async function queryCalllog() { + var resultColumns = ["id", "phone_number"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + condition.and(); + condition.lessThan("ring_duration", "200").orderByAsc("id"); + try { + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info("logMessage calllog_query_test_1100: columnNames:" + resultSet.columnNames); + console.info("logMessage calllog_query_test_1100: columnCount:" + resultSet.columnCount); + console.info('logMessage calllog_query_test_1100: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == calllogId.toString()).assertTrue(); + console.info('logMessage calllog_query_test_1100: phone_number = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "44325008").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage calllog_query_test_1100: query error:" + error); + done(); + } + } + }); + + /** + * @tc.number calllog_query_test_800 + * @tc.name Query a single call log + * @tc.desc Function test + */ + it("calllog_query_test_800", 0, async function (done) { + console.info("------------calllog_query_test_800 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "88888888888", "ring_duration": "100" + }; + try { + var callLogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage calllog_query_test_800: callLogId = " + callLogId); + expect(callLogId > 0).assertTrue(); + await queryOneCallLog(); + await callLogDelete("calllog_query_test_800"); + done(); + } catch (error) { + console.info("logMessage calllog_query_test_800: calllog insert error = " + error); + done(); + } + + async function queryOneCallLog() { + var resultColumns = ["id", "phone_number"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", calllogId.toString()); + try { + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info("logMessage calllog_query_test_800: columnNames:" + resultSet.columnNames); + console.info("logMessage calllog_query_test_800: columnCount:" + resultSet.columnCount); + console.info('logMessage calllog_query_test_800: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == calllogId.toString()).assertTrue(); + console.info('logMessage calllog_query_test_800: phone_number = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "88888888888").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage calllog_query_test_800: query error = " + error); + done(); + } + } + }); + + /** + * @tc.number calllog_fuzzyquery_test_100 + * @tc.name Fuzzy query ability based on mobile phone number (beginning of a certain field) + * @tc.desc Function test + */ + it("calllog_fuzzyquery_test_100", 0, async function (done) { + console.info("------------calllog_fuzzyquery_test_100 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "196320147" + }; + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage calllog_fuzzyquery_test_100: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + await queryByStartsWithPhoneNumber(); + await callLogDelete("calllog_fuzzyquery_test_100"); + done(); + } catch (error) { + console.info("logMessage calllog_fuzzyquery_test_100: calllog insert error = " + error); + done(); + } + + async function queryByStartsWithPhoneNumber() { + var resultColumns = ["id", "phone_number"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.like("phone_number", "196%"); + try { + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info("logMessage calllog_fuzzyquery_test_100: columnNames:" + resultSet.columnNames); + console.info("logMessage calllog_fuzzyquery_test_100: columnCount:" + resultSet.columnCount); + console.info('logMessage calllog_fuzzyquery_test_100: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == calllogId.toString()).assertTrue(); + console.info( + 'logMessage calllog_fuzzyquery_test_100: phone_number = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "196320147").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage calllog_fuzzyquery_test_100: query error = " + error); + done(); + } + } + }); + + /** + * @tc.number calllog_fuzzyquery_test_200 + * @tc.name Fuzzy query ability based on mobile phone number (at the end of a certain field) + * @tc.desc Function test + */ + it("calllog_fuzzyquery_test_200", 0, async function (done) { + console.info("------------calllog_fuzzyquery_test_200 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "126467821" + }; + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage calllog_fuzzyquery_test_200: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + await queryByEndWithPhoneNumber(); + await callLogDelete("calllog_fuzzyquery_test_200"); + done(); + } catch (error) { + console.info("logMessage calllog_fuzzyquery_test_200: calllog insert error = " + error); + done(); + } + + async function queryByEndWithPhoneNumber() { + var resultColumns = ["id", "phone_number"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.like("phone_number", "%821"); + try { + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info("logMessage calllog_fuzzyquery_test_200: columnNames:" + resultSet.columnNames); + console.info("logMessage calllog_fuzzyquery_test_200: columnCount:" + resultSet.columnCount); + console.info('logMessage calllog_fuzzyquery_test_200: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == calllogId.toString()).assertTrue(); + console.info( + 'logMessage calllog_fuzzyquery_test_200: phone_number = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "126467821").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage calllog_fuzzyquery_test_200: query error = " + error); + done(); + } + } + }); + + /** + * @tc.number calllog_fuzzyquery_test_300 + * @tc.name Fuzzy query ability based on mobile phone number (including a certain field) + * @tc.desc Function test + */ + it("calllog_fuzzyquery_test_300", 0, async function (done) { + console.info("------------calllog_fuzzyquery_test_300 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "1234567855557568" + }; + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage calllog_fuzzyquery_test_300: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + await queryByPhoneNumberContainsField(); + await callLogDelete("calllog_fuzzyquery_test_300"); + done(); + } catch (error) { + console.info("logMessage calllog_fuzzyquery_test_300: calllog insert error = " + error); + done(); + } + + async function queryByPhoneNumberContainsField() { + var resultColumns = ["id", "phone_number"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.like("phone_number", "%555%"); + try { + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info("logMessage calllog_fuzzyquery_test_300: columnNames:" + resultSet.columnNames); + console.info("logMessage calllog_fuzzyquery_test_300: columnCount:" + resultSet.columnCount); + console.info('logMessage calllog_fuzzyquery_test_300: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == calllogId.toString()).assertTrue(); + console.info( + 'logMessage calllog_fuzzyquery_test_300: phone_number = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "1234567855557568").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage calllog_fuzzyquery_test_300: query error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_calllog_insert_test_200 + * @tc.name Abnormal use case, an incorrect field is passed in when inserting data + * @tc.desc Function test + */ + it("abnormal_calllog_insert_test_200", 0, async function (done) { + console.info("------------abnormal_calllog_insert_test_200 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_numbers": "1111111111" + }; + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage abnormal_calllog_insert_test_200: calllogId = " + calllogId); + expect(calllogId == -1).assertTrue(); + done(); + } catch (error) { + console.info("logMessage abnormal_calllog_insert_test_200: calllog insert error = " + error); + done(); + } + }); + + /** + * @tc.number abnormal_calllog_insert_test_300 + * @tc.name Abnormal use case, an incorrect table name is passed in when inserting data + * @tc.desc Function test + */ + it("abnormal_calllog_insert_test_300", 0, async function (done) { + console.info("------------abnormal_calllog_insert_test_300 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var errorUri = "dataability:///com.ohos.calllogability/calls/calllogs"; + + var insertValues = { + "phone_number": "456789410" + }; + try { + var calllogId = await DAHelper.insert(errorUri, insertValues); + console.info("logMessage abnormal_calllog_insert_test_300: calllogId = " + calllogId); + expect(calllogId == -1).assertTrue(); + done(); + } catch (error) { + console.info("logMessage abnormal_calllog_insert_test_300: calllog insert error = " + error); + done(); + } + }); + + /** + * @tc.number abnormal_calllog_update_test_600 + * @tc.name Abnormal use case, passing in a wrong field when updating data + * @tc.desc Function test + */ + it("abnormal_calllog_update_test_600", 0, async function (done) { + console.info("------------abnormal_calllog_update_test_600 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "1020202020" + }; + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage abnormal_calllog_update_test_600: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + await abnormalUpdate(); + await callLogDelete("abnormal_calllog_update_test_600"); + done(); + } catch (error) { + console.info("logMessage abnormal_calllog_update_test_600: calllog insert error = " + error); + done(); + } + + async function abnormalUpdate() { + var updateValues = { + "phone_numbers": "22001122" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", calllogId.toString()); + try { + var updataCode = await DAHelper.update(calllogUri, updateValues, condition); + console.info("logMessage abnormal_calllog_update_test_600: updataCode = " + updataCode); + expect(updataCode == -1).assertTrue(); + var map = new Map(); + map.set("id", calllogId.toString()); + map.set("phone_number", "1020202020"); + await calllogQueryForALL(map, "abnormal_calllog_update_test_600"); + } catch (error) { + console.info("logMessage abnormal_calllog_update_test_600: update error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_calllog_update_test_700 + * @tc.name Abnormal use case, an incorrect table name is passed in when updating data + * @tc.desc Function test + */ + it("abnormal_calllog_update_test_700", 0, async function (done) { + console.info("------------abnormal_calllog_update_test_700 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var errorUri = "dataability:///com.ohos.calllogability/calls/calllogs"; + + var insertValues = { + "phone_number": "9952364" + }; + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage abnormal_calllog_update_test_700: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + await abnormalUpdate(); + await callLogDelete("abnormal_calllog_update_test_700"); + done(); + } catch (error) { + console.info("logMessage abnormal_calllog_update_test_700: calllog insert error = " + error); + done(); + } + + async function abnormalUpdate() { + var updateValues = { + "phone_numbers": "22001122" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", calllogId.toString()); + try { + var updataCode = await DAHelper.update(errorUri, updateValues, condition); + console.info("logMessage abnormal_calllog_update_test_700: updataCode = " + updataCode); + expect(updataCode == -1).assertTrue(); + var map = new Map(); + map.set("id", calllogId.toString()); + map.set("phone_number", "9952364"); + await calllogQueryForALL(map, "abnormal_calllog_update_test_700"); + done(); + } catch (error) { + console.info("logMessage abnormal_calllog_update_test_700: update error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_calllog_delete_test_1400 + * @tc.name Abnormal use case, passing in a wrong field when deleting data + * @tc.desc Function test + */ + it("abnormal_calllog_delete_test_1400", 0, async function (done) { + console.info("------------abnormal_calllog_delete_test_1400 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "789130" + }; + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage abnormal_calllog_delete_test_1400: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + await abnormalDelete(); + await callLogDelete("abnormal_calllog_delete_test_1400"); + done(); + } catch (error) { + console.info("logMessage abnormal_calllog_delete_test_1400: calllog insert error = " + error); + done(); + } + + async function abnormalDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", calllogId.toString()); + try { + var deleteCode = await DAHelper.delete(calllogUri, condition); + console.info("logMessage abnormal_calllog_delete_test_1400: deleteCode = " + deleteCode); + expect(deleteCode == -1).assertTrue(); + var map = new Map(); + map.set("id", calllogId.toString()); + map.set("phone_number", "789130"); + await calllogQueryForALL(map, "abnormal_calllog_delete_test_1400"); + } catch (error) { + console.info("logMessage abnormal_calllog_delete_test_1400: delete error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_calllog_delete_test_1500 + * @tc.name Abnormal use case, passing in an incorrect table name when deleting data + * @tc.desc Function test + */ + it("abnormal_calllog_delete_test_1500", 0, async function (done) { + console.info("------------abnormal_calllog_delete_test_1500 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var errorUri = "dataability:///com.ohos.calllogability/calls/calllogs"; + + var insertValues = { + "phone_number": "1564721" + }; + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage abnormal_calllog_delete_test_1500: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + await abnormalDelete(); + await callLogDelete("abnormal_calllog_delete_test_1500"); + done(); + } catch (error) { + console.info("logMessage abnormal_calllog_delete_test_1500: calllog insert error = " + error); + done(); + } + + async function abnormalDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", calllogId.toString()); + try { + var deleteCode = await DAHelper.delete(errorUri, condition); + console.info("logMessage abnormal_calllog_delete_test_1500: deleteCode = " + deleteCode); + expect(deleteCode == -1).assertTrue(); + done() + var map = new Map(); + map.set("id", calllogId.toString()); + map.set("phone_number", "1564721"); + await calllogQueryForALL(map, "abnormal_calllog_delete_test_1500"); + } catch (error) { + console.info("logMessage abnormal_calllog_delete_test_1500: delete error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_calllog_query_test_900 + * @tc.name Abnormal use case, an incorrect field is passed in when querying + * @tc.desc Function test + */ + it("abnormal_calllog_query_test_900", 0, async function (done) { + console.info("------------abnormal_calllog_query_test_900 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "1564721" + }; + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage abnormal_calllog_query_test_900: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + await abnormalQuery(); + await callLogDelete("abnormal_calllog_query_test_900"); + done(); + } catch (error) { + console.info("logMessage abnormal_calllog_query_test_900: calllog insert error = " + error); + done(); + } + + async function abnormalQuery() { + var resultColumns = ["id", "phone_number"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", calllogId.toString()); + try { + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + console.info('logMessage abnormal_calllog_query_test_900: goToFirstRow' + resultSet.goToFirstRow()); + expect(resultSet.goToFirstRow()).assertEqual(false); + resultSet.close(); + } catch (error) { + console.info("logMessage abnormal_calllog_query_test_900:query error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_calllog_batchinsert_test_1700 + * @tc.name abnormal_batchinsert + * @tc.desc Function test + */ + it("abnormal_calllog_batchinsert_test_1700", 0, async function (done) { + console.info("--------logMessage abnormal_calllog_batchinsert_test_1700 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var addBulkValue1 = { + "phone_number": "5555555555", "ring_duration": "500" + }; + var addBulkValue2 = { + "phone_number": "1511002", "ring_duration": "100" + }; + var addBulkValue3 = { + "phone_numbers": "1521003", "ring_duration": "100" + }; + var addBulkValue4 = { + "phone_number": "1521004", "ring_durations": "100" + }; + var addBulkValue5 = { + "phone_number": "1521005", "ring_duration": "100" + }; + var listAddBluk = []; + listAddBluk[0] = addBulkValue1; + listAddBluk[1] = addBulkValue2; + listAddBluk[2] = addBulkValue3; + listAddBluk[3] = addBulkValue4; + listAddBluk[4] = addBulkValue5; + try { + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + console.info("logMessage abnormal_calllog_batchinsert_test_1700: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == -1).assertTrue(); + done(); + } catch (error) { + console.info("logMessage abnormal_calllog_batchinsert_test_1700: batchInsert error = " + error); + done(); + } + }); + + /** + * @tc.number calllog_delete_test_1800 + * @tc.name batchDelete + * @tc.desc Function test + */ + it("calllog_delete_test_1800", 0, async function (done) { + console.info("--------logMessage calllog_delete_test_1800 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var calllogId = await DAHelper.insert(calllogUri, common.getCallLogInsert()); + console.info("logMessage calllog_delete_test_1800: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + var map = common.getCallLogInsertMap() + map.set("id", calllogId.toString()); + await calllogQueryForALL(map, "calllog_delete_test_1800"); + await executeBatch(); + } catch (error) { + console.info("logMessage calllog_delete_test_1800: calllog insert error = " + error); + done(); + } + + async function executeBatch() { + console.info("logMessage calllog_delete_test_1800: executeBatch start "); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", calllogId.toString()); + DAHelper.executeBatch(URI_CALLLOG, [{ + uri: calllogUri, + type: featureAbility.DataAbilityOperationType.TYPE_DELETE, + predicates: condition, + expectedCount: 0, + PredicatesBackReferences: {}, + interrupted: true, + }], + (error, data) => { + console.info("logMessage calllog_delete_test_1800: executeBatch data = " + JSON.stringify(data)); + console.info("logMessage calllog_delete_test_1800: data_3 = " + data); + console.info("logMessage calllog_delete_test_1800: data_1= " + data[0].count); + expect(data[0].count == 0).assertTrue(); + done(); + }); + }; + }); + + /** + * @tc.number calllog_update_test_1900 + * @tc.name batchUpdate + * @tc.desc Function test + */ + it("calllog_update_test_1900", 0, async function (done) { + console.info("--------logMessage calllog_update_test_1900 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var calllogId = await DAHelper.insert(calllogUri, common.getCallLogInsert()); + console.info("logMessage calllog_update_test_1900: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + var map = common.getCallLogInsertMap() + map.set("id", calllogId.toString()); + await calllogQueryForALL(map, "calllog_update_test_1900"); + await executeBatch(); + } catch (error) { + console.info("logMessage calllog_update_test_1900: calllog insert error = " + error); + done(); + } + + async function executeBatch() { + var updateValues = { + "phone_number": "123456789" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", calllogId.toString()); + DAHelper.executeBatch(URI_CALLLOG, [{ + uri: calllogUri, + type: featureAbility.DataAbilityOperationType.TYPE_UPDATE, + valuesBucket: updateValues, + predicates: condition, + expectedCount: 0, + PredicatesBackReferences: {}, + interrupted: true, + }], + (error, data) => { + console.info("logMessage calllog_update_test_1900: executeBatch data = " + JSON.stringify(data)); + console.info("logMessage calllog_update_test_1900: data_3 = " + data); + console.info("logMessage calllog_update_test_1900: data_1= " + data[0].count); + expect(data[0].count == 0).assertTrue(); + done(); + }); + }; + }); + + /** + * @tc.number calllog_Delete_test_2000 + * @tc.name calllog Delete + * @tc.desc Function test + */ + it("calllog_Delete_test_2000", 0, async function (done) { + console.info("--------logMessage calllog_Delete_test_2000 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertValues = { + "phone_number": "123456", "ring_duration": "200" + }; + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + var calllogIdTwo = await DAHelper.insert(calllogUri, insertValues); + var calllogIdThree = await DAHelper.insert(calllogUri, insertValues); + expect(calllogId > 0).assertTrue(); + expect(calllogIdTwo > 0).assertTrue(); + expect(calllogIdThree > 0).assertTrue(); + await deleteCalllog(); + done(); + } catch (error) { + console.info("logMessage calllog_Delete_test_2000: calllog insert error = " + error); + done(); + } + + async function deleteCalllog() { + try { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", calllogId.toString()); + condition.or(); + condition.equalTo("id", calllogIdTwo.toString()); + condition.or(); + condition.equalTo("id", calllogIdThree.toString()); + var deleteCode = await DAHelper.delete(calllogUri, condition); + console.info("logMessage calllog_Delete_test_2000: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + var resultColumns = []; + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + expect(resultSet.rowCount == 0).assertTrue(); + resultSet.close(); + } catch (error) { + console.info("logMessage calllog_Delete_test_2000: delete error = " + error); + done(); + } + } + }); + + /** + * @tc.number calllog_Delete_test_2100 + * @tc.name calllog Delete + * @tc.desc Function test + */ + it("calllog_Delete_test_2100", 0, async function (done) { + console.info("--------logMessage calllog_Delete_test_2100 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var calllogId = await DAHelper.insert(calllogUri, common.getCallLogInsert()); + console.info("logMessage calllog_Delete_test_2100: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + var map = common.getCallLogInsertMap() + map.set("id", calllogId.toString()); + await calllogQueryForALL(map, "calllog_Delete_test_2100"); + await callLogDelete("calllog_Delete_test_2100"); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", calllogId); + var resultColumns = []; + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + expect(resultSet.rowCount == 0).assertTrue(); + resultSet.close(); + done(); + } catch (error) { + console.info("logMessage calllog_Delete_test_2100: calllog insert error = " + error); + done(); + } + }); + + /** + * @tc.number calllog_queryContains_test_2200 + * @tc.name calllog Delete + * @tc.desc Function test + */ + it("calllog_queryContains_test_2200", 0, async function (done) { + console.info("--------logMessage calllog_queryContains_test_2200 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertValues = { + "phone_number": "123456789220099999" + } + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage calllog_queryContains_test_2200: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + + var resultColumns = ["phone_number"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.contains("phone_number", "99999"); + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var phone = resultSet.getString(resultSet.getColumnIndex("phone_number")); + console.info("logMessage calllog_queryContains_test_2200: phone is = " + phone); + expect(phone == "123456789220099999").assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + await callLogDelete(); + done(); + } catch (error) { + console.info("logMessage calllog_queryContains_test_2200: calllog insert error = " + error); + done(); + } + }); + + /** + * @tc.number abnormal_calllog_update_test_2300 + * @tc.name Update all call records, pass in a field that does not exist + * @tc.desc Function test + */ + it("abnormal_calllog_update_test_2300", 0, async function (done) { + console.info("--------logMessage abnormal_calllog_update_test_2300 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertValues = { + phone_number: "15748646546", display_name: "name2300" + } + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + var calllogIdTwo = await DAHelper.insert(calllogUri, insertValues); + expect(calllogId > 0).assertTrue(); + expect(calllogIdTwo > 0).assertTrue(); + await updateOneCalllog(); + done(); + } catch (error) { + console.info("logMessage abnormal_calllog_update_test_2300: calllog insert error = " + error); + done(); + } + ; + async function updateOneCalllog() { + try { + var insertValues = { + phone_number: "15748646546", display_names: "nameUpdateError2300" + }; + var condition = + new ohosDataAbility.DataAbilityPredicates(); + var updateCode = await DAHelper.update(calllogUri, insertValues, condition); + console.info("logMessage abnormal_calllog_update_test_2300: updateCode = " + updateCode); + expect(updateCode == -1).assertTrue(); + var map = new Map(); + map.set("id", calllogId.toString()); + map.set("display_name", "name2300"); + await calllogQueryForALL(map, "abnormal_calllog_update_test_2300"); + map.set("id", calllogIdTwo.toString()); + await calllogQueryForALL(map, "abnormal_calllog_update_test_2300"); + await callLogDelete("calllog_update_test_2300"); + } catch (error) { + console.info("logMessage abnormal_calllog_update_test_2300: update error = " + error); + done(); + } + ; + } + }); + + /** + * @tc.number abnormal_calllog_query_test_2400 + * @tc.name When querying call records based on combined conditions, incorrect field + * names and non-existent data are passed in + * @tc.desc Function test + */ + it("abnormal_calllog_query_test_2400", 0, async function (done) { + console.info("--------logMessage abnormal_calllog_query_test_2400 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertValues = { + phone_number: "15748646546", display_name: "name2300" + } + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + var calllogIdTwo = await DAHelper.insert(calllogUri, insertValues); + expect(calllogId > 0).assertTrue(); + expect(calllogIdTwo > 0).assertTrue(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", calllogId.toString() + "ksks"); + var resultColumns = ["display_names"]; + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + console.info("abnormal_calllog_query_test_2400: resultSet.rowCount = " + resultSet.rowCount); + expect(resultSet.rowCount == -1).assertTrue(); + resultSet.close(); + await callLogDelete("abnormal_calllog_query_test_2400"); + done(); + } catch (error) { + console.info("logMessage abnormal_calllog_query_test_2400: calllog insert error = " + error); + done(); + } + ; + }); + + /** + * @tc.number abnormal_calllog_query_test_2500 + * @tc.name When querying all call records based on combined conditions, incorrect field + * names and non-existent data are passed in + * @tc.desc Function test + */ + it("abnormal_calllog_query_test_2500", 0, async function (done) { + console.info("--------logMessage abnormal_calllog_query_test_2500 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertValues = { + phone_number: "15748646546", display_name: "name2300" + } + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info('abnormal_calllog_query_test_2500 calllogId = ' + calllogId); + var calllogIdTwo = await DAHelper.insert(calllogUri, insertValues); + console.info('abnormal_calllog_query_test_2500 calllogIdTwo = ' + calllogIdTwo); + expect(calllogId > 0).assertTrue(); + expect(calllogIdTwo > 0).assertTrue(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + var resultColumns = ["display_names"]; + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + console.info('abnormal_calllog_query_test_2500 resultSet.goToFirstRow() = ' + resultSet.goToFirstRow()); + console.info('abnormal_calllog_query_test_2500 resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.goToFirstRow() == false).assertTrue(); + resultSet.close(); + await callLogDelete("abnormal_calllog_query_test_2500"); + done(); + } catch (error) { + console.info("logMessage abnormal_calllog_query_test_2500: calllog insert error = " + error); + done(); + } + ; + }); + + /** + * @tc.number abnormal_calllog_delete_test_2600 + * @tc.name Batch call records are added, and some of them fail, depending on the processing logic + * @tc.desc Function test + */ + it("abnormal_calllog_delete_test_2600", 0, async function (done) { + console.info("--------logMessage abnormal_calllog_delete_test_2600 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertValues = { + phone_number: "15748646546", display_name: "name2300" + } + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + var calllogIdTwo = await DAHelper.insert(calllogUri, insertValues); + expect(calllogId > 0).assertTrue(); + expect(calllogIdTwo > 0).assertTrue(); + } catch (error) { + console.info("logMessage abnormal_calllog_delete_test_2600: calllog insert error = " + error); + done(); + } + ; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", calllogIdTwo.toString()); + condition.or(); + condition.equalTo("id", calllogId.toString()); + var code = await DAHelper.delete(calllogUri, condition); + console.info("logMessage abnormal_calllog_delete_test_2600: code = " + code); + expect(code == -1).assertTrue(); + condition.clear(); + var resultColumns = []; + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + var count = 2; + expect(resultSet.rowCount == count).assertTrue(); + resultSet.close(); + await callLogDelete("abnormal_calllog_delete_test_2600"); + done(); + }); + + /** + * @tc.number abnormal_calllog_update_test_2700 + * @tc.name When batch call records are modified, the wrong field or table name is passed in + * @tc.desc Function test + */ + it("abnormal_calllog_delete_test_2700", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertValues = { + phone_number: "270015748646546", display_name: "name2700" + } + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + var calllogIdTwo = await DAHelper.insert(calllogUri, insertValues); + expect(calllogId > 0).assertTrue(); + expect(calllogIdTwo > 0).assertTrue(); + await updateOneCalllog(); + done(); + } catch (error) { + console.info("logMessage abnormal_calllog_delete_test_2700: calllog insert error = " + error); + done(); + } + ; + async function updateOneCalllog() { + try { + var insertValues = { + phone_number: "270015748646546", display_names: "nameUpdateError2700" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", calllogIdTwo.toString()); + condition.or(); + condition.equalTo("id", calllogId.toString()); + var updateCode = await DAHelper.update(calllogUri, insertValues, condition); + console.info("logMessage abnormal_calllog_delete_test_2700: updateCode = " + updateCode); + expect(updateCode == -1).assertTrue(); + var map = new Map(); + map.set("id", calllogId.toString()); + map.set("display_name", "name2700"); + await calllogQueryForALL(map, "abnormal_calllog_delete_test_2700"); + map.set("id", calllogIdTwo.toString()); + await calllogQueryForALL(map, "abnormal_calllog_delete_test_2700"); + await callLogDelete("abnormal_calllog_delete_test_2700"); + } catch (error) { + console.info("logMessage abnormal_calllog_delete_test_2700: update error = " + error); + done(); + } + ; + } + }); + + /** + * @tc.number abnormal_calllog_query_test_2800 + * @tc.name Fuzzy search query based on mobile phone number + * @tc.desc Function test + */ + it("abnormal_calllog_query_test_2800", 0, async function (done) { + console.info("------------abnormal_calllog_query_test_2800 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertValues = { + "phone_number": "196320147" + }; + try { + var calllogId = await DAHelper.insert(calllogUri, insertValues); + console.info("logMessage abnormal_calllog_query_test_2800: calllogId = " + calllogId); + expect(calllogId > 0).assertTrue(); + await queryByStartsWithPhoneNumberError(); + await callLogDelete("abnormal_calllog_query_test_2800"); + done(); + } catch (error) { + console.info("logMessage abnormal_calllog_query_test_2800: calllog insert error = " + error); + done(); + } + + async function queryByStartsWithPhoneNumberError() { + var resultColumns = ["id", "phone_number"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.like("phone_numbers", "196%"); + try { + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + console.info("logMessage abnormal_calllog_query_test_2800: resultSet.rowCount = " + resultSet.rowCount); + expect(resultSet.rowCount == -1).assertTrue(); + resultSet.close(); + } catch (error) { + console.info("logMessage abnormal_calllog_query_test_2800: query error = " + error); + done(); + } + } + }); + + afterAll(async function () { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('callllog afterAll logMessage get DAHelper success! DAHelper = ' + DAHelper); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + var deleteCode = await DAHelper.delete(calllogUri, condition); + console.info('callllog afterAll end logMessage deleteCode = ' + deleteCode); + }); + }) +} diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/ContactCard_test.js b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/ContactCard_test.js new file mode 100644 index 0000000000000000000000000000000000000000..70c1ba5e403e427d16703de94fc855d0ef74dfd0 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/ContactCard_test.js @@ -0,0 +1,5441 @@ +/* + * Copyright (c) 2021 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 featureAbility from '@ohos.ability.featureAbility'; +import ohosDataAbility from '@ohos.data.dataability'; +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'deccjsunit/index' +import common from './common.js'; + +const URI_CONTACTS = "dataability:///com.ohos.contactsdataability"; +const profilecontactUri = "dataability:///com.ohos.contactsdataability/profile/contact"; +const profileRawContactUri = "dataability:///com.ohos.contactsdataability/profile/raw_contact"; +const profileContactDataUri = "dataability:///com.ohos.contactsdataability/profile/contact_data"; +const profileGroupUri = "dataability:///com.ohos.contactsdataability/profile/groups"; +const profileBlocklistUri = "dataability:///com.ohos.contactsdataability/profile/contact_blocklist"; +const profilesearchContactUri = "dataability:///com.ohos.contactsdataability/profile/search_contact"; +const profileDeletedContactsUri = "dataability:///com.ohos.contactsdataability/profile/deleted_raw_contact"; +const profileDeletedRawContactRecord = + "dataability:///com.ohos.contactsdataability/profile/deleted_raw_contact_record"; + +export default function ContactCardTest() { + describe('ContactCardTest', function () { + console.info("-------ContactsTest is starting!--------"); + + function sleep(numberMillis) { + var now = new Date(); + var exitTime = now.getTime() + numberMillis; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) + return; + } + } + + async function contactsQuery(map, tag, uri) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': contactsQuery start ! DAHelper = ' + DAHelper); + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", map.get("id")); + try { + var resultSet = await DAHelper.query(uri, resultColumns, condition); + sleep(2000); + if (resultSet.rowCount > 0 && resultSet.goToFirstRow()) { + do { + for (var [key, value] of map) { + var dbresult = resultSet.getString(resultSet.getColumnIndex(key)); + console.info(tag + ':logMessage contactsQuery key = ' + key + ' dbresult :' + dbresult + + ' value : ' + value); + expect(value == dbresult).assertEqual(true); + } + } while (resultSet.goToNextRow()); + } + + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage contactsQuery: error = " + error); + } + } + + async function queryBatch(map, tag, size) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': queryBatch start ! DAHelper = ' + DAHelper); + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", map.get("raw_contact_id")); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + sleep(1000); + console.info(tag + ': queryBatch start ! resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == size).assertEqual(true); + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage resultSet.rowCount: error = " + error); + } + } + + async function queryIdForDelete(map, tag, uri) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': queryIdForDelete start ! DAHelper = ' + DAHelper); + var resultColumns = common.getCallLogResultColumns(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", map.get("id")); + try { + var resultSet = await DAHelper.query(uri, resultColumns, condition); + sleep(1000); + expect(resultSet.goToFirstRow() == false).assertTrue(); + console.info(tag + " :logMessage queryIdForDelete: goToFirstRow " + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info(tag + " :logMessage queryIdForDelete: error = " + error); + } + } + + async function deleteAll(uri, tag) { + try { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + var deleteCode = await DAHelper.delete(uri, condition); + console.info(tag + ': deleteAll deleteCode = ' + deleteCode); + expect(deleteCode == 0).assertTrue(); + } catch (error) { + console.info(tag + ': deleteAll error = ' + error); + } + } + + async function deleteRawContact(tag) { + try { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + condition.and(); + condition.equalTo("is_deleted", "0"); + var deleteCode = await DAHelper.delete(profileRawContactUri, condition); + console.info(tag + ': deleteRawContact deleteCode = ' + deleteCode); + expect(deleteCode == 0).assertTrue(); + sleep(1000); + var conditionAll = new ohosDataAbility.DataAbilityPredicates(); + conditionAll.greaterThan("id", "0"); + var code = await DAHelper.delete(profileDeletedContactsUri, conditionAll); + console.info(tag + ': Completely delete code = ' + code); + expect(code == 0).assertTrue(); + } catch (error) { + console.info(tag + ': deleteRawContact error = ' + error); + } + } + + async function insertData(rawContactId, type, value, position) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var contactDataValues1 = + { + "raw_contact_id": rawContactId, "content_type": type, "detail_info": value, "position": position + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues1); + console.info("logMessage : contactDataId " + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info("logMessage : contact_data name insert error = " + error); + } + return contactDataId; + } + + /** + * @tc.number contactCard_insert_test_100 + * @tc.name Insert contact data + * @tc.desc Function test + */ + it("contactCard_insert_test_100", 0, async function (done) { + console.info("------logMessage contactCard_insert_test_100 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, common.getProfileRawContact()); + sleep(1000); + console.info('logMessage contactCard_insert_test_100: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + var map = common.getProfileRawContactMap(); + map.set("id", rawContactId.toString()); + await contactsQuery(map, "contactCard_insert_test_100", profileRawContactUri); + await deleteRawContact("contactCard_insert_test_100"); + done(); + } catch (error) { + console.info('logMessage contactCard_insert_test_100: insert error = ' + error); + done(); + } + }); + + /** + * @tc.number contactCard_insert_test_400 + * @tc.name Insert contact details (name, company, position, mobile phone number) + * @tc.desc Function test + */ + it("contactCard_insert_test_400", 0, async function (done) { + console.info("------logMessage contactCard_insert_test_400 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocheng", + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_insert_test_400: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await dataNameInsert(DAHelper, rawContactId); + await dataCompanyInsert(DAHelper, rawContactId); + await dataPhoneInsert(DAHelper, rawContactId); + await deleteRawContact("contactCard_insert_test_400"); + await deleteAll(profileContactDataUri, "contactCard_insert_test_400"); + done(); + } catch (error) { + console.info("logMessage contactCard_insert_test_400: raw_contact insert error = " + error); + done(); + } + }); + + async function dataNameInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "name", + "detail_info": "xiaocheng" + }; + try { + var contactDataId1 = await DAHelper.insert(profileContactDataUri, contactDataValues1); + console.info("logMessage contactCard_insert_test_400: contactDataId1 " + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "xiaocheng"); + map.set("raw_contact_id", rawContactId.toString()); + await contactsQuery(map, "contactCard_insert_test_400", profileContactDataUri); + } catch (error) { + console.info("logMessage contactCard_insert_test_400: contact_data name insert error = " + error); + done(); + } + } + + async function dataCompanyInsert(DAHelper, rawContactId) { + var contactDataValues2 = { + "raw_contact_id": rawContactId, + "content_type": "organization", + "detail_info": "TT", + "position": "developer" + }; + try { + var contactDataId2 = await DAHelper.insert(profileContactDataUri, contactDataValues2); + console.info("logMessage contactCard_insert_test_400: contactDataId2 " + contactDataId2); + expect(contactDataId2 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId2.toString()); + map.set("detail_info", "TT"); + map.set("position", "developer"); + contactsQuery(map, "contactCard_insert_test_400", profileContactDataUri); + } catch (error) { + console.info("logMessage contactCard_insert_test_400: contact_data company insert error = " + error); + done(); + } + } + + async function dataPhoneInsert(DAHelper, rawContactId) { + var contactDataValues3 = { + "raw_contact_id": rawContactId, + "content_type": "phone", + "detail_info": "12345678" + }; + try { + var contactDataId3 = await DAHelper.insert(profileContactDataUri, contactDataValues3); + sleep(1000); + console.info("logMessage contactCard_insert_test_400: contactDataId3 " + contactDataId3); + expect(contactDataId3 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId3.toString()); + map.set("detail_info", "12345678"); + await contactsQuery(map, "contactCard_insert_test_400", profileContactDataUri); + } catch (error) { + console.info("logMessage contactCard_insert_test_400: contact_data phone insert error = " + error); + done(); + } + } + + /** + * @tc.number contactCard_insert_test_500 + * @tc.name Insert contact details (nickname, email, home) + * @tc.desc Function test + */ + it("contactCard_insert_test_500", 0, async function (done) { + console.info("------logMessage contactCard_insert_test_500 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocheng", + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_insert_test_500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await dataEmailInsert(DAHelper, rawContactId); + await dataNickNameInsert(DAHelper, rawContactId); + await dataPostalAddressInsert(DAHelper, rawContactId); + await deleteRawContact("contactCard_insert_test_500"); + await deleteAll(profileContactDataUri, "contactCard_insert_test_500"); + done(); + } catch (error) { + console.info("logMessage contactCard_insert_test_500: raw_contact insert error = " + error); + done(); + } + }); + + async function dataEmailInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "email", + "detail_info": "166@163.com" + }; + try { + var contactDataId1 = await DAHelper.insert(profileContactDataUri, contactDataValues1); + sleep(1000); + console.info("logMessage contactCard_insert_test_500: contactDataId1 " + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "166@163.com"); + await contactsQuery(map, "contactCard_insert_test_500_1", profileContactDataUri); + } catch (error) { + console.info("logMessage contactCard_insert_test_500: contact_data email insert error = " + error); + } + } + + async function dataNickNameInsert(DAHelper, rawContactId) { + var contactDataValues2 = { + "raw_contact_id": rawContactId, + "content_type": "nickname", + "detail_info": "xiaocheng" + }; + try { + var contactDataId2 = await DAHelper.insert(profileContactDataUri, contactDataValues2); + console.info("logMessage contactCard_insert_test_500: contactDataId2 " + contactDataId2); + expect(contactDataId2 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId2.toString()); + map.set("detail_info", "xiaocheng"); + await contactsQuery(map, "contactCard_insert_test_500_2", profileContactDataUri); + } catch (error) { + console.info("logMessage contactCard_insert_test_500: contact_data nickname insert error = " + error); + } + } + + async function dataPostalAddressInsert(DAHelper, rawContactId) { + var contactDataValues3 = { + "raw_contact_id": rawContactId, + "content_type": "postal_address", + "detail_info": "NanJingSoftRoad" + }; + try { + var contactDataId3 = await DAHelper.insert(profileContactDataUri, contactDataValues3); + console.info("logMessage contactCard_insert_test_500: contactDataId3 " + contactDataId3); + expect(contactDataId3 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId3.toString()); + map.set("detail_info", "NanJingSoftRoad"); + await contactsQuery(map, "contactCard_insert_test_500_3", profileContactDataUri); + } catch (error) { + console.info("logMessage contactCard_insert_test_500: contact_data postal_address insert error = " + error); + } + } + + /** + * @tc.number contactCard_insert_test_600 + * @tc.name Insert contact details (remarks, AIM, birthday) + * @tc.desc Function test + */ + it("contactCard_insert_test_600", 0, async function (done) { + console.info("------logMessage contactCard_insert_test_600 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocheng", + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues) + console.info("logMessage contactCard_insert_test_600: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await dataNoteInsert(DAHelper, rawContactId); + await dataAimInsert(DAHelper, rawContactId); + await dataEventInsert(DAHelper, rawContactId); + await deleteRawContact("contactCard_insert_test_600"); + await deleteAll(profileContactDataUri, "contactCard_insert_test_600"); + done(); + } catch (error) { + console.info("logMessage contactCard_insert_test_600: raw_contact insert error = " + error); + done(); + } + }); + + async function dataNoteInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "note", + "detail_info": "javaGangster" + }; + try { + var contactDataId1 = await DAHelper.insert(profileContactDataUri, contactDataValues1); + console.info("logMessage contactCard_insert_test_600: contactDataId1 " + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "javaGangster"); + await contactsQuery(map, "contactCard_insert_test_600_1", profileContactDataUri); + } catch (error) { + console.info("logMessage contactCard_insert_test_600: contact_data note insert error = " + error); + done(); + } + } + + async function dataAimInsert(DAHelper, rawContactId) { + var contactDataValues2 = { + "raw_contact_id": rawContactId, "content_type": "im", "detail_info": "aaaaa" + }; + try { + var contactDataId2 = await DAHelper.insert(profileContactDataUri, contactDataValues2); + console.info("logMessage contactCard_insert_test_600: contactDataId2 " + contactDataId2); + expect(contactDataId2 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "aaaaa"); + await contactsQuery(map, "contactCard_insert_test_600_2", profileContactDataUri); + } catch (error) { + console.info("logMessage contactCard_insert_test_600: contact_data aim insert error = " + error); + } + } + + async function dataEventInsert(DAHelper, rawContactId) { + var contactDataValues3 = { + "raw_contact_id": rawContactId, + "content_type": "contact_event", + "detail_info": "19960229" + }; + try { + var contactDataId3 = await DAHelper.insert(profileContactDataUri, contactDataValues3); + console.info("logMessage contactCard_insert_test_600: contactDataId3 " + contactDataId3); + expect(contactDataId3 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "19960229"); + await contactsQuery(map, "contactCard_insert_test_600_3", profileContactDataUri); + } catch (error) { + console.info("logMessage contactCard_insert_test_600: contact_data event insert error = " + error); + } + } + + /** + * @tc.number contactCard_insert_test_700 + * @tc.name Insert contact details (URL, assistant, group) + * @tc.desc Function test + */ + it("contactCard_insert_test_700", 0, async function (done) { + console.info("------logMessage contactCard_insert_test_700 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocheng", + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_insert_test_700: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await dataWebsiteInsert(DAHelper, rawContactId); + await dataRelationInsert(DAHelper, rawContactId); + await dataWebsiteInsert(DAHelper, rawContactId); + await deleteRawContact("contactCard_insert_test_700"); + await deleteAll(profileContactDataUri, "contactCard_insert_test_700"); + done(); + } catch (error) { + console.info("logMessage contactCard_insert_test_700: raw_contact insert error = " + error); + done(); + } + }); + + async function dataWebsiteInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "website", + "detail_info": "www.com" + }; + try { + var contactDataId1 = await DAHelper.insert(profileContactDataUri, contactDataValues1); + sleep(1000); + console.info("logMessage contactCard_insert_test_700: contactDataId1 " + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "www.com"); + await contactsQuery(map, "contactCard_insert_test_700_1", profileContactDataUri); + await contactDataRelationInsert(); + } catch (error) { + console.info("logMessage contactCard_insert_test_700: contact_data website insert error = " + error); + } + } + + async function dataRelationInsert(DAHelper, rawContactId) { + var contactDataValues2 = { + "raw_contact_id": rawContactId, + "content_type": "relation", + "detail_info": "Secretary" + }; + try { + var contactDataId2 = await DAHelper.insert(profileContactDataUri, contactDataValues2); + sleep(1000); + console.info("logMessage contactCard_insert_test_700: contactDataId2 " + contactDataId2); + expect(contactDataId2 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId2.toString()); + map.set("detail_info", "Secretary"); + await contactsQuery(map, "contactCard_insert_test_700_2", profileContactDataUri); + await contactDataGroupInsert(); + } catch (error) { + console.info("logMessage contactCard_insert_test_700: contact_data relation insert error = " + error); + } + } + + async function dataGroupInsert(DAHelper, rawContactId) { + var contactDataValues3 = { + "raw_contact_id": rawContactId, + "content_type": "group_membership", + "detail_info": "1" + }; + try { + var contactDataId3 = await DAHelper.insert(profileContactDataUri, contactDataValues3); + sleep(1000); + console.info("logMessage contactCard_insert_test_700: contactDataId3 " + contactDataId3); + expect(contactDataId3 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId3.toString()); + map.set("detail_info", "1"); + await contactsQuery(map, "contactCard_insert_test_700_3", profileContactDataUri); + done(); + } catch (error) { + console.info("logMessage contactCard_insert_test_700: contact_data group insert error = " + error); + } + } + + /** + * @tc.number contactCard_insert_test_800 + * @tc.name Insert contact details (phone ringtone) + * @tc.desc Function test + */ + it("contactCard_insert_test_800", 0, async function (done) { + console.info("------logMessage contactCard_insert_test_800 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocheng", + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_insert_test_800: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await dataMiscInsert(DAHelper, rawContactId); + await deleteRawContact("contactCard_insert_test_800"); + await deleteAll(profileContactDataUri, "contactCard_insert_test_800"); + done(); + } catch (error) { + console.info("logMessage contactCard_insert_test_800: raw_contact insert error = " + error); + done(); + } + }); + + async function dataMiscInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "contact_misc", + "detail_info": "1234" + }; + try { + var contactDataId1 = await DAHelper.insert(profileContactDataUri, contactDataValues1); + sleep(1000); + console.info("logMessage contactCard_insert_test_800: contactDataId1 " + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "1234"); + await contactsQuery(map, "contactCard_insert_test_800_1", profileContactDataUri); + } catch (error) { + console.info("logMessage contactCard_insert_test_800: contact_data misc insert error = " + error); + } + } + + /** + * @tc.number contactCard_update_test_900 + * @tc.name Update contact data + * @tc.desc Function test + */ + it("contactCard_update_test_900", 0, async function (done) { + console.info("------logMessage contactCard_update_test_900 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "licheng", + "company": "TT", + "position": "developer", + "favorite": 1, + "phonetic_name": "licheng||lc" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_update_test_900: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await rawContactUpdate(DAHelper, rawContactId); + await deleteRawContact("contactCard_update_test_900"); + await deleteAll(profileContactDataUri, "contactCard_update_test_900"); + done(); + } catch (error) { + console.info("logMessage contactCard_update_test_900: raw_contact insert error = " + error); + done(); + } + }); + + async function rawContactUpdate(DAHelper, rawContactId) { + var updateValues = { + "display_name": "dacheng", + "company": "oo", + "position": "Testers", + "favorite": 0, + "phonetic_name": "dacheng||dc" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileRawContactUri, updateValues, condition); + sleep(1000); + console.info('logMessage contactCard_update_test_900: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "dacheng"); + map.set("company", "oo"); + map.set("position", "Testers"); + map.set("favorite", "0"); + map.set("phonetic_name", "dacheng||dc"); + await contactsQuery(map, "contactCard_update_test_900", profileRawContactUri); + } catch (error) { + console.info('logMessage contactCard_update_test_900: raw_contact update error = ' + error); + } + } + + /** + * @tc.number contactCard_update_test_1200 + * @tc.name Update contact details (name) + * @tc.desc Function test + */ + it("contactCard_update_test_1200", 0, async function (done) { + console.info("------logMessage contactCard_update_test_1200 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_update_test_1200: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforedataNameInsert(DAHelper, rawContactId); + await dataNameUpdate(DAHelper, rawContactId); + await deleteRawContact("contactCard_update_test_1200"); + await deleteAll(profileContactDataUri, "contactCard_update_test_1200"); + done(); + } catch (error) { + console.info('logMessage contactCard_update_test_1200: raw_contact insert error = ' + error); + done(); + } + }); + + async function beforedataNameInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": "name", "detail_info": "xiaoyuan" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contactCard_update_test_1200: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contactCard_update_test_1200: contact_data insert error = ' + error); + } + } + + async function dataNameUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "dayuan" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contactCard_update_test_1200: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "dayuan"); + await contactsQuery(map, "contactCard_update_test_1200", profileRawContactUri); + } catch (error) { + console.info('logMessage contactCard_update_test_1200: contact_data update error = ' + error); + } + } + + /** + * @tc.number contactCard_update_test_1300 + * @tc.name Update contact details (company, position) + * @tc.desc Function test + */ + it("contactCard_update_test_1300", 0, async function (done) { + console.info("------logMessage contactCard_update_test_1300 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_update_test_1300: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforedataCompanyInsert(DAHelper, rawContactId); + await dataCompanyUpdate(DAHelper, rawContactId); + await deleteRawContact("contactCard_update_test_1300"); + await deleteAll(profileContactDataUri, "contactCard_update_test_1300"); + done(); + } catch (error) { + console.info('logMessage contactCard_update_test_1300: raw_contact insert error = ' + error); + done(); + } + }); + + async function beforedataCompanyInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "organization", + "detail_info": "TT", + "position": "Testers", + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contactCard_update_test_1300: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contactCard_update_test_1300: contact_data insert error = ' + error); + } + } + + async function dataCompanyUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "OOOO", "position": "developer" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contactCard_update_test_1300: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("company", "OOOO"); + map.set("position", "developer"); + await contactsQuery(map, "contactCard_update_test_1300", profileRawContactUri); + } catch (error) { + console.info('logMessage contactCard_update_test_1300: contact_data update error = ' + error); + } + } + + /** + * @tc.number contactCard_update_test_1400 + * @tc.name Update contact details (mobile phone number) + * @tc.desc Function test + */ + it("contactCard_update_test_1400", 0, async function (done) { + console.info("------logMessage contactCard_update_test_1400 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_update_test_1400: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataPhoneInsert(DAHelper, rawContactId); + await dataPhoneUpdate(DAHelper, rawContactId); + await deleteRawContact("contactCard_update_test_1400"); + await deleteAll(profileContactDataUri, "contactCard_update_test_1400"); + done(); + } catch (error) { + console.info('logMessage contactCard_update_test_1400: raw_contact insert error = ' + error); + done(); + } + }); + + async function beforeDataPhoneInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": "phone", "detail_info": "123456" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contactCard_update_test_1400: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contactCard_update_test_1400: contact_data insert error = ' + error); + } + } + + async function dataPhoneUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "99663355" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contactCard_update_test_1400: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "99663355"); + await contactsQuery(map, "contactCard_update_test_1400", profileContactDataUri); + } catch (error) { + console.info('logMessage contactCard_update_test_1400: contact_data update error = ' + error); + } + } + + /** + * @tc.number contactCard_update_test_1500 + * @tc.name Update contact details (nickname) + * @tc.desc Function test + */ + it("contactCard_update_test_1500", 0, async function (done) { + console.info("------logMessage contactCard_update_test_1500 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_update_test_1500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforedataNickNameInsert(DAHelper, rawContactId); + await dataNickNameUpdate(DAHelper, rawContactId); + await deleteRawContact("contactCard_update_test_1500"); + await deleteAll(profileContactDataUri, "contactCard_update_test_1500"); + done(); + } catch (error) { + console.info('logMessage contactCard_update_test_1500: raw_contact insert error = ' + error); + done(); + } + }); + + async function beforedataNickNameInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "nickname", + "detail_info": "xiaoyuan" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contactCard_update_test_1500: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contactCard_update_test_1500: contact_data insert error = ' + error); + } + } + + async function dataNickNameUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "fengyuan" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contactCard_update_test_1500: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "fengyuan"); + await contactsQuery(map, "contactCard_update_test_1500", profileContactDataUri); + } catch (error) { + console.info('logMessage contactCard_update_test_1500: contact_data update error = ' + error); + } + } + + /** + * @tc.number contactCard_update_test_1600 + * @tc.name Update contact details (email) + * @tc.desc Function test + */ + it("contactCard_update_test_1600", 0, async function (done) { + console.info("------logMessage contactCard_update_test_1600 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_update_test_1600: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataEmailInsert(DAHelper, rawContactId); + await dataEmailUpdate(DAHelper, rawContactId); + await deleteRawContact("contactCard_update_test_1600"); + await deleteAll(profileContactDataUri, "contactCard_update_test_1600"); + done(); + } catch (error) { + console.info("logMessage contactCard_update_test_1600: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataEmailInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "email", + "detail_info": "166@163.com" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contactCard_update_test_1600: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contactCard_update_test_1600: contact_data insert error = ' + error); + } + } + + async function dataEmailUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "199@163.com" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileContactDataUri, updateValues, condition) + sleep(1000); + console.info('logMessage contactCard_update_test_1600: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "199@163.com"); + await contactsQuery(map, "contactCard_update_test_1600", profileContactDataUri); + } catch (error) { + console.info('logMessage contactCard_update_test_1600: update error = ' + error); + } + } + + /** + * @tc.number contactCard_update_test_1700 + * @tc.name Update Contact Details (Residential) + * @tc.desc Function test + */ + it("contactCard_update_test_1700", 0, async function (done) { + console.info("------logMessage contactCard_update_test_1700 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_update_test_1700: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataPostalInsert(DAHelper, rawContactId); + await dataPostalUpdate(); + await deleteRawContact("contactCard_update_test_1700"); + await deleteAll(profileContactDataUri, "contactCard_update_test_1700"); + done(); + } catch (error) { + console.info("logMessage contactCard_update_test_1700: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataPostalInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "postal_address", + "detail_info": "NanJing" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contactCard_update_test_1700: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_update_test_1700: contact_data insert error = " + error); + } + } + + async function dataPostalUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "BeiJing" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contactCard_update_test_1700: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "BeiJing"); + await contactsQuery(map, "contactCard_update_test_1700", profileContactDataUri); + } catch (error) { + console.info('logMessage contactCard_update_test_1700: update error = ' + error); + } + } + + /** + * @tc.number contactCard_update_test_1800 + * @tc.name Update contact details (remarks) + * @tc.desc Function test + */ + it("contactCard_update_test_1800", 0, async function (done) { + console.info("------logMessage contactCard_update_test_1800 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_update_test_1800: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforedataNoteInsert(DAHelper, rawContactId); + await dataNoteUpdate(DAHelper, rawContactId); + await deleteRawContact("contactCard_update_test_1800"); + await deleteAll(profileContactDataUri, "contactCard_update_test_1800"); + done(); + } catch (error) { + console.info("logMessage contactCard_update_test_1800: raw_contact insert error = " + error); + done(); + } + }); + + async function beforedataNoteInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": "note", "detail_info": "Gangster" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contactCard_update_test_1800: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contactCard_update_test_1800: contact_data insert error = ' + error); + } + } + + async function dataNoteUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "God" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contactCard_update_test_1800: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "God"); + await contactsQuery(map, "contactCard_update_test_1800", profileContactDataUri); + } catch (error) { + console.info('logMessage contactCard_update_test_1800: update error = ' + error); + } + } + + /** + * @tc.number contactCard_update_test_1900 + * @tc.name Update Contact Details (AIM) + * @tc.desc Function test + */ + it("contactCard_update_test_1900", 0, async function (done) { + console.info("------logMessage contactCard_update_test_1900 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues) + console.info("logMessage contactCard_update_test_1900: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataAimInsert(DAHelper, rawContactId); + await dataAimUpdate(DAHelper, rawContactId); + await deleteRawContact("contactCard_update_test_1900"); + await deleteAll(profileContactDataUri, "contactCard_update_test_1900"); + done(); + } catch (error) { + console.info("logMessage contactCard_update_test_1900: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataAimInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": "im", "detail_info": "aaaaa" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contactCard_update_test_1900: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_update_test_1900: contact_data insert error = " + error); + } + } + + async function dataAimUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "bbbbb" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contactCard_update_test_1900: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "bbbbb"); + await contactsQuery(map, "contactCard_update_test_1900", profileContactDataUri); + } catch (error) { + console.info('logMessage contactCard_update_test_1900: update error = ' + error); + } + } + + /** + * @tc.number contactCard_update_test_2000 + * @tc.name Update Contact Details (Birthday) + * @tc.desc Function test + */ + it("contactCard_update_test_2000", 0, async function (done) { + console.info("------logMessage contactCard_update_test_2000 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_update_test_2000: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataEventInsert(DAHelper, rawContactId); + await dataEventUpdate(DAHelper, rawContactId); + await deleteRawContact("contactCard_update_test_2000"); + await deleteAll(profileContactDataUri, "contactCard_update_test_2000"); + done(); + } catch (error) { + console.info("logMessage contactCard_update_test_2000: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataEventInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "contact_event", + "detail_info": "19960229" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues1); + sleep(1000); + console.info('logMessage contactCard_update_test_2000: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contactCard_update_test_2000: contact_data insert error = ' + error); + } + } + + async function dataEventUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "19971021" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contactCard_update_test_2000: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "19971021"); + await contactsQuery(map, "contactCard_update_test_2000", profileContactDataUri); + } catch (error) { + console.info('logMessage contactCard_update_test_2000: update error = ' + error); + } + } + + /** + * @tc.number contactCard_update_test_2100 + * @tc.name Update contact details (website) + * @tc.desc Function test + */ + it("contactCard_update_test_2100", 0, async function (done) { + console.info("------logMessage contactCard_update_test_2100 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_update_test_2100: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataWebsiteInsert(DAHelper, rawContactId); + await dataWebsiteUpdate(DAHelper, rawContactId); + await deleteRawContact("contactCard_update_test_2100"); + await deleteAll(profileContactDataUri, "contactCard_update_test_2100"); + done(); + } catch (error) { + console.info("logMessage contactCard_update_test_2100: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataWebsiteInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "website", + "detail_info": "www.com" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues1); + sleep(1000); + console.info('logMessage contactCard_update_test_2100: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contactCard_update_test_2100: contact_data insert error = ' + error); + } + } + + async function dataWebsiteUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "www.123.com" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contactCard_update_test_2100: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "www.123.com"); + await contactsQuery(map, "contactCard_update_test_2100", profileContactDataUri); + } catch (error) { + console.info('logMessage contactCard_update_test_2100: update error = ' + error); + } + } + + /** + * @tc.number contactCard_update_test_2200 + * @tc.name Update contact details (assistant) + * @tc.desc Function test + */ + it("contactCard_update_test_2200", 0, async function (done) { + console.info("------logMessage contactCard_update_test_2200 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_update_test_2200: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataRelationInsert(DAHelper, rawContactId); + await dataRelationUpdate(DAHelper, rawContactId); + await deleteRawContact("contactCard_update_test_2200"); + await deleteAll(profileContactDataUri, "contactCard_update_test_2200"); + done(); + } catch (error) { + console.info("logMessage contactCard_update_test_2200: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataRelationInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "relation", + "detail_info": "Secretary" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + console.info('logMessage contactCard_update_test_2200: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contactCard_update_test_2200: contact_data insert error = ' + error); + } + } + + async function dataRelationUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "spouse" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contactCard_update_test_2200: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "spouse"); + await contactsQuery(map, "contactCard_update_test_2200", profileContactDataUri); + } catch (error) { + console.info('logMessage contactCard_update_test_2200: update error = ' + error); + } + } + + /** + * @tc.number contactCard_update_test_2300 + * @tc.name Update contact detail data table (group) + * @tc.desc Function test + */ + it("contactCard_update_test_2300", 0, async function (done) { + console.info("------logMessage contactCard_update_test_2300 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_update_test_2300: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataGroupInsert(DAHelper, rawContactId); + await dataGroupUpdate(DAHelper, rawContactId); + await deleteRawContact("contactCard_update_test_2300"); + await deleteAll(profileContactDataUri, "contactCard_update_test_2300"); + done(); + } catch (error) { + console.info("logMessage contactCard_update_test_2300: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataGroupInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "group_membership", + "detail_info": "2" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contactCard_update_test_2300: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contactCard_update_test_2300: contact_data insert error = ' + error); + } + } + + async function dataGroupUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "7" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contactCard_update_test_2300: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "3"); + await contactsQuery(map, "contactCard_update_test_2300", profileContactDataUri); + } catch (error) { + console.info('logMessage contactCard_update_test_2300: update error = ' + error); + } + } + + /** + * @tc.number contactCard_update_test_2400 + * @tc.name Update contact detail data table (phone ringtone) + * @tc.desc Function test + */ + it("contactCard_update_test_2400", 0, async function (done) { + console.info("------logMessage contactCard_update_test_2400 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + sleep(1000); + console.info("logMessage contactCard_update_test_2400: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataMiscInsert(DAHelper, rawContactId); + await dataMiscUpdate(DAHelper, rawContactId); + await deleteRawContact("contactCard_update_test_2400"); + await deleteAll(profileContactDataUri, "contactCard_update_test_2400"); + done(); + } catch (error) { + console.info("logMessage contactCard_update_test_2400: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataMiscInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "contact_misc", + "detail_info": "1234" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues1); + sleep(1000); + console.info('logMessage contactCard_update_test_2400: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contactCard_update_test_2400: contact_data insert error = ' + error); + } + } + + async function dataMiscUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "999" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contactCard_update_test_2400: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "999"); + await contactsQuery(map, "contactCard_update_test_2300", profileContactDataUri); + } catch (error) { + console.info('logMessage contactCard_update_test_2400: update error = ' + error); + } + } + + /** + * @tc.number contactCard_favorite_test_2500 + * @tc.name Favorite contacts + * @tc.desc Function test + */ + it("contactCard_favorite_test_2500", 0, async function (done) { + console.info("-------logMessage contactCard_favorite_test_2500 is starting!------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaocai", "company": "TT", "position": "Testers" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues) + console.info('logMessage contactCard_favorite_test_2500: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await updateFavorite(DAHelper, rawContactId); + await deleteRawContact("contactCard_favorite_test_2500"); + done(); + } catch (error) { + console.info('logMessage contactCard_favorite_test_2500: raw_contact insert error = ' + error); + done(); + } + }); + + async function updateFavorite(DAHelper, rawContactId) { + var updateValues = { + "favorite": 1 + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileRawContactUri, updateValues, condition); + sleep(1000); + console.info("logMessage contactCard_favorite_test_2500: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "xiaocai"); + map.set("company", "TT"); + map.set("position", "Testers"); + map.set("favorite", "1"); + await contactsQuery(map, "contactCard_favorite_test_2500", profileRawContactUri); + } catch (error) { + console.info('logMessage contactCard_favorite_test_2500: update error = ' + error); + } + } + + /** + * @tc.number contactCard_unfavorite_test_2600 + * @tc.name Unfavorite contacts + * @tc.desc Function test + */ + it("contactCard_unfavorite_test_2600", 0, async function (done) { + console.info("-------logMessage contactCard_unfavorite_test_2600 is starting!------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var rawContactValues = { + "display_name": "xiaohong", "company": "TT", "position": "Testers", "favorite": 1 + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + console.info('logMessage contactCard_unfavorite_test_2600: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await updateUnFavorite(DAHelper, rawContactId); + await deleteRawContact("contactCard_unfavorite_test_2600"); + done(); + } catch (error) { + console.info('logMessage contactCard_unfavorite_test_2600: raw_contact insert error = ' + error); + done(); + } + }); + + async function updateUnFavorite(DAHelper, rawContactId) { + var updateValues = { + "favorite": 0 + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(profileRawContactUri, updateValues, condition); + sleep(1000); + console.info("logMessage contactCard_unfavorite_test_2600: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "xiaohong"); + map.set("company", "TT"); + map.set("position", "Testers"); + map.set("favorite", "0"); + await contactsQuery(map, "contactCard_favorite_test_2500", profileRawContactUri); + } catch (error) { + console.info("logMessage contactCard_unfavorite_test_2600: update error = " + error); + } + } + + /** + * @tc.number contactCard_insert_test_2700 + * @tc.name Insert contact black list + * @tc.desc Function test + */ + it("contactCard_insert_test_2700", 0, async function (done) { + console.info("-------logMessage contactCard_insert_test_2700 is starting!------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var blocklistId = await DAHelper.insert(profileBlocklistUri, common.getProfileBlockList()); + sleep(1000); + console.info('logMessage contactCard_insert_test_2700: blocklistId = ' + blocklistId); + expect(blocklistId > 0).assertTrue(); + var map = common.getProfileBlockListMap(); + map.set("id", blocklistId.toString()); + await contactsQuery(map, "contactCard_insert_test_2700", profileBlocklistUri); + await deleteAll(profileBlocklistUri, "contactCard_insert_test_2700"); + done(); + } catch (error) { + console.info('logMessage contactCard_insert_test_2700: blocklist insert error = ' + error); + done(); + } + }); + + /** + * @tc.number contactCard_delete_test_2800 + * @tc.name Delete contact black list + * @tc.desc Function test + */ + it("contactCard_delete_test_2800", 0, async function (done) { + console.info("-------logMessage contactCard_delete_test_2800 is starting!------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var blocklistId = await DAHelper.insert(profileBlocklistUri, common.getProfileBlockList()); + sleep(1000); + console.info('logMessage contactCard_delete_test_2800: blocklistId = ' + blocklistId); + expect(blocklistId > 0).assertTrue(); + await blocklistDelete(); + done(); + } catch (error) { + console.info('logMessage contactCard_delete_test_2800: blocklist insert error = ' + error); + done(); + } + + async function blocklistDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", blocklistId.toString()); + try { + var deleteCode = await DAHelper.delete(profileBlocklistUri, condition); + sleep(1000); + console.info("logMessage contactCard_delete_test_2800: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + var map = new Map(); + map.set("id", blocklistId.toString()); + await queryIdForDelete(map, "contactCard_delete_test_2800", profileBlocklistUri); + } catch (error) { + console.info('logMessage contactCard_delete_test_2800: delete error = ' + error); + done(); + } + } + }); + + /** + * @tc.number contactCard_insert_test_2900 + * @tc.name Insert contact group + * @tc.desc Function test + */ + it("contactCard_insert_test_2900", 0, async function (done) { + console.info("-------logMessage contactCard_insert_test_2900 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var groupValues = { + "group_name": "TestersThird" + }; + try { + var groupId = await DAHelper.insert(profileGroupUri, groupValues); + sleep(1000); + console.info("logMessage contactCard_insert_test_2900: groupId =" + groupId); + expect(groupId > 0).assertTrue(); + await groupRawContactInsert(DAHelper); + await deleteRawContact("contactCard_insert_test_2900"); + await deleteAll(profileGroupUri, "contactCard_insert_test_2900"); + await deleteAll(profileContactDataUri, "contactCard_insert_test_2900"); + done(); + } catch (error) { + console.info("logMessage contactCard_insert_test_2900: group insert error =" + error); + done(); + } + }); + + async function groupRawContactInsert(DAHelper) { + var rawContactValues = { + "display_name": "liyu" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contactCard_insert_test_2900: rawContactId =" + rawContactId); + expect(rawContactId > 0).assertTrue(); + await groupDataInsert(DAHelper, rawContactId); + } catch (error) { + console.info("logMessage contactCard_insert_test_2900: raw_contact insert error =" + error); + } + } + + async function groupDataInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "group_membership", + "detail_info": groupId.toString() + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues) + sleep(1000); + console.info("logMessage contactCard_insert_test_2900: contactDataId =" + contactDataId); + expect(contactDataId > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId); + map.set("raw_contact_id", rawContactId.toString()); + map.set("detail_info", groupId.toString()); + await contactsQuery(map, "contactCard_insert_test_2900", profileContactDataUri); + } catch (error) { + console.info("logMessage contactCard_insert_test_2900: contact_data insert error =" + error); + } + } + + /** + * @tc.number contactCard_delete_test_3000 + * @tc.name Delete contact group + * @tc.desc Function test + */ + it("contactCard_delete_test_3000", 0, async function (done) { + console.info("-------logMessage contactCard_delete_test_3000 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var groupValues = { + "group_name": "TestersFourth" + }; + try { + var groupId = await DAHelper.insert(profileGroupUri, groupValues); + sleep(1000); + console.info("logMessage contactCard_delete_test_3000: groupId =" + groupId); + expect(groupId > 0).assertTrue(); + await groupAfterRawContactInsert(DAHelper); + await deleteRawContact("contactCard_delete_test_3000"); + await deleteAll(profileGroupUri, "contactCard_delete_test_3000"); + await deleteAll(profileContactDataUri, "contactCard_delete_test_3000"); + done(); + } catch (error) { + console.info("logMessage contactCard_delete_test_3000: group insert error =" + error); + done(); + } + }); + + async function groupAfterRawContactInsert(DAHelper) { + var rawContactValues = { + "display_name": "liyuchen" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contactCard_delete_test_3000: rawContactId =" + rawContactId); + expect(rawContactId > 0).assertTrue(); + await deleteGroupContactDataInsert(DAHelper, rawContactId); + } catch (error) { + console.info("logMessage contactCard_delete_test_3000: raw_contact insert error =" + error); + } + } + + async function deleteGroupContactDataInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "group_membership", + "detail_info": groupId.toString() + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + console.info("logMessage contactCard_delete_test_3000: contactDataId =" + contactDataId); + expect(contactDataId > 0).assertTrue(); + await deleteGroup(DAHelper, contactDataId); + } catch (error) { + console.info("logMessage contactCard_delete_test_3000: contact_data insert error =" + error); + } + } + + async function deleteGroup(DAHelper, contactDataId) { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", contactDataId.toString()); + try { + var deleteCode = await DAHelper.delete(profileContactDataUri, condition); + sleep(1000); + console.info("logMessage contactCard_delete_test_3000: deleteCode =" + deleteCode); + expect(deleteCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + await queryIdForDelete(map, "contactCard_delete_test_3000", profileContactDataUri); + } catch (error) { + console.info("logMessage contactCard_delete_test_3000: delete error =" + error); + } + } + + /** + * @tc.number contactCard_query_test_3100 + * @tc.name Query basic information of a single contact + * @tc.desc Function test + */ + it("contactCard_query_test_3100", 0, async function (done) { + console.info("-----------logMessage contactCard_query_test_3100 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoyu" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contactCard_query_test_3100: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await rawContactQuery(DAHelper, rawContactId); + await deleteRawContact("contactCard_query_test_3100"); + done(); + } catch (error) { + console.info("logMessage contactCard_query_test_3100: raw_contact insert error = " + error); + done(); + } + }); + + async function rawContactQuery(DAHelper, rawContactId) { + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + sleep(2000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_query_test_3100: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId).assertEqual(true); + console.info('logMessage contactCard_query_test_3100: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "xiaoyu").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contactCard_query_test_3100: query error = " + error); + } + } + + /** + * @tc.number contactCard_query_test_3200 + * @tc.name Query basic information of multiple contacts + * @tc.desc Function test + */ + it("contactCard_query_test_3200", 0, async function (done) { + console.info("-----------logMessage contactCard_query_test_3200 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues1 = { + "display_name": "xiaoyu" + }; + try { + var rawContactIdFirst = await DAHelper.insert(profileRawContactUri, rawContactValues1); + sleep(1000); + console.info("logMessage contactCard_query_test_3200: rawContactId = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_query_test_3200: raw_contact_1 insert error = " + error); + done(); + } + + var rawContactValues2 = { + "display_name": "xiaohong" + }; + try { + var rawContactIdSecond = await DAHelper.insert(profileRawContactUri, rawContactValues2); + sleep(1000); + console.info("logMessage contactCard_query_test_3200: rawContactId = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + await queryTwoRaw(DAHelper, rawContactIdFirst, rawContactIdSecond); + await deleteRawContact("contactCard_query_test_3200"); + done(); + } catch (error) { + console.info("logMessage contactCard_query_test_3200: raw_contact_2 insert error = " + error); + done(); + } + }); + + async function queryTwoRaw(DAHelper, rawContactIdFirst, rawContactIdSecond) { + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactIdFirst.toString()); + condition.or(); + condition.equalTo("id", rawContactIdSecond.toString()); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + sleep(1000); + console.info('logMessage contactCard_query_test_3200: goToFirstRow' + resultSet.goToFirstRow()); + expect(resultSet.goToFirstRow()).assertEqual(true); + if (resultSet.goToFirstRow()) { + do { + console.info("logMessage contactCard_query_test_3200: columnNames :" + resultSet.columnNames); + console.info("logMessage contactCard_query_test_3200: columnCount:" + resultSet.columnCount); + console.info('logMessage contactCard_query_test_3200: id = ' + resultSet.getString(0)); + console.info('logMessage contactCard_query_test_3200: displayName = ' + resultSet.getString(1)); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_query_test_3200: query error' + error); + } + } + + /** + * @tc.number contactCard_query_test_3300 + * @tc.name Query basic information of all contacts + * @tc.desc Function test + */ + it("contactCard_query_test_3300", 0, async function (done) { + console.info("-----------logMessage contactCard_query_test_3300 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues1 = { + "display_name": "xiaoyu" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues1); + sleep(1000); + console.info("logMessage contactCard_query_test_3300: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_query_test_3300: raw_contact_1 insert error = " + error); + done(); + } + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_query_test_3300: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertEqual(true); + console.info('logMessage contactCard_query_test_3300: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "xiaoyu").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + await deleteRawContact("contactCard_query_test_3300"); + done(); + } catch (error) { + console.info("logMessage contactCard_query_test_3300: query error = " + error); + done(); + } + }); + + /** + * @tc.number contactCard_query_test_3400 + * @tc.name Query all information of a single contact + * @tc.desc Function test + */ + it("contactCard_query_test_3400", 0, async function (done) { + console.info("-----------logMessage contactCard_query_test_3400 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoyuzhou", + "company": "TT", + "position": "Testers", + "favorite": 1, + "phonetic_name": "xiaoyu||xy" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contactCard_query_test_3400: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await queryAllInformation(DAHelper, rawContactId); + await deleteRawContact("contactCard_query_test_3400"); + done(); + } catch (error) { + console.info("logMessage contactCard_query_test_3400: raw_contact insert error = " + error); + done(); + } + }); + + async function queryAllInformation(DAHelper, rawContactId) { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + var id = resultSet.getString(resultSet.getColumnIndex("id")); + console.info('logMessage contactCard_query_test_3400: id = ' + id); + expect(id == rawContactId).assertEqual(true); + var favorite = resultSet.getString(resultSet.getColumnIndex("favorite")); + console.info('logMessage contactCard_query_test_3400: favorite = ' + favorite); + expect(favorite == "1").assertEqual(true); + var phoneticName = resultSet.getString(resultSet.getColumnIndex("phonetic_name")); + console.info('logMessage contactCard_query_test_3400: phoneticName = ' + phonetic_name); + expect(phoneticName == "xiaoyu||xy").assertEqual(true); + var company = resultSet.getString(resultSet.getColumnIndex("company")); + console.info('logMessage contactCard_query_test_3400: company = ' + company); + expect(company == "TT").assertEqual(true); + var displayName = resultSet.getString(resultSet.getColumnIndex("display_name")); + console.info('logMessage contactCard_query_test_3400: displayName = ' + displayName); + expect(displayName == "xiaoyuzhou").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_query_test_3400: query error = ' + error); + } + } + + /** + * @tc.number contactCard_query_test_3500 + * @tc.name Query group member ability + * @tc.desc Function test + */ + it("contactCard_query_test_3500", 0, async function (done) { + console.info("-----------logMessage contactCard_query_test_3500 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var rawContactValues = { + "display_name": "xiaoyuzhou" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contactCard_query_test_3500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_query_test_3500: raw_contact insert error = " + error); + done(); + } + var groupValues = { + "group_name": "BossBoard3500" + }; + try { + var groupId = await DAHelper.insert(profileGroupUri, groupValues); + sleep(1000); + console.info("logMessage contactCard_query_test_3500: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_query_test_3500: group insert error = " + error); + done(); + } + await groupBossBoardInsert(DAHelper, rawContactId, groupId); + await deleteRawContact("contactCard_query_test_3500"); + await deleteAll(profileGroupUri, "contactCard_query_test_3500"); + await deleteAll(profileContactDataUri, "contactCard_query_test_3500"); + done(); + }); + + async function groupBossBoardInsert(DAHelper, rawContactId, groupId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "group_membership", + "detail_info": groupId.toString() + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info("logMessage contactCard_query_test_3500: contactDataId = " + contactDataId); + expect(contactDataId > 0).assertTrue(); + await groupBossBoardQuery(DAHelper, rawContactId, groupId); + } catch (error) { + console.info("logMessage contactCard_query_test_3500: query error = " + error); + } + } + + async function groupBossBoardQuery(DAHelper, rawContactId, groupId) { + var resultColumns = ["raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 9 data is group + condition.equalTo("type_id", "9"); + condition.and(); + condition.equalTo("detail_info", groupId.toString()); + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_query_test_3500: raw_contact_id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId).assertEqual(true); + console.info('logMessage contactCard_query_test_3500: detail_info = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == groupId.toString()).assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contactCard_query_test_3500: query error :" + error); + } + } + + /** + * @tc.number contactCard_query_test_3600 + * @tc.name Query favorite contacts + * @tc.desc Function test + */ + it("contactCard_query_test_3600", 0, async function (done) { + console.info("-----------logMessage contactCard_query_test_3600 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var rawContactValues = { + "display_name": "xiaoyuzhou", "favorite": 1 + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contactCard_query_test_3600: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await queryFavorite(); + await deleteRawContact("contactCard_query_test_3600"); + done(); + } catch (error) { + console.info("logMessage contactCard_query_test_3600: raw_contact insert error = " + error); + done(); + } + + async function queryFavorite() { + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("favorite", "1"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_query_test_3600: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertTrue(); + console.info( + 'logMessage contactCard_query_test_3600: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "xiaoyuzhou").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contactCard_query_test_3600: query error :" + error); + done(); + } + } + }); + + /** + * @tc.number contactCard_query_test_3700 + * @tc.name Query recent contact ability + * @tc.desc Function test + */ + it("contactCard_query_test_3700", 0, async function (done) { + console.info("-----------logMessage contactCard_query_test_3700 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var rawContactValues = { + "display_name": "xiaoyuzhou", "lastest_contacted_time": 60 + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contactCard_query_test_3700: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await queryContacted(); + await deleteRawContact("contactCard_query_test_3700"); + done(); + } catch (error) { + console.info("logMessage contactCard_query_test_3700: raw_contact insert error = " + error); + done(); + } + + async function queryContacted() { + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.lessThan("lastest_contacted_time", "100"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_query_test_3700: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertTrue(); + console.info( + 'logMessage contactCard_query_test_3700: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "xiaoyuzhou").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_query_test_3700: query error' + error); + done(); + } + } + }); + + /** + * @tc.number contactCard_query_test_3800 + * @tc.name Query recently deleted contacts + * @tc.desc Function test + */ + it("contactCard_query_test_3800", 0, async function (done) { + console.info("-----------logMessage contactCard_query_test_3800 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var rawContactValues = { + "display_name": "xiaocai" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contactCard_query_test_3800: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await rawContactDelete(DAHelper, rawContactId); + await deletedRawContactQuery(DAHelper, rawContactId); + await deleteAll(profileDeletedContactsUri, "contactCard_query_test_3800") + done(); + } catch (error) { + console.info("logMessage contactCard_query_test_3800: raw_contact insert error = " + error); + done(); + } + }); + + async function rawContactDelete(DAHelper, rawContactId) { + var condition1 = new ohosDataAbility.DataAbilityPredicates(); + condition1.equalTo("id", rawContactId.toString()); + try { + var deleteCode = await DAHelper.delete(profileRawContactUri, condition1); + sleep(1000); + console.info('logMessage contactCard_query_test_3800: deleteCode = ' + deleteCode); + expect(deleteCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_query_test_3800: raw_contact delete error = " + error); + done(); + } + } + + async function deletedRawContactQuery(DAHelper, rawContactId) { + var resultColumns = ["id", "raw_contact_id", "display_name", "is_deleted"]; + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + condition2.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(deletedprofileRawContactUri, resultColumns, condition2); + sleep(1000); + if (resultSet.goToFirstRow()) { + console.info('logMessage contactCard_query_test_3800: id = ' + resultSet.getString(0)); + console.info('logMessage contactCard_query_test_3800: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertTrue(); + console.info('logMessage contactCard_query_test_3800: displayName = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "xiaocai").assertTrue(); + console.info('logMessage contactCard_query_test_3800: is_deleted = ' + resultSet.getString(3)); + expect(resultSet.getString(3) == "1").assertTrue(); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contactCard_query_test_3800: query error :" + error); + done(); + } + } + + /** + * @tc.number contactCard_query_test_3900 + * @tc.name Query all mobile phone numbers + * @tc.desc Function test + */ + it("contactCard_query_test_3900", 0, async function (done) { + console.info("-----------logMessage contactCard_query_test_3900 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var rawContactValues = { + "display_name": "xiaocai" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contactCard_query_test_3900: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await queryPhoneInsert(); + await phoneQuery(rawContactId); + await deleteRawContact("contactCard_query_test_3900"); + await deleteAll(profileContactDataUri, "contactCard_query_test_3900"); + done(); + } catch (error) { + console.info("logMessage contactCard_query_test_3900: raw_contact insert error = " + error); + done(); + } + }); + + async function queryPhoneInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "phone", + "detail_info": "1853696321" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info("logMessage contactCard_query_test_3900: contactDataId = " + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_query_test_3900: contact_data insert error = " + error); + } + } + + async function phoneQuery(DAHelper, rawContactId) { + var resultColumns = ["raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 5 data is phone + condition.equalTo("content_type", "phone"); + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_query_test_3900: raw_contact_id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertTrue(); + console.info('logMessage contactCard_query_test_3900: detail_info = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "1853696321").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_query_test_3900: query error' + error); + } + } + + /** + * @tc.number contactCard_query_test_4000 + * @tc.name Query all mailbox capabilities + * @tc.desc Function test + */ + it("contactCard_query_test_4000", 0, async function (done) { + console.info("-----------logMessage contactCard_query_test_4000 is starting!------------"); + + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoyu" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contactCard_query_test_4000: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await queryEmailInsert(DAHelper, rawContactId); + await emailQuery(DAHelper, contactDataId, rawContactId); + await deleteRawContact("contactCard_query_test_4000"); + await deleteAll(profileContactDataUri, "contactCard_query_test_4000"); + done(); + } catch (error) { + console.info("logMessage contactCard_query_test_4000: raw_contact insert error = " + error); + done(); + } + }); + + async function queryEmailInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "email", + "detail_info": "16658@163.com" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info("logMessage contactCard_query_test_4000: contactDataId = " + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_query_test_4000: contact_data insert error = " + error); + } + } + + async function emailQuery(DAHelper, contactDataId, rawContactId) { + var resultColumns = ["id", "raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 1 data content_type is email + condition.equalTo("type_id", "1").limitAs(3).orderByDesc("id"); + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_query_test_4000: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == contactDataId.toString()).assertTrue(); + console.info('logMessage contactCard_query_test_4000: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertTrue(); + console.info('logMessage contactCard_query_test_4000: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "16658@163.com").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contactCard_query_test_4000: query error :" + error); + } + } + + /** + * @tc.number contactCard_query_test_4100 + * @tc.name Query data information of a single contact + * @tc.desc Function test + */ + it("contactCard_query_test_4100", 0, async function (done) { + console.info("-----------logMessage contactCard_query_test_4100 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoyu" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contactCard_query_test_4100: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await queryTwoDataInsert(DAHelper, rawContactId); + await queryTwoDataInsertCompany(DAHelper, rawContactId); + await queryTwo(DAHelper, rawContactId); + await deleteRawContact("contactCard_query_test_4100"); + await deleteAll(profileContactDataUri, "contactCard_query_test_4100"); + del + done(); + } catch (error) { + console.info("logMessage contactCard_query_test_4100: raw_contact insert error = " + error); + done(); + } + }); + + async function queryTwoDataInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": "name", "detail_info": "xiaoyu" + }; + try { + var contactDataId1 = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info("logMessage contactCard_query_test_4100: contactDataId = " + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_query_test_4100: contact_data name insert error = " + error); + } + } + + async function queryTwoDataInsertCompany(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "organization", + "detail_info": "OOOO", + "position": "Testers" + }; + try { + var contactDataId2 = await DAHelper.insert(profileContactDataUri, contactDataValues); + console.info("logMessage contactCard_query_test_4100: contactDataId = " + contactDataId2); + expect(contactDataId2 > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_query_test_4100: contact_data company insert error = " + error); + } + } + + async function queryTwo(DAHelper, rawContactId) { + var resultColumns = ["id", "raw_contact_id", "detail_info", "position"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + sleep(1000); + var array = [{ + detail_info: "xiaoyu", position: "" + }, { + detail_info: "OOOO", position: "Testers" + }]; + var i = 0; + if (resultSet.goToFirstRow()) { + do { + console.info("logMessage contactCard_query_test_4100: columnNames :" + resultSet.columnNames); + console.info("logMessage contactCard_query_test_4100: columnCount:" + resultSet.columnCount); + console.info('logMessage contactCard_query_test_4100: id = ' + resultSet.getString(0)); + console.info('logMessage contactCard_query_test_4100: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertEqual(true); + console.info('logMessage contactCard_query_test_4100: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == array[i].detail_info).assertEqual(true); + console.info('logMessage contactCard_query_test_4100: position = ' + resultSet.getString(3)); + expect(resultSet.getString(3) == array[i].position).assertEqual(true); + i++; + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contactCard_query_test_4100: query error :" + error); + } + } + + /** + * @tc.number contactCard_delete_test_4400 + * @tc.name Delete the basic raw data of the contact and record the deleted basic raw data + * @tc.desc Function test + */ + it("contactCard_delete_test_4400", 0, async function (done) { + console.info("-------logMessage contactCard_delete_test_4400 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoming" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + sleep(1000); + console.info("logMessage contactCard_delete_test_4400: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await deleteRaw(DAHelper, rawContactId); + await queryDelete(DAHelper, rawContactId); + done(); + } catch (error) { + console.info("logMessage contactCard_delete_test_4400: raw_contact insert error :" + error); + done(); + } + }); + + async function deleteRaw(DAHelper, rawContactId) { + var condition1 = new ohosDataAbility.DataAbilityPredicates(); + condition1.equalTo("id", rawContactId.toString()); + try { + var deleteCode = await DAHelper.delete(profileRawContactUri, condition1); + sleep(1000); + console.info("logMessage contactCard_delete_test_4400: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_delete_test_4400: delete error = " + error); + } + } + + async function queryDelete(DAHelper, rawContactId) { + var resultColumns = ["id", "delete_time", "display_name"]; + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + condition2.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(deletedprofileRawContactUri, resultColumns, condition2); + sleep(1000); + if (resultSet.goToFirstRow()) { + console.info("logMessage contactCard_delete_test_4400: columnNames:" + resultSet.columnNames); + console.info("logMessage contactCard_delete_test_4400: columnCount:" + resultSet.columnCount); + console.info('logMessage contactCard_delete_test_4400: id = ' + resultSet.getString(0)); + console.info('logMessage contactCard_delete_test_4400: delete_time = ' + resultSet.getString(1)); + console.info('logMessage contactCard_delete_test_4400: displayName = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "xiaoming").assertTrue(); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contactCard_delete_test_4400: query error:" + error); + } + } + + /** + * @tc.number contactCard_delete_test_4700 + * @tc.name Delete detailed contact data and record detailed data + * @tc.desc Function test + */ + it("contactCard_delete_test_4700", 0, async function (done) { + console.info("-------logMessage contactCard_delete_test_4700 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaozhang", "company": "OOOO", "position": "TestManager" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + sleep(1000); + console.info("logMessage contactCard_delete_test_4700: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await queryDeleteCompanyData(DAHelper, rawContactId); + await rawContactDelete(DAHelper, rawContactId); + await companyRawContactDeleteQuery(DAHelper, rawContactId); + await deleteAll(profileContactDataUri, "contactCard_delete_test_4700"); + done(); + } catch (error) { + console.info("logMessage contactCard_delete_test_4700: raw_contact insert error:" + error); + done(); + } + }); + + async function queryDeleteCompanyData(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "organization", + "detail_info": "OOOO", + "position": "TestManager" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info("logMessage contactCard_delete_test_4700: contactDataId = " + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_delete_test_4700: contact_data insert error:" + error); + } + } + + async function rawContactDelete(DAHelper, rawContactId) { + var condition1 = new ohosDataAbility.DataAbilityPredicates(); + condition1.equalTo("id", rawContactId.toString()); + try { + var deleteCode = await DAHelper.delete(profileRawContactUri, condition1); + sleep(1000); + console.info("logMessage contactCard_delete_test_4700: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_delete_test_4700: delete error = " + error); + done(); + } + } + + async function companyRawContactDeleteQuery(DAHelper, rawContactId) { + var resultColumns = ["id", "display_name", "backup_data"]; + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + condition2.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(deletedprofileRawContactUri, resultColumns, condition2); + sleep(1000); + if (resultSet.goToFirstRow()) { + console.info("logMessage contactCard_delete_test_4700: columnNames:" + resultSet.columnNames); + console.info("logMessage contactCard_delete_test_4700: columnCount:" + resultSet.columnCount); + console.info('logMessage contactCard_delete_test_4700: id = ' + resultSet.getString(0)); + console.info('logMessage contactCard_delete_test_4700: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "xiaozhang").assertEqual(true); + console.info('logMessage contactCard_delete_test_4700: backup_data = ' + resultSet.getString(2)); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contactCard_delete_test_4700: query error:" + error); + } + } + + /** + * @tc.number contactCard_delete_test_4800 + * @tc.name Delete and record basic data of a single contact + * @tc.desc Function test + */ + it("contactCard_delete_test_4800", 0, async function (done) { + console.info("-------logMessage contactCard_delete_test_4800 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaopeng" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + sleep(1000); + console.info("logMessage contactCard_delete_test_4800: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDelete(DAHelper, rawContactId); + await deletedRawContactQuery(DAHelper, rawContactId) + await deleteAll(profileContactDataUri, "contactCard_delete_test_4800"); + done(); + } catch (error) { + console.info("logMessage contactCard_delete_test_4800: raw_contact insert error:" + error); + done(); + } + }); + + async function contactDelete(DAHelper, rawContactId) { + var condition1 = new ohosDataAbility.DataAbilityPredicates(); + condition1.equalTo("name_raw_contact_id", rawContactId.toString()); + try { + var deleteCode = await DAHelper.delete(profilecontactUri, condition1); + sleep(1000); + console.info("logMessage contactCard_delete_test_4800: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_delete_test_4800: delete error = " + error); + } + } + + async function deletedRawContactQuery(DAHelper, rawContactId) { + var resultColumns = ["id", "delete_time", "display_name"]; + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + condition2.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(deletedprofileRawContactUri, resultColumns, condition2); + sleep(1000) + if (resultSet.goToFirstRow()) { + console.info("logMessage contactCard_delete_test_4800: columnNames:" + resultSet.columnNames); + console.info("logMessage contactCard_delete_test_4800: columnCount:" + resultSet.columnCount); + console.info('logMessage contactCard_delete_test_4800: id = ' + resultSet.getString(0)); + console.info('logMessage contactCard_delete_test_4800: delete_time = ' + resultSet.getString(1)); + console.info('logMessage contactCard_delete_test_4800: displayName = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "xiaopeng").assertTrue(); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contactCard_delete_test_4800: query error:" + error); + } + } + + /** + * @tc.number contactCard_batchinsert_test_4900 + * @tc.name Insert contacts in batches(raw_contact) + * @tc.desc Function test + */ + it("contactCard_batchinsert_test_4900", 0, async function (done) { + console.info("--------logMessage contactCard_batchinsert_test_4900 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var batchInsertCode = await DAHelper.batchInsert(profileRawContactUri, common.getContactBatchCompany()); + sleep(1000); + console.info("logMessage contactCard_batchinsert_test_4900: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("company", "TT4900"); + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + console.info( + 'contactCard_batchinsert_test_4900 : queryBatch start ! resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == 5).assertEqual(true); + resultSet.close(); + await deleteRawContact("contactCard_batchinsert_test_4900"); + done(); + } catch (error) { + console.info("logMessage contactCard_batchinsert_test_4900: batchInsert error = " + error); + done(); + } + }); + + /** + * @tc.number contactCard_batchinsert_test_5000 + * @tc.name Insert contact_data in batches of address book + * @tc.desc Function test + */ + it("contactCard_batchinsert_test_5000", 0, async function (done) { + console.info("--------logMessage contactCard_batchinsert_test_5000 start!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var rawContactValues = { + "display_name": "xiaozhi" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contactCard_batchinsert_test_5000: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataBatchInsert(rawContactId); + done(); + } catch (error) { + console.info("logMessage contactCard_batchinsert_test_5000: raw_contact insert error = " + error); + done(); + } + async function contactDataBatchInsert(rawContactId) { + try { + var batchInsertCode = + await DAHelper.batchInsert(profileContactDataUri, common.getContactBatchCompanyTwo()); + sleep(1000); + console.info("logMessage contactCard_batchinsert_test_5000: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + var map = new Map(); + map.set("raw_contact_id", rawContactId.toString()); + await queryBatch(map, "contactCard_batchinsert_test_5000", 5); + await deleteRawContact("contactCard_batchinsert_test_5000"); + done(); + } catch (error) { + console.info("logMessage contactCard_batchinsert_test_5000: batchInsert error = " + error); + done(); + } + } + }); + + /** + * @tc.number contactCard_batchinsert_test_5400 + * @tc.name Batch operation of contact black list + * @tc.desc Function test + */ + it("contactCard_batchinsert_test_5400", 0, async function (done) { + console.info("--------logMessage contactCard_batchinsert_test_5400 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var batchInsertCode = await DAHelper.batchInsert(profileBlocklistUri, common.getPhoneNumberBatch()); + sleep(1000); + console.info("logMessage contactCard_batchinsert_test_5400: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + await query(5); + await blocklistDelete(); + done(); + } catch (error) { + console.info("logMessage contactCard_batchinsert_test_5400: batchInsert error = " + error); + done(); + } + + async function blocklistDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("phone_number", "85525040585400"); + try { + var deleteCode = await DAHelper.delete(profileBlocklistUri, condition); + console.info("logMessage contactCard_batchinsert_test_5400: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + await query(0); + done(); + } catch (error) { + console.info("logMessage contactCard_batchinsert_test_5400: delete error = " + error); + done(); + } + } + + async function query(size) { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("phone_number", "85525040585400"); + try { + var resultSet = await DAHelper.query(profileBlocklistUri, resultColumns, condition); + sleep(1000); + console.info('contactCard_batchinsert_test_5400 : queryBatch start ! resultSet.rowCount = ' + + resultSet.rowCount); + expect(resultSet.rowCount == size).assertEqual(true); + resultSet.close(); + } catch (error) { + console.info(" contactCard_batchinsert_test_5400 logMessage resultSet.rowCount: error = " + error); + } + } + }); + + /** + * @tc.number contactCard_update_test_5300 + * @tc.name Bulk favorites and unfavorites of contacts + * @tc.desc Function test + */ + it("contactCard_update_test_5300", 0, async function (done) { + console.info("--------logMessage contactCard_update_test_5300 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValuesOne = { + "display_name": "fengyuan", "favorite": 1 + }; + var rawContactValuesTwo = { + "display_name": "xiaoli", "favorite": 1 + }; + var rawContactValuesThree = { + "display_name": "xiaoma", "favorite": 1 + }; + var listAddBluk = [] + listAddBluk[0] = rawContactValuesOne; + listAddBluk[1] = rawContactValuesTwo; + listAddBluk[2] = rawContactValuesThree; + try { + var batchInsertCode = await DAHelper.batchInsert(profileRawContactUri, listAddBluk); + sleep(1000); + console.info("logMessage contactCard_update_test_5300: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + await rawContactUpdateUnFavorites(DAHelper); + await queryUnFavorites(DAHelper); + await deleteRawContact("contactCard_update_test_5300"); + done(); + } catch (error) { + console.info("logMessage contactCard_update_test_5300: batchInsert error = " + error); + done(); + } + }); + + async function rawContactUpdateUnFavorites(DAHelper) { + var updateValues = { + "favorite": 0 + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("display_name", "fengyuan"); + condition.or(); + condition.equalTo("display_name", "xiaoma"); + try { + var updateCode = await DAHelper.update(profileRawContactUri, updateValues, condition); + sleep(1000); + console.info("logMessage contactCard_update_test_5300: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_update_test_5300: update error = " + error); + } + } + + async function queryUnFavorites(DAHelper) { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("display_name", "fengyuan"); + condition.or(); + condition.equalTo("display_name", "xiaoma"); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + sleep(1000); + console.info( + 'contactCard_update_test_5300 : queryBatch start ! resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == 2).assertEqual(true); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var dbresult = resultSet.getString(resultSet.getColumnIndex("favorite")); + console.info(' contactCard_update_test_5300 :logMessage contactsQuery dbresult :' + dbresult + + ' value : ' + value); + expect(dbresult == "0").assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info(" contactCard_batchinsert_test_5400 logMessage resultSet.rowCount: error = " + error); + } + } + + /** + * @tc.number contactCard_batchinsert_test_5500 + * @tc.name Contacts are added to and removed from groups in batches + * @tc.desc Function test + */ + it("contactCard_batchinsert_test_5500", 0, async function (done) { + console.info("--------logMessage contactCard_batchinsert_test_5500 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var groupValues = { + "group_name": "ManagerGroup" + }; + try { + var groupId = await DAHelper.insert(profileGroupUri, groupValues); + console.info("logMessage contactCard_batchinsert_test_5500: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_batchinsert_test_5500: group insert error = " + error); + done(); + } + + try { + var rawContactValues1 = { + "display_name": "xiaohuang" + }; + var rawContactIdFirst = await DAHelper.insert(profileRawContactUri, rawContactValues1); + console.info("logMessage contactCard_batchinsert_test_5500: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_batchinsert_test_5500: raw_contact_1 insert error = " + error); + done(); + } + + try { + var rawContactValues2 = { + "display_name": "xiaolv" + }; + var rawContactIdSecond = await DAHelper.insert(profileRawContactUri, rawContactValues2); + console.info("logMessage contactCard_batchinsert_test_5500: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_batchinsert_test_5500: raw_contact_2 insert error = " + error); + done(); + } + + try { + var rawContactValues3 = { + "display_name": "xiaobai" + }; + var rawContactIdThird = await DAHelper.insert(profileRawContactUri, rawContactValues3); + console.info("logMessage contactCard_batchinsert_test_5500: rawContactIdThird = " + rawContactIdThird); + expect(rawContactIdThird > 0).assertTrue(); + } catch (error) { + console.info("logMessage contactCard_batchinsert_test_5500: raw_contact_3 insert error = " + error); + done(); + } + await threeDataInsert(DAHelper, rawContactIdFirst, rawContactIdSecond, rawContactIdThird, groupId); + await deleteRawContact("contactCard_batchinsert_test_5500"); + await deleteAll(profileGroupUri, "contactCard_batchinsert_test_5500"); + await deleteAll(profileContactDataUri, "contactCard_batchinsert_test_5500"); + done(); + }); + + async function threeDataInsert(DAHelper, rawContactIdFirst, rawContactIdSecond, rawContactIdThird, groupId) { + var contactDataValues1 = { + "raw_contact_id": rawContactIdFirst, + "content_type": "group_membership", + "detail_info": groupId.toString() + }; + var contactDataValues2 = { + "raw_contact_id": rawContactIdSecond, + "content_type": "group_membership", + "detail_info": groupId.toString() + }; + var contactDataValues3 = { + "raw_contact_id": rawContactIdThird, + "content_type": "group_membership", + "detail_info": groupId.toString() + }; + var listAddBluk = []; + listAddBluk[0] = contactDataValues1; + listAddBluk[1] = contactDataValues2; + listAddBluk[2] = contactDataValues3; + try { + var batchInsertCode = await DAHelper.batchInsert(profileContactDataUri, listAddBluk); + sleep(1000); + console.info("logMessage contactCard_batchinsert_test_5500: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + await contactDataDelete(DAHelper, rawContactIdFirst, rawContactIdThird); + } catch (error) { + console.info("logMessage contactCard_batchinsert_test_5500: batchInsert error = " + error); + } + } + + async function contactDataDelete(DAHelper, rawContactIdFirst, rawContactIdThird) { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactIdFirst.toString()); + condition.or(); + condition.equalTo("raw_contact_id", rawContactIdThird.toString()); + try { + var deleteCode = await DAHelper.delete(profileContactDataUri, condition); + sleep(1000); + console.info("logMessage contactCard_batchinsert_test_5500: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + await queryTwoData(DAHelper, rawContactIdFirst, rawContactIdThird); + } catch (error) { + console.info("logMessage contactCard_batchinsert_test_5500: delete error = " + error); + } + } + + async function queryTwoData(DAHelper, rawContactIdFirst, rawContactIdThird) { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactIdFirst.toString()); + condition.or(); + condition.equalTo("raw_contact_id", rawContactIdThird.toString()); + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + sleep(1000); + console.info( + 'contactCard_batchinsert_test_5500 : queryBatch start ! resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == 0).assertEqual(true); + resultSet.close(); + } catch (error) { + console.info(" contactCard_batchinsert_test_5400 logMessage resultSet.rowCount: error = " + error); + } + } + + /** + * @tc.number contactCard_pinyin_query_test_200 + * @tc.name Contact name to pinyin (Chinese Simplified) + * @tc.desc Function test + */ + it("contactCard_pinyin_query_test_200", 0, async function (done) { + console.info("--------logMessage contactCard_pinyin_query_test_200 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "小黄" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + console.info('logMessage contactCard_pinyin_query_test_200 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataInsert(); + await deleteRawContact("contactCard_pinyin_query_test_100"); + await deleteAll(profileContactDataUri, "contactCard_pinyin_query_test_100"); + done(); + } catch (error) { + console.info("logMessage contactCard_pinyin_query_test_200: raw_contact insert error = " + error); + done(); + } + + async function contactDataInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "name", + "detail_info": "xiaohuang" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + console.info('logMessage contactCard_pinyin_query_test_200 contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await searchQuery(DAHelper, rawContactId); + } catch (error) { + console.info('logMessage contactCard_pinyin_query_test_200 contact_data insert error = ' + error); + done(); + } + } + }); + + async function searchQuery(DAHelper, rawContactId) { + var resultColumns = ["id", "search_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(profilesearchContactUri, resultColumns, condition); + var map = common.getSearchMap(); + map.set("raw_contact_id", rawContactId.toString()); + if (resultSet.goToFirstRow()) { + do { + for (var [key, value] of map) { + var dbresult = resultSet.getString(resultSet.getColumnIndex(key)); + console.info(tag + ':contactCard_pinyin_query_test_200 key = ' + key + + ' dbresult :' + dbresult + ' value : ' + value); + expect(value == dbresult).assertEqual(true); + } + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_pinyin_query_test_200 query error = ' + error); + } + } + + /** + * @tc.number contactCard_pinyin_query_test_100 + * @tc.name Contact name to pinyin (Chinese Traditional) + * @tc.desc Function test + */ + it("contactCard_pinyin_query_test_100", 0, async function (done) { + console.info("--------logMessage contactCard_pinyin_query_test_100 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "鍵盤" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contactCard_pinyin_query_test_100 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataInsert(); + await deleteRawContact("contactCard_pinyin_query_test_100"); + await deleteAll(profileContactDataUri, "contactCard_pinyin_query_test_100"); + done(); + } catch (error) { + console.info('logMessage contactCard_pinyin_query_test_100 raw_contact insert error = ' + error); + done(); + } + + async function contactDataInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": "name", "detail_info": "鍵盤" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contactCard_pinyin_query_test_100 contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await searchContactQueryChinese(DAHelper, rawContactId); + } catch (error) { + console.info('logMessage contactCard_pinyin_query_test_100 contact_data insert error = ' + error); + done(); + } + } + }); + + async function searchContactQueryChinese(DAHelper, rawContactId) { + var resultColumns = ["raw_contact_id", "search_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(profilesearchContactUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_pinyin_query_test_100: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertEqual(true); + console.info( + 'logMessage contactCard_pinyin_query_test_100: search_name = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "鍵盤||jianpan||jp").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_pinyin_query_test_100 query error = ' + error); + } + } + + /** + * @tc.number contactCard_pinyin_query_test_300 + * @tc.name Contact name to pinyin (English) + * @tc.desc Function test + */ + it("contactCard_pinyin_query_test_300", 0, async function (done) { + console.info("--------logMessage contactCard_pinyin_query_test_300 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "Tom" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contactCard_pinyin_query_test_300 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataInsert(); + await deleteRawContact("contactCard_pinyin_query_test_300"); + done(); + } catch (error) { + console.info('logMessage contactCard_pinyin_query_test_300 raw_contact insert error = ' + error); + done(); + } + + async function contactDataInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": "name", "detail_info": "Tom" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + console.info('logMessage contactCard_pinyin_query_test_300 contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await searchContactQuery(DAHelper, rawContactId); + } catch (error) { + console.info('logMessage contactCard_pinyin_query_test_300 contact_data insert error = ' + error); + done(); + } + } + }); + + async function searchContactQuery(DAHelper, rawContactId) { + var resultColumns = ["raw_contact_id", "search_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(profilesearchContactUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_pinyin_query_test_300: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertTrue(); + console.info( + 'logMessage contactCard_pinyin_query_test_300: search_name = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "Tom||Tom||Tom").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_pinyin_query_test_300 query error = ' + error); + } + } + + /** + * @tc.number contactCard_fuzzyquery_test_400 + * @tc.name Contact fuzzy search query interface (name) + * @tc.desc Function test + */ + it("contactCard_fuzzyquery_test_400", 0, async function (done) { + console.info("--------logMessage contactCard_fuzzyquery_test_400 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "400xiaoming400" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contactCard_fuzzyquery_test_400 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await rawContactNameQuery(); + await deleteRawContact("contactCard_fuzzyquery_test_400"); + done(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_400 raw_contact insert error = ' + error); + done(); + } + + async function rawContactNameQuery() { + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.like("display_name", "%xiaoming40%"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_fuzzyquery_test_400: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertEqual(true); + console.info( + 'logMessage contactCard_fuzzyquery_test_400: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "400xiaoming400").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_400 query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number contactCard_fuzzyquery_test_500 + * @tc.name Contact fuzzy search query interface (name pinyin, pinyin name) + * @tc.desc Function test + */ + it("contactCard_fuzzyquery_test_500", 0, async function (done) { + console.info("--------logMessage contactCard_fuzzyquery_test_500 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var rawContactValues = { + "display_name": "500xiaoming500", "phonetic_name": "500xiaoming500||xm" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contactCard_fuzzyquery_test_500 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await rawContactPhoneticNameQuery(); + await deleteRawContact("contactCard_fuzzyquery_test_500"); + done(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_500 raw_contact insert error = ' + error); + done(); + } + + async function rawContactPhoneticNameQuery() { + var resultColumns = ["id", "display_name", "phonetic_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.like("phonetic_name", "%xiaoming%"); + condition.and(); + condition.equalTo("is_deleted", "0"); + condition.or(); + condition.like("phonetic_name", "%xm%"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_fuzzyquery_test_500: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertTrue(); + console.info( + 'logMessage contactCard_fuzzyquery_test_500: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "500xiaoming500").assertTrue(); + console.info( + 'logMessage contactCard_fuzzyquery_test_500: phoneticName = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "500xiaoming500||xm").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_500 query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number contactCard_fuzzyquery_test_600 + * @tc.name Contact fuzzy search query interface (company, position) + * @tc.desc Function test + */ + it("contactCard_fuzzyquery_test_600", 0, async function (done) { + console.info("--------logMessage contactCard_fuzzyquery_test_600 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoming", "company": "TT600", "position": "Testers600" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contactCard_fuzzyquery_test_600 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await rawContactCompanyQuery(DAHelper, rawContactId); + await deleteRawContact("contactCard_fuzzyquery_test_600"); + done(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_600 raw_contact insert error = ' + error); + done(); + } + }); + + async function rawContactCompanyQuery(DAHelper, rawContactId) { + var resultColumns = ["id", "display_name", "company", "position"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.like("company", "%TT6%"); + condition.and(); + condition.equalTo("is_deleted", "0"); + condition.or(); + condition.like("position", "%Testers6%"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_fuzzyquery_test_600: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertEqual(true); + console.info( + 'logMessage contactCard_fuzzyquery_test_600: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "xiaoming").assertEqual(true); + console.info('logMessage contactCard_fuzzyquery_test_600: company = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "TT600").assertEqual(true); + console.info('logMessage contactCard_fuzzyquery_test_600: position = ' + resultSet.getString(3)); + expect(resultSet.getString(3) == "Testers600").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_600 query error = ' + error); + } + } + + /** + * @tc.number contactCard_fuzzyquery_test_700 + * @tc.name Contact fuzzy search query interface (mobile phone number) + * @tc.desc Function test + */ + it("contactCard_fuzzyquery_test_700", 0, async function (done) { + console.info("--------logMessage contactCard_fuzzyquery_test_700 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoming" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contactCard_fuzzyquery_test_700 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataPhoneInsert(); + await deleteRawContact("contactCard_fuzzyquery_test_700"); + await deleteAll(profileContactDataUri, "contactCard_fuzzyquery_test_700"); + done(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_700 raw_contact insert error = ' + error); + done(); + } + + async function contactDataPhoneInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "phone", + "detail_info": "14528963" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contactCard_fuzzyquery_test_700 contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await fuzzyQueryPhone(DAHelper, rawContactId, contactDataId); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_700 contact_data insert error = ' + contactDataId); + done(); + } + } + }); + + async function fuzzyQueryPhone(DAHelper, rawContactId, contactDataId) { + var resultColumns = ["id", "raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 5 data is phone + condition.like("detail_info", "%52896%"); + condition.and(); + condition.equalTo("type_id", "5"); + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_fuzzyquery_test_700: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == contactDataId.toString()).assertEqual(true); + console.info( + 'logMessage contactCard_fuzzyquery_test_700: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertEqual(true); + console.info('logMessage contactCard_fuzzyquery_test_700: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "14528963").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_700 query error = ' + error); + } + } + + /** + * @tc.number contactCard_fuzzyquery_test_800 + * @tc.name Contact fuzzy search query interface (nickname) + * @tc.desc Function test + */ + it("contactCard_fuzzyquery_test_800", 0, async function (done) { + console.info("--------logMessage contactCard_fuzzyquery_test_800 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoming" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contactCard_fuzzyquery_test_800 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactNickNameInsert(); + await deleteRawContact("contactCard_fuzzyquery_test_800"); + await deleteAll(profileContactDataUri, "contactCard_fuzzyquery_test_800"); + done(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_800 raw_contact insert error = ' + error); + done(); + } + + async function contactNickNameInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "nickname", + "detail_info": "daming" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + console.info('logMessage contactCard_fuzzyquery_test_800 contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await fuzzyQueryPhoneNickName(DAHelper, rawContactId, contactDataId); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_800 contact_data insert error = ' + contactDataId); + done(); + } + } + }); + + async function fuzzyQueryPhoneNickName(DAHelper, rawContactId, contactDataId) { + var resultColumns = ["id", "raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 3 data is nickname + condition.like("detail_info", "%daming%"); + condition.and(); + condition.equalTo("type_id", "3"); + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_fuzzyquery_test_800: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == contactDataId.toString()).assertTrue(); + console.info( + 'logMessage contactCard_fuzzyquery_test_800: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertTrue(); + console.info('logMessage contactCard_fuzzyquery_test_800: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "daming").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_800 query error = ' + error); + } + } + + /** + * @tc.number contactCard_fuzzyquery_test_900 + * @tc.name Contact fuzzy search query interface (mailbox) + * @tc.desc Function test + */ + it("contactCard_fuzzyquery_test_900", 0, async function (done) { + console.info("--------logMessage contactCard_fuzzyquery_test_900 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoming" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contactCard_fuzzyquery_test_900 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataEmailInsert(); + await deleteRawContact("contactCard_fuzzyquery_test_900"); + await deleteAll(profileContactDataUri, "contactCard_fuzzyquery_test_900"); + done(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_900 raw_contact insert error = ' + error); + done(); + } + + async function contactDataEmailInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "email", + "detail_info": "1564@163.com" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + console.info('logMessage contactCard_fuzzyquery_test_900 ; = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await fuzzyQueryEmail(DAHelper, rawContactId, contactDataId); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_900 contact_data insert error = ' + error); + done(); + } + } + }); + + async function fuzzyQueryEmail(DAHelper, rawContactId, contactDataId) { + var resultColumns = ["id", "raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 1 data is email + condition.like("detail_info", "%1564%"); + condition.and(); + condition.equalTo("type_id", "1"); + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_fuzzyquery_test_900: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == contactDataId.toString()).assertTrue(); + console.info( + 'logMessage contactCard_fuzzyquery_test_900: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertTrue(); + console.info('logMessage contactCard_fuzzyquery_test_900: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "1564@163.com").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_900 query error = ' + error); + } + } + + /** + * @tc.number contactCard_fuzzyquery_test_1000 + * @tc.name Contact fuzzy search query interface (residential) + * @tc.desc Function test + */ + it("contactCard_fuzzyquery_test_1000", 0, async function (done) { + console.info("--------logMessage contactCard_fuzzyquery_test_1000 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoming" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contactCard_fuzzyquery_test_1000 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataPostalInsert(); + await deleteRawContact("contactCard_fuzzyquery_test_1000"); + await deleteAll(profileContactDataUri, "contactCard_fuzzyquery_test_1000"); + done(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_1000 raw_contact insert error = ' + error); + done(); + } + + async function contactDataPostalInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "postal_address", + "detail_info": "nanjing1000" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contactCard_fuzzyquery_test_1000 contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await fuzzyQueryAddress(DAHelper, rawContactId, contactDataId); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_1000 contact_data insert error = ' + error); + done(); + } + } + }); + + async function fuzzyQueryAddress(DAHelper, rawContactId, contactDataId) { + var resultColumns = ["id", "raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 1 data is postal_address + condition.like("detail_info", "%nanjing10%"); + condition.and(); + condition.equalTo("type_id", "7"); + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_fuzzyquery_test_1000: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == contactDataId.toString()).assertTrue(); + console.info( + 'logMessage contactCard_fuzzyquery_test_1000: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertTrue(); + console.info( + 'logMessage contactCard_fuzzyquery_test_1000: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "nanjing1000").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_1000: query error' + error); + } + } + + /** + * @tc.number contactCard_fuzzyquery_test_1100 + * @tc.name Contact fuzzy search query interface (remarks) + * @tc.desc Function test + */ + it("contactCard_fuzzyquery_test_1100", 0, async function (done) { + console.info("--------logMessage contactCard_fuzzyquery_test_1100 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoming" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contactCard_fuzzyquery_test_1100 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataNoteInsert(); + await deleteRawContact("contactCard_fuzzyquery_test_1100"); + await deleteAll(profileContactDataUri, "contactCard_fuzzyquery_test_1100"); + done(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_1100 raw_contact insert error = ' + error); + done(); + } + + async function contactDataNoteInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "note", + "detail_info": "java1100" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contactCard_fuzzyquery_test_1100 contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await fuzzyQueryNote(DAHelper, rawContactId, contactDataId); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_1100 contact_data insert error = ' + error); + done(); + } + } + }); + + async function fuzzyQueryNote(DAHelper, rawContactId, contactDataId) { + var resultColumns = ["id", "raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 10 data is note + condition.like("detail_info", "%java11%"); + condition.and(); + condition.equalTo("type_id", "10"); + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_fuzzyquery_test_1100: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == contactDataId.toString()).assertEqual(true); + console.info( + 'logMessage contactCard_fuzzyquery_test_1100: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertEqual(true); + console.info( + 'logMessage contactCard_fuzzyquery_test_1100: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "java1100").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_1100: query error' + error); + } + } + + /** + * @tc.number contactCard_fuzzyquery_test_1200 + * @tc.name Contact fuzzy search query interface (AIM) + * @tc.desc Function test + */ + it("contactCard_fuzzyquery_test_1200", 0, async function (done) { + console.info("--------logMessage contactCard_fuzzyquery_test_1200 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoming" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + console.info('logMessage contactCard_fuzzyquery_test_1200 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataAimInsert(); + await deleteRawContact("contactCard_fuzzyquery_test_1200"); + await deleteAll(profileContactDataUri, "contactCard_fuzzyquery_test_1200"); + done(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_1200 raw_contact insert error = ' + error); + done(); + } + + async function contactDataAimInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "im", + "detail_info": "aaaa1200" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + console.info('logMessage contactCard_fuzzyquery_test_1200 ; = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await fuzzyQueryIM(DAHelper, rawContactId, contactDataId); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_1200 contact_data insert error = ' + error); + done(); + } + } + }); + + async function fuzzyQueryIM(DAHelper, rawContactId, contactDataId) { + var resultColumns = ["id", "raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 10 data is im account number + condition.like("detail_info", "%aa12%"); + condition.and(); + condition.equalTo("type_id", "2"); + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contactCard_fuzzyquery_test_1200: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == contactDataId.toString()).assertEqual(true); + console.info( + 'logMessage contactCard_fuzzyquery_test_1200: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertEqual(true); + console.info( + 'logMessage contactCard_fuzzyquery_test_1200: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "aaaa1200").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contactCard_fuzzyquery_test_1200: query error' + error); + } + } + + /** + * @tc.number abnormal_contactCard_insert_test_200 + * @tc.name Abnormal use case, an incorrect field is passed in when inserting + * @tc.desc Function test + */ + it("abnormal_contactCard_insert_test_200", 0, async function (done) { + console.info("------------abnormal_contactCard_insert_test_200 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_names": "xiaoshan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + console.info("logMessage abnormal_contactCard_insert_test_200: rawContactId = " + rawContactId); + expect(rawContactId).assertEqual(-1); + done(); + } catch (error) { + console.info('logMessage abnormal_contactCard_insert_test_200: raw_contact insert error' + error); + done(); + } + }); + + /** + * @tc.number abnormal_contactCard_insert_test_300 + * @tc.name Abnormal use case, an incorrect table name is passed in when inserting + * @tc.desc Function test + */ + it("abnormal_contactCard_insert_test_300", 0, async function (done) { + console.info("------------abnormal_contactCard_insert_test_300 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var errorUri = "dataability:///com.ohos.calllogability/contacts/raw_contacts"; + + var rawContactValues = { + "display_name": "xiaoshan" + }; + try { + var rawContactId = await DAHelper.insert(errorUri, rawContactValues); + console.info("logMessage abnormal_contactCard_insert_test_300: rawContactId = " + rawContactId); + expect(rawContactId == -1).assertTrue(); + done(); + } catch (error) { + console.info('logMessage abnormal_contactCard_insert_test_300: raw_contact insert error' + error); + done(); + } + }); + + /** + * @tc.number abnormal_contactCard_update_test_1100 + * @tc.name Abnormal use case, an incorrect field is passed in when updating + * @tc.desc Function test + */ + it("abnormal_contactCard_update_test_1100", 0, async function (done) { + console.info("------------abnormal_contactCard_update_test_1100 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoshan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + console.info("logMessage abnormal_contactCard_update_test_1100: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await abnormalUpdate(); + await deleteRawContact("abnormal_contactCard_update_test_1100"); + done(); + } catch (error) { + console.info('logMessage abnormal_contactCard_update_test_1100: raw_contact insert error' + error); + done(); + } + + async function abnormalUpdate() { + var updateValues = { + "display_names": "xiaosan" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", rawContactId.toString()); + try { + var updataCode = await DAHelper.update(profileRawContactUri, updateValues, condition) + console.info("logMessage abnormal_contactCard_update_test_1100: updataCode = " + updataCode); + expect(updataCode == -1).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "xiaoshan"); + await contactsQuery(map, "abnormal_contactCard_update_test_1100", profileRawContactUri); + } catch (error) { + console.info('logMessage abnormal_contactCard_update_test_1100: update error' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contactCard_update_test_1000 + * @tc.name Abnormal use case, an incorrect table name is passed in when updating + * @tc.desc Function test + */ + it("abnormal_contactCard_update_test_1000", 0, async function (done) { + console.info("------------abnormal_contactCard_update_test_1000 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var errorUri = "dataability:///com.ohos.calllogability/contacts/raw_contacts"; + + var rawContactValues = { + "display_name": "xiaoshan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + console.info("logMessage abnormal_contactCard_update_test_1000: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await abnormalUpdate(); + await deleteRawContact("abnormal_contactCard_update_test_1100"); + done(); + } catch (error) { + console.info('logMessage abnormal_contactCard_update_test_1000: raw_contact insert error' + error); + done(); + } + + async function abnormalUpdate() { + var updateValues = { + "display_name": "xiaosan" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var updataCode = await DAHelper.update(errorUri, updateValues, condition); + console.info("logMessage abnormal_contactCard_update_test_1000: updataCode = " + updataCode); + expect(updataCode == -1).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "xiaoshan"); + await contactsQuery(map, "abnormal_contactCard_update_test_1000", profileRawContactUri); + } catch (error) { + console.info("logMessage abnormal_contactCard_update_test_1000: updata error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contactCard_delete_test_4500 + * @tc.name Abnormal use case, an incorrect field is passed in when deleting + * @tc.desc Function test + */ + it("abnormal_contactCard_delete_test_4500", 0, async function (done) { + console.info("------------abnormal_contactCard_delete_test_4500 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaozhi" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + console.info("logMessage abnormal_contactCard_delete_test_4500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await abnormalDelete(); + await deleteRawContact("abnormal_contactCard_delete_test_4500"); + done(); + } catch (error) { + console.info('logMessage abnormal_contactCard_delete_test_4500: raw_contact insert error' + error); + done(); + } + + async function abnormalDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", rawContactId.toString()); + try { + var deleteCode = await DAHelper.delete(profileRawContactUri, condition); + console.info("logMessage abnormal_contactCard_delete_test_4500: deleteCode = " + deleteCode); + expect(deleteCode == -1).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "xiaozhi"); + await contactsQuery(map, "abnormal_contactCard_delete_test_4500", profileRawContactUri); + done(); + } catch (error) { + console.info('logMessage abnormal_contactCard_delete_test_4500: delete error' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contactCard_delete_test_4600 + * @tc.name Abnormal use case, an incorrect table name is passed in when deleting + * @tc.desc Function test + */ + it("abnormal_contactCard_delete_test_4600", 0, async function (done) { + console.info("------------abnormal_contactCard_delete_test_4600 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var errorUri = "dataability:///com.ohos.calllogability/contacts/raw_contacts"; + + var rawContactValues = { + "display_name": "xiaoshan" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + console.info("logMessage abnormal_contactCard_delete_test_4600: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await abnormalDelete(); + await deleteRawContact("abnormal_contactCard_delete_test_4600"); + done(); + } catch (error) { + console.info('logMessage abnormal_contactCard_delete_test_4600: raw_contact insert error' + error); + done(); + } + + async function abnormalDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var deleteCode = await DAHelper.delete(errorUri, condition); + console.info("logMessage abnormal_contactCard_delete_test_4600: deleteCode = " + deleteCode); + expect(deleteCode == -1).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "xiaoshan"); + await contactsQuery(map, "abnormal_contactCard_delete_test_4600", profileRawContactUri); + done(); + } catch (error) { + console.info('logMessage abnormal_contactCard_delete_test_4600: delete error' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contactCard_query_test_4200 + * @tc.name Abnormal use case, an incorrect field is passed in when querying + * @tc.desc Function test + */ + it("abnormal_contactCard_query_test_4200", 0, async function (done) { + console.info("------------abnormal_contactCard_query_test_4200 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaozhicheng" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues) + console.info("logMessage abnormal_contactCard_query_test_4200: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await abnormalQuery(); + await deleteRawContact("abnormal_contactCard_query_test_4200"); + done(); + } catch (error) { + console.info('logMessage abnormal_contactCard_query_test_4200: raw_contact insert error' + error); + done(); + } + + async function abnormalQuery() { + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + expect(resultSet.goToFirstRow()).assertEqual(false); + console.info( + 'logMessage abnormal_contactCard_query_test_4200: goToFirstRow' + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info('logMessage abnormal_contactCard_query_test_4200: query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contactCard_batchinsert_test_5100 + * @tc.name Abnormal use cases, when adding data in batches, some of them failed, check the processing logic + * @tc.desc Function test + */ + it("abnormal_contactCard_batchinsert_test_5100", 0, async function (done) { + console.info("--------logMessage abnormal_contactCard_batchinsert_test_5100 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var addBulkValue1 = { + "display_name": "zhangsan" + }; + var addBulkValue2 = { + "display_names": "lisi" + }; + var addBulkValue3 = { + "display_name": "wangwu" + }; + var addBulkValue4 = { + "display_names": "laoliu" + }; + var addBulkValue5 = { + "display_name": "xiaozhang" + }; + var listAddBluk = []; + listAddBluk[0] = addBulkValue1; + listAddBluk[1] = addBulkValue2; + listAddBluk[2] = addBulkValue3; + listAddBluk[3] = addBulkValue4; + listAddBluk[4] = addBulkValue5; + try { + var batchInsertCode = await DAHelper.batchInsert(profileRawContactUri, listAddBluk); + console.info("logMessage abnormal_contactCard_batchinsert_test_5100: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == -1).assertTrue(); + done(); + } catch (error) { + console.info("logMessage abnormal_contactCard_batchinsert_test_5100: batch insert error = " + error); + done(); + } + }); + + /** + * @tc.number abnormal_contactCard_insert_data_5300 + * @tc.name insert_data error no rawContactId + * @tc.desc Function test + */ + it("abnormal_contactCard_insert_data_5300", 0, async function (done) { + console.info("--------logMessage abnormal_contactCard_insert_data_5300 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaotian" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage abnormal_contactCard_insert_data_5300 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataAimInsert(); + await deleteRawContact("abnormal_contactCard_insert_data_5300"); + done(); + } catch (error) { + console.info('logMessage abnormal_contactCard_insert_data_5300 raw_contact insert error = ' + error); + done(); + } + + async function contactDataAimInsert() { + var contactDataValues = { + "content_type": "im", "detail_info": "aaaa" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + console.info('logMessage abnormal_contactCard_insert_data_5300 ; = ' + contactDataId); + expect(contactDataId == -1).assertTrue(); + } catch (error) { + console.info('logMessage abnormal_contactCard_insert_data_5300 contact_data insert error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contactCard_insert_data_5400 + * @tc.name insert_data error no content_type + * @tc.desc Function test + */ + it("abnormal_contactCard_insert_data_5400", 0, async function (done) { + console.info("--------logMessage abnormal_contactCard_insert_data_5400 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaotian" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, rawContactValues); + console.info('logMessage abnormal_contactCard_insert_data_5400 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataAimInsert(); + await deleteRawContact("abnormal_contactCard_insert_data_5400"); + done(); + } catch (error) { + console.info('logMessage abnormal_contactCard_insert_data_5400 raw_contact insert error = ' + error); + done(); + } + + async function contactDataAimInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, "detail_info": "aaaa" + }; + try { + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + console.info('logMessage abnormal_contactCard_insert_data_5400 ; = ' + contactDataId); + expect(contactDataId == -1).assertTrue(); + } catch (error) { + console.info('logMessage abnormal_contactCard_insert_data_5400 contact_data insert error = ' + error); + done(); + } + } + }); + + /** + * @tc.number contactCard_delete_test_5500 + * @tc.name batchDelete + * @tc.desc Function test + */ + it("contactCard_delete_test_5500", 0, async function (done) { + console.info("--------logMessage contactCard_delete_test_5500 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, common.getProfileRawContact()); + console.info("logMessage contactCard_delete_test_5500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var map = common.getProfileRawContactMap(); + map.set("id", rawContactId.toString()); + await contactsQuery(map, "contactCard_delete_test_5500", profileRawContactUri); + await executeBatch(); + } catch (error) { + console.info("logMessage contactCard_delete_test_5500: insert error = " + error); + done(); + } + async function executeBatch() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + DAHelper.executeBatch(URI_CONTACTS, [{ + uri: profileRawContactUri, + type: featureAbility.DataAbilityOperationType.TYPE_DELETE, + predicates: condition, + expectedCount: 0, + PredicatesBackReferences: {}, + interrupted: true, + }], + (error, data) => { + console.info( + "logMessage contactCard_delete_test_5500: executeBatch data = " + JSON.stringify(data)); + console.info("logMessage contactCard_delete_test_5500: data_3 = " + data); + console.info("logMessage contactCard_delete_test_5500: data_1= " + data[0].count); + expect(data[0].count == 0).assertTrue(); + done(); + }); + } + }); + + /** + * @tc.number contactCard_update_test_5600 + * @tc.name batchUpdate + * @tc.desc Function test + */ + it("contactCard_update_test_5600", 0, async function (done) { + console.info("--------logMessage contactCard_update_test_5600 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, common.getProfileRawContact()); + console.info("logMessage contactCard_update_test_5600: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var map = common.getProfileRawContactMap(); + map.set("id", rawContactId.toString()); + await contactsQuery(map, "contactCard_update_test_5600", profileRawContactUri); + await executeBatch(); + } catch (error) { + console.info("logMessage contactCard_update_test_5600: insert error = " + error); + done(); + } + + async function executeBatch() { + var updateValues = { + "display_name": "xiaoxiaoxiao" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + DAHelper.executeBatch(URI_CONTACTS, [{ + uri: profileRawContactUri, + type: featureAbility.DataAbilityOperationType.TYPE_UPDATE, + valuesBucket: updateValues, + predicates: condition, + expectedCount: 0, + PredicatesBackReferences: {}, + interrupted: true, + }], + (error, data) => { + console.info( + "logMessage contactCard_update_test_5600: executeBatch data = " + JSON.stringify(data)); + console.info("logMessage contactCard_update_test_5600: data_3 = " + data); + console.info("logMessage contactCard_update_test_5600: data_1= " + data[0].count); + expect(data[0].count == 0).assertTrue(); + done(); + }); + } + }); + + /** + * @tc.number contactCard_insert_test_5700 + * @tc.name Insert Multiple raw_contact essential information + * @tc.desc Function test + */ + it("contactCard_insert_test_5700", 0, async function (done) { + console.info("------logMessage contactCard_insert_test_5700 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, common.getProfileRawContact()); + sleep(1000); + console.info('logMessage contactCard_insert_test_5700: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + var map = common.getProfileRawContactMap(); + map.set("id", rawContactId.toString()); + await contactsQuery(map, "contactCard_insert_test_5700", profileRawContactUri); + var rawContactIdOne = await DAHelper.insert(profileRawContactUri, common.getProfileRawContact()); + sleep(1000); + console.info('logMessage contactCard_insert_test_5700: rawContactIdOne = ' + rawContactIdOne); + expect(rawContactIdOne > 0).assertTrue(); + var map = common.getProfileRawContactMap(); + map.set("id", rawContactIdOne.toString()); + await contactsQuery(map, "contactCard_insert_test_5700", profileRawContactUri); + var rawContactIdTwo = await DAHelper.insert(profileRawContactUri, common.getProfileRawContact()); + sleep(1000); + console.info('logMessage contactCard_insert_test_5700: rawContactIdTwo = ' + rawContactIdTwo); + expect(rawContactIdTwo > 0).assertTrue(); + var map = common.getProfileRawContactMap(); + map.set("id", rawContactIdTwo.toString()); + await contactsQuery(map, "contactCard_insert_test_5700", profileRawContactUri); + await deleteRawContact("contactCard_insert_test_5700"); + done(); + } catch (error) { + console.info('logMessage contactCard_insert_test_5700: insert error = ' + error); + done(); + } + }); + + /** + * @tc.number contactCard_insert_test_5800 + * @tc.name Add 20000 bytes of basic contact information and verify whether the text insertion is successful + * @tc.desc Function test + */ + it("contactCard_insert_test_5800", 0, async function (done) { + console.info("------logMessage contactCard_insert_test_5800 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var name; + for (var i = 0; i < 20000; i++) { + name += "i"; + } + var contcatvalues = { + "display_name": name + } + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, contcatvalues); + sleep(1000); + console.info('logMessage contactCard_insert_test_5800: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", name); + await contactsQuery(map, "contactCard_insert_test_5800", profileRawContactUri); + await deleteRawContact("contactCard_insert_test_5800"); + done(); + } catch (error) { + console.info('logMessage contactCard_insert_test_5800: insert error = ' + error); + done(); + } + }); + + /** + * @tc.number contactCard_insert_test_5900 + * @tc.name Add multiple contact details and verify that the insertion was successful + * @tc.desc Function test + */ + it("contactCard_insert_test_5900", 0, async function (done) { + console.info("------logMessage contactCard_insert_test_5900 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var contcatvalues = { + "display_name": "xiao5900" + } + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, contcatvalues); + console.info('logMessage contactCard_insert_test_5900: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "phone", + "detail_info": "19960229" + }; + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues1); + console.info('logMessage contactCard_insert_test_5900: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "19960229"); + await contactsQuery(map, "contactCard_insert_test_5900", profileContactDataUri); + + var rawContactIdOne = await DAHelper.insert(profileRawContactUri, contcatvalues); + console.info('logMessage contactCard_insert_test_5900: rawContactId = ' + rawContactIdOne); + expect(rawContactIdOne > 0).assertTrue(); + var contactDataValues2 = { + "raw_contact_id": rawContactIdOne, + "content_type": "phone", + "detail_info": "111111032" + }; + var contactDataId1 = await DAHelper.insert(profileContactDataUri, contactDataValues2); + console.info('logMessage contactCard_insert_test_5900: contactDataId = ' + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "111111032"); + await contactsQuery(map, "contactCard_insert_test_5900", profileContactDataUri); + + await deleteRawContact("contactCard_insert_test_5900"); + await deleteAll(profileContactDataUri, "contactCard_insert_test_5900"); + done(); + } catch (error) { + console.info('logMessage contactCard_insert_test_5900: insert error = ' + error); + done(); + } + }); + + /** + * @tc.number contactCard_insert_test_6000 + * @tc.name Add the basic information of a single contact and verify whether the insertion is successful (name, + * Pinyin, company, position, favorite) + * @tc.desc Function test + */ + it("contactCard_insert_test_6000", 0, async function (done) { + console.info("------logMessage contactCard_insert_test_6000 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "licheng", + "company": "TT", + "position": "developer", + "favorite": 1, + "phonetic_name": "licheng||lc" + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_insert_test_6000: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "licheng"); + map.set("company", "TT"); + map.set("position", "developer"); + map.set("favorite", "1"); + map.set("phonetic_name", "licheng||lc"); + await contactsQuery(map, "contactCard_insert_test_6000", profileRawContactUri); + await deleteRawContact("contactCard_insert_test_6000"); + await deleteAll(profileContactDataUri, "contactCard_insert_test_6000"); + done(); + } catch (error) { + console.info("logMessage contactCard_insert_test_6000: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number contactCard_insertData_test_6100 + * @tc.name To contact_data Add a full field data to the data table and verify whether the insertion is + * successful + * @tc.desc Function test + */ + it("contactCard_insertData_test_6100", 0, async function (done) { + console.info("------logMessage contactCard_insertData_test_6100 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocai", + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_insertData_test_6100: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var contactDataValues = common.getProfileContactData(); + contactDataValues["raw_contact_id"] = rawContactId; + console.info('logMessage contactCard_insertData_test_6100: contactDataValues["raw_contact_id"] = ' + + contactDataValues.raw_contact_id); + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + console.info('logMessage contactCard_insertData_test_6100: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + var map = common.getProfileContactDataMap(); + map.set("id", contactDataId.toString()); + map.set("raw_contact_id", rawContactId.toString()); + await contactsQuery(map, "contactCard_insertData_test_6100", profileContactDataUri); + await deleteRawContact("contactCard_insertData_test_6100"); + await deleteAll(profileContactDataUri, "contactCard_insertData_test_6100"); + done(); + } catch (error) { + console.info("logMessage contactCard_insertData_test_6100: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number contactCard_update_test_6200 + * @tc.name Modify the basic information of multiple contacts and verify whether the modification is successful + * @tc.desc Function test + */ + it("contactCard_update_test_6200", 0, async function (done) { + console.info("--------logMessage contactCard_update_test_6200 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var insertRawContactValues = { + "display_name": "xiaocai", + }; + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + expect(rawContactId > 0).assertTrue(); + console.info("logMessage contactCard_update_test_6200: rawContactId = " + rawContactId); + var insertRawContactValuesOne = { + "display_name": "xiaocai1", + }; + var rawContactIdOne = await DAHelper.insert(profileRawContactUri, insertRawContactValuesOne); + expect(rawContactIdOne > 0).assertTrue(); + console.info("logMessage contactCard_update_test_6200: rawContactIdOne = " + rawContactIdOne); + var insertRawContactValuesTwo = { + "display_name": "xiaocai1", + }; + var rawContactIdTwo = await DAHelper.insert(profileRawContactUri, insertRawContactValuesTwo); + expect(rawContactIdTwo > 0).assertTrue(); + console.info("logMessage contactCard_update_test_6200: rawContactIdTwo = " + rawContactIdTwo); + + var updateValues = { + "display_name": "xiaosan" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + condition.or(); + condition.equalTo("id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("id", rawContactIdTwo.toString()); + var updataCode = await DAHelper.update(profileRawContactUri, updateValues, condition); + console.info("logMessage contactCard_update_test_6200: updataCode = " + updataCode); + expect(updataCode == 0).assertTrue(); + sleep(1000); + await queryUpdateThree( + "contactCard_update_test_6200", DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo); + await deleteRawContact("contactCard_update_test_6200"); + done(); + } catch (error) { + console.info("logMessage contactCard_update_test_6200: insert error = " + error); + done(); + } + }); + + async function queryUpdateThree(tag, DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo) { + + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': contactsQuery start ! DAHelper = ' + DAHelper); + var resultColumns = ["display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + condition.or(); + condition.equalTo("id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("id", rawContactIdTwo.toString()); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var name = resultSet.getString(resultSet.getColumnIndex("display_name")); + expect(name == "xiaosan").assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage contactsQuery: error = " + error); + } + } + + /** + * @tc.number contactCard_UpdateRawContcat_test_6300 + * @tc.name Update raw_contact The full field data of the contact table and verify whether the modification is + * successful + * @tc.desc Function test + */ + it("contactCard_UpdateRawContcat_test_6300", 0, async function (done) { + console.info("------logMessage contactCard_UpdateRawContcat_test_6300 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, common.getProfileRawContact()); + console.info("logMessage contactCard_UpdateRawContcat_test_6300: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + sleep(2000); + var updateValues = common.getProfileRawContactUpdate(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + var updataCode = await DAHelper.update(profileRawContactUri, updateValues, condition); + console.info('logMessage contactCard_UpdateRawContcat_test_6300: updataCode = ' + updataCode); + sleep(3000); + var map = common.getProfileRawContactUpdateMap(); + map.set("id", rawContactId.toString()); + await contactsQuery(map, "contactCard_UpdateRawContcat_test_6300", profileRawContactUri); + await deleteRawContact("contactCard_UpdateRawContcat_test_6300"); + await deleteAll(profileContactDataUri, "contactCard_UpdateRawContcat_test_6300"); + done(); + } catch (error) { + console.info("logMessage contactCard_UpdateRawContcat_test_6300: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number contactCard_insertDataUpdate_test_6400 + * @tc.name Update contact_data table, and verify whether the modification is successful + * @tc.desc Function test + */ + it("contactCard_insertDataUpdate_test_6400", 0, async function (done) { + console.info("------logMessage contactCard_insertDataUpdate_test_6400 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocai", + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_insertDataUpdate_test_6400: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + + var contactDataValues = common.getProfileContactData(); + contactDataValues["raw_contact_id"] = rawContactId; + console.info('logMessage contactCard_insertDataUpdate_test_6400: contactDataValues.raw_contact_id = ' + + contactDataValues.raw_contact_id); + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + console.info('logMessage contactCard_insertDataUpdate_test_6400: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + + var updateValues = common.getProfileContactDataUpdate(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", contactDataId.toString()); + var updataCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + console.info('logMessage contactCard_insertDataUpdate_test_6400: updataCode = ' + updataCode); + sleep(1000); + var map = common.getProfileContactDataUpdateMap(); + map.set("id", contactDataId.toString()); + map.set("raw_contact_id", rawContactId.toString()); + await contactsQuery(map, "contactCard_insertDataUpdate_test_6400", profileContactDataUri); + await deleteRawContact("contactCard_insertDataUpdate_test_6400"); + await deleteAll(profileContactDataUri, "contactCard_insertDataUpdate_test_6400"); + done(); + } catch (error) { + console.info("logMessage contactCard_insertDataUpdate_test_6400: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number contactCard_insertDataUpdateAll_test_6500 + * @tc.name Update all contact details and verify that the modification was successful + * @tc.desc Function test + */ + it("contactCard_insertDataUpdateAll_test_6500", 0, async function (done) { + console.info("------logMessage contactCard_insertDataUpdateAll_test_6500 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocai", + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_insertDataUpdateAll_test_6500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await insertData(rawContactId, "name", "xiaocai", ""); + await insertData(rawContactId, "phone", "6500", ""); + await insertData(rawContactId, "organization", "TTTTT", "Deve"); + await insertData(rawContactId, "nickname", "xxxxcai", ""); + await insertData(rawContactId, "email", "111@fox.com", ""); + await insertData(rawContactId, "postal_address", "dddd", ""); + await insertData(rawContactId, "note", "caicai", ""); + await insertData(rawContactId, "im", "999999999", ""); + await insertData(rawContactId, "contact_event", "1125", ""); + await insertData(rawContactId, "website", "wwww.xxx.com", ""); + await insertData(rawContactId, "relation", "xiaobai", ""); + await insertData(rawContactId, "group_membership", 1, ""); + await insertData(rawContactId, "contact_misc", "5678", ""); + var updateValues = { + "detail_info": "xiaocai" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + var updataCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + console.info('logMessage contactCard_insertDataUpdateAll_test_6500: updataCode = ' + updataCode); + sleep(1000); + await queryUpdateAllData("contactCard_insertDataUpdateAll_test_6500", DAHelper, rawContactId); + await deleteRawContact("contactCard_insertDataUpdateAll_test_6500"); + await deleteAll(profileContactDataUri, "contactCard_insertDataUpdateAll_test_6500"); + done(); + } catch (error) { + console.info("logMessage contactCard_insertDataUpdateAll_test_6500: raw_contact insert error = " + error); + done(); + } + }); + + async function queryUpdateAllData(tag, DAHelper, rawContactId) { + + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': contactsQuery start ! DAHelper = ' + DAHelper); + var resultColumns = ["detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("row_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var detail_info = resultSet.getString(resultSet.getColumnIndex("detail_info")); + expect(detail_info == "xiaocai").assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage contactsQuery: error = " + error); + } + } + + /** + * @tc.number contactCard_insertFavorite_test_6600 + * @tc.name Add multiple contacts to favorites and verify that the favorites field is changed + * @tc.desc Function test + */ + it("contactCard_insertFavorite_test_6600", 0, async function (done) { + console.info("------logMessage contactCard_insertFavorite_test_6600 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + try { + var insertRawContactValues = { + "display_name": "xiaocai", "favorite": 1 + }; + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_insertFavorite_test_6600: rawContactId = " + rawContactId); + + var insertRawContactValuesOne = { + "display_name": "xiaotian", "favorite": 1 + }; + var rawContactIdOne = await DAHelper.insert(profileRawContactUri, insertRawContactValuesOne); + console.info("logMessage contactCard_insertFavorite_test_6600: rawContactId = " + rawContactIdOne); + + var insertRawContactValuesTwo = { + "display_name": "xiaoli", "favorite": 1 + }; + var rawContactIdTwo = await DAHelper.insert(profileRawContactUri, insertRawContactValuesTwo); + console.info("logMessage contactCard_insertFavorite_test_6600: rawContactId = " + rawContactIdTwo); + + sleep(1000); + await queryThreeFavorite( + "contactCard_insertFavorite_test_6600", DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo, 1); + await deleteRawContact("contactCard_insertFavorite_test_6600"); + done(); + } catch (error) { + console.info("logMessage contactCard_insertFavorite_test_6600: raw_contact insert error = " + error); + done(); + } + }); + + async function queryThreeFavorite(tag, DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo, favoritevalue) { + + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': queryThreeFavorite start ! DAHelper = ' + DAHelper); + var resultColumns = ["favorite"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + condition.or(); + condition.equalTo("id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("id", rawContactIdTwo.toString()); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var favorite = resultSet.getInt(resultSet.getColumnIndex("favorite")); + expect(favorite == favoritevalue).assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage queryThreeFavorite: error = " + error); + } + } + + /** + * @tc.number contactCard_unFavorite_test_6700 + * @tc.name Remove favorites from multiple contacts and verify that the favorites field has changed + * @tc.desc Function test + */ + it("contactCard_unFavorite_test_6700", 0, async function (done) { + console.info("------logMessage contactCard_unFavorite_test_6700 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + try { + var insertRawContactValues = { + "display_name": "xiaocai", "favorite": 1 + }; + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_unFavorite_test_6700: rawContactId = " + rawContactId); + + var insertRawContactValuesOne = { + "display_name": "xiaotian", "favorite": 1 + }; + var rawContactIdOne = await DAHelper.insert(profileRawContactUri, insertRawContactValuesOne); + console.info("logMessage contactCard_unFavorite_test_6700: rawContactId = " + rawContactIdOne); + + var insertRawContactValuesTwo = { + "display_name": "xiaoli", "favorite": 1 + }; + var rawContactIdTwo = await DAHelper.insert(profileRawContactUri, insertRawContactValuesTwo); + console.info("logMessage contactCard_unFavorite_test_6700: rawContactId = " + rawContactIdTwo); + + var updateValues = { + "favorite": 0 + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + condition.or(); + condition.equalTo("id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("id", rawContactIdTwo.toString()); + var updataCode = await DAHelper.update(profileRawContactUri, updateValues, condition); + console.info("logMessage contactCard_unFavorite_test_6700: updataCode = " + updataCode); + sleep(1000); + await queryThreeFavorite( + "contactCard_unFavorite_test_6700", DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo, 0); + await deleteRawContact("contactCard_unFavorite_test_6700"); + done(); + } catch (error) { + console.info("logMessage contactCard_unFavorite_test_6700: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number contactCard_insertContactBlocklist_test_6800 + * @tc.name Add multiple records to the black list and verify whether the insertion is successful + * @tc.desc Function test + */ + it("contactCard_insertContactBlocklist_test_6800", 0, async function (done) { + console.info("--------logMessage contactCard_insertContactBlocklist_test_6800 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var batchInsertCode = await DAHelper.insert(profileBlocklistUri, common.getProfileBlockList()); + console.info("logMessage contactCard_insertContactBlocklist_test_6800: insert = " + batchInsertCode); + var batchInsertCodeOne = await DAHelper.insert(profileBlocklistUri, common.getProfileBlockList()); + console.info("logMessage contactCard_insertContactBlocklist_test_6800: insert = " + batchInsertCodeOne); + var batchInsertCodeTwo = await DAHelper.insert(profileBlocklistUri, common.getProfileBlockList()); + console.info("logMessage contactCard_insertContactBlocklist_test_6800: insert = " + batchInsertCodeTwo); + sleep(1000); + expect(batchInsertCode > 0).assertTrue(); + await query(3); + await deleteAll(profileBlocklistUri, "contactCard_insertContactBlocklist_test_6800"); + done(); + } catch (error) { + console.info("logMessage contactCard_insertContactBlocklist_test_6800: batchInsert error = " + error); + done(); + } + + async function query(size) { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("phone_number", "123456789"); + try { + var resultSet = await DAHelper.query(profileBlocklistUri, resultColumns, condition); + sleep(1000); + console.info('contactCard_insertContactBlocklist_test_6800 :resultSet.goToFirstRow() = ' + + resultSet.goToFirstRow()); + console.info( + 'contactCard_insertContactBlocklist_test_6800 : query result is = ' + resultSet.rowCount == size); + expect(resultSet.rowCount == size).assertEqual(true); + resultSet.close(); + } catch (error) { + console.info(" contactCard_insertContactBlocklist_test_6800 error = " + error); + } + } + }); + + /** + * @tc.number contactCard_removeContactBlocklist_test_6900 + * @tc.name Delete multiple records from the black list and verify whether the deletion is successful + * @tc.desc Function test + */ + it("contactCard_removeContactBlocklist_test_6900", 0, async function (done) { + console.info("--------logMessage contactCard_removeContactBlocklist_test_6900 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var batchInsertCode = await DAHelper.insert(profileBlocklistUri, common.getProfileBlockList()); + console.info( + "logMessage contactCard_removeContactBlocklist_test_6900: batchInsertCode = " + batchInsertCode); + var batchInsertCodeOne = await DAHelper.insert(profileBlocklistUri, common.getProfileBlockList()); + console.info("logMessage contactCard_removeContactBlocklist_test_6900: insert = " + batchInsertCodeOne); + var batchInsertCodeTwo = await DAHelper.insert(profileBlocklistUri, common.getProfileBlockList()); + console.info("logMessage contactCard_removeContactBlocklist_test_6900: insert = " + batchInsertCodeTwo); + sleep(1000); + expect(batchInsertCode > 0).assertTrue(); + await deleteAll(profileBlocklistUri, "contactCard_removeContactBlocklist_test_6900"); + await query(0); + done(); + } catch (error) { + console.info("logMessage contactCard_removeContactBlocklist_test_6900: batchInsert error = " + error); + done(); + } + async function query(size) { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("phone_number", "123456789"); + try { + var resultSet = await DAHelper.query(profileBlocklistUri, resultColumns, condition); + console.info('contactCard_removeContactBlocklist_test_6900 : resultSet = ' + resultSet); + expect(resultSet.rowCount == size).assertEqual(true); + resultSet.close(); + } catch (error) { + console.info(" contactCard_removeContactBlocklist_test_6900 error = " + error); + } + } + }); + + /** + * @tc.number contactCard_insertGroup_test_7000 + * @tc.name Add multiple contacts to favorites and verify that the favorites field is changed + * @tc.desc Function test + */ + it("contactCard_insertGroup_test_7000", 0, async function (done) { + console.info("------logMessage contactCard_insertGroup_test_7000 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + try { + var insertRawContactValues = { + "display_name": "xiaocai", + }; + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_insertGroup_test_7000: rawContactId = " + rawContactId); + await insertData(rawContactId, "group_membership", 1, ""); + + var insertRawContactValuesOne = { + "display_name": "xiaotian", + }; + var rawContactIdOne = await DAHelper.insert(profileRawContactUri, insertRawContactValuesOne); + console.info("logMessage contactCard_insertGroup_test_7000: rawContactId = " + rawContactIdOne); + await insertData(rawContactIdOne, "group_membership", 1, ""); + var insertRawContactValuesTwo = { + "display_name": "xiaoli", + }; + var rawContactIdTwo = await DAHelper.insert(profileRawContactUri, insertRawContactValuesTwo); + console.info("logMessage contactCard_insertGroup_test_7000: rawContactId = " + rawContactIdTwo); + await insertData(rawContactIdTwo, "group_membership", 1, ""); + sleep(1000); + await queryThreeGroup( + "contactCard_insertGroup_test_7000", DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo, 1); + await deleteRawContact("contactCard_insertGroup_test_7000"); + done(); + } catch (error) { + console.info("logMessage contactCard_insertGroup_test_7000: raw_contact insert error = " + error); + done(); + } + }); + + async function queryThreeGroup(tag, DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo, groupId) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': queryThreeGroup start ! DAHelper = ' + DAHelper); + var resultColumns = ["detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + condition.or(); + condition.equalTo("id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("id", rawContactIdTwo.toString()); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var group = resultSet.getInt(resultSet.getColumnIndex("detail_info")); + expect(group == groupId).assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage queryThreeGroup: error = " + error); + } + } + + /** + * @tc.number contactCard_insert_test_7100 + * @tc.name Add a full field data to the groups table and verify whether the insertion is successful + * @tc.desc Function test + */ + it("contactCard_insert_test_7100", 0, async function (done) { + console.info("---------logMessage contactCard_insert_test_7100 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var groupId = await DAHelper.insert(profileGroupUri, common.getProfileGroup()); + console.info("logMessage contactCard_insert_test_7100: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + var map = common.getProfileGroupMap(); + map.set("id", groupId.toString()); + await contactsQuery(map, "contactCard_insert_test_7100", profileGroupUri); + await deleteAll(profileGroupUri, "contactCard_insert_test_7100"); + done(); + } catch (error) { + console.info("logMessage contactCard_insert_test_7100: group insert error = " + error); + done(); + } + }); + + /** + * @tc.number contactCard_delete_test_7200 + * @tc.name Add a full field data to the groups table and verify whether the insertion is successful + * @tc.desc Function test + */ + it("contactCard_delete_test_7200", 0, async function (done) { + console.info("------logMessage contactCard_delete_test_7200 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + try { + var insertRawContactValues = { + "display_name": "xiaocai", + }; + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_delete_test_7200: rawContactId = " + rawContactId); + await insertData(rawContactId, "group_membership", 1, ""); + + var insertRawContactValuesOne = { + "display_name": "xiaotian", + }; + var rawContactIdOne = await DAHelper.insert(profileRawContactUri, insertRawContactValuesOne); + console.info("logMessage contactCard_delete_test_7200: rawContactId = " + rawContactIdOne); + await insertData(rawContactIdOne, "group_membership", 1, ""); + var insertRawContactValuesTwo = { + "display_name": "xiaoli", + }; + var rawContactIdTwo = await DAHelper.insert(profileRawContactUri, insertRawContactValuesTwo); + console.info("logMessage contactCard_delete_test_7200: rawContactId = " + rawContactIdTwo); + await insertData(rawContactIdTwo, "group_membership", 1, ""); + sleep(1000); + await deleteAll(profileContactDataUri, "contactCard_delete_test_7200"); + sleep(1000); + await queryZeroGroup( + "contactCard_delete_test_7200", DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo); + await deleteRawContact("contactCard_delete_test_7200"); + done(); + } catch (error) { + console.info("logMessage contactCard_delete_test_7200: raw_contact insert error = " + error); + done(); + } + }); + + async function queryZeroGroup(tag, DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo) { + + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': queryZeroGroup start ! DAHelper = ' + DAHelper); + var resultColumns = ["detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + condition.or(); + condition.equalTo("raw_contact_id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("raw_contact_id", rawContactIdTwo.toString()); + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + console.info(tag + ': queryZeroGroup! resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == 0).assertEqual(true); + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage queryZeroGroup: error = " + error); + } + } + + /** + * @tc.number contactCard_delete_test_7300 + * @tc.name Delete the full field data of a groups table and verify whether the deletion is successful + * @tc.desc Function test + */ + it("contactCard_delete_test_7300", 0, async function (done) { + console.info("---------logMessage contactCard_delete_test_7300 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var groupId = await DAHelper.insert(profileGroupUri, common.getProfileGroup()); + console.info("logMessage contactCard_delete_test_7300: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + var map = common.getProfileGroupMap(); + map.set("id", groupId.toString()); + await contactsQuery(map, "contactCard_delete_test_7300", profileGroupUri); + await deleteAll(profileGroupUri, "contactCard_delete_test_7300"); + done(); + } catch (error) { + console.info("logMessage contactCard_delete_test_7300: group insert error = " + error); + done(); + } + }); + + /** + * @tc.number contactCard_delete_test_7400 + * @tc.name Add a raw_contact all fields, delete raw_contact + * @tc.desc Function test + */ + it("contactCard_delete_test_7400", 0, async function (done) { + console.info("------logMessage contactCard_delete_test_7400 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, common.getProfileRawContact()); + sleep(1000); + console.info('logMessage contactCard_delete_test_7400: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + var map = common.getProfileRawContactMap(); + map.set("id", rawContactId.toString()); + map.set("version", "2"); + map.set("is_deleted", "1"); + await deleteAll(profileRawContactUri, "contact_Delete_test_7400"); + sleep(1000); + await contactsQuery(map, "contactCard_delete_test_7400", profileRawContactUri); + var conditionAll = new ohosDataAbility.DataAbilityPredicates(); + conditionAll.greaterThan("id", "0"); + var code = await DAHelper.delete(profileDeletedContactsUri, conditionAll); + console.info('contactCard_delete_test_7400 : Completely delete code = ' + code); + expect(code == 0).assertTrue(); + done(); + } catch (error) { + console.info('logMessage contactCard_delete_test_7400: insert error = ' + error); + done(); + } + }); + + /** + * @tc.number contactCard_delete_test_7500 + * @tc.name Delete contact_data Single full field data in data table + * @tc.desc Function test + */ + it("contactCard_delete_test_7500", 0, async function (done) { + console.info("------logMessage contactCard_delete_test_7500 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocai", + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_delete_test_7500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var contactDataValues = common.getProfileContactData(); + contactDataValues["raw_contact_id"] = rawContactId; + var contactDataId = await DAHelper.insert(profileContactDataUri, contactDataValues); + console.info('logMessage contactCard_delete_test_7500: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await deleteAll(profileContactDataUri, "contactCard_delete_test_7500"); + var map = new Map(); + map.set("id", contactDataId.toString()); + await queryIdForDelete(map, "contactCard_delete_test_7500", profileContactDataUri); + await deleteRawContact("contactCard_delete_test_7500"); + done(); + } catch (error) { + console.info("logMessage contactCard_delete_test_7500: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number contactCard_insertDataAll_test_7600 + * @tc.name Add all details of a single contact and verify whether the insertion is successful (name, mobile + * number, company, position, nickname, email, home, remarks, aim) + * @tc.desc Function test + */ + it("contactCard_insertDataAll_test_7600", 0, async function (done) { + console.info("------logMessage contactCard_insertDataAll_test_7600 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocai", + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_insertDataAll_test_7600: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var contactdata1 = await insertData(rawContactId, "name", "xiaocai", ""); + await queryAlldata("contactCard_insertDataAll_test_7600", DAHelper, rawContactId, contactdata1, "xiaocai"); + var contactdata2 = await insertData(rawContactId, "phone", "6500", ""); + await queryAlldata("contactCard_insertDataAll_test_7600", DAHelper, rawContactId, contactdata2, "6500"); + var contactdatd3 = await insertData(rawContactId, "organization", "TTTTT", "Deve"); + await queryAlldata("contactCard_insertDataAll_test_7600", DAHelper, rawContactId, contactdatd3, "TTTTT"); + var contactdatd4 = await insertData(rawContactId, "nickname", "xxxxcai", ""); + await queryAlldata("contactCard_insertDataAll_test_7600", DAHelper, rawContactId, contactdatd4, "xxxxcai"); + var contactdatd5 = await insertData(rawContactId, "email", "111@fox.com", ""); + await queryAlldata( + "contactCard_insertDataAll_test_7600", DAHelper, rawContactId, contactdatd5, "111@fox.com"); + var contactdatd6 = await insertData(rawContactId, "postal_address", "dddd", ""); + await queryAlldata("contactCard_insertDataAll_test_7600", DAHelper, rawContactId, contactdatd6, "dddd"); + var contactdatd7 = await insertData(rawContactId, "note", "caicai", ""); + await queryAlldata("contactCard_insertDataAll_test_7600", DAHelper, rawContactId, contactdatd7, "caicai"); + var contactdatd8 = await insertData(rawContactId, "im", "999999999", ""); + await queryAlldata( + "contactCard_insertDataAll_test_7600", DAHelper, rawContactId, contactdatd8, "999999999"); + sleep(1000); + await deleteRawContact("contactCard_insertDataAll_test_7600"); + await deleteAll(profileContactDataUri, "contactCard_insertDataAll_test_7600"); + done(); + } catch (error) { + console.info("logMessage contactCard_insertDataAll_test_7600: raw_contact insert error = " + error); + done(); + } + }); + + async function queryAlldata(tag, DAHelper, rawContactId, contactdata, values) { + var resultColumns = ["raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", contactdata.toString()); + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var id = resultSet.getString(resultSet.getColumnIndex("raw_contact_id")); + console.info(tag + " result raw_contact_id = " + id); + expect(id == rawContactId).assertEqual(true); + var info = resultSet.getString(resultSet.getColumnIndex("detail_info")); + console.info(tag + "result info = " + info + " value = " + values); + expect(info == values).assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info(tag + " :logMessage queryIdForDelete: error = " + error); + } + } + + /** + * @tc.number contactCard_insertDataAll_test_7700 + * @tc.name Add all details of a single contact and verify whether the insertion is successful (name, mobile + * number, company, position, nickname, email, home, remarks, aim, birthday, website, assistant, group, phone ring) + * @tc.desc Function test + */ + it("contactCard_insertDataAll_test_7700", 0, async function (done) { + console.info("------logMessage contactCard_insertDataAll_test_7700 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocai", + }; + try { + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_insertDataAll_test_7700: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var contactdata1 = await insertData(rawContactId, "name", "xiaocai", ""); + await queryAlldata("contactCard_insertDataAll_test_7700", DAHelper, rawContactId, contactdata1, "xiaocai"); + var contactdata2 = await insertData(rawContactId, "phone", "6500", ""); + await queryAlldata("contactCard_insertDataAll_test_7700", DAHelper, rawContactId, contactdata2, "6500"); + var contactdatd3 = await insertData(rawContactId, "organization", "TTTTT", "Deve"); + await queryAlldata("contactCard_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd3, "TTTTT"); + var contactdatd4 = await insertData(rawContactId, "nickname", "xxxxcai", ""); + await queryAlldata("contactCard_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd4, "xxxxcai"); + var contactdatd5 = await insertData(rawContactId, "email", "111@fox.com", ""); + await queryAlldata( + "contactCard_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd5, "111@fox.com"); + var contactdatd6 = await insertData(rawContactId, "postal_address", "dddd", ""); + await queryAlldata("contactCard_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd6, "dddd"); + var contactdatd7 = await insertData(rawContactId, "note", "caicai", ""); + await queryAlldata("contactCard_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd7, "caicai"); + var contactdatd8 = await insertData(rawContactId, "im", "999999999", ""); + await queryAlldata( + "contactCard_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd8, "999999999"); + var contactdatd9 = await insertData(rawContactId, "contact_event", "1125", ""); + await queryAlldata("contactCard_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd9, "1125"); + var contactdatd10 = await insertData(rawContactId, "website", "wwww.xxx.com", ""); + await queryAlldata( + "contactCard_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd10, "wwww.xxx.com"); + var contactdatd11 = await insertData(rawContactId, "relation", "xiaobai", ""); + await queryAlldata("contactCard_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd11, "xiaobai"); + var contactdatd12 = await insertData(rawContactId, "group_membership", 1, ""); + await queryAlldata("contactCard_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd12, 1); + var contactdatd13 = await insertData(rawContactId, "contact_misc", "5678", ""); + await queryAlldata("contactCard_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd13, "5678"); + sleep(1000); + await deleteRawContact("contactCard_insertDataAll_test_7700"); + await deleteAll(profileContactDataUri, "contactCard_insertDataAll_test_7700"); + done(); + } catch (error) { + console.info("logMessage contactCard_insertDataAll_test_7700: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number contactCard_insertDataUpdateMore_test_7800 + * @tc.name Modify multiple contact details and verify whether the modification is successful + * @tc.desc Function test + */ + it("contactCard_insertDataUpdateMore_test_7800", 0, async function (done) { + console.info("------logMessage contactCard_insertDataUpdateMore_test_7800 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var insertRawContactValues = { + "display_name": "xiaocai" + }; + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_insertDataUpdateMore_test_7800: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + + var insertRawContactValues = { + "display_name": "xiaotian" + }; + var rawContactIdFirst = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_insertDataUpdateMore_test_7800: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + await insertData(rawContactId, "name", "xiaotian", ""); + + var updateValues = { + "detail_info": "xiaocai7800" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + condition.or(); + condition.equalTo("raw_contact_id", rawContactIdFirst.toString()) + var updataCode = await DAHelper.update(profileContactDataUri, updateValues, condition); + console.info('logMessage contactCard_insertDataUpdateMore_test_7800: updataCode = ' + updataCode); + sleep(1000); + await insertDataUpdateMoreQuery( + "contactCard_insertDataUpdateMore_test_7800", DAHelper, rawContactId, rawContactIdFirst); + await deleteRawContact("contactCard_insertDataUpdateMore_test_7800"); + await deleteAll(profileContactDataUri, "contactCard_insertDataUpdateMore_test_7800"); + done(); + } catch (error) { + console.info("logMessage contactCard_insertDataUpdateMore_test_7800: raw_contact insert error = " + error); + done(); + } + }); + + async function insertDataUpdateMoreQuery(tag, DAHelper, rawContactId, rawContactIdFirst) { + var resultColumns = ["detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + condition.or(); + condition.equalTo("raw_contact_id", rawContactIdFirst.toString()) + try { + var resultSet = await DAHelper.query(profileContactDataUri, resultColumns, condition); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var info = resultSet.getString(resultSet.getColumnIndex("detail_info")); + console.info(tag + "result info = " + info); + expect(info == "xiaocai7800").assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info(tag + " :logMessage : error = " + error); + } + } + + /** + * @tc.number contactCard_deleterestore_test_7900 + * @tc.name Modify multiple contact details and verify whether the modification is successful + * @tc.desc Function test + */ + it("contactCard_deleterestore_test_7900", 0, async function (done) { + console.info("------logMessage contactCard_deleterestore_test_7900 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var insertRawContactValues = { + "display_name": "xaioli7900" + }; + var rawContactId = await DAHelper.insert(profileRawContactUri, insertRawContactValues); + console.info("logMessage contactCard_deleterestore_test_7900: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + sleep(1000); + var condition1 = new ohosDataAbility.DataAbilityPredicates(); + condition1.equalTo("id", rawContactId.toString()); + var deleteCode = await DAHelper.delete(profileRawContactUri, condition1); + console.info("contactCard_deleterestore_test_7900 : deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + sleep(1000); + + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + condition2.equalTo("id", rawContactId.toString()); + var updatevalue = { + "is_deleted": 0 + }; + var updateCode = await DAHelper.update(profileRawContactUri, updatevalue, condition2); + console.info('contactCard_deleterestore_test_7900 : update = ' + updateCode); + sleep(1000); + + var condition3 = new ohosDataAbility.DataAbilityPredicates(); + condition3.equalTo("id", rawContactId.toString()); + var deleteCode = await DAHelper.delete(profileDeletedRawContactRecord, condition3); + + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("is_deleted", "0"); + await contactsQuery(map, "contactCard_deleterestore_test_7900", profileRawContactUri); + done(); + } catch (error) { + console.info("logMessage contactCard_deleterestore_test_7900: raw_contact insert error = " + error); + done(); + } + }); + + afterAll(async function () { + var tag = "Contacts_test_start_deleted"; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + var DAHelperContact = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': start ! DAHelperContact = ' + DAHelperContact); + var deleteBlockList = await DAHelperContact.delete(profileBlocklistUri, condition); + console.info(tag + " : logMessage : deleteBlockList = " + deleteBlockList); + var deletedGroup = await DAHelperContact.delete(profileGroupUri, condition); + console.info(tag + " : logMessage : deletedGroup = " + deletedGroup); + var dataDeletedCode = await DAHelperContact.delete(profileContactDataUri, condition); + sleep(2000); + console.info(tag + " : logMessage : dataDeletedCode = " + dataDeletedCode); + var rawContactDeleted = await DAHelperContact.delete(profileRawContactUri, condition); + sleep(2000); + console.info(tag + " : logMessage : rawContactDeleted = " + rawContactDeleted); + var deleted = await DAHelperContact.delete(profileDeletedContactsUri, condition); + sleep(2000); + console.info(tag + " : logMessage : deleted = " + deleted); + }); + }); +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/ContactClass_test.js b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/ContactClass_test.js new file mode 100644 index 0000000000000000000000000000000000000000..38c4158bd6ed99d46cf9db4856f228f5d4b18ec8 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/ContactClass_test.js @@ -0,0 +1,310 @@ +/* + * Copyright (c) 2021 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 utils from '../Utils.ets' +import {describe, expect, it} from 'deccjsunit/index' + +export default function ContactClassTest() { + describe('ContactClassTest', function () { + console.log('*************ContactClassTest is start*************'); + + /* * + * @tc.number : telephony_contact_phoneNumber_test_0100 + * @tc.name : CUSTOM_LABEL NUM_HOME NUM_MOBILE NUM_WORK NUM_FAX_WORK + * @tc.desc : check class PhoneNumber + */ + it("telephony_contact_phoneNumber_test_0100", 0, async function (done) { + console.log("************* telephony_contact_phoneNumber_test_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + try { + expect(0).assertEqual(contact.PhoneNumber.CUSTOM_LABEL); + expect(1).assertEqual(contact.PhoneNumber.NUM_HOME); + expect(2).assertEqual(contact.PhoneNumber.NUM_MOBILE); + expect(3).assertEqual(contact.PhoneNumber.NUM_WORK); + expect(4).assertEqual(contact.PhoneNumber.NUM_FAX_WORK); + done(); + } catch (error) { + console.log("telephony_contact_phoneNumber_test_0100 error " + error.message); + } + console.log("************* telephony_contact_phoneNumber_test_0100 Test end*************"); + }); + + /* * + * @tc.number : telephony_contact_phoneNumber_test_0200 + * @tc.name : NUM_FAX_HOME NUM_PAGER NUM_OTHER NUM_CALLBACK NUM_CAR + * @tc.desc : check class PhoneNumber + */ + it("telephony_contact_phoneNumber_test_0200", 0, async function (done) { + console.log("************* telephony_contact_phoneNumber_test_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(5).assertEqual(contact.PhoneNumber.NUM_FAX_HOME); + expect(6).assertEqual(contact.PhoneNumber.NUM_PAGER); + expect(7).assertEqual(contact.PhoneNumber.NUM_OTHER); + expect(8).assertEqual(contact.PhoneNumber.NUM_CALLBACK); + expect(9).assertEqual(contact.PhoneNumber.NUM_CAR); + done(); + console.log("************* telephony_contact_phoneNumber_test_0200 Test end*************"); + }); + + /* * + * @tc.number : telephony_contact_phoneNumber_test_0300 + * @tc.name : NUM_COMPANY_MAIN NUM_ISDN NUM_MAIN NUM_OTHER_FAX NUM_RADIO + * @tc.desc : check class PhoneNumber + */ + it("telephony_contact_phoneNumber_test_0300", 0, async function (done) { + console.log("************* telephony_contact_phoneNumber_test_0300 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(10).assertEqual(contact.PhoneNumber.NUM_COMPANY_MAIN); + expect(11).assertEqual(contact.PhoneNumber.NUM_ISDN); + expect(12).assertEqual(contact.PhoneNumber.NUM_MAIN); + expect(13).assertEqual(contact.PhoneNumber.NUM_OTHER_FAX); + expect(14).assertEqual(contact.PhoneNumber.NUM_RADIO); + done(); + console.log("************* telephony_contact_phoneNumber_test_0300 Test end*************"); + }); + + /* * + * @tc.number : telephony_contact_phoneNumber_test_0400 + * @tc.name : NUM_TELEX NUM_TTY_TDD NUM_WORK_MOBILE NUM_WORK_PAGER NUM_ASSISTANT NUM_MMS INVALID_LABEL_ID labelName + * @tc.desc : check class PhoneNumber + */ + it("telephony_contact_phoneNumber_test_0400", 0, async function (done) { + console.log("************* telephony_contact_phoneNumber_test_0400 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(15).assertEqual(contact.PhoneNumber.NUM_TELEX); + expect(16).assertEqual(contact.PhoneNumber.NUM_TTY_TDD); + expect(17).assertEqual(contact.PhoneNumber.NUM_WORK_MOBILE); + expect(18).assertEqual(contact.PhoneNumber.NUM_WORK_PAGER); + expect(19).assertEqual(contact.PhoneNumber.NUM_ASSISTANT); + expect(20).assertEqual(contact.PhoneNumber.NUM_MMS); + expect(-1).assertEqual(contact.PhoneNumber.INVALID_LABEL_ID); + expect(typeof contact.PhoneNumber.labelName).assertEqual("string"); + done(); + console.log("************* telephony_contact_phoneNumber_test_0400 Test end*************"); + }); + + /* * + * @tc.number : telephony_contact_postalAddress_test_0100 + * @tc.name : CUSTOM_LABEL ADDR_HOME ADDR_WORK ADDR_OTHER INVALID_LABEL_ID + * @tc.desc : check class PostalAddress + */ + it("telephony_contact_postalAddress_test_0100", 0, async function (done) { + console.log("************* telephony_contact_postalAddress_test_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(0).assertEqual(contact.PostalAddress.CUSTOM_LABEL); + expect(1).assertEqual(contact.PostalAddress.ADDR_HOME); + expect(2).assertEqual(contact.PostalAddress.ADDR_WORK); + expect(3).assertEqual(contact.PostalAddress.ADDR_OTHER); + expect(-1).assertEqual(contact.PostalAddress.INVALID_LABEL_ID); + done(); + console.log("************* telephony_contact_postalAddress_test_0100 Test end*************"); + }); + + /* * + * @tc.number : telephony_contact_postalAddress_test_0200 + * @tc.name : labelName neighborhood pobox postalAddress postcode street + * @tc.desc : check class PostalAddress + */ + it("telephony_contact_postalAddress_test_0200", 0, async function (done) { + console.log("************* telephony_contact_postalAddress_test_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + try { + var postalAddress = new contact.PostalAddress({ + 'labelName': 'testLabel', + 'neighborhood': 'beijing', + 'pobox': 'testBox', + 'postalAddress': 'testAddress', + 'postcode': 'testCode', + 'street': 'testStreet' + }) + expect(postalAddress.labelName).assertEqual('testLabel'); + expect(postalAddress.neighborhood).assertEqual('beijing'); + expect(postalAddress.pobox).assertEqual('testBox'); + expect(postalAddress.postalAddress).assertEqual('testAddress'); + expect(postalAddress.postcode).assertEqual('testCode'); + expect(postalAddress.street).assertEqual('testStreet'); + } catch (err) { + console.log("telephony_contact_postalAddress_test_0200 test error " + err.message); + } + done(); + console.log("************* telephony_contact_postalAddress_test_0200 Test end*************"); + }); + + /* * + * @tc.number : telephony_contact_relation_test_0100 + * @tc.name : CUSTOM_LABEL ADDR_HOME ADDR_WORK ADDR_OTHER INVALID_LABEL_ID + * @tc.desc : check class Relation + */ + it("telephony_contact_relation_test_0100", 0, async function (done) { + console.log("************* telephony_contact_relation_test_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(0).assertEqual(contact.Relation.CUSTOM_LABEL); + expect(1).assertEqual(contact.Relation.RELATION_ASSISTANT); + expect(2).assertEqual(contact.Relation.RELATION_BROTHER); + expect(3).assertEqual(contact.Relation.RELATION_CHILD); + expect(4).assertEqual(contact.Relation.RELATION_DOMESTIC_PARTNER); + done(); + console.log("************* telephony_contact_relation_test_0100 Test end*************"); + }); + + /* * + * @tc.number : telephony_contact_relation_test_0200 + * @tc.name : RELATION_FATHER RELATION_FRIEND RELATION_MANAGER RELATION_MOTHER RELATION_PARENT + * @tc.desc : check class Relation + */ + it("telephony_contact_relation_test_0200", 0, async function (done) { + console.log("************* telephony_contact_relation_test_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(5).assertEqual(contact.Relation.RELATION_FATHER); + expect(6).assertEqual(contact.Relation.RELATION_FRIEND); + expect(7).assertEqual(contact.Relation.RELATION_MANAGER); + expect(8).assertEqual(contact.Relation.RELATION_MOTHER); + expect(9).assertEqual(contact.Relation.RELATION_PARENT); + done(); + console.log("************* telephony_contact_relation_test_0200 Test end*************"); + }); + + /* * + * @tc.number : telephony_contact_Relation_test_0300 + * @tc.name : RELATION_PARTNER RELATION_REFERRED_BY RELATION_RELATIVE + RELATION_SISTER RELATION_SPOUSE INVALID_LABEL_ID + * @tc.desc : check class Relation + */ + it("telephony_contact_relation_test_0300", 0, async function (done) { + console.log("************* telephony_contact_relation_test_0300 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(10).assertEqual(contact.Relation.RELATION_PARTNER); + expect(11).assertEqual(contact.Relation.RELATION_REFERRED_BY); + expect(12).assertEqual(contact.Relation.RELATION_RELATIVE); + expect(13).assertEqual(contact.Relation.RELATION_SISTER); + expect(14).assertEqual(contact.Relation.RELATION_SPOUSE); + expect(-1).assertEqual(contact.Relation.INVALID_LABEL_ID); + done(); + console.log("************* telephony_contact_relation_test_0300 Test end*************"); + }); + + /* * + * @tc.number : telephony_contact_relation_test_0400 + * @tc.name : labelName relationName + * @tc.desc : check class Relation + */ + it("telephony_contact_relation_test_0400", 0, async function (done) { + console.log("************* telephony_contact_relation_test_0400 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + try { + var relation = new contact.Relation({ + 'labelName': 'testLabel', + 'relationName': 'testRelation' + }) + expect(relation.labelName).assertEqual('testLabel'); + expect(relation.relationName).assertEqual('testRelation'); + } catch (err) { + console.log("telephony_contact_relation_test_0400 test error " + err.message); + } + done(); + console.log("************* telephony_contact_relation_test_0400 Test end*************"); + }); + + /* * + * @tc.number : telephony_contact_sipAddress_test_0100 + * @tc.name : CUSTOM_LABEL SIP_HOME SIP_WORK SIP_OTHER INVALID_LABEL_ID + * @tc.desc : check class SipAddress + */ + it("telephony_contact_sipAddress_test_0100", 0, async function (done) { + console.log("************* telephony_contact_sipAddress_test_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(0).assertEqual(contact.SipAddress.CUSTOM_LABEL); + expect(1).assertEqual(contact.SipAddress.SIP_HOME); + expect(2).assertEqual(contact.SipAddress.SIP_WORK); + expect(3).assertEqual(contact.SipAddress.SIP_OTHER); + expect(-1).assertEqual(contact.SipAddress.INVALID_LABEL_ID); + done(); + console.log("************* telephony_contact_sipAddress_test_0100 Test end*************"); + }); + + /* * + * @tc.number : telephony_contact_sipAddress_test_0200 + * @tc.name : labelName sipAddress + * @tc.desc : check class SipAddress + */ + it("telephony_contact_sipAddress_test_0200", 0, async function (done) { + console.log("************* telephony_contact_sipAddress_test_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + + try { + var sip = new contact.SipAddress({ + 'labelName': 'testLabel', + 'sipAddress': 'testSip' + }) + expect(sip.labelName).assertEqual('testLabel'); + expect(sip.sipAddress).assertEqual('testSip'); + } catch (err) { + console.log("telephony_contact_sipAddress_test_0200 test error " + err.message); + } + done(); + console.log("************* telephony_contact_sipAddress_test_0200 Test end*************"); + }); + console.log('*************ContactClassTest is end*************'); + }) +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/ContacterJsunit.ets b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/ContacterJsunit.ets new file mode 100644 index 0000000000000000000000000000000000000000..a5e2873bfab59f8bf597a1190f6839e92841e89c --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/ContacterJsunit.ets @@ -0,0 +1,262 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import contact from '@ohos.contact'; +import utils from '../Utils.ets' + +export default function contacterJsunit() { + describe('ContacterTest',function () { + /** + * @tc.number Telephony_contact_Contact_0100 + * @tc.name Test The Contact enum + * @tc.desc Function test + */ + + it('Telephony_contact_Contact_0100', 0, async function (done) { + console.info("Telephony_contact_Contact_0100 start") + if(utils.notCheck){ + done(); + return; + } + expect(contact.Contact.INVALID_CONTACT_ID === -1).assertTrue(); + expect(contact.Contact.id === 0).assertTrue(); + expect(contact.Contact.key !== "test").assertTrue(); + console.info("Telephony_contact_Contact_0100 end") + done(); + }); + + /** + * @tc.number Telephony_contact_Contact_0200 + * @tc.name Test The Contact enum + * @tc.desc Function test + */ + + it('Telephony_contact_Contact_0200', 0, async function (done) { + console.info("Telephony_contact_Contact_0200 start") + if(utils.notCheck){ + done(); + return; + } + expect(contact.Contact.INVALID_CONTACT_ID === -1).assertTrue(); + expect(contact.Contact.id === 1).assertTrue(); + expect(contact.Contact.key !== "key").assertTrue(); + console.info("Telephony_contact_Contact_0200 end") + done(); + }); + + /** + * @tc.number Telephony_contact_Attribute_0100 + * @tc.name Test The Attribute enum + * @tc.desc Function test + */ + it('Telephony_contact_Attribute_0100', 0, async function (done) { + console.info("Telephony_contact_Attribute_0100 start") + if(utils.notCheck){ + done(); + return; + } + expect(contact.Attribute.ATTR_CONTACT_EVENT === 0).assertTrue(); + expect(contact.Attribute.ATTR_EMAIL === 0).assertTrue(); + expect(contact.Attribute.ATTR_GROUP_MEMBERSHIP === 0).assertTrue(); + expect(contact.Attribute.ATTR_IM === 0).assertTrue(); + expect(contact.Attribute.ATTR_NAME === 0).assertTrue(); + expect(contact.Attribute.ATTR_NICKNAME === 0).assertTrue(); + expect(contact.Attribute.ATTR_NOTE === 0).assertTrue(); + expect(contact.Attribute.ATTR_ORGANIZATION === 0).assertTrue(); + expect(contact.Attribute.ATTR_PHONE === 0).assertTrue(); + expect(contact.Attribute.ATTR_PORTRAIT === 0).assertTrue(); + expect(contact.Attribute.ATTR_POSTAL_ADDRESS === 0).assertTrue(); + expect(contact.Attribute.ATTR_RELATION === 0).assertTrue(); + expect(contact.Attribute.ATTR_SIP_ADDRESS === 0).assertTrue(); + expect(contact.Attribute.ATTR_WEBSITE === 0).assertTrue(); + console.info("Telephony_contact_Attribute_0100 end") + done(); + }); + + /** + * @tc.number Telephony_contact_Attribute_0200 + * @tc.name Test The Attribute enum + * @tc.desc Function test + */ + it('Telephony_contact_Attribute_0200', 0, async function (done) { + console.info("Telephony_contact_Attribute_0100 start") + if(utils.notCheck){ + done(); + return; + } + expect(contact.Attribute.ATTR_CONTACT_EVENT === 1).assertTrue(); + expect(contact.Attribute.ATTR_EMAIL === 1).assertTrue(); + expect(contact.Attribute.ATTR_GROUP_MEMBERSHIP === 1).assertTrue(); + expect(contact.Attribute.ATTR_IM === 1).assertTrue(); + expect(contact.Attribute.ATTR_NAME === 1).assertTrue(); + expect(contact.Attribute.ATTR_NICKNAME === 1).assertTrue(); + expect(contact.Attribute.ATTR_NOTE === 1).assertTrue(); + expect(contact.Attribute.ATTR_ORGANIZATION === 1).assertTrue(); + expect(contact.Attribute.ATTR_PHONE === 1).assertTrue(); + expect(contact.Attribute.ATTR_PORTRAIT === 1).assertTrue(); + expect(contact.Attribute.ATTR_POSTAL_ADDRESS === 1).assertTrue(); + expect(contact.Attribute.ATTR_RELATION === 1).assertTrue(); + expect(contact.Attribute.ATTR_SIP_ADDRESS === 1).assertTrue(); + expect(contact.Attribute.ATTR_WEBSITE === 1).assertTrue(); + console.info("Telephony_contact_Attribute_0200 end") + done(); + }); + + /** + * @tc.number Telephony_contact_Email_0100 + * @tc.name Test The Attribute Email + * @tc.desc Function test + */ + it('Telephony_contact_Email_0100', 0, async function (done) { + console.info("Telephony_contact_Email_0100 start") + if(utils.notCheck){ + done(); + return; + } + expect(contact.Email.CUSTOM_LABEL === 0).assertTrue(); + expect(contact.Email.EMAIL_HOME === 1).assertTrue(); + expect(contact.Email.EMAIL_WORK === 2).assertTrue(); + expect(contact.Email.EMAIL_OTHER === 3).assertTrue(); + expect(contact.Email.INVALID_LABEL_ID === -1).assertTrue(); + expect(contact.Email.email !== "email").assertTrue(); + expect(contact.Email.labelName !== "email").assertTrue(); + expect(contact.Email.displayName !== "email").assertTrue(); + console.info("Telephony_contact_Email_0100 end") + done(); + }); + + /** + * @tc.number Telephony_contact_Email_0200 + * @tc.name Test The Attribute Email + * @tc.desc Function test + */ + it('Telephony_contact_Email_0200', 0, async function (done) { + console.info("Telephony_contact_Email_0200 start") + if(utils.notCheck){ + done(); + return; + } + expect(contact.Email.CUSTOM_LABEL === 0).assertTrue(); + expect(contact.Email.EMAIL_HOME === 1).assertTrue(); + expect(contact.Email.EMAIL_WORK === 2).assertTrue(); + expect(contact.Email.EMAIL_OTHER === 3).assertTrue(); + expect(contact.Email.INVALID_LABEL_ID === -1).assertTrue(); + expect(contact.Email.email !== "email2").assertTrue(); + expect(contact.Email.labelName !== "email2").assertTrue(); + expect(contact.Email.displayName !== "email2").assertTrue(); + console.info("Telephony_contact_Email_0200 end") + done(); + }); + + /** + * @tc.number Telephony_contact_Event_0100 + * @tc.name Test The Attribute Event + * @tc.desc Function test + */ + it('Telephony_contact_Event_0100', 0, async function (done) { + console.info("Telephony_contact_Event_0100 start") + if(utils.notCheck){ + done(); + return; + } + expect(contact.Event.CUSTOM_LABEL === 0).assertTrue(); + expect(contact.Event.EVENT_ANNIVERSARY === 1).assertTrue(); + expect(contact.Event.EVENT_OTHER === 2).assertTrue(); + expect(contact.Event.EVENT_BIRTHDAY === 3).assertTrue(); + expect(contact.Event.INVALID_LABEL_ID === -1).assertTrue(); + expect(contact.Event.eventDate !== "event").assertTrue(); + expect(contact.Event.labelName !== "event").assertTrue(); + console.info("Telephony_contact_Event_0100 end") + done(); + }); + + /** + * @tc.number Telephony_contact_Event_0200 + * @tc.name Test The Attribute Event + * @tc.desc Function test + */ + it('Telephony_contact_Event_0200', 0, async function (done) { + console.info("Telephony_contact_Event_0200 start") + if(utils.notCheck){ + done(); + return; + } + expect(contact.Event.CUSTOM_LABEL === 0).assertTrue(); + expect(contact.Event.EVENT_ANNIVERSARY === 1).assertTrue(); + expect(contact.Event.EVENT_OTHER === 2).assertTrue(); + expect(contact.Event.EVENT_BIRTHDAY === 3).assertTrue(); + expect(contact.Event.INVALID_LABEL_ID === -1).assertTrue(); + expect(contact.Event.eventDate !== "event2").assertTrue(); + expect(contact.Event.labelName !== "event2").assertTrue(); + console.info("Telephony_contact_Event_0200 end") + done(); + }); + + /** + * @tc.number Telephony_contact_ImAddress_0100 + * @tc.name Test The Attribute ImAddress + * @tc.desc Function test + */ + it('Telephony_contact_ImAddress_0100', 0, async function (done) { + console.info("Telephony_contact_ImAddress_0100 start") + if(utils.notCheck){ + done(); + return; + } + expect(contact.ImAddress.CUSTOM_LABEL === -1).assertTrue(); + expect(contact.ImAddress.IM_AIM === 0).assertTrue(); + expect(contact.ImAddress.IM_MSN === 1).assertTrue(); + expect(contact.ImAddress.IM_YAHOO === 2).assertTrue(); + expect(contact.ImAddress.IM_SKYPE === 3).assertTrue(); + expect(contact.ImAddress.IM_QQ === 4).assertTrue(); + expect(contact.ImAddress.IM_ICQ === 6).assertTrue(); + expect(contact.ImAddress.IM_JABBER === 7).assertTrue(); + expect(contact.ImAddress.INVALID_LABEL_ID === -2).assertTrue(); + expect(contact.ImAddress.imAddress !== "imAddress").assertTrue(); + expect(contact.ImAddress.labelName !== "imAddress").assertTrue(); + console.info("Telephony_contact_ImAddress_0100 end") + done(); + }); + + /** + * @tc.number Telephony_contact_ImAddress_0200 + * @tc.name Test The Attribute ImAddress + * @tc.desc Function test + */ + it('Telephony_contact_ImAddress_0200', 0, async function (done) { + console.info("Telephony_contact_ImAddress_0100 start") + if(utils.notCheck){ + done(); + return; + } + expect(contact.ImAddress.CUSTOM_LABEL === -1).assertTrue(); + expect(contact.ImAddress.IM_AIM === 0).assertTrue(); + expect(contact.ImAddress.IM_MSN === 1).assertTrue(); + expect(contact.ImAddress.IM_YAHOO === 2).assertTrue(); + expect(contact.ImAddress.IM_SKYPE === 3).assertTrue(); + expect(contact.ImAddress.IM_QQ === 4).assertTrue(); + expect(contact.ImAddress.IM_ICQ === 6).assertTrue(); + expect(contact.ImAddress.IM_JABBER === 7).assertTrue(); + expect(contact.ImAddress.INVALID_LABEL_ID === -2).assertTrue(); + expect(contact.ImAddress.imAddress !== "imAddress2").assertTrue(); + expect(contact.ImAddress.labelName !== "imAddress2").assertTrue(); + console.info("Telephony_contact_ImAddress_0200 end") + done(); + }); + + }) +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/Contacts_test.js b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/Contacts_test.js new file mode 100644 index 0000000000000000000000000000000000000000..b3fe8365b2fc01316158d10023f0ee835ae0879a --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/Contacts_test.js @@ -0,0 +1,6306 @@ +/* + * Copyright (c) 2021 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 featureAbility from '@ohos.ability.featureAbility'; +import ohosDataAbility from '@ohos.data.dataability'; +import utils from '../Utils.ets' +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'deccjsunit/index' +import common from './common.js'; + +const URI_CONTACTS = "dataability:///com.ohos.contactsdataability"; +const contactUri = "dataability:///com.ohos.contactsdataability/contacts/contact"; +const rawContactUri = "dataability:///com.ohos.contactsdataability/contacts/raw_contact"; +const contactDataUri = "dataability:///com.ohos.contactsdataability/contacts/contact_data"; +const groupUri = "dataability:///com.ohos.contactsdataability/contacts/groups"; +const contactBlocklistUri = "dataability:///com.ohos.contactsdataability/contacts/contact_blocklist"; +const deletedRawContactUri = "dataability:///com.ohos.contactsdataability/contacts/deleted_raw_contact"; +const searchContactUri = "dataability:///com.ohos.contactsdataability/contacts/search_contact"; +const deletedUri = "dataability:///com.ohos.contactsdataability/contacts/deleted_raw_contact"; +const deletedRawContactRecord = "dataability:///com.ohos.contactsdataability/contacts/deleted_raw_contact_record"; + +export default function ContactsTest() { + describe('ContactsTest', function () { + console.info("-------ContactsTest is starting!--------"); + + function sleep(numberMillis) { + var now = new Date(); + var exitTime = now.getTime() + numberMillis; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) + return; + } + } + + async function contactsQuery(map, tag, uri) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': contactsQuery start ! DAHelper = ' + DAHelper); + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", map.get("id")); + try { + var resultSet = await DAHelper.query(uri, resultColumns, condition); + sleep(2000); + if (resultSet.rowCount > 0 && resultSet.goToFirstRow()) { + do { + for (var [key, value] of map) { + var dbresult = resultSet.getString(resultSet.getColumnIndex(key)); + console.info(tag + ' :logMessage contactsQuery key = ' + key + ' dbresult :' + dbresult + + ' value : ' + value); + expect(value == dbresult).assertEqual(true); + } + } while (resultSet.goToNextRow()); + } + + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage contactsQuery: error = " + error); + } + } + + async function queryBatch(map, tag, size) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': queryBatch start ! DAHelper = ' + DAHelper); + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", map.get("raw_contact_id")); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + sleep(1000); + console.info(tag + ': queryBatch start ! resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == size).assertEqual(true); + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage resultSet.rowCount: error = " + error); + } + } + + async function queryIdForDelete(map, tag, uri) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': queryIdForDelete start ! DAHelper = ' + DAHelper); + var resultColumns = common.getCallLogResultColumns(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", map.get("id")); + try { + var resultSet = await DAHelper.query(uri, resultColumns, condition); + sleep(1000); + expect(resultSet.goToFirstRow() == false).assertTrue(); + console.info(tag + " :logMessage queryIdForDelete: goToFirstRow " + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info(tag + " :logMessage queryIdForDelete: error = " + error); + } + } + + async function deleteAll(uri, tag) { + try { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + var deleteCode = await DAHelper.delete(uri, condition); + console.info(tag + ': deleteAll deleteCode = ' + deleteCode); + expect(deleteCode == 0).assertTrue(); + } catch (error) { + console.info(tag + ': deleteAll error = ' + error); + } + } + + async function deleteRawContact(tag) { + try { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + condition.and(); + condition.equalTo("is_deleted", "0"); + var deleteCode = await DAHelper.delete(rawContactUri, condition); + console.info(tag + ': deleteRawContact deleteCode = ' + deleteCode); + expect(deleteCode == 0).assertTrue(); + sleep(1000); + var conditionAll = new ohosDataAbility.DataAbilityPredicates(); + conditionAll.greaterThan("id", "0"); + var code = await DAHelper.delete(deletedUri, conditionAll); + console.info(tag + ': Completely delete code = ' + code); + expect(code == 0).assertTrue(); + } catch (error) { + console.info(tag + ': deleteRawContact error = ' + error); + } + } + + async function insertData(rawContactId, type, value, position) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var contactDataValues1 = + { + "raw_contact_id": rawContactId, "content_type": type, "detail_info": value, "position": position + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues1); + console.info("logMessage : contactDataId1 " + contactDataId1); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info("logMessage : contact_data name insert error = " + error); + } + return contactDataId; + } + + /** + * @tc.number contact_insert_test_100 + * @tc.name Insert contact data + * @tc.desc Function test + */ + it("contact_insert_test_100", 0, async function (done) { + console.info("------logMessage contact_insert_test_100 is starting!-----"); + if(utils.notCheck){ + expect(true).assertTrue(); + done(); + return; + } + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactId = await DAHelper.insert(rawContactUri, common.getProfileRawContact()); + sleep(1000); + console.info('logMessage contact_insert_test_100: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + var map = common.getProfileRawContactMap(); + map.set("id", rawContactId.toString()); + await contactsQuery(map, "contact_insert_test_100", rawContactUri); + await deleteRawContact("contact_insert_test_100"); + done(); + } catch (error) { + console.info('logMessage contact_insert_test_100: insert error = ' + error); + done(); + } + }); + + /** + * @tc.number contact_insert_test_400 + * @tc.name Insert contact details (name, company, position, mobile phone number) + * @tc.desc Function test + */ + it("contact_insert_test_400", 0, async function (done) { + console.info("------logMessage contact_insert_test_400 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocheng", + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_insert_test_400: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await dataNameInsert(DAHelper, rawContactId); + await dataCompanyInsert(DAHelper, rawContactId); + await dataPhoneInsert(DAHelper, rawContactId); + await deleteRawContact("contact_insert_test_400"); + await deleteAll(contactDataUri, "contact_insert_test_400"); + done(); + } catch (error) { + console.info("logMessage contact_insert_test_400: raw_contact insert error = " + error); + done(); + } + }); + + async function dataNameInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "name", + "detail_info": "xiaocheng" + }; + try { + var contactDataId1 = await DAHelper.insert(contactDataUri, contactDataValues1); + console.info("logMessage contact_insert_test_400: contactDataId1 " + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "xiaocheng"); + map.set("raw_contact_id", rawContactId.toString()); + await contactsQuery(map, "contact_insert_test_400", contactDataUri); + } catch (error) { + console.info("logMessage contact_insert_test_400: contact_data name insert error = " + error); + done(); + } + } + + async function dataCompanyInsert(DAHelper, rawContactId) { + var contactDataValues2 = { + "raw_contact_id": rawContactId, + "content_type": "organization", + "detail_info": "TT", + "position": "developer" + }; + try { + var contactDataId2 = await DAHelper.insert(contactDataUri, contactDataValues2); + console.info("logMessage contact_insert_test_400: contactDataId2 " + contactDataId2); + expect(contactDataId2 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId2.toString()); + map.set("detail_info", "TT"); + map.set("position", "developer"); + contactsQuery(map, "contact_insert_test_400", contactDataUri); + } catch (error) { + console.info("logMessage contact_insert_test_400: contact_data company insert error = " + error); + done(); + } + } + + async function dataPhoneInsert(DAHelper, rawContactId) { + var contactDataValues3 = { + "raw_contact_id": rawContactId, + "content_type": "phone", + "detail_info": "12345678" + }; + try { + var contactDataId3 = await DAHelper.insert(contactDataUri, contactDataValues3); + sleep(1000); + console.info("logMessage contact_insert_test_400: contactDataId3 " + contactDataId3); + expect(contactDataId3 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId3.toString()); + map.set("detail_info", "12345678"); + await contactsQuery(map, "contact_insert_test_400", contactDataUri); + } catch (error) { + console.info("logMessage contact_insert_test_400: contact_data phone insert error = " + error); + done(); + } + } + + /** + * @tc.number contact_insert_test_500 + * @tc.name Insert contact details (nickname, email, home) + * @tc.desc Function test + */ + it("contact_insert_test_500", 0, async function (done) { + console.info("------logMessage contact_insert_test_500 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocheng", + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_insert_test_500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await dataEmailInsert(DAHelper, rawContactId); + await dataNickNameInsert(DAHelper, rawContactId); + await dataPostalAddressInsert(DAHelper, rawContactId); + await deleteRawContact("contact_insert_test_500"); + await deleteAll(contactDataUri, "contact_insert_test_500"); + done(); + } catch (error) { + console.info("logMessage contact_insert_test_500: raw_contact insert error = " + error); + done(); + } + }); + + async function dataEmailInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "email", + "detail_info": "166@163.com" + }; + try { + var contactDataId1 = await DAHelper.insert(contactDataUri, contactDataValues1); + sleep(1000); + console.info("logMessage contact_insert_test_500: contactDataId1 " + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "166@163.com"); + await contactsQuery(map, "contact_insert_test_500_1", contactDataUri); + } catch (error) { + console.info("logMessage contact_insert_test_500: contact_data email insert error = " + error); + } + } + + async function dataNickNameInsert(DAHelper, rawContactId) { + var contactDataValues2 = { + "raw_contact_id": rawContactId, + "content_type": "nickname", + "detail_info": "xiaocheng" + }; + try { + var contactDataId2 = await DAHelper.insert(contactDataUri, contactDataValues2); + console.info("logMessage contact_insert_test_500: contactDataId2 " + contactDataId2); + expect(contactDataId2 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId2.toString()); + map.set("detail_info", "xiaocheng"); + await contactsQuery(map, "contact_insert_test_500_2", contactDataUri); + } catch (error) { + console.info("logMessage contact_insert_test_500: contact_data nickname insert error = " + error); + } + } + + async function dataPostalAddressInsert(DAHelper, rawContactId) { + var contactDataValues3 = { + "raw_contact_id": rawContactId, + "content_type": "postal_address", + "detail_info": "NanJingSoftRoad" + }; + try { + var contactDataId3 = await DAHelper.insert(contactDataUri, contactDataValues3); + console.info("logMessage contact_insert_test_500: contactDataId3 " + contactDataId3); + expect(contactDataId3 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId3.toString()); + map.set("detail_info", "NanJingSoftRoad"); + await contactsQuery(map, "contact_insert_test_500_3", contactDataUri); + } catch (error) { + console.info("logMessage contact_insert_test_500: contact_data postal_address insert error = " + error); + } + } + + /** + * @tc.number contact_insert_test_600 + * @tc.name Insert contact details (remarks, AIM, birthday) + * @tc.desc Function test + */ + it("contact_insert_test_600", 0, async function (done) { + console.info("------logMessage contact_insert_test_600 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocheng", + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues) + console.info("logMessage contact_insert_test_600: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await dataNoteInsert(DAHelper, rawContactId); + await dataAimInsert(DAHelper, rawContactId); + await dataEventInsert(DAHelper, rawContactId); + await deleteRawContact("contact_insert_test_600"); + await deleteAll(contactDataUri, "contact_insert_test_600"); + done(); + } catch (error) { + console.info("logMessage contact_insert_test_600: raw_contact insert error = " + error); + done(); + } + }); + + async function dataNoteInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "note", + "detail_info": "javaGangster" + }; + try { + var contactDataId1 = await DAHelper.insert(contactDataUri, contactDataValues1); + console.info("logMessage contact_insert_test_600: contactDataId1 " + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "javaGangster"); + await contactsQuery(map, "contact_insert_test_600_1", contactDataUri); + } catch (error) { + console.info("logMessage contact_insert_test_600: contact_data note insert error = " + error); + done(); + } + } + + async function dataAimInsert(DAHelper, rawContactId) { + var contactDataValues2 = { + "raw_contact_id": rawContactId, "content_type": "im", "detail_info": "aaaaa" + }; + try { + var contactDataId2 = await DAHelper.insert(contactDataUri, contactDataValues2); + console.info("logMessage contact_insert_test_600: contactDataId2 " + contactDataId2); + expect(contactDataId2 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "aaaaa"); + await contactsQuery(map, "contact_insert_test_600_2", contactDataUri); + } catch (error) { + console.info("logMessage contact_insert_test_600: contact_data aim insert error = " + error); + } + } + + async function dataEventInsert(DAHelper, rawContactId) { + var contactDataValues3 = { + "raw_contact_id": rawContactId, + "content_type": "contact_event", + "detail_info": "19960229" + }; + try { + var contactDataId3 = await DAHelper.insert(contactDataUri, contactDataValues3); + console.info("logMessage contact_insert_test_600: contactDataId3 " + contactDataId3); + expect(contactDataId3 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "19960229"); + await contactsQuery(map, "contact_insert_test_600_3", contactDataUri); + } catch (error) { + console.info("logMessage contact_insert_test_600: contact_data event insert error = " + error); + } + } + + /** + * @tc.number contact_insert_test_700 + * @tc.name Insert contact details (URL, assistant, group) + * @tc.desc Function test + */ + it("contact_insert_test_700", 0, async function (done) { + console.info("------logMessage contact_insert_test_700 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocheng", + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_insert_test_700: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await dataWebsiteInsert(DAHelper, rawContactId); + await dataRelationInsert(DAHelper, rawContactId); + await dataWebsiteInsert(DAHelper, rawContactId); + await deleteRawContact("contact_insert_test_700"); + await deleteAll(contactDataUri, "contact_insert_test_700"); + done(); + } catch (error) { + console.info("logMessage contact_insert_test_700: raw_contact insert error = " + error); + done(); + } + }); + + async function dataWebsiteInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "website", + "detail_info": "www.com" + }; + try { + var contactDataId1 = await DAHelper.insert(contactDataUri, contactDataValues1); + sleep(1000); + console.info("logMessage contact_insert_test_700: contactDataId1 " + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "www.com"); + await contactsQuery(map, "contact_insert_test_700_1", contactDataUri); + await contactDataRelationInsert(); + } catch (error) { + console.info("logMessage contact_insert_test_700: contact_data website insert error = " + error); + } + } + + async function dataRelationInsert(DAHelper, rawContactId) { + var contactDataValues2 = { + "raw_contact_id": rawContactId, + "content_type": "relation", + "detail_info": "Secretary" + }; + try { + var contactDataId2 = await DAHelper.insert(contactDataUri, contactDataValues2); + sleep(1000); + console.info("logMessage contact_insert_test_700: contactDataId2 " + contactDataId2); + expect(contactDataId2 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId2.toString()); + map.set("detail_info", "Secretary"); + await contactsQuery(map, "contact_insert_test_700_2", contactDataUri); + await contactDataGroupInsert(); + } catch (error) { + console.info("logMessage contact_insert_test_700: contact_data relation insert error = " + error); + } + } + + async function dataGroupInsert(DAHelper, rawContactId) { + var contactDataValues3 = { + "raw_contact_id": rawContactId, + "content_type": "group_membership", + "detail_info": "1" + }; + try { + var contactDataId3 = await DAHelper.insert(contactDataUri, contactDataValues3); + sleep(1000); + console.info("logMessage contact_insert_test_700: contactDataId3 " + contactDataId3); + expect(contactDataId3 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId3.toString()); + map.set("detail_info", "1"); + await contactsQuery(map, "contact_insert_test_700_3", contactDataUri); + done(); + } catch (error) { + console.info("logMessage contact_insert_test_700: contact_data group insert error = " + error); + } + } + + /** + * @tc.number contact_insert_test_800 + * @tc.name Insert contact details (phone ringtone) + * @tc.desc Function test + */ + it("contact_insert_test_800", 0, async function (done) { + console.info("------logMessage contact_insert_test_800 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocheng", + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_insert_test_800: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await dataMiscInsert(DAHelper, rawContactId); + await deleteRawContact("contact_insert_test_800"); + await deleteAll(contactDataUri, "contact_insert_test_800"); + done(); + } catch (error) { + console.info("logMessage contact_insert_test_800: raw_contact insert error = " + error); + done(); + } + }); + + async function dataMiscInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "contact_misc", + "detail_info": "1234" + }; + try { + var contactDataId1 = await DAHelper.insert(contactDataUri, contactDataValues1); + sleep(1000); + console.info("logMessage contact_insert_test_800: contactDataId1 " + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "1234"); + await contactsQuery(map, "contact_insert_test_800_1", contactDataUri); + } catch (error) { + console.info("logMessage contact_insert_test_800: contact_data misc insert error = " + error); + } + } + + /** + * @tc.number contact_update_test_900 + * @tc.name Update contact data + * @tc.desc Function test + */ + it("contact_update_test_900", 0, async function (done) { + console.info("------logMessage contact_update_test_900 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "licheng", + "company": "TT", + "position": "developer", + "favorite": 1, + "phonetic_name": "licheng||lc" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_update_test_900: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await rawContactUpdate(DAHelper, rawContactId); + await deleteRawContact("contact_update_test_900"); + await deleteAll(contactDataUri, "contact_update_test_900"); + done(); + } catch (error) { + console.info("logMessage contact_update_test_900: raw_contact insert error = " + error); + done(); + } + }); + + async function rawContactUpdate(DAHelper, rawContactId) { + var updateValues = { + "display_name": "dacheng", + "company": "oo", + "position": "Testers", + "favorite": 0, + "phonetic_name": "dacheng||dc" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(rawContactUri, updateValues, condition); + sleep(1000); + console.info('logMessage contact_update_test_900: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "dacheng"); + map.set("company", "oo"); + map.set("position", "Testers"); + map.set("favorite", "0"); + map.set("phonetic_name", "dacheng||dc"); + await contactsQuery(map, "contact_update_test_900", rawContactUri); + } catch (error) { + console.info('logMessage contact_update_test_900: raw_contact update error = ' + error); + } + } + + /** + * @tc.number contact_update_test_1200 + * @tc.name Update contact details (name) + * @tc.desc Function test + */ + it("contact_update_test_1200", 0, async function (done) { + console.info("------logMessage contact_update_test_1200 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_update_test_1200: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforedataNameInsert(DAHelper, rawContactId); + await dataNameUpdate(DAHelper, rawContactId); + await deleteRawContact("contact_update_test_1200"); + await deleteAll(contactDataUri, "contact_update_test_1200"); + done(); + } catch (error) { + console.info('logMessage contact_update_test_1200: raw_contact insert error = ' + error); + done(); + } + }); + + async function beforedataNameInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": "name", "detail_info": "xiaoyuan" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contact_update_test_1200: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_update_test_1200: contact_data insert error = ' + error); + } + } + + async function dataNameUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "dayuan" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contact_update_test_1200: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "dayuan"); + await contactsQuery(map, "contact_update_test_1200", rawContactUri); + } catch (error) { + console.info('logMessage contact_update_test_1200: contact_data update error = ' + error); + } + } + + /** + * @tc.number contact_update_test_1300 + * @tc.name Update contact details (company, position) + * @tc.desc Function test + */ + it("contact_update_test_1300", 0, async function (done) { + console.info("------logMessage contact_update_test_1300 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_update_test_1300: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforedataCompanyInsert(DAHelper, rawContactId); + await dataCompanyUpdate(DAHelper, rawContactId); + await deleteRawContact("contact_update_test_1300"); + await deleteAll(contactDataUri, "contact_update_test_1300"); + done(); + } catch (error) { + console.info('logMessage contact_update_test_1300: raw_contact insert error = ' + error); + done(); + } + }); + + async function beforedataCompanyInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "organization", + "detail_info": "TT", + "position": "Testers", + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contact_update_test_1300: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_update_test_1300: contact_data insert error = ' + error); + } + } + + async function dataCompanyUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "OOOO", "position": "developer" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contact_update_test_1300: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("company", "OOOO"); + map.set("position", "developer"); + await contactsQuery(map, "contact_update_test_1300", rawContactUri); + } catch (error) { + console.info('logMessage contact_update_test_1300: contact_data update error = ' + error); + } + } + + /** + * @tc.number contact_update_test_1400 + * @tc.name Update contact details (mobile phone number) + * @tc.desc Function test + */ + it("contact_update_test_1400", 0, async function (done) { + console.info("------logMessage contact_update_test_1400 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_update_test_1400: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataPhoneInsert(DAHelper, rawContactId); + await dataPhoneUpdate(DAHelper, rawContactId); + await deleteRawContact("contact_update_test_1400"); + await deleteAll(contactDataUri, "contact_update_test_1400"); + done(); + } catch (error) { + console.info('logMessage contact_update_test_1400: raw_contact insert error = ' + error); + done(); + } + }); + + async function beforeDataPhoneInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": "phone", "detail_info": "123456" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contact_update_test_1400: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_update_test_1400: contact_data insert error = ' + error); + } + } + + async function dataPhoneUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "99663355" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contact_update_test_1400: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "99663355"); + await contactsQuery(map, "contact_update_test_1400", contactDataUri); + } catch (error) { + console.info('logMessage contact_update_test_1400: contact_data update error = ' + error); + } + } + + /** + * @tc.number contact_update_test_1500 + * @tc.name Update contact details (nickname) + * @tc.desc Function test + */ + it("contact_update_test_1500", 0, async function (done) { + console.info("------logMessage contact_update_test_1500 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_update_test_1500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforedataNickNameInsert(DAHelper, rawContactId); + await dataNickNameUpdate(DAHelper, rawContactId); + await deleteRawContact("contact_update_test_1500"); + await deleteAll(contactDataUri, "contact_update_test_1500"); + done(); + } catch (error) { + console.info('logMessage contact_update_test_1500: raw_contact insert error = ' + error); + done(); + } + }); + + async function beforedataNickNameInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "nickname", + "detail_info": "xiaoyuan" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contact_update_test_1500: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_update_test_1500: contact_data insert error = ' + error); + } + } + + async function dataNickNameUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "fengyuan" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contact_update_test_1500: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "fengyuan"); + await contactsQuery(map, "contact_update_test_1500", contactDataUri); + } catch (error) { + console.info('logMessage contact_update_test_1500: contact_data update error = ' + error); + } + } + + /** + * @tc.number contact_update_test_1600 + * @tc.name Update contact details (email) + * @tc.desc Function test + */ + it("contact_update_test_1600", 0, async function (done) { + console.info("------logMessage contact_update_test_1600 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_update_test_1600: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataEmailInsert(DAHelper, rawContactId); + await dataEmailUpdate(DAHelper, rawContactId); + await deleteRawContact("contact_update_test_1600"); + await deleteAll(contactDataUri, "contact_update_test_1600"); + done(); + } catch (error) { + console.info("logMessage contact_update_test_1600: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataEmailInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "email", + "detail_info": "166@163.com" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contact_update_test_1600: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_update_test_1600: contact_data insert error = ' + error); + } + } + + async function dataEmailUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "199@163.com" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition) + sleep(1000); + console.info('logMessage contact_update_test_1600: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "199@163.com"); + await contactsQuery(map, "contact_update_test_1600", contactDataUri); + } catch (error) { + console.info('logMessage contact_update_test_1600: update error = ' + error); + } + } + + /** + * @tc.number contact_update_test_1700 + * @tc.name Update Contact Details (Residential) + * @tc.desc Function test + */ + it("contact_update_test_1700", 0, async function (done) { + console.info("------logMessage contact_update_test_1700 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_update_test_1700: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataPostalInsert(DAHelper, rawContactId); + await dataPostalUpdate(); + await deleteRawContact("contact_update_test_1700"); + await deleteAll(contactDataUri, "contact_update_test_1700"); + done(); + } catch (error) { + console.info("logMessage contact_update_test_1700: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataPostalInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "postal_address", + "detail_info": "NanJing" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contact_update_test_1700: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_update_test_1700: contact_data insert error = " + error); + } + } + + async function dataPostalUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "BeiJing" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contact_update_test_1700: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "BeiJing"); + await contactsQuery(map, "contact_update_test_1700", contactDataUri); + } catch (error) { + console.info('logMessage contact_update_test_1700: update error = ' + error); + } + } + + /** + * @tc.number contact_update_test_1800 + * @tc.name Update contact details (remarks) + * @tc.desc Function test + */ + it("contact_update_test_1800", 0, async function (done) { + console.info("------logMessage contact_update_test_1800 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_update_test_1800: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforedataNoteInsert(DAHelper, rawContactId); + await dataNoteUpdate(DAHelper, rawContactId); + await deleteRawContact("contact_update_test_1800"); + await deleteAll(contactDataUri, "contact_update_test_1800"); + done(); + } catch (error) { + console.info("logMessage contact_update_test_1800: raw_contact insert error = " + error); + done(); + } + }); + + async function beforedataNoteInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": "note", "detail_info": "Gangster" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contact_update_test_1800: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_update_test_1800: contact_data insert error = ' + error); + } + } + + async function dataNoteUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "God" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contact_update_test_1800: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "God"); + await contactsQuery(map, "contact_update_test_1800", contactDataUri); + } catch (error) { + console.info('logMessage contact_update_test_1800: update error = ' + error); + } + } + + /** + * @tc.number contact_update_test_1900 + * @tc.name Update Contact Details (AIM) + * @tc.desc Function test + */ + it("contact_update_test_1900", 0, async function (done) { + console.info("------logMessage contact_update_test_1900 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues) + console.info("logMessage contact_update_test_1900: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataAimInsert(DAHelper, rawContactId); + await dataAimUpdate(DAHelper, rawContactId); + await deleteRawContact("contact_update_test_1900"); + await deleteAll(contactDataUri, "contact_update_test_1900"); + done(); + } catch (error) { + console.info("logMessage contact_update_test_1900: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataAimInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": "im", "detail_info": "aaaaa" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contact_update_test_1900: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_update_test_1900: contact_data insert error = " + error); + } + } + + async function dataAimUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "bbbbb" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contact_update_test_1900: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "bbbbb"); + await contactsQuery(map, "contact_update_test_1900", contactDataUri); + } catch (error) { + console.info('logMessage contact_update_test_1900: update error = ' + error); + } + } + + /** + * @tc.number contact_update_test_2000 + * @tc.name Update Contact Details (Birthday) + * @tc.desc Function test + */ + it("contact_update_test_2000", 0, async function (done) { + console.info("------logMessage contact_update_test_2000 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_update_test_2000: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataEventInsert(DAHelper, rawContactId); + await dataEventUpdate(DAHelper, rawContactId); + await deleteRawContact("contact_update_test_2000"); + await deleteAll(contactDataUri, "contact_update_test_2000"); + done(); + } catch (error) { + console.info("logMessage contact_update_test_2000: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataEventInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "contact_event", + "detail_info": "19960229" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues1); + sleep(1000); + console.info('logMessage contact_update_test_2000: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_update_test_2000: contact_data insert error = ' + error); + } + } + + async function dataEventUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "19971021" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contact_update_test_2000: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "19971021"); + await contactsQuery(map, "contact_update_test_2000", contactDataUri); + } catch (error) { + console.info('logMessage contact_update_test_2000: update error = ' + error); + } + } + + /** + * @tc.number contact_update_test_2100 + * @tc.name Update contact details (website) + * @tc.desc Function test + */ + it("contact_update_test_2100", 0, async function (done) { + console.info("------logMessage contact_update_test_2100 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_update_test_2100: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataWebsiteInsert(DAHelper, rawContactId); + await dataWebsiteUpdate(DAHelper, rawContactId); + await deleteRawContact("contact_update_test_2100"); + await deleteAll(contactDataUri, "contact_update_test_2100"); + done(); + } catch (error) { + console.info("logMessage contact_update_test_2100: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataWebsiteInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "website", + "detail_info": "www.com" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues1); + sleep(1000); + console.info('logMessage contact_update_test_2100: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_update_test_2100: contact_data insert error = ' + error); + } + } + + async function dataWebsiteUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "www.123.com" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contact_update_test_2100: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "www.123.com"); + await contactsQuery(map, "contact_update_test_2100", contactDataUri); + } catch (error) { + console.info('logMessage contact_update_test_2100: update error = ' + error); + } + } + + /** + * @tc.number contact_update_test_2200 + * @tc.name Update contact details (assistant) + * @tc.desc Function test + */ + it("contact_update_test_2200", 0, async function (done) { + console.info("------logMessage contact_update_test_2200 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_update_test_2200: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataRelationInsert(DAHelper, rawContactId); + await dataRelationUpdate(DAHelper, rawContactId); + await deleteRawContact("contact_update_test_2200"); + await deleteAll(contactDataUri, "contact_update_test_2200"); + done(); + } catch (error) { + console.info("logMessage contact_update_test_2200: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataRelationInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "relation", + "detail_info": "Secretary" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + console.info('logMessage contact_update_test_2200: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_update_test_2200: contact_data insert error = ' + error); + } + } + + async function dataRelationUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "spouse" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contact_update_test_2200: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "spouse"); + await contactsQuery(map, "contact_update_test_2200", contactDataUri); + } catch (error) { + console.info('logMessage contact_update_test_2200: update error = ' + error); + } + } + + /** + * @tc.number contact_update_test_2300 + * @tc.name Update contact detail data table (group) + * @tc.desc Function test + */ + it("contact_update_test_2300", 0, async function (done) { + console.info("------logMessage contact_update_test_2300 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_update_test_2300: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataGroupInsert(DAHelper, rawContactId); + await dataGroupUpdate(DAHelper, rawContactId); + await deleteRawContact("contact_update_test_2300"); + await deleteAll(contactDataUri, "contact_update_test_2300"); + done(); + } catch (error) { + console.info("logMessage contact_update_test_2300: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataGroupInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "group_membership", + "detail_info": "2" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contact_update_test_2300: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_update_test_2300: contact_data insert error = ' + error); + } + } + + async function dataGroupUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "7" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contact_update_test_2300: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "3"); + await contactsQuery(map, "contact_update_test_2300", contactDataUri); + } catch (error) { + console.info('logMessage contact_update_test_2300: update error = ' + error); + } + } + + /** + * @tc.number contact_update_test_2400 + * @tc.name Update contact detail data table (phone ringtone) + * @tc.desc Function test + */ + it("contact_update_test_2400", 0, async function (done) { + console.info("------logMessage contact_update_test_2400 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoyuan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + sleep(1000); + console.info("logMessage contact_update_test_2400: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await beforeDataMiscInsert(DAHelper, rawContactId); + await dataMiscUpdate(DAHelper, rawContactId); + await deleteRawContact("contact_update_test_2400"); + await deleteAll(contactDataUri, "contact_update_test_2400"); + done(); + } catch (error) { + console.info("logMessage contact_update_test_2400: raw_contact insert error = " + error); + done(); + } + }); + + async function beforeDataMiscInsert(DAHelper, rawContactId) { + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "contact_misc", + "detail_info": "1234" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues1); + sleep(1000); + console.info('logMessage contact_update_test_2400: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_update_test_2400: contact_data insert error = ' + error); + } + } + + async function dataMiscUpdate(DAHelper, rawContactId) { + var updateValues = { + "detail_info": "999" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition); + sleep(1000); + console.info('logMessage contact_update_test_2400: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "999"); + await contactsQuery(map, "contact_update_test_2300", contactDataUri); + } catch (error) { + console.info('logMessage contact_update_test_2400: update error = ' + error); + } + } + + /** + * @tc.number contact_favorite_test_2500 + * @tc.name Favorite contacts + * @tc.desc Function test + */ + it("contact_favorite_test_2500", 0, async function (done) { + console.info("-------logMessage contact_favorite_test_2500 is starting!------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaocai", "company": "TT", "position": "Testers" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues) + console.info('logMessage contact_favorite_test_2500: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await updateFavorite(DAHelper, rawContactId); + await deleteRawContact("contact_favorite_test_2500"); + done(); + } catch (error) { + console.info('logMessage contact_favorite_test_2500: raw_contact insert error = ' + error); + done(); + } + }); + + async function updateFavorite(DAHelper, rawContactId) { + var updateValues = { + "favorite": 1 + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(rawContactUri, updateValues, condition); + sleep(1000); + console.info("logMessage contact_favorite_test_2500: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "xiaocai"); + map.set("company", "TT"); + map.set("position", "Testers"); + map.set("favorite", "1"); + await contactsQuery(map, "contact_favorite_test_2500", rawContactUri); + } catch (error) { + console.info('logMessage contact_favorite_test_2500: update error = ' + error); + } + } + + /** + * @tc.number contact_unfavorite_test_2600 + * @tc.name Unfavorite contacts + * @tc.desc Function test + */ + it("contact_unfavorite_test_2600", 0, async function (done) { + console.info("-------logMessage contact_unfavorite_test_2600 is starting!------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var rawContactValues = { + "display_name": "xiaohong", "company": "TT", "position": "Testers", "favorite": 1 + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info('logMessage contact_unfavorite_test_2600: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await updateUnFavorite(DAHelper, rawContactId); + await deleteRawContact("contact_unfavorite_test_2600"); + done(); + } catch (error) { + console.info('logMessage contact_unfavorite_test_2600: raw_contact insert error = ' + error); + done(); + } + }); + + async function updateUnFavorite(DAHelper, rawContactId) { + var updateValues = { + "favorite": 0 + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var updateCode = await DAHelper.update(rawContactUri, updateValues, condition); + sleep(1000); + console.info("logMessage contact_unfavorite_test_2600: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "xiaohong"); + map.set("company", "TT"); + map.set("position", "Testers"); + map.set("favorite", "0"); + await contactsQuery(map, "contact_favorite_test_2500", rawContactUri); + } catch (error) { + console.info("logMessage contact_unfavorite_test_2600: update error = " + error); + } + } + + /** + * @tc.number contact_insert_test_2700 + * @tc.name Insert contact black list + * @tc.desc Function test + */ + it("contact_insert_test_2700", 0, async function (done) { + console.info("-------logMessage contact_insert_test_2700 is starting!------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var blocklistId = await DAHelper.insert(contactBlocklistUri, common.getProfileBlockList()); + sleep(1000); + console.info('logMessage contact_insert_test_2700: blocklistId = ' + blocklistId); + expect(blocklistId > 0).assertTrue(); + var map = common.getProfileBlockListMap(); + map.set("id", blocklistId.toString()); + await contactsQuery(map, "contact_insert_test_2700", contactBlocklistUri); + await deleteAll(contactBlocklistUri, "contact_insert_test_2700"); + done(); + } catch (error) { + console.info('logMessage contact_insert_test_2700: blocklist insert error = ' + error); + done(); + } + }); + + /** + * @tc.number contact_delete_test_2800 + * @tc.name Delete contact black list + * @tc.desc Function test + */ + it("contact_delete_test_2800", 0, async function (done) { + console.info("-------logMessage contact_delete_test_2800 is starting!------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var blocklistId = await DAHelper.insert(contactBlocklistUri, common.getProfileBlockList()); + sleep(1000); + console.info('logMessage contact_delete_test_2800: blocklistId = ' + blocklistId); + expect(blocklistId > 0).assertTrue(); + await blocklistDelete(); + done(); + } catch (error) { + console.info('logMessage contact_delete_test_2800: blocklist insert error = ' + error); + done(); + } + + async function blocklistDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", blocklistId.toString()); + try { + var deleteCode = await DAHelper.delete(contactBlocklistUri, condition); + sleep(1000); + console.info("logMessage contact_delete_test_2800: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + var map = new Map(); + map.set("id", blocklistId.toString()); + await queryIdForDelete(map, "contact_delete_test_2800", contactBlocklistUri); + } catch (error) { + console.info('logMessage contact_delete_test_2800: delete error = ' + error); + done(); + } + } + }); + + /** + * @tc.number contact_insert_test_2900 + * @tc.name Insert contact group + * @tc.desc Function test + */ + it("contact_insert_test_2900", 0, async function (done) { + console.info("-------logMessage contact_insert_test_2900 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var groupValues = { + "group_name": "TestersThird" + }; + try { + var groupId = await DAHelper.insert(groupUri, groupValues); + sleep(1000); + console.info("logMessage contact_insert_test_2900: groupId =" + groupId); + expect(groupId > 0).assertTrue(); + await groupRawContactInsert(DAHelper); + await deleteRawContact("contact_insert_test_2900"); + await deleteAll(groupUri, "contact_insert_test_2900"); + await deleteAll(contactDataUri, "contact_insert_test_2900"); + done(); + } catch (error) { + console.info("logMessage contact_insert_test_2900: group insert error =" + error); + done(); + } + }); + + async function groupRawContactInsert(DAHelper) { + var rawContactValues = { + "display_name": "liyu" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contact_insert_test_2900: rawContactId =" + rawContactId); + expect(rawContactId > 0).assertTrue(); + await groupDataInsert(DAHelper, rawContactId); + } catch (error) { + console.info("logMessage contact_insert_test_2900: raw_contact insert error =" + error); + } + } + + async function groupDataInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "group_membership", + "detail_info": groupId.toString() + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues) + sleep(1000); + console.info("logMessage contact_insert_test_2900: contactDataId =" + contactDataId); + expect(contactDataId > 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId); + map.set("raw_contact_id", rawContactId.toString()); + map.set("detail_info", groupId.toString()); + await contactsQuery(map, "contact_insert_test_2900", contactDataUri); + } catch (error) { + console.info("logMessage contact_insert_test_2900: contact_data insert error =" + error); + } + } + + /** + * @tc.number contact_delete_test_3000 + * @tc.name Delete contact group + * @tc.desc Function test + */ + it("contact_delete_test_3000", 0, async function (done) { + console.info("-------logMessage contact_delete_test_3000 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var groupValues = { + "group_name": "TestersFourth" + }; + try { + var groupId = await DAHelper.insert(groupUri, groupValues); + sleep(1000); + console.info("logMessage contact_delete_test_3000: groupId =" + groupId); + expect(groupId > 0).assertTrue(); + await groupAfterRawContactInsert(DAHelper); + await deleteRawContact("contact_delete_test_3000"); + await deleteAll(groupUri, "contact_delete_test_3000"); + await deleteAll(contactDataUri, "contact_delete_test_3000"); + done(); + } catch (error) { + console.info("logMessage contact_delete_test_3000: group insert error =" + error); + done(); + } + }); + + async function groupAfterRawContactInsert(DAHelper) { + var rawContactValues = { + "display_name": "liyuchen" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contact_delete_test_3000: rawContactId =" + rawContactId); + expect(rawContactId > 0).assertTrue(); + await deleteGroupContactDataInsert(DAHelper, rawContactId); + } catch (error) { + console.info("logMessage contact_delete_test_3000: raw_contact insert error =" + error); + } + } + + async function deleteGroupContactDataInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "group_membership", + "detail_info": groupId.toString() + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + console.info("logMessage contact_delete_test_3000: contactDataId =" + contactDataId); + expect(contactDataId > 0).assertTrue(); + await deleteGroup(DAHelper, contactDataId); + } catch (error) { + console.info("logMessage contact_delete_test_3000: contact_data insert error =" + error); + } + } + + async function deleteGroup(DAHelper, contactDataId) { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", contactDataId.toString()); + try { + var deleteCode = await DAHelper.delete(contactDataUri, condition); + sleep(1000); + console.info("logMessage contact_delete_test_3000: deleteCode =" + deleteCode); + expect(deleteCode == 0).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + await queryIdForDelete(map, "contact_delete_test_3000", contactDataUri); + } catch (error) { + console.info("logMessage contact_delete_test_3000: delete error =" + error); + } + } + + /** + * @tc.number contact_query_test_3100 + * @tc.name Query basic information of a single contact + * @tc.desc Function test + */ + it("contact_query_test_3100", 0, async function (done) { + console.info("-----------logMessage contact_query_test_3100 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoyu" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contact_query_test_3100: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await rawContactQuery(DAHelper, rawContactId); + await deleteRawContact("contact_query_test_3100"); + done(); + } catch (error) { + console.info("logMessage contact_query_test_3100: raw_contact insert error = " + error); + done(); + } + }); + + async function rawContactQuery(DAHelper, rawContactId) { + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + sleep(2000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_query_test_3100: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId).assertEqual(true); + console.info('logMessage contact_query_test_3100: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "xiaoyu").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contact_query_test_3100: query error = " + error); + } + } + + /** + * @tc.number contact_query_test_3200 + * @tc.name Query basic information of multiple contacts + * @tc.desc Function test + */ + it("contact_query_test_3200", 0, async function (done) { + console.info("-----------logMessage contact_query_test_3200 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues1 = { + "display_name": "xiaoyu" + }; + try { + var rawContactIdOne = await DAHelper.insert(rawContactUri, rawContactValues1); + sleep(1000); + console.info("logMessage contact_query_test_3200: rawContactId = " + rawContactIdOne); + expect(rawContactIdOne > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_query_test_3200: raw_contact_1 insert error = " + error); + done(); + } + + var rawContactValues2 = { + "display_name": "xiaohong" + }; + try { + var rawContactIdTwo = await DAHelper.insert(rawContactUri, rawContactValues2); + sleep(1000); + console.info("logMessage contact_query_test_3200: rawContactId = " + rawContactIdTwo); + expect(rawContactIdTwo > 0).assertTrue(); + await queryTwoRaw(DAHelper, rawContactIdOne, rawContactIdTwo); + await deleteRawContact("contact_query_test_3200"); + done(); + } catch (error) { + console.info("logMessage contact_query_test_3200: raw_contact_2 insert error = " + error); + done(); + } + }); + + async function queryTwoRaw(DAHelper, rawContactIdOne, rawContactIdTwo) { + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("id", rawContactIdTwo.toString()); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + sleep(1000); + console.info('logMessage contact_query_test_3200: goToFirstRow' + resultSet.goToFirstRow()); + expect(resultSet.goToFirstRow()).assertEqual(true); + if (resultSet.goToFirstRow()) { + do { + console.info("logMessage contact_query_test_3200: columnNames :" + resultSet.columnNames); + console.info("logMessage contact_query_test_3200: columnCount:" + resultSet.columnCount); + console.info('logMessage contact_query_test_3200: id = ' + resultSet.getString(0)); + console.info('logMessage contact_query_test_3200: displayName = ' + resultSet.getString(1)); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_query_test_3200: query error' + error); + } + } + + /** + * @tc.number contact_query_test_3300 + * @tc.name Query basic information of all contacts + * @tc.desc Function test + */ + it("contact_query_test_3300", 0, async function (done) { + console.info("-----------logMessage contact_query_test_3300 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues1 = { + "display_name": "xiaoyu" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues1); + sleep(1000); + console.info("logMessage contact_query_test_3300: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_query_test_3300: raw_contact_1 insert error = " + error); + done(); + } + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + var resultSet = await DAHelper.query(profileRawContactUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_query_test_3300: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertEqual(true); + console.info('logMessage contact_query_test_3300: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "xiaoyu").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + await deleteRawContact("contact_query_test_3300"); + done(); + } catch (error) { + console.info("logMessage contact_query_test_3300: query error = " + error); + done(); + } + }); + + /** + * @tc.number contact_query_test_3400 + * @tc.name Query all information of a single contact + * @tc.desc Function test + */ + it("contact_query_test_3400", 0, async function (done) { + console.info("-----------logMessage contact_query_test_3400 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoyuzhou", + "company": "TT", + "position": "Testers", + "favorite": 1, + "phonetic_name": "xiaoyu||xy" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contact_query_test_3400: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await queryAllInformation(DAHelper, rawContactId); + await deleteRawContact("contact_query_test_3400"); + done(); + } catch (error) { + console.info("logMessage contact_query_test_3400: raw_contact insert error = " + error); + done(); + } + }); + + async function queryAllInformation(DAHelper, rawContactId) { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + var id = resultSet.getString(resultSet.getColumnIndex("id")); + console.info('logMessage contact_query_test_3400: id = ' + id); + expect(id == rawContactId).assertEqual(true); + var favorite = resultSet.getString(resultSet.getColumnIndex("favorite")); + console.info('logMessage contact_query_test_3400: favorite = ' + favorite); + expect(favorite == "1").assertEqual(true); + var phoneticName = resultSet.getString(resultSet.getColumnIndex("phonetic_name")); + console.info('logMessage contact_query_test_3400: phoneticName = ' + phonetic_name); + expect(phoneticName == "xiaoyu||xy").assertEqual(true); + var company = resultSet.getString(resultSet.getColumnIndex("company")); + console.info('logMessage contact_query_test_3400: company = ' + company); + expect(company == "TT").assertEqual(true); + var displayName = resultSet.getString(resultSet.getColumnIndex("display_name")); + console.info('logMessage contact_query_test_3400: displayName = ' + displayName); + expect(displayName == "xiaoyuzhou").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_query_test_3400: query error = ' + error); + } + } + + /** + * @tc.number contact_query_test_3500 + * @tc.name Query group member ability + * @tc.desc Function test + */ + it("contact_query_test_3500", 0, async function (done) { + console.info("-----------logMessage contact_query_test_3500 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var rawContactValues = { + "display_name": "xiaoyuzhou" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contact_query_test_3500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_query_test_3500: raw_contact insert error = " + error); + done(); + } + var groupValues = { + "group_name": "BossBoard3500" + }; + try { + var groupId = await DAHelper.insert(groupUri, groupValues); + sleep(1000); + console.info("logMessage contact_query_test_3500: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_query_test_3500: group insert error = " + error); + done(); + } + await groupBossBoardInsert(DAHelper, rawContactId, groupId); + await deleteRawContact("contact_query_test_3500"); + await deleteAll(groupUri, "contact_query_test_3500"); + await deleteAll(contactDataUri, "contact_query_test_3500"); + done(); + }); + + async function groupBossBoardInsert(DAHelper, rawContactId, groupId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "group_membership", + "detail_info": groupId.toString() + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info("logMessage contact_query_test_3500: contactDataId = " + contactDataId); + expect(contactDataId > 0).assertTrue(); + await groupBossBoardQuery(DAHelper, rawContactId, groupId); + } catch (error) { + console.info("logMessage contact_query_test_3500: query error = " + error); + } + } + + async function groupBossBoardQuery(DAHelper, rawContactId, groupId) { + var resultColumns = ["raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 9 data is group + condition.equalTo("type_id", "9"); + condition.and(); + condition.equalTo("detail_info", groupId.toString()); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_query_test_3500: raw_contact_id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId).assertEqual(true); + console.info('logMessage contact_query_test_3500: detail_info = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == groupId.toString()).assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contact_query_test_3500: query error :" + error); + } + } + + /** + * @tc.number contact_query_test_3600 + * @tc.name Query favorite contacts + * @tc.desc Function test + */ + it("contact_query_test_3600", 0, async function (done) { + console.info("-----------logMessage contact_query_test_3600 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var rawContactValues = { + "display_name": "xiaoyuzhou", "favorite": 1 + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contact_query_test_3600: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await queryFavorite(); + await deleteRawContact("contact_query_test_3600"); + done(); + } catch (error) { + console.info("logMessage contact_query_test_3600: raw_contact insert error = " + error); + done(); + } + + async function queryFavorite() { + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("favorite", "1"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_query_test_3600: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertTrue(); + console.info('logMessage contact_query_test_3600: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "xiaoyuzhou").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contact_query_test_3600: query error :" + error); + done(); + } + } + }); + + /** + * @tc.number contact_query_test_3700 + * @tc.name Query recent contact ability + * @tc.desc Function test + */ + it("contact_query_test_3700", 0, async function (done) { + console.info("-----------logMessage contact_query_test_3700 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var rawContactValues = { + "display_name": "xiaoyuzhou", "lastest_contacted_time": 60 + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contact_query_test_3700: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await queryContacted(); + await deleteRawContact("contact_query_test_3700"); + done(); + } catch (error) { + console.info("logMessage contact_query_test_3700: raw_contact insert error = " + error); + done(); + } + + async function queryContacted() { + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.lessThan("lastest_contacted_time", "100"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_query_test_3700: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertTrue(); + console.info('logMessage contact_query_test_3700: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "xiaoyuzhou").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_query_test_3700: query error' + error); + done(); + } + } + }); + + /** + * @tc.number contact_query_test_3800 + * @tc.name Query recently deleted contacts + * @tc.desc Function test + */ + it("contact_query_test_3800", 0, async function (done) { + console.info("-----------logMessage contact_query_test_3800 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var rawContactValues = { + "display_name": "xiaocai" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contact_query_test_3800: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await rawContactDelete(DAHelper, rawContactId); + await deletedRawContactQuery(DAHelper, rawContactId); + await deleteAll(deletedUri, "contact_query_test_3800") + done(); + } catch (error) { + console.info("logMessage contact_query_test_3800: raw_contact insert error = " + error); + done(); + } + }); + + async function rawContactDelete(DAHelper, rawContactId) { + var condition1 = new ohosDataAbility.DataAbilityPredicates(); + condition1.equalTo("id", rawContactId.toString()); + try { + var deleteCode = await DAHelper.delete(rawContactUri, condition1); + sleep(1000); + console.info('logMessage contact_query_test_3800: deleteCode = ' + deleteCode); + expect(deleteCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_query_test_3800: raw_contact delete error = " + error); + done(); + } + } + + async function deletedRawContactQuery(DAHelper, rawContactId) { + var resultColumns = ["id", "raw_contact_id", "display_name", "is_deleted"]; + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + condition2.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(deletedRawContactUri, resultColumns, condition2); + sleep(1000); + if (resultSet.goToFirstRow()) { + console.info('logMessage contact_query_test_3800: id = ' + resultSet.getString(0)); + console.info('logMessage contact_query_test_3800: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertTrue(); + console.info('logMessage contact_query_test_3800: displayName = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "xiaocai").assertTrue(); + console.info('logMessage contact_query_test_3800: is_deleted = ' + resultSet.getString(3)); + expect(resultSet.getString(3) == "1").assertTrue(); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contact_query_test_3800: query error :" + error); + done(); + } + } + + /** + * @tc.number contact_query_test_3900 + * @tc.name Query all mobile phone numbers + * @tc.desc Function test + */ + it("contact_query_test_3900", 0, async function (done) { + console.info("-----------logMessage contact_query_test_3900 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var rawContactValues = { + "display_name": "xiaocai" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contact_query_test_3900: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await queryPhoneInsert(); + await phoneQuery(rawContactId); + await deleteRawContact("contact_query_test_3900"); + await deleteAll(contactDataUri, "contact_query_test_3900"); + done(); + } catch (error) { + console.info("logMessage contact_query_test_3900: raw_contact insert error = " + error); + done(); + } + }); + + async function queryPhoneInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "phone", + "detail_info": "1853696321" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info("logMessage contact_query_test_3900: contactDataId = " + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_query_test_3900: contact_data insert error = " + error); + } + } + + async function phoneQuery(DAHelper, rawContactId) { + var resultColumns = ["raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 5 data is phone + condition.equalTo("content_type", "phone"); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_query_test_3900: raw_contact_id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertTrue(); + console.info('logMessage contact_query_test_3900: detail_info = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "1853696321").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_query_test_3900: query error' + error); + } + } + + /** + * @tc.number contact_query_test_4000 + * @tc.name Query all mailbox capabilities + * @tc.desc Function test + */ + it("contact_query_test_4000", 0, async function (done) { + console.info("-----------logMessage contact_query_test_4000 is starting!------------"); + + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoyu" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contact_query_test_4000: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await queryEmailInsert(DAHelper, rawContactId); + await emailQuery(DAHelper, contactDataId, rawContactId); + await deleteRawContact("contact_query_test_4000"); + await deleteAll(contactDataUri, "contact_query_test_4000"); + done(); + } catch (error) { + console.info("logMessage contact_query_test_4000: raw_contact insert error = " + error); + done(); + } + }); + + async function queryEmailInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "email", + "detail_info": "16658@163.com" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info("logMessage contact_query_test_4000: contactDataId = " + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_query_test_4000: contact_data insert error = " + error); + } + } + + async function emailQuery(DAHelper, contactDataId, rawContactId) { + var resultColumns = ["id", "raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 1 data content_type is email + condition.equalTo("type_id", "1").limitAs(3).orderByDesc("id"); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_query_test_4000: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == contactDataId.toString()).assertTrue(); + console.info('logMessage contact_query_test_4000: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertTrue(); + console.info('logMessage contact_query_test_4000: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "16658@163.com").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contact_query_test_4000: query error :" + error); + } + } + + /** + * @tc.number contact_query_test_4100 + * @tc.name Query data information of a single contact + * @tc.desc Function test + */ + it("contact_query_test_4100", 0, async function (done) { + console.info("-----------logMessage contact_query_test_4100 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoyu" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contact_query_test_4100: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await queryTwoDataInsert(DAHelper, rawContactId); + await queryTwoDataInsertCompany(DAHelper, rawContactId); + await queryTwo(DAHelper, rawContactId); + await deleteRawContact("contact_query_test_4100"); + await deleteAll(contactDataUri, "contact_query_test_4100"); + del + done(); + } catch (error) { + console.info("logMessage contact_query_test_4100: raw_contact insert error = " + error); + done(); + } + }); + + async function queryTwoDataInsert(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": "name", "detail_info": "xiaoyu" + }; + try { + var contactDataId1 = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info("logMessage contact_query_test_4100: contactDataId = " + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_query_test_4100: contact_data name insert error = " + error); + } + } + + async function queryTwoDataInsertCompany(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "organization", + "detail_info": "OOOO", + "position": "Testers" + }; + try { + var contactDataId2 = await DAHelper.insert(contactDataUri, contactDataValues); + console.info("logMessage contact_query_test_4100: contactDataId = " + contactDataId2); + expect(contactDataId2 > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_query_test_4100: contact_data company insert error = " + error); + } + } + + async function queryTwo(DAHelper, rawContactId) { + var resultColumns = ["id", "raw_contact_id", "detail_info", "position"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + sleep(1000); + var array = [{ + detail_info: "xiaoyu", position: "" + }, { + detail_info: "OOOO", position: "Testers" + }]; + var i = 0; + if (resultSet.goToFirstRow()) { + do { + console.info("logMessage contact_query_test_4100: columnNames :" + resultSet.columnNames); + console.info("logMessage contact_query_test_4100: columnCount:" + resultSet.columnCount); + console.info('logMessage contact_query_test_4100: id = ' + resultSet.getString(0)); + console.info('logMessage contact_query_test_4100: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertEqual(true); + console.info('logMessage contact_query_test_4100: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == array[i].detail_info).assertEqual(true); + console.info('logMessage contact_query_test_4100: position = ' + resultSet.getString(3)); + expect(resultSet.getString(3) == array[i].position).assertEqual(true); + i++; + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contact_query_test_4100: query error :" + error); + } + } + + /** + * @tc.number contact_delete_test_4400 + * @tc.name Delete the basic raw data of the contact and record the deleted basic raw data + * @tc.desc Function test + */ + it("contact_delete_test_4400", 0, async function (done) { + console.info("-------logMessage contact_delete_test_4400 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaoming" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + sleep(1000); + console.info("logMessage contact_delete_test_4400: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await deleteRaw(DAHelper, rawContactId); + await queryDelete(DAHelper, rawContactId); + done(); + } catch (error) { + console.info("logMessage contact_delete_test_4400: raw_contact insert error :" + error); + done(); + } + }); + + async function deleteRaw(DAHelper, rawContactId) { + var condition1 = new ohosDataAbility.DataAbilityPredicates(); + condition1.equalTo("id", rawContactId.toString()); + try { + var deleteCode = await DAHelper.delete(rawContactUri, condition1); + sleep(1000); + console.info("logMessage contact_delete_test_4400: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_delete_test_4400: delete error = " + error); + } + } + + async function queryDelete(DAHelper, rawContactId) { + var resultColumns = ["id", "delete_time", "display_name"]; + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + condition2.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(deletedRawContactUri, resultColumns, condition2); + sleep(1000); + if (resultSet.goToFirstRow()) { + console.info("logMessage contact_delete_test_4400: columnNames:" + resultSet.columnNames); + console.info("logMessage contact_delete_test_4400: columnCount:" + resultSet.columnCount); + console.info('logMessage contact_delete_test_4400: id = ' + resultSet.getString(0)); + console.info('logMessage contact_delete_test_4400: delete_time = ' + resultSet.getString(1)); + console.info('logMessage contact_delete_test_4400: displayName = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "xiaoming").assertTrue(); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contact_delete_test_4400: query error:" + error); + } + } + + /** + * @tc.number contact_delete_test_4700 + * @tc.name Delete detailed contact data and record detailed data + * @tc.desc Function test + */ + it("contact_delete_test_4700", 0, async function (done) { + console.info("-------logMessage contact_delete_test_4700 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaozhang", "company": "OOOO", "position": "TestManager" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + sleep(1000); + console.info("logMessage contact_delete_test_4700: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await queryDeleteCompanyData(DAHelper, rawContactId); + await rawContactDelete(DAHelper, rawContactId); + await companyRawContactDeleteQuery(DAHelper, rawContactId); + await deleteAll(contactDataUri, "contact_delete_test_4700"); + done(); + } catch (error) { + console.info("logMessage contact_delete_test_4700: raw_contact insert error:" + error); + done(); + } + }); + + async function queryDeleteCompanyData(DAHelper, rawContactId) { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "organization", + "detail_info": "OOOO", + "position": "TestManager" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info("logMessage contact_delete_test_4700: contactDataId = " + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_delete_test_4700: contact_data insert error:" + error); + } + } + + async function rawContactDelete(DAHelper, rawContactId) { + var condition1 = new ohosDataAbility.DataAbilityPredicates(); + condition1.equalTo("id", rawContactId.toString()); + try { + var deleteCode = await DAHelper.delete(rawContactUri, condition1); + sleep(1000); + console.info("logMessage contact_delete_test_4700: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_delete_test_4700: delete error = " + error); + done(); + } + } + + async function companyRawContactDeleteQuery(DAHelper, rawContactId) { + var resultColumns = ["id", "display_name", "backup_data"]; + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + condition2.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(deletedRawContactUri, resultColumns, condition2); + sleep(1000); + if (resultSet.goToFirstRow()) { + console.info("logMessage contact_delete_test_4700: columnNames:" + resultSet.columnNames); + console.info("logMessage contact_delete_test_4700: columnCount:" + resultSet.columnCount); + console.info('logMessage contact_delete_test_4700: id = ' + resultSet.getString(0)); + console.info('logMessage contact_delete_test_4700: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "xiaozhang").assertEqual(true); + console.info('logMessage contact_delete_test_4700: backup_data = ' + resultSet.getString(2)); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contact_delete_test_4700: query error:" + error); + } + } + + /** + * @tc.number contact_delete_test_4800 + * @tc.name Delete and record basic data of a single contact + * @tc.desc Function test + */ + it("contact_delete_test_4800", 0, async function (done) { + console.info("-------logMessage contact_delete_test_4800 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaopeng" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + sleep(1000); + console.info("logMessage contact_delete_test_4800: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDelete(DAHelper, rawContactId); + await deletedRawContactQuery(DAHelper, rawContactId) + await deleteAll(contactDataUri, "contact_delete_test_4800"); + done(); + } catch (error) { + console.info("logMessage contact_delete_test_4800: raw_contact insert error:" + error); + done(); + } + }); + + async function contactDelete(DAHelper, rawContactId) { + var condition1 = new ohosDataAbility.DataAbilityPredicates(); + condition1.equalTo("name_raw_contact_id", rawContactId.toString()); + try { + var deleteCode = await DAHelper.delete(contactUri, condition1); + sleep(1000); + console.info("logMessage contact_delete_test_4800: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_delete_test_4800: delete error = " + error); + } + } + + async function deletedRawContactQuery(DAHelper, rawContactId) { + var resultColumns = ["id", "delete_time", "display_name"]; + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + condition2.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(deletedRawContactUri, resultColumns, condition2); + sleep(1000) + if (resultSet.goToFirstRow()) { + console.info("logMessage contact_delete_test_4800: columnNames:" + resultSet.columnNames); + console.info("logMessage contact_delete_test_4800: columnCount:" + resultSet.columnCount); + console.info('logMessage contact_delete_test_4800: id = ' + resultSet.getString(0)); + console.info('logMessage contact_delete_test_4800: delete_time = ' + resultSet.getString(1)); + console.info('logMessage contact_delete_test_4800: displayName = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "xiaopeng").assertTrue(); + } + resultSet.close(); + } catch (error) { + console.info("logMessage contact_delete_test_4800: query error:" + error); + } + } + + /** + * @tc.number contact_batchinsert_test_4900 + * @tc.name Insert contacts in batches(raw_contact) + * @tc.desc Function test + */ + it("contact_batchinsert_test_4900", 0, async function (done) { + console.info("--------logMessage contact_batchinsert_test_4900 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, common.getContactBatchCompany()); + sleep(1000); + console.info("logMessage contact_batchinsert_test_4900: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("company", "TT4900"); + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + console.info( + 'contact_batchinsert_test_4900 : queryBatch start ! resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == 5).assertEqual(true); + resultSet.close(); + await deleteRawContact("contact_batchinsert_test_4900"); + done(); + } catch (error) { + console.info("logMessage contact_batchinsert_test_4900: batchInsert error = " + error); + done(); + } + }); + + /** + * @tc.number contact_batchinsert_test_5000 + * @tc.name Insert contact_data in batches of address book + * @tc.desc Function test + */ + it("contact_batchinsert_test_5000", 0, async function (done) { + console.info("--------logMessage contact_batchinsert_test_5000 start!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var rawContactValues = { + "display_name": "xiaozhi" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contact_batchinsert_test_5000: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataBatchInsert(rawContactId); + done(); + } catch (error) { + console.info("logMessage contact_batchinsert_test_5000: raw_contact insert error = " + error); + done(); + } + async function contactDataBatchInsert(rawContactId) { + try { + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, common.getContactBatchCompanyTwo()); + sleep(1000); + console.info("logMessage contact_batchinsert_test_5000: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + var map = new Map(); + map.set("raw_contact_id", rawContactId.toString()); + await queryBatch(map, "contact_batchinsert_test_5000", 5); + await deleteRawContact("contact_batchinsert_test_5000"); + done(); + } catch (error) { + console.info("logMessage contact_batchinsert_test_5000: batchInsert error = " + error); + done(); + } + } + }); + + /** + * @tc.number contact_batchinsert_test_5400 + * @tc.name Batch operation of contact black list + * @tc.desc Function test + */ + it("contact_batchinsert_test_5400", 0, async function (done) { + console.info("--------logMessage contact_batchinsert_test_5400 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var batchInsertCode = await DAHelper.batchInsert(contactBlocklistUri, common.getPhoneNumberBatch()); + sleep(1000); + console.info("logMessage contact_batchinsert_test_5400: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + await query(5); + await blocklistDelete(); + done(); + } catch (error) { + console.info("logMessage contact_batchinsert_test_5400: batchInsert error = " + error); + done(); + } + + async function blocklistDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("phone_number", "85525040585400"); + try { + var deleteCode = await DAHelper.delete(contactBlocklistUri, condition); + console.info("logMessage contact_batchinsert_test_5400: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + await query(0); + done(); + } catch (error) { + console.info("logMessage contact_batchinsert_test_5400: delete error = " + error); + done(); + } + } + + async function query(size) { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("phone_number", "85525040585400"); + try { + var resultSet = await DAHelper.query(contactBlocklistUri, resultColumns, condition); + sleep(1000); + console.info( + 'contact_batchinsert_test_5400 : queryBatch start ! resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == size).assertEqual(true); + resultSet.close(); + } catch (error) { + console.info(" contact_batchinsert_test_5400 logMessage resultSet.rowCount: error = " + error); + } + } + }); + + /** + * @tc.number contact_update_test_5300 + * @tc.name Bulk favorites and unfavorites of contacts + * @tc.desc Function test + */ + it("contact_update_test_5300", 0, async function (done) { + console.info("--------logMessage contact_update_test_5300 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValuesOne = { + "display_name": "fengyuan", "favorite": 1 + }; + var rawContactValuesTwo = { + "display_name": "xiaoli", "favorite": 1 + }; + var rawContactValuesThree = { + "display_name": "xiaoma", "favorite": 1 + }; + var listAddBluk = [] + listAddBluk[0] = rawContactValuesOne; + listAddBluk[1] = rawContactValuesTwo; + listAddBluk[2] = rawContactValuesThree; + try { + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + sleep(1000); + console.info("logMessage contact_update_test_5300: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + await rawContactUpdateUnFavorites(DAHelper); + await queryUnFavorites(DAHelper); + await deleteRawContact("contact_update_test_5300"); + done(); + } catch (error) { + console.info("logMessage contact_update_test_5300: batchInsert error = " + error); + done(); + } + }); + + async function rawContactUpdateUnFavorites(DAHelper) { + var updateValues = { + "favorite": 0 + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("display_name", "fengyuan"); + condition.or(); + condition.equalTo("display_name", "xiaoma"); + try { + var updateCode = await DAHelper.update(rawContactUri, updateValues, condition); + sleep(1000); + console.info("logMessage contact_update_test_5300: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_update_test_5300: update error = " + error); + } + } + + async function queryUnFavorites(DAHelper) { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("display_name", "fengyuan"); + condition.or(); + condition.equalTo("display_name", "xiaoma"); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + sleep(1000); + console.info('contact_update_test_5300 : queryBatch start ! resultSet.rowCount = ' + + resultSet.rowCount); + expect(resultSet.rowCount == 2).assertEqual(true); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var dbresult = resultSet.getString(resultSet.getColumnIndex("favorite")); + console.info(' contact_update_test_5300 :logMessage contactsQuery dbresult :' + dbresult + + ' value : ' + value); + expect(dbresult == "0").assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info(" contact_batchinsert_test_5400 logMessage resultSet.rowCount: error = " + error); + } + } + + /** + * @tc.number contact_batchinsert_test_5500 + * @tc.name Contacts are added to and removed from groups in batches + * @tc.desc Function test + */ + it("contact_batchinsert_test_5500", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var groupValues = { + "group_name": "ManagerGroup" + }; + try { + var groupId = await DAHelper.insert(groupUri, groupValues); + console.info("logMessage contact_batchinsert_test_5500: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_batchinsert_test_5500: group insert error = " + error); + done(); + } + try { + var rawContactValues1 = { + "display_name": "xiaohuang" + }; + var rawContactIdOne = await DAHelper.insert(rawContactUri, rawContactValues1); + console.info("logMessage contact_batchinsert_test_5500: rawContactIdOne = " + rawContactIdOne); + expect(rawContactIdOne > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_batchinsert_test_5500: raw_contact_1 insert error = " + error); + done(); + } + try { + var rawContactValues2 = { + "display_name": "xiaolv" + }; + var rawContactIdTwo = await DAHelper.insert(rawContactUri, rawContactValues2); + console.info("logMessage contact_batchinsert_test_5500: rawContactIdTwo = " + rawContactIdTwo); + expect(rawContactIdTwo > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_batchinsert_test_5500: raw_contact_2 insert error = " + error); + done(); + } + try { + var rawContactValues3 = { + "display_name": "xiaobai" + }; + var rawContactIdThird = await DAHelper.insert(rawContactUri, rawContactValues3); + console.info("logMessage contact_batchinsert_test_5500: rawContactIdThird = " + rawContactIdThird); + expect(rawContactIdThird > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_batchinsert_test_5500: raw_contact_3 insert error = " + error); + done(); + } + await threeDataInsert(DAHelper, rawContactIdOne, rawContactIdTwo, rawContactIdThird, groupId); + await deleteRawContact("contact_batchinsert_test_5500"); + await deleteAll(groupUri, "contact_batchinsert_test_5500"); + await deleteAll(contactDataUri, "contact_batchinsert_test_5500"); + done(); + }); + + async function threeDataInsert(DAHelper, rawContactIdOne, rawContactIdTwo, rawContactIdThird, groupId) { + var contactDataValues1 = { + "raw_contact_id": rawContactIdOne, + "content_type": "group_membership", + "detail_info": groupId.toString() + }; + var contactDataValues2 = { + "raw_contact_id": rawContactIdTwo, + "content_type": "group_membership", + "detail_info": groupId.toString() + }; + var contactDataValues3 = { + "raw_contact_id": rawContactIdThird, + "content_type": "group_membership", + "detail_info": groupId.toString() + }; + var listAddBluk = []; + listAddBluk[0] = contactDataValues1; + listAddBluk[1] = contactDataValues2; + listAddBluk[2] = contactDataValues3; + try { + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + sleep(1000); + console.info("logMessage contact_batchinsert_test_5500: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + await contactDataDelete(DAHelper, rawContactIdOne, rawContactIdThird); + } catch (error) { + console.info("logMessage contact_batchinsert_test_5500: batchInsert error = " + error); + } + } + + async function contactDataDelete(DAHelper, rawContactIdOne, rawContactIdThird) { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("raw_contact_id", rawContactIdThird.toString()); + try { + var deleteCode = await DAHelper.delete(contactDataUri, condition); + sleep(1000); + console.info("logMessage contact_batchinsert_test_5500: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + await queryTwoData(DAHelper, rawContactIdOne, rawContactIdThird); + } catch (error) { + console.info("logMessage contact_batchinsert_test_5500: delete error = " + error); + } + } + + async function queryTwoData(DAHelper, rawContactIdOne, rawContactIdThird) { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("raw_contact_id", rawContactIdThird.toString()); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + sleep(1000); + console.info( + 'contact_batchinsert_test_5500 : queryBatch start ! resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == 0).assertEqual(true); + resultSet.close(); + } catch (error) { + console.info(" contact_batchinsert_test_5400 logMessage resultSet.rowCount: error = " + error); + } + } + + /** + * @tc.number contact_pinyin_query_test_200 + * @tc.name Contact name to pinyin (Chinese Simplified) + * @tc.desc Function test + */ + it("contact_pinyin_query_test_200", 0, async function (done) { + console.info("--------logMessage contact_pinyin_query_test_200 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "小黄" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info('logMessage contact_pinyin_query_test_200 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataInsert(); + await deleteRawContact("contact_pinyin_query_test_100"); + await deleteAll(contactDataUri, "contact_pinyin_query_test_100"); + done(); + } catch (error) { + console.info("logMessage contact_pinyin_query_test_200: raw_contact insert error = " + error); + done(); + } + + async function contactDataInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "name", + "detail_info": "xiaohuang" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + console.info('logMessage contact_pinyin_query_test_200 contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await searchQuery(DAHelper, rawContactId); + } catch (error) { + console.info('logMessage contact_pinyin_query_test_200 contact_data insert error = ' + error); + done(); + } + } + }); + + async function searchQuery(DAHelper, rawContactId) { + var resultColumns = ["id", "search_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(searchContactUri, resultColumns, condition); + var map = common.getSearchMap(); + map.set("raw_contact_id", rawContactId.toString()); + if (resultSet.goToFirstRow()) { + do { + for (var [key, value] of map) { + var dbresult = resultSet.getString(resultSet.getColumnIndex(key)); + console.info(tag + ':contact_pinyin_query_test_200 key = ' + key + ' dbresult :' + dbresult + + ' value : ' + value); + expect(value == dbresult).assertEqual(true); + } + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_pinyin_query_test_200 query error = ' + error); + } + } + + /** + * @tc.number contact_pinyin_query_test_100 + * @tc.name Contact name to pinyin (Chinese Traditional) + * @tc.desc Function test + */ + it("contact_pinyin_query_test_100", 0, async function (done) { + console.info("--------logMessage contact_pinyin_query_test_100 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "鍵盤" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contact_pinyin_query_test_100 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataInsert(); + await deleteRawContact("contact_pinyin_query_test_100"); + await deleteAll(contactDataUri, "contact_pinyin_query_test_100"); + done(); + } catch (error) { + console.info('logMessage contact_pinyin_query_test_100 raw_contact insert error = ' + error); + done(); + } + + async function contactDataInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": "name", "detail_info": "鍵盤" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contact_pinyin_query_test_100 contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await searchContactQueryChinese(DAHelper, rawContactId); + } catch (error) { + console.info('logMessage contact_pinyin_query_test_100 contact_data insert error = ' + error); + done(); + } + } + }); + + async function searchContactQueryChinese(DAHelper, rawContactId) { + var resultColumns = ["raw_contact_id", "search_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(searchContactUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_pinyin_query_test_100: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertEqual(true); + console.info('logMessage contact_pinyin_query_test_100: search_name = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "鍵盤||jianpan||jp").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_pinyin_query_test_100 query error = ' + error); + } + } + + /** + * @tc.number contact_pinyin_query_test_300 + * @tc.name Contact name to pinyin (English) + * @tc.desc Function test + */ + it("contact_pinyin_query_test_300", 0, async function (done) { + console.info("--------logMessage contact_pinyin_query_test_300 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "Tom" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contact_pinyin_query_test_300 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataInsert(); + await deleteRawContact("contact_pinyin_query_test_300"); + done(); + } catch (error) { + console.info('logMessage contact_pinyin_query_test_300 raw_contact insert error = ' + error); + done(); + } + + async function contactDataInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": "name", "detail_info": "Tom" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + console.info('logMessage contact_pinyin_query_test_300 contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await searchContactQuery(DAHelper, rawContactId); + } catch (error) { + console.info('logMessage contact_pinyin_query_test_300 contact_data insert error = ' + error); + done(); + } + } + }); + + async function searchContactQuery(DAHelper, rawContactId) { + var resultColumns = ["raw_contact_id", "search_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(searchContactUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_pinyin_query_test_300: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertTrue(); + console.info('logMessage contact_pinyin_query_test_300: search_name = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "Tom||Tom||Tom").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_pinyin_query_test_300 query error = ' + error); + } + } + + /** + * @tc.number contact_fuzzyquery_test_400 + * @tc.name Contact fuzzy search query interface (name) + * @tc.desc Function test + */ + it("contact_fuzzyquery_test_400", 0, async function (done) { + console.info("--------logMessage contact_fuzzyquery_test_400 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "400xiaoming400" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contact_fuzzyquery_test_400 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await rawContactNameQuery(); + await deleteRawContact("contact_fuzzyquery_test_400"); + done(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_400 raw_contact insert error = ' + error); + done(); + } + + async function rawContactNameQuery() { + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.like("display_name", "%xiaoming40%"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_fuzzyquery_test_400: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertEqual(true); + console.info( + 'logMessage contact_fuzzyquery_test_400: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "400xiaoming400").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_400 query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number contact_fuzzyquery_test_500 + * @tc.name Contact fuzzy search query interface (name pinyin, pinyin name) + * @tc.desc Function test + */ + it("contact_fuzzyquery_test_500", 0, async function (done) { + console.info("--------logMessage contact_fuzzyquery_test_500 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var rawContactValues = { + "display_name": "500xiaoming500", "phonetic_name": "500xiaoming500||xm" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contact_fuzzyquery_test_500 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await rawContactPhoneticNameQuery(); + await deleteRawContact("contact_fuzzyquery_test_500"); + done(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_500 raw_contact insert error = ' + error); + done(); + } + + async function rawContactPhoneticNameQuery() { + var resultColumns = ["id", "display_name", "phonetic_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.like("phonetic_name", "%xiaoming%"); + condition.and(); + condition.equalTo("is_deleted", "0"); + condition.or(); + condition.like("phonetic_name", "%xm%"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_fuzzyquery_test_500: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertTrue(); + console.info( + 'logMessage contact_fuzzyquery_test_500: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "500xiaoming500").assertTrue(); + console.info( + 'logMessage contact_fuzzyquery_test_500: phoneticName = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "500xiaoming500||xm").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_500 query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number contact_fuzzyquery_test_600 + * @tc.name Contact fuzzy search query interface (company, position) + * @tc.desc Function test + */ + it("contact_fuzzyquery_test_600", 0, async function (done) { + console.info("--------logMessage contact_fuzzyquery_test_600 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoming", "company": "TT600", "position": "Testers600" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contact_fuzzyquery_test_600 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await rawContactCompanyQuery(DAHelper, rawContactId); + await deleteRawContact("contact_fuzzyquery_test_600"); + done(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_600 raw_contact insert error = ' + error); + done(); + } + }); + + async function rawContactCompanyQuery(DAHelper, rawContactId) { + var resultColumns = ["id", "display_name", "company", "position"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.like("company", "%TT6%"); + condition.and(); + condition.equalTo("is_deleted", "0"); + condition.or(); + condition.like("position", "%Testers6%"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_fuzzyquery_test_600: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == rawContactId.toString()).assertEqual(true); + console.info('logMessage contact_fuzzyquery_test_600: displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "xiaoming").assertEqual(true); + console.info('logMessage contact_fuzzyquery_test_600: company = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "TT600").assertEqual(true); + console.info('logMessage contact_fuzzyquery_test_600: position = ' + resultSet.getString(3)); + expect(resultSet.getString(3) == "Testers600").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_600 query error = ' + error); + } + } + + /** + * @tc.number contact_fuzzyquery_test_700 + * @tc.name Contact fuzzy search query interface (mobile phone number) + * @tc.desc Function test + */ + it("contact_fuzzyquery_test_700", 0, async function (done) { + console.info("--------logMessage contact_fuzzyquery_test_700 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoming" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contact_fuzzyquery_test_700 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataPhoneInsert(); + await deleteRawContact("contact_fuzzyquery_test_700"); + await deleteAll(contactDataUri, "contact_fuzzyquery_test_700"); + done(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_700 raw_contact insert error = ' + error); + done(); + } + + async function contactDataPhoneInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "phone", + "detail_info": "14528963" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contact_fuzzyquery_test_700 contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await fuzzyQueryPhone(DAHelper, rawContactId, contactDataId); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_700 contact_data insert error = ' + contactDataId); + done(); + } + } + }); + + async function fuzzyQueryPhone(DAHelper, rawContactId, contactDataId) { + var resultColumns = ["id", "raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 5 data is phone + condition.like("detail_info", "%52896%"); + condition.and(); + condition.equalTo("type_id", "5"); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_fuzzyquery_test_700: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == contactDataId.toString()).assertEqual(true); + console.info('logMessage contact_fuzzyquery_test_700: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertEqual(true); + console.info('logMessage contact_fuzzyquery_test_700: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "14528963").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_700 query error = ' + error); + } + } + + /** + * @tc.number contact_fuzzyquery_test_800 + * @tc.name Contact fuzzy search query interface (nickname) + * @tc.desc Function test + */ + it("contact_fuzzyquery_test_800", 0, async function (done) { + console.info("--------logMessage contact_fuzzyquery_test_800 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoming" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contact_fuzzyquery_test_800 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactNickNameInsert(); + await deleteRawContact("contact_fuzzyquery_test_800"); + await deleteAll(contactDataUri, "contact_fuzzyquery_test_800"); + done(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_800 raw_contact insert error = ' + error); + done(); + } + + async function contactNickNameInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "nickname", + "detail_info": "daming" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + console.info('logMessage contact_fuzzyquery_test_800 contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await fuzzyQueryPhoneNickName(DAHelper, rawContactId, contactDataId); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_800 contact_data insert error = ' + contactDataId); + done(); + } + } + }); + + async function fuzzyQueryPhoneNickName(DAHelper, rawContactId, contactDataId) { + var resultColumns = ["id", "raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 3 data is nickname + condition.like("detail_info", "%daming%"); + condition.and(); + condition.equalTo("type_id", "3"); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_fuzzyquery_test_800: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == contactDataId.toString()).assertTrue(); + console.info('logMessage contact_fuzzyquery_test_800: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertTrue(); + console.info('logMessage contact_fuzzyquery_test_800: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "daming").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_800 query error = ' + error); + } + } + + /** + * @tc.number contact_fuzzyquery_test_900 + * @tc.name Contact fuzzy search query interface (mailbox) + * @tc.desc Function test + */ + it("contact_fuzzyquery_test_900", 0, async function (done) { + console.info("--------logMessage contact_fuzzyquery_test_900 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoming" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contact_fuzzyquery_test_900 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataEmailInsert(); + await deleteRawContact("contact_fuzzyquery_test_900"); + await deleteAll(contactDataUri, "contact_fuzzyquery_test_900"); + done(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_900 raw_contact insert error = ' + error); + done(); + } + + async function contactDataEmailInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "email", + "detail_info": "1564@163.com" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + console.info('logMessage contact_fuzzyquery_test_900 ; = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await fuzzyQueryEmail(DAHelper, rawContactId, contactDataId); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_900 contact_data insert error = ' + error); + done(); + } + } + }); + + async function fuzzyQueryEmail(DAHelper, rawContactId, contactDataId) { + var resultColumns = ["id", "raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 1 data is email + condition.like("detail_info", "%1564%"); + condition.and(); + condition.equalTo("type_id", "1"); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_fuzzyquery_test_900: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == contactDataId.toString()).assertTrue(); + console.info('logMessage contact_fuzzyquery_test_900: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertTrue(); + console.info('logMessage contact_fuzzyquery_test_900: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "1564@163.com").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_900 query error = ' + error); + } + } + + /** + * @tc.number contact_fuzzyquery_test_1000 + * @tc.name Contact fuzzy search query interface (residential) + * @tc.desc Function test + */ + it("contact_fuzzyquery_test_1000", 0, async function (done) { + console.info("--------logMessage contact_fuzzyquery_test_1000 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoming" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contact_fuzzyquery_test_1000 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataPostalInsert(); + await deleteRawContact("contact_fuzzyquery_test_1000"); + await deleteAll(contactDataUri, "contact_fuzzyquery_test_1000"); + done(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_1000 raw_contact insert error = ' + error); + done(); + } + + async function contactDataPostalInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "postal_address", + "detail_info": "nanjing1000" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contact_fuzzyquery_test_1000 contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await fuzzyQueryAddress(DAHelper, rawContactId, contactDataId); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_1000 contact_data insert error = ' + error); + done(); + } + } + }); + + async function fuzzyQueryAddress(DAHelper, rawContactId, contactDataId) { + var resultColumns = ["id", "raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 1 data is postal_address + condition.like("detail_info", "%nanjing10%"); + condition.and(); + condition.equalTo("type_id", "7"); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + sleep(1000); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_fuzzyquery_test_1000: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == contactDataId.toString()).assertTrue(); + console.info('logMessage contact_fuzzyquery_test_1000: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertTrue(); + console.info('logMessage contact_fuzzyquery_test_1000: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "nanjing1000").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_1000: query error' + error); + } + } + + /** + * @tc.number contact_fuzzyquery_test_1100 + * @tc.name Contact fuzzy search query interface (remarks) + * @tc.desc Function test + */ + it("contact_fuzzyquery_test_1100", 0, async function (done) { + console.info("--------logMessage contact_fuzzyquery_test_1100 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoming" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage contact_fuzzyquery_test_1100 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataNoteInsert(); + await deleteRawContact("contact_fuzzyquery_test_1100"); + await deleteAll(contactDataUri, "contact_fuzzyquery_test_1100"); + done(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_1100 raw_contact insert error = ' + error); + done(); + } + + async function contactDataNoteInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "note", + "detail_info": "java1100" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info('logMessage contact_fuzzyquery_test_1100 contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await fuzzyQueryNote(DAHelper, rawContactId, contactDataId); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_1100 contact_data insert error = ' + error); + done(); + } + } + }); + + async function fuzzyQueryNote(DAHelper, rawContactId, contactDataId) { + var resultColumns = ["id", "raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 10 data is note + condition.like("detail_info", "%java11%"); + condition.and(); + condition.equalTo("type_id", "10"); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_fuzzyquery_test_1100: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == contactDataId.toString()).assertEqual(true); + console.info('logMessage contact_fuzzyquery_test_1100: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertEqual(true); + console.info('logMessage contact_fuzzyquery_test_1100: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "java1100").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_1100: query error' + error); + } + } + + /** + * @tc.number contact_fuzzyquery_test_1200 + * @tc.name Contact fuzzy search query interface (AIM) + * @tc.desc Function test + */ + it("contact_fuzzyquery_test_1200", 0, async function (done) { + console.info("--------logMessage contact_fuzzyquery_test_1200 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoming" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info('logMessage contact_fuzzyquery_test_1200 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataAimInsert(); + await deleteRawContact("contact_fuzzyquery_test_1200"); + await deleteAll(contactDataUri, "contact_fuzzyquery_test_1200"); + done(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_1200 raw_contact insert error = ' + error); + done(); + } + + async function contactDataAimInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, + "content_type": "im", + "detail_info": "aaaa1200" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + console.info('logMessage contact_fuzzyquery_test_1200 ; = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await fuzzyQueryIM(DAHelper, rawContactId, contactDataId); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_1200 contact_data insert error = ' + error); + done(); + } + } + }); + + async function fuzzyQueryIM(DAHelper, rawContactId, contactDataId) { + var resultColumns = ["id", "raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + // type_id = 10 data is im account number + condition.like("detail_info", "%aa12%"); + condition.and(); + condition.equalTo("type_id", "2"); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('logMessage contact_fuzzyquery_test_1200: id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == contactDataId.toString()).assertEqual(true); + console.info('logMessage contact_fuzzyquery_test_1200: raw_contact_id = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == rawContactId.toString()).assertEqual(true); + console.info('logMessage contact_fuzzyquery_test_1200: detail_info = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "aaaa1200").assertEqual(true); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info('logMessage contact_fuzzyquery_test_1200: query error' + error); + } + } + + /** + * @tc.number abnormal_contact_insert_test_200 + * @tc.name Abnormal use case, an incorrect field is passed in when inserting + * @tc.desc Function test + */ + it("abnormal_contact_insert_test_200", 0, async function (done) { + console.info("------------abnormal_contact_insert_test_200 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_names": "xiaoshan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_insert_test_200: rawContactId = " + rawContactId); + expect(rawContactId).assertEqual(-1); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_insert_test_200: raw_contact insert error' + error); + done(); + } + }); + + /** + * @tc.number abnormal_contact_insert_test_300 + * @tc.name Abnormal use case, an incorrect table name is passed in when inserting + * @tc.desc Function test + */ + it("abnormal_contact_insert_test_300", 0, async function (done) { + console.info("------------abnormal_contact_insert_test_300 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var errorUri = "dataability:///com.ohos.calllogability/contacts/raw_contacts"; + + var rawContactValues = { + "display_name": "xiaoshan" + }; + try { + var rawContactId = await DAHelper.insert(errorUri, rawContactValues); + console.info("logMessage abnormal_contact_insert_test_300: rawContactId = " + rawContactId); + expect(rawContactId == -1).assertTrue(); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_insert_test_300: raw_contact insert error' + error); + done(); + } + }); + + /** + * @tc.number abnormal_contact_update_test_1100 + * @tc.name Abnormal use case, an incorrect field is passed in when updating + * @tc.desc Function test + */ + it("abnormal_contact_update_test_1100", 0, async function (done) { + console.info("------------abnormal_contact_update_test_1100 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoshan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_update_test_1100: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await abnormalUpdate(); + await deleteRawContact("abnormal_contact_update_test_1100"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_update_test_1100: raw_contact insert error' + error); + done(); + } + + async function abnormalUpdate() { + var updateValues = { + "display_names": "xiaosan" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", rawContactId.toString()); + try { + var updataCode = await DAHelper.update(rawContactUri, updateValues, condition) + console.info("logMessage abnormal_contact_update_test_1100: updataCode = " + updataCode); + expect(updataCode == -1).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "xiaoshan"); + await contactsQuery(map, "abnormal_contact_update_test_1100", rawContactUri); + } catch (error) { + console.info('logMessage abnormal_contact_update_test_1100: update error' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_update_test_1000 + * @tc.name Abnormal use case, an incorrect table name is passed in when updating + * @tc.desc Function test + */ + it("abnormal_contact_update_test_1000", 0, async function (done) { + console.info("------------abnormal_contact_update_test_1000 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var errorUri = "dataability:///com.ohos.calllogability/contacts/raw_contacts"; + + var rawContactValues = { + "display_name": "xiaoshan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_update_test_1000: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await abnormalUpdate(); + await deleteRawContact("abnormal_contact_update_test_1000"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_update_test_1000: raw_contact insert error' + error); + done(); + } + + async function abnormalUpdate() { + var updateValues = { + "display_name": "xiaosan" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var updataCode = await DAHelper.update(errorUri, updateValues, condition); + console.info("logMessage abnormal_contact_update_test_1000: updataCode = " + updataCode); + expect(updataCode == -1).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "xiaoshan"); + await contactsQuery(map, "abnormal_contact_update_test_1000", rawContactUri); + } catch (error) { + console.info("logMessage abnormal_contact_update_test_1000: updata error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_delete_test_4500 + * @tc.name Abnormal use case, an incorrect field is passed in when deleting + * @tc.desc Function test + */ + it("abnormal_contact_delete_test_4500", 0, async function (done) { + console.info("------------abnormal_contact_delete_test_4500 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaozhi" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_delete_test_4500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await abnormalDelete(); + await deleteRawContact("abnormal_contact_delete_test_4500"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_delete_test_4500: raw_contact insert error' + error); + done(); + } + + async function abnormalDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", rawContactId.toString()); + try { + var deleteCode = await DAHelper.delete(rawContactUri, condition); + console.info("logMessage abnormal_contact_delete_test_4500: deleteCode = " + deleteCode); + expect(deleteCode == -1).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "xiaozhi"); + await contactsQuery(map, "abnormal_contact_delete_test_4500", rawContactUri); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_delete_test_4500: delete error' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_delete_test_4600 + * @tc.name Abnormal use case, an incorrect table name is passed in when deleting + * @tc.desc Function test + */ + it("abnormal_contact_delete_test_4600", 0, async function (done) { + console.info("------------abnormal_contact_delete_test_4600 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var errorUri = "dataability:///com.ohos.calllogability/contacts/raw_contacts"; + + var rawContactValues = { + "display_name": "xiaoshan" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_delete_test_4600: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await abnormalDelete(); + await deleteRawContact("abnormal_contact_delete_test_4600"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_delete_test_4600: raw_contact insert error' + error); + done(); + } + + async function abnormalDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var deleteCode = await DAHelper.delete(errorUri, condition); + console.info("logMessage abnormal_contact_delete_test_4600: deleteCode = " + deleteCode); + expect(deleteCode == -1).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "xiaoshan"); + await contactsQuery(map, "abnormal_contact_delete_test_4600", rawContactUri); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_delete_test_4600: delete error' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_query_test_4200 + * @tc.name Abnormal use case, an incorrect field is passed in when querying + * @tc.desc Function test + */ + it("abnormal_contact_query_test_4200", 0, async function (done) { + console.info("------------abnormal_contact_query_test_4200 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaozhicheng" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_query_test_4200: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await abnormalQuery(); + await deleteRawContact("abnormal_contact_query_test_4200"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_4200: raw_contact insert error' + error); + done(); + } + + async function abnormalQuery() { + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + expect(resultSet.goToFirstRow()).assertEqual(false); + console.info('logMessage abnormal_contact_query_test_4200: goToFirstRow' + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_4200: query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_batchinsert_test_5100 + * @tc.name Abnormal use cases, when adding data in batches, some of them failed, check the processing logic + * @tc.desc Function test + */ + it("abnormal_contact_batchinsert_test_5100", 0, async function (done) { + console.info("--------logMessage abnormal_contact_batchinsert_test_5100 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var addBulkValue1 = { + "display_name": "zhangsan" + }; + var addBulkValue2 = { + "display_names": "lisi" + }; + var addBulkValue3 = { + "display_name": "wangwu" + }; + var addBulkValue4 = { + "display_names": "laoliu" + }; + var addBulkValue5 = { + "display_name": "xiaozhang" + }; + var listAddBluk = []; + listAddBluk[0] = addBulkValue1; + listAddBluk[1] = addBulkValue2; + listAddBluk[2] = addBulkValue3; + listAddBluk[3] = addBulkValue4; + listAddBluk[4] = addBulkValue5; + try { + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + console.info("logMessage abnormal_contact_batchinsert_test_5100: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == -1).assertTrue(); + done(); + } catch (error) { + console.info("logMessage abnormal_contact_batchinsert_test_5100: batch insert error = " + error); + done(); + } + }); + + /** + * @tc.number abnormal_contact_insert_data_5300 + * @tc.name insert_data error no rawContactId + * @tc.desc Function test + */ + it("abnormal_contact_insert_data_5300", 0, async function (done) { + console.info("--------logMessage abnormal_contact_insert_data_5300 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaotian" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage abnormal_contact_insert_data_5300 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataAimInsert(); + await deleteRawContact("abnormal_contact_insert_data_5300"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_insert_data_5300 raw_contact insert error = ' + error); + done(); + } + + async function contactDataAimInsert() { + var contactDataValues = { + "content_type": "im", "detail_info": "aaaa" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + console.info('logMessage abnormal_contact_insert_data_5300 ; = ' + contactDataId); + expect(contactDataId == -1).assertTrue(); + } catch (error) { + console.info('logMessage abnormal_contact_insert_data_5300 contact_data insert error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_insert_data_5400 + * @tc.name insert_data error no content_type + * @tc.desc Function test + */ + it("abnormal_contact_insert_data_5400", 0, async function (done) { + console.info("--------logMessage abnormal_contact_insert_data_5400 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaotian" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info('logMessage abnormal_contact_insert_data_5400 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + await contactDataAimInsert(); + await deleteRawContact("abnormal_contact_insert_data_5400"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_insert_data_5400 raw_contact insert error = ' + error); + done(); + } + + async function contactDataAimInsert() { + var contactDataValues = { + "raw_contact_id": rawContactId, "detail_info": "aaaa" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + console.info('logMessage abnormal_contact_insert_data_5400 ; = ' + contactDataId); + expect(contactDataId == -1).assertTrue(); + } catch (error) { + console.info('logMessage abnormal_contact_insert_data_5400 contact_data insert error = ' + error); + done(); + } + } + }); + + /** + * @tc.number contact_delete_test_5500 + * @tc.name batchDelete + * @tc.desc Function test + */ + it("contact_delete_test_5500", 0, async function (done) { + console.info("--------logMessage contact_delete_test_5500 is starting!------------"); + if(utils.notCheck){ + expect(true).assertTrue(); + done(); + return; + } + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactId = await DAHelper.insert(rawContactUri, common.getProfileRawContact()); + console.info("logMessage contact_delete_test_5500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var map = common.getProfileRawContactMap(); + map.set("id", rawContactId.toString()); + await contactsQuery(map, "contact_delete_test_5500", rawContactUri); + await executeBatch(); + } catch (error) { + console.info("logMessage contact_delete_test_5500: insert error = " + error); + done(); + } + async function executeBatch() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + DAHelper.executeBatch(URI_CONTACTS, [{ + uri: rawContactUri, + type: featureAbility.DataAbilityOperationType.TYPE_DELETE, + predicates: condition, + expectedCount: 0, + PredicatesBackReferences: {}, + interrupted: true, + }], + (error, data) => { + console.info("logMessage contact_delete_test_5500: executeBatch data = " + JSON.stringify(data)); + console.info("logMessage contact_delete_test_5500: data_3 = " + data); + console.info("logMessage contact_delete_test_5500: data_1= " + data[0].count); + expect(data[0].count == 0).assertTrue(); + done(); + }); + } + }); + + /** + * @tc.number contact_update_test_5600 + * @tc.name batchUpdate + * @tc.desc Function test + */ + it("contact_update_test_5600", 0, async function (done) { + console.info("--------logMessage contact_update_test_5600 is starting!------------"); + if(utils.notCheck){ + expect(true).assertTrue(); + done(); + return; + } + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactId = await DAHelper.insert(rawContactUri, common.getProfileRawContact()); + console.info("logMessage contact_update_test_5600: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var map = common.getProfileRawContactMap(); + map.set("id", rawContactId.toString()); + await contactsQuery(map, "contact_update_test_5600", rawContactUri); + await executeBatch(); + } catch (error) { + console.info("logMessage contact_update_test_5600: insert error = " + error); + done(); + } + + async function executeBatch() { + var updateValues = { + "display_name": "xiaoxiaoxiao" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + DAHelper.executeBatch(URI_CONTACTS, [{ + uri: rawContactUri, + type: featureAbility.DataAbilityOperationType.TYPE_UPDATE, + valuesBucket: updateValues, + predicates: condition, + expectedCount: 0, + PredicatesBackReferences: {}, + interrupted: true, + }], + (error, data) => { + console.info("logMessage contact_update_test_5600: executeBatch data = " + JSON.stringify(data)); + console.info("logMessage contact_update_test_5600: data_3 = " + data); + console.info("logMessage contact_update_test_5600: data_1= " + data[0].count); + expect(data[0].count == 0).assertTrue(); + done(); + }); + } + }); + + /** + * @tc.number contact_insert_test_5700 + * @tc.name Insert Multiple raw_contact essential information + * @tc.desc Function test + */ + it("contact_insert_test_5700", 0, async function (done) { + console.info("------logMessage contact_insert_test_5700 is starting!-----"); + if(utils.notCheck){ + expect(true).assertTrue(); + done(); + return; + } + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactId = await DAHelper.insert(rawContactUri, common.getProfileRawContact()); + sleep(1000); + console.info('logMessage contact_insert_test_5700: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + var map = common.getProfileRawContactMap(); + map.set("id", rawContactId.toString()); + await contactsQuery(map, "contact_insert_test_5700", rawContactUri); + var rawContactIdOne = await DAHelper.insert(rawContactUri, common.getProfileRawContact()); + sleep(1000); + console.info('logMessage contact_insert_test_5700: rawContactIdOne = ' + rawContactIdOne); + expect(rawContactIdOne > 0).assertTrue(); + var map = common.getProfileRawContactMap(); + map.set("id", rawContactIdOne.toString()); + await contactsQuery(map, "contact_insert_test_5700", rawContactUri); + var rawContactIdTwo = await DAHelper.insert(rawContactUri, common.getProfileRawContact()); + sleep(1000); + console.info('logMessage contact_insert_test_5700: rawContactIdTwo = ' + rawContactIdTwo); + expect(rawContactIdTwo > 0).assertTrue(); + var map = common.getProfileRawContactMap(); + map.set("id", rawContactIdTwo.toString()); + await contactsQuery(map, "contact_insert_test_5700", rawContactUri); + await deleteRawContact("contact_insert_test_5700"); + done(); + } catch (error) { + console.info('logMessage contact_insert_test_5700: insert error = ' + error); + done(); + } + }); + + /** + * @tc.number contact_insert_test_5800 + * @tc.name Add 20000 bytes of basic contact information and verify whether the text insertion is successful + * @tc.desc Function test + */ + it("contact_insert_test_5800", 0, async function (done) { + console.info("------logMessage contact_insert_test_5800 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var name; + for (var i = 0; i < 20000; i++) { + name += "i"; + } + var contcatvalues = { + "display_name": name + } + try { + var rawContactId = await DAHelper.insert(rawContactUri, contcatvalues); + sleep(1000); + console.info('logMessage contact_insert_test_5800: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", name); + await contactsQuery(map, "contact_insert_test_5800", rawContactUri); + await deleteRawContact("contact_insert_test_5800"); + done(); + } catch (error) { + console.info('logMessage contact_insert_test_5800: insert error = ' + error); + done(); + } + }); + + /** + * @tc.number contact_insert_test_5900 + * @tc.name Add multiple contact details and verify that the insertion was successful + * @tc.desc Function test + */ + it("contact_insert_test_5900", 0, async function (done) { + console.info("------logMessage contact_insert_test_5900 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var contcatvalues = { + "display_name": "xiao5900" + } + try { + var rawContactId = await DAHelper.insert(rawContactUri, contcatvalues); + console.info('logMessage contact_insert_test_5900: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_type": "phone", + "detail_info": "19960229" + }; + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues1); + console.info('logMessage contact_insert_test_5900: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("detail_info", "19960229"); + await contactsQuery(map, "contact_insert_test_5900", contactDataUri); + + var rawContactIdOne = await DAHelper.insert(rawContactUri, contcatvalues); + console.info('logMessage contact_insert_test_5900: rawContactId = ' + rawContactIdOne); + expect(rawContactIdOne > 0).assertTrue(); + var contactDataValues2 = { + "raw_contact_id": rawContactIdOne, + "content_type": "phone", + "detail_info": "111111032" + }; + var contactDataId1 = await DAHelper.insert(contactDataUri, contactDataValues2); + console.info('logMessage contact_insert_test_5900: contactDataId = ' + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + + var map = new Map(); + map.set("id", contactDataId1.toString()); + map.set("detail_info", "111111032"); + await contactsQuery(map, "contact_insert_test_5900", contactDataUri); + + await deleteRawContact("contact_insert_test_5900"); + await deleteAll(contactDataUri, "contact_insert_test_5900"); + done(); + } catch (error) { + console.info('logMessage contact_insert_test_5900: insert error = ' + error); + done(); + } + }); + + /** + * @tc.number contact_insert_test_6000 + * @tc.name Add the basic information of a single contact and verify whether the insertion is successful (name, + * Pinyin, company, position, favorite) + * @tc.desc Function test + */ + it("contact_insert_test_6000", 0, async function (done) { + console.info("------logMessage contact_insert_test_6000 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "licheng", + "company": "TT", + "position": "developer", + "favorite": 1, + "phonetic_name": "licheng||lc" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_insert_test_6000: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "licheng"); + map.set("company", "TT"); + map.set("position", "developer"); + map.set("favorite", "1"); + map.set("phonetic_name", "licheng||lc"); + await contactsQuery(map, "contact_insert_test_6000", rawContactUri); + await deleteRawContact("contact_insert_test_6000"); + await deleteAll(contactDataUri, "contact_insert_test_6000"); + done(); + } catch (error) { + console.info("logMessage contact_insert_test_6000: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number contact_insertData_test_6100 + * @tc.name To contact_data Add a full field data to the data table and verify whether the insertion is + * successful + * @tc.desc Function test + */ + it("contact_insertData_test_6100", 0, async function (done) { + console.info("------logMessage contact_insertData_test_6100 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocai", + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_insertData_test_6100: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var contactDataValues = common.getProfileContactData(); + contactDataValues["raw_contact_id"] = rawContactId; + console.info('logMessage contact_insertData_test_6100: contactDataValues["raw_contact_id"] = ' + + contactDataValues.raw_contact_id); + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + console.info('logMessage contact_insertData_test_6100: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + var map = common.getProfileContactDataMap(); + map.set("id", contactDataId.toString()); + map.set("raw_contact_id", rawContactId.toString()); + await contactsQuery(map, "contact_insertData_test_6100", contactDataUri); + await deleteRawContact("contact_insertData_test_6100"); + await deleteAll(contactDataUri, "contact_insertData_test_6100"); + done(); + } catch (error) { + console.info("logMessage contact_insertData_test_6100: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number contact_update_test_6200 + * @tc.name Modify the basic information of multiple contacts and verify whether the modification is successful + * @tc.desc Function test + */ + it("contact_update_test_6200", 0, async function (done) { + console.info("--------logMessage contact_update_test_6200 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var insertRawContactValues = { + "display_name": "xiaocai", + }; + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + expect(rawContactId > 0).assertTrue(); + console.info("logMessage contact_update_test_6200: rawContactId = " + rawContactId); + var insertRawContactValuesOne = { + "display_name": "xiaocai1", + }; + var rawContactIdOne = await DAHelper.insert(rawContactUri, insertRawContactValuesOne); + expect(rawContactIdOne > 0).assertTrue(); + console.info("logMessage contact_update_test_6200: rawContactIdOne = " + rawContactIdOne); + var insertRawContactValuesTwo = { + "display_name": "xiaocai1", + }; + var rawContactIdTwo = await DAHelper.insert(rawContactUri, insertRawContactValuesTwo); + expect(rawContactIdTwo > 0).assertTrue(); + console.info("logMessage contact_update_test_6200: rawContactIdTwo = " + rawContactIdTwo); + + var updateValues = { + "display_name": "xiaosan" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + condition.or(); + condition.equalTo("id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("id", rawContactIdTwo.toString()); + var updataCode = await DAHelper.update(rawContactUri, updateValues, condition); + console.info("logMessage contact_update_test_6200: updataCode = " + updataCode); + expect(updataCode == 0).assertTrue(); + sleep(1000); + await queryUpdateThree( + "contact_update_test_6200", DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo); + await deleteRawContact("contact_update_test_6200"); + done(); + } catch (error) { + console.info("logMessage contact_update_test_6200: insert error = " + error); + done(); + } + }); + + async function queryUpdateThree(tag, DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo) { + + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': contactsQuery start ! DAHelper = ' + DAHelper); + var resultColumns = ["display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + condition.or(); + condition.equalTo("id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("id", rawContactIdTwo.toString()); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var name = resultSet.getString(resultSet.getColumnIndex("display_name")); + expect(name == "xiaosan").assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage contactsQuery: error = " + error); + } + } + + /** + * @tc.number contact_UpdateRawContcat_test_6300 + * @tc.name Update raw_contact The full field data of the contact table and verify whether the modification is + * successful + * @tc.desc Function test + */ + it("contact_UpdateRawContcat_test_6300", 0, async function (done) { + console.info("------logMessage contact_UpdateRawContcat_test_6300 is starting!-----"); + if(utils.notCheck){ + expect(true).assertTrue(); + done(); + return; + } + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactId = await DAHelper.insert(rawContactUri, common.getProfileRawContact()); + console.info("logMessage contact_UpdateRawContcat_test_6300: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + sleep(2000); + var updateValues = common.getProfileRawContactUpdate(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + var updataCode = await DAHelper.update(rawContactUri, updateValues, condition); + console.info('logMessage contact_UpdateRawContcat_test_6300: updataCode = ' + updataCode); + sleep(3000); + var map = common.getProfileRawContactUpdateMap(); + map.set("id", rawContactId.toString()); + await contactsQuery(map, "contact_UpdateRawContcat_test_6300", rawContactUri); + await deleteRawContact("contact_UpdateRawContcat_test_6300"); + await deleteAll(contactDataUri, "contact_UpdateRawContcat_test_6300"); + done(); + } catch (error) { + console.info("logMessage contact_UpdateRawContcat_test_6300: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number contact_insertDataUpdate_test_6400 + * @tc.name Update contact_data table, and verify whether the modification is successful + * @tc.desc Function test + */ + it("contact_insertDataUpdate_test_6400", 0, async function (done) { + console.info("------logMessage contact_insertDataUpdate_test_6400 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocai", + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_insertDataUpdate_test_6400: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + + var contactDataValues = common.getProfileContactData(); + contactDataValues["raw_contact_id"] = rawContactId; + console.info('logMessage contact_insertDataUpdate_test_6400: contactDataValues.raw_contact_id = ' + + contactDataValues.raw_contact_id); + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + console.info('logMessage contact_insertDataUpdate_test_6400: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + + var updateValues = common.getProfileContactDataUpdate(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", contactDataId.toString()); + var updataCode = await DAHelper.update(contactDataUri, updateValues, condition); + console.info('logMessage contact_insertDataUpdate_test_6400: updataCode = ' + updataCode); + sleep(1000); + var map = common.getProfileContactDataUpdateMap(); + map.set("id", contactDataId.toString()); + map.set("raw_contact_id", rawContactId.toString()); + await contactsQuery(map, "contact_insertDataUpdate_test_6400", contactDataUri); + await deleteRawContact("contact_insertDataUpdate_test_6400"); + await deleteAll(contactDataUri, "contact_insertDataUpdate_test_6400"); + done(); + } catch (error) { + console.info("logMessage contact_insertDataUpdate_test_6400: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number contact_insertDataUpdateAll_test_6500 + * @tc.name Update all contact details and verify that the modification was successful + * @tc.desc Function test + */ + it("contact_insertDataUpdateAll_test_6500", 0, async function (done) { + console.info("------logMessage contact_insertDataUpdateAll_test_6500 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocai", + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_insertDataUpdateAll_test_6500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await insertData(rawContactId, "name", "xiaocai", ""); + await insertData(rawContactId, "phone", "6500", ""); + await insertData(rawContactId, "organization", "TTTTT", "Deve"); + await insertData(rawContactId, "nickname", "xxxxcai", ""); + await insertData(rawContactId, "email", "111@fox.com", ""); + await insertData(rawContactId, "postal_address", "dddd", ""); + await insertData(rawContactId, "note", "caicai", ""); + await insertData(rawContactId, "im", "999999999", ""); + await insertData(rawContactId, "contact_event", "1125", ""); + await insertData(rawContactId, "website", "wwww.xxx.com", ""); + await insertData(rawContactId, "relation", "xiaobai", ""); + await insertData(rawContactId, "group_membership", 1, ""); + await insertData(rawContactId, "contact_misc", "5678", ""); + var updateValues = { + "detail_info": "xiaocai" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + var updataCode = await DAHelper.update(contactDataUri, updateValues, condition); + console.info('logMessage contact_insertDataUpdateAll_test_6500: updataCode = ' + updataCode); + sleep(1000); + await queryUpdateAllData("contact_insertDataUpdateAll_test_6500", DAHelper, rawContactId); + await deleteRawContact("contact_insertDataUpdateAll_test_6500"); + await deleteAll(contactDataUri, "contact_insertDataUpdateAll_test_6500"); + done(); + } catch (error) { + console.info("logMessage contact_insertDataUpdateAll_test_6500: raw_contact insert error = " + error); + done(); + } + }); + + async function queryUpdateAllData(tag, DAHelper, rawContactId) { + + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': contactsQuery start ! DAHelper = ' + DAHelper); + var resultColumns = ["detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("row_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var detail_info = resultSet.getString(resultSet.getColumnIndex("detail_info")); + expect(detail_info == "xiaocai").assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage contactsQuery: error = " + error); + } + } + + /** + * @tc.number contact_insertFavorite_test_6600 + * @tc.name Add multiple contacts to favorites and verify that the favorites field is changed + * @tc.desc Function test + */ + it("contact_insertFavorite_test_6600", 0, async function (done) { + console.info("------logMessage contact_insertFavorite_test_6600 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + try { + var insertRawContactValues = { + "display_name": "xiaocai", "favorite": 1 + }; + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_insertFavorite_test_6600: rawContactId = " + rawContactId); + + var insertRawContactValuesOne = { + "display_name": "xiaotian", "favorite": 1 + }; + var rawContactIdOne = await DAHelper.insert(rawContactUri, insertRawContactValuesOne); + console.info("logMessage contact_insertFavorite_test_6600: rawContactId = " + rawContactIdOne); + + var insertRawContactValuesTwo = { + "display_name": "xiaoli", "favorite": 1 + }; + var rawContactIdTwo = await DAHelper.insert(rawContactUri, insertRawContactValuesTwo); + console.info("logMessage contact_insertFavorite_test_6600: rawContactId = " + rawContactIdTwo); + + sleep(1000); + await queryThreeFavorite( + "contact_insertFavorite_test_6600", DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo, 1); + await deleteRawContact("contact_insertFavorite_test_6600"); + done(); + } catch (error) { + console.info("logMessage contact_insertFavorite_test_6600: raw_contact insert error = " + error); + done(); + } + }); + + async function queryThreeFavorite(tag, DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo, favoritevalue) { + + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': queryThreeFavorite start ! DAHelper = ' + DAHelper); + var resultColumns = ["favorite"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + condition.or(); + condition.equalTo("id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("id", rawContactIdTwo.toString()); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var favorite = resultSet.getInt(resultSet.getColumnIndex("favorite")); + expect(favorite == favoritevalue).assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage queryThreeFavorite: error = " + error); + } + } + + /** + * @tc.number contact_unFavorite_test_6700 + * @tc.name Remove favorites from multiple contacts and verify that the favorites field has changed + * @tc.desc Function test + */ + it("contact_unFavorite_test_6700", 0, async function (done) { + console.info("------logMessage contact_unFavorite_test_6700 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + try { + var insertRawContactValues = { + "display_name": "xiaocai", "favorite": 1 + }; + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_unFavorite_test_6700: rawContactId = " + rawContactId); + + var insertRawContactValuesOne = { + "display_name": "xiaotian", "favorite": 1 + }; + var rawContactIdOne = await DAHelper.insert(rawContactUri, insertRawContactValuesOne); + console.info("logMessage contact_unFavorite_test_6700: rawContactId = " + rawContactIdOne); + + var insertRawContactValuesTwo = { + "display_name": "xiaoli", "favorite": 1 + }; + var rawContactIdTwo = await DAHelper.insert(rawContactUri, insertRawContactValuesTwo); + console.info("logMessage contact_unFavorite_test_6700: rawContactId = " + rawContactIdTwo); + + var updateValues = { + "favorite": 0 + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + condition.or(); + condition.equalTo("id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("id", rawContactIdTwo.toString()); + var updataCode = await DAHelper.update(rawContactUri, updateValues, condition); + console.info("logMessage contact_unFavorite_test_6700: updataCode = " + updataCode); + sleep(1000); + await queryThreeFavorite( + "contact_unFavorite_test_6700", DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo, 0); + await deleteRawContact("contact_unFavorite_test_6700"); + done(); + } catch (error) { + console.info("logMessage contact_unFavorite_test_6700: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number contact_insertContactBlocklist_test_6800 + * @tc.name Add multiple records to the black list and verify whether the insertion is successful + * @tc.desc Function test + */ + it("contact_insertContactBlocklist_test_6800", 0, async function (done) { + console.info("--------logMessage contact_insertContactBlocklist_test_6800 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var batchInsertCode = await DAHelper.insert(contactBlocklistUri, common.getProfileBlockList()); + console.info("logMessage contact_insertContactBlocklist_test_6800: insert = " + batchInsertCode); + var batchInsertCodeOne = await DAHelper.insert(contactBlocklistUri, common.getProfileBlockList()); + console.info("logMessage contact_insertContactBlocklist_test_6800: insert = " + batchInsertCodeOne); + var batchInsertCodeTwo = await DAHelper.insert(contactBlocklistUri, common.getProfileBlockList()); + console.info("logMessage contact_insertContactBlocklist_test_6800: insert = " + batchInsertCodeTwo); + sleep(1000); + expect(batchInsertCode > 0).assertTrue(); + await query(3); + await deleteAll(contactBlocklistUri, "contact_insertContactBlocklist_test_6800"); + done(); + } catch (error) { + console.info("logMessage contact_insertContactBlocklist_test_6800: insert error = " + error); + done(); + } + + async function query(size) { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("phone_number", "123456789"); + try { + var resultSet = await DAHelper.query(contactBlocklistUri, resultColumns, condition); + sleep(1000); + console.info('contact_insertContactBlocklist_test_6800 :resultSet.goToFirstRow() = ' + + resultSet.goToFirstRow()); + console.info( + 'contact_insertContactBlocklist_test_6800 : query result is = ' + resultSet.rowCount == size); + expect(resultSet.rowCount == size).assertEqual(true); + resultSet.close(); + } catch (error) { + console.info(" contact_insertContactBlocklist_test_6800 error = " + error); + } + } + }); + + /** + * @tc.number contact_removeContactBlocklist_test_6900 + * @tc.name Delete multiple records from the black list and verify whether the deletion is successful + * @tc.desc Function test + */ + it("contact_removeContactBlocklist_test_6900", 0, async function (done) { + console.info("--------logMessage contact_removeContactBlocklist_test_6900 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var batchInsertCode = await DAHelper.insert(contactBlocklistUri, common.getProfileBlockList()); + console.info("logMessage contact_removeContactBlocklist_test_6900: batchInsertCode = " + batchInsertCode); + var batchInsertCodeOne = await DAHelper.insert(contactBlocklistUri, common.getProfileBlockList()); + console.info("logMessage contact_removeContactBlocklist_test_6900: insert = " + batchInsertCodeOne); + var batchInsertCodeTwo = await DAHelper.insert(contactBlocklistUri, common.getProfileBlockList()); + console.info("logMessage contact_removeContactBlocklist_test_6900: insert = " + batchInsertCodeTwo); + sleep(1000); + expect(batchInsertCode > 0).assertTrue(); + await deleteAll(contactBlocklistUri, "contact_removeContactBlocklist_test_6900"); + await query(0); + done(); + } catch (error) { + console.info("logMessage contact_removeContactBlocklist_test_6900: batchInsert error = " + error); + done(); + } + async function query(size) { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("phone_number", "123456789"); + try { + var resultSet = await DAHelper.query(contactBlocklistUri, resultColumns, condition); + console.info('contact_removeContactBlocklist_test_6900 : resultSet = ' + resultSet); + expect(resultSet.rowCount == size).assertEqual(true); + resultSet.close(); + } catch (error) { + console.info(" contact_removeContactBlocklist_test_6900 error = " + error); + } + } + }); + + /** + * @tc.number contact_insertGroup_test_7000 + * @tc.name Add multiple contacts to favorites and verify that the favorites field is changed + * @tc.desc Function test + */ + it("contact_insertGroup_test_7000", 0, async function (done) { + console.info("------logMessage contact_insertGroup_test_7000 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + try { + var insertRawContactValues = { + "display_name": "xiaocai", + }; + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_insertGroup_test_7000: rawContactId = " + rawContactId); + await insertData(rawContactId, "group_membership", 1, ""); + + var insertRawContactValuesOne = { + "display_name": "xiaotian", + }; + var rawContactIdOne = await DAHelper.insert(rawContactUri, insertRawContactValuesOne); + console.info("logMessage contact_insertGroup_test_7000: rawContactId = " + rawContactIdOne); + await insertData(rawContactIdOne, "group_membership", 1, ""); + var insertRawContactValuesTwo = { + "display_name": "xiaoli", + }; + var rawContactIdTwo = await DAHelper.insert(rawContactUri, insertRawContactValuesTwo); + console.info("logMessage contact_insertGroup_test_7000: rawContactId = " + rawContactIdTwo); + await insertData(rawContactIdTwo, "group_membership", 1, ""); + sleep(1000); + await queryThreeGroup( + "contact_insertGroup_test_7000", DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo, 1); + await deleteRawContact("contact_insertGroup_test_7000"); + done(); + } catch (error) { + console.info("logMessage contact_insertGroup_test_7000: raw_contact insert error = " + error); + done(); + } + }); + + async function queryThreeGroup(tag, DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo, groupId) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': queryThreeGroup start ! DAHelper = ' + DAHelper); + var resultColumns = ["detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + condition.or(); + condition.equalTo("id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("id", rawContactIdTwo.toString()); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var group = resultSet.getInt(resultSet.getColumnIndex("detail_info")); + expect(group == groupId).assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage queryThreeGroup: error = " + error); + } + } + + /** + * @tc.number contact_insert_test_7100 + * @tc.name Add a full field data to the groups table and verify whether the insertion is successful + * @tc.desc Function test + */ + it("contact_insert_test_7100", 0, async function (done) { + console.info("---------logMessage contact_insert_test_7100 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var groupId = await DAHelper.insert(groupUri, common.getProfileGroup()); + console.info("logMessage contact_insert_test_7100: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + var map = common.getProfileGroupMap(); + map.set("id", groupId.toString()); + await contactsQuery(map, "contact_insert_test_7100", groupUri); + await deleteAll(groupUri, "contact_insert_test_7100"); + done(); + } catch (error) { + console.info("logMessage contact_insert_test_7100: group insert error = " + error); + done(); + } + }); + + /** + * @tc.number contact_delete_test_7200 + * @tc.name Add a full field data to the groups table and verify whether the insertion is successful + * @tc.desc Function test + */ + it("contact_delete_test_7200", 0, async function (done) { + console.info("------logMessage contact_delete_test_7200 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + try { + var insertRawContactValues = { + "display_name": "xiaocai", + }; + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_delete_test_7200: rawContactId = " + rawContactId); + await insertData(rawContactId, "group_membership", 1, ""); + + var insertRawContactValuesOne = { + "display_name": "xiaotian", + }; + var rawContactIdOne = await DAHelper.insert(rawContactUri, insertRawContactValuesOne); + console.info("logMessage contact_delete_test_7200: rawContactId = " + rawContactIdOne); + await insertData(rawContactIdOne, "group_membership", 1, ""); + var insertRawContactValuesTwo = { + "display_name": "xiaoli", + }; + var rawContactIdTwo = await DAHelper.insert(rawContactUri, insertRawContactValuesTwo); + console.info("logMessage contact_delete_test_7200: rawContactId = " + rawContactIdTwo); + await insertData(rawContactIdTwo, "group_membership", 1, ""); + sleep(1000); + await deleteAll(contactDataUri, "contact_delete_test_7200"); + sleep(1000); + await queryZeroGroup("contact_delete_test_7200", DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo); + await deleteRawContact("contact_delete_test_7200"); + done(); + } catch (error) { + console.info("logMessage contact_delete_test_7200: raw_contact insert error = " + error); + done(); + } + }); + + async function queryZeroGroup(tag, DAHelper, rawContactId, rawContactIdOne, rawContactIdTwo) { + + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': queryZeroGroup start ! DAHelper = ' + DAHelper); + var resultColumns = ["detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + condition.or(); + condition.equalTo("raw_contact_id", rawContactIdOne.toString()); + condition.or(); + condition.equalTo("raw_contact_id", rawContactIdTwo.toString()); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + console.info(tag + ': queryZeroGroup! resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == 0).assertEqual(true); + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage queryZeroGroup: error = " + error); + } + } + + /** + * @tc.number contact_delete_test_7300 + * @tc.name Delete the full field data of a groups table and verify whether the deletion is successful + * @tc.desc Function test + */ + it("contact_delete_test_7300", 0, async function (done) { + console.info("---------logMessage contact_delete_test_7300 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var groupId = await DAHelper.insert(groupUri, common.getProfileGroup()); + console.info("logMessage contact_delete_test_7300: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + var map = common.getProfileGroupMap(); + map.set("id", groupId.toString()); + await contactsQuery(map, "contact_delete_test_7300", groupUri); + await deleteAll(groupUri, "contact_delete_test_7300"); + done(); + } catch (error) { + console.info("logMessage contact_delete_test_7300: group insert error = " + error); + done(); + } + }); + + /** + * @tc.number contact_delete_test_7400 + * @tc.name Add a raw_contact all fields, delete raw_contact + * @tc.desc Function test + */ + it("contact_delete_test_7400", 0, async function (done) { + console.info("------logMessage contact_Delete_test_7400 is starting!-----"); + if(utils.notCheck){ + expect(true).assertTrue(); + done(); + return; + } + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactId = await DAHelper.insert(rawContactUri, common.getProfileRawContact()); + sleep(1000); + console.info('logMessage contact_Delete_test_7400: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + var map = common.getProfileRawContactMap(); + map.set("id", rawContactId.toString()); + map.set("version", "2"); + map.set("is_deleted", "1"); + await deleteAll(rawContactUri, "contact_Delete_test_7400"); + sleep(1000); + await contactsQuery(map, "contact_Delete_test_7400", rawContactUri); + var conditionAll = new ohosDataAbility.DataAbilityPredicates(); + conditionAll.greaterThan("id", "0"); + var code = await DAHelper.delete(deletedUri, conditionAll); + console.info('contact_Delete_test_7400 : Completely delete code = ' + code); + expect(code == 0).assertTrue(); + done(); + } catch (error) { + console.info('logMessage contact_Delete_test_7400: insert error = ' + error); + done(); + } + }); + + /** + * @tc.number contact_delete_test_7500 + * @tc.name Delete contact_data Single full field data in data table + * @tc.desc Function test + */ + it("contact_delete_test_7500", 0, async function (done) { + console.info("------logMessage contact_delete_test_7500 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocai", + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_delete_test_7500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var contactDataValues = common.getProfileContactData(); + contactDataValues["raw_contact_id"] = rawContactId; + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + console.info('logMessage contact_delete_test_7500: contactDataId = ' + contactDataId); + expect(contactDataId > 0).assertTrue(); + await deleteAll(contactDataUri, "contact_delete_test_7500"); + var map = new Map(); + map.set("id", contactDataId.toString()); + await queryIdForDelete(map, "contact_delete_test_7500", contactDataUri); + await deleteRawContact("contact_delete_test_7500"); + done(); + } catch (error) { + console.info("logMessage contact_delete_test_7500: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number contact_insertDataAll_test_7600 + * @tc.name Add all details of a single contact and verify whether the insertion is successful (name, mobile + * number, company, position, nickname, email, home, remarks, aim) + * @tc.desc Function test + */ + it("contact_insertDataAll_test_7600", 0, async function (done) { + console.info("------logMessage contact_insertDataAll_test_7600 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocai", + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_insertDataAll_test_7600: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var contactdata1 = await insertData(rawContactId, "name", "xiaocai", ""); + await queryAlldata("contact_insertDataAll_test_7600", DAHelper, rawContactId, contactdata1, "xiaocai"); + var contactdata2 = await insertData(rawContactId, "phone", "6500", ""); + await queryAlldata("contact_insertDataAll_test_7600", DAHelper, rawContactId, contactdata2, "6500"); + var contactdatd3 = await insertData(rawContactId, "organization", "TTTTT", "Deve"); + await queryAlldata("contact_insertDataAll_test_7600", DAHelper, rawContactId, contactdatd3, "TTTTT"); + var contactdatd4 = await insertData(rawContactId, "nickname", "xxxxcai", ""); + await queryAlldata("contact_insertDataAll_test_7600", DAHelper, rawContactId, contactdatd4, "xxxxcai"); + var contactdatd5 = await insertData(rawContactId, "email", "111@fox.com", ""); + await queryAlldata("contact_insertDataAll_test_7600", DAHelper, rawContactId, contactdatd5, "111@fox.com"); + var contactdatd6 = await insertData(rawContactId, "postal_address", "dddd", ""); + await queryAlldata("contact_insertDataAll_test_7600", DAHelper, rawContactId, contactdatd6, "dddd"); + var contactdatd7 = await insertData(rawContactId, "note", "caicai", ""); + await queryAlldata("contact_insertDataAll_test_7600", DAHelper, rawContactId, contactdatd7, "caicai"); + var contactdatd8 = await insertData(rawContactId, "im", "999999999", ""); + await queryAlldata("contact_insertDataAll_test_7600", DAHelper, rawContactId, contactdatd8, "999999999"); + sleep(1000); + await deleteRawContact("contact_insertDataAll_test_7600"); + await deleteAll(contactDataUri, "contact_insertDataAll_test_7600"); + done(); + } catch (error) { + console.info("logMessage contact_insertDataAll_test_7600: raw_contact insert error = " + error); + done(); + } + }); + + async function queryAlldata(tag, DAHelper, rawContactId, contactdata, values) { + var resultColumns = ["raw_contact_id", "detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", contactdata.toString()); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var id = resultSet.getString(resultSet.getColumnIndex("raw_contact_id")); + console.info(tag + " result raw_contact_id = " + id); + expect(id == rawContactId).assertEqual(true); + var info = resultSet.getString(resultSet.getColumnIndex("detail_info")); + console.info(tag + " result info = " + info + " value = " + values); + expect(info == values).assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info(tag + " :logMessage queryIdForDelete: error = " + error); + } + } + + /** + * @tc.number contact_insertDataAll_test_7700 + * @tc.name Add all details of a single contact and verify whether the insertion is successful (name, mobile + * number, company, position, nickname, email, home, remarks, aim, birthday, website, assistant, group, phone ring) + * @tc.desc Function test + */ + it("contact_insertDataAll_test_7700", 0, async function (done) { + console.info("------logMessage contact_insertDataAll_test_7700 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues = { + "display_name": "xiaocai", + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_insertDataAll_test_7700: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var contactdata1 = await insertData(rawContactId, "name", "xiaocai", ""); + await queryAlldata("contact_insertDataAll_test_7700", DAHelper, rawContactId, contactdata1, "xiaocai"); + var contactdata2 = await insertData(rawContactId, "phone", "6500", ""); + await queryAlldata("contact_insertDataAll_test_7700", DAHelper, rawContactId, contactdata2, "6500"); + var contactdatd3 = await insertData(rawContactId, "organization", "TTTTT", "Deve"); + await queryAlldata("contact_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd3, "TTTTT"); + var contactdatd4 = await insertData(rawContactId, "nickname", "xxxxcai", ""); + await queryAlldata("contact_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd4, "xxxxcai"); + var contactdatd5 = await insertData(rawContactId, "email", "111@fox.com", ""); + await queryAlldata("contact_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd5, "111@fox.com"); + var contactdatd6 = await insertData(rawContactId, "postal_address", "dddd", ""); + await queryAlldata("contact_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd6, "dddd"); + var contactdatd7 = await insertData(rawContactId, "note", "caicai", ""); + await queryAlldata("contact_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd7, "caicai"); + var contactdatd8 = await insertData(rawContactId, "im", "999999999", ""); + await queryAlldata("contact_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd8, "999999999"); + var contactdatd9 = await insertData(rawContactId, "contact_event", "1125", ""); + await queryAlldata("contact_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd9, "1125"); + var contactdatd10 = await insertData(rawContactId, "website", "wwww.xxx.com", ""); + await queryAlldata( + "contact_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd10, "wwww.xxx.com"); + var contactdatd11 = await insertData(rawContactId, "relation", "xiaobai", ""); + await queryAlldata("contact_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd11, "xiaobai"); + var contactdatd12 = await insertData(rawContactId, "group_membership", 1, ""); + await queryAlldata("contact_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd12, 1); + var contactdatd13 = await insertData(rawContactId, "contact_misc", "5678", ""); + await queryAlldata("contact_insertDataAll_test_7700", DAHelper, rawContactId, contactdatd13, "5678"); + sleep(1000); + await deleteRawContact("contact_insertDataAll_test_7700"); + await deleteAll(contactDataUri, "contact_insertDataAll_test_7700"); + done(); + } catch (error) { + console.info("logMessage contact_insertDataAll_test_7700: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number contact_insertDataUpdateMore_test_7800 + * @tc.name Modify multiple contact details and verify whether the modification is successful + * @tc.desc Function test + */ + it("contact_insertDataUpdateMore_test_7800", 0, async function (done) { + console.info("------logMessage contact_insertDataUpdateMore_test_7800 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var insertRawContactValues = { + "display_name": "xiaocai" + }; + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_insertDataUpdateMore_test_7800: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await insertData(rawContactId, "name", "xiaotian", ""); + + var insertRawContactValues1 = { + "display_name": "xiaotian" + }; + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + console.info("logMessage contact_insertDataUpdateMore_test_7800: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + await insertData(rawContactId, "name", "xiaotian", ""); + + var updateValues = { + "detail_info": "xiaocai7800" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + condition.or(); + condition.equalTo("raw_contact_id", rawContactIdFirst.toString()) + var updataCode = await DAHelper.update(contactDataUri, updateValues, condition); + console.info('logMessage contact_insertDataUpdateMore_test_7800: updataCode = ' + updataCode); + sleep(1000); + await insertDataUpdateMoreQuery( + "contact_insertDataUpdateMore_test_7800", DAHelper, rawContactId, rawContactIdFirst); + await deleteRawContact("contact_insertDataUpdateMore_test_7800"); + await deleteAll(contactDataUri, "contact_insertDataUpdateMore_test_7800"); + done(); + } catch (error) { + console.info("logMessage contact_insertDataUpdateMore_test_7800: raw_contact insert error = " + error); + done(); + } + }); + + async function insertDataUpdateMoreQuery(tag, DAHelper, rawContactId, rawContactIdFirst) { + var resultColumns = ["detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + condition.or(); + condition.equalTo("raw_contact_id", rawContactIdFirst.toString()) + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var info = resultSet.getString(resultSet.getColumnIndex("detail_info")); + console.info(tag + " result info = " + info); + expect(info == "xiaocai7800").assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info(tag + " :logMessage : error = " + error); + } + } + + /** + * @tc.number contact_deleterestore_test_7900 + * @tc.name Delete contacts and restore + * @tc.desc Function test + */ + it("contact_deleterestore_test_7900", 0, async function (done) { + console.info("------logMessage contact_deleterestore_test_7900 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var insertRawContactValues = { + "display_name": "xaioli7900" + }; + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage contact_deleterestore_test_7900: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + sleep(1000); + var condition1 = new ohosDataAbility.DataAbilityPredicates(); + condition1.equalTo("id", rawContactId.toString()); + var deleteCode = await DAHelper.delete(rawContactUri, condition1); + console.info("contact_deleterestore_test_7900 " + + ': deleteCode = ' + deleteCode); + expect(deleteCode == 0).assertTrue(); + sleep(1000); + + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + condition2.equalTo("id", rawContactId.toString()); + var updatevalue = { + "is_deleted": 0 + }; + var updateCode = await DAHelper.update(rawContactUri, updatevalue, condition2); + console.info('contact_deleterestore_test_7900 : update = ' + updateCode); + sleep(1000); + + var condition3 = new ohosDataAbility.DataAbilityPredicates(); + condition3.equalTo("id", rawContactId.toString()); + var code = await DAHelper.delete(deletedRawContactRecord, condition3); + console.info('contact_deleterestore_test_7900 : record code = ' + code); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("is_deleted", "0"); + await contactsQuery(map, "contact_deleterestore_test_7900", rawContactUri); + await deleteRawContact("contact_deleterestore_test_7900"); + done(); + } catch (error) { + console.info("logMessage contact_deleterestore_test_7900: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number abnormal_contact_updateData_test_8000 + * @tc.name When modifying contact_data table, incorrect field or table name or nonexistent value is passed in + * @tc.desc Function test + */ + it("abnormal_contact_updateData_test_8000", 0, async function (done) { + console.info("------logMessage abnormal_contact_updateData_test_8000 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var insertRawContactValues = { + "display_name": "xaioli8000" + }; + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage abnormal_contact_updateData_test_8000: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + sleep(1000); + var contactDataId = await insertData(rawContactId, "name", "xaioli8000", ""); + console.info("logMessage abnormal_contact_updateData_test_8000: contactDataId = " + contactDataId); + expect(contactDataId > 0).assertTrue(); + + var condition = new ohosDataAbility.DataAbilityPredicates(); + var updateValues = { + "display_namess": "xaioli80000000" + }; + condition.equalTo("id", contactDataId.toString()); + var code = await DAHelper.update(contactDataUri, updateValues, condition); + console.info('abnormal_contact_updateData_test_8000 : update code = ' + code); + expect(code == -1).assertTrue(); + var map = new Map(); + map.set("id", contactDataId.toString()); + map.set("display_name", "xaioli8000"); + await contactsQuery(map, "abnormal_contact_updateData_test_8000", contactDataUri); + await deleteRawContact("abnormal_contact_updateData_test_8000"); + await deleteAll(contactDataUri, "abnormal_contact_updateData_test_8000"); + done(); + } catch (error) { + console.info("logMessage abnormal_contact_updateData_test_8000: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number abnormal_contact_favorite_test_8100 + * @tc.name When collecting contacts, an incorrect field was passed in + * @tc.desc Function test + */ + it("abnormal_contact_favorite_test_8100", 0, async function (done) { + console.info("------logMessage abnormal_contact_favorite_test_8100 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var insertRawContactValues = { + "display_name": "xaioli8100", "favoriteeee": 1 + }; + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage abnormal_contact_favorite_test_8100: rawContactId = " + rawContactId); + expect(rawContactId == -1).assertTrue(); + sleep(1000); + done(); + } catch (error) { + console.info("logMessage abnormal_contact_favorite_test_8100: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number abnormal_contact_blocklist_test_8200 + * @tc.name When adding to the blocklist, an error field is passed in + * @tc.desc Function test + */ + it("abnormal_contact_blocklist_test_8200", 0, async function (done) { + console.info("------logMessage abnormal_contact_blocklist_test_8200 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var insertValues = { + "phone_numberss": "9999999", + }; + var id = await DAHelper.insert(contactBlocklistUri, insertValues); + console.info("logMessage abnormal_contact_blocklist_test_8200: id = " + id); + expect(id == -1).assertTrue(); + sleep(1000); + done(); + } catch (error) { + console.info("logMessage abnormal_contact_blocklist_test_8200: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number abnormal_contact_group_test_8300 + * @tc.name When joining a group, an incorrect field is passed in + * @tc.desc Function test + */ + it("abnormal_contact_group_test_8300", 0, async function (done) { + console.info("------logMessage abnormal_contact_group_test_8300 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var insertRawContactValues = { + "display_name": "xaioli8100" + }; + var rawContactId = await DAHelper.insert(rawContactUri, insertRawContactValues); + console.info("logMessage abnormal_contact_group_test_8300: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_typess": "group_membership", + "detail_info": 1 + }; + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues1); + console.info("abnormal_contact_group_test_8300 logMessage : contactDataId " + contactDataId); + expect(contactDataId == -1).assertTrue(); + done(); + } catch (error) { + console.info("logMessage abnormal_contact_group_test_8300: raw_contact insert error = " + error); + done(); + } + }); + + /** + * @tc.number abnormal_contact_query_test_8400 + * @tc.name When querying the basic information of multiple contacts, an error field is passed in + * @tc.desc Function test + */ + it("abnormal_contact_query_test_8400", 0, async function (done) { + console.info("------------abnormal_contact_query_test_8400 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaotian8400" + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_query_test_8400: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var rawContactValues = { + "display_name": "xiaoli8400" + }; + var rawContactIdFirst = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_query_test_8400: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + await abnormalQuery(); + await deleteRawContact("abnormal_contact_query_test_8400"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_8400: raw_contact insert error' + error); + done(); + } + + async function abnormalQuery() { + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", rawContactId.toString()); + condition.or(); + condition.equalTo("ids", rawContactIdFirst.toString()); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + expect(resultSet.goToFirstRow()).assertEqual(false); + console.info('logMessage abnormal_contact_query_test_8400: goToFirstRow' + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_8400: query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_query_test_8500 + * @tc.name When querying the basic information of all contacts, an error field is passed in + * @tc.desc Function test + */ + it("abnormal_contact_query_test_8500", 0, async function (done) { + console.info("------------abnormal_contact_query_test_8500 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaotian8500" + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_query_test_8500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var rawContactValues = { + "display_name": "xiaoli8500" + }; + var rawContactIdFirst = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_query_test_8500: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + await abnormalQuery(); + await deleteRawContact("abnormal_contact_query_test_8500"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_8500: raw_contact insert error' + error); + done(); + } + + async function abnormalQuery() { + var resultColumns = ["id", "display_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("ids", "0"); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + expect(resultSet.goToFirstRow()).assertEqual(false); + console.info('logMessage abnormal_contact_query_test_8500: goToFirstRow' + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_8500: query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_query_test_8600 + * @tc.name When querying all the information of a single contact, an error field is passed in + * @tc.desc Function test + */ + it("abnormal_contact_query_test_8600", 0, async function (done) { + console.info("------------abnormal_contact_query_test_8600 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaotian8600" + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_query_test_8600: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await abnormalQuery(); + await deleteRawContact("abnormal_contact_query_test_8600"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_8600: raw_contact insert error' + error); + done(); + } + + async function abnormalQuery() { + var resultColumns = ["id", "display_names"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + expect(resultSet.goToFirstRow()).assertEqual(false); + console.info('logMessage abnormal_contact_query_test_8600: goToFirstRow' + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_8600: query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_query_test_8700 + * @tc.name An incorrect field was passed in when querying group members + * @tc.desc Function test + */ + it("abnormal_contact_query_test_8700", 0, async function (done) { + console.info("------------abnormal_contact_query_test_8700 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaotian8700" + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_query_test_8700: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var dataId = await insertData(rawContactId, "group_membership", 1, ""); + console.info("logMessage abnormal_contact_query_test_8700: dataId = " + dataId); + expect(dataId > 0).assertTrue(); + await abnormalQuery(); + await deleteRawContact("abnormal_contact_query_test_8700"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_8700: raw_contact insert error' + error); + done(); + } + + async function abnormalQuery() { + var resultColumns = ["raw_contact_id"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("content_typess", "group_membership"); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + expect(resultSet.goToFirstRow()).assertEqual(false); + console.info('logMessage abnormal_contact_query_test_8700: goToFirstRow' + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_8700: query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_query_test_8800 + * @tc.name An incorrect field was passed in when querying favorite contacts + * @tc.desc Function test + */ + it("abnormal_contact_query_test_8800", 0, async function (done) { + console.info("------------abnormal_contact_query_test_8800 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaotian8700", "favorite": 1 + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_query_test_8800: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await abnormalQuery(); + await deleteRawContact("abnormal_contact_query_test_8800"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_8800: raw_contact insert error' + error); + done(); + } + + async function abnormalQuery() { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + expect(resultSet.goToFirstRow()).assertEqual(false); + console.info('logMessage abnormal_contact_query_test_8800: goToFirstRow' + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_8800: query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_query_test_8900 + * @tc.name An incorrect field was passed in when querying recent contacts + * @tc.desc Function test + */ + it("abnormal_contact_query_test_8900", 0, async function (done) { + console.info("------------abnormal_contact_query_test_8900 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaoyuzhou", "lastest_contacted_time": 60 + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_query_test_8900: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + await abnormalQuery(); + await deleteRawContact("abnormal_contact_query_test_8900"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_8900: raw_contact insert error' + error); + done(); + } + + async function abnormalQuery() { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("lastest_contacted_timess", "50"); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + expect(resultSet.goToFirstRow()).assertEqual(false); + console.info('logMessage abnormal_contact_query_test_8900: goToFirstRow' + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_8900: query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_query_test_9000 + * @tc.name An error field was passed in when querying the recently deleted contact + * @tc.desc Function test + */ + it("abnormal_contact_query_test_9000", 0, async function (done) { + console.info("------------abnormal_contact_query_test_9000 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaotian" + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_query_test_9000: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + var deleteCode = await DAHelper.delete(rawContactUri, condition); + console.info(tag + ': deleteRawContact deleteCode = ' + deleteCode); + expect(deleteCode == 0).assertTrue(); + await abnormalQuery(); + await deleteRawContact("abnormal_contact_query_test_9000"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_9000: raw_contact insert error' + error); + done(); + } + + async function abnormalQuery() { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.orderByDesc("delete_timess"); + try { + var resultSet = await DAHelper.query(deletedRawContactUri, resultColumns, condition); + expect(resultSet.goToFirstRow()).assertEqual(false); + console.info('logMessage abnormal_contact_query_test_9000: goToFirstRow' + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_9000: query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_query_test_9100 + * @tc.name When querying all mobile phone numbers, an error field is passed in + * @tc.desc Function test + */ + it("abnormal_contact_query_test_9100", 0, async function (done) { + console.info("------------abnormal_contact_query_test_9100 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaotian9100" + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_query_test_9100: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var dataId = await insertData(rawContactId, "phone", "11159100", ""); + console.info("logMessage abnormal_contact_query_test_9100: dataId = " + dataId); + var dataId1 = await insertData(rawContactId, "phone", "111591009100", ""); + console.info("logMessage abnormal_contact_query_test_9100: dataId1 = " + dataId1); + await abnormalQuery(); + await deleteRawContact("abnormal_contact_query_test_9100"); + await deleteAll(contactDataUri, "abnormal_contact_query_test_9100"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_9100: raw_contact insert error' + error); + done(); + } + + async function abnormalQuery() { + var resultColumns = ["detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("content_typess", "phone"); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + expect(resultSet.goToFirstRow()).assertEqual(false); + console.info('logMessage abnormal_contact_query_test_9100: goToFirstRow' + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_9100: query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_query_test_9200 + * @tc.name When querying all mailboxes, an error field was passed in + * @tc.desc Function test + */ + it("abnormal_contact_query_test_9200", 0, async function (done) { + console.info("------------abnormal_contact_query_test_9200 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaotian9100" + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_query_test_9200: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var dataId = await insertData(rawContactId, "email", "fox@1.com", ""); + console.info("logMessage abnormal_contact_query_test_9200: dataId = " + dataId); + var dataId1 = await insertData(rawContactId, "phone", "fox@2.com", ""); + console.info("logMessage abnormal_contact_query_test_9200: dataId1 = " + dataId1); + await abnormalQuery(); + await deleteRawContact("abnormal_contact_query_test_9200"); + await deleteAll(contactDataUri, "abnormal_contact_query_test_9200"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_9200: raw_contact insert error' + error); + done(); + } + + async function abnormalQuery() { + var resultColumns = ["detail_info"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("content_typess", "email"); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + expect(resultSet.goToFirstRow()).assertEqual(false); + console.info('logMessage abnormal_contact_query_test_9200: goToFirstRow' + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_9200: query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_delete_test_10000 + * @tc.name When querying all mailboxes, an error field was passed in + * @tc.desc Function test + */ + it("abnormal_contact_delete_test_10000", 0, async function (done) { + console.info("------------abnormal_contact_delete_test_10000 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaotian9300" + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_delete_test_10000: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var dataId = await insertData(rawContactId, "email", "fox@1.com", ""); + console.info("logMessage abnormal_contact_delete_test_10000: dataId = " + dataId); + var dataId1 = await insertData(rawContactId, "phone", "fox@2.com", ""); + console.info("logMessage abnormal_contact_delete_test_10000: dataId1 = " + dataId1); + + var errorUri = "dataability:///com.ohos.contactsdataability/contacts/contact_datasss"; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", dataId.toString()); + var deleteCode = await DAHelper.delete(errorUri, condition); + console.info(tag + ': deleteAll deleteCode = ' + deleteCode); + expect(deleteCode == -1).assertTrue(); + var map = new Map(); + map.set("id", dataId.toString()); + map.set("datail_info", "fox@1.com"); + await contactsQuery(map, "abnormal_contact_delete_test_10000", contactDataUri); + await deleteRawContact("abnormal_contact_delete_test_10000"); + await deleteAll(contactDataUri, "abnormal_contact_delete_test_10000"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_delete_test_10000: raw_contact insert error' + error); + done(); + } + }); + + /** + * @tc.number abnormal_contact_delete_test_9300 + * @tc.name When deleting, an incorrect URI was passed in + * @tc.desc Function test + */ + it("abnormal_contact_delete_test_9300", 0, async function (done) { + console.info("------------abnormal_contact_delete_test_9300 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaotian9300" + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_delete_test_9300: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var dataId = await insertData(rawContactId, "email", "fox@1.com", ""); + console.info("logMessage abnormal_contact_delete_test_9300: dataId = " + dataId); + var dataId1 = await insertData(rawContactId, "phone", "fox@2.com", ""); + console.info("logMessage abnormal_contact_delete_test_9300: dataId1 = " + dataId1); + + var errorUri = "dataability:///com.ohos.contactsdataability/contacts/raw_contactsss"; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + var deleteCode = await DAHelper.delete(errorUri, condition); + console.info(tag + ': deleteAll deleteCode = ' + deleteCode); + expect(deleteCode == -1).assertTrue(); + var map = new Map(); + map.set("id", rawContactId.toString()); + map.set("display_name", "xiaotian9300"); + await contactsQuery(map, "abnormal_contact_delete_test_9300", rawContactUri); + await deleteRawContact("abnormal_contact_delete_test_9300"); + await deleteAll(contactDataUri, "abnormal_contact_delete_test_9300"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_delete_test_9300: raw_contact insert error' + error); + done(); + } + }); + + /** + * @tc.number abnormal_contact_delete_test_9400 + * @tc.name When deleting contacts in batch, an error field is passed in + * @tc.desc Function test + */ + it("abnormal_contact_delete_test_9400", 0, async function (done) { + console.info("------------abnormal_contact_delete_test_9400 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaotian9400" + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_delete_test_9400: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var rawContactValues = { + "display_name": "xiaoli9400" + }; + var rawContactIdFirst = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_delete_test_9400: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", rawContactId.toString()); + condition.or(); + condition.equalTo("ids", rawContactIdFirst.toString()) + var deleteCode = await DAHelper.delete(rawContactUri, condition); + console.info('abnormal_contact_delete_test_9400 : deleteCode = ' + deleteCode); + expect(deleteCode == -1).assertTrue(); + await deleteRawContact("abnormal_contact_delete_test_9400"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_delete_test_9400: raw_contact insert error' + error); + done(); + } + }); + + /** + * @tc.number abnormal_contact_favorite_test_9500 + * @tc.name When collecting contacts in batch, the error field is transferred + * @tc.desc Function test + */ + it("abnormal_contact_favorite_test_9500", 0, async function (done) { + console.info("------------abnormal_contact_favorite_test_9500 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaotian9500", "favorite": 0 + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_favorite_test_9500: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var rawContactValues = { + "display_name": "xiaoli9500", "favorite": 0 + }; + var rawContactIdFirst = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_favorite_test_9500: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + + var condition = new ohosDataAbility.DataAbilityPredicates(); + var updateValues = { + "favorites": 1 + }; + condition.equalTo("id", rawContactId.toString()); + condition.or(); + condition.equalTo("id", rawContactIdFirst.toString()) + var code = await DAHelper.update(rawContactUri, updateValues, condition); + console.info(' abnormal_contact_favorite_test_9500 : update code = ' + deleteCode); + expect(code == -1).assertTrue(); + await deleteRawContact("abnormal_contact_favorite_test_9500"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_favorite_test_9500: raw_contact insert error' + error); + done(); + } + }); + + /** + * @tc.number abnormal_contact_insertblocklist_test_9600 + * @tc.name When collecting contacts in batch, the error field is transferred + * @tc.desc Function test + */ + it("abnormal_contact_insertblocklist_test_9600", 0, async function (done) { + console.info("------------abnormal_contact_insertblocklist_test_9600 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaotian9600", + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_insertblocklist_test_9600: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var dataId = await insertData(rawContactId, "phone", "1234567899600", ""); + console.info("logMessage abnormal_contact_insertblocklist_test_9600: dataId = " + dataId); + var rawContactValues = { + "display_name": "xiaoli9600", + }; + var rawContactIdFirst = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_insertblocklist_test_9600: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var dataId1 = await insertData(rawContactIdFirst, "phone", "1234567899600", ""); + console.info("logMessage abnormal_contact_insertblocklist_test_9600: dataId1 = " + dataId1); + + var blist = { + "phone_numbers": "1234567899600" + }; + var code = await DAHelper.insert(contactBlocklistUri, blist); + expect(code == -1).assertTrue(); + await deleteRawContact("abnormal_contact_insertblocklist_test_9600"); + await deleteAll(contactDataUri, "abnormal_contact_insertblocklist_test_9600"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_insertblocklist_test_9600: raw_contact insert error' + error); + done(); + } + }); + + /** + * @tc.number abnormal_contact_insertGroup_test_9700 + * @tc.name When a contact joins a group in batch, an error field is passed + * @tc.desc Function test + */ + it("abnormal_contact_insertGroup_test_9700", 0, async function (done) { + console.info("------------abnormal_contact_insertGroup_test_9700 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var rawContactValues = { + "display_name": "xiaotian9700" + }; + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_insertGroup_test_9700: rawContactId = " + rawContactId); + expect(rawContactId > 0).assertTrue(); + var contactDataValues1 = { + "raw_contact_id": rawContactId, + "content_typess": "group_membership", + "detail_info": 1 + }; + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues1); + console.info("abnormal_contact_insertGroup_test_9700 logMessage : contactDataId " + contactDataId); + expect(contactDataId == -1).assertTrue(); + var rawContactValues = { + "display_name": "xiaoli9700" + }; + var rawContactIdFirst = await DAHelper.insert(rawContactUri, rawContactValues); + console.info("logMessage abnormal_contact_insertGroup_test_9700: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var contactDataValues2 = { + "raw_contact_id": rawContactIdFirst, + "content_typess": "group_membership", + "detail_info": 1 + }; + var contactDataId1 = await DAHelper.insert(contactDataUri, contactDataValues2); + console.info("abnormal_contact_insertGroup_test_9700 logMessage : contactDataId1 " + contactDataId1); + expect(contactDataId1 == -1).assertTrue(); + await deleteRawContact("abnormal_contact_insertblocklist_test_9600"); + done(); + } catch (error) { + console.info('logMessage abnormal_contact_insertblocklist_test_9600: raw_contact insert error' + error); + done(); + } + }); + + /** + * @tc.number abnormal_contact_pinyinquery_test_9800 + * @tc.name Insert a name with special characters to view the converted Pinyin + * @tc.desc Function test + */ + it("abnormal_contact_pinyinquery_test_9800", 0, async function (done) { + console.info("--------logMessage abnormal_contact_pinyinquery_test_9800 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "李bp玉成욱" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage abnormal_contact_pinyinquery_test_9800 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + var dataId = await insertData(rawContactId, "name", "李bp玉成욱", ""); + console.info('logMessage abnormal_contact_pinyinquery_test_9800 dataId = ' + dataId); + expect(dataId > 0).assertTrue(); + await query(); + await deleteRawContact("abnormal_contact_pinyinquery_test_9800"); + await deleteAll(contactDataUri, "abnormal_contact_pinyinquery_test_9800") + done(); + } catch (error) { + console.info('logMessage abnormal_contact_pinyinquery_test_9800 raw_contact insert error = ' + error); + done(); + } + + async function query() { + var resultColumns = ["search_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("raw_contact_id", rawContactId.toString()); + try { + var resultSet = await DAHelper.query(searchContactUri, resultColumns, condition); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var name = resultSet.getString(resultSet.getColumnIndex("search_name")); + console.info( + ' abnormal_contact_pinyinquery_test_9800 :logMessage contactsQuery name = ' + name); + expect(name == "李bp玉成욱||libpyucheng욱||lbpyc욱").assertEqual(true); + } while (resultSet.goToNextRow()); + } + } + resultSet.close(); + } catch (error) { + console.info('logMessage abnormal_contact_pinyinquery_test_9800 query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_contact_query_test_9900 + * @tc.name An incorrect field name was passed in during retrieval + * @tc.desc Function test + */ + it("abnormal_contact_query_test_9900", 0, async function (done) { + console.info("--------logMessage abnormal_contact_query_test_9900 is starting!-------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "键盘" + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info('logMessage abnormal_contact_query_test_9900 rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + var dataId = await insertData(rawContactId, "name", "键盘", ""); + console.info('logMessage abnormal_contact_query_test_9900 dataId = ' + dataId); + expect(dataId > 0).assertTrue(); + await query(); + await deleteRawContact("abnormal_contact_query_test_9900"); + await deleteAll(contactDataUri, "abnormal_contact_query_test_9900") + done(); + } catch (error) { + console.info('logMessage abnormal_contact_query_test_9900 raw_contact insert error = ' + error); + done(); + } + + async function query() { + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.like("search_namesss", "%jp%"); + try { + var resultSet = await DAHelper.query(searchContactUri, resultColumns, condition); + console.info( + ' abnormal_contact_query_test_9900 :resultSet.goToFirstRow() = ' + resultSet.goToFirstRow()); + expect(resultSet.goToFirstRow() == false).assertTrue(); + resultSet.close(); + } catch (error) { + console.info('logMessage abnormal_contact_pinyinquery_test_9800 query error = ' + error); + done(); + } + } + }); + + afterAll(async function () { + var tag = "Contacts_test_start_deleted"; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + var DAHelperContact = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': start ! DAHelperContact = ' + DAHelperContact); + var deleteBlockList = await DAHelperContact.delete(contactBlocklistUri, condition); + console.info(tag + " : logMessage : deleteBlockList = " + deleteBlockList); + var deletedGroup = await DAHelperContact.delete(groupUri, condition); + console.info(tag + " : logMessage : deletedGroup = " + deletedGroup); + var dataDeletedCode = await DAHelperContact.delete(contactDataUri, condition); + sleep(2000); + console.info(tag + " : logMessage : dataDeletedCode = " + dataDeletedCode); + var rawContactDeleted = await DAHelperContact.delete(rawContactUri, condition); + sleep(2000); + console.info(tag + " : logMessage : rawContactDeleted = " + rawContactDeleted); + var deleted = await DAHelperContact.delete(deletedUri, condition); + sleep(2000); + console.info(tag + " : logMessage : deleted = " + deleted); + }); + }); +} diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/Groups_test.js b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/Groups_test.js new file mode 100644 index 0000000000000000000000000000000000000000..e3faa50302921b6060f1293683abc0c5b7d4ba77 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/Groups_test.js @@ -0,0 +1,574 @@ +/* + * Copyright (c) 2021 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 featureAbility from '@ohos.ability.featureAbility'; +import ohosDataAbility from '@ohos.data.dataability'; +import utils from '../Utils.ets' +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'deccjsunit/index' + +const URI_CONTACTS = "dataability:///com.ohos.contactsdataability"; +const groupUri = "dataability:///com.ohos.contactsdataability/contacts/groups"; +import common from './common.js'; + +export default function GroupsTest() { + describe('GroupsTest', function () { + console.info('logMessage GroupsTest start! '); + + async function groupsQuery(map, tag) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': groupsQuery start ! DAHelper = ' + DAHelper); + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", map.get("id")); + try { + if (resultSet.rowCount > 0 && resultSet.goToFirstRow()) { + do { + for (var [key, value] of map) { + var dbresult = resultSet.getString(resultSet.getColumnIndex(key)); + console.info(tag + ': logMessage groupsQuery key =' + key + 'dbresult :' + dbresult + + ' value : ' + value); + expect(value == dbresult).assertTrue(); + } + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info(tag + ': logMessage groupsQuery: error = ' + error); + } + } + + async function queryIdForDelete(map, tag) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': queryIdForDelete start ! DAHelper = ' + DAHelper); + var resultColumns = common.getCallLogResultColumns(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", map.get("id")); + try { + var resultSet = await DAHelper.query(groupUri, resultColumns, condition); + expect(resultSet.goToFirstRow() == false).assertTrue(); + console.info(tag + " :logMessage queryIdForDelete: goToFirstRow " + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info(tag + " :logMessage queryIdForDelete: error = " + error); + } + } + + async function deleteAll(uri, tag) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + var deleteCode = await DAHelper.delete(uri, condition); + console.info(tag + ': deleteAll deleteCode = ' + deleteCode); + expect(deleteCode == 0).assertTrue(); + } + + /** + * @tc.number group_insert_test_100 + * @tc.name Insert group + * @tc.desc Function test + */ + it("group_insert_test_100", 0, async function (done) { + console.info("---------logMessage group_insert_test_100 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var groupId = await DAHelper.insert(groupUri, common.getProfileGroup()); + console.info("logMessage group_insert_test_100: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + var map = common.getProfileGroupMap(); + map.set("id", groupId.toString()); + await groupsQuery(map, "group_insert_test_100"); + await deleteAll(groupUri, "group_insert_test_100"); + done(); + } catch (error) { + console.info("logMessage group_insert_test_100: group insert error = " + error); + done(); + } + }); + + /** + * @tc.number group_update_test_500 + * @tc.name Update group + * @tc.desc Function test + */ + it("group_update_test_500", 0, async function (done) { + console.info("---------logMessage group_update_test_500 is starting!----------"); + if(utils.notCheck){ + expect(true).assertTrue(); + done(); + return; + } + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var groupId = await DAHelper.insert(groupUri, common.getProfileGroup()); + console.info("logMessage group_update_test_500: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + await groupUpdate(); + await deleteAll(groupUri, "group_update_test_500"); + done(); + } catch (error) { + console.info("logMessage group_update_test_500: group insert error = " + error); + done(); + } + + async function groupUpdate() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", groupId.toString()); + try { + var updateCode = await DAHelper.update(groupUri, common.getProfileUpdateGroup(), condition); + console.info("logMessage group_update_test_500: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + var map = common.getProfileUpdateGroupMap(); + map.set("id", groupId.toStirng()); + await groupsQuery(map, "group_update_test_500"); + } catch (error) { + console.info("logMessage group_update_test_500: update error = " + error); + done(); + } + } + }); + + /** + * @tc.number group_delete_test_200 + * @tc.name Delete group + * @tc.desc Function test + */ + it("group_delete_test_200", 0, async function (done) { + console.info("---------logMessage group_delete_test_200 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var groupId = await DAHelper.insert(groupUri, common.getProfileGroup()); + console.info("logMessage group_delete_test_200: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + await groupDelete(); + done(); + } catch (error) { + console.info("logMessage group_delete_test_200: group insert error = " + error); + done(); + } + async function groupDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", groupId.toString()); + try { + var deleteCode = await DAHelper.delete(groupUri, condition); + console.info("logMessage group_delete_test_200 : deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + var map = new Map(); + map.set("id", groupId.toString()); + await queryIdForDelete(map, "group_delete_test_200"); + } catch (error) { + console.info("logMessage group_delete_test_200 : delete error = " + error); + done(); + } + } + }); + + /** + * @tc.number group_query_test_300 + * @tc.name Query a group + * @tc.desc Function test + */ + it("group_query_test_300", 0, async function (done) { + console.info("------------logMessage group_query_test_300 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var groupId = await DAHelper.insert(groupUri, common.getProfileGroup()); + console.info("logMessage group_query_test_300: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + var map = common.getProfileGroupMap(); + map.set("id", groupId.toString()); + await groupsQuery(map, "logMessage group_query_test_300"); + await deleteAll(groupUri, "group_query_test_300"); + done(); + } catch (error) { + console.info("logMessage group_query_test_300: group insert error = " + error); + done(); + } + }); + + /** + * @tc.number group_query_test_400 + * @tc.name Query all groups + * @tc.desc Function test + */ + it("group_query_test_400", 0, async function (done) { + console.info("------------logMessage group_query_test_400 is starting!-----------"); + console.info("---------logMessage getDbHelper start!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + console.info('logMessage uri = ' + URI_CONTACTS); + var groupUri = "dataability:///com.ohos.contactsdataability/contacts/groups"; + + var insertValues = { + "group_name": "ManagerSecondGroup" + }; + try { + var groupId = await DAHelper.insert(groupUri, insertValues); + console.info("logMessage group_query_test_400: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + await groupQuery(); + await deleteAll(groupUri, "group_query_test_400"); + done(); + } catch (error) { + console.info("logMessage group_query_test_400: group insert error = " + error); + done(); + } + + async function groupQuery() { + var resultColumns = ["id", "group_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + var resultSet = await DAHelper.query(groupUri, resultColumns, condition); + console.info("logMessage group_query_test_400: resultSet.rowCount = " + resultSet.rowCount); + expect(resultSet.rowCount == 1).assertTrue(); + resultSet.close(); + } catch (error) { + console.info("group_query_test_400 resultSet query error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_group_insert_test_600 + * @tc.name abnormal insert + * @tc.desc Function test + */ + it("abnormal_group_insert_test_600", 0, async function (done) { + console.info("---------logMessage abnormal_group_insert_test_600 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + const errorUri = "dataability:///com.ohos.contactsdataability/contacts/groupssss"; + try { + var groupId = await DAHelper.insert(errorUri, common.getProfileGroup()); + console.info("logMessage abnormal_group_insert_test_600: groupId = " + groupId); + expect(groupId == -1).assertTrue(); + done(); + } catch (error) { + console.info("logMessage abnormal_group_insert_test_600: group insert error = " + error); + done(); + } + }); + + /** + * @tc.number abnormal_group_update_test_700 + * @tc.name abnormal update + * @tc.desc Function test + */ + it("abnormal_group_update_test_700", 0, async function (done) { + console.info("---------logMessage abnormal_group_update_test_700 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var groupId = await DAHelper.insert(groupUri, common.getProfileGroup()); + console.info("logMessage abnormal_group_update_test_700: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + await groupUpdate(); + await deleteAll(groupUri, "abnormal_group_update_test_700"); + done(); + } catch (error) { + console.info("logMessage abnormal_group_update_test_700: group insert error = " + error); + done(); + } + + async function groupUpdate() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", groupId.toString()); + var updateValue = { + "group_notesss": "6666" + } + try { + var updateCode = await DAHelper.update(groupUri, updateValue, condition); + console.info("logMessage abnormal_group_update_test_700: updateCode = " + updateCode); + expect(updateCode == -1).assertTrue(); + var map = common.getProfileUpdateGroupMap(); + map.set("id", groupId.toStirng()); + await groupsQuery(map, "abnormal_group_update_test_700"); + } catch (error) { + console.info("logMessage abnormal_group_update_test_700: update error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_group_delete_test_800 + * @tc.name abnormal delete + * @tc.desc Function test + */ + it("abnormal_group_delete_test_800", 0, async function (done) { + console.info("---------logMessage abnormal_group_delete_test_800 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var groupId = await DAHelper.insert(groupUri, common.getProfileGroup()); + console.info("logMessage abnormal_group_delete_test_800: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + await groupDelete(); + await deleteAll(groupUri, "abnormal_group_delete_test_800"); + done(); + } catch (error) { + console.info("logMessage abnormal_group_delete_test_800: group insert error = " + error); + done(); + } + async function groupDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("idss", groupId.toString()); + try { + var deleteCode = await DAHelper.delete(groupUri, condition); + console.info("logMessage abnormal_group_delete_test_800 : deleteCode = " + deleteCode); + expect(deleteCode == -1).assertTrue(); + var map = common.getProfileUpdateGroupMap(); + map.set("id", groupId.toStirng()); + await groupsQuery(map, "abnormal_group_delete_test_800"); + } catch (error) { + console.info("logMessage abnormal_group_delete_test_800 : delete error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_group_query_test_900 + * @tc.name abnormal query + * @tc.desc Function test + */ + it("abnormal_group_query_test_900", 0, async function (done) { + console.info("------------logMessage abnormal_group_insert_test_900 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "group_name": "PersonnelDepartment" + }; + try { + var groupId = await DAHelper.insert(groupUri, insertValues); + console.info("logMessage abnormal_group_insert_test_900: groupId = " + groupId); + expect(groupId > 0).assertTrue(); + await groupQuery(DAHelper); + await deleteAll(groupUri, "abnormal_group_insert_test_900"); + done(); + } catch (error) { + console.info("logMessage abnormal_group_insert_test_900: group insert error = " + error); + done(); + } + + async function groupQuery(DAHelper) { + var resultColumns = ["id", "group_namesss"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", groupId.toString()); + try { + var resultSet = await DAHelper.query(groupUri, resultColumns, condition); + console.info('abnormal_group_insert_test_900 resultSet.goToFirstRow() = ' + resultSet.goToFirstRow()); + expect(resultSet.goToFirstRow() == false).assertTrue(); + resultSet.close(); + } catch (error) { + console.info('abnormal_group_insert_test_900 query error ' + error); + done(); + } + } + }); + + /** + * @tc.number group_insert_test_1000 + * @tc.name Adding multiple groups + * @tc.desc Function test + */ + it("group_insert_test_1000", 0, async function (done) { + console.info("------------logMessage group_insert_test_1000 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValuesOne = { + "group_name": "test1000" + }; + var insertValuesTwo = { + "group_name": "test1000" + }; + var insertValuesThree = { + "group_name": "test1000" + }; + var array = [] + array[0] = insertValuesOne; + array[1] = insertValuesTwo; + array[2] = insertValuesThree; + try { + var code = await DAHelper.batchInsert(groupUri, array); + console.info("logMessage group_insert_test_1000: batchInsert code = " + code); + expect(code == 0).assertTrue(); + await groupQuery(DAHelper); + await deleteAll(groupUri, "group_insert_test_1000"); + done(); + } catch (error) { + console.info("logMessage group_insert_test_1000: group insert error = " + error); + done(); + } + + async function groupQuery(DAHelper) { + var groupSize = 3; + var resultColumns = ["id", "group_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("group_name", "test1000"); + try { + var resultSet = await DAHelper.query(groupUri, resultColumns, condition); + console.info('group_insert_test_1000 resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == groupSize).assertTrue(); + resultSet.close(); + } catch (error) { + console.info('group_insert_test_1000 query error ' + error); + done(); + } + } + }); + + /** + * @tc.number group_delete_test_1100 + * @tc.name delete multiple groups + * @tc.desc Function test + */ + it("group_delete_test_1100", 0, async function (done) { + console.info("------------logMessage group_delete_test_1100 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValuesOne = { + "group_name": "test1100" + }; + var insertValuesTwo = { + "group_name": "test1100" + }; + var insertValuesThree = { + "group_name": "test1100" + }; + var array = [] + array[0] = insertValuesOne; + array[1] = insertValuesTwo; + array[2] = insertValuesThree; + try { + var code = await DAHelper.batchInsert(groupUri, array); + console.info("logMessage group_delete_test_1100: batchInsert code = " + code); + expect(code == 0).assertTrue(); + await deleteAll(groupUri, "group_delete_test_1100"); + await groupQuery(DAHelper); + done(); + } catch (error) { + console.info("logMessage group_delete_test_1100: group insert error = " + error); + done(); + } + + async function groupQuery(DAHelper) { + var groupSize = 0; + var resultColumns = ["id", "group_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("group_name", "test1100"); + try { + var resultSet = await DAHelper.query(groupUri, resultColumns, condition); + console.info('group_delete_test_1100 resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == groupSize).assertTrue(); + resultSet.close(); + } catch (error) { + console.info('group_delete_test_1100 query error ' + error); + done(); + } + } + }); + + /** + * @tc.number group_update_test_1200 + * @tc.name update multiple groups + * @tc.desc Function test + */ + it("group_update_test_1200", 0, async function (done) { + console.info("------------logMessage group_update_test_1200 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValuesOne = { + "group_name": "test1200" + }; + var insertValuesTwo = { + "group_name": "test1200" + }; + var insertValuesThree = { + "group_name": "test1200" + }; + var array = [] + array[0] = insertValuesOne; + array[1] = insertValuesTwo; + array[2] = insertValuesThree; + try { + var code = await DAHelper.batchInsert(groupUri, array); + console.info("logMessage group_update_test_1200: batchInsert code = " + code); + expect(code == 0).assertTrue(); + await groupUpdateThree(DAHelper); + await groupQuery(DAHelper); + await deleteAll(groupUri, "group_update_test_1200"); + done(); + } catch (error) { + console.info("logMessage group_update_test_1200: group insert error = " + error); + done(); + } + + async function groupQuery(DAHelper) { + var groupSize = 3; + var resultColumns = ["id", "group_name"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("group_name", "test120000"); + try { + var resultSet = await DAHelper.query(groupUri, resultColumns, condition); + console.info("logMessage group_update_test_1200: resultSet.rowCount = " + resultSet.rowCount); + expect(resultSet.rowCount == groupSize).assertTrue(); + resultSet.close(); + } catch (error) { + console.info('group_update_test_1200 query error ' + error); + done(); + } + } + }); + + async function groupUpdateThree(DAHelper) { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("group_name", "test1200"); + var updateValue = { + "group_name": "test120000" + } + try { + var updateCode = await DAHelper.update(groupUri, updateValue, condition); + console.info("logMessage group_update_test_1200: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage group_update_test_1200: update error = " + error); + } + } + + afterAll(async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.notEqualTo("id", "0"); + try { + var deleteCode = await DAHelper.delete(groupUri, condition); + console.info("logMessage group_deleted : deleteCode = " + deleteCode); + done(); + } catch (error) { + console.info("logMessage group_deleted: group insert error = " + error); + done(); + } + }); + }) +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/ObjectInterface_test.js b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/ObjectInterface_test.js new file mode 100644 index 0000000000000000000000000000000000000000..955a223298107f5acc67ac50208a7d5fc0726840 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/ObjectInterface_test.js @@ -0,0 +1,915 @@ +/* + * Copyright (c) 2021 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 contactsapi from "@ohos.contactsapi"; +import utils from '../Utils.ets' +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'deccjsunit/index' +import common from './common.js'; + +const URI_CONTACTS = "dataability:///com.ohos.contactsdataability"; +const groupUri = "dataability:///com.ohos.contactsdataability/contacts/groups"; +const rawContactUri = "dataability:///com.ohos.contactsdataability/contacts/raw_contact"; +const profileRawContactUri = "dataability:///com.ohos.contactsdataability/profile/raw_contact"; + +export default function ObjectInterfaceTest() { + describe('ObjectInterfaceTest', function () { + function sleep(numberMillis) { + var now = new Date(); + var exitTime = now.getTime() + numberMillis; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) + return; + } + } + + var contactData = { + id: 0, + key: "0", + contactAttributes: { + attributes: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] + }, + emails: [{ + email: "email", labelName: "自定义邮箱", labelId: 1, displayName: "emailDisplayName" + }], + events: [{ + eventDate: "event", labelName: "自定义event", labelId: 2 + }], + groups: [{ + groupId: 1, title: "群组" + }], + imAddresses: [{ + imAddress: "imAddress", labelName: "自定义", labelId: 3 + }], + phoneNumbers: [{ + phoneNumber: "183", 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 gRawContactId; + var gGroup; + + /** + * @tc.number contactsApi_insert_test_100 + * @tc.name Insert contact information + * @tc.desc Function test + */ + it("contactsApi_insert_test_100", 0, async function (done) { + try { + var rawContactId = await contactsapi.addContact(contactData); + console.info("contactsApi_insert_test_100 : rawContactId = " + rawContactId); + gRawContactId = rawContactId; + expect(gRawContactId > 0).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_insert_test_100 : raw_contact insert error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_delete_test_200 + * @tc.name Delete contact information + * @tc.desc Function test + */ + it("contactsApi_delete_test_200", 0, async function (done) { + var deleteId = gRawContactId; + try { + var deleteCode = await contactsapi.deleteContact(deleteId); + var gDelete = deleteCode; + console.info("contactsApi_delete_test_200 : deleteCode = " + deleteCode); + expect(gDelete == 0).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_delete_test_200 : delete error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_update_test_300 + * @tc.name Update contact information + * @tc.desc Function test + */ + it("contactsApi_update_test_300", 0, async function (done) { + if(utils.notCheck){ + expect(true).assertTrue(); + done(); + return; + } + var rawContactId = await contactsapi.addContact(contactData); + console.info("contactsApi_insert_test_300 : rawContactId = " + rawContactId); + gRawContactId = rawContactId; + expect(rawContactId > 0).assertTrue(); + + var updateValues = { + id: gRawContactId, name: { + fullName: "小红" + } + }; + var condition = { + attributes: [6] + } + try { + var updateCode = await contactsapi.updateContact(updateValues, condition); + console.info("contactsApi_update_test_300 : updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_update_test_300 : update error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_contact_test_400 + * @tc.name Query contacts information + * @tc.desc Function test + */ + it("contactsApi_query_contact_test_400", 0, async function (done) { + var queryId = gRawContactId; + try { + var resultSet = await contactsapi.queryContact(queryId); + console.info("contactsApi_query_contact_test_400 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_contact_test_400 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_contact_test_500 + * @tc.name Query contacts information + * @tc.desc Function test + */ + it("contactsApi_query_contact_test_500", 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + var queryId = gRawContactId.toString(); + var holder = { + bundleName: "com.ohos.contacts", displayName: "phone", holderId: 1 + } + try { + var resultSet = await contactsapi.queryContact(queryId, holder); + console.info("contactsApi_query_contact_test_500 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_contact_test_500 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_contact_test_600 + * @tc.name Query contacts information + * @tc.desc Function test + */ + it("contactsApi_query_contact_test_600", 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + var queryId = gRawContactId.toString(); + var holder = { + bundleName: "com.ohos.contacts", displayName: "phone", holderId: 1 + }; + var ContactAttributes = { + attributes: [1, 5, 6] + } + try { + var resultSet = await contactsapi.queryContact(queryId, holder, ContactAttributes); + console.info("contactsApi_query_contact_test_600 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_contact_test_600 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_contacts_test_700 + * @tc.name Query contacts information + * @tc.desc Function test + */ + it("contactsApi_query_contacts_test_700", 0, async function (done) { + try { + var resultSet = await contactsapi.queryContacts(); + console.info("contactsApi_query_contacts_test_700 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_contacts_test_700 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_contacts_test_800 + * @tc.name Query contacts information + * @tc.desc Function test + */ + it("contactsApi_query_contacts_test_800", 0, async function (done) { + var holder = { + bundleName: "com.ohos.contacts", displayName: "phone", holderId: 1 + } + try { + var resultSet = await contactsapi.queryContacts(holder); + console.info("contactsApi_query_contacts_test_800 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_contacts_test_800 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_contacts_test_900 + * @tc.name Query contacts information + * @tc.desc Function test + */ + it("contactsApi_query_contacts_test_900", 0, async function (done) { + var ContactAttributes = { + attributes: [1, 5, 6] + } + try { + var resultSet = await contactsapi.queryContacts(ContactAttributes); + console.info("contactsApi_query_contacts_test_900 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_contacts_test_900 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_contacts_test_1000 + * @tc.name Query contacts information + * @tc.desc Function test + */ + it("contactsApi_query_contacts_test_1000", 0, async function (done) { + var holder = { + bundleName: "com.ohos.contacts", displayName: "phone", holderId: 1 + }; + var ContactAttributes = { + attributes: [1, 5, 6] + } + try { + var resultSet = await contactsapi.queryContacts(holder, ContactAttributes); + console.info("contactsApi_query_contacts_test_1000 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_contacts_test_1000 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_email_test_1100 + * @tc.name Query email information + * @tc.desc Function test + */ + it("contactsApi_query_email_test_1100", 0, async function (done) { + var email = "email"; + var holder = { + bundleName: "com.ohos.contacts", displayName: "phone", holderId: 1 + } + try { + var resultSet = await contactsapi.queryContactsByEmail(email, holder); + console.info("contactsApi_query_email_test_1100 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_email_test_1100 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_email_test_1200 + * @tc.name Query email information + * @tc.desc Function test + */ + it("contactsApi_query_email_test_1200", 0, async function (done) { + var email = "email"; + try { + var resultSet = await contactsapi.queryContactsByEmail(email); + console.info("contactsApi_query_email_test_1200 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_email_test_1200 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_email_test_1300 + * @tc.name Query email information + * @tc.desc Function test + */ + it("contactsApi_query_email_test_1300", 0, async function (done) { + var email = "email"; + var holder = { + bundleName: "com.ohos.contacts", displayName: "phone", holderId: 1 + }; + var ContactAttributes = { + attributes: [1, 5, 6] + } + try { + var resultSet = await contactsapi.queryContactsByEmail(email, holder, ContactAttributes); + console.info("contactsApi_query_email_test_1300 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_email_test_1300 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_email_test_1400 + * @tc.name Query email information + * @tc.desc Function test + */ + it("contactsApi_query_email_test_1400", 0, async function (done) { + var email = "email"; + var ContactAttributes = { + attributes: [1, 5, 6] + } + try { + var resultSet = await contactsapi.queryContactsByEmail(email, ContactAttributes); + console.info("contactsApi_query_email_test_1400 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_email_test_1400 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_phoneNumber_test_1500 + * @tc.name Query phoneNumber information + * @tc.desc Function test + */ + it("contactsApi_query_phoneNumber_test_1500", 0, async function (done) { + var phoneNumber = "183"; + var holder = { + bundleName: "com.ohos.contacts", displayName: "phone", holderId: 1 + } + try { + var resultSet = await contactsapi.queryContactsByPhoneNumber(phoneNumber, holder); + console.info("contactsApi_query_phoneNumber_test_1500 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_phoneNumber_test_1500 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_phoneNumber_test_1600 + * @tc.name Query phoneNumber information + * @tc.desc Function test + */ + it("contactsApi_query_phoneNumber_test_1600", 0, async function (done) { + var phoneNumber = "183"; + var holder = { + bundleName: "com.ohos.contacts", displayName: "phone", holderId: 1 + }; + var ContactAttributes = { + attributes: [1, 5, 6] + } + try { + var resultSet = await contactsapi.queryContactsByPhoneNumber(phoneNumber, holder, ContactAttributes); + console.info("contactsApi_query_phoneNumber_test_1600 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_phoneNumber_test_1600 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_phoneNumber_test_1700 + * @tc.name Query phoneNumber information + * @tc.desc Function test + */ + it("contactsApi_query_phoneNumber_test_1700", 0, async function (done) { + var phoneNumber = "183"; + try { + var resultSet = await contactsapi.queryContactsByPhoneNumber(phoneNumber); + console.info("contactsApi_query_phoneNumber_test_1700 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_phoneNumber_test_1700 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_phoneNumber_test_1800 + * @tc.name Query phoneNumber information + * @tc.desc Function test + */ + it("contactsApi_query_phoneNumber_test_1800", 0, async function (done) { + var phoneNumber = "183"; + var ContactAttributes = { + attributes: [1, 5, 6] + } + try { + var resultSet = await contactsapi.queryContactsByPhoneNumber(phoneNumber, ContactAttributes); + console.info("contactsApi_query_phoneNumber_test_1800 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_phoneNumber_test_1800 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_group_test_1900 + * @tc.name Query group + * @tc.desc Function test + */ + it("contactsApi_query_group_test_1900", 0, async function (done) { + try { + var resultSet = await contactsapi.queryGroups(); + console.info("contactsApi_query_group_test_1900 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet.length == 0).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_group_test_1900 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_group_test_2000 + * @tc.name Query group + * @tc.desc Function test + */ + it("contactsApi_query_group_test_2000", 0, async function (done) { + var holder = { + bundleName: "com.ohos.contacts", displayName: "phone", holderId: 1 + } + try { + var resultSet = await contactsapi.queryGroups(holder); + console.info("contactsApi_query_group_test_2000 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet.length == 0).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_group_test_2000 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_holders_test_2200 + * @tc.name Query holders information + * @tc.desc Function test + */ + it("contactsApi_query_holders_test_2200", 0, async function (done) { + try { + var resultSet = await contactsapi.queryHolders(); + console.info("contactsApi_query_holders_test_2200 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet != null).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_holders_test_2200 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_key_test_2300 + * @tc.name Query key information + * @tc.desc Function test + */ + it("contactsApi_query_key_test_2300", 0, async function (done) { + var idtest = gRawContactId; + var holder = { + bundleName: "com.ohos.contacts", displayName: "phone", holderId: 1 + } + try { + var resultSet = await contactsapi.queryKey(idtest, holder); + console.info("contactsApi_query_key_test_2300 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet.length != 0).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_key_test_2300 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_key_test_2400 + * @tc.name Query key information + * @tc.desc Function test + */ + it("contactsApi_query_key_test_2400", 0, async function (done) { + var idtest = gRawContactId; + console.info("contactsApi_query_key_test_2400 : query gRawContactId = " + idtest); + try { + var resultSet = await contactsapi.queryKey(idtest); + console.info("contactsApi_query_key_test_2400 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet.length != 0).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_key_test_2400 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_query_mycard_test_2500 + * @tc.name Query mycard information + * @tc.desc Function test + */ + it("contactsApi_query_mycard_test_2500", 0, async function (done) { + var holder = { + bundleName: "com.ohos.contacts", displayName: "phone", holderId: 1 + } + try { + var resultSet = await contactsapi.queryMyCard(holder); + console.info("contactsApi_query_mycard_test_2500 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet.length == 0).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_mycard_test_2500 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_isMyCard_test_2600 + * @tc.name Query mycard exist + * @tc.desc Function test + */ + it("contactsApi_isMyCard_test_2600", 0, async function (done) { + var id = 1; + try { + var isExist = await contactsapi.isMyCard(id); + console.info("contactsApi_isMyCard_test_2600 : query isExist = " + isExist); + expect(isExist == 0).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_isMyCard_test_2600 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number contactsApi_isLocalContact_test_2700 + * @tc.name Query isLocalContact exist + * @tc.desc Function test + */ + it("contactsApi_isLocalContact_test_2700", 0, async function (done) { + var id = gRawContactId; + try { + var isExist = await contactsapi.isLocalContact(id); + console.info("logMessage contactsApi_isLocalContact_test_2700 isExist = " + isExist); + expect(isExist == 1).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_isLocalContact_test_2700 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number abnormal_contactsApi_insert_test_2800 + * @tc.name contactsApi_insert error + * @tc.desc Function test + */ + it("abnormal_contactsApi_insert_test_2800", 0, async function (done) { + var contactDataError = {}; + try { + var rawContactId = await contactsapi.addContact(contactDataError); + console.info("abnormal_contactsApi_insert_test_2800 : rawContactId = " + rawContactId); + expect(rawContactId == -1).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_insert_test_100 : raw_contact insert error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number abnormal_contactsApi_update_test_3000 + * @tc.name contactsApi_update error + * @tc.desc Function test + */ + it("abnormal_contactsApi_update_test_3000", 0, async function (done) { + var rawContactId = -1; + var updateValues = { + id: rawContactId, name: { + fullName: "小红" + } + }; + var condition = { + attributes: [6] + } + try { + var updateCode = await contactsapi.updateContact(updateValues, condition); + console.info("abnormal_contactsApi_update_test_3000 : updateCode = " + updateCode); + expect(updateCode == -1).assertTrue(); + done(); + } catch (error) { + console.info("abnormal_contactsApi_update_test_3000 : update error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number abnormal_contactsApi_query_contact_test_3100 + * @tc.name contactsApi_query_contact error + * @tc.desc Function test + */ + it("abnormal_contactsApi_query_contact_test_3100", 0, async function (done) { + var queryId = "-1"; + try { + var resultSet = await contactsapi.queryContact(queryId); + if (resultSet == null) { + console.info("abnormal_contactsApi_query_contact_test_3100 is null"); + } + if (resultSet == undefined) { + console.info("abnormal_contactsApi_query_contact_test_3100 is undefined"); + } + console.info("abnormal_contactsApi_query_contact_test_3100 : updateCode = " + JSON.stringify(resultSet)); + expect(resultSet == undefined).assertTrue(); + done(); + } catch (error) { + console.info("abnormal_contactsApi_query_contact_test_3100 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number abnormal_contactsApi_query_contacts_test_3200 + * @tc.name contactsApi_query_contacts error + * @tc.desc Function test + */ + it("abnormal_contactsApi_query_contacts_test_3200", 0, async function (done) { + var ContactAttributes = { + attributes: [100] + } + try { + var resultSet = await contactsapi.queryContacts(ContactAttributes); + if (resultSet == null) { + console.info("abnormal_contactsApi_query_contacts_test_3200 is null"); + } + if (resultSet == undefined) { + console.info("abnormal_contactsApi_query_contacts_test_3200 is undefined"); + } + console.info( + "abnormal_contactsApi_query_contacts_test_3200 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet.length == 0).assertTrue(); + done(); + } catch (error) { + console.info("abnormal_contactsApi_query_contacts_test_3200 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number abnormal_contactsApi_query_email_test_3300 + * @tc.name contactsApi_query_email error + * @tc.desc Function test + */ + it("abnormal_contactsApi_query_email_test_3300", 0, async function (done) { + var email = "email2222"; + try { + var resultSet = await contactsapi.queryContactsByEmail(email); + console.info("abnormal_contactsApi_query_email_test_3300 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet.length == 0).assertTrue(); + done(); + } catch (error) { + console.info("abnormal_contactsApi_query_email_test_3300 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number abnormal_contactsApi_query_phoneNumber_test_3400 + * @tc.name contactsApi_query_phoneNumber error + * @tc.desc Function test + */ + it("abnormal_contactsApi_query_phoneNumber_test_3400", 0, async function (done) { + var phoneNumber = "19999999"; + try { + var resultSet = await contactsapi.queryContactsByPhoneNumber(phoneNumber); + console.info( + "abnormal_contactsApi_query_phoneNumber_test_3400 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet.length == 0).assertTrue(); + done(); + } catch (error) { + console.info("abnormal_contactsApi_query_phoneNumber_test_3400 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number abnormal_contactsApi_query_group_test_3500 + * @tc.name contactsApi_query_group error + * @tc.desc Function test + */ + it("abnormal_contactsApi_query_group_test_3500", 0, async function (done) { + var holder = { + bundleName: "com.ohos.contacts2", displayName: "phone2", holderId: 2 + } + try { + var resultSet = await contactsapi.queryGroups(holder); + console.info("abnormal_contactsApi_query_group_test_3500 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet.length == 0).assertTrue(); + done(); + } catch (error) { + console.info("contactsApi_query_group_test_2000 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number abnormal_contactsApi_query_key_test_3600 + * @tc.name contactsApi_query_key error + * @tc.desc Function test + */ + it("abnormal_contactsApi_query_key_test_3600", 0, async function (done) { + var idtest = -1; + try { + var resultSet = await contactsapi.queryKey(idtest); + console.info("abnormal_contactsApi_query_key_test_3600 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet.length == 0).assertTrue(); + done(); + } catch (error) { + console.info("abnormal_contactsApi_query_key_test_3600 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number abnormal_contactsApi_query_mycard_test_3700 + * @tc.name contactsApi_query_mycard error + * @tc.desc Function test + */ + it("abnormal_contactsApi_query_mycard_test_3700", 0, async function (done) { + var ContactAttributes = { + attributes: [100] + }; + try { + var resultSet = await contactsapi.queryMyCard(ContactAttributes); + console.info( + "abnormal_contactsApi_query_mycard_test_3700 : query resultSet = " + JSON.stringify(resultSet)); + expect(resultSet.length == 0).assertTrue(); + done(); + } catch (error) { + console.info("abnormal_contactsApi_query_mycard_test_3700 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number abnormal_contactsApi_isMyCard_test_3800 + * @tc.name isMyCard is not exist + * @tc.desc Function test + */ + it("abnormal_contactsApi_isMyCard_test_3800", 0, async function (done) { + var id = 999; + try { + var isExist = await contactsapi.isMyCard(id); + console.info("abnormal_contactsApi_isMyCard_test_3800 : query isExist = " + isExist); + expect(isExist == 0).assertTrue(); + done(); + } catch (error) { + console.info("abnormal_contactsApi_isMyCard_test_3800 query error = " + error); + done(); + } + sleep(2000) + }); + + /** + * @tc.number abnormal_contactsApi_isLocalContact_test_3900 + * @tc.name contactsApi_isLocalContact is not exist + * @tc.desc Function test + */ + it("abnormal_contactsApi_isLocalContact_test_3900", 0, async function (done) { + var id = 999; + try { + var isExist = await contactsapi.isLocalContact(id); + console.info("abnormal_contactsApi_isLocalContact_test_3900 : query isExist = " + isExist); + expect(isExist == 0).assertTrue(); + done(); + } catch (error) { + console.info("abnormal_contactsApi_isLocalContact_test_3900 query error = " + error); + done(); + } + sleep(2000) + }); + }); +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/Voicemail_test.js b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/Voicemail_test.js new file mode 100644 index 0000000000000000000000000000000000000000..d311fbdc5d7458ecace4d461bc22381e275aa1a2 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/Voicemail_test.js @@ -0,0 +1,1329 @@ +/* + * Copyright (c) 2021 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 featureAbility from '@ohos.ability.featureAbility'; +import ohosDataAbility from '@ohos.data.dataability'; +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'deccjsunit/index' +import common from './common.js'; + +const URI_VOICEMAIL = "dataability:///com.ohos.voicemailability"; +const voicemailUri = "dataability:///com.ohos.voicemailability/calls/voicemail"; + +export default function VoicemailTest() { + describe('VoicemailTest', function () { + console.log("----------VoicemailTest is starting!----------"); + + async function voiceMailQuery(map, tag) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info(tag + ':calllogInsertQuery start ! DAHelper = ' + DAHelper); + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", map.get("id")); + try { + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition); + if (resultSet.rowCount > 0 && resultSet.goToFirstRow()) { + do { + for (var [key, value] of map) { + var dbresult = resultSet.getString(resultSet.getColumnIndex(key)); + console.info(tag + ' :logMessage voiceMailQuery key = ' + key + ' dbresult :' + dbresult + + ' value : ' + value); + expect(value == dbresult).assertTrue(); + } + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info(tag + ":logMessage voiceMailQuery: error = " + error); + } + } + + async function voiceMailQueryForDelete(map, tag) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info(tag + ': voiceMailQueryForDelete start ! DAHelper = ' + DAHelper); + var resultColumns = common.getCallLogResultColumns(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", map.get("id")); + try { + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition); + expect(resultSet.goToFirstRow() == false).assertTrue(); + console.info(tag + " :logMessage voiceMailQueryForDelete: goToFirstRow " + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info(tag + " :logMessage voiceMailQueryForDelete: error = " + error); + } + } + + async function voiceMailQueryError(map, tag) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info(tag + ': voiceMailQueryError start ! DAHelper = ' + DAHelper); + var resultColumns = common.getCallLogResultColumns(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("phone_number", map.get("phone_number")); + try { + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition); + expect(resultSet.goToFirstRow() == false).assertTrue(); + console.info(tag + " :logMessage voiceMailQueryError: goToFirstRow " + resultSet.goToFirstRow()); + resultSet.close(); + } catch (error) { + console.info(tag + " :logMessage voiceMailQueryError: error = " + error); + } + } + + async function voiceMailQueryForBatchInsert(array, tag) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info(tag + ': voiceMailQueryForBatchInsert start ! DAHelper = ' + DAHelper); + var resultColumns = common.getCallLogResultColumns(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("phone_number", array[0].get("phone_number")); + try { + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition); + var size = array.size(); + console.info(tag + ' : logMessage voiceMailQueryForBatchInsert: size' + size); + expect(resultSet.rowCount == size).assertEqual(true); + var i = 0; + if (resultSet.rowCount > 0 && resultSet.goToFirstRow()) { + do { + for (var [key, value] of array[i]) { + var dbresult = resultSet.getString(resultSet.getColumnIndex(key)); + console.info(tag + ' : logMessage voiceMailQueryForBatchInsert dbresult :' + dbresult + + ' value : ' + value); + console.info( + tag + ' : logMessage voiceMailQueryForBatchInsert value ' + (value == dbresult)); + expect(value == dbresult).assertTrue(); + } + i++; + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info(tag + " :logMessage calllogQueryByInsert: error = " + error); + } + } + + async function voiceMailDelete(tag) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + var deleteCode = await DAHelper.delete(voicemailUri, condition); + console.info(tag + ': voiceMailDelete deleteCode = ' + deleteCode); + expect(deleteCode == 0).assertTrue(); + } + + /** + * @tc.number voicemail_insert_test_100 + * @tc.name Insert voicemail data + * @tc.desc Function test + */ + it("voicemail_insert_test_100", 0, async function (done) { + console.info("---------logMessage voicemail_insert_test_100 is starting!---------") + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + console.info('logMessage uri = ' + URI_VOICEMAIL) + try { + var voicemailId = await DAHelper.insert(voicemailUri, common.getVoiceMail()); + console.info("logMessage voicemail_insert_test_100: voicemailId = " + voicemailId); + expect(voicemailId > 0).assertTrue(); + var map = common.getVoiceMailMap(); + map.set("id", voicemailId.toString()); + await voiceMailQuery(map, "voicemail_insert_test_100"); + await voiceMailDelete("voicemail_insert_test_100"); + done(); + } catch (error) { + console.info("logMessage voicemail_insert_test_100: voicemail insert error = " + error); + done(); + } + }); + + /** + * @tc.number voicemail_insert_test_200 + * @tc.name Insert voicemail status + * @tc.desc Function test + */ + it("voicemail_insert_test_200", 0, async function (done) { + console.info("---------logMessage voicemail_insert_test_200 is starting!---------") + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + console.info('logMessage uri = ' + URI_VOICEMAIL) + + var stringValue = { + "phone_number": "1557254", "voice_status": 1 + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, stringValue) + console.info("logMessage voicemail_insert_test_200: voicemailId = " + voicemailId); + expect(voicemailId > 0).assertTrue(); + var map = new Map(); + map.set("id", voicemailId.toString()); + map.set("phone_number", "1557254"); + map.set("voice_status", "1"); + await voiceMailQuery(map, "voicemail_insert_test_200"); + await voiceMailDelete("voicemail_insert_test_200"); + done(); + } catch (error) { + console.info("logMessage voicemail_insert_test_200: voicemail insert error = " + error); + done(); + } + }); + + /** + * @tc.number voicemail_insert_test_100000 + * @tc.name Insert voicemail status + * @tc.desc Function test + */ + it("voicemail_insert_test_100000", 0, async function (done) { + console.info("---------logMessage voicemail_insert_test_100000 is starting!---------") + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + console.info('logMessage uri = ' + URI_VOICEMAIL) + + var stringValue = { + "phone_number": "1557254", "voice_status": 0 + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, stringValue) + console.info("logMessage voicemail_insert_test_100000: voicemailId = " + voicemailId); + expect(voicemailId > 0).assertTrue(); + var map = new Map(); + map.set("id", voicemailId.toString()); + map.set("phone_number", "1557254"); + map.set("voice_status", "0"); + await voiceMailQuery(map, "voicemail_insert_test_100000"); + await voiceMailDelete("voicemail_insert_test_100000"); + done(); + } catch (error) { + console.info("logMessage voicemail_insert_test_100000: voicemail insert error = " + error); + done(); + } + }); + + /** + * @tc.number voicemail_update_test_1000 + * @tc.name Update voicemail data + * @tc.desc Function test + */ + it("voicemail_update_test_1000", 0, async function (done) { + console.info("------------logMessage voicemail_update_test_1000 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + try { + var voicemailId = await DAHelper.insert(voicemailUri, common.getVoiceMail()); + console.info("logMessage voicemail_update_test_1000: voicemailId = " + voicemailId); + expect(voicemailId > 0).assertTrue(); + await voicemailUpdate(); + await voiceMailDelete("voicemail_update_test_1000"); + done(); + } catch (error) { + console.info("logMessage voicemail_update_test_1000: voicemail insert error = " + error); + done(); + } + + async function voicemailUpdate() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", voicemailId.toString()); + try { + var updateCode = await DAHelper.update(voicemailUri, common.getVoiceMailUpdate(), condition); + console.info("logMessage voicemail_update_test_1000: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + var map = common.getVoiceMailUpdateMap(); + map.set("id", voicemailId.toString()); + await voiceMailQuery(map, "voicemail_update_test_1000"); + } catch (error) { + console.info("logMessage voicemail_update_test_1000: update error = " + error); + done(); + } + } + }); + + /** + * @tc.number voicemail_update_test_900 + * @tc.name Update voicemail status + * @tc.desc Function test + */ + it("voicemail_update_test_900", 0, async function (done) { + console.info("------------logMessage voicemail_update_test_900 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "18862013", "voice_status": 0 + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, insertValues); + console.info("logMessage voicemail_update_test_900: voicemailId = " + voicemailId); + expect(voicemailId > 0).assertTrue(); + await voicemailUpdate(); + await voiceMailDelete("voicemail_update_test_900"); + done(); + } catch (error) { + console.info("logMessage voicemail_update_test_900: voicemail insert error = " + error); + done(); + } + + async function voicemailUpdate() { + var updateValues = { + "voice_status": 1 + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", voicemailId.toString()); + try { + var updateCode = await DAHelper.update(voicemailUri, updateValues, condition); + console.info("logMessage voicemail_update_test_900: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", voicemailId.toString()); + map.set("voice_status", "1"); + await voiceMailQuery(map, "voicemail_update_test_900"); + } catch (error) { + console.info("logMessage voicemail_update_test_900: update error = " + error); + done(); + } + } + }); + + /** + * @tc.number voicemail_delete_test_500 + * @tc.name Delete voicemail data + * @tc.desc Function test + */ + it("voicemail_delete_test_500", 0, async function (done) { + console.info("-------------logMessage voicemail_delete_test_500 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "100578615", "display_name": "zhangming" + }; + try { + var voiceMailId = await DAHelper.insert(voicemailUri, insertValues); + console.info("logMessage voicemail_delete_test_500: voiceMailId = " + voiceMailId); + expect(voiceMailId > 0).assertTrue(); + await VoicemailDelete(); + await voiceMailDelete("voicemail_delete_test_500"); + done(); + } catch (error) { + console.info("logMessage voicemail_delete_test_500: voicemail insert error = " + error); + done(); + } + + async function VoicemailDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", voicemailId.toString()); + try { + var deleteCode = await DAHelper.delete(voicemailUri, condition); + console.info('logMessage voicemail_delete_test_500: deleteCode = ' + deleteCode); + expect(deleteCode == 0).assertTrue(); + var map = new Map(); + map.set("id", voicemailId.toString()); + await voiceMailQueryForDelete(map, "voicemail_delete_test_500"); + } catch (error) { + console.info("logMessage voicemail_delete_test_500: delete error = " + error); + done(); + } + } + }); + + /** + * @tc.number voicemail_update_test_600 + * @tc.name Delete voicemail status + * @tc.desc Function test + */ + it("voicemail_update_test_600", 0, async function (done) { + console.info("-------------logMessage voicemail_update_test_600 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues1 = { + "phone_number": "100578615", "voice_status": 1 + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, insertValues1); + console.info("logMessage voicemail_update_test_600: voicemailId = " + voicemailId); + expect(voicemailId > 0).assertTrue(); + await voicemailUpdate(); + await voiceMailDelete("voicemail_update_test_600"); + done(); + } catch (error) { + console.info("logMessage voicemail_update_test_600: voicemail insert error = " + error); + done(); + } + + async function voicemailUpdate() { + var updateValues = { + "voice_status": 0 + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", voicemailId.toString()); + try { + var updateCode = await DAHelper.update(voicemailUri, updateValues, condition); + console.info('logMessage voicemail_update_test_600: deleteCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + var map = new Map(); + map.set("id", voicemailId.toString()); + map.set("voice_status", "0"); + await voiceMailQuery(map, "voicemail_update_test_600"); + } catch (error) { + console.info("logMessage voicemail_update_test_600: update error = " + error); + done(); + } + } + }); + + /** + * @tc.number voicemail_batchInsert_test_1800 + * @tc.name Insert voicemail data in batches + * @tc.desc Function test + */ + it("voicemail_batchInsert_test_1800", 0, async function (done) { + console.info("-------------logMessage voicemail_batchInsert_test_1800 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValuesOne = { + "phone_number": "10086", "display_name": "xiaoming" + }; + var insertValuesTwo = { + "phone_number": "12580", "display_name": "xiaohei" + }; + var insertValuesThree = { + "phone_number": "123456", "display_name": "xiaohong" + }; + var insertValuesFour = { + "phone_number": "9996325", "display_name": "xiaohei" + }; + var insertValuesFive = { + "phone_number": "18862013", "display_name": "xiaofen" + }; + var listAddBluk = []; + listAddBluk[0] = insertValuesOne; + listAddBluk[1] = insertValuesTwo; + listAddBluk[2] = insertValuesThree; + listAddBluk[3] = insertValuesFour; + listAddBluk[4] = insertValuesFive; + try { + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + console.info("logMessage voicemail_batchInsert_test_1800: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + await voiceMailDelete("voicemail_batchInsert_test_1800"); + done(); + } catch (error) { + console.info("logMessage voicemail_batchInsert_test_1800: batchInsert error = " + error); + done(); + } + }); + + /** + * @tc.number voicemail_batchInsert_test_1700 + * @tc.name Insert voicemail status in batches + * @tc.desc Function test + */ + it("voicemail_batchInsert_test_1700", 0, async function (done) { + console.info("-------------logMessage voicemail_batchInsert_test_1700 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValuesOne = { + "phone_number": "1600", "display_name": "xiaoming", "voice_status": 0 + }; + var insertValuesTwo = { + "phone_number": "1600", "display_name": "xiaohei", "voice_status": 1 + }; + var insertValuesThree = { + "phone_number": "1600", "display_name": "xiaohong", "voice_status": 0 + }; + var insertValuesFour = { + "phone_number": "1600", "display_name": "xiaohei", "voice_status": 0 + }; + var insertValuesFive = { + "phone_number": "1600", "display_name": "xiaofen", "voice_status": 1 + }; + var listAddBluk = []; + listAddBluk[0] = insertValuesOne; + listAddBluk[1] = insertValuesTwo; + listAddBluk[2] = insertValuesThree; + listAddBluk[3] = insertValuesFour; + listAddBluk[4] = insertValuesFive; + try { + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + console.info("logMessage voicemail_batchInsert_test_1700: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + var array = common.getvoiceMailBatchInsert(); + await voiceMailQueryForBatchInsert(array, "voicemail_batchInsert_test_1700"); + await voiceMailDelete("voicemail_batchInsert_test_1700"); + done(); + } catch (error) { + console.info("logMessage voicemail_batchInsert_test_1700: batchInsert error = " + error); + done(); + } + }); + + /** + * @tc.number voicemail_query_test_1400 + * @tc.name Query voicemail data + * @tc.desc Function test + */ + it("voicemail_query_test_1400", 0, async function (done) { + console.info("------------voicemail_query_test_1400 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "8855220011", "display_name": "daming" + }; + try { + var voiceMailId = await DAHelper.insert(voicemailUri, insertValues); + console.info("logMessage voicemail_query_test_1400: voiceMailId = " + voiceMailId); + expect(voiceMailId > 0).assertTrue(); + await voiceMailQuery(); + await voiceMailDelete("voicemail_query_test_1400"); + done(); + } catch (error) { + console.info("logMessage voicemail_query_test_1400: voicemial insert error = " + error); + done(); + } + async function voiceMailQuery() { + var resultColumns = ["id", "display_name", "phone_number"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", voicemailId.toString()); + try { + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('voicemail_query_test_1400 id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == voicemailId.toString()).assertTrue(); + console.info('voicemail_query_test_1400 displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "daming").assertTrue(); + console.info('voicemail_query_test_1400 phone_number = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "8855220011").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("voicemail_query_test_1400 query error = " + error); + done(); + } + } + }); + + /** + * @tc.number voicemail_query_test_1300 + * @tc.name Query voicemail's status + * @tc.desc Function test + */ + it("voicemail_query_test_1300", 0, async function (done) { + console.info("------------voicemail_query_test_1300 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertValues = { + "phone_number": "1158220165", "display_name": "xiaoming", "voice_status": 1 + }; + try { + var voiceMailId = await DAHelper.insert(voicemailUri, insertValues); + console.info("logMessage voicemail_query_test_1300: voiceMailId = " + voiceMailId); + expect(voiceMailId > 0).assertTrue(); + await voiceMailQuery(); + await voiceMailDelete("voicemail_query_test_1300"); + done(); + } catch (error) { + console.info("logMessage voicemail_query_test_1300: voicemial insert error = " + error); + done(); + } + async function voiceMailQuery() { + var resultColumns = ["id", "display_name", "phone_number"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("voice_status", "1"); + condition.and(); + condition.equalTo("phone_number", "1158220165"); + try { + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition); + if (resultSet.goToFirstRow()) { + do { + console.info('voicemail_query_test_1300 id = ' + resultSet.getString(0)); + expect(resultSet.getString(0) == voicemailId.toString()).assertTrue(); + console.info('voicemail_query_test_1300 displayName = ' + resultSet.getString(1)); + expect(resultSet.getString(1) == "xiaoming").assertTrue(); + console.info('voicemail_query_test_1300 phone_number = ' + resultSet.getString(2)); + expect(resultSet.getString(2) == "1158220165").assertTrue(); + } while (resultSet.goToNextRow()); + } + resultSet.close(); + } catch (error) { + console.info("voicemail_query_test_1300 query error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_voicemail_insert_test_300 + * @tc.name Abnormal use case, an incorrect field is passed in when inserting data + * @tc.desc Function test + */ + it("abnormal_voicemail_insert_test_300", 0, async function (done) { + console.info("------------abnormal_voicemail_insert_test_300 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_numbers": "18942010321", "display_name": "xiaoming" + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, insertValues); + console.info("logMessage abnormal_voicemail_insert_test_300: voicemialId = " + voicemailId); + expect(voicemailId == -1).assertTrue(); + done(); + } catch (error) { + console.info("abnormal_voicemail_insert_test_300 insert error = " + error); + done(); + } + }); + + /** + * @tc.number abnormal_voicemail_insert_test_400 + * @tc.name Exception use case, an incorrect table name is passed in when inserting data + * @tc.desc Function test + */ + it("abnormal_voicemail_insert_test_400", 0, async function (done) { + console.info("------------abnormal_voicemail_insert_test_400 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var errorUri = "dataability:///com.ohos.calllogability/calls/voicemails"; + + var insertValues = { + "phone_number": "18942010321", "display_name": "xiaoming" + }; + try { + var voicemialId = await DAHelper.insert(errorUri, insertValues) + console.info("logMessage abnormal_voicemail_insert_test_400: voicemialId = " + voicemialId); + expect(voicemialId == -1).assertTrue(); + var map = new Map(); + map.set("phone_number", "18942010321"); + await voiceMailQueryError(map, "abnormal_voicemail_insert_test_400"); + done(); + } catch (error) { + console.info("abnormal_voicemail_insert_test_400 insert error = " + error); + done(); + } + }); + + /** + * @tc.number abnormal_voicemail_update_test_1100 + * @tc.name Abnormal use case, passing in a wrong field when updating data + * @tc.desc Function test + */ + it("abnormal_voicemail_update_test_1100", 0, async function (done) { + console.info("------------abnormal_voicemail_update_test_1100 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "18942010321" + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, insertValues); + console.info("logMessage abnormal_voicemail_update_test_1100: voicemailId = " + voicemailId); + expect(voicemailId > 0).assertTrue(); + await abnormalUpdate(); + await voiceMailDelete("abnormal_voicemail_update_test_1100"); + done(); + } catch (error) { + console.info("abnormal_voicemail_update_test_1100 insert error = " + error); + done(); + } + async function abnormalUpdate() { + var updateValues = { + "phone_numbers": "11111111111111111" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", voicemailId.toString()); + try { + var updataCode = await DAHelper.update(voicemailUri, updateValues, condition); + console.info("logMessage abnormal_voicemail_update_test_1100: updataCode = " + updataCode); + expect(updataCode == -1).assertTrue(); + var map = new Map(); + map.set("phone_number", "11111111111111111"); + await voiceMailQueryError(map, "abnormal_voicemail_insert_test_400"); + } catch (error) { + console.info("logMessage abnormal_voicemail_update_test_1100: update error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_voicemail_update_test_1200 + * @tc.name Abnormal use case, an incorrect table name is passed in when updating data + * @tc.desc Function test + */ + it("abnormal_voicemail_update_test_1200", 0, async function (done) { + console.info("------------abnormal_voicemail_update_test_1200 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var errorUri = "dataability:///com.ohos.calllogability/calls/voicemails"; + + var insertValues = { + "phone_number": "9952364" + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, insertValues); + console.info("logMessage abnormal_voicemail_update_test_1200: voicemailId = " + voicemailId); + expect(voicemailId > 0).assertTrue(); + await abnormalUpdate(); + await voiceMailDelete("abnormal_voicemail_update_test_1200"); + done(); + } catch (error) { + console.info("logMessage abnormal_voicemail_update_test_1200: insert error = " + error); + done(); + } + + async function abnormalUpdate() { + var updateValues = { + "phone_number": "22001122" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", voicemailId.toString()); + try { + var updataCode = await DAHelper.update(errorUri, updateValues, condition) + console.info("logMessage abnormal_voicemail_update_test_1200: updataCode = " + updataCode); + expect(updataCode == -1).assertTrue(); + var map = new Map(); + map.set("phone_number", "22001122"); + await voiceMailQueryError(map, "abnormal_voicemail_insert_test_400"); + } catch (error) { + console.info("logMessage abnormal_voicemail_update_test_1200: update error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_voicemail_delete_test_700 + * @tc.name Abnormal use case, passing in a wrong field when deleting data + * @tc.desc Function test + */ + it("abnormal_voicemail_delete_test_700", 0, async function (done) { + console.info("------------abnormal_voicemail_delete_test_700 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "789130" + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, insertValues); + console.info("logMessage abnormal_voicemail_delete_test_700: voicemailId = " + voicemailId); + expect(voicemailId > 0).assertTrue(); + await abnormalDelete(); + await voiceMailDelete("abnormal_voicemail_delete_test_700"); + done(); + } catch (error) { + console.info("logMessage abnormal_voicemail_delete_test_700: insert error = " + error); + done(); + } + + async function abnormalDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", voicemailId.toString()); + try { + var deleteCode = await DAHelper.delete(voicemailUri, condition); + console.info("logMessage abnormal_voicemail_delete_test_700: deleteCode = " + deleteCode); + expect(deleteCode == -1).assertTrue(); + } catch (error) { + console.info("logMessage abnormal_voicemail_delete_test_700: delete error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_voicemail_delete_test_800 + * @tc.name Abnormal use case, passing in an incorrect table name when deleting data + * @tc.desc Function test + */ + it("abnormal_voicemail_delete_test_800", 0, async function (done) { + console.info("------------abnormal_voicemail_delete_test_800 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var errorUri = "dataability:///com.ohos.calllogability/calls/voicemails"; + + var insertValues = { + "phone_number": "1564721" + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, insertValues); + console.info("logMessage abnormal_voicemail_delete_test_800: voicemailId = " + voicemailId); + expect(voicemailId > 0).assertTrue(); + await abnormalDelete(); + await voiceMailDelete("abnormal_voicemail_delete_test_800"); + done(); + } catch (error) { + console.info("logMessage abnormal_voicemail_delete_test_800: insert error = " + error); + done(); + } + + async function abnormalDelete() { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", voicemailId.toString()); + try { + var deleteCode = await DAHelper.delete(errorUri, condition); + console.info("logMessage abnormal_voicemail_delete_test_800: deleteCode = " + deleteCode); + expect(deleteCode == -1).assertTrue(); + } catch (error) { + console.info("logMessage abnormal_voicemail_delete_test_800: delete error = " + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_voicemail_query_test_1500 + * @tc.name Abnormal use case, an incorrect field is passed in when querying + * @tc.desc Function test + */ + it("abnormal_voicemail_query_test_1500", 0, async function (done) { + console.info("------------abnormal_voicemail_query_test_1500 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValues = { + "phone_number": "1564721" + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, insertValues); + console.info("logMessage abnormal_voicemail_query_test_1500: voicemailId = " + voicemailId); + expect(voicemailId > 0).assertTrue(); + await abnormalQuery(); + await voiceMailDelete("abnormal_voicemail_query_test_1500"); + done(); + } catch (error) { + console.info("logMessage abnormal_voicemail_query_test_1500: insert error = " + error); + done(); + } + + async function abnormalQuery() { + var resultColumns = ["id", "phone_number"]; + + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", voicemailId.toString()); + try { + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition) + console.info('logMessage abnormal_voicemail_query_test_1500: goToFirstRow' + resultSet.goToFirstRow()); + expect(resultSet.goToFirstRow()).assertEqual(false); + resultSet.close(); + } catch (error) { + console.info('logMessage abnormal_voicemail_query_test_1500: query error = ' + error); + done(); + } + } + }); + + /** + * @tc.number abnormal_voicemail_batchinsert_test_1900 + * @tc.name Abnormal use cases, when inserting data in batches, some of them failed, check the processing logic + * @tc.desc Function test + */ + it("abnormal_voicemail_batchinsert_test_1900", 0, async function (done) { + console.info("--------logMessage abnormal_voicemail_batchinsert_test_1900 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var addBulkValue1 = { + "phone_number": "5555555555", "ring_duration": "500" + }; + var addBulkValue2 = { + "phone_number": "1511002", "ring_duration": "100" + }; + var addBulkValue3 = { + "phone_numbers": "1521003", "ring_duration": "100" + }; + var addBulkValue4 = { + "phone_number": "1521004", "ring_durations": "100" + }; + var addBulkValue5 = { + "phone_number": "1521005", "ring_duration": "100" + }; + var listAddBluk = []; + listAddBluk[0] = addBulkValue1; + listAddBluk[1] = addBulkValue2; + listAddBluk[2] = addBulkValue3; + listAddBluk[3] = addBulkValue4; + listAddBluk[4] = addBulkValue5; + try { + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk) + console.info("logMessage abnormal_voicemail_batchinsert_test_1900: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == -1).assertTrue(); + done(); + } catch (error) { + console.info('logMessage abnormal_voicemail_batchinsert_test_1900: batchInsert error = ' + error); + done(); + } + }); + + /** + * @tc.number voiceMail_delete_test_2000 + * @tc.name batchDelete + * @tc.desc Function test + */ + it("voiceMail_delete_test_2000", 0, async function (done) { + console.info("--------logMessage voiceMail_delete_test_2000 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var voiceMailId = await DAHelper.insert(voicemailUri, common.getVoiceMail()); + console.info("logMessage voiceMail_delete_test_2000: voiceMailId = " + voiceMailId); + expect(voiceMailId > 0).assertTrue(); + var map = common.getVoiceMailMap() + map.set("id", voiceMailId.toString()); + await voiceMailQuery(map, "voiceMail_delete_test_2000"); + await executeBatch(); + } catch (error) { + console.info("logMessage voiceMail_delete_test_2000: voiceMailId insert error = " + error); + done(); + } + async function executeBatch() { + console.info("logMessage voiceMail_delete_test_2000: executeBatch start "); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", voiceMailId.toString()); + DAHelper.executeBatch(URI_VOICEMAIL, [{ + uri: voicemailUri, + type: featureAbility.DataAbilityOperationType.TYPE_DELETE, + predicates: condition, + expectedCount: 0, + PredicatesBackReferences: {}, + interrupted: true, + }], + (error, data) => { + console.info("logMessage voiceMail_delete_test_2000: executeBatch data = " + JSON.stringify(data)); + console.info("logMessage voiceMail_delete_test_2000: data_3 = " + data); + console.info("logMessage voiceMail_delete_test_2000: data_1= " + data[0].count); + expect(data[0].count == 0).assertTrue(); + done(); + }); + } + }); + + /** + * @tc.number voiceMail_update_test_2100 + * @tc.name batchUpdate + * @tc.desc Function test + */ + it("voiceMail_update_test_2100", 0, async function (done) { + console.info("--------logMessage voiceMail_update_test_2100 is starting!------------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var voiceMailId = await DAHelper.insert(voicemailUri, common.getVoiceMail()); + console.info("logMessage voiceMail_update_test_2100: voiceMailId = " + voiceMailId); + expect(voiceMailId > 0).assertTrue(); + var map = common.getVoiceMailMap(); + map.set("id", voiceMailId.toString()); + await voiceMailQuery(map, "voiceMail_update_test_2100"); + await executeBatch(); + } catch (error) { + console.info("logMessage voiceMail_update_test_2100: calllog insert error = " + error); + done(); + } + async function executeBatch() { + var updateValues = { + "phone_number": "123456789" + }; + console.info("logMessage voiceMail_update_test_2100: executeBatch start "); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", voiceMailId.toString()); + DAHelper.executeBatch(URI_VOICEMAIL, [{ + uri: voicemailUri, + type: featureAbility.DataAbilityOperationType.TYPE_UPDATE, + valuesBucket: updateValues, + predicates: condition, + expectedCount: 0, + PredicatesBackReferences: {}, + interrupted: true, + }], + (error, data) => { + console.info("logMessage voiceMail_update_test_2100: executeBatch data = " + JSON.stringify(data)); + console.info("logMessage voiceMail_update_test_2100: data_3 = " + data); + console.info("logMessage voiceMail_update_test_2100: data_1= " + data[0].count); + expect(data[0].count == 0).assertTrue(); + done(); + }); + } + }); + + /** + * @tc.number voicemail_insert_test_2200 + * @tc.name Insert voicemail status 0 + * @tc.desc Function test + */ + it("voicemail_insert_test_2200", 0, async function (done) { + console.info("---------logMessage voicemail_insert_test_2200 is starting!---------") + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + console.info('logMessage uri = ' + URI_VOICEMAIL) + + var stringValue = { + "phone_number": "1557544452542200", "voice_status": 0 + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, stringValue) + console.info("logMessage voicemail_insert_test_2200: voicemailId = " + voicemailId); + expect(voicemailId > 0).assertTrue(); + var map = new Map(); + map.set("id", voicemailId.toString()); + map.set("phone_number", "1557544452542200"); + map.set("voice_status", "0"); + await voiceMailQuery(map, "voicemail_insert_test_2200"); + await voiceMailDelete("voicemail_insert_test_2200"); + done(); + } catch (error) { + console.info("logMessage voicemail_insert_test_2200: voicemail insert error = " + error); + done(); + } + }); + + /** + * @tc.number voicemail_insert_test_2300 + * @tc.name Insert 3 pieces of voice mail data first, then delete 2 pieces of data, + * and verify whether the deletion is successful + * @tc.desc Function test + */ + it("voicemail_insert_test_2300", 0, async function (done) { + console.info("---------logMessage voicemail_insert_test_2300 is starting!---------") + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + console.info('logMessage uri = ' + URI_VOICEMAIL) + + var stringValue = { + "phone_number": "155754445254", "voice_status": 0 + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, stringValue) + var voicemailIdOne = await DAHelper.insert(voicemailUri, stringValue) + var voicemailIdTwo = await DAHelper.insert(voicemailUri, stringValue) + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", voicemailId.toString()); + condition.or(); + condition.equalTo("id", voicemailIdOne.toString()); + var deleteCode = await DAHelper.delete(voicemailUri, condition); + console.info("logMessage voicemail_insert_test_2300: deleteCode = " + deleteCode); + var resultColumns = []; + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition); + expect(resultSet.rowCount == 0).assertTrue(); + resultSet.close(); + await voiceMailDelete("voicemail_insert_test_2300"); + done(); + } catch (error) { + console.info("logMessage voicemail_insert_test_2300: voicemail insert error = " + error); + done(); + } + }); + + /** + * @tc.number voicemail_insert_test_2400 + * @tc.name Insert 3 pieces of voice mail data first, then update 2 pieces of data, + * and verify whether the deletion is successful + * @tc.desc Function test + */ + it("voicemail_insert_test_2400", 0, async function (done) { + console.info("---------logMessage voicemail_insert_test_2400 is starting!---------") + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + console.info('logMessage uri = ' + URI_VOICEMAIL) + + var stringValue = { + "phone_number": "155754445254", "voice_status": 0 + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, stringValue) + var voicemailIdOne = await DAHelper.insert(voicemailUri, stringValue) + var voicemailIdTwo = await DAHelper.insert(voicemailUri, stringValue) + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", voicemailId.toString()); + condition.or(); + condition.equalTo("id", voicemailIdOne.toString()); + var updateValue = { + "phone_number": "14541555754445254", "voice_status": 1 + }; + var updateCode = await DAHelper.update(voicemailUri, updateValue, condition); + console.info("logMessage voicemail_insert_test_2400: deleteCode = " + updateCode); + + var map = new Map(); + map.set("id", voicemailId.toString()); + map.set("phone_number", "14541555754445254"); + map.set("voice_status", "1"); + await voiceMailQuery(map, "voicemail_insert_test_2400"); + + var mapOne = new Map(); + mapOne.set("id", voicemailIdOne.toString()); + mapOne.set("phone_number", "14541555754445254"); + mapOne.set("voice_status", "1"); + await voiceMailQuery(mapOne, "voicemail_insert_test_2400"); + await voiceMailDelete("voicemail_insert_test_2400"); + done(); + } catch (error) { + console.info("logMessage voicemail_insert_test_2400: voicemail insert error = " + error); + done(); + } + }); + + /** + * @tc.number voicemail_insert_test_2500 + * @tc.name Query the voice mailbox with status 0 or id and return the query result + * @tc.desc Function test + */ + it("voicemail_query_test_2500", 0, async function (done) { + console.info("---------logMessage voicemail_query_test_2500 is starting!---------") + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + console.info('logMessage uri = ' + URI_VOICEMAIL) + var stringValue = { + "phone_number": "4454445254", "voice_status": 0 + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, stringValue) + var voicemailIdOne = await DAHelper.insert(voicemailUri, stringValue) + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.beginWrap(); + condition.equalTo("id", voicemailId.toString()); + condition.or(); + condition.equalTo("id", voicemailIdOne.toString()); + condition.endWrap(); + condition.and(); + condition.equalTo("voice_status", "0"); + var resultColumns = []; + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition); + expect(resultSet.rowCount == 2).assertTrue(); + resultSet.close(); + await voiceMailDelete("voicemail_query_test_2500"); + done(); + } catch (error) { + console.info("logMessage voicemail_query_test_2500: voicemail insert error = " + error); + done(); + } + }); + + /** + * @tc.number voicemail_query_test_2600 + * @tc.name Query the voice mailbox and return the query result + * @tc.desc Function test + */ + it("voicemail_query_test_2600", 0, async function (done) { + console.info("---------logMessage voicemail_query_test_2600 is starting!---------") + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + console.info('logMessage uri = ' + URI_VOICEMAIL) + var stringValue = { + "phone_number": "445444445254", "voice_status": 0 + }; + try { + var voicemailId = await DAHelper.insert(voicemailUri, stringValue); + console.info('voicemail_query_test_2600 voicemailId = ' + voicemailId); + var voicemailIdOne = await DAHelper.insert(voicemailUri, stringValue); + console.info('voicemail_query_test_2600 voicemailIdOne = ' + voicemailIdOne); + var condition = new ohosDataAbility.DataAbilityPredicates(); + var resultColumns = []; + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition); + expect(resultSet.rowCount == 2).assertTrue(); + resultSet.close(); + await voiceMailDelete("voicemail_query_test_2600"); + done(); + } catch (error) { + console.info("logMessage voicemail_query_test_2600: voicemail insert error = " + error); + done(); + } + }); + + /** + * @tc.number abnormal_voicemail_insert_test_2700 + * @tc.name When the voicemail status is added, a non-existent field is passed in + * @tc.desc Function test + */ + it("abnormal_voicemail_insert_test_2700", 0, async function (done) { + console.info("---------logMessage abnormal_voicemail_insert_test_2700 is starting!---------") + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + console.info('logMessage uri = ' + URI_VOICEMAIL) + try { + var insertValues = { + display_name: "2700name", voice_statuss: "1" + }; + var voicemailId = await DAHelper.insert(voicemailUri, insertValues); + expect(voicemailId == -1).assertTrue(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + var resultColumns = []; + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition); + expect(resultSet.rowCount == 0).assertTrue(); + await voiceMailDelete("abnormal_voicemail_insert_test_2700"); + done(); + } catch (error) { + done(); + } + }); + + /** + * @tc.number abnormal_voicemail_delete_test_2800 + * @tc.name When deleting the voicemail status, pass in a non-existent field + * @tc.desc Function test + */ + it("abnormal_voicemail_delete_test_2800", 0, async function (done) { + console.info("---------logMessage abnormal_voicemail_delete_test_2800 is starting!---------") + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + console.info('logMessage uri = ' + URI_VOICEMAIL) + try { + var insertValues = { + display_name: "2800name", voice_status: "1" + }; + var voicemailId = await DAHelper.insert(voicemailUri, insertValues); + expect(voicemailId > 0).assertTrue(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", voicemailId.toString()); + var updateValues = { + display_name: "2800name", voice_statuss: "0" + }; + var updateCode = await DAHelper.update(voicemailUri, updateValues, condition); + expect(updateCode == -1).assertTrue(); + var map = new Map(); + map.set("id", voicemailId.toString()); + map.set("display_name", "2800name"); + map.set("voice_status", "1"); + await voiceMailQuery(map, "abnormal_voicemail_delete_test_2800"); + await voiceMailDelete("abnormal_voicemail_delete_test_2800"); + done(); + } catch (error) { + done(); + } + }); + + /** + * @tc.number abnormal_voicemail_update_test_2900 + * @tc.name When update the voicemail status, pass in a non-existent field + * @tc.desc Function test + */ + it("abnormal_voicemail_update_test_2900", 0, async function (done) { + console.info("---------logMessage abnormal_voicemail_update_test_2900 is starting!---------") + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + console.info('logMessage uri = ' + URI_VOICEMAIL) + try { + var insertValues = { + display_name: "2900name", voice_status: "1" + }; + var voicemailId = await DAHelper.insert(voicemailUri, insertValues); + expect(voicemailId > 0).assertTrue(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", voicemailId.toString()); + var updateValues = { + display_name: "2900name", voice_statuss: "0" + }; + var updateCode = await DAHelper.update(voicemailUri, updateValues, condition); + expect(updateCode == -1).assertTrue(); + var map = new Map(); + map.set("id", voicemailId.toString()); + map.set("display_name", "2900name"); + map.set("voice_status", "1"); + await voiceMailQuery(map, "abnormal_voicemail_update_test_2900"); + await voiceMailDelete("abnormal_voicemail_update_test_2900"); + done(); + } catch (error) { + done(); + } + }); + + /** + * @tc.number abnormal_voicemail_update_test_3000 + * @tc.name When update the voicemail status, pass in a non-existent field + * @tc.desc Function test + */ + it("abnormal_voicemail_update_test_3000", 0, async function (done) { + console.info("---------logMessage abnormal_voicemail_update_test_3000 is starting!---------") + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + console.info('logMessage uri = ' + URI_VOICEMAIL) + try { + var insertValues = { + display_name: "2900name", voice_status: "1" + }; + var voicemailId = await DAHelper.insert(voicemailUri, insertValues); + expect(voicemailId > 0).assertTrue(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("ids", voicemailId.toString()); + var resultColumns = []; + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition); + expect(resultSet.rowCount == -1).assertTrue(); + resultSet.close(); + await voiceMailDelete("abnormal_voicemail_update_test_3000"); + done(); + } catch (error) { + done(); + } + }); + + /** + * @tc.number abnormal_voicemail_batchInsert_test_3100 + * @tc.name Insert voicemail data in batches , pass in a non-existent field + * @tc.desc Function test + */ + it("abnormal_voicemail_batchInsert_test_3100", 0, async function (done) { + console.info("-------------logMessage abnormal_voicemail_batchInsert_test_3100 is starting!-----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertValuesOne = { + "voice_status": "0", "display_name": "xiaoming" + }; + var insertValuesTwo = { + "voice_status": "1", "display_name": "xiaohei" + }; + var insertValuesThree = { + "voice_statusss": "1", "display_name": "xiaohong" + }; + var insertValuesFour = { + "voice_status": "0", "display_name": "xiaohei" + }; + var insertValuesFive = { + "voice_status": "0", "display_name": "xiaofen" + }; + var listAddBluk = []; + listAddBluk[0] = insertValuesOne; + listAddBluk[1] = insertValuesTwo; + listAddBluk[2] = insertValuesThree; + listAddBluk[3] = insertValuesFour; + listAddBluk[4] = insertValuesFive; + try { + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + console.info("logMessage abnormal_voicemail_batchInsert_test_3100: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == -1).assertTrue(); + var condition = new ohosDataAbility.DataAbilityPredicates(); + var resultColumns = []; + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition); + expect(resultSet.rowCount == 0).assertTrue(); + resultSet.close(); + done(); + } catch (error) { + console.info("logMessage abnormal_voicemail_batchInsert_test_3100: batchInsert error = " + error); + done(); + } + }); + + afterAll(async function () { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('voicemai afterAll logMessage get DAHelper success! DAHelper = ' + DAHelper); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + var deleteCode = await DAHelper.delete(voicemailUri, condition); + console.info('voicemai afterAll logMessage deleteCode = ' + deleteCode); + }); + }) +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/common.js b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/common.js new file mode 100644 index 0000000000000000000000000000000000000000..5e82feeb831322c67d510c61ce8931ce54144fee --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/common.js @@ -0,0 +1,726 @@ +/* + * Copyright (c) 2021 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 featureAbility from '@ohos.ability.featureAbility'; +import ohosDataAbility from '@ohos.data.dataability'; +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'deccjsunit/index' + +const URI_CONTACTS = "dataability:///com.ohos.contactsdataability"; +const contactUri = "dataability:///com.ohos.contactsdataability/contacts/contact"; +const rawContactUri = "dataability:///com.ohos.contactsdataability/contacts/raw_contact"; +const contactDataUri = "dataability:///com.ohos.contactsdataability/contacts/contact_data"; +const groupUri = "dataability:///com.ohos.contactsdataability/contacts/groups"; +const contactBlocklistUri = "dataability:///com.ohos.contactsdataability/contacts/contact_blocklist"; +const deletedRawContactUri = "dataability:///com.ohos.contactsdataability/contacts/deleted_raw_contact"; +const profileRawContactUri = "dataability:///com.ohos.contactsdataability/profile/raw_contact"; +const profilecontactUri = "dataability:///com.ohos.contactsdataability/profile/contact"; +const profileContactDataUri = "dataability:///com.ohos.contactsdataability/profile/contact_data"; +const profileGroupUri = "dataability:///com.ohos.contactsdataability/profile/groups"; +const profileBlocklistUri = "dataability:///com.ohos.contactsdataability/profile/contact_blocklist"; +const profileDeletedContactsUri = "dataability:///com.ohos.contactsdataability/profile/deleted_raw_contact"; + +const URI_CALLLOG = "dataability:///com.ohos.calllogability"; +const calllogUri = "dataability:///com.ohos.calllogability/calls/calllog"; + +export default { + data: {}, + getCallLogInsertMap: + function () { + var calllogInsert100Map = new Map([ + ["phone_number", "123456789"], ["display_name", "xxw"], ["voicemail_uri", "uri"], + ["sim_type", "1"], ["is_hd", "2"], ["is_read", "1"], ["ring_duration", "900"], + ["talk_duration", "200"], ["format_number", "123 456 789"], ["quicksearch_key", "2"], + ["number_type", "2"], ["number_type_name", "tian"], ["begin_time", "200"], ["end_time", "300"], + ["answer_state", "1"], ["create_time", "400"], ["number_location", "dizhi"], ["photo_id", "1"], + ["photo_uri", "666"], ["country_iso_code", "2"], ["extra1", "test1"], ["extra2", "test2"], + ["extra3", "test3"], ["extra4", "test4"], ["extra5", "test5"], ["extra6", "test6"] + ]); + return calllogInsert100Map; + }, + getCallLogInsert: + function () { + var calllogInsert100 = { + "phone_number": "123456789", + "display_name": "xxw", + "voicemail_uri": "uri", + "sim_type": 1, + "is_hd": 2, + "is_read": 1, + "ring_duration": 900, + "talk_duration": 200, + "format_number": "123 456 789", + "quicksearch_key": "2", + "number_type": 2, + "number_type_name": "tian", + "begin_time": 200, + "end_time": 300, + "answer_state": 1, + "create_time": 400, + "number_location": "dizhi", + "photo_id": 1, + "photo_uri": "666", + "country_iso_code": 2, + "extra1": "test1", + "extra2": "test2", + "extra3": "test3", + "extra4": "test4", + "extra5": "test5", + "extra6": "test6", + }; + return calllogInsert100; + }, + getCallLogResultColumns: + function () { + var resultColumns = [ + "id", "phone_number", "display_name", "call_direction", "voicemail_uri", "sim_type", "is_hd", "is_read", + "ring_duration", "talk_duration", "format_number", "quicksearch_key", "number_type", "number_type_name", + "begin_time", "end_time", "answer_state", "create_time", "number_location", "photo_id", "photo_uri", + "country_iso_code", "extra1", "extra2", "extra3", "extra4", "extra5", "extra6" + ]; + return resultColumns; + }, + getCallLogUpdate: + function () { + var updateValues = { + "phone_number": "987654321", + "display_name": "6666", + "voicemail_uri": "7777", + "sim_type": 4, + "is_hd": 4, + "is_read": 4, + "ring_duration": 400, + "talk_duration": 400, + "format_number": "987 654 321", + "quicksearch_key": "4", + "number_type": 4, + "number_type_name": "4tian", + "begin_time": 400, + "end_time": 400, + "answer_state": 4, + "create_time": 40000, + "number_location": "4dizhi", + "photo_id": 4, + "photo_uri": "4444", + "country_iso_code": 4, + "extra1": "test7", + "extra2": "test7", + "extra3": "test7", + "extra4": "test7", + "extra5": "test7", + "extra6": "test7", + }; + return updateValues; + }, + getCallLogUpdateMap: + function () { + var calllogInsert100Map = new Map([ + ["phone_number", "987654321"], ["display_name", "6666"], ["voicemail_uri", "7777"], + ["sim_type", "4"], ["is_hd", "4"], ["is_read", "4"], ["ring_duration", "400"], + ["talk_duration", "400"], ["format_number", "987 654 321"], ["quicksearch_key", "4"], + ["number_type", "4"], ["number_type_name", "4tian"], ["begin_time", "400"], ["end_time", "400"], + ["answer_state", "4"], ["create_time", "40000"], ["number_location", "4dizhi"], + ["photo_id", "4"], ["photo_uri", "4444"], ["country_iso_code", "4"], ["extra1", "test7"], + ["extra2", "test7"], ["extra3", "test7"], ["extra4", "test7"], ["extra5", "test7"], + ["extra6", "test7"] + ]); + return calllogInsert100Map; + }, + getCallLogBatchInsert: + function () { + var map = new Map([["phone_number", "1600"], ["ring_duration", "333"]]); + var map2 = new Map([["phone_number", "1600"], ["ring_duration", "600"]]); + var map3 = new Map([["phone_number", "1600"], ["ring_duration", "600"]]); + var map4 = new Map([["phone_number", "1600"], ["ring_duration", "600"]]); + var map5 = new Map([["phone_number", "1600"], ["ring_duration", "600"]]); + var array = [map, map2, map3, map4, map5]; + return array; + }, + getProfileRawContact: + function () { + var rawContact = { + "photo_id": 2, + "photo_file_id": 3, + "is_transfer_voicemail": 1, + "personal_ringtone": "test", + "is_deleted": 0, + "personal_notification_ringtone": "666", + "photo_first_name": "7777", + "account_id": 1, + "version": 1, + "sort": "6666", + "contacted_count": 2, + "lastest_contacted_time": 2, + "favorite": 1, + "favorite_order": "test", + "phonetic_name": "testname", + "phonetic_name_type": 1, + "display_name": "licheng", + "company": "TTTTT", + "position": "Developer", + "read_only": 2, + "sort_first_letter": "testsort", + "sync_id": 8, + "syn_1": "syn_1", + "syn_2": "syn_2", + "syn_3": "syn_3", + }; + return rawContact; + }, + getProfileRawContactMap: + function () { + var rawContactMap = new Map([ + ["photo_id", "2"], ["photo_file_id", "3"], ["is_transfer_voicemail", "1"], + ["personal_ringtone", "test"], ["is_deleted", "0"], + [ + "personal_notification_ringtone", + "666", + ], + [ + "photo_first_name", + "7777", + ], + ["account_id", "1"], ["version", "1"], ["sort", "6666"], ["contacted_count", "2"], + ["lastest_contacted_time", "2"], ["favorite", "1"], ["favorite_order", "test"], + ["phonetic_name", "testname"], ["phonetic_name_type", "1"], ["display_name", "licheng"], + ["company", "TTTTT"], ["position", "Developer"], ["read_only", "2"], + ["sort_first_letter", "testsort"], ["merge_mode", "0"], ["is_need_merge", "1"], + ["merge_status", "1"], ["is_merge_target", "0"], ["vibration_setting", "0"], ["sync_id", "8"], + ["syn_1", "syn_1"], ["syn_2", "syn_2"], ["syn_3", "syn_3"] + ]); + return rawContactMap; + }, + getProfileRawContactUpdate: + function () { + var rawContact = { + "photo_id": 21, + "photo_file_id": 31, + "is_transfer_voicemail": 11, + "personal_ringtone": "test1", + "is_deleted": 0, + "personal_notification_ringtone": "6661", + "photo_first_name": "77771", + "account_id": 1, + "sort": "66661", + "contacted_count": 21, + "lastest_contacted_time": 21, + "favorite": 11, + "favorite_order": "test1", + "phonetic_name": "testname1", + "phonetic_name_type": 11, + "display_name": "licheng1", + "company": "TTTTT1", + "position": "Developer1", + "read_only": 21, + "sort_first_letter": "testsort1", + "sync_id": 81, + "syn_1": "syn_11", + "syn_2": "syn_21", + "syn_3": "syn_31", + }; + return rawContact; + }, + getProfileRawContactUpdateMap: + function () { + var rawContactMap = new Map([ + ["photo_id", "21"], ["photo_file_id", "31"], ["is_transfer_voicemail", "11"], + ["personal_ringtone", "test1"], ["is_deleted", "0"], + [ + "personal_notification_ringtone", + "6661", + ], + [ + "photo_first_name", + "77771", + ], + ["account_id", "1"], ["version", "1"], ["sort", "66661"], ["contacted_count", "21"], + ["lastest_contacted_time", "21"], ["favorite", "11"], ["favorite_order", "test1"], + ["phonetic_name", "testname1"], ["phonetic_name_type", "11"], ["display_name", "licheng1"], + ["company", "TTTTT1"], ["position", "Developer1"], ["read_only", "21"], + ["sort_first_letter", "testsort1"], ["merge_mode", "0"], ["is_need_merge", "1"], + ["merge_status", "1"], ["is_merge_target", "0"], ["vibration_setting", "0"], ["sync_id", "81"], + ["syn_1", "syn_11"], ["syn_2", "syn_21"], ["syn_3", "syn_31"] + ]); + return rawContactMap; + }, + getProfileContactData: + function () { + var contactData = { + "content_type": "name", + "detail_info": "xiaocai", + "family_name": "family_name", + "middle_name_phonetic": "middle_name_phonetic", + "given_name": "given_name", + "given_name_phonetic": "given_name_phonetic", + "alias_detail_info": "alias_detail_info", + "phonetic_name": "phonetic_name", + "position": "Developer", + "extend1": "extend1", + "extend2": "extend2", + "extend3": "extend3", + "extend4": "extend4", + "city": "city", + "country": "country", + "neighborhood": "neighborhood", + "pobox": "pobox", + "postcode": "postcode", + "region": "region", + "street": "street", + "alpha_name": "alpha_name", + "other_lan_last_name": "other_lan_last_name", + "other_lan_first_name": "other_lan_first_name", + "extend5": "extend5", + "lan_style": "lan_style", + "custom_data": "custom_data", + "extend6": "extend6", + "extend7": "extend7", + "blob_data": "blob_data", + "syn_1": "syn_1", + "syn_2": "syn_2", + "syn_3": "syn_3", + }; + return contactData; + }, + getProfileContactDataMap: + function () { + var ContactDataMap = new Map([ + ["detail_info", "xiaocai"], ["family_name", "family_name"], + ["middle_name_phonetic", "middle_name_phonetic"], ["given_name", "given_name"], + ["given_name_phonetic", "given_name_phonetic"], ["alias_detail_info", "alias_detail_info"], + ["phonetic_name", "phonetic_name"], ["position", "position"], ["extend1", "extend1"], + ["extend2", "extend2"], ["pobox", "pobox"], ["postcode", "postcode"], ["city", "city"], + ["country", "country"], ["neighborhood", "neighborhood"], + [ + "position", + "Developer", + ], + ["region", "region"], ["street", "street"], ["alpha_name", "alpha_name"], + ["other_lan_last_name", "other_lan_last_name"], ["other_lan_first_name", "other_lan_first_name"], + ["extend5", "extend5"], ["lan_style", "lan_style"], ["custom_data", "custom_data"], + ["extend6", "extend6"], ["extend7", "extend7"], ["blob_data", "blob_data"], ["syn_1", "syn_1"], + [ + "syn_2", + "syn_2", + ], + [ + "syn_3", + "syn_3", + ], + ["read_only", "0"], ["version", "0"], ["is_preferred_number", "0"] + ]); + return ContactDataMap; + }, + getProfileContactDataUpdate: + function () { + var contactData = { + "detail_info": "xiaocai1", + "family_name": "family_name1", + "middle_name_phonetic": "middle_name_phonetic1", + "given_name": "given_name1", + "given_name_phonetic": "given_name_phonetic1", + "alias_detail_info": "alias_detail_info1", + "phonetic_name": "phonetic_name1", + "position": "Developer1", + "extend1": "extend11", + "extend2": "extend21", + "extend3": "extend31", + "extend4": "extend41", + "city": "city1", + "country": "country1", + "neighborhood": "neighborhood1", + "pobox": "pobox1", + "postcode": "postcode1", + "region": "region1", + "street": "street1", + "alpha_name": "alpha_name1", + "other_lan_last_name": "other_lan_last_name1", + "other_lan_first_name": "other_lan_first_name1", + "extend5": "extend51", + "lan_style": "lan_style1", + "custom_data": "custom_data1", + "extend6": "extend61", + "extend7": "extend71", + "blob_data": "blob_data1", + "syn_1": "syn_11", + "syn_2": "syn_21", + "syn_3": "syn_31", + }; + return contactData; + }, + getProfileContactDataUpdateMap: + function () { + var ContactDataMap = new Map([ + ["detail_info", "xiaocai1"], ["family_name", "family_name1"], + ["middle_name_phonetic", "middle_name_phonetic1"], ["given_name", "given_name1"], + ["given_name_phonetic", "given_name_phonetic1"], ["alias_detail_info", "alias_detail_info1"], + ["phonetic_name", "phonetic_name1"], ["position", "position1"], ["extend1", "extend11"], + ["extend2", "extend21"], ["pobox", "pobox1"], ["postcode", "postcode1"], ["city", "city1"], + ["country", "country1"], ["neighborhood", "neighborhood1"], + [ + "position", + "Developer1", + ], + ["region", "region1"], ["street", "street1"], ["alpha_name", "alpha_name1"], + ["other_lan_last_name", "other_lan_last_name1"], ["other_lan_first_name", "other_lan_first_name1"], + ["extend5", "extend51"], ["lan_style", "lan_style1"], ["custom_data", "custom_data1"], + ["extend6", "extend61"], ["extend7", "extend71"], ["blob_data", "blob_data1"], + ["syn_1", "syn_11"], + [ + "syn_2", + "syn_21", + ], + [ + "syn_3", + "syn_31", + ], + ["read_only", "0"], ["version", "1"], ["is_preferred_number", "0"] + ]); + return ContactDataMap; + }, + getProfileGroup: + function () { + var group = { + "account_id": 1, + "group_name": "DeveloperFirsthGroup", + "group_notes": "note", + "group_ringtone": "test" + }; + return group; + }, + getProfileGroupMap: + function () { + var groupMap = new Map([ + ["account_id", "1"], ["group_name", "DeveloperFirsthGroup"], ["group_notes", "note"], + ["is_deleted", "0"], ["group_ringtone", "test"], ["ringtone_modify_time", "0"], + ["lastest_modify_time", "0"] + ]); + return groupMap; + }, + getProfileBlockList: + function () { + var blockList = { + "phone_number": "123456789", "content": "heimingdan" + }; + return blockList; + }, + getProfileBlockListMap: + function () { + var blockListMap = new Map([ + ["types", "0"], ["phone_number", "123456789"], ["content", "heimingdan"], ["time_stamp", "0"] + ]); + return blockListMap; + }, + getProfileUpdateRawContact: + function () { + var rawContact = { + "photo_id": 8, + "photo_file_id": 8, + "is_transfer_voicemail": 8, + "personal_ringtone": "test8", + "is_deleted": 1, + "personal_notification_ringtone": "888", + "photo_first_name": "9999", + "account_id": 8, + "version": 2, + "sort": "8888", + "contacted_count": 8, + "lastest_contacted_time": 8, + "favorite": 0, + "favorite_order": "test8", + "phonetic_name": "testname8", + "phonetic_name_type": 8, + "display_name": "licheng8", + "company": "TTTTT8", + "position": "Developer8", + "read_only": 8, + "sort_first_letter": "testsort8", + "sync_id": 888, + "syn_1": "syn_8", + "syn_2": "syn_8", + "syn_3": "syn_8", + }; + return rawContact; + }, + getProfileUpdateRawContactMap: + function () { + var rawContactMap = new Map([ + ["photo_id", "8"], ["photo_file_id", "8"], ["is_transfer_voicemail", "8"], + ["personal_ringtone", "test8"], ["is_deleted", "1"], + [ + "personal_notification_ringtone", + "888", + ], + [ + "photo_first_name", + "9999", + ], + ["account_id", "8"], ["version", "2"], ["sort", "8888"], ["contacted_count", "8"], + ["lastest_contacted_time", "8"], ["favorite", "0"], ["favorite_order", "test8"], + ["phonetic_name", "testname8"], ["phonetic_name_type", "8"], ["display_name", "licheng8"], + ["company", "TTTTT8"], ["position", "Developer8"], ["read_only", "8"], + ["sort_first_letter", "testsort8"], ["merge_mode", "0"], ["is_need_merge", "1"], + ["merge_status", "1"], ["is_merge_target", "0"], ["vibration_setting", "0"], ["sync_id", "888"], + ["syn_1", "syn_8"], ["syn_2", "syn_8"], ["syn_3", "syn_8"] + ]); + return rawContactMap; + }, + getProfileUpdateContactData: + function () { + var contactData = { + "detail_info": "BossCai", + "family_name": "family_name8", + "middle_name_phonetic": "middle_name_phonetic8", + "given_name": "given_name8", + "given_name_phonetic": "given_name_phonetic8", + "alias_detail_info": "alias_detail_info8", + "phonetic_name": "phonetic_name8", + "position": "position8", + "extend1": "extend8", + "extend2": "extend8", + "extend3": "extend8", + "extend4": "extend8", + "country": "country8", + "neighborhood": "neighborhood8", + "pobox": "pobox8", + "city": "city8", + "postcode": "postcode8", + "region": "region8", + "street": "street8", + "alpha_name": "alpha_name8", + "other_lan_last_name": "other_lan_last_name8", + "other_lan_first_name": "other_lan_first_name8", + "extend5": "extend8", + "lan_style": "lan_style8", + "custom_data": "custom_data8", + "extend6": "extend8", + "extend7": "extend8", + "blob_data": "blob_data8", + "syn_1": "syn_8", + "syn_2": "syn_8", + "syn_3": "syn_8" + }; + return contactData; + }, + getProfileUpdateContactDataMap: + function () { + var ContactDataMap = new Map([ + ["detail_info", "BossCai"], ["family_name", "family_name8"], + ["middle_name_phonetic", "middle_name_phonetic8"], ["given_name", "given_name8"], + ["given_name_phonetic", "given_name_phonetic8"], ["alias_detail_info", "alias_detail_info8"], + ["phonetic_name", "phonetic_name8"], ["position", "position8"], ["extend1", "extend8"], + ["extend2", "extend8"], ["pobox", "pobox8"], ["postcode", "postcode8"], ["city", "city8"], + ["country", "country8"], ["neighborhood", "neighborhood8"], + [ + "position", + "position8", + ], + ["region", "region8"], ["street", "street8"], ["alpha_name", "alpha_name8"], + ["other_lan_last_name", "other_lan_last_name8"], ["other_lan_first_name", "other_lan_first_name8"], + ["extend5", "extend8"], ["lan_style", "lan_style8"], ["custom_data", "custom_data8"], + ["extend6", "extend8"], ["extend7", "extend8"], ["blob_data", "blob_data8"], ["syn_1", "syn_8"], + [ + "syn_2", + "syn_8", + ], + [ + "syn_3", + "syn_8", + ], + ["read_only", "0"], ["version", "1"], ["is_preferred_number", "0"] + ]); + return ContactDataMap; + }, + getProfileUpdateGroup: + function () { + var group = { + "account_id": 8, + "group_name": "TestFifthGroup", + "group_notes": "note8", + "group_ringtone": "test8" + }; + return group; + }, + getProfileUpdateGroupMap: + function () { + var groupMap = new Map([ + ["account_id", "8"], ["group_name", "TestFifthGroup"], ["group_notes", "note8"], + ["is_deleted", "0"], ["group_ringtone", "test8"], ["ringtone_modify_time", "0"], + ["lastest_modify_time", "0"] + ]); + return groupMap; + }, + getProfileUpdateBlockList: + function () { + var blockList = { + "phone_number": "987654321", + "content": "danminghei", + }; + return blockList; + }, + getProfileUpdateBlockListMap: + function () { + var blockListMap = new Map([ + ["types", "0"], ["phone_number", "987654321"], ["content", "danminghei"], ["time_stamp", "0"] + ]); + return blockListMap; + }, + getVoiceMail: + function () { + var voicemail = { + "phone_number": "66666", + "quicksearch_key": "777", + "display_name": "xiaoli", + "voicemail_uri": "XXXX", + "origin_type": "xxxxx", + "create_time": 0 + }; + return voicemail; + }, + getVoiceMailMap: + function () { + var map = new Map([ + ["phone_number", "66666"], ["quicksearch_key", "777"], ["display_name", "xiaoli"], + ["voicemail_uri", "XXXX"], ["origin_type", "xxxxx"], ["create_time", "0"], + ["voicemail_type", "0"], ["voice_file_size", "0"], ["voice_duration", "0"], + ["voice_status", "0"] + ]); + return map; + }, + getVoiceMailUpdate: + function () { + var voicemail = { + "phone_number": "9999999", + "quicksearch_key": "999", + "display_name": "xiaocai", + "voicemail_uri": "uuuu", + "origin_type": "iiiii", + "create_time": "999" + }; + return voicemail; + }, + getVoiceMailUpdateMap: + function () { + var map = new Map([ + ["phone_number", "9999999"], ["quicksearch_key", "999"], ["display_name", "xiaocai"], + ["voicemail_uri", "uuuu"], ["origin_type", "iiiii"], ["create_time", "999"], + ["voicemail_type", "0"], ["voice_file_size", "0"], ["voice_duration", "0"], + ["voice_status", "0"] + ]); + return map; + }, + getvoiceMailBatchInsert: + function () { + var map = new Map([["phone_number", "1600"], ["display_name", "xiaoming"], ["voice_status", "0"]]); + var map2 = new Map([["phone_number", "1600"], ["display_name", "xiaohei"], ["voice_status", "1"]]); + var map3 = new Map([["phone_number", "1600"], ["display_name", "xiaohong"], ["voice_status", "0"]]); + var map4 = new Map([["phone_number", "1600"], ["display_name", "xiaohei"], ["voice_status", "0"]]); + var map5 = new Map([["phone_number", "1600"], ["display_name", "xiaofen"], ["voice_status", "0"]]); + var array = [map, map2, map3, map4, map5]; + return array; + }, + getContactBatchCompany: + function () { + var rawContactValuesOne = { + "display_name": "fengyuanyuan", "company": "TT4900", "position": "Testers" + }; + var rawContactValuesTwo = { + "display_name": "caiboss", "company": "TT4900", "position": "developer" + }; + var rawContactValuesThree = { + "display_name": "zhangsan", "company": "TT4900", "position": "developer" + }; + var rawContactValuesFour = { + "display_name": "lisi", "company": "TT4900", "position": "developer" + }; + var rawContactValuesFive = { + "display_name": "wangwu", "company": "TT4900", "position": "developer" + }; + var listAddBluk = []; + listAddBluk[0] = rawContactValuesOne; + listAddBluk[1] = rawContactValuesTwo; + listAddBluk[2] = rawContactValuesThree; + listAddBluk[3] = rawContactValuesFour; + listAddBluk[4] = rawContactValuesFive; + return listAddBluk; + }, + getContactBatchCompanyTwo: + function () { + var contactDataValuesOne = { + "raw_contact_id": rawContactId, + "content_type": "name", + "detail_info": "xiaozhi" + }; + var contactDataValuesTwo = { + "raw_contact_id": rawContactId, + "content_type": "organization", + "detail_info": "TT", + "position": "Testers" + }; + var contactDataValuesThree = { + "raw_contact_id": rawContactId, + "content_type": "email", + "detail_info": "15844@163.com" + }; + var contactDataValuesFour = { + "raw_contact_id": rawContactId, + "content_type": "nickname", + "detail_info": "xiaozhicheng" + }; + var contactDataValuesFive = { + "raw_contact_id": rawContactId, + "content_type": "phone", + "detail_info": "111885566" + }; + var listAddBluk = []; + listAddBluk[0] = contactDataValuesOne; + listAddBluk[1] = contactDataValuesTwo; + listAddBluk[2] = contactDataValuesThree; + listAddBluk[3] = contactDataValuesFour; + listAddBluk[4] = contactDataValuesFive; + return listAddBluk; + }, + getPhoneNumberBatch: + function () { + var contactBlacklistValuesOne = { + "phone_number": "85525040585400" + }; + var contactBlacklistValuesTwo = { + "phone_number": "85525040585400" + }; + var contactBlacklistValuesThree = { + "phone_number": "85525040585400" + }; + var contactBlacklistValuesFour = { + "phone_number": "85525040585400" + }; + var contactBlacklistValuesFive = { + "phone_number": "85525040585400" + }; + var listAddBluk = [] + listAddBluk[0] = contactBlacklistValuesOne; + listAddBluk[1] = contactBlacklistValuesTwo; + listAddBluk[2] = contactBlacklistValuesThree; + listAddBluk[3] = contactBlacklistValuesFour; + listAddBluk[4] = contactBlacklistValuesFive; + return listAddBluk; + }, + getSearchMap: + function () { + var map = new Map([ + ["account_id", "1"], ["search_name", "小黄||xiaohuang||xh"], ["display_name", "小黄"], + ["phonetic_name", ""], ["photo_id", ""], ["photo_file_id", ""] + ]); + return map; + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/recovery_test.js b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/recovery_test.js new file mode 100644 index 0000000000000000000000000000000000000000..d5f41ed7a0e199005bb27e75b5f34c2b83b99a24 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/contact/recovery_test.js @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2021 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 featureAbility from '@ohos.ability.featureAbility'; +import ohosDataAbility from '@ohos.data.dataability'; +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'deccjsunit/index' +import common from './common.js'; + +const URI_CONTACTS = "dataability:///com.ohos.contactsdataability"; +const rawContactUri = "dataability:///com.ohos.contactsdataability/contacts/raw_contact"; +const backup = "dataability:///com.ohos.contactsdataability/contacts/backup"; +const recover = "dataability:///com.ohos.contactsdataability/contacts/recover"; +const deletedUri = "dataability:///com.ohos.contactsdataability/contacts/deleted_raw_contact"; + +export default function RecoveryTest() { + describe('RecoveryTest', function () { + function sleep(numberMillis) { + var now = new Date(); + var exitTime = now.getTime() + numberMillis; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) + return; + } + } + + async function contactsQuery(tag, uri, size) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': contactsQuery start ! DAHelper = ' + DAHelper); + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + var resultSet = await DAHelper.query(uri, resultColumns, condition); + console.info(tag + ' contactsQuery resultSet.rowCount is = ' + resultSet.rowCount); + console.info(tag + ' contactsQuery size is = ' + size); + expect(resultSet.rowCount == size).assertEqual(true); + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var id = resultSet.getString(resultSet.getColumnIndex("id")); + console.info(tag + ':logMessage contactsQuery id = ' + id); + var name = resultSet.getString(resultSet.getColumnIndex("display_name")); + console.info(tag + ':logMessage contactsQuery name = ' + name); + } while (resultSet.goToNextRow()) + } + } + resultSet.close(); + } catch (error) { + console.info(tag + "logMessage contactsQuery: error = " + error); + } + } + + async function rawContactInsert(name) { + console.info("------logMessage rawContactInsert is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var insertValue = { + "display_name": name, + } + try { + var rawContactId = await DAHelper.insert(rawContactUri, insertValue); + console.info('logMessage rawContactInsert: rawContactId = ' + rawContactId); + expect(rawContactId > 0).assertTrue(); + } catch (error) { + console.info('logMessage rawContactInsert: insert error = ' + error); + } + return rawContactId; + } + + async function deleteRawContact(tag) { + try { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + condition.and(); + condition.equalTo("is_deleted", "0"); + await DAHelper.delete(rawContactUri, condition); + sleep(5000); + var conditionAll = new ohosDataAbility.DataAbilityPredicates(); + conditionAll.greaterThan("id", "0"); + await DAHelper.delete(deletedUri, conditionAll); + } catch (error) { + console.info(tag + ': deleteRawContact error = ' + error); + } + } + + /** + * @tc.number recovery_test_100 + * @tc.name backup database + * @tc.desc Function test + */ + it("recovery_test_100", 0, async function (done) { + await deleteRawContact("recovery_test_100"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var updateValues = {}; + var condition = new ohosDataAbility.DataAbilityPredicates(); + try { + var updateCode = await DAHelper.update(backup, updateValues, condition); + sleep(2000); + console.info('logMessage recovery_test_100: updateCode = ' + updateCode); + expect(updateCode == 0).assertTrue(); + sleep(2000); + await contactsQuery("recovery_test_100", rawContactUri, 0); + done(); + } catch (error) { + console.info('logMessage recovery_test_100: raw_contact update error = ' + error); + done(); + } + }); + + /** + * @tc.number recovery_test_200 + * @tc.n ame recovery database + * @tc.desc Function test + */ + it("recovery_test_200", 0, async function (done) { + await deleteRawContact("recovery_test_200"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var updateValues = {}; + var condition = new ohosDataAbility.DataAbilityPredicates(); + rawContactInsert("liming"); + rawContactInsert("xiaolilili"); + sleep(2000); + var updateCode = await DAHelper.update(backup, updateValues, condition); + sleep(2000); + console.info(' recovery_test_200: backup = ' + updateCode); + expect(updateCode == 0).assertTrue(); + sleep(1000); + try { + var updateCode = await DAHelper.update(recover, updateValues, condition); + sleep(3000); + console.info('logMessage recovery_test_200: recover = ' + updateCode); + expect(updateCode == 0).assertTrue(); + await contactsQuery("recovery_test_200", rawContactUri, 2); + await deleteRawContact("recovery_test_200"); + done(); + } catch (error) { + console.info('logMessage recovery_test_200: raw_contact update error = ' + error); + done(); + } + }); + }); +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/lib/Const.js b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/lib/Const.js new file mode 100644 index 0000000000000000000000000000000000000000..f9263cd46dee1a0ffdfaa1e5ef5c29755c7e13f7 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/ets/MainAbility/test/lib/Const.js @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2021 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. + */ + +// sim slot id +export const DEFAULT_SLOTID = 0; +export const SLOTID3 = 3; +export const SLOTID2 = 2; +export const SLOTID_MINUS1 = -1; + +// sim correct password +export const CORRECT_PIN = '1234'; +export const CORRECT_PIN2 = '18099014'; + +// sim incorrect password +export const INCORRECT_PIN = '134679'; +export const INCORRECT_PIN_LEN3 = '123'; +export const INCORRECT_PUK = '134679'; +export const INCORRECT_PIN2 = '134679'; +export const INCORRECT_PIN2_LEN3 = '123'; +export const INCORRECT_PIN2_LEN9 = '123456789'; +export const INCORRECT_PUK2 = '134679'; + +// lock status response +export const LOCK_RESULT = { SUCCESS: 0, FAILURE: -1, EXCEPTION: -2 }; \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/contact_function/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03b8532c53ca563f8ed6b1e21d20ad3f67a68906 --- /dev/null +++ b/telephony/telephonyjstest/contact_function/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/resources/base/media/icon.png b/telephony/telephonyjstest/contact_function/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/contact_function/entry/src/main/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/hand.png b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/hand.png new file mode 100644 index 0000000000000000000000000000000000000000..9f1fa16ee073093b40920e273502513fa66fa980 Binary files /dev/null and b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/hand.png differ diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/icon.png b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/icon.png differ diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/images.jpg b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/images.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c75ddfc5ead15e8d49ca7cae9f97c03585565be1 Binary files /dev/null and b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/images.jpg differ diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/person.png b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/person.png new file mode 100644 index 0000000000000000000000000000000000000000..f0f540d078e6c0441a763ca2cc375a551d6cf736 Binary files /dev/null and b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/person.png differ diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/star-1-1.png b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/star-1-1.png new file mode 100644 index 0000000000000000000000000000000000000000..990c5e5ad20698c7701faf641bc80eb004a127b7 Binary files /dev/null and b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/star-1-1.png differ diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/star-1-2.png b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/star-1-2.png new file mode 100644 index 0000000000000000000000000000000000000000..450c3dd3ca68bf601bd08e5f41797d376e20d00d Binary files /dev/null and b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/star-1-2.png differ diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/star-1-3.png b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/star-1-3.png new file mode 100644 index 0000000000000000000000000000000000000000..1044869832b423a5dfc2559a395529377bd34f0c Binary files /dev/null and b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/star-1-3.png differ diff --git a/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/video/show.mp4 b/telephony/telephonyjstest/contact_function/entry/src/main/resources/rawfile/video/show.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/telephony/telephonyjstest/contact_function/signature/openharmony_sx.p7b b/telephony/telephonyjstest/contact_function/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/telephony/telephonyjstest/contact_function/signature/openharmony_sx.p7b differ diff --git a/telephony/telephonyjstest/contact_function_merge/BUILD.gn b/telephony/telephonyjstest/contact_function_merge/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9203b26a2d6201bf440011a333b0f908d73ca8d3 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 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("ActsContactFunctionMergeEtsTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":ace_demo_ets_assets", + ":ace_demo_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsContactFunctionMergeEtsTest" +} +ohos_js_assets("ace_demo_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("ace_demo_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/telephony/telephonyjstest/contact_function_merge/Test.json b/telephony/telephonyjstest/contact_function_merge/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..a7eacfaa16f1ff1f427b1e024f93329c62c16f4f --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "1800000", + "package": "com.ohos.contactfunctionmerge", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsContactFunctionMergeEtsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/config.json b/telephony/telephonyjstest/contact_function_merge/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..7491de1be85322b4725b0bc3b8bb4afba6d5c184 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/config.json @@ -0,0 +1,93 @@ +{ + "app": { + "bundleName": "com.ohos.contactfunctionmerge", + "vendor": "open", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.contactfunctionmerge", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/Button", + "pages/Blank", + "pages/DataPanel", + "pages/Divider", + "pages/Text", + "pages/RowSplit", + "pages/Scroll", + "pages/Stack", + "pages/Image", + "pages/Progress", + "pages/Qrcode", + "pages/Rating", + "pages/Span", + "pages/Slider", + "pages/Badge", + "pages/Column", + "pages/ColumnSplit", + "pages/Counter", + "pages/Flex", + "pages/GridContainer" + + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/app.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..261fadca29ff0ea310a8bc105ddd1af65e2dd2f6 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Badge.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Badge.ets new file mode 100644 index 0000000000000000000000000000000000000000..66de6f8e3b9c0360931602dd25d1511878ac63ab --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Badge.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct badge { + @State counts: number = 33 + @State message: string = 'new' + @State active: boolean = false + private content: string = "badge Page"; + + onPageShow() { + console.info('badge page show called'); + } + + onBuildDone() { + console.info('badge page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Scroll() { + Column() { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Badge({ + count: this.counts, + position: BadgePosition.Right, + maxCount: 99, + style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge') + + Text("BadgePosition.RightTop").fontSize(16) + Badge({ + count: this.counts, + position: BadgePosition.RightTop, + maxCount: 99, + style: { color: 0xFFFFFF, fontSize: '16', badgeSize: '20', badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge1') + + Text("BadgePosition.Left").fontSize(16) + Badge({ + count: this.counts, + position: BadgePosition.Left, + maxCount: 99, + style: { color: Color.Pink, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge2') + } + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Blank.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Blank.ets new file mode 100644 index 0000000000000000000000000000000000000000..a50fc719e09ab27c91f9705ac06008e936830f33 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Blank.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct blank_testcase { + @State Color: Color = Color.Pink + @State active: boolean = false + private content: string = "Blank Page" + + onPageShow() { + console.info('Blank page show called'); + } + + onBuildDone() { + console.info('Blank page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Blank(100) + .color(this.Color) + .key('blank') + Text('on/off').fontSize(18).height(60) + } + .key('flex') + .width('100%') + .height('100%') + + + } +} diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Button.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Button.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac2271ea3a13664bbbb6afe4f173abae9e66f867 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Button.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct button_testcase { + @State stateEffect: boolean = true + @State ButtonType: ButtonType = ButtonType.Circle + private content: string = "Button Page"; + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button('1.value', { type: ButtonType.Circle, stateEffect: this.stateEffect }) + .fontSize(12) + .fontWeight(FontWeight.Bold) + .fontColor(0xCCCCCC) + .height(40) + .width(40) + .key('button') + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + .padding(10) + Button() { + Text("2.Capsule") + } + .type(ButtonType.Capsule) + .stateEffect(false) + .backgroundColor('#0D9FFB') + .padding(10) + .key('button1') + + Button() { + Text("3.Normal") + }.type(ButtonType.Normal) + .backgroundColor('#0D9FFB') + .key('button2') + + }.key('flex') + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Column.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Column.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9e5c84e21ccf25419be432d8f95418fac82070a --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Column.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct column { + @State active: boolean = false + private content: string = "Column Page" + + onPageShow() { + console.info('Column page show called'); + } + + onBuildDone() { + console.info('Column page build done called'); + } + + build() { + Column({ space: 5 }) { + Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Center).width('90%').border({ width: 1 }).key('column') + + Text('alignItems(Start)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column({ space: '5' }) { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Start).width('90%').border({ width: 1 }).key('column1') + + Text('alignItems(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.End).width('90%').border({ width: 1 }).key('column2') + }.width('100%').padding({ top: 5 }) + } +} diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb0597310a15be8ab4503a3ae89385e3708fac96 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct columnSplit { + private content: string = "ColumnSplit Page" + + onPageShow() { + console.info('ColumnSplit page show called'); + } + + onBuildDone() { + console.info('ColumnSplit page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Scroll() { + Column() { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Column() { + Text('ColumnSplit').fontSize(9).fontColor(0xCCCCCC).width('90%') + ColumnSplit() { + Text('1').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('2').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('3').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + }.key('columnSplit') + .resizeable(true) + .width('90%').height('60%') + + }.width("100%") + + Column() { + Text('ColumnSplit1').fontSize(9).fontColor(0xCCCCCC).width('90%') + ColumnSplit() { + Text('1').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('2').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('3').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + }.key('columnSplit1') + .resizeable(false) + .width('90%').height('60%') + + }.width("100%") + } + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Counter.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Counter.ets new file mode 100644 index 0000000000000000000000000000000000000000..ecdbfaf10393e7a348fd76098868e6455505b07f --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Counter.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct counter { + @State value: number = 0 + @State active: boolean = false + private content: string = "Counter Page" + + onPageShow() { + console.info('Counter page show called'); + } + + onBuildDone() { + console.info('Counter page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Counter() { + Text(this.value.toString()) + }.margin(100) + .key('counter') + .onInc(() => { + this.value++ + }) + .onDec(() => { + this.value-- + }) + }.width("100%") + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/DataPanel.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/DataPanel.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c624848482b22998b2a1d137796ddaedbcf198c --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/DataPanel.ets @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct dataPanel_testcase { + @State width: string= "200" + @State height: string= "100" + @State active: boolean = false + private content: string = "DataPanel Page" + + onPageShow() { + console.info('Blank page show called'); + } + + onBuildDone() { + console.info('Blank page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + DataPanel({ values: [20, 40, 20], max: 100, type: DataPanelType.Line }) + .width(this.width) + .height(this.height) + .key('DataPanel') + .onClick(() => { + router.back() + }) + .closeEffect(false) + + DataPanel({ values: [20, 40, 20], max: 100, type: DataPanelType.Circle}) + .width(this.width) + .height(this.height) + .key('DataPanel2') + .onClick(() => { + router.back() + }) + .closeEffect(true) + DataPanel({ values: [20, 40, 20], max: 100}) + .width(this.width) + .height(this.height) + .key('DataPanel3') + .onClick(() => { + router.back() + }) + .closeEffect(false) + } + .key('flex') + .width('100%') + .height('100%') + + } +} diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Divider.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Divider.ets new file mode 100644 index 0000000000000000000000000000000000000000..02bf60779418674d1fd58127907fdb3915bd8f8f --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Divider.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct divider_textcase { + @State vertical: boolean = true + @State color: Color = Color.Red + @State strokeWidth: number = 7 + @State lineCap: LineCapStyle = LineCapStyle.Butt + @State active: boolean = false + private content: string = "Divider Page"; + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + Divider() + .lineCap(LineCapStyle.Butt) + .strokeWidth(this.strokeWidth) + .color(this.color) + .vertical(this.vertical) + .height(150) + .key('divider') + .onClick(() => { + router.back() + }) + Divider() + .lineCap(LineCapStyle.Round) + .vertical(false) + .color(Color.Green) + .strokeWidth(10) + .height(150) + .key('divider1') + Divider() + .lineCap(LineCapStyle.Square) + .color(Color.Green) + .vertical(true) + .strokeWidth(10) + .height(150) + .key('divider2') + } + .key('flex') + .width('100%') + .height('100%') + } +} + + diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Flex.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Flex.ets new file mode 100644 index 0000000000000000000000000000000000000000..a0e21251e80008c5be9f29aa52074acc5eb24a78 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Flex.ets @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct flex { + private content: string = "Flex Page" + + onPageShow() { + console.info('Flex page show called'); + } + + onBuildDone() { + console.info('Flex page build done called'); + } + + build() { + Column() { + Column({ space : 2 }) { + Text('direction:Column').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Column, + wrap: FlexWrap.NoWrap, + justifyContent: FlexAlign.Center, + alignItems:ItemAlign.Start, + alignContent: FlexAlign.Start, + }) { + Text('1').width('100%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('100%').height(20).backgroundColor(0xD2B48C) + Text('3').width('100%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex') + .height(70) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('direction:Row').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.Start, + alignItems:ItemAlign.Start, + alignContent: FlexAlign.Center, + }) { + Text('1').width('20%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('20%').height(20).backgroundColor(0xD2B48C) + Text('3').width('20%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex1') + .height(70) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('direction:RowReverse').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.RowReverse, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.End, + alignItems:ItemAlign.End, + alignContent: FlexAlign.End, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex2') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent:SpaceBetween').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceBetween, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('100%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('100%').height(20).backgroundColor(0xD2B48C) + Text('3').width('100%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex3') + .height(100) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent AND alignContent').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceEvenly, + alignContent: FlexAlign.SpaceEvenly, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex4') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent AND alignContent').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceAround, + alignContent: FlexAlign.SpaceAround, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex5') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + }.width('100%').margin({ top: 5 }) + }.width('100%') + } +} diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/GridContainer.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/GridContainer.ets new file mode 100644 index 0000000000000000000000000000000000000000..57358110413406263e70a2a5f650cbfeb22a4387 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/GridContainer.ets @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct gridContainer { + @State sizeType: SizeType = SizeType.XS + @State active: boolean = false + private content: string = "GridContainer Page" + + onPageShow() { + console.info('GridContainer page show called'); + } + + onBuildDone() { + console.info('GridContainer page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Scroll() { + Column({ space: 5 }) { + GridContainer({ columns: 12, sizeType: this.sizeType, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer') + .width('90%') + .alignItems(HorizontalAlign.Start) + + Text('Click Simulate to change the device width').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() { + Button('XS') + .onClick(() => { + this.sizeType = SizeType.XS + }).backgroundColor(0x317aff) + Button('SM') + .onClick(() => { + this.sizeType = SizeType.SM + }).backgroundColor(0x317aff) + Button('MD') + .onClick(() => { + this.sizeType = SizeType.MD + }).backgroundColor(0x317aff) + Button('LG') + .onClick(() => { + this.sizeType = SizeType.LG + }).backgroundColor(0x317aff) + } + + GridContainer({ columns: "auto", sizeType: SizeType.MD, gutter: '10', margin: '20' }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer1') + .width('90%') + .alignItems(HorizontalAlign.Center) + + GridContainer({ columns: 12, sizeType: SizeType.SM, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer2') + .width('90%') + .alignItems(HorizontalAlign.End) + + GridContainer({ columns: 12, sizeType: SizeType.LG, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer3') + .width('90%') + .alignItems(HorizontalAlign.End) + + GridContainer({ columns: 12, sizeType: SizeType.Auto, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer4') + .width('90%') + .alignItems(HorizontalAlign.End) + + }.width('100%').margin({ top: 5 }) + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Image.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Image.ets new file mode 100644 index 0000000000000000000000000000000000000000..5cc583e931f51aa8e4f2bd55decfeeb14a40afb4 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Image.ets @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct image_textcase { + @State Width: number = 0 + @State height: number = 0 + + onPageShow() { + console.info('Image page show called'); + } + + onBuildDone() { + console.info('Image page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Image page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Image("/resources/rawfile/hand.png") + .matchTextDirection(false) + .fitOriginalSize(false) + .fillColor(0xCCCCCC) + .objectFit(ImageFit.Cover) + .objectRepeat(ImageRepeat.NoRepeat) + .interpolation(ImageInterpolation.None) + .renderMode(ImageRenderMode.Original) + .autoResize(false) + .syncLoad(false) + .sourceSize({ width: 200, height: 100 }) + .alt("/resources/rawfile/person.png") + .key('image1') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.Contain) + .objectRepeat(ImageRepeat.X) + .interpolation(ImageInterpolation.High) + .renderMode(ImageRenderMode.Template) + .key('image2') + .height(180) + .width(180) + .onComplete((msg: { + width: number, + height: number + }) => { + this.Width = msg.width + this.height = msg.height + console.info('Width ----' + this.Width) + console.info('height ----' + this.height) + }) + .onError(() => { + console.info('load image fail') + }) + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.Fill) + .objectRepeat(ImageRepeat.Y) + .interpolation(ImageInterpolation.Low) + .key('image3') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.None) + .objectRepeat(ImageRepeat.XY) + .interpolation(ImageInterpolation.Medium) + .key('image4') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.ScaleDown) + .key('image5') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(4) + } + } +} + + diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Navigator.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Navigator.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c50769cf2ab045cbe48b52e294b4105a21e1c3d --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Navigator.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct navigator_testcase { + @State active: boolean = false + @State params: Object = { text: 'news' } + + onPageShow() { + console.info('Navigator page show called'); + } + + onBuildDone() { + console.info('Navigator page build done called'); + } + + build() { + Column() { + Navigator({ target: "pages/index", type: NavigationType.Back }) { + Text('Navigator test in Navigator,back') + }.active(this.active) + .key('navigator') + .params({ + data: 24 + }) + + Navigator({ target: "pages/index", type: NavigationType.Push }) { + Text('Navigator test in Navigator,push') + }.active(this.active) + .key('navigator2') + .params({ + data: 24 + }) + + Navigator({ target: "pages/index", type: NavigationType.Replace }) { + Text('Navigator test in Navigator,replace') + }.active(this.active) + .key('navigator3') + .params({ + data: 24 + }) + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } +} diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Panel.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Panel.ets new file mode 100644 index 0000000000000000000000000000000000000000..32ddabbd1ccbae3805dd462e6f04b28364d6a1e7 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Panel.ets @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct PanelExample { + @State show: boolean = true + + onPageShow() { + console.info('Panel page show called'); + } + + onBuildDone() { + console.info('Panel page build done called'); + } + + build() { + Column() { + Text('2021-09-30 Today Calendar: 1.afternoon......Click for details') + .width('90%') + .height(50) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + .padding({ left: 20 }) + .onClick(() => { + this.show = !this.show + }) + Panel(this.show) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel') + .type(PanelType.Foldable) + .mode(PanelMode.Half) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + Panel(this.show) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel2') + .type(PanelType.Minibar) + .mode(PanelMode.Mini) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + Panel(false) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel3') + .type(PanelType.Temporary) + .mode(PanelMode.Full) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + }.width('100%').height('50%').backgroundColor(0xDCDCDC).padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Progress.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Progress.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8608089fe51e1988fd305fc49db028b6c2efe76 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Progress.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct progress_testcase { + onPageShow() { + console.info('Progress page show called'); + } + + onBuildDone() { + console.info('Progress page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Progress page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Progress({ value: 20, total: 40, style: ProgressStyle.Linear }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress') + + Progress({ value: 20, total: 40, style: ProgressStyle.Eclipse }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress2') + + Progress({ value: 20, total: 40, style: ProgressStyle.Ring }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress3') + + Progress({ value: 20, total: 40, style: ProgressStyle.ScaleRing }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress4') + + Progress({ value: 20, total: 40, style: ProgressStyle.Capsule }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress5') + + } + .width(400) + .height(400) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Qrcode.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Qrcode.ets new file mode 100644 index 0000000000000000000000000000000000000000..5c0dd84eff5a6653ee5fd940662d141025a1bb4e --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Qrcode.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct qrcode_textcase { + @State Color: Color = Color.Pink + + onPageShow() { + console.info('Qrcode page show called'); + } + + onBuildDone() { + console.info('Qrcode page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`Qrcode page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + QRCode('hello world') + .color("#FFFFC0CB") + .backgroundColor(this.Color) + .width("200") + .height("100") + .key('qrcode') + } + } +} + + diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Rating.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Rating.ets new file mode 100644 index 0000000000000000000000000000000000000000..b29e26a392fca6f15a5b7f0eb4156dd3bc767c3f --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Rating.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct rating_testcase { + @State rating: number = 2 + + onPageShow() { + console.info('Rating page show called'); + } + + onBuildDone() { + console.info('Rating page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Rating page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Rating({ rating: 2, indicator: false }) + .stepSize(0.5) + .stars(5) + .starStyle({ + backgroundUri: '/resources/rawfile/star-1-1.png', + foregroundUri: '/resources/rawfile/star-1-3.png', + secondaryUri: '/resources/rawfile/star-1-2.png' + }) + .onChange((value: number) => { + this.rating = value + }) + .key('rating1') + Rating({ rating: 2, indicator: true }) + .stepSize(0.5) + .stars(5) + .starStyle({ + backgroundUri: '/resources/rawfile/star-1-1.png', + foregroundUri: '/resources/rawfile/star-1-3.png', + secondaryUri: '/resources/rawfile/star-1-2.png' + }) + .key('rating2') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/RowSplit.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/RowSplit.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f4f397b13b83e98ac643633309b02858f337eb0 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/RowSplit.ets @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct rowSplit_testcase { + @State resizeable: boolean = false + private content: string = "rowSplit Page"; + + onPageShow() { + console.info('RowSplit page show called'); + } + + onBuildDone() { + console.info('RowSplit page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + RowSplit() { + Column() { + Text('Demo1.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + + Column() { + Text('Demo2.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + } + .height(100) + .key('rowSplit') + .resizeable(this.resizeable) + .onClick(() => { + router.back() + }) + + RowSplit() { + Column() { + Text('Demo3.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + + Column() { + Text('Demo4.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + }.height(100) + .key('rowSplit1') + .resizeable(true) + } + .key('flex') + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Scroll.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Scroll.ets new file mode 100644 index 0000000000000000000000000000000000000000..363089d22580febed16b983d8a4b2877cde52bec --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Scroll.ets @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct scroll_testcase { + @State scrollBarWidth: number = 20 + @State scrollable: ScrollDirection = ScrollDirection.None + @State scrollBarColor: Color = Color.Pink + @State scrollBar: BarState= BarState.On + private value1: Array = [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30] + @State edge: Edge= Edge.Top + private content: string = "Scroll Page"; + scroller: Scroller = new Scroller(); + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Scroll(this.scroller) { + Column() { + ForEach( + this.value1, + item => { + Text(`${item}`) + .fontSize(15) + .width(400) + .margin(10) + .height(70) + .backgroundColor(0xfff5deb3) + }, + item => item + ) + } + } + .scrollable(ScrollDirection.Vertical) + .scrollBar(this.scrollBar) + .scrollBarColor(this.scrollBarColor) + .scrollBarWidth(this.scrollBarWidth) + .key('scroll') + .width(400) + .height(200) + .onScroll((xOffset: number, yOffset: number) => { + console.info(` current offset is ${xOffset} ${yOffset}`) + }) + .onScrollEnd(() => { + console.info(` now on scroll end`) + }) + .onScrollEdge((side: Edge) => { + console.info(`To the edge`) + }) + Scroll() { + Row() { + Text('scroll uppppp') + .width(60) + .height(100) + .backgroundColor(Color.Yellow) + .margin({ + right: 5, + left: 5 + }) + .key('text') + + Text('scroll to') + .width(60) + .height(100) + .backgroundColor(Color.Green) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollTo({ + xOffset: 100, + yOffset: 100, + }) + }) + Text('scroll page') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollPage({ + next: true + }) + }) + Text('scroll Edge') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollEdge(Edge.Top) + }) + Text('scroll Edge') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.currentOffset() + }) + Text('scroll to index') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollToIndex(0) + console.info(` now on scroll end`) + }) + } + } + .key('scroll1') + .height(100) + .scrollable(ScrollDirection.Horizontal) + + Scroll() { + Column() { + Text("start").fontSize(30) + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + } + } + .padding(10) + .scrollable(ScrollDirection.None) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Red) + .scrollBarWidth(5) + .width(300) + .height(200) + .key('scroll2') + + Scroll() { + Column() { + Text("start").fontSize(30) + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + } + } + .padding(10) + .scrollable(ScrollDirection.Free) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Red) + .scrollBarWidth(5) + .width(300) + .height(200) + .key('scroll3') + } + .key('flex') + + } +} diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Slider.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Slider.ets new file mode 100644 index 0000000000000000000000000000000000000000..625cd02874f16e9debb7638322624f890e08fa62 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Slider.ets @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct slider { + @State inSetValue: number= 40 + @State outSetValue: number= 40 + @State direction: Axis= Axis.Horizontal + @State Begin: number = SliderChangeMode.Begin + + onPageShow() { + console.info('Slider page show called'); + } + + onBuildDone() { + console.info('Slider page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Slider page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Slider({ + value: this.outSetValue, + min: 0, + max: 100, + step: 1, + direction: Axis.Horizontal, + reverse: false, + style: SliderStyle.OutSet + }) + .blockColor('#FFFF0000') + .selectedColor('#FF0000FF') + .trackColor('#FF808080') + .minLabel('10') + .maxLabel('10') + .showTips(false) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + this.outSetValue = value + this.Begin = mode + console.info('value: ' + value + '---mode: ' + mode) + }) + .width("100") + .height("100") + .key('slider1') + Slider({ + value: 40, + min: 0, + max: 100, + step: 1, + style: SliderStyle.InSet + }) + .blockColor(Color.Red) + .selectedColor(Color.Blue) + .trackColor(Color.Gray) + .showTips(true) + .showSteps(true) + .key('slider2') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Span.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Span.ets new file mode 100644 index 0000000000000000000000000000000000000000..df5a71043f1ae000b822646f6b56df7ae103fa1f --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Span.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct span_textcase { + + onPageShow() { + console.info('Span page show called'); + } + + onBuildDone() { + console.info('Span page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text() { + Span('Test Span demo') + .decoration({ type: TextDecorationType.LineThrough, "color": Color.Red }) + .textCase(TextCase.UpperCase) + .fontColor(Color.Blue) + .fontSize("20fp") + .letterSpacing(5) + .fontFamily("sans-serif") + .fontWeight(FontWeight.Bold) + .fontStyle(FontStyle.Italic) + .key('span1') + Span('The second test Span demo') + .textCase(TextCase.LowerCase) + .fontColor(Color.Black) + .letterSpacing('5') + .fontSize(30) + .key('span2') + Span('The third test Span demo') + .textCase(TextCase.Normal) + .fontColor(Color.Yellow) + .fontSize("30fp") + .key('span3') + } + } + .width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(4) + } + } +} + + + diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Stack.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Stack.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a694889f0e768afbd3e3af6a17c3af9d8738cfb --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Stack.ets @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct stack_testcase { + @State alignContent: Alignment = Alignment.Bottom + private content: string = "Stack Page"; + + onPageShow() { + console.info('Stack page show called'); + } + + onBuildDone() { + console.info('Stack page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Stack({ alignContent: this.alignContent }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + } + .width('100%') + .height(80) + .margin({ top: 5 }) + .key('stack') + .onClick(() => { + router.back() + }) + + Stack({ alignContent: Alignment.BottomStart }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack1') + + Stack({ alignContent: Alignment.BottomEnd }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack2') + + Stack({ alignContent: Alignment.Start }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack3') + + Stack({ alignContent: Alignment.Center }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack4') + + Stack({ alignContent: Alignment.End }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack5') + + Stack({ alignContent: Alignment.Top }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack6') + + Stack({ alignContent: Alignment.TopStart }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack7') + + Stack({ alignContent: Alignment.TopEnd }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack8') + } + .key('flex') + .width('100%') + .height('100%') + + } +} + diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Text.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Text.ets new file mode 100644 index 0000000000000000000000000000000000000000..fbd1415dc815b0f1966476c430f7d69e28e587ee --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/Text.ets @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2021 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. + */ + +// @ts-nocheck +import router from '@system.router' + +var paramInfo = router.getParams() +console.info("cd paramInfo" + JSON.stringify(paramInfo)) + +@Entry +@Component +struct text_textcase { + @State textAlign: TextAlign= TextAlign.End + @State lineHeight: string= '15fp' + @State overflow: TextOverflow = TextOverflow.Ellipsis + @State textOverflow: textOverflow<{ "overflow": TextOverflow }> = { "overflow": this.overflow } + @State maxLines: number = 2 + @State baselineOffset: number = 0 + @State textCase: TextCase= TextCase.Normal + @State decoration: decoration<{ + type: TextDecorationType, + color: Color + }> = { type: TextDecorationType.Underline, color: Color.Red } + @State color: Color = Color.Red + @State width: string= "200" + @State height: string= "100" + @State size: size = { width: 200, height: 100 } + @State marginBottom: string = "10px" + @State marginTop: string = "10px" + @State marginLeft: string = "10px" + @State marginRingt: string= "10px" + @State paddingBottom: string= "5" + @State paddingTop: string= "5" + @State paddingLeft: string= "5" + @State paddingRingt: string= "5" + @State constraintSize: constraintSize = { minWidth: 20, maxWidth: 200, minHeight: 0, maxHeight: 50 } + @State layoutPriority: string= "9px" + @State layoutWeight: string = "10px" + @State align: Alignment = Alignment.Center + @State direction: Direction = Direction.Auto + @State position: position<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State markAnchor: markAnchor<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State offset: offset<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State flexGrow: number = 5 + @State flexShrink: number = 2 + @State flexBasis: number = 0 + @State alignSelf: ItemAlign = ItemAlign.Auto + @State borderStyle: BorderStyle = BorderStyle.Dashed + @State borderRadius: number = 10 + @State borderWidth: string= "4px" + @State borderColor: Color= Color.Blue + @State backgroundColor: Color = Color.Pink + @State backgroundImageSize: ImageSize = ImageSize.Cover + @State backgroundImagePosition: Alignment= Alignment.Center + @State opacity: number= 1 + @State visibility: Visibility= Visibility.Visible + @State enabled: boolean = false + @State zIndex: number = 1 + @State fontStyle: FontStyle = FontStyle.Italic + @State fontSize: number = 15 + @State minFontSize: number = 15 + @State maxFontSize: number = 15 + @State letterSpacing: number= 10 + @State fontWeight: FontWeight= FontWeight.Bold + @State fontColor: Color= Color.Black + @State active: boolean = false + private content: string = "Text Page"; + + onPageShow() { + console.info('Text page show called'); + } + + onBuildDone() { + console.info('Text page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .width(this.width) + .height(this.height) + .padding({ bottom: this.paddingBottom, top: this.paddingTop, right: this.paddingRingt, left: this.paddingLeft }) + .margin({ bottom: this.marginBottom, top: this.marginTop, right: this.marginRingt, left: this.marginLeft }) + .constraintSize(this.constraintSize) + .layoutWeight(this.layoutWeight) + .align(this.align) + .direction(this.direction) + .position(this.position) + .markAnchor(this.markAnchor) + .offset(this.offset) + .flexBasis(this.flexBasis) + .flexGrow(this.flexGrow) + .flexShrink(this.flexShrink) + .alignSelf(this.alignSelf) + .borderStyle(this.borderStyle) + .borderRadius(this.borderRadius) + .borderWidth(this.borderWidth) + .borderColor(this.borderColor) + .backgroundColor(this.backgroundColor) + .opacity(this.opacity) + .visibility(this.visibility) + .enabled(this.enabled) + .zIndex(this.zIndex) + .fontColor(this.fontColor) + .fontSize(this.fontSize) + .minFontSize(this.minFontSize) + .letterSpacing(this.letterSpacing) + .maxFontSize(this.maxFontSize) + .fontWeight(this.fontWeight) + .fontStyle(this.fontStyle) + .fontFamily("sans-serif") + .textAlign(this.textAlign) + .textOverflow(this.textOverflow) + .lineHeight(this.lineHeight) + .baselineOffset(this.baselineOffset) + .maxLines(2) + .textCase(this.textCase) + .decoration(this.decoration) + .aspectRatio(1) + .fontColor(Color.Black) + .key('Text') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .size({ width: 100, height: 50 }) + .padding({ bottom: 5, top: 5, right: 5, left: 10 }) + .margin({ bottom: 15, top: 10, right: 10, left: 10 }) + .fontSize('13') + .textAlign(TextAlign.Start) + .align(Alignment.Start) + .direction(Direction.Ltr) + .alignSelf(ItemAlign.Start) + .borderStyle(BorderStyle.Dotted) + .borderWidth(2) + .visibility(Visibility.Hidden) + .enabled(true) + .fontWeight(FontWeight.Normal) + .textAlign(TextAlign.Start) + .textOverflow(TextOverflow.Clip) + .maxLines(2) + .textCase(TextCase.LowerCase) + .decoration({ "type": TextDecorationType.LineThrough, "color": Color.Red }) + .fontColor(Color.White) + .key('Text1') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .width('100%') + .textAlign(TextAlign.Center) + .align(Alignment.TopEnd) + .direction(Direction.Rtl) + .alignSelf(ItemAlign.Center) + .borderStyle(BorderStyle.Solid) + .borderWidth(2) + .visibility(Visibility.None) + .fontWeight(FontWeight.Bolder) + .textAlign(TextAlign.Center) + .textOverflow(TextOverflow.None) + .textCase(TextCase.UpperCase) + .decoration({ "type": TextDecorationType.None, "color": Color.Red }) + .fontColor(Color.Blue) + .key('Text2') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.Top) + .alignSelf(ItemAlign.End) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Lighter) + .decoration({ type: TextDecorationType.Overline, color: Color.Red }) + .fontColor(Color.Gray) + .key('Text3') + Text('Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.TopStart) + .alignSelf(ItemAlign.Baseline) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Medium) + .fontColor(Color.Brown) + .key('Text4') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.End) + .alignSelf(ItemAlign.Stretch) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Regular) + .fontColor(Color.Grey) + .key('Text5') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.BottomEnd) + .width('100%') + .fontColor(Color.Orange) + .key('Text6') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.Bottom) + .width('100%') + .fontColor(Color.Yellow) + .key('Text7') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.BottomStart) + .width('100%') + .key('Text8') + + } + .key('flex') + .width('100%') + .height('100%') + } +} + + diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/index.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..10359134da915c9b44b0836ba4881bca71f43f33 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,65 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 file from '@system.file'; + +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; +import testsuite from "../test/List.test.ets"; +import featureAbility from "@ohos.ability.featureAbility"; + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + Want.parameters['timeout'] = 100000 + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('ACE ETS TEST') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/test/List.test.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..33a58e6a8de77a60e1d785efeecc9d736c7f8634 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2021 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. + */ + +//contact import +import ContactMergeTest from './contact/ContactMerge_test.js' + +export default function testsuite() { + //contact + ContactMergeTest(); +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/test/Utils.ets b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..65f70088ddb62bcf80f4e0ec07dc841a8ab033f0 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,119 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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. + */ + +export default class Utils { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + static notCheck = true; + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } + + static async swipe(downX, downY, upX, upY, steps) { + console.info('start to swipe') + this.drags(downX, downY, upX, upY, steps, false) + } + + static async drag(downX, downY, upX, upY, steps) { + console.info('start to drag') + this.drags(downX, downY, upX, upY, steps, true) + } + + static async drags(downX, downY, upX, upY, steps, drag) { + var xStep; + var yStep; + var swipeSteps; + var ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + var downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('start to move') + if (drag) { + await this.sleep(500) + } + for (var i = 1;i <= swipeSteps; i++) { + var movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('start to up') + if (drag) { + await this.sleep(100) + } + var upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) + } +} + + + + diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/test/contact/ContactMerge_test.js b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/test/contact/ContactMerge_test.js new file mode 100644 index 0000000000000000000000000000000000000000..76dcd4cc0d9fe7aaf92597c265ce2accbef0f033 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/test/contact/ContactMerge_test.js @@ -0,0 +1,1873 @@ +/* + * Copyright (c) 2021 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 featureAbility from '@ohos.ability.featureAbility'; +import ohosDataAbility from '@ohos.data.dataability'; +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'deccjsunit/index' + +const URI_CONTACTS = "dataability:///com.ohos.contactsdataability"; +const rawContactUri = "dataability:///com.ohos.contactsdataability/contacts/raw_contact"; +const contactDataUri = "dataability:///com.ohos.contactsdataability/contacts/contact_data"; + +const autoMergeUri = "dataability:///com.ohos.contactsdataability/contacts/raw_contact/auto_merge"; +const splitUri = "dataability:///com.ohos.contactsdataability/contacts/raw_contact/split_contact"; +const manualMergeUri = "dataability:///com.ohos.contactsdataability/contacts/raw_contact/manual_merge"; +const uriQueryMergeList = "dataability:///com.ohos.contactsdataability/contacts/raw_contact/query_merge_list"; +const deletedUri = "dataability:///com.ohos.contactsdataability/contacts/deleted_raw_contact"; + +export default function ContactMergeTest() { + describe('ContactMergeTest', function () { + console.info("ContactMergeTest start!"); + + function sleep(numberMillis) { + var now = new Date(); + var exitTime = now.getTime() + numberMillis; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) + return; + } + } + + async function contactDataInsert1(DAHelper, rawContactIdFirst) { + var contactDataValues = { + "raw_contact_id": rawContactIdFirst, "content_type": "name", "detail_info": "xiaoli" + }; + try { + var contactDataId1 = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info("logMessage contact_auto_merge_and_spilt_test_100: contactDataId1 = " + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_auto_merge_and_spilt_test_100: contact_data_1 insert error = ' + error); + } + } + + async function contactDataInsert2(DAHelper, rawContactIdSecond) { + var contactDataValues = { + "raw_contact_id": rawContactIdSecond, "content_type": "name", "detail_info": "xiaoli" + }; + try { + var contactDataId2 = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info("logMessage contact_auto_merge_and_spilt_test_100: contactDataId2 = " + contactDataId2); + expect(contactDataId2 > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_auto_merge_and_spilt_test_100: contact_data_2 insert error = ' + error); + } + } + + async function autoMerge(DAHelper, rawContactIdFirst) { + var condition = new ohosDataAbility.DataAbilityPredicates(); + var updateValues = {}; + try { + sleep(4000); + var autoMergeCode = await DAHelper.update(autoMergeUri, updateValues, condition); + console.info("logMessage contact_auto_merge_and_spilt_test_100: autoMergeCode = " + autoMergeCode); + expect(autoMergeCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactIdFirst.toString()); + await contactMergeQuery(map, "contact_auto_merge_and_spilt_test_100", 2); + sleep(2000); + await contactSplit(DAHelper, rawContactIdFirst); + await deleteAll(rawContactUri, "contact_auto_merge_and_spilt_test_100"); + await deleteAll(contactDataUri, "contact_auto_merge_and_spilt_test_100"); + } catch (error) { + console.info("logMessage contact_auto_merge_and_spilt_test_100: auto_merge error = " + error); + } + } + + async function contactSplit(DAHelper, rawContactIdFirst) { + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + var array = [rawContactIdFirst.toString()]; + condition2.in("raw_contact_id", array); + var updateValues2 = {}; + try { + var splitCode = await DAHelper.update(splitUri, updateValues2, condition2); + sleep(4000); + console.info('logMessage contact_auto_merge_and_spilt_test_100 splitCode = ' + splitCode); + expect(splitCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactIdFirst.toString()); + await contactMergeQuery(map, "contact_auto_merge_and_spilt_test_100", 1); + } catch (error) { + console.info('logMessage contact_auto_merge_and_spilt_test_100 split error = ' + error); + } + } + + async function deleteAll(uri, tag) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + var deleteCode = await DAHelper.delete(uri, condition); + console.info(tag + ': deleteAll deleteCode = ' + deleteCode); + expect(deleteCode == 0).assertTrue(); + } + + async function contactMergeQuery(map, tag, size) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ' : contactMergeQuery start ! DAHelper = ' + DAHelper); + var resultColumns = ["contact_id"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + console.info(tag + ' : map_id = ' + map.get("id")); + condition.equalTo("id", map.get("id")); + try { + var resultSetID = await DAHelper.query(rawContactUri, resultColumns, condition); + sleep(1000); + var conatctID; + if (resultSetID.goToFirstRow()) { + do { + conatctID = resultSetID.getString(resultSetID.getColumnIndex("contact_id")); + console.info(tag + ' : contact_id = ' + conatctID); + } while (resultSetID.goToNextRow()); + } + resultSetID.close(); + var pre = new ohosDataAbility.DataAbilityPredicates(); + pre.equalTo("contact_id", conatctID); + var newResultColumns = []; + var resultSet = await DAHelper.query(rawContactUri, newResultColumns, pre); + sleep(1000); + console.info(tag + ' : contactMergeQuery start ! rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == size).assertEqual(true); + resultSet.close(); + } catch (error) { + console.info(tag + " : logMessage contactMergeQuery: error = " + error); + } + } + + async function updateContactData(updateDataValue, contactDataId, testName) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + var updateValues = { + "detail_info": updateDataValue + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", contactDataId.toString()); + var code = await DAHelper.update(contactDataUri, updateValues, condition); + console.info(testName + " updateContactData: code = " + code); + sleep(3000); + } + + async function insertContactData(DAHelper, rawContactId, detailInfo, types, tag) { + var size = detailInfo.length; + for (var i = 0; i < size; i++) { + var contactDataValues = { + "raw_contact_id": rawContactId.toString(), + "content_type": types[i], + "detail_info": detailInfo[i] + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(2000); + expect(contactDataId > 0).assertTrue(); + console.info(tag + ' logMessage : insert contactDataId = ' + contactDataId); + } catch (error) { + console.info('logMessage : contact_data_1 insert error = ' + error); + } + } + } + + async function insertContactDataSingle(DAHelper, rawContactId, detailInfo, type) { + var size = detailInfo.length; + var contactDataValues = { + "raw_contact_id": rawContactId, "content_type": type, "detail_info": detailInfo + }; + try { + var contactDataId1 = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + expect(contactDataId1 > 0).assertTrue(); + } catch (error) { + console.info('logMessage : contact_data_1 insert error = ' + error); + } + return contactDataId1; + } + + async function manualMergeList(DAHelper, rawContactList, testName) { + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + condition2.in("raw_contact_id", rawContactList); + var updateValues2 = {}; + try { + var ManualMergeCode = await DAHelper.update(manualMergeUri, updateValues2, condition2); + sleep(1000); + console.info("logMessage " + testName + " ManualMergeCode = " + ManualMergeCode); + expect(ManualMergeCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactList[0].toString()); + await contactMergeQuery(map, testName, rawContactList.length); + await deleteAll(rawContactUri, testName); + await deleteAll(contactDataUri, testName); + } catch (error) { + console.info("logMessage " + testName + " manual_merge error = " + error); + } + } + + /** + * @tc.number contact_autoMerge_and_spilt_test_100 + * @tc.name Two contacts without mobile phone number with the same name are automatically merged and split + * @tc.desc Function test + */ + it("contact_autoMerge_and_spilt_test_100", 0, async function (done) { + console.info("------logMessage contact_auto_merge_and_spilt_test_100 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues1 = { + "display_name": "xiaoli" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_auto_merge_and_spilt_test_100: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + await contactDataInsert1(DAHelper, rawContactIdFirst); + } catch (error) { + console.info('logMessage contact_auto_merge_and_spilt_test_100: raw_contact_1 insert error = ' + error); + done(); + } + + var insertRawContactValues2 = { + "display_name": "xiaoli" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_auto_merge_and_spilt_test_100: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + await contactDataInsert2(DAHelper, rawContactIdSecond); + } catch (error) { + console.info('logMessage contact_auto_merge_and_spilt_test_100: raw_contact_2 insert error = ' + error); + done(); + } + + await autoMerge(DAHelper, rawContactIdFirst); + done(); + }); + + /** + * @tc.number contact_manualMerge_test_200 + * @tc.name Two contacts with the same name, one with a mobile phone number and the other without a mobile phone + * number, call the manual merge interface + * @tc.desc Function test + */ + it("contact_manualMerge_test_200", 0, async function (done) { + console.info("------logMessage contact_manualMerge_test_200 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues1 = { + "display_name": "xiaoming" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_manualMerge_test_200: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + await manualMergeDataInsert(DAHelper, rawContactIdFirst); + } catch (error) { + console.info('logMessage contact_manualMerge_test_200: raw_contact_1 insert error = ' + error); + done(); + } + + var insertRawContactValues2 = { + "display_name": "xiaoming" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_manualMerge_test_200: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + await manualMergeDataInsertTwo(DAHelper, rawContactIdSecond); + } catch (error) { + console.info('logMessage contact_manualMerge_test_200: raw_contact_2 insert error = ' + error); + done(); + } + var rawContactIds = [rawContactIdFirst + "", rawContactIdSecond + ""]; + await manualMergeList(DAHelper, rawContactIds, "contact_query_merge_list_test_2000"); + done(); + }); + + async function manualMergeDataInsert(DAHelper, rawContactIdFirst) { + var contactDataValuesOne = { + "raw_contact_id": rawContactIdFirst, + "content_type": "name", + "detail_info": "xiaoming" + }; + var contactDataValuesTwo = { + "raw_contact_id": rawContactIdFirst, + "content_type": "phone", + "detail_info": "123456789", + }; + var listAddBluk = []; + listAddBluk[0] = contactDataValuesOne; + listAddBluk[1] = contactDataValuesTwo; + try { + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + sleep(1000); + console.info("logMessage contact_manualMerge_test_200: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_manualMerge_test_200: batch insert error = " + error) + } + } + + async function manualMergeDataInsertTwo(DAHelper, rawContactIdSecond) { + var contactDataValues = { + "raw_contact_id": rawContactIdSecond, "content_type": "name", "detail_info": "xiaoming" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info("logMessage contact_manualMerge_test_200: contactDataId = " + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_manualMerge_test_200: contact_data_2 insert error = " + error) + } + } + + /** + * @tc.number contact_autoMerge_test_300 + * @tc.name Two contacts with the same name have a mobile phone number, and the mobile phone numbers are the + * same. Call the automatic merge interface + * @tc.desc Function test + */ + it("contact_autoMerge_test_300", 0, async function (done) { + console.info("------logMessage contact_autoMerge_test_300 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues1 = { + "display_name": "xiaohong" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_autoMerge_test_300: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + await autoMergeDataInsert(DAHelper, rawContactIdFirst); + } catch (error) { + console.info('logMessage contact_autoMerge_test_300: raw_contact_1 insert error = ' + error); + done(); + } + + var insertRawContactValues2 = { + "display_name": "xiaohong" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_autoMerge_test_300: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + await autoMergeDataInsertTwo(DAHelper, rawContactIdSecond); + } catch (error) { + console.info('logMessage contact_autoMerge_test_300: raw_contact_2 insert error = ' + error); + done(); + } + + await autoMerger(DAHelper, rawContactIdFirst, "contact_autoMerge_test_300"); + done(); + }); + + async function autoMergeDataInsert(DAHelper, rawContactIdFirst) { + var contactDataValuesOne = { + "raw_contact_id": rawContactIdFirst, + "content_type": "name", + "detail_info": "xiaohong" + }; + var contactDataValuesTwo = { + "raw_contact_id": rawContactIdFirst, + "content_type": "phone", + "detail_info": "123465", + }; + var listAddBluk = []; + listAddBluk[0] = contactDataValuesOne; + listAddBluk[1] = contactDataValuesTwo; + try { + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + sleep(1000); + console.info("logMessage contact_autoMerge_test_300: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_autoMerge_test_300: batch insert1 error = " + error) + } + } + + async function autoMergeDataInsertTwo(DAHelper, rawContactIdSecond) { + var contactDataValuesThree = { + "raw_contact_id": rawContactIdSecond, + "content_type": "name", + "detail_info": "xiaohong" + }; + var contactDataValuesFour = { + "raw_contact_id": rawContactIdSecond, + "content_type": "phone", + "detail_info": "123465", + }; + var listAddBluk2 = []; + listAddBluk2[0] = contactDataValuesThree; + listAddBluk2[1] = contactDataValuesFour; + try { + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk2); + sleep(1000); + console.info("logMessage contact_autoMerge_test_300: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_autoMerge_test_300: batch insert2 error = " + error) + } + } + + async function autoMerger(DAHelper, rawContactIdFirst, testName) { + var condition = new ohosDataAbility.DataAbilityPredicates(); + var updateValues = {}; + try { + var autoMergeCode = await DAHelper.update(autoMergeUri, updateValues, condition); + sleep(1000); + console.info("logMessage " + testName + "autoMergeCode = " + autoMergeCode); + expect(autoMergeCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactIdFirst.toString()); + await contactMergeQuery(map, testName, 2); + await deleteAll(rawContactUri, testName); + await deleteAll(contactDataUri, testName); + } catch (error) { + console.info("logMessage " + testName + "auto_merge error =" + error); + } + } + + async function autoNotMerger(DAHelper, rawContactIdFirst, testName) { + var condition = new ohosDataAbility.DataAbilityPredicates(); + var updateValues = {}; + try { + sleep(2000); + var autoMergeCode = await DAHelper.update(autoMergeUri, updateValues, condition); + console.info("logMessage " + testName + "autoMergeCode = " + autoMergeCode); + expect(autoMergeCode == -1).assertTrue(); + var map = new Map(); + map.set("id", rawContactIdFirst.toString()); + await contactMergeQuery(map, testName, 1); + await deleteAll(rawContactUri, testName); + await deleteAll(contactDataUri, testName); + } catch (error) { + console.info("logMessage " + testName + "auto_merge error =" + error); + } + } + + /** + * @tc.number contact_manualMerge_test_400 + * @tc.name Two contacts with the same name have a mobile phone number, and the mobile phone numbers are + * different. Call the manual merge interface + * @tc.desc Function test + */ + it("contact_manualMerge_test_400", 0, async function (done) { + console.info("------logMessage contact_manualMerge_test_400 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues1 = { + "display_name": "xiaozhang" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_manualMerge_test_400: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + await noequalPhoneDataInsert(DAHelper, rawContactIdFirst) + } catch (error) { + console.info('logMessage contact_manualMerge_test_400: raw_contact_1 insert error = ' + error); + done(); + } + + var insertRawContactValues2 = { + "display_name": "xiaozhang" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_manualMerge_test_400: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + await noequalPhoneDataInsertTwo(DAHelper, rawContactIdSecond) + } catch (error) { + console.info('logMessage contact_manualMerge_test_400: raw_contact_2 insert error = ' + error); + done(); + } + + await noequalManualMerge(DAHelper, rawContactIdFirst, rawContactIdSecond); + done(); + }); + + async function noequalPhoneDataInsert(DAHelper, rawContactIdFirst) { + var contactDataValuesOne = { + "raw_contact_id": rawContactIdFirst, + "content_type": "name", + "detail_info": "xiaozhang" + }; + var contactDataValuesTwo = { + "raw_contact_id": rawContactIdFirst, + "content_type": "phone", + "detail_info": "147852", + }; + var listAddBluk = []; + listAddBluk[0] = contactDataValuesOne; + listAddBluk[1] = contactDataValuesTwo; + try { + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + sleep(1000); + console.info("logMessage contact_manualMerge_test_400: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_manualMerge_test_400: batch insert1 error = " + error) + } + } + + async function noequalPhoneDataInsertTwo(DAHelper, rawContactIdSecond) { + var contactDataValuesThree = { + "raw_contact_id": rawContactIdSecond, + "content_type": "name", + "detail_info": "xiaozhang" + }; + var contactDataValuesFour = { + "raw_contact_id": rawContactIdSecond, + "content_type": "phone", + "detail_info": "996369", + }; + var listAddBluk2 = []; + listAddBluk2[0] = contactDataValuesThree; + listAddBluk2[1] = contactDataValuesFour; + try { + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk2); + sleep(1000); + console.info("logMessage contact_manualMerge_test_400: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_manualMerge_test_400: batch insert2 error = " + error) + } + } + + async function noequalManualMerge(DAHelper, rawContactIdFirst, rawContactIdSecond) { + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + var id = [rawContactIdFirst.toString(), rawContactIdSecond.toString()]; + condition2.in("raw_contact_id", id); + var updateValues2 = {}; + try { + var ManualMergeCode = await DAHelper.update(manualMergeUri, updateValues2, condition2); + sleep(1000); + console.info("logMessage contact_manualMerge_test_400 ManualMergeCode = " + ManualMergeCode); + expect(ManualMergeCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactIdFirst.toString()); + await contactMergeQuery(map, "contact_manualMerge_test_400", 2); + await deleteAll(rawContactUri, "contact_manualMerge_test_400"); + await deleteAll(contactDataUri, "contact_manualMerge_test_400"); + } catch (error) { + console.info("logMessage contact_manualMerge_test_400 manual_merge error = " + error); + } + } + + /** + * @tc.number contact_manualMerge_test_500 + * @tc.name Two contacts with the same name, one with two mobile phone numbers and the other without mobile phone + * numbers, call the manual merge interface + * @tc.desc Function test + */ + it("contact_manualMerge_test_500", 0, async function (done) { + console.info("------logMessage contact_manualMerge_test_500 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var insertRawContactValues1 = { + "display_name": "xiaozhou" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_manualMerge_test_500: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + await manualDataInsert(DAHelper, rawContactIdFirst) + } catch (error) { + console.info('logMessage contact_manualMerge_test_500: raw_contact_1 insert error = ' + error); + done(); + } + + var insertRawContactValues2 = { + "display_name": "xiaozhou" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_manualMerge_test_500: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + await manualDataInsertTwo(DAHelper, rawContactIdSecond) + } catch (error) { + console.info('logMessage contact_manualMerge_test_500: raw_contact_2 insert error = ' + error); + done(); + } + await hasOneNoPhoneManualMerge(DAHelper, rawContactIdFirst, rawContactIdSecond); + done(); + }); + + async function manualDataInsert(DAHelper, rawContactIdFirst) { + var contactDataValuesOne = { + "raw_contact_id": rawContactIdFirst, + "content_type": "name", + "detail_info": "xiaozhou" + }; + var contactDataValuesTwo = { + "raw_contact_id": rawContactIdFirst, + "content_type": "phone", + "detail_info": "123456789", + }; + var contactDataValuesThree = { + "raw_contact_id": rawContactIdFirst, + "content_type": "phone", + "detail_info": "996632", + }; + var listAddBluk = []; + listAddBluk[0] = contactDataValuesOne; + listAddBluk[1] = contactDataValuesTwo; + listAddBluk[2] = contactDataValuesThree; + try { + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + sleep(1000); + console.info("logMessage contact_manualMerge_test_500: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_manualMerge_test_500: batch insert1 error = " + error) + } + } + + async function manualDataInsertTwo(DAHelper, rawContactIdSecond) { + var contactDataValuesFour = { + "raw_contact_id": rawContactIdSecond, + "content_type": "name", + "detail_info": "xiaozhou" + }; + try { + var contactDataId = await DAHelper.insert(contactDataUri, contactDataValuesFour); + sleep(1000); + console.info("logMessage contact_manualMerge_test_500: contactDataId = " + contactDataId); + expect(contactDataId > 0).assertTrue(); + } catch (error) { + console.info("logMessage contact_manualMerge_test_500: contact_data insert error = " + error) + } + } + + async function hasOneNoPhoneManualMerge(DAHelper, rawContactIdFirst, rawContactIdSecond) { + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + var id = [rawContactIdFirst.toString(), rawContactIdSecond.toString()]; + condition2.in("raw_contact_id", id); + var updateValues2 = {}; + try { + var ManualMergeCode = await DAHelper.update(manualMergeUri, updateValues2, condition2); + sleep(1000); + console.info("logMessage contact_manualMerge_test_500 ManualMergeCode = " + ManualMergeCode); + expect(ManualMergeCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactIdFirst.toString()); + await contactMergeQuery(map, "contact_manualMerge_test_500", 2); + await deleteAll(rawContactUri, "contact_manualMerge_test_500"); + await deleteAll(contactDataUri, "contact_manualMerge_test_500"); + } catch (error) { + console.info("logMessage contact_manualMerge_test_500 manual_merge error = " + error); + } + } + + /** + * @tc.number contact_autoMerge_test_600 + * @tc.name Batch add contacts, then call auto merge interface. + * @tc.desc Function test + */ + it("contact_autoMerge_test_600", 0, async function (done) { + console.info("------logMessage contact_autoMerge_test_600 is starting!-----"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + try { + var insertRawContactValues1 = { + "display_name": "xiaoliu" + }; + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_autoMerge_test_600: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_autoMerge_test_600: raw_contact_1 insert error = ' + error); + done(); + } + + try { + var insertRawContactValues2 = { + "display_name": "xiaoliu" + }; + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_autoMerge_test_600: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_autoMerge_test_600: raw_contact_2 insert error = ' + error); + done(); + } + + try { + var insertRawContactValues3 = { + "display_name": "xiaoliu" + }; + var rawContactIdThird = await DAHelper.insert(rawContactUri, insertRawContactValues3); + sleep(1000); + console.info("logMessage contact_autoMerge_test_600: rawContactIdThird = " + rawContactIdThird); + expect(rawContactIdThird > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_autoMerge_test_600: raw_contact_3 insert error = ' + error); + done(); + } + + await contactDataBatchInsert(); + done(); + }); + + async function contactDataBatchInsert(DAHelper, rawContactIdFirst, rawContactIdSecond, rawContactIdThird) { + var contactDataValues1 = { + "raw_contact_id": rawContactIdFirst, "content_type": "name", "detail_info": "xiaoliu" + }; + var contactDataValues2 = { + "raw_contact_id": rawContactIdSecond, "content_type": "name", "detail_info": "xiaoliu" + }; + var contactDataValues3 = { + "raw_contact_id": rawContactIdThird, "content_type": "name", "detail_info": "xiaoliu" + }; + var listAddBluk = []; + listAddBluk[0] = contactDataValues1; + listAddBluk[1] = contactDataValues2; + listAddBluk[2] = contactDataValues3; + try { + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + sleep(2000); + console.info("logMessage contact_autoMerge_test_600: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + await threeAutoMerger(); + await deleteAll(rawContactUri, "contact_autoMerge_test_600"); + await deleteAll(contactDataUri, "contact_autoMerge_test_600"); + } catch (error) { + console.info('logMessage contact_autoMerge_test_600: raw_contact insert error = ' + error); + } + } + + async function threeAutoMerger(DAHelper, rawContactIdFirst) { + var condition = new ohosDataAbility.DataAbilityPredicates(); + var updateValues = {}; + try { + var autoMergeCode = await DAHelper.update(autoMergeUri, updateValues, condition); + sleep(1000); + console.info("logMessage contact_autoMerge_test_600 autoMergeCode = " + autoMergeCode); + expect(autoMergeCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactIdFirst.toString()); + await contactMergeQuery(map, "contact_autoMerge_test_600", 3); + } catch (error) { + console.info("logMessage contact_autoMerge_test_600 auto_merge error = " + error); + } + } + + /** + * @tc.number contact_query_merge_list_test_700 + * @tc.name Query contacts to be merged + * @tc.desc Function test + */ + it("contact_query_merge_list_test_700", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage contact_query_merge_list_test_700 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "xiaowu" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_700: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + await queryContactDataInsert(DAHelper, rawContactIdFirst); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_700: raw_contact_1 insert error = ' + error); + done(); + } + + var insertRawContactValues2 = { + "display_name": "xiaowu" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_700: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + await queryContactDataInsertTwo(DAHelper, rawContactIdSecond); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_700: raw_contact_2 insert error = ' + error); + done(); + } + await queryMergeList(DAHelper, rawContactIdFirst, rawContactIdSecond, "contact_query_merge_list_test_700"); + done(); + }); + + async function queryContactDataInsert(DAHelper, rawContactIdFirst) { + var contactDataValues = { + "raw_contact_id": rawContactIdFirst, "content_type": "name", "detail_info": "xiaowu" + }; + try { + var contactDataId1 = await DAHelper.insert(contactDataUri, contactDataValues); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_700: contactDataId1 = " + contactDataId1); + expect(contactDataId1 > 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_700: contact_data_1 insert error = ' + error); + } + } + + async function queryContactDataInsertTwo(DAHelper, rawContactIdSecond) { + var contactDataValuesOne = { + "raw_contact_id": rawContactIdSecond, + "content_type": "name", + "detail_info": "xiaowu" + }; + var contactDataValuesTwo = { + "raw_contact_id": rawContactIdSecond, + "content_type": "phone", + "detail_info": "002563" + }; + var listAddBluk = []; + listAddBluk[0] = contactDataValuesOne; + listAddBluk[1] = contactDataValuesTwo; + try { + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_700: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_700: contact_data_2 insert error = ' + error); + } + } + + async function queryMergeList(DAHelper, rawContactIdFirst, rawContactIdSecond, testName) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var columns = []; + var predicates = new ohosDataAbility.DataAbilityPredicates(); + try { + sleep(3000); + var resultSet = await DAHelper.query(uriQueryMergeList, columns, predicates); + var array = [rawContactIdFirst, rawContactIdSecond]; + var i = 0; + if (resultSet.rowCount > 0) { + if (resultSet.goToFirstRow()) { + do { + var rawContactId = resultSet.getInt(resultSet.getColumnIndex("raw_contact_id")); + console.info(testName + (array[i] == rawContactId)); + expect(array[i] == rawContactId).assertTrue(); + console.info(testName + rawContactId); + i++; + } while (resultSet.goToNextRow()) + } + } + resultSet.close(); + await deleteAll(rawContactUri, testName); + await deleteAll(contactDataUri, testName); + } catch (error) { + console.info(testName + ": query error = " + error); + } + } + + /** + * @tc.number contact_query_merge_list_test_800 + * @tc.name Insert contacts with the same name and different mobile phone numbers, + * and check whether the database can query contacts that can be merged + * @tc.desc Function test + */ + it("contact_query_merge_list_test_800", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage contact_query_merge_list_test_800 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "xiaowuu" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_800: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["xiaowuu", "1854154"]; + var types = ["name", "phone"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "contact_query_merge_list_test_800"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_800: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "xiaowuu" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_800: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["xiaowuu", "1854154414242"]; + var types1 = ["name", "phone"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "contact_query_merge_list_test_800"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_800: raw_contact_2 insert error = ' + error); + done(); + } + var rawContactIds = [rawContactIdFirst + "", rawContactIdSecond + ""]; + await manualMergeList(DAHelper, rawContactIds, "contact_query_merge_list_test_800"); + done(); + }); + + /** + * @tc.number contact_query_merge_list_test_900 + * @tc.name Insert two contacts with different names to see if the database can + * query contacts that can be merged + * @tc.desc Function test + */ + it("contact_query_merge_list_test_900", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage contact_query_merge_list_test_900 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "xiaowusu" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_900: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["xiaowusu"]; + var types = ["name"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "contact_query_merge_list_test_900"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_900: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "kxiaowusu" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_900: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["kxiaowusu"]; + var types1 = ["name"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "contact_query_merge_list_test_900"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_900: raw_contact_2 insert error = ' + error); + done(); + } + await manualNotMerge(DAHelper, rawContactIdFirst, rawContactIdSecond, "contact_query_merge_list_test_900"); + done(); + }); + + async function manualNotMerge(DAHelper, rawContactIdFirst, rawContactIdSecond, tag) { + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + var id = [rawContactIdFirst.toString(), rawContactIdSecond.toString()]; + condition2.in("raw_contact_id", id); + var updateValues2 = {}; + try { + var ManualMergeCode = await DAHelper.update(manualMergeUri, updateValues2, condition2); + sleep(1000); + console.info(tag + "logMessage ManualMergeCode = " + ManualMergeCode); + expect(ManualMergeCode == -1).assertTrue(); + var map = new Map(); + map.set("id", rawContactIdFirst.toString()); + await contactMergeQuery(map, tag, 1); + await deleteAll(rawContactUri, tag); + await deleteAll(contactDataUri, tag); + } catch (error) { + console.info(tag + "logMessage manual_merge error = " + error); + } + } + + /** + * @tc.number contact_query_merge_list_test_1000 + * @tc.name Insert contacts with the same name and phone number, and check whether + * the database can query contacts that can be merged + * @tc.desc Function test + */ + it("contact_query_merge_list_test_1000", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage contact_query_merge_list_test_1000 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "xiaotiantian" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1000: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["xiaotiantian", "1854154414242441"]; + var types = ["name", "phone"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "contact_query_merge_list_test_1000"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1000: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "xiaotiantian" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1000: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["xiaotiantian", "1854154414242441"]; + var types1 = ["name", "phone"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "contact_query_merge_list_test_1000"); + sleep(2000); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1000: raw_contact_2 insert error = ' + error); + done(); + } + var condition = new ohosDataAbility.DataAbilityPredicates(); + var updateValues = {}; + try { + sleep(4000); + var autoMergeCode = await DAHelper.update(autoMergeUri, updateValues, condition); + console.info("logMessage contact_query_merge_list_test_1000: autoMergeCode = " + autoMergeCode); + expect(autoMergeCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactIdFirst.toString()); + await contactMergeQuery(map, "contact_query_merge_list_test_1000", 2); + await deleteAll(rawContactUri, "contact_query_merge_list_test_1000"); + await deleteAll(contactDataUri, "contact_query_merge_list_test_1000"); + done(); + } catch (error) { + console.info("logMessage contact_auto_merge_and_spilt_test_100: auto_merge error = " + error); + } + }); + + /** + * @tc.number contact_query_merge_list_test_1100 + * @tc.name Insert contacts with different names and different mobile phone numbers, + and check whether the database can query contacts that can be merged + * @tc.desc Function test + */ + it("contact_query_merge_list_test_1100", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage contact_query_merge_list_test_1100 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "wsxiuklkk" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1100: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["wsxiuklkk", "56465465"]; + var types = ["name", "phone"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "contact_query_merge_list_test_1100"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1100: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "xiaolilili" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1100: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["xiaolilili", "8954598595"]; + var types1 = ["name", "phone"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "contact_query_merge_list_test_1100"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1100: raw_contact_2 insert error = ' + error); + done(); + } + await manualNotMerge(DAHelper, rawContactIdFirst, rawContactIdSecond, "contact_query_merge_list_test_1100"); + done(); + }); + + /** + * @tc.number contact_query_merge_list_test_1200 + * @tc.name Insert two contacts with the same name. Contacts A and B have two + same mobile phone numbers, and check whether the database can be merged + * @tc.desc Function test + */ + it("contact_query_merge_list_test_1200", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage contact_query_merge_list_test_1200 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "lwsxiuklkk" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1200: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["lwsxiuklkk", "122504", "122505"]; + var types = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "contact_query_merge_list_test_1200"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1200: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "lwsxiuklkk" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1200: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["lwsxiuklkk", "122504", "122505"]; + var types1 = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "contact_query_merge_list_test_1200"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1200: raw_contact_2 insert error = ' + error); + done(); + } + await autoMerger(DAHelper, rawContactIdFirst, "contact_query_merge_list_test_1200"); + done(); + }); + + /** + * @tc.number contact_query_merge_list_test_1300 + * @tc.name Insert two contacts with the same name. Contacts A and B have two + * identical mobile phone numbers. Check whether the database can be merged + * @tc.desc Function test + */ + it("contact_query_merge_list_test_1300", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage contact_query_merge_list_test_1300 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "xiaowuuklkk" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1300: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["xiaowuuklkk", "56465465", "122504"]; + var types = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "contact_query_merge_list_test_1300"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1300: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "xiaowuuklkk" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1300: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["xiaowuuklkk", "8954598595", "1225054"]; + var types1 = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "contact_query_merge_list_test_1300"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1300: raw_contact_2 insert error = ' + error); + done(); + } + var rawContactIds = [rawContactIdFirst + "", rawContactIdSecond + ""]; + await manualMergeList(DAHelper, rawContactIds, "contact_query_merge_list_test_1300"); + done(); + }); + + /** + * @tc.number contact_query_merge_list_test_1400 + * @tc.name Insert two contacts with the same name. Contacts A and B have two mobile phone + * numbers, one of which is the same. Check whether the database can be merged + * @tc.desc Function test + */ + it("contact_query_merge_list_test_1400", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage contact_query_merge_list_test_1400 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "limingm" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1400: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["limingm", "122504555", "1122505"]; + var types = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "contact_query_merge_list_test_1400"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1400: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "limingm" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1400: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["limingm", "122504555", "1225056"]; + var types1 = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "contact_query_merge_list_test_1400"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1400: raw_contact_2 insert error = ' + error); + done(); + } + var rawContactIds = [rawContactIdFirst + "", rawContactIdSecond + ""]; + await manualMergeList(DAHelper, rawContactIds, "contact_query_merge_list_test_1400"); + done(); + }); + + /** + * @tc.number contact_query_merge_list_test_1500 + * @tc.name Insert two contacts with the same name, contact A has two mobile phone numbers, + * and contact B has one mobile phone number which is the same as one of the mobile phone + * numbers of A, and check whether the database can be merged + * @tc.desc Function test + */ + it("contact_query_merge_list_test_1500", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage contact_query_merge_list_test_1500 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "kplimingm" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1500: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["kplimingm", "7122504555", "1122505"]; + var types = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "contact_query_merge_list_test_1500"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1500: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "kplimingm" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1500: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["kplimingm", "7122504555"]; + var types1 = ["name", "phone"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "contact_query_merge_list_test_1500"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1500: raw_contact_2 insert error = ' + error); + done(); + } + var rawContactIds = [rawContactIdFirst + "", rawContactIdSecond + ""]; + await manualMergeList(DAHelper, rawContactIds, "contact_query_merge_list_test_1500"); + done(); + }); + + /** + * @tc.number contact_query_merge_list_test_1600 + * @tc.name Insert two contacts with the same name, contact A has two mobile phone numbers, + * and contact B has a mobile phone number different from that of A, check whether + * the database can be merged + * @tc.desc Function test + */ + it("contact_query_merge_list_test_1600", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage contact_query_merge_list_test_1600 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "pkplimingm" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1600: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["pkplimingm", "87122504555", "11122505"]; + var types = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "contact_query_merge_list_test_1600"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1600: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "pkplimingm" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1600: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["pkplimingm", "7122554504555", "11122505"]; + var types1 = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "contact_query_merge_list_test_1600"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1600: raw_contact_2 insert error = ' + error); + done(); + } + var rawContactIds = [rawContactIdFirst + "", rawContactIdSecond + ""]; + await manualMergeList(DAHelper, rawContactIds, "contact_query_merge_list_test_1600"); + done(); + }); + + /** + * @tc.number contact_query_merge_list_test_1700 + * @tc.name Insert multiple manually merged contacts to check whether the database can be merged + * @tc.desc Function test + */ + it("contact_query_merge_list_test_1700", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage contact_query_merge_list_test_1700 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "llllllk" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1700: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["llllllk", "87122504555", "11122505"]; + var types = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "contact_query_merge_list_test_1700"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1700: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "llllllk" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1700: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["llllllk", "7555", "02505"]; + var types1 = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "contact_query_merge_list_test_1700"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1700: raw_contact_2 insert error = ' + error); + done(); + } + var insertRawContactValues3 = { + "display_name": "llllllk" + }; + try { + var rawContactIdThird = await DAHelper.insert(rawContactUri, insertRawContactValues3); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1700: rawContactIdSecond = " + rawContactIdThird); + expect(rawContactIdThird > 0).assertTrue(); + var detailInfo1 = ["llllllk", "87555", "002505"]; + var types1 = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdThird, detailInfo1, types1, "contact_query_merge_list_test_1700"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1700: raw_contact_2 insert error = ' + error); + done(); + } + var rawContactIds = [rawContactIdFirst + "", rawContactIdSecond + "", rawContactIdThird + ""]; + await manualMergeList(DAHelper, rawContactIds, "contact_query_merge_list_test_1700"); + done(); + }); + + /** + * @tc.number contact_query_merge_list_test_1800 + * @tc.name Import multiple automatically merged contacts to check whether the database can be merged + * @tc.desc Function test + */ + it("contact_query_merge_list_test_1800", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage contact_query_merge_list_test_1800 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "jggbgbk" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1800: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["jggbgbk", "85555", "996174"]; + var types = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "contact_query_merge_list_test_1800"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1800: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "jggbgbk" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1800: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["jggbgbk", "85555", "996174"]; + var types1 = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "contact_query_merge_list_test_1800"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1800: raw_contact_2 insert error = ' + error); + done(); + } + var insertRawContactValues3 = { + "display_name": "jggbgbk" + }; + try { + var rawContactIdThird = await DAHelper.insert(rawContactUri, insertRawContactValues3); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1800: rawContactIdSecond = " + rawContactIdThird); + expect(rawContactIdThird > 0).assertTrue(); + var detailInfo1 = ["jggbgbk", "85555", "996174"]; + var types1 = ["name", "phone", "phone"]; + await insertContactData(DAHelper, rawContactIdThird, detailInfo1, types1, "contact_query_merge_list_test_1800"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1800: raw_contact_2 insert error = ' + error); + done(); + } + var condition = new ohosDataAbility.DataAbilityPredicates(); + var updateValues = {}; + try { + var autoMergeCode = await DAHelper.update(autoMergeUri, updateValues, condition); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1800 autoMergeCode = " + autoMergeCode); + expect(autoMergeCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactIdFirst.toString()); + await contactMergeQuery(map, "contact_query_merge_list_test_1800", 3); + await deleteAll(rawContactUri, "contact_query_merge_list_test_1800"); + await deleteAll(contactDataUri, "contact_query_merge_list_test_1800"); + } catch (error) { + console.info("contact_query_merge_list_test_1800 auto_merge error =" + error); + } + done(); + }); + + /** + * @tc.number contact_query_merge_list_test_1900 + * @tc.name Insert two contacts with the same name, contact A has two mobile phone numbers, + * and contact B has a mobile phone number different from that of A, check whether + * the database can be merged + * @tc.desc Function test + */ + it("contact_query_merge_list_test_1900", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage contact_query_merge_list_test_1900 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "owjiuh" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1900: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var dataId = insertContactDataSingle(DAHelper, rawContactIdFirst, "owjiuh", "name"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1900: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "owjiuh" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_1900: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var dataId = insertContactDataSingle(DAHelper, rawContactIdFirst, "owjiuh", "name"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_1900: raw_contact_2 insert error = ' + error); + done(); + } + await updateContactData("owjiuh111", dataId, "contact_query_merge_list_test_1900"); + await autoNotMerger(DAHelper, rawContactIdFirst, "contact_query_merge_list_test_1900"); + done(); + }); + + /** + * @tc.number contact_query_merge_list_test_2000 + * @tc.name Insert two automatically merged contacts, modify the phone number of A, and then + * merge the contacts manually to check whether the database can be merged + * the database can be merged + * @tc.desc Function test + */ + it("contact_query_merge_list_test_2000", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage contact_query_merge_list_test_2000 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "ollwjiuh" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_2000: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + await insertContactDataSingle(DAHelper, rawContactIdFirst, "ollwjiuh", "name"); + var dataIdTwo = await insertContactDataSingle(DAHelper, rawContactIdFirst, "8554544", "phone"); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_2000: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "ollwjiuh" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage contact_query_merge_list_test_2000: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + await insertContactDataSingle(DAHelper, rawContactIdSecond, "ollwjiuh", "name"); + await insertContactDataSingle(DAHelper, rawContactIdSecond, "8554544", "phone"); + sleep(2000); + } catch (error) { + console.info('logMessage contact_query_merge_list_test_2000: raw_contact_2 insert error = ' + error); + done(); + } + await updateContactData("8554544444", dataIdTwo, "contact_query_merge_list_test_2000"); + sleep(3000); + var rawContactIds = [rawContactIdFirst + "", rawContactIdSecond + ""]; + await manualMergeList(DAHelper, rawContactIds, "contact_query_merge_list_test_2000"); + done(); + }); + + /** + * @tc.number abnormal_merge_Update_test_2100 + * @tc.name Insert two contacts with different names for automatic and manual merging operations + * @tc.desc Function test + */ + it("abnormal_merge_Update_test_2100", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage abnormal_merge_Update_test_2100 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "2100mergeTest" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage abnormal_merge_Update_test_2100: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["2100mergeTest"]; + var types = ["name"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "abnormal_merge_Update_test_2100"); + } catch (error) { + console.info('logMessage abnormal_merge_Update_test_2100: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "2100mergeTestTwo" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage abnormal_merge_Update_test_2100: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["2100mergeTestTwo"]; + var types1 = ["name"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "abnormal_merge_Update_test_2100"); + } catch (error) { + console.info('logMessage abnormal_merge_Update_test_2100: raw_contact_2 insert error = ' + error); + done(); + } + var condition = new ohosDataAbility.DataAbilityPredicates(); + var updateValues = {}; + var autoMergeCode = await DAHelper.update(autoMergeUri, updateValues, condition); + console.info("logMessage abnormal_merge_Update_test_2100 autoMergeCode = " + autoMergeCode); + expect(autoMergeCode == -1).assertTrue(); + await manualNotMerge(DAHelper, rawContactIdFirst, rawContactIdSecond, "abnormal_merge_Update_test_2100"); + done(); + }); + + /** + * @tc.number abnormal_merge_Update_test_2200 + * @tc.name Insert two contacts with same names for automatic and manual merging operations + * @tc.desc Function test + */ + it("abnormal_merge_Update_test_2200", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage abnormal_merge_Update_test_2200 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "2200mergeTest" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage abnormal_merge_Update_test_2200: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["2200mergeTest", "45544"]; + var types = ["name", "phone"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "abnormal_merge_Update_test_2200"); + } catch (error) { + console.info('logMessage abnormal_merge_Update_test_2200: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "2200mergeTestTwo" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage abnormal_merge_Update_test_2200: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["2200mergeTestTwo", "55134865"]; + var types1 = ["name", "phone"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "abnormal_merge_Update_test_2200"); + } catch (error) { + console.info('logMessage abnormal_merge_Update_test_2200: raw_contact_2 insert error = ' + error); + done(); + } + await queryMergeListError(DAHelper, rawContactIdFirst, rawContactIdSecond, "abnormal_merge_Update_test_2200"); + done(); + }); + + async function queryMergeListError(DAHelper, rawContactIdFirst, rawContactIdSecond, testName) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var columns = ["display_names"]; + var predicates = new ohosDataAbility.DataAbilityPredicates(); + try { + sleep(3000); + var resultSet = await DAHelper.query(uriQueryMergeList, columns, predicates); + console.info(testName + 'resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == 0).assertTrue(); + resultSet.close(); + await deleteAll(rawContactUri, testName); + await deleteAll(contactDataUri, testName); + } catch (error) { + console.info(testName + ": query error = " + error); + } + } + + /** + * @tc.number abnormal_merge_Update_test_2300 + * @tc.name Insert two contacts with different names, and then automatically merge them to + * see if the database can be merged + * @tc.desc Function test + */ + it("abnormal_merge_Update_test_2300", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage abnormal_merge_Update_test_2300 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "2300mergeTest" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage abnormal_merge_Update_test_2300: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["2300mergeTest"]; + var types = ["name"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "abnormal_merge_Update_test_2300"); + } catch (error) { + console.info('logMessage abnormal_merge_Update_test_2300: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "2300mergeTestName" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage abnormal_merge_Update_test_2300: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["2300mergeTestName"]; + var types1 = ["name"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "abnormal_merge_Update_test_2300"); + } catch (error) { + console.info('logMessage abnormal_merge_Update_test_2300: raw_contact_2 insert error = ' + error); + done(); + } + await autoNotMerger(DAHelper, rawContactIdFirst, "abnormal_merge_Update_test_2300"); + done(); + }); + + /** + * @tc.number abnormal_merge_Update_test_2400 + * @tc.name Insert two contacts with different names, and then automatically merge them to + * see if the database can be merged + * @tc.desc Function test + */ + it("abnormal_merge_Update_test_2400", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage abnormal_merge_Update_test_2400 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "2400mergeTest" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage abnormal_merge_Update_test_2400: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["2400mergeTest"]; + var types = ["namee"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "abnormal_merge_Update_test_2400"); + } catch (error) { + console.info('logMessage abnormal_merge_Update_test_2400: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "2400mergeTest" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage abnormal_merge_Update_test_2400: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["2400mergeTest"]; + var types1 = ["name"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "abnormal_merge_Update_test_2400"); + } catch (error) { + console.info('logMessage abnormal_merge_Update_test_2400: raw_contact_2 insert error = ' + error); + done(); + } + await autoNotMerger(DAHelper, rawContactIdFirst, "abnormal_merge_Update_test_2400"); + done(); + }); + + /** + * @tc.number abnormal_merge_Update_test_2500 + * @tc.name Pass 0 after merging to split + * @tc.desc Function test + */ + it("abnormal_merge_Update_test_2500", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage abnormal_merge_Update_test_2500 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "2500mergeTest" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage abnormal_merge_Update_test_2500: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["2500mergeTest"]; + var types = ["name"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "abnormal_merge_Update_test_2500"); + } catch (error) { + console.info('logMessage abnormal_merge_Update_test_2500: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "2500mergeTest" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage abnormal_merge_Update_test_2500: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["2500mergeTest"]; + var types1 = ["name"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "abnormal_merge_Update_test_2500"); + } catch (error) { + console.info('logMessage abnormal_merge_Update_test_2500: raw_contact_2 insert error = ' + error); + done(); + } + var condition = new ohosDataAbility.DataAbilityPredicates(); + var updateValues = {}; + var autoMergeCode = await DAHelper.update(autoMergeUri, updateValues, condition); + sleep(1000); + console.info("logMessage abnormal_merge_Update_test_2500 autoMergeCode = " + autoMergeCode); + expect(autoMergeCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactIdFirst.toString()); + await contactNotSplit(DAHelper, 0, "abnormal_merge_Update_test_2500"); + await contactMergeQuery(map, "abnormal_merge_Update_test_2500", 2); + await deleteAll(rawContactUri, "abnormal_merge_Update_test_2500"); + await deleteAll(contactDataUri, "abnormal_merge_Update_test_2500"); + done(); + }); + + /** + * @tc.number abnormal_merge_Update_test_2600 + * @tc.name Pass -1 after merging to split + * @tc.desc Function test + */ + it("abnormal_merge_Update_test_2600", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('before delete_all: start ! DAHelper = ' + DAHelper); + console.info("------logMessage abnormal_merge_Update_test_2600 is starting!-----"); + var insertRawContactValues1 = { + "display_name": "2600mergeTest" + }; + try { + var rawContactIdFirst = await DAHelper.insert(rawContactUri, insertRawContactValues1); + sleep(1000); + console.info("logMessage abnormal_merge_Update_test_2600: rawContactIdFirst = " + rawContactIdFirst); + expect(rawContactIdFirst > 0).assertTrue(); + var detailInfo = ["2600mergeTest"]; + var types = ["name"]; + await insertContactData(DAHelper, rawContactIdFirst, detailInfo, types, "abnormal_merge_Update_test_2600"); + } catch (error) { + console.info('logMessage abnormal_merge_Update_test_2600: raw_contact_1 insert error = ' + error); + done(); + } + var insertRawContactValues2 = { + "display_name": "2600mergeTest" + }; + try { + var rawContactIdSecond = await DAHelper.insert(rawContactUri, insertRawContactValues2); + sleep(1000); + console.info("logMessage abnormal_merge_Update_test_2600: rawContactIdSecond = " + rawContactIdSecond); + expect(rawContactIdSecond > 0).assertTrue(); + var detailInfo1 = ["2600mergeTest"]; + var types1 = ["name"]; + await insertContactData(DAHelper, rawContactIdSecond, detailInfo1, types1, "abnormal_merge_Update_test_2600"); + } catch (error) { + console.info('logMessage abnormal_merge_Update_test_2600: raw_contact_2 insert error = ' + error); + done(); + } + var condition = new ohosDataAbility.DataAbilityPredicates(); + var updateValues = {}; + var autoMergeCode = await DAHelper.update(autoMergeUri, updateValues, condition); + sleep(1000); + console.info("logMessage abnormal_merge_Update_test_2600 autoMergeCode = " + autoMergeCode); + expect(autoMergeCode == 0).assertTrue(); + var map = new Map(); + map.set("id", rawContactIdFirst.toString()); + await contactNotSplit(DAHelper, -1, "abnormal_merge_Update_test_2600"); + await contactMergeQuery(map, "abnormal_merge_Update_test_2600", 2); + await deleteAll(rawContactUri, "abnormal_merge_Update_test_2600"); + await deleteAll(contactDataUri, "abnormal_merge_Update_test_2600"); + done(); + }); + + async function contactNotSplit(DAHelper, rawContactIdFirst, testName) { + var condition2 = new ohosDataAbility.DataAbilityPredicates(); + var array = [rawContactIdFirst.toString()]; + condition2.in("raw_contact_id", array); + var updateValues2 = {}; + try { + var splitCode = await DAHelper.update(splitUri, updateValues2, condition2); + sleep(4000); + console.info(testName + 'logMessage splitCode = ' + splitCode); + expect(splitCode == -1).assertTrue(); + } catch (error) { + console.info(testName + 'logMessage split error = ' + error); + } + } + + afterAll(async function () { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('merge afterAll delete_All: start ! DAHelper = ' + DAHelper); + var condition = new ohosDataAbility.DataAbilityPredicates(); + var deletedAll = await DAHelper.delete(deletedUri, condition); + sleep(4000); + console.info('merge afterAll delete_All : deletedAll ! DAHelper = ' + deletedAll); + }); + }); +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/test/lib/Const.js b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/test/lib/Const.js new file mode 100644 index 0000000000000000000000000000000000000000..f9263cd46dee1a0ffdfaa1e5ef5c29755c7e13f7 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/ets/MainAbility/test/lib/Const.js @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2021 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. + */ + +// sim slot id +export const DEFAULT_SLOTID = 0; +export const SLOTID3 = 3; +export const SLOTID2 = 2; +export const SLOTID_MINUS1 = -1; + +// sim correct password +export const CORRECT_PIN = '1234'; +export const CORRECT_PIN2 = '18099014'; + +// sim incorrect password +export const INCORRECT_PIN = '134679'; +export const INCORRECT_PIN_LEN3 = '123'; +export const INCORRECT_PUK = '134679'; +export const INCORRECT_PIN2 = '134679'; +export const INCORRECT_PIN2_LEN3 = '123'; +export const INCORRECT_PIN2_LEN9 = '123456789'; +export const INCORRECT_PUK2 = '134679'; + +// lock status response +export const LOCK_RESULT = { SUCCESS: 0, FAILURE: -1, EXCEPTION: -2 }; \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03b8532c53ca563f8ed6b1e21d20ad3f67a68906 --- /dev/null +++ b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/base/media/icon.png b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/hand.png b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/hand.png new file mode 100644 index 0000000000000000000000000000000000000000..9f1fa16ee073093b40920e273502513fa66fa980 Binary files /dev/null and b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/hand.png differ diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/icon.png b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/icon.png differ diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/images.jpg b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/images.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c75ddfc5ead15e8d49ca7cae9f97c03585565be1 Binary files /dev/null and b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/images.jpg differ diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/person.png b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/person.png new file mode 100644 index 0000000000000000000000000000000000000000..f0f540d078e6c0441a763ca2cc375a551d6cf736 Binary files /dev/null and b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/person.png differ diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/star-1-1.png b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/star-1-1.png new file mode 100644 index 0000000000000000000000000000000000000000..990c5e5ad20698c7701faf641bc80eb004a127b7 Binary files /dev/null and b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/star-1-1.png differ diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/star-1-2.png b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/star-1-2.png new file mode 100644 index 0000000000000000000000000000000000000000..450c3dd3ca68bf601bd08e5f41797d376e20d00d Binary files /dev/null and b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/star-1-2.png differ diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/star-1-3.png b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/star-1-3.png new file mode 100644 index 0000000000000000000000000000000000000000..1044869832b423a5dfc2559a395529377bd34f0c Binary files /dev/null and b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/star-1-3.png differ diff --git a/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/video/show.mp4 b/telephony/telephonyjstest/contact_function_merge/entry/src/main/resources/rawfile/video/show.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/telephony/telephonyjstest/contact_function_merge/signature/openharmony_sx.p7b b/telephony/telephonyjstest/contact_function_merge/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/telephony/telephonyjstest/contact_function_merge/signature/openharmony_sx.p7b differ diff --git a/telephony/telephonyjstest/contact_performance/BUILD.gn b/telephony/telephonyjstest/contact_performance/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..cf8ca1bec9d0bbac3223badffee69c1ee166d2c3 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 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("ActsContactPerformanceEtsTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":ace_demo_ets_assets", + ":ace_demo_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsContactPerformanceEtsTest" +} +ohos_js_assets("ace_demo_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("ace_demo_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/telephony/telephonyjstest/contact_performance/Test.json b/telephony/telephonyjstest/contact_performance/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..1ac6ac21a7f0ae6c1cf5da562d43b809cf54cd2c --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "1800000", + "package": "com.ohos.contactperformance", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsContactPerformanceEtsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/config.json b/telephony/telephonyjstest/contact_performance/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..a8d0ec05ec541af723d25df1301f2ce600933421 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/config.json @@ -0,0 +1,93 @@ +{ + "app": { + "bundleName": "com.ohos.contactperformance", + "vendor": "open", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.contactperformance", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/Button", + "pages/Blank", + "pages/DataPanel", + "pages/Divider", + "pages/Text", + "pages/RowSplit", + "pages/Scroll", + "pages/Stack", + "pages/Image", + "pages/Progress", + "pages/Qrcode", + "pages/Rating", + "pages/Span", + "pages/Slider", + "pages/Badge", + "pages/Column", + "pages/ColumnSplit", + "pages/Counter", + "pages/Flex", + "pages/GridContainer" + + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/app.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..261fadca29ff0ea310a8bc105ddd1af65e2dd2f6 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Badge.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Badge.ets new file mode 100644 index 0000000000000000000000000000000000000000..66de6f8e3b9c0360931602dd25d1511878ac63ab --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Badge.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct badge { + @State counts: number = 33 + @State message: string = 'new' + @State active: boolean = false + private content: string = "badge Page"; + + onPageShow() { + console.info('badge page show called'); + } + + onBuildDone() { + console.info('badge page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Scroll() { + Column() { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Badge({ + count: this.counts, + position: BadgePosition.Right, + maxCount: 99, + style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge') + + Text("BadgePosition.RightTop").fontSize(16) + Badge({ + count: this.counts, + position: BadgePosition.RightTop, + maxCount: 99, + style: { color: 0xFFFFFF, fontSize: '16', badgeSize: '20', badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge1') + + Text("BadgePosition.Left").fontSize(16) + Badge({ + count: this.counts, + position: BadgePosition.Left, + maxCount: 99, + style: { color: Color.Pink, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge2') + } + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Blank.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Blank.ets new file mode 100644 index 0000000000000000000000000000000000000000..a50fc719e09ab27c91f9705ac06008e936830f33 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Blank.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct blank_testcase { + @State Color: Color = Color.Pink + @State active: boolean = false + private content: string = "Blank Page" + + onPageShow() { + console.info('Blank page show called'); + } + + onBuildDone() { + console.info('Blank page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Blank(100) + .color(this.Color) + .key('blank') + Text('on/off').fontSize(18).height(60) + } + .key('flex') + .width('100%') + .height('100%') + + + } +} diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Button.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Button.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac2271ea3a13664bbbb6afe4f173abae9e66f867 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Button.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct button_testcase { + @State stateEffect: boolean = true + @State ButtonType: ButtonType = ButtonType.Circle + private content: string = "Button Page"; + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button('1.value', { type: ButtonType.Circle, stateEffect: this.stateEffect }) + .fontSize(12) + .fontWeight(FontWeight.Bold) + .fontColor(0xCCCCCC) + .height(40) + .width(40) + .key('button') + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + .padding(10) + Button() { + Text("2.Capsule") + } + .type(ButtonType.Capsule) + .stateEffect(false) + .backgroundColor('#0D9FFB') + .padding(10) + .key('button1') + + Button() { + Text("3.Normal") + }.type(ButtonType.Normal) + .backgroundColor('#0D9FFB') + .key('button2') + + }.key('flex') + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Column.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Column.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9e5c84e21ccf25419be432d8f95418fac82070a --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Column.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct column { + @State active: boolean = false + private content: string = "Column Page" + + onPageShow() { + console.info('Column page show called'); + } + + onBuildDone() { + console.info('Column page build done called'); + } + + build() { + Column({ space: 5 }) { + Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Center).width('90%').border({ width: 1 }).key('column') + + Text('alignItems(Start)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column({ space: '5' }) { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Start).width('90%').border({ width: 1 }).key('column1') + + Text('alignItems(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.End).width('90%').border({ width: 1 }).key('column2') + }.width('100%').padding({ top: 5 }) + } +} diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb0597310a15be8ab4503a3ae89385e3708fac96 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct columnSplit { + private content: string = "ColumnSplit Page" + + onPageShow() { + console.info('ColumnSplit page show called'); + } + + onBuildDone() { + console.info('ColumnSplit page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Scroll() { + Column() { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Column() { + Text('ColumnSplit').fontSize(9).fontColor(0xCCCCCC).width('90%') + ColumnSplit() { + Text('1').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('2').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('3').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + }.key('columnSplit') + .resizeable(true) + .width('90%').height('60%') + + }.width("100%") + + Column() { + Text('ColumnSplit1').fontSize(9).fontColor(0xCCCCCC).width('90%') + ColumnSplit() { + Text('1').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('2').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('3').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + }.key('columnSplit1') + .resizeable(false) + .width('90%').height('60%') + + }.width("100%") + } + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Counter.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Counter.ets new file mode 100644 index 0000000000000000000000000000000000000000..ecdbfaf10393e7a348fd76098868e6455505b07f --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Counter.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct counter { + @State value: number = 0 + @State active: boolean = false + private content: string = "Counter Page" + + onPageShow() { + console.info('Counter page show called'); + } + + onBuildDone() { + console.info('Counter page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Counter() { + Text(this.value.toString()) + }.margin(100) + .key('counter') + .onInc(() => { + this.value++ + }) + .onDec(() => { + this.value-- + }) + }.width("100%") + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/DataPanel.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/DataPanel.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c624848482b22998b2a1d137796ddaedbcf198c --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/DataPanel.ets @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct dataPanel_testcase { + @State width: string= "200" + @State height: string= "100" + @State active: boolean = false + private content: string = "DataPanel Page" + + onPageShow() { + console.info('Blank page show called'); + } + + onBuildDone() { + console.info('Blank page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + DataPanel({ values: [20, 40, 20], max: 100, type: DataPanelType.Line }) + .width(this.width) + .height(this.height) + .key('DataPanel') + .onClick(() => { + router.back() + }) + .closeEffect(false) + + DataPanel({ values: [20, 40, 20], max: 100, type: DataPanelType.Circle}) + .width(this.width) + .height(this.height) + .key('DataPanel2') + .onClick(() => { + router.back() + }) + .closeEffect(true) + DataPanel({ values: [20, 40, 20], max: 100}) + .width(this.width) + .height(this.height) + .key('DataPanel3') + .onClick(() => { + router.back() + }) + .closeEffect(false) + } + .key('flex') + .width('100%') + .height('100%') + + } +} diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Divider.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Divider.ets new file mode 100644 index 0000000000000000000000000000000000000000..02bf60779418674d1fd58127907fdb3915bd8f8f --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Divider.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct divider_textcase { + @State vertical: boolean = true + @State color: Color = Color.Red + @State strokeWidth: number = 7 + @State lineCap: LineCapStyle = LineCapStyle.Butt + @State active: boolean = false + private content: string = "Divider Page"; + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + Divider() + .lineCap(LineCapStyle.Butt) + .strokeWidth(this.strokeWidth) + .color(this.color) + .vertical(this.vertical) + .height(150) + .key('divider') + .onClick(() => { + router.back() + }) + Divider() + .lineCap(LineCapStyle.Round) + .vertical(false) + .color(Color.Green) + .strokeWidth(10) + .height(150) + .key('divider1') + Divider() + .lineCap(LineCapStyle.Square) + .color(Color.Green) + .vertical(true) + .strokeWidth(10) + .height(150) + .key('divider2') + } + .key('flex') + .width('100%') + .height('100%') + } +} + + diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Flex.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Flex.ets new file mode 100644 index 0000000000000000000000000000000000000000..a0e21251e80008c5be9f29aa52074acc5eb24a78 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Flex.ets @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct flex { + private content: string = "Flex Page" + + onPageShow() { + console.info('Flex page show called'); + } + + onBuildDone() { + console.info('Flex page build done called'); + } + + build() { + Column() { + Column({ space : 2 }) { + Text('direction:Column').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Column, + wrap: FlexWrap.NoWrap, + justifyContent: FlexAlign.Center, + alignItems:ItemAlign.Start, + alignContent: FlexAlign.Start, + }) { + Text('1').width('100%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('100%').height(20).backgroundColor(0xD2B48C) + Text('3').width('100%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex') + .height(70) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('direction:Row').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.Start, + alignItems:ItemAlign.Start, + alignContent: FlexAlign.Center, + }) { + Text('1').width('20%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('20%').height(20).backgroundColor(0xD2B48C) + Text('3').width('20%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex1') + .height(70) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('direction:RowReverse').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.RowReverse, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.End, + alignItems:ItemAlign.End, + alignContent: FlexAlign.End, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex2') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent:SpaceBetween').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceBetween, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('100%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('100%').height(20).backgroundColor(0xD2B48C) + Text('3').width('100%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex3') + .height(100) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent AND alignContent').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceEvenly, + alignContent: FlexAlign.SpaceEvenly, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex4') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent AND alignContent').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceAround, + alignContent: FlexAlign.SpaceAround, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex5') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + }.width('100%').margin({ top: 5 }) + }.width('100%') + } +} diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/GridContainer.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/GridContainer.ets new file mode 100644 index 0000000000000000000000000000000000000000..57358110413406263e70a2a5f650cbfeb22a4387 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/GridContainer.ets @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct gridContainer { + @State sizeType: SizeType = SizeType.XS + @State active: boolean = false + private content: string = "GridContainer Page" + + onPageShow() { + console.info('GridContainer page show called'); + } + + onBuildDone() { + console.info('GridContainer page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Scroll() { + Column({ space: 5 }) { + GridContainer({ columns: 12, sizeType: this.sizeType, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer') + .width('90%') + .alignItems(HorizontalAlign.Start) + + Text('Click Simulate to change the device width').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() { + Button('XS') + .onClick(() => { + this.sizeType = SizeType.XS + }).backgroundColor(0x317aff) + Button('SM') + .onClick(() => { + this.sizeType = SizeType.SM + }).backgroundColor(0x317aff) + Button('MD') + .onClick(() => { + this.sizeType = SizeType.MD + }).backgroundColor(0x317aff) + Button('LG') + .onClick(() => { + this.sizeType = SizeType.LG + }).backgroundColor(0x317aff) + } + + GridContainer({ columns: "auto", sizeType: SizeType.MD, gutter: '10', margin: '20' }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer1') + .width('90%') + .alignItems(HorizontalAlign.Center) + + GridContainer({ columns: 12, sizeType: SizeType.SM, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer2') + .width('90%') + .alignItems(HorizontalAlign.End) + + GridContainer({ columns: 12, sizeType: SizeType.LG, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer3') + .width('90%') + .alignItems(HorizontalAlign.End) + + GridContainer({ columns: 12, sizeType: SizeType.Auto, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer4') + .width('90%') + .alignItems(HorizontalAlign.End) + + }.width('100%').margin({ top: 5 }) + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Image.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Image.ets new file mode 100644 index 0000000000000000000000000000000000000000..5cc583e931f51aa8e4f2bd55decfeeb14a40afb4 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Image.ets @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct image_textcase { + @State Width: number = 0 + @State height: number = 0 + + onPageShow() { + console.info('Image page show called'); + } + + onBuildDone() { + console.info('Image page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Image page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Image("/resources/rawfile/hand.png") + .matchTextDirection(false) + .fitOriginalSize(false) + .fillColor(0xCCCCCC) + .objectFit(ImageFit.Cover) + .objectRepeat(ImageRepeat.NoRepeat) + .interpolation(ImageInterpolation.None) + .renderMode(ImageRenderMode.Original) + .autoResize(false) + .syncLoad(false) + .sourceSize({ width: 200, height: 100 }) + .alt("/resources/rawfile/person.png") + .key('image1') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.Contain) + .objectRepeat(ImageRepeat.X) + .interpolation(ImageInterpolation.High) + .renderMode(ImageRenderMode.Template) + .key('image2') + .height(180) + .width(180) + .onComplete((msg: { + width: number, + height: number + }) => { + this.Width = msg.width + this.height = msg.height + console.info('Width ----' + this.Width) + console.info('height ----' + this.height) + }) + .onError(() => { + console.info('load image fail') + }) + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.Fill) + .objectRepeat(ImageRepeat.Y) + .interpolation(ImageInterpolation.Low) + .key('image3') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.None) + .objectRepeat(ImageRepeat.XY) + .interpolation(ImageInterpolation.Medium) + .key('image4') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.ScaleDown) + .key('image5') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(4) + } + } +} + + diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Navigator.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Navigator.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c50769cf2ab045cbe48b52e294b4105a21e1c3d --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Navigator.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct navigator_testcase { + @State active: boolean = false + @State params: Object = { text: 'news' } + + onPageShow() { + console.info('Navigator page show called'); + } + + onBuildDone() { + console.info('Navigator page build done called'); + } + + build() { + Column() { + Navigator({ target: "pages/index", type: NavigationType.Back }) { + Text('Navigator test in Navigator,back') + }.active(this.active) + .key('navigator') + .params({ + data: 24 + }) + + Navigator({ target: "pages/index", type: NavigationType.Push }) { + Text('Navigator test in Navigator,push') + }.active(this.active) + .key('navigator2') + .params({ + data: 24 + }) + + Navigator({ target: "pages/index", type: NavigationType.Replace }) { + Text('Navigator test in Navigator,replace') + }.active(this.active) + .key('navigator3') + .params({ + data: 24 + }) + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } +} diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Panel.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Panel.ets new file mode 100644 index 0000000000000000000000000000000000000000..32ddabbd1ccbae3805dd462e6f04b28364d6a1e7 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Panel.ets @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct PanelExample { + @State show: boolean = true + + onPageShow() { + console.info('Panel page show called'); + } + + onBuildDone() { + console.info('Panel page build done called'); + } + + build() { + Column() { + Text('2021-09-30 Today Calendar: 1.afternoon......Click for details') + .width('90%') + .height(50) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + .padding({ left: 20 }) + .onClick(() => { + this.show = !this.show + }) + Panel(this.show) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel') + .type(PanelType.Foldable) + .mode(PanelMode.Half) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + Panel(this.show) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel2') + .type(PanelType.Minibar) + .mode(PanelMode.Mini) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + Panel(false) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel3') + .type(PanelType.Temporary) + .mode(PanelMode.Full) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + }.width('100%').height('50%').backgroundColor(0xDCDCDC).padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Progress.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Progress.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8608089fe51e1988fd305fc49db028b6c2efe76 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Progress.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct progress_testcase { + onPageShow() { + console.info('Progress page show called'); + } + + onBuildDone() { + console.info('Progress page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Progress page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Progress({ value: 20, total: 40, style: ProgressStyle.Linear }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress') + + Progress({ value: 20, total: 40, style: ProgressStyle.Eclipse }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress2') + + Progress({ value: 20, total: 40, style: ProgressStyle.Ring }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress3') + + Progress({ value: 20, total: 40, style: ProgressStyle.ScaleRing }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress4') + + Progress({ value: 20, total: 40, style: ProgressStyle.Capsule }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress5') + + } + .width(400) + .height(400) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Qrcode.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Qrcode.ets new file mode 100644 index 0000000000000000000000000000000000000000..5c0dd84eff5a6653ee5fd940662d141025a1bb4e --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Qrcode.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct qrcode_textcase { + @State Color: Color = Color.Pink + + onPageShow() { + console.info('Qrcode page show called'); + } + + onBuildDone() { + console.info('Qrcode page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`Qrcode page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + QRCode('hello world') + .color("#FFFFC0CB") + .backgroundColor(this.Color) + .width("200") + .height("100") + .key('qrcode') + } + } +} + + diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Rating.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Rating.ets new file mode 100644 index 0000000000000000000000000000000000000000..b29e26a392fca6f15a5b7f0eb4156dd3bc767c3f --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Rating.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct rating_testcase { + @State rating: number = 2 + + onPageShow() { + console.info('Rating page show called'); + } + + onBuildDone() { + console.info('Rating page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Rating page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Rating({ rating: 2, indicator: false }) + .stepSize(0.5) + .stars(5) + .starStyle({ + backgroundUri: '/resources/rawfile/star-1-1.png', + foregroundUri: '/resources/rawfile/star-1-3.png', + secondaryUri: '/resources/rawfile/star-1-2.png' + }) + .onChange((value: number) => { + this.rating = value + }) + .key('rating1') + Rating({ rating: 2, indicator: true }) + .stepSize(0.5) + .stars(5) + .starStyle({ + backgroundUri: '/resources/rawfile/star-1-1.png', + foregroundUri: '/resources/rawfile/star-1-3.png', + secondaryUri: '/resources/rawfile/star-1-2.png' + }) + .key('rating2') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/RowSplit.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/RowSplit.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f4f397b13b83e98ac643633309b02858f337eb0 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/RowSplit.ets @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct rowSplit_testcase { + @State resizeable: boolean = false + private content: string = "rowSplit Page"; + + onPageShow() { + console.info('RowSplit page show called'); + } + + onBuildDone() { + console.info('RowSplit page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + RowSplit() { + Column() { + Text('Demo1.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + + Column() { + Text('Demo2.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + } + .height(100) + .key('rowSplit') + .resizeable(this.resizeable) + .onClick(() => { + router.back() + }) + + RowSplit() { + Column() { + Text('Demo3.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + + Column() { + Text('Demo4.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + }.height(100) + .key('rowSplit1') + .resizeable(true) + } + .key('flex') + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Scroll.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Scroll.ets new file mode 100644 index 0000000000000000000000000000000000000000..363089d22580febed16b983d8a4b2877cde52bec --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Scroll.ets @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct scroll_testcase { + @State scrollBarWidth: number = 20 + @State scrollable: ScrollDirection = ScrollDirection.None + @State scrollBarColor: Color = Color.Pink + @State scrollBar: BarState= BarState.On + private value1: Array = [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30] + @State edge: Edge= Edge.Top + private content: string = "Scroll Page"; + scroller: Scroller = new Scroller(); + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Scroll(this.scroller) { + Column() { + ForEach( + this.value1, + item => { + Text(`${item}`) + .fontSize(15) + .width(400) + .margin(10) + .height(70) + .backgroundColor(0xfff5deb3) + }, + item => item + ) + } + } + .scrollable(ScrollDirection.Vertical) + .scrollBar(this.scrollBar) + .scrollBarColor(this.scrollBarColor) + .scrollBarWidth(this.scrollBarWidth) + .key('scroll') + .width(400) + .height(200) + .onScroll((xOffset: number, yOffset: number) => { + console.info(` current offset is ${xOffset} ${yOffset}`) + }) + .onScrollEnd(() => { + console.info(` now on scroll end`) + }) + .onScrollEdge((side: Edge) => { + console.info(`To the edge`) + }) + Scroll() { + Row() { + Text('scroll uppppp') + .width(60) + .height(100) + .backgroundColor(Color.Yellow) + .margin({ + right: 5, + left: 5 + }) + .key('text') + + Text('scroll to') + .width(60) + .height(100) + .backgroundColor(Color.Green) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollTo({ + xOffset: 100, + yOffset: 100, + }) + }) + Text('scroll page') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollPage({ + next: true + }) + }) + Text('scroll Edge') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollEdge(Edge.Top) + }) + Text('scroll Edge') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.currentOffset() + }) + Text('scroll to index') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollToIndex(0) + console.info(` now on scroll end`) + }) + } + } + .key('scroll1') + .height(100) + .scrollable(ScrollDirection.Horizontal) + + Scroll() { + Column() { + Text("start").fontSize(30) + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + } + } + .padding(10) + .scrollable(ScrollDirection.None) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Red) + .scrollBarWidth(5) + .width(300) + .height(200) + .key('scroll2') + + Scroll() { + Column() { + Text("start").fontSize(30) + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + } + } + .padding(10) + .scrollable(ScrollDirection.Free) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Red) + .scrollBarWidth(5) + .width(300) + .height(200) + .key('scroll3') + } + .key('flex') + + } +} diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Slider.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Slider.ets new file mode 100644 index 0000000000000000000000000000000000000000..625cd02874f16e9debb7638322624f890e08fa62 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Slider.ets @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct slider { + @State inSetValue: number= 40 + @State outSetValue: number= 40 + @State direction: Axis= Axis.Horizontal + @State Begin: number = SliderChangeMode.Begin + + onPageShow() { + console.info('Slider page show called'); + } + + onBuildDone() { + console.info('Slider page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Slider page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Slider({ + value: this.outSetValue, + min: 0, + max: 100, + step: 1, + direction: Axis.Horizontal, + reverse: false, + style: SliderStyle.OutSet + }) + .blockColor('#FFFF0000') + .selectedColor('#FF0000FF') + .trackColor('#FF808080') + .minLabel('10') + .maxLabel('10') + .showTips(false) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + this.outSetValue = value + this.Begin = mode + console.info('value: ' + value + '---mode: ' + mode) + }) + .width("100") + .height("100") + .key('slider1') + Slider({ + value: 40, + min: 0, + max: 100, + step: 1, + style: SliderStyle.InSet + }) + .blockColor(Color.Red) + .selectedColor(Color.Blue) + .trackColor(Color.Gray) + .showTips(true) + .showSteps(true) + .key('slider2') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Span.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Span.ets new file mode 100644 index 0000000000000000000000000000000000000000..df5a71043f1ae000b822646f6b56df7ae103fa1f --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Span.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct span_textcase { + + onPageShow() { + console.info('Span page show called'); + } + + onBuildDone() { + console.info('Span page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text() { + Span('Test Span demo') + .decoration({ type: TextDecorationType.LineThrough, "color": Color.Red }) + .textCase(TextCase.UpperCase) + .fontColor(Color.Blue) + .fontSize("20fp") + .letterSpacing(5) + .fontFamily("sans-serif") + .fontWeight(FontWeight.Bold) + .fontStyle(FontStyle.Italic) + .key('span1') + Span('The second test Span demo') + .textCase(TextCase.LowerCase) + .fontColor(Color.Black) + .letterSpacing('5') + .fontSize(30) + .key('span2') + Span('The third test Span demo') + .textCase(TextCase.Normal) + .fontColor(Color.Yellow) + .fontSize("30fp") + .key('span3') + } + } + .width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(4) + } + } +} + + + diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Stack.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Stack.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a694889f0e768afbd3e3af6a17c3af9d8738cfb --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Stack.ets @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct stack_testcase { + @State alignContent: Alignment = Alignment.Bottom + private content: string = "Stack Page"; + + onPageShow() { + console.info('Stack page show called'); + } + + onBuildDone() { + console.info('Stack page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Stack({ alignContent: this.alignContent }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + } + .width('100%') + .height(80) + .margin({ top: 5 }) + .key('stack') + .onClick(() => { + router.back() + }) + + Stack({ alignContent: Alignment.BottomStart }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack1') + + Stack({ alignContent: Alignment.BottomEnd }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack2') + + Stack({ alignContent: Alignment.Start }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack3') + + Stack({ alignContent: Alignment.Center }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack4') + + Stack({ alignContent: Alignment.End }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack5') + + Stack({ alignContent: Alignment.Top }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack6') + + Stack({ alignContent: Alignment.TopStart }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack7') + + Stack({ alignContent: Alignment.TopEnd }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack8') + } + .key('flex') + .width('100%') + .height('100%') + + } +} + diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Text.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Text.ets new file mode 100644 index 0000000000000000000000000000000000000000..fbd1415dc815b0f1966476c430f7d69e28e587ee --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/Text.ets @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2021 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. + */ + +// @ts-nocheck +import router from '@system.router' + +var paramInfo = router.getParams() +console.info("cd paramInfo" + JSON.stringify(paramInfo)) + +@Entry +@Component +struct text_textcase { + @State textAlign: TextAlign= TextAlign.End + @State lineHeight: string= '15fp' + @State overflow: TextOverflow = TextOverflow.Ellipsis + @State textOverflow: textOverflow<{ "overflow": TextOverflow }> = { "overflow": this.overflow } + @State maxLines: number = 2 + @State baselineOffset: number = 0 + @State textCase: TextCase= TextCase.Normal + @State decoration: decoration<{ + type: TextDecorationType, + color: Color + }> = { type: TextDecorationType.Underline, color: Color.Red } + @State color: Color = Color.Red + @State width: string= "200" + @State height: string= "100" + @State size: size = { width: 200, height: 100 } + @State marginBottom: string = "10px" + @State marginTop: string = "10px" + @State marginLeft: string = "10px" + @State marginRingt: string= "10px" + @State paddingBottom: string= "5" + @State paddingTop: string= "5" + @State paddingLeft: string= "5" + @State paddingRingt: string= "5" + @State constraintSize: constraintSize = { minWidth: 20, maxWidth: 200, minHeight: 0, maxHeight: 50 } + @State layoutPriority: string= "9px" + @State layoutWeight: string = "10px" + @State align: Alignment = Alignment.Center + @State direction: Direction = Direction.Auto + @State position: position<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State markAnchor: markAnchor<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State offset: offset<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State flexGrow: number = 5 + @State flexShrink: number = 2 + @State flexBasis: number = 0 + @State alignSelf: ItemAlign = ItemAlign.Auto + @State borderStyle: BorderStyle = BorderStyle.Dashed + @State borderRadius: number = 10 + @State borderWidth: string= "4px" + @State borderColor: Color= Color.Blue + @State backgroundColor: Color = Color.Pink + @State backgroundImageSize: ImageSize = ImageSize.Cover + @State backgroundImagePosition: Alignment= Alignment.Center + @State opacity: number= 1 + @State visibility: Visibility= Visibility.Visible + @State enabled: boolean = false + @State zIndex: number = 1 + @State fontStyle: FontStyle = FontStyle.Italic + @State fontSize: number = 15 + @State minFontSize: number = 15 + @State maxFontSize: number = 15 + @State letterSpacing: number= 10 + @State fontWeight: FontWeight= FontWeight.Bold + @State fontColor: Color= Color.Black + @State active: boolean = false + private content: string = "Text Page"; + + onPageShow() { + console.info('Text page show called'); + } + + onBuildDone() { + console.info('Text page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .width(this.width) + .height(this.height) + .padding({ bottom: this.paddingBottom, top: this.paddingTop, right: this.paddingRingt, left: this.paddingLeft }) + .margin({ bottom: this.marginBottom, top: this.marginTop, right: this.marginRingt, left: this.marginLeft }) + .constraintSize(this.constraintSize) + .layoutWeight(this.layoutWeight) + .align(this.align) + .direction(this.direction) + .position(this.position) + .markAnchor(this.markAnchor) + .offset(this.offset) + .flexBasis(this.flexBasis) + .flexGrow(this.flexGrow) + .flexShrink(this.flexShrink) + .alignSelf(this.alignSelf) + .borderStyle(this.borderStyle) + .borderRadius(this.borderRadius) + .borderWidth(this.borderWidth) + .borderColor(this.borderColor) + .backgroundColor(this.backgroundColor) + .opacity(this.opacity) + .visibility(this.visibility) + .enabled(this.enabled) + .zIndex(this.zIndex) + .fontColor(this.fontColor) + .fontSize(this.fontSize) + .minFontSize(this.minFontSize) + .letterSpacing(this.letterSpacing) + .maxFontSize(this.maxFontSize) + .fontWeight(this.fontWeight) + .fontStyle(this.fontStyle) + .fontFamily("sans-serif") + .textAlign(this.textAlign) + .textOverflow(this.textOverflow) + .lineHeight(this.lineHeight) + .baselineOffset(this.baselineOffset) + .maxLines(2) + .textCase(this.textCase) + .decoration(this.decoration) + .aspectRatio(1) + .fontColor(Color.Black) + .key('Text') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .size({ width: 100, height: 50 }) + .padding({ bottom: 5, top: 5, right: 5, left: 10 }) + .margin({ bottom: 15, top: 10, right: 10, left: 10 }) + .fontSize('13') + .textAlign(TextAlign.Start) + .align(Alignment.Start) + .direction(Direction.Ltr) + .alignSelf(ItemAlign.Start) + .borderStyle(BorderStyle.Dotted) + .borderWidth(2) + .visibility(Visibility.Hidden) + .enabled(true) + .fontWeight(FontWeight.Normal) + .textAlign(TextAlign.Start) + .textOverflow(TextOverflow.Clip) + .maxLines(2) + .textCase(TextCase.LowerCase) + .decoration({ "type": TextDecorationType.LineThrough, "color": Color.Red }) + .fontColor(Color.White) + .key('Text1') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .width('100%') + .textAlign(TextAlign.Center) + .align(Alignment.TopEnd) + .direction(Direction.Rtl) + .alignSelf(ItemAlign.Center) + .borderStyle(BorderStyle.Solid) + .borderWidth(2) + .visibility(Visibility.None) + .fontWeight(FontWeight.Bolder) + .textAlign(TextAlign.Center) + .textOverflow(TextOverflow.None) + .textCase(TextCase.UpperCase) + .decoration({ "type": TextDecorationType.None, "color": Color.Red }) + .fontColor(Color.Blue) + .key('Text2') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.Top) + .alignSelf(ItemAlign.End) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Lighter) + .decoration({ type: TextDecorationType.Overline, color: Color.Red }) + .fontColor(Color.Gray) + .key('Text3') + Text('Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.TopStart) + .alignSelf(ItemAlign.Baseline) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Medium) + .fontColor(Color.Brown) + .key('Text4') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.End) + .alignSelf(ItemAlign.Stretch) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Regular) + .fontColor(Color.Grey) + .key('Text5') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.BottomEnd) + .width('100%') + .fontColor(Color.Orange) + .key('Text6') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.Bottom) + .width('100%') + .fontColor(Color.Yellow) + .key('Text7') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.BottomStart) + .width('100%') + .key('Text8') + + } + .key('flex') + .width('100%') + .height('100%') + } +} + + diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/index.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..10359134da915c9b44b0836ba4881bca71f43f33 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,65 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 file from '@system.file'; + +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; +import testsuite from "../test/List.test.ets"; +import featureAbility from "@ohos.ability.featureAbility"; + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + Want.parameters['timeout'] = 100000 + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('ACE ETS TEST') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/test/List.test.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..19c443805757f1926834fd2f8244eccf1c1bf585 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2021 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. + */ + +//contact import +import PerformanceTest from './contact/Performance_test.js' + +export default function testsuite() { + //contact + PerformanceTest(); +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/test/Utils.ets b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..65f70088ddb62bcf80f4e0ec07dc841a8ab033f0 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,119 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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. + */ + +export default class Utils { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + static notCheck = true; + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } + + static async swipe(downX, downY, upX, upY, steps) { + console.info('start to swipe') + this.drags(downX, downY, upX, upY, steps, false) + } + + static async drag(downX, downY, upX, upY, steps) { + console.info('start to drag') + this.drags(downX, downY, upX, upY, steps, true) + } + + static async drags(downX, downY, upX, upY, steps, drag) { + var xStep; + var yStep; + var swipeSteps; + var ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + var downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('start to move') + if (drag) { + await this.sleep(500) + } + for (var i = 1;i <= swipeSteps; i++) { + var movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('start to up') + if (drag) { + await this.sleep(100) + } + var upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) + } +} + + + + diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/test/contact/Performance_test.js b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/test/contact/Performance_test.js new file mode 100644 index 0000000000000000000000000000000000000000..f54c33bbf9970e5479cbbda579b0cc5bc73ec3b5 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/test/contact/Performance_test.js @@ -0,0 +1,627 @@ +/* + * Copyright (c) 2021 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 featureAbility from '@ohos.ability.featureAbility'; +import ohosDataAbility from '@ohos.data.dataability'; +import utils from '../Utils.ets' +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'deccjsunit/index' + +const URI_CALLLOG = "dataability:///com.ohos.calllogability"; +const calllogUri = "dataability:///com.ohos.calllogability/calls/calllog"; +const URI_VOICEMAIL = "dataability:///com.ohos.voicemailability"; +const voicemailUri = "dataability:///com.ohos.voicemailability/calls/voicemail"; +const URI_CONTACTS = "dataability:///com.ohos.contactsdataability"; +const rawContactUri = "dataability:///com.ohos.contactsdataability/contacts/raw_contact"; +const contactDataUri = "dataability:///com.ohos.contactsdataability/contacts/contact_data"; +const deletedUri = "dataability:///com.ohos.contactsdataability/contacts/deleted_raw_contact"; + +export default function PerformanceTest() { + describe('PerformanceTest', function () { + console.log(' PerformanceTest is start'); + + function sleep(numberMillis) { + var now = new Date(); + var exitTime = now.getTime() + numberMillis; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) + return; + } + } + + /** + * @tc.number raw_contact_insert_performance_test_900 + * @tc.name The raw_contact table adds 10000 pieces of data, and the time consumption is calculated according to + * the running time of the use case + * @tc.desc Function test + */ + it("raw_contact_insert_performance_test_900", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var listAddBluk = []; + for (var i = 0; i < 1000; i++) { + var add = { + "display_name": "xiaoli" + i, "company": "testCompany" + i, "position": "testPosition" + i + }; + listAddBluk[i] = add; + } + try { + let old = new Date(); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + let now = new Date(); + let usedTime = now - old; + console.info('raw_contact_insert_performance_test_900 usedTime = ' + usedTime); + expect(usedTime < 70000).assertTrue(); + sleep(5000); + console.info("logMessage raw_contact_insert_performance_test_900: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + done(); + } catch (error) { + console.info('logMessage raw_contact_insert_performance_test_900: insert error = ' + error); + done(); + } + }); + + /** + * @tc.number raw_contact_update_performance_test_1000 + * @tc.name The raw_contact table updates data whose ID is not equal to 0, and the time consumption is calculated + * according to the running time of the use case + * @tc.desc Function test + */ + it("raw_contact_update_performance_test_1000", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var updateValues = { + "favorite": 1 + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + let old = new Date(); + var updateCode = await DAHelper.update(rawContactUri, updateValues, condition); + let now = new Date(); + let usedTime = now - old; + console.info('raw_contact_update_performance_test_1000 usedTime = ' + usedTime); + expect(usedTime < 3000).assertTrue(); + sleep(5000); + console.info("logMessage raw_contact_update_performance_test_1000: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("logMessage raw_contact_update_performance_test_1000: update error = " + error); + done(); + } + }); + + /** + * @tc.number raw_contact_query_performance_test_1100 + * @tc.name The raw_ contact table queries 10000 pieces of data and calculates the time consumption according to + * the running time of the use case + * @tc.desc Function test + */ + it("raw_contact_query_performance_test_1100", 0, async function (done) { + var tag = "raw_contact_query_performance_test_1100"; + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': start ! DAHelper = ' + DAHelper); + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + let old = new Date(); + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + let now = new Date(); + let usedTime = now - old; + console.info('raw_contact_query_performance_test_1100 usedTime = ' + usedTime); + expect(usedTime < 2000).assertTrue(); + sleep(5000); + console.info(tag + ' : logMessage : rowCount' + resultSet.rowCount); + expect(resultSet.rowCount == 10000).assertTrue(); + resultSet.close(); + done(); + } catch (error) { + console.info(tag + " :logMessage : error = " + error); + done(); + } + }); + + /** + * @tc.number raw_contact_delete_performance_test_1200 + * @tc.name The raw_contact table deletes 10000 pieces of data, and the time consumption is calculated according + * to the running time of the use case + * @tc.desc Function test + */ + it("raw_contact_delete_performance_test_1200", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('raw_contact_delete_performance_test_1200 : start ! DAHelper = ' + DAHelper); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + let old = new Date(); + var deleteCode = await DAHelper.delete(rawContactUri, condition); + let now = new Date(); + let usedTime = now - old; + console.info('raw_contact_delete_performance_test_1200 usedTime = ' + usedTime); + expect(usedTime < 10000).assertTrue(); + sleep(5000); + console.info("logMessage raw_contact_delete_performance_test_1200: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + done(); + } catch (error) { + console.info('logMessage raw_contact_delete_performance_test_1200: delete error = ' + error); + done(); + } + }); + + /** + * @tc.number contact_data_insert_performance_test_1300 + * @tc.name The contact_data table adds 10000 pieces of data, and the time consumption is calculated according to + * the running time of the use case + * @tc.desc Function test + */ + it("contact_data_insert_performance_test_1300", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoli", + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contact_data_insert_performance_test_1300: rawContactId = " + rawContactId); + } catch (error) { + console.info("logMessage contact_data_insert_performance_test_1300: raw_contact insert error = " + error); + } + + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + var deleteCode = await DAHelper.delete(rawContactUri, condition); + sleep(1000); + console.info("logMessage contact_data_insert_performance_test_1300: deleteCode = " + deleteCode); + + var listAddBluk = []; + for (var i = 0; i < 1000; i++) { + var add = { + "raw_contact_id": rawContactId, "detail_info": "xxx" + i, "content_type": "name" + }; + listAddBluk[i] = add; + } + try { + let old = new Date(); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + let now = new Date(); + let usedTime = now - old; + console.info('contact_data_insert_performance_test_1300 usedTime = ' + usedTime); + expect(usedTime < 70000).assertTrue(); + sleep(5000); + console.info("logMessage contact_data_insert_performance_test_1300: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + done(); + } catch (error) { + console.info('logMessage contact_data_insert_performance_test_1300: insert error = ' + error); + done(); + } + }); + + /** + * @tc.number contact_data_update_performance_test_1400 + * @tc.name The contact_data table updates data whose ID is not equal to 0, and the time consumption is + * calculated according to the running time of the use case + * @tc.desc Function test + */ + it("contact_data_update_performance_test_1400", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage contact_data_update_performance_test_1400 DAHelper success! DAHelper = ' + DAHelper); + var updateValues = { + "syn_1": "test" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + let old = new Date(); + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition); + let now = new Date(); + let usedTime = now - old; + console.info('contact_data_update_performance_test_1400 usedTime = ' + usedTime); + expect(usedTime < 50000).assertTrue(); + sleep(8000); + console.info("logMessage contact_data_update_performance_test_1400: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("logMessage contact_data_update_performance_test_1400: update error = " + error); + done(); + } + }); + + /** + * @tc.number contact_data_query_performance_test_1500 + * @tc.name The contact_datat table queries 10000 pieces of data and calculates the time consumption according to + * the running time of the use case + * @tc.desc Function test + */ + it("contact_data_query_performance_test_1500", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('contact_data_query_performance_test_1500 start ! DAHelper = ' + DAHelper); + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + let old = new Date(); + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + let now = new Date(); + let usedTime = now - old; + console.info('contact_data_query_performance_test_1500 usedTime = ' + usedTime); + expect(usedTime < 4000).assertTrue(); + sleep(5000); + console.info('logMessage contact_data_query_performance_test_1500: goToFirstRow' + resultSet.rowCount); + expect(resultSet.rowCount == 10000).assertEqual(true); + resultSet.close(); + done(); + } catch (error) { + console.info("logMessage contact_data_query_performance_test_1500: error = " + error); + done(); + } + }); + + /** + * @tc.number contact_data_delete_performance_test_1600 + * @tc.name The contact_data table deletes 10000 pieces of data, and the time consumption is calculated according + * to the running time of the use case + * @tc.desc Function test + */ + it("contact_data_delete_performance_test_1600", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('contact_data_delete_performance_test_1600 : start ! DAHelper = ' + DAHelper); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + let old = new Date(); + var deleteCode = await DAHelper.delete(contactDataUri, condition); + let now = new Date(); + let usedTime = now - old; + console.info('contact_data_delete_performance_test_1600 usedTime = ' + usedTime); + expect(usedTime < 40000).assertTrue(); + sleep(5000); + console.info("logMessage contact_data_delete_performance_test_1600: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + done(); + } catch (error) { + console.info('logMessage contact_data_delete_performance_test_1600: delete error = ' + error); + done(); + } + }); + + /** + * @tc.number calllog_insert_performance_test_100 + * @tc.name The callog table adds 10000 pieces of data, and the time consumption is calculated according to the + * running time of the use case + * @tc.desc Function test + */ + it("calllog_insert_performance_test_100", 0, async function (done) { + console.info("---------logMessage calllog_insert_performance_test_100 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var listAddBluk = []; + for (var i = 0; i < 1000; i++) { + var add = { + "phone_number": "1511002" + i + }; + listAddBluk[i] = add; + } + try { + let old = new Date(); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + let now = new Date(); + let usedTime = now - old; + console.info('calllog_insert_performance_test_100 usedTime = ' + usedTime); + expect(usedTime < 100000).assertTrue(); + sleep(5000); + console.info("logMessage calllog_insert_performance_test_100: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("logMessage calllog_insert_performance_test_100: batchInsert error = " + error); + done(); + } + }); + + /** + * @tc.number calllog_update_performance_test_200 + * @tc.name The callog table updates data whose ID is not equal to 0, and the time consumption is calculated + * according to the running time of the use case + * @tc.desc Function test + */ + it("calllog_update_performance_test_200", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var updateValues = { + "answer_state": "1" + }; + try { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.notEqualTo("id", 0); + let old = new Date(); + var updateCode = await DAHelper.update(calllogUri, updateValues, condition); + let now = new Date(); + let usedTime = now - old; + console.info('calllog_update_performance_test_200 usedTime = ' + usedTime); + expect(usedTime < 1000).assertTrue(); + sleep(5000); + console.info("logMessage calllog_update_performance_test_200: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("logMessage calllog_update_performance_test_200: update error = " + error); + done(); + } + ; + }); + + /** + * @tc.number calllog_query_performance_test_300 + * @tc.name The callog table queries 10000 pieces of data to see whether they can be queried successfully + * @tc.desc Function test + */ + it("calllog_query_performance_test_300", 0, async function (done) { + var tag = "calllog_query_performance_test_300"; + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info(tag + ': start ! DAHelper = ' + DAHelper); + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.notEqualTo("id", 0); + + try { + let old = new Date(); + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + let now = new Date(); + let usedTime = now - old; + console.info('calllog_query_performance_test_300 usedTime = ' + usedTime); + expect(usedTime < 1000).assertTrue(); + sleep(5000); + console.info(tag + ' : logMessage : rowCount' + resultSet.rowCount); + expect(resultSet.rowCount == 10000).assertTrue(); + resultSet.close(); + done(); + } catch (error) { + console.info("logMessage calllog_query_performance_test_300: error = " + error); + done() + } + }); + + /** + * @tc.number calllog_delete_performance_test_400 + * @tc.name The callog table deletes 10000 pieces of data, and the time consumption is calculated according to + * the running time of the use case + * @tc.desc Function test + */ + it("calllog_delete_performance_test_400", 0, async function (done) { + var tag = "calllog_delete_performance_test_400"; + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info(tag + ': start ! DAHelper = ' + DAHelper); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + let old = new Date(); + var deleteCode = await DAHelper.delete(calllogUri, condition); + let now = new Date(); + let usedTime = now - old; + console.info('calllog_delete_performance_test_400 usedTime = ' + usedTime); + expect(usedTime < 10000).assertTrue(); + sleep(5000); + console.info(tag + " : logMessage : deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + done(); + }); + + /** + * @tc.number voicemail_insert_performance_test_500 + * @tc.name The voicemail table adds 10000 pieces of data, and the time consumption is calculated according to + * the running time of the use case + * @tc.desc Function test + */ + it("voicemail_insert_performance_test_500", 0, async function (done) { + console.info("---------logMessage voicemail_insert_performance_test_500 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var listAddBluk = []; + for (var i = 0; i < 1000; i++) { + var add = { + "phone_number": "12345" + i + }; + listAddBluk[i] = add; + } + try { + let old = new Date(); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + let now = new Date(); + let usedTime = now - old; + console.info('voicemail_insert_performance_test_500 usedTime = ' + usedTime); + expect(usedTime < 100000).assertTrue(); + sleep(5000); + console.info("logMessage voicemail_insert_performance_test_500: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("logMessage voicemail_insert_performance_test_500: batchInsert error = " + error); + done(); + } + }); + + /** + * @tc.number voicemail_update_performance_test_600 + * @tc.name The voicemail table updates data whose ID is not equal to 0, and the time consumption is calculated + * according to the running time of the use case + * @tc.desc Function test + */ + it("voicemail_update_performance_test_600", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var updateValues = { + "origin_type": "test" + }; + try { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.notEqualTo("id", 0); + let old = new Date(); + var updateCode = await DAHelper.update(voicemailUri, updateValues, condition); + let now = new Date(); + let usedTime = now - old; + console.info('voicemail_update_performance_test_600 usedTime = ' + usedTime); + expect(usedTime < 10000).assertTrue(); + sleep(5000); + console.info("logMessage voicemail_update_performance_test_600: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("logMessage voicemail_update_performance_test_600: update error = " + error); + done(); + } + ; + }); + + /** + * @tc.number voicemail_query_performance_test_700 + * @tc.name The voicemail table queries 10000 items, and the time consumption is calculated according to the + * running time of the use case + * @tc.desc Function test + */ + it("voicemail_query_performance_test_700", 0, async function (done) { + var tag = "voicemail_query_performance_test_700"; + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info(tag + ': start ! DAHelper = ' + DAHelper); + var resultColumns = []; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + let old = new Date(); + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition); + let now = new Date(); + let usedTime = now - old; + console.info('voicemail_query_performance_test_700 usedTime = ' + usedTime); + expect(usedTime < 500).assertTrue(); + sleep(5000); + console.info(tag + ' : logMessage : rowCount' + resultSet.rowCount); + expect(resultSet.rowCount == 10000).assertTrue(); + resultSet.close(); + done(); + } catch (error) { + console.info("logMessage voicemail_query_performance_test_700: error = " + error); + done() + } + }); + + /** + * @tc.number voicemail_delete_performance_test_800 + * @tc.name The voicemail table deletes 10000 pieces of data, and the time consumption is calculated according to + * the running time of the use case + * @tc.desc Function test + */ + it("voicemail_delete_performance_test_800", 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + var tag = "voicemail_delete_performance_test_800"; + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info(tag + ': start ! DAHelper = ' + DAHelper); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + let old = new Date(); + var deleteCode = await DAHelper.delete(voicemailUri, condition); + let now = new Date(); + let usedTime = now - old; + console.info('voicemail_delete_performance_test_800 usedTime = ' + usedTime); + expect(usedTime < 500).assertTrue(); + sleep(5000); + console.info(tag + " : logMessage : deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("logMessage voicemail_delete_performance_test_800: error = " + error); + done(); + } + }); + + afterAll(async function () { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('DeleteContact : start ! DAHelper = ' + DAHelper); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.notEqualTo("id", "0"); + try { + var resultColumns = ["id"]; + var conditionDelete = new ohosDataAbility.DataAbilityPredicates(); + conditionDelete.greaterThan("id", "0"); + var count = 0; + var deleteCount = 9999; + while (count < deleteCount) { + var result = await DAHelper.query(deletedUri, resultColumns, conditionDelete); + console.info("performance : result.rowCount = " + result.rowCount); + count = result.rowCount; + result.close(); + sleep(5000); + } + var deleteCode = await DAHelper.delete(deletedUri, condition); + console.info("afterAll logMessage DeleteContact: deleteCode = " + deleteCode); + } catch (error) { + console.info('afterAll logMessage DeleteContact: delete error = ' + error); + } + }); + }) +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/test/lib/Const.js b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/test/lib/Const.js new file mode 100644 index 0000000000000000000000000000000000000000..f9263cd46dee1a0ffdfaa1e5ef5c29755c7e13f7 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/ets/MainAbility/test/lib/Const.js @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2021 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. + */ + +// sim slot id +export const DEFAULT_SLOTID = 0; +export const SLOTID3 = 3; +export const SLOTID2 = 2; +export const SLOTID_MINUS1 = -1; + +// sim correct password +export const CORRECT_PIN = '1234'; +export const CORRECT_PIN2 = '18099014'; + +// sim incorrect password +export const INCORRECT_PIN = '134679'; +export const INCORRECT_PIN_LEN3 = '123'; +export const INCORRECT_PUK = '134679'; +export const INCORRECT_PIN2 = '134679'; +export const INCORRECT_PIN2_LEN3 = '123'; +export const INCORRECT_PIN2_LEN9 = '123456789'; +export const INCORRECT_PUK2 = '134679'; + +// lock status response +export const LOCK_RESULT = { SUCCESS: 0, FAILURE: -1, EXCEPTION: -2 }; \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03b8532c53ca563f8ed6b1e21d20ad3f67a68906 --- /dev/null +++ b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/resources/base/media/icon.png b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/hand.png b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/hand.png new file mode 100644 index 0000000000000000000000000000000000000000..9f1fa16ee073093b40920e273502513fa66fa980 Binary files /dev/null and b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/hand.png differ diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/icon.png b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/icon.png differ diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/images.jpg b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/images.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c75ddfc5ead15e8d49ca7cae9f97c03585565be1 Binary files /dev/null and b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/images.jpg differ diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/person.png b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/person.png new file mode 100644 index 0000000000000000000000000000000000000000..f0f540d078e6c0441a763ca2cc375a551d6cf736 Binary files /dev/null and b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/person.png differ diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/star-1-1.png b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/star-1-1.png new file mode 100644 index 0000000000000000000000000000000000000000..990c5e5ad20698c7701faf641bc80eb004a127b7 Binary files /dev/null and b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/star-1-1.png differ diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/star-1-2.png b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/star-1-2.png new file mode 100644 index 0000000000000000000000000000000000000000..450c3dd3ca68bf601bd08e5f41797d376e20d00d Binary files /dev/null and b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/star-1-2.png differ diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/star-1-3.png b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/star-1-3.png new file mode 100644 index 0000000000000000000000000000000000000000..1044869832b423a5dfc2559a395529377bd34f0c Binary files /dev/null and b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/star-1-3.png differ diff --git a/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/video/show.mp4 b/telephony/telephonyjstest/contact_performance/entry/src/main/resources/rawfile/video/show.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/telephony/telephonyjstest/contact_performance/signature/openharmony_sx.p7b b/telephony/telephonyjstest/contact_performance/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/telephony/telephonyjstest/contact_performance/signature/openharmony_sx.p7b differ diff --git a/telephony/telephonyjstest/contact_stability/BUILD.gn b/telephony/telephonyjstest/contact_stability/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0bd78c4a9e52f801324579297cd904a706c29f1e --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 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("ActsContactStabilityEtsTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":ace_demo_ets_assets", + ":ace_demo_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsContactStabilityEtsTest" +} +ohos_js_assets("ace_demo_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("ace_demo_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/telephony/telephonyjstest/contact_stability/Test.json b/telephony/telephonyjstest/contact_stability/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..197a0b94631dfda2c74fd236e8f2bd1b336ce0fd --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "1800000", + "package": "com.ohos.contactstability", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsContactStabilityEtsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/config.json b/telephony/telephonyjstest/contact_stability/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..5aebc14516f11b4fbd5c36999a96cd03e618b0a5 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/config.json @@ -0,0 +1,93 @@ +{ + "app": { + "bundleName": "com.ohos.contactstability", + "vendor": "open", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.contactstability", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/Button", + "pages/Blank", + "pages/DataPanel", + "pages/Divider", + "pages/Text", + "pages/RowSplit", + "pages/Scroll", + "pages/Stack", + "pages/Image", + "pages/Progress", + "pages/Qrcode", + "pages/Rating", + "pages/Span", + "pages/Slider", + "pages/Badge", + "pages/Column", + "pages/ColumnSplit", + "pages/Counter", + "pages/Flex", + "pages/GridContainer" + + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/app.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..261fadca29ff0ea310a8bc105ddd1af65e2dd2f6 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Badge.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Badge.ets new file mode 100644 index 0000000000000000000000000000000000000000..66de6f8e3b9c0360931602dd25d1511878ac63ab --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Badge.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct badge { + @State counts: number = 33 + @State message: string = 'new' + @State active: boolean = false + private content: string = "badge Page"; + + onPageShow() { + console.info('badge page show called'); + } + + onBuildDone() { + console.info('badge page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Scroll() { + Column() { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Badge({ + count: this.counts, + position: BadgePosition.Right, + maxCount: 99, + style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge') + + Text("BadgePosition.RightTop").fontSize(16) + Badge({ + count: this.counts, + position: BadgePosition.RightTop, + maxCount: 99, + style: { color: 0xFFFFFF, fontSize: '16', badgeSize: '20', badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge1') + + Text("BadgePosition.Left").fontSize(16) + Badge({ + count: this.counts, + position: BadgePosition.Left, + maxCount: 99, + style: { color: Color.Pink, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge2') + } + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Blank.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Blank.ets new file mode 100644 index 0000000000000000000000000000000000000000..a50fc719e09ab27c91f9705ac06008e936830f33 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Blank.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct blank_testcase { + @State Color: Color = Color.Pink + @State active: boolean = false + private content: string = "Blank Page" + + onPageShow() { + console.info('Blank page show called'); + } + + onBuildDone() { + console.info('Blank page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Blank(100) + .color(this.Color) + .key('blank') + Text('on/off').fontSize(18).height(60) + } + .key('flex') + .width('100%') + .height('100%') + + + } +} diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Button.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Button.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac2271ea3a13664bbbb6afe4f173abae9e66f867 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Button.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct button_testcase { + @State stateEffect: boolean = true + @State ButtonType: ButtonType = ButtonType.Circle + private content: string = "Button Page"; + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button('1.value', { type: ButtonType.Circle, stateEffect: this.stateEffect }) + .fontSize(12) + .fontWeight(FontWeight.Bold) + .fontColor(0xCCCCCC) + .height(40) + .width(40) + .key('button') + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + .padding(10) + Button() { + Text("2.Capsule") + } + .type(ButtonType.Capsule) + .stateEffect(false) + .backgroundColor('#0D9FFB') + .padding(10) + .key('button1') + + Button() { + Text("3.Normal") + }.type(ButtonType.Normal) + .backgroundColor('#0D9FFB') + .key('button2') + + }.key('flex') + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Column.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Column.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9e5c84e21ccf25419be432d8f95418fac82070a --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Column.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct column { + @State active: boolean = false + private content: string = "Column Page" + + onPageShow() { + console.info('Column page show called'); + } + + onBuildDone() { + console.info('Column page build done called'); + } + + build() { + Column({ space: 5 }) { + Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Center).width('90%').border({ width: 1 }).key('column') + + Text('alignItems(Start)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column({ space: '5' }) { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Start).width('90%').border({ width: 1 }).key('column1') + + Text('alignItems(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.End).width('90%').border({ width: 1 }).key('column2') + }.width('100%').padding({ top: 5 }) + } +} diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb0597310a15be8ab4503a3ae89385e3708fac96 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct columnSplit { + private content: string = "ColumnSplit Page" + + onPageShow() { + console.info('ColumnSplit page show called'); + } + + onBuildDone() { + console.info('ColumnSplit page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Scroll() { + Column() { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Column() { + Text('ColumnSplit').fontSize(9).fontColor(0xCCCCCC).width('90%') + ColumnSplit() { + Text('1').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('2').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('3').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + }.key('columnSplit') + .resizeable(true) + .width('90%').height('60%') + + }.width("100%") + + Column() { + Text('ColumnSplit1').fontSize(9).fontColor(0xCCCCCC).width('90%') + ColumnSplit() { + Text('1').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('2').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('3').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + }.key('columnSplit1') + .resizeable(false) + .width('90%').height('60%') + + }.width("100%") + } + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Counter.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Counter.ets new file mode 100644 index 0000000000000000000000000000000000000000..ecdbfaf10393e7a348fd76098868e6455505b07f --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Counter.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct counter { + @State value: number = 0 + @State active: boolean = false + private content: string = "Counter Page" + + onPageShow() { + console.info('Counter page show called'); + } + + onBuildDone() { + console.info('Counter page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Counter() { + Text(this.value.toString()) + }.margin(100) + .key('counter') + .onInc(() => { + this.value++ + }) + .onDec(() => { + this.value-- + }) + }.width("100%") + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/DataPanel.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/DataPanel.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c624848482b22998b2a1d137796ddaedbcf198c --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/DataPanel.ets @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct dataPanel_testcase { + @State width: string= "200" + @State height: string= "100" + @State active: boolean = false + private content: string = "DataPanel Page" + + onPageShow() { + console.info('Blank page show called'); + } + + onBuildDone() { + console.info('Blank page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + DataPanel({ values: [20, 40, 20], max: 100, type: DataPanelType.Line }) + .width(this.width) + .height(this.height) + .key('DataPanel') + .onClick(() => { + router.back() + }) + .closeEffect(false) + + DataPanel({ values: [20, 40, 20], max: 100, type: DataPanelType.Circle}) + .width(this.width) + .height(this.height) + .key('DataPanel2') + .onClick(() => { + router.back() + }) + .closeEffect(true) + DataPanel({ values: [20, 40, 20], max: 100}) + .width(this.width) + .height(this.height) + .key('DataPanel3') + .onClick(() => { + router.back() + }) + .closeEffect(false) + } + .key('flex') + .width('100%') + .height('100%') + + } +} diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Divider.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Divider.ets new file mode 100644 index 0000000000000000000000000000000000000000..02bf60779418674d1fd58127907fdb3915bd8f8f --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Divider.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct divider_textcase { + @State vertical: boolean = true + @State color: Color = Color.Red + @State strokeWidth: number = 7 + @State lineCap: LineCapStyle = LineCapStyle.Butt + @State active: boolean = false + private content: string = "Divider Page"; + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + Divider() + .lineCap(LineCapStyle.Butt) + .strokeWidth(this.strokeWidth) + .color(this.color) + .vertical(this.vertical) + .height(150) + .key('divider') + .onClick(() => { + router.back() + }) + Divider() + .lineCap(LineCapStyle.Round) + .vertical(false) + .color(Color.Green) + .strokeWidth(10) + .height(150) + .key('divider1') + Divider() + .lineCap(LineCapStyle.Square) + .color(Color.Green) + .vertical(true) + .strokeWidth(10) + .height(150) + .key('divider2') + } + .key('flex') + .width('100%') + .height('100%') + } +} + + diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Flex.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Flex.ets new file mode 100644 index 0000000000000000000000000000000000000000..a0e21251e80008c5be9f29aa52074acc5eb24a78 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Flex.ets @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct flex { + private content: string = "Flex Page" + + onPageShow() { + console.info('Flex page show called'); + } + + onBuildDone() { + console.info('Flex page build done called'); + } + + build() { + Column() { + Column({ space : 2 }) { + Text('direction:Column').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Column, + wrap: FlexWrap.NoWrap, + justifyContent: FlexAlign.Center, + alignItems:ItemAlign.Start, + alignContent: FlexAlign.Start, + }) { + Text('1').width('100%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('100%').height(20).backgroundColor(0xD2B48C) + Text('3').width('100%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex') + .height(70) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('direction:Row').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.Start, + alignItems:ItemAlign.Start, + alignContent: FlexAlign.Center, + }) { + Text('1').width('20%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('20%').height(20).backgroundColor(0xD2B48C) + Text('3').width('20%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex1') + .height(70) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('direction:RowReverse').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.RowReverse, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.End, + alignItems:ItemAlign.End, + alignContent: FlexAlign.End, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex2') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent:SpaceBetween').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceBetween, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('100%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('100%').height(20).backgroundColor(0xD2B48C) + Text('3').width('100%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex3') + .height(100) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent AND alignContent').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceEvenly, + alignContent: FlexAlign.SpaceEvenly, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex4') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent AND alignContent').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceAround, + alignContent: FlexAlign.SpaceAround, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex5') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + }.width('100%').margin({ top: 5 }) + }.width('100%') + } +} diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/GridContainer.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/GridContainer.ets new file mode 100644 index 0000000000000000000000000000000000000000..57358110413406263e70a2a5f650cbfeb22a4387 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/GridContainer.ets @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct gridContainer { + @State sizeType: SizeType = SizeType.XS + @State active: boolean = false + private content: string = "GridContainer Page" + + onPageShow() { + console.info('GridContainer page show called'); + } + + onBuildDone() { + console.info('GridContainer page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Scroll() { + Column({ space: 5 }) { + GridContainer({ columns: 12, sizeType: this.sizeType, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer') + .width('90%') + .alignItems(HorizontalAlign.Start) + + Text('Click Simulate to change the device width').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() { + Button('XS') + .onClick(() => { + this.sizeType = SizeType.XS + }).backgroundColor(0x317aff) + Button('SM') + .onClick(() => { + this.sizeType = SizeType.SM + }).backgroundColor(0x317aff) + Button('MD') + .onClick(() => { + this.sizeType = SizeType.MD + }).backgroundColor(0x317aff) + Button('LG') + .onClick(() => { + this.sizeType = SizeType.LG + }).backgroundColor(0x317aff) + } + + GridContainer({ columns: "auto", sizeType: SizeType.MD, gutter: '10', margin: '20' }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer1') + .width('90%') + .alignItems(HorizontalAlign.Center) + + GridContainer({ columns: 12, sizeType: SizeType.SM, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer2') + .width('90%') + .alignItems(HorizontalAlign.End) + + GridContainer({ columns: 12, sizeType: SizeType.LG, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer3') + .width('90%') + .alignItems(HorizontalAlign.End) + + GridContainer({ columns: 12, sizeType: SizeType.Auto, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer4') + .width('90%') + .alignItems(HorizontalAlign.End) + + }.width('100%').margin({ top: 5 }) + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Image.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Image.ets new file mode 100644 index 0000000000000000000000000000000000000000..5cc583e931f51aa8e4f2bd55decfeeb14a40afb4 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Image.ets @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct image_textcase { + @State Width: number = 0 + @State height: number = 0 + + onPageShow() { + console.info('Image page show called'); + } + + onBuildDone() { + console.info('Image page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Image page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Image("/resources/rawfile/hand.png") + .matchTextDirection(false) + .fitOriginalSize(false) + .fillColor(0xCCCCCC) + .objectFit(ImageFit.Cover) + .objectRepeat(ImageRepeat.NoRepeat) + .interpolation(ImageInterpolation.None) + .renderMode(ImageRenderMode.Original) + .autoResize(false) + .syncLoad(false) + .sourceSize({ width: 200, height: 100 }) + .alt("/resources/rawfile/person.png") + .key('image1') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.Contain) + .objectRepeat(ImageRepeat.X) + .interpolation(ImageInterpolation.High) + .renderMode(ImageRenderMode.Template) + .key('image2') + .height(180) + .width(180) + .onComplete((msg: { + width: number, + height: number + }) => { + this.Width = msg.width + this.height = msg.height + console.info('Width ----' + this.Width) + console.info('height ----' + this.height) + }) + .onError(() => { + console.info('load image fail') + }) + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.Fill) + .objectRepeat(ImageRepeat.Y) + .interpolation(ImageInterpolation.Low) + .key('image3') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.None) + .objectRepeat(ImageRepeat.XY) + .interpolation(ImageInterpolation.Medium) + .key('image4') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.ScaleDown) + .key('image5') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(4) + } + } +} + + diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Navigator.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Navigator.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c50769cf2ab045cbe48b52e294b4105a21e1c3d --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Navigator.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct navigator_testcase { + @State active: boolean = false + @State params: Object = { text: 'news' } + + onPageShow() { + console.info('Navigator page show called'); + } + + onBuildDone() { + console.info('Navigator page build done called'); + } + + build() { + Column() { + Navigator({ target: "pages/index", type: NavigationType.Back }) { + Text('Navigator test in Navigator,back') + }.active(this.active) + .key('navigator') + .params({ + data: 24 + }) + + Navigator({ target: "pages/index", type: NavigationType.Push }) { + Text('Navigator test in Navigator,push') + }.active(this.active) + .key('navigator2') + .params({ + data: 24 + }) + + Navigator({ target: "pages/index", type: NavigationType.Replace }) { + Text('Navigator test in Navigator,replace') + }.active(this.active) + .key('navigator3') + .params({ + data: 24 + }) + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } +} diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Panel.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Panel.ets new file mode 100644 index 0000000000000000000000000000000000000000..32ddabbd1ccbae3805dd462e6f04b28364d6a1e7 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Panel.ets @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct PanelExample { + @State show: boolean = true + + onPageShow() { + console.info('Panel page show called'); + } + + onBuildDone() { + console.info('Panel page build done called'); + } + + build() { + Column() { + Text('2021-09-30 Today Calendar: 1.afternoon......Click for details') + .width('90%') + .height(50) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + .padding({ left: 20 }) + .onClick(() => { + this.show = !this.show + }) + Panel(this.show) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel') + .type(PanelType.Foldable) + .mode(PanelMode.Half) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + Panel(this.show) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel2') + .type(PanelType.Minibar) + .mode(PanelMode.Mini) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + Panel(false) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel3') + .type(PanelType.Temporary) + .mode(PanelMode.Full) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + }.width('100%').height('50%').backgroundColor(0xDCDCDC).padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Progress.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Progress.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8608089fe51e1988fd305fc49db028b6c2efe76 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Progress.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct progress_testcase { + onPageShow() { + console.info('Progress page show called'); + } + + onBuildDone() { + console.info('Progress page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Progress page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Progress({ value: 20, total: 40, style: ProgressStyle.Linear }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress') + + Progress({ value: 20, total: 40, style: ProgressStyle.Eclipse }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress2') + + Progress({ value: 20, total: 40, style: ProgressStyle.Ring }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress3') + + Progress({ value: 20, total: 40, style: ProgressStyle.ScaleRing }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress4') + + Progress({ value: 20, total: 40, style: ProgressStyle.Capsule }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress5') + + } + .width(400) + .height(400) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Qrcode.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Qrcode.ets new file mode 100644 index 0000000000000000000000000000000000000000..5c0dd84eff5a6653ee5fd940662d141025a1bb4e --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Qrcode.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct qrcode_textcase { + @State Color: Color = Color.Pink + + onPageShow() { + console.info('Qrcode page show called'); + } + + onBuildDone() { + console.info('Qrcode page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`Qrcode page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + QRCode('hello world') + .color("#FFFFC0CB") + .backgroundColor(this.Color) + .width("200") + .height("100") + .key('qrcode') + } + } +} + + diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Rating.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Rating.ets new file mode 100644 index 0000000000000000000000000000000000000000..b29e26a392fca6f15a5b7f0eb4156dd3bc767c3f --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Rating.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct rating_testcase { + @State rating: number = 2 + + onPageShow() { + console.info('Rating page show called'); + } + + onBuildDone() { + console.info('Rating page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Rating page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Rating({ rating: 2, indicator: false }) + .stepSize(0.5) + .stars(5) + .starStyle({ + backgroundUri: '/resources/rawfile/star-1-1.png', + foregroundUri: '/resources/rawfile/star-1-3.png', + secondaryUri: '/resources/rawfile/star-1-2.png' + }) + .onChange((value: number) => { + this.rating = value + }) + .key('rating1') + Rating({ rating: 2, indicator: true }) + .stepSize(0.5) + .stars(5) + .starStyle({ + backgroundUri: '/resources/rawfile/star-1-1.png', + foregroundUri: '/resources/rawfile/star-1-3.png', + secondaryUri: '/resources/rawfile/star-1-2.png' + }) + .key('rating2') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/RowSplit.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/RowSplit.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f4f397b13b83e98ac643633309b02858f337eb0 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/RowSplit.ets @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct rowSplit_testcase { + @State resizeable: boolean = false + private content: string = "rowSplit Page"; + + onPageShow() { + console.info('RowSplit page show called'); + } + + onBuildDone() { + console.info('RowSplit page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + RowSplit() { + Column() { + Text('Demo1.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + + Column() { + Text('Demo2.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + } + .height(100) + .key('rowSplit') + .resizeable(this.resizeable) + .onClick(() => { + router.back() + }) + + RowSplit() { + Column() { + Text('Demo3.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + + Column() { + Text('Demo4.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + }.height(100) + .key('rowSplit1') + .resizeable(true) + } + .key('flex') + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Scroll.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Scroll.ets new file mode 100644 index 0000000000000000000000000000000000000000..363089d22580febed16b983d8a4b2877cde52bec --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Scroll.ets @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct scroll_testcase { + @State scrollBarWidth: number = 20 + @State scrollable: ScrollDirection = ScrollDirection.None + @State scrollBarColor: Color = Color.Pink + @State scrollBar: BarState= BarState.On + private value1: Array = [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30] + @State edge: Edge= Edge.Top + private content: string = "Scroll Page"; + scroller: Scroller = new Scroller(); + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Scroll(this.scroller) { + Column() { + ForEach( + this.value1, + item => { + Text(`${item}`) + .fontSize(15) + .width(400) + .margin(10) + .height(70) + .backgroundColor(0xfff5deb3) + }, + item => item + ) + } + } + .scrollable(ScrollDirection.Vertical) + .scrollBar(this.scrollBar) + .scrollBarColor(this.scrollBarColor) + .scrollBarWidth(this.scrollBarWidth) + .key('scroll') + .width(400) + .height(200) + .onScroll((xOffset: number, yOffset: number) => { + console.info(` current offset is ${xOffset} ${yOffset}`) + }) + .onScrollEnd(() => { + console.info(` now on scroll end`) + }) + .onScrollEdge((side: Edge) => { + console.info(`To the edge`) + }) + Scroll() { + Row() { + Text('scroll uppppp') + .width(60) + .height(100) + .backgroundColor(Color.Yellow) + .margin({ + right: 5, + left: 5 + }) + .key('text') + + Text('scroll to') + .width(60) + .height(100) + .backgroundColor(Color.Green) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollTo({ + xOffset: 100, + yOffset: 100, + }) + }) + Text('scroll page') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollPage({ + next: true + }) + }) + Text('scroll Edge') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollEdge(Edge.Top) + }) + Text('scroll Edge') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.currentOffset() + }) + Text('scroll to index') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollToIndex(0) + console.info(` now on scroll end`) + }) + } + } + .key('scroll1') + .height(100) + .scrollable(ScrollDirection.Horizontal) + + Scroll() { + Column() { + Text("start").fontSize(30) + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + } + } + .padding(10) + .scrollable(ScrollDirection.None) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Red) + .scrollBarWidth(5) + .width(300) + .height(200) + .key('scroll2') + + Scroll() { + Column() { + Text("start").fontSize(30) + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + } + } + .padding(10) + .scrollable(ScrollDirection.Free) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Red) + .scrollBarWidth(5) + .width(300) + .height(200) + .key('scroll3') + } + .key('flex') + + } +} diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Slider.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Slider.ets new file mode 100644 index 0000000000000000000000000000000000000000..625cd02874f16e9debb7638322624f890e08fa62 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Slider.ets @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct slider { + @State inSetValue: number= 40 + @State outSetValue: number= 40 + @State direction: Axis= Axis.Horizontal + @State Begin: number = SliderChangeMode.Begin + + onPageShow() { + console.info('Slider page show called'); + } + + onBuildDone() { + console.info('Slider page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Slider page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Slider({ + value: this.outSetValue, + min: 0, + max: 100, + step: 1, + direction: Axis.Horizontal, + reverse: false, + style: SliderStyle.OutSet + }) + .blockColor('#FFFF0000') + .selectedColor('#FF0000FF') + .trackColor('#FF808080') + .minLabel('10') + .maxLabel('10') + .showTips(false) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + this.outSetValue = value + this.Begin = mode + console.info('value: ' + value + '---mode: ' + mode) + }) + .width("100") + .height("100") + .key('slider1') + Slider({ + value: 40, + min: 0, + max: 100, + step: 1, + style: SliderStyle.InSet + }) + .blockColor(Color.Red) + .selectedColor(Color.Blue) + .trackColor(Color.Gray) + .showTips(true) + .showSteps(true) + .key('slider2') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Span.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Span.ets new file mode 100644 index 0000000000000000000000000000000000000000..df5a71043f1ae000b822646f6b56df7ae103fa1f --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Span.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct span_textcase { + + onPageShow() { + console.info('Span page show called'); + } + + onBuildDone() { + console.info('Span page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text() { + Span('Test Span demo') + .decoration({ type: TextDecorationType.LineThrough, "color": Color.Red }) + .textCase(TextCase.UpperCase) + .fontColor(Color.Blue) + .fontSize("20fp") + .letterSpacing(5) + .fontFamily("sans-serif") + .fontWeight(FontWeight.Bold) + .fontStyle(FontStyle.Italic) + .key('span1') + Span('The second test Span demo') + .textCase(TextCase.LowerCase) + .fontColor(Color.Black) + .letterSpacing('5') + .fontSize(30) + .key('span2') + Span('The third test Span demo') + .textCase(TextCase.Normal) + .fontColor(Color.Yellow) + .fontSize("30fp") + .key('span3') + } + } + .width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(4) + } + } +} + + + diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Stack.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Stack.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a694889f0e768afbd3e3af6a17c3af9d8738cfb --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Stack.ets @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct stack_testcase { + @State alignContent: Alignment = Alignment.Bottom + private content: string = "Stack Page"; + + onPageShow() { + console.info('Stack page show called'); + } + + onBuildDone() { + console.info('Stack page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Stack({ alignContent: this.alignContent }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + } + .width('100%') + .height(80) + .margin({ top: 5 }) + .key('stack') + .onClick(() => { + router.back() + }) + + Stack({ alignContent: Alignment.BottomStart }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack1') + + Stack({ alignContent: Alignment.BottomEnd }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack2') + + Stack({ alignContent: Alignment.Start }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack3') + + Stack({ alignContent: Alignment.Center }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack4') + + Stack({ alignContent: Alignment.End }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack5') + + Stack({ alignContent: Alignment.Top }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack6') + + Stack({ alignContent: Alignment.TopStart }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack7') + + Stack({ alignContent: Alignment.TopEnd }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack8') + } + .key('flex') + .width('100%') + .height('100%') + + } +} + diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Text.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Text.ets new file mode 100644 index 0000000000000000000000000000000000000000..fbd1415dc815b0f1966476c430f7d69e28e587ee --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/Text.ets @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2021 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. + */ + +// @ts-nocheck +import router from '@system.router' + +var paramInfo = router.getParams() +console.info("cd paramInfo" + JSON.stringify(paramInfo)) + +@Entry +@Component +struct text_textcase { + @State textAlign: TextAlign= TextAlign.End + @State lineHeight: string= '15fp' + @State overflow: TextOverflow = TextOverflow.Ellipsis + @State textOverflow: textOverflow<{ "overflow": TextOverflow }> = { "overflow": this.overflow } + @State maxLines: number = 2 + @State baselineOffset: number = 0 + @State textCase: TextCase= TextCase.Normal + @State decoration: decoration<{ + type: TextDecorationType, + color: Color + }> = { type: TextDecorationType.Underline, color: Color.Red } + @State color: Color = Color.Red + @State width: string= "200" + @State height: string= "100" + @State size: size = { width: 200, height: 100 } + @State marginBottom: string = "10px" + @State marginTop: string = "10px" + @State marginLeft: string = "10px" + @State marginRingt: string= "10px" + @State paddingBottom: string= "5" + @State paddingTop: string= "5" + @State paddingLeft: string= "5" + @State paddingRingt: string= "5" + @State constraintSize: constraintSize = { minWidth: 20, maxWidth: 200, minHeight: 0, maxHeight: 50 } + @State layoutPriority: string= "9px" + @State layoutWeight: string = "10px" + @State align: Alignment = Alignment.Center + @State direction: Direction = Direction.Auto + @State position: position<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State markAnchor: markAnchor<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State offset: offset<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State flexGrow: number = 5 + @State flexShrink: number = 2 + @State flexBasis: number = 0 + @State alignSelf: ItemAlign = ItemAlign.Auto + @State borderStyle: BorderStyle = BorderStyle.Dashed + @State borderRadius: number = 10 + @State borderWidth: string= "4px" + @State borderColor: Color= Color.Blue + @State backgroundColor: Color = Color.Pink + @State backgroundImageSize: ImageSize = ImageSize.Cover + @State backgroundImagePosition: Alignment= Alignment.Center + @State opacity: number= 1 + @State visibility: Visibility= Visibility.Visible + @State enabled: boolean = false + @State zIndex: number = 1 + @State fontStyle: FontStyle = FontStyle.Italic + @State fontSize: number = 15 + @State minFontSize: number = 15 + @State maxFontSize: number = 15 + @State letterSpacing: number= 10 + @State fontWeight: FontWeight= FontWeight.Bold + @State fontColor: Color= Color.Black + @State active: boolean = false + private content: string = "Text Page"; + + onPageShow() { + console.info('Text page show called'); + } + + onBuildDone() { + console.info('Text page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .width(this.width) + .height(this.height) + .padding({ bottom: this.paddingBottom, top: this.paddingTop, right: this.paddingRingt, left: this.paddingLeft }) + .margin({ bottom: this.marginBottom, top: this.marginTop, right: this.marginRingt, left: this.marginLeft }) + .constraintSize(this.constraintSize) + .layoutWeight(this.layoutWeight) + .align(this.align) + .direction(this.direction) + .position(this.position) + .markAnchor(this.markAnchor) + .offset(this.offset) + .flexBasis(this.flexBasis) + .flexGrow(this.flexGrow) + .flexShrink(this.flexShrink) + .alignSelf(this.alignSelf) + .borderStyle(this.borderStyle) + .borderRadius(this.borderRadius) + .borderWidth(this.borderWidth) + .borderColor(this.borderColor) + .backgroundColor(this.backgroundColor) + .opacity(this.opacity) + .visibility(this.visibility) + .enabled(this.enabled) + .zIndex(this.zIndex) + .fontColor(this.fontColor) + .fontSize(this.fontSize) + .minFontSize(this.minFontSize) + .letterSpacing(this.letterSpacing) + .maxFontSize(this.maxFontSize) + .fontWeight(this.fontWeight) + .fontStyle(this.fontStyle) + .fontFamily("sans-serif") + .textAlign(this.textAlign) + .textOverflow(this.textOverflow) + .lineHeight(this.lineHeight) + .baselineOffset(this.baselineOffset) + .maxLines(2) + .textCase(this.textCase) + .decoration(this.decoration) + .aspectRatio(1) + .fontColor(Color.Black) + .key('Text') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .size({ width: 100, height: 50 }) + .padding({ bottom: 5, top: 5, right: 5, left: 10 }) + .margin({ bottom: 15, top: 10, right: 10, left: 10 }) + .fontSize('13') + .textAlign(TextAlign.Start) + .align(Alignment.Start) + .direction(Direction.Ltr) + .alignSelf(ItemAlign.Start) + .borderStyle(BorderStyle.Dotted) + .borderWidth(2) + .visibility(Visibility.Hidden) + .enabled(true) + .fontWeight(FontWeight.Normal) + .textAlign(TextAlign.Start) + .textOverflow(TextOverflow.Clip) + .maxLines(2) + .textCase(TextCase.LowerCase) + .decoration({ "type": TextDecorationType.LineThrough, "color": Color.Red }) + .fontColor(Color.White) + .key('Text1') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .width('100%') + .textAlign(TextAlign.Center) + .align(Alignment.TopEnd) + .direction(Direction.Rtl) + .alignSelf(ItemAlign.Center) + .borderStyle(BorderStyle.Solid) + .borderWidth(2) + .visibility(Visibility.None) + .fontWeight(FontWeight.Bolder) + .textAlign(TextAlign.Center) + .textOverflow(TextOverflow.None) + .textCase(TextCase.UpperCase) + .decoration({ "type": TextDecorationType.None, "color": Color.Red }) + .fontColor(Color.Blue) + .key('Text2') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.Top) + .alignSelf(ItemAlign.End) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Lighter) + .decoration({ type: TextDecorationType.Overline, color: Color.Red }) + .fontColor(Color.Gray) + .key('Text3') + Text('Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.TopStart) + .alignSelf(ItemAlign.Baseline) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Medium) + .fontColor(Color.Brown) + .key('Text4') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.End) + .alignSelf(ItemAlign.Stretch) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Regular) + .fontColor(Color.Grey) + .key('Text5') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.BottomEnd) + .width('100%') + .fontColor(Color.Orange) + .key('Text6') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.Bottom) + .width('100%') + .fontColor(Color.Yellow) + .key('Text7') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.BottomStart) + .width('100%') + .key('Text8') + + } + .key('flex') + .width('100%') + .height('100%') + } +} + + diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/index.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..10359134da915c9b44b0836ba4881bca71f43f33 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,65 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 file from '@system.file'; + +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; +import testsuite from "../test/List.test.ets"; +import featureAbility from "@ohos.ability.featureAbility"; + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + Want.parameters['timeout'] = 100000 + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('ACE ETS TEST') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/test/List.test.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a51a5eab339f7e06b653f7c64ef0586165fa2d0b --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2021 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. + */ + +//contact import +import StabilityTest from './contact/Stability_test.js' + +export default function testsuite() { + //contact + StabilityTest(); +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/test/Utils.ets b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..65f70088ddb62bcf80f4e0ec07dc841a8ab033f0 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,119 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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. + */ + +export default class Utils { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + static notCheck = true; + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } + + static async swipe(downX, downY, upX, upY, steps) { + console.info('start to swipe') + this.drags(downX, downY, upX, upY, steps, false) + } + + static async drag(downX, downY, upX, upY, steps) { + console.info('start to drag') + this.drags(downX, downY, upX, upY, steps, true) + } + + static async drags(downX, downY, upX, upY, steps, drag) { + var xStep; + var yStep; + var swipeSteps; + var ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + var downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('start to move') + if (drag) { + await this.sleep(500) + } + for (var i = 1;i <= swipeSteps; i++) { + var movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('start to up') + if (drag) { + await this.sleep(100) + } + var upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) + } +} + + + + diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/test/contact/Stability_test.js b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/test/contact/Stability_test.js new file mode 100644 index 0000000000000000000000000000000000000000..c48dcb21801906fbb99a46f4b36a61ca4b687220 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/test/contact/Stability_test.js @@ -0,0 +1,538 @@ +/* + * Copyright (c) 2021 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 featureAbility from '@ohos.ability.featureAbility'; +import ohosDataAbility from '@ohos.data.dataability'; +import utils from '../Utils.ets' +import {afterAll, afterEach, beforeAll, beforeEach, describe, expect, it} from 'deccjsunit/index' + +const URI_CALLLOG = "dataability:///com.ohos.calllogability"; +const calllogUri = "dataability:///com.ohos.calllogability/calls/calllog"; + +const URI_VOICEMAIL = "dataability:///com.ohos.voicemailability"; +const voicemailUri = "dataability:///com.ohos.voicemailability/calls/voicemail"; + +const URI_CONTACTS = "dataability:///com.ohos.contactsdataability"; +const rawContactUri = "dataability:///com.ohos.contactsdataability/contacts/raw_contact"; +const contactDataUri = "dataability:///com.ohos.contactsdataability/contacts/contact_data"; +const deletedUri = "dataability:///com.ohos.contactsdataability/contacts/deleted_raw_contact"; + +export default function StabilityTest() { + describe('StabilityTest', function () { + console.log(' StabilityTest is start'); + + function sleep(numberMillis) { + var now = new Date(); + var exitTime = now.getTime() + numberMillis; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) + return; + } + } + + /** + * @tc.number raw_contact_insert_stability_test_900 + * @tc.name Add 10000 pieces of data to the raw_contact table to see if they can be successfully inserted + * @tc.desc Function test + */ + it("raw_contact_insert_stability_test_900", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var listAddBluk = []; + for (var i = 0; i < 1000; i++) { + var add = { + "display_name": "xiaoli" + i, "company": "testCompany" + i, "position": "testPosition" + i + }; + listAddBluk[i] = add; + } + try { + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(rawContactUri, listAddBluk); + sleep(1000); + console.info("logMessage raw_contact_insert_stability_test_900: contactDataId1 = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + done(); + } catch (error) { + console.info('logMessage raw_contact_insert_stability_test_900: insert error = ' + error); + done(); + } + }); + + /** + * @tc.number raw_contact_update_stability_test_1000 + * @tc.name The raw_contact table updates the data whose ID is not equal to 0 to see whether they can be updated + * successfully + * @tc.desc Function test + */ + it("raw_contact_update_stability_test_1000", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var updateValues = { + "favorite": 1 + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + var updateCode = await DAHelper.update(rawContactUri, updateValues, condition); + sleep(1000); + console.info("logMessage raw_contact_update_stability_test_1000: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("logMessage raw_contact_update_stability_test_1000: update error = " + error); + done(); + } + }); + + /** + * @tc.number raw_contact_query_stability_test_1100 + * @tc.name The raw_contact table queries 10000 pieces of data to see whether they can be queried successfully + * @tc.desc Function test + */ + it("raw_contact_query_stability_test_1100", 0, async function (done) { + var tag = "raw_contact_query_stability_test_1100"; + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info(tag + ': start ! DAHelper = ' + DAHelper); + var resultColumns = ["id"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + var resultSet = await DAHelper.query(rawContactUri, resultColumns, condition); + sleep(1000); + console.info(tag + ' : logMessage : rowCount' + resultSet.rowCount); + expect(resultSet.rowCount == 10000).assertTrue(); + resultSet.close(); + done(); + } catch (error) { + console.info(tag + " :logMessage : error = " + error); + done(); + } + }); + + /** + * @tc.number raw_contact_delete_stability_test_1200 + * @tc.name Delete 10000 pieces of data in raw_contact table to see if they can be deleted successfully + * @tc.desc Function test + */ + it("raw_contact_delete_stability_test_1200", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('raw_contact_delete_stability_test_1200 : start ! DAHelper = ' + DAHelper); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + condition.and(); + condition.equalTo("is_deleted", "0"); + try { + var deleteCode = await DAHelper.delete(rawContactUri, condition); + sleep(1000); + console.info("logMessage raw_contact_delete_stability_test_1200: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + done(); + } catch (error) { + console.info('logMessage raw_contact_delete_stability_test_1200: delete error = ' + error); + done(); + } + }); + + /** + * @tc.number contact_data_insert_stability_test_1300 + * @tc.name Add 10000 pieces of data to the contact_data table to see if they can be successfully inserted + * @tc.desc Function test + */ + it("contact_data_insert_stability_test_1300", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var rawContactValues = { + "display_name": "xiaoli", + }; + try { + var rawContactId = await DAHelper.insert(rawContactUri, rawContactValues); + sleep(1000); + console.info("logMessage contact_data_insert_stability_test_1300: rawContactId = " + rawContactId); + } catch (error) { + console.info("logMessage contact_data_insert_stability_test_1300: raw_contact insert error = " + error); + } + + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.equalTo("id", rawContactId.toString()); + var deleteCode = await DAHelper.delete(rawContactUri, condition); + sleep(1000); + console.info("logMessage contact_data_insert_stability_test_1300: deleteCode = " + deleteCode); + + var listAddBluk = []; + for (var i = 0; i < 1000; i++) { + var add = { + "raw_contact_id": rawContactId, "detail_info": "xxx" + i, "content_type": "name" + }; + listAddBluk[i] = add; + } + try { + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(contactDataUri, listAddBluk); + sleep(2000); + console.info("logMessage contact_data_insert_stability_test_1300: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + done(); + } catch (error) { + console.info('logMessage contact_data_insert_stability_test_1300: insert error = ' + error); + done(); + } + }); + + /** + * @tc.number contact_data_update_stability_test_1400 + * @tc.name The contact_data table updates the data whose ID is not equal to 0 to see whether they can be updated + * successfully + * @tc.desc Function test + */ + it("contact_data_update_stability_test_1400", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('logMessage contact_data_update_stability_test_1400 DAHelper success! DAHelper = ' + DAHelper); + var updateValues = { + "syn_1": "test" + }; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + var updateCode = await DAHelper.update(contactDataUri, updateValues, condition); + sleep(2000); + console.info("logMessage contact_data_update_stability_test_1400: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("logMessage contact_data_update_stability_test_1400: update error = " + error); + done(); + } + }); + + /** + * @tc.number contact_data_query_stability_test_1500 + * @tc.name The contact_data table queries 10000 pieces of data to see whether they can be queried successfully + * @tc.desc Function test + */ + it("contact_data_query_stability_test_1500", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('contact_data_query_stability_test_1500 start ! DAHelper = ' + DAHelper); + var resultColumns = ["id"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + var resultSet = await DAHelper.query(contactDataUri, resultColumns, condition); + sleep(2000); + console.info(' contact_data_query_stability_test_1500 : resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == 10000).assertEqual(true); + resultSet.close(); + done(); + } catch (error) { + console.info("logMessage contact_data_query_stability_test_1500: error = " + error); + done(); + } + }); + + /** + * @tc.number contact_data_delete_stability_test_1600 + * @tc.name Delete 10000 pieces of data in contact_data table to see if they can be deleted successfully + * @tc.desc Function test + */ + it("contact_data_delete_stability_test_1600", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('contact_data_delete_stability_test_1600 : start ! DAHelper = ' + DAHelper); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + var deleteCode = await DAHelper.delete(contactDataUri, condition); + sleep(2000); + console.info("logMessage contact_data_delete_stability_test_1600: deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + done(); + } catch (error) { + console.info('logMessage contact_data_delete_stability_test_1600: delete error = ' + error); + done(); + } + }); + + /** + * @tc.number calllog_insert_stability_test_100 + * @tc.name Add 10000 pieces of data to the callog table to see if they can be successfully inserted + * @tc.desc Function test + */ + it("calllog_insert_stability_test_100", 0, async function (done) { + console.info("---------logMessage calllog_insert_stability_test_100 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var listAddBluk = []; + for (var i = 0; i < 1000; i++) { + var add = { + "phone_number": "1511002" + i + }; + listAddBluk[i] = add; + } + try { + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(calllogUri, listAddBluk); + sleep(1000); + console.info("logMessage calllog_insert_stability_test_100: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("logMessage calllog_insert_stability_test_100: batchInsert error = " + error); + done(); + } + }); + + /** + * @tc.number calllog_update_stability_test_200 + * @tc.name The callog table updates the data whose ID is not equal to 0 to see whether they can be updated + * successfully + * @tc.desc Function test + */ + it("calllog_update_stability_test_200", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var updateValues = { + "answer_state": "1" + }; + try { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + var updateCode = await DAHelper.update(calllogUri, updateValues, condition); + sleep(1000); + console.info("logMessage calllog_update_stability_test_200: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("logMessage calllog_update_stability_test_200: update error = " + error); + done(); + } + ; + }); + + /** + * @tc.number calllog_query_stability_test_300 + * @tc.name The callog table queries 10000 pieces of data to see whether they can be queried successfully + * @tc.desc Function test + */ + it("calllog_query_stability_test_300", 0, async function (done) { + var tag = "calllog_query_stability_test_300"; + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info(tag + ': start ! DAHelper = ' + DAHelper); + var resultColumns = ["id"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.notEqualTo("id", 0); + + try { + var resultSet = await DAHelper.query(calllogUri, resultColumns, condition); + sleep(5000); + console.info(tag + ' : logMessage : rowCount' + resultSet.rowCount); + expect(resultSet.rowCount == 10000).assertTrue(); + resultSet.close(); + done(); + } catch (error) { + console.info("logMessage calllog_query_stability_test_300: error = " + error); + done() + } + }); + + /** + * @tc.number calllog_delete_stability_test_400 + * @tc.name Delete 10000 pieces of data in callog table to see if they can be deleted successfully + * @tc.desc Function test + */ + it("calllog_delete_stability_test_400", 0, async function (done) { + var tag = "calllog_delete_stability_test_400"; + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CALLLOG); + console.info(tag + ': start ! DAHelper = ' + DAHelper); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + var deleteCode = await DAHelper.delete(calllogUri, condition); + sleep(5000); + console.info(tag + " : logMessage : deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + done(); + }); + + /** + * @tc.number voicemail_insert_stability_test_500 + * @tc.name Add 10000 pieces of data to the voicemail table to see if they can be successfully inserted + * @tc.desc Function test + */ + it("voicemail_insert_stability_test_500", 0, async function (done) { + console.info("---------logMessage voicemail_insert_stability_test_500 is starting!----------"); + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + + var listAddBluk = []; + for (var i = 0; i < 1000; i++) { + var add = { + "phone_number": "12345" + i + }; + listAddBluk[i] = add; + } + try { + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + var batchInsertCode = await DAHelper.batchInsert(voicemailUri, listAddBluk); + sleep(1000); + console.info("logMessage voicemail_insert_stability_test_500: batchInsertCode = " + batchInsertCode); + expect(batchInsertCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("logMessage voicemail_insert_stability_test_500: batchInsert error = " + error); + done(); + } + }); + + /** + * @tc.number voicemail_update_stability_test_600 + * @tc.name The voicemail table updates the data whose ID is not equal to 0 to see whether they can be updated + * successfully + * @tc.desc Function test + */ + it("voicemail_update_stability_test_600", 0, async function (done) { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info('logMessage get DAHelper success! DAHelper = ' + DAHelper); + var updateValues = { + "origin_type": "test" + }; + try { + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.notEqualTo("id", 0); + var updateCode = await DAHelper.update(voicemailUri, updateValues, condition); + sleep(1000); + console.info("logMessage voicemail_update_stability_test_600: updateCode = " + updateCode); + expect(updateCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("logMessage voicemail_update_stability_test_600: update error = " + error); + done(); + } + ; + }); + + /** + * @tc.number voicemail_query_stability_test_700 + * @tc.name The voicemail table queries 10000 pieces of data to see whether they can be queried successfully + * @tc.desc Function test + */ + it("voicemail_query_stability_test_700", 0, async function (done) { + if(utils.notCheck){ + expect(true).assertTrue(); + done(); + return; + } + var tag = "voicemail_query_stability_test_700"; + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info(tag + ': start ! DAHelper = ' + DAHelper); + var resultColumns = ["id"]; + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + var resultSet = await DAHelper.query(voicemailUri, resultColumns, condition); + sleep(1000); + console.info(tag + ' : resultSet.rowCount = ' + resultSet.rowCount); + expect(resultSet.rowCount == 10000).assertEqual(true); + resultSet.close(); + done(); + } catch (error) { + console.info("logMessage voicemail_query_stability_test_700: error = " + error); + done() + } + }); + + /** + * @tc.number voicemail_delete_stability_test_800 + * @tc.name Delete 10000 pieces of data in voicemail table to see if they can be deleted successfully + * @tc.desc Function test + */ + it("voicemail_delete_stability_test_800", 0, async function (done) { + var tag = "voicemail_delete_stability_test_800"; + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_VOICEMAIL); + console.info(tag + ': start ! DAHelper = ' + DAHelper); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.greaterThan("id", "0"); + try { + var deleteCode = await DAHelper.delete(voicemailUri, condition); + sleep(2000); + console.info(tag + " : logMessage : deleteCode = " + deleteCode); + expect(deleteCode == 0).assertTrue(); + done(); + } catch (error) { + console.info("logMessage voicemail_delete_stability_test_800: error = " + error); + done(); + } + }); + + afterAll(async function () { + var DAHelper = featureAbility.acquireDataAbilityHelper(URI_CONTACTS); + console.info('Stability : start ! DAHelper = ' + DAHelper); + var condition = new ohosDataAbility.DataAbilityPredicates(); + condition.notEqualTo("id", "0"); + try { + var resultColumns = ["id"]; + var conditionDelete = new ohosDataAbility.DataAbilityPredicates(); + conditionDelete.greaterThan("id", "0"); + var count = 0; + var deleteCount = 9999; + while (count < deleteCount) { + var result = await DAHelper.query(deletedUri, resultColumns, conditionDelete); + console.info("Stability : result.rowCount = " + result.rowCount); + count = result.rowCount; + result.close(); + sleep(5000); + } + var deleteCode = await DAHelper.delete(deletedUri, condition); + console.info("Stability afterAll logMessage DeleteContact: deleteCode = " + deleteCode); + } catch (error) { + console.info('Stability afterAll logMessage DeleteContact: delete error = ' + error); + } + }); + }) +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/test/lib/Const.js b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/test/lib/Const.js new file mode 100644 index 0000000000000000000000000000000000000000..f9263cd46dee1a0ffdfaa1e5ef5c29755c7e13f7 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/ets/MainAbility/test/lib/Const.js @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2021 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. + */ + +// sim slot id +export const DEFAULT_SLOTID = 0; +export const SLOTID3 = 3; +export const SLOTID2 = 2; +export const SLOTID_MINUS1 = -1; + +// sim correct password +export const CORRECT_PIN = '1234'; +export const CORRECT_PIN2 = '18099014'; + +// sim incorrect password +export const INCORRECT_PIN = '134679'; +export const INCORRECT_PIN_LEN3 = '123'; +export const INCORRECT_PUK = '134679'; +export const INCORRECT_PIN2 = '134679'; +export const INCORRECT_PIN2_LEN3 = '123'; +export const INCORRECT_PIN2_LEN9 = '123456789'; +export const INCORRECT_PUK2 = '134679'; + +// lock status response +export const LOCK_RESULT = { SUCCESS: 0, FAILURE: -1, EXCEPTION: -2 }; \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03b8532c53ca563f8ed6b1e21d20ad3f67a68906 --- /dev/null +++ b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/resources/base/media/icon.png b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/hand.png b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/hand.png new file mode 100644 index 0000000000000000000000000000000000000000..9f1fa16ee073093b40920e273502513fa66fa980 Binary files /dev/null and b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/hand.png differ diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/icon.png b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/icon.png differ diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/images.jpg b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/images.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c75ddfc5ead15e8d49ca7cae9f97c03585565be1 Binary files /dev/null and b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/images.jpg differ diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/person.png b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/person.png new file mode 100644 index 0000000000000000000000000000000000000000..f0f540d078e6c0441a763ca2cc375a551d6cf736 Binary files /dev/null and b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/person.png differ diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/star-1-1.png b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/star-1-1.png new file mode 100644 index 0000000000000000000000000000000000000000..990c5e5ad20698c7701faf641bc80eb004a127b7 Binary files /dev/null and b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/star-1-1.png differ diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/star-1-2.png b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/star-1-2.png new file mode 100644 index 0000000000000000000000000000000000000000..450c3dd3ca68bf601bd08e5f41797d376e20d00d Binary files /dev/null and b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/star-1-2.png differ diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/star-1-3.png b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/star-1-3.png new file mode 100644 index 0000000000000000000000000000000000000000..1044869832b423a5dfc2559a395529377bd34f0c Binary files /dev/null and b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/star-1-3.png differ diff --git a/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/video/show.mp4 b/telephony/telephonyjstest/contact_stability/entry/src/main/resources/rawfile/video/show.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/telephony/telephonyjstest/contact_stability/signature/openharmony_sx.p7b b/telephony/telephonyjstest/contact_stability/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/telephony/telephonyjstest/contact_stability/signature/openharmony_sx.p7b differ diff --git a/telephony/telephonyjstest/netmanager_http/BUILD.gn b/telephony/telephonyjstest/netmanager_http/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8b9be1eba6521ac2cc8c90c17cec28619e486bff --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 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("ActsNetManagerHttpEtsTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":ace_demo_ets_assets", + ":ace_demo_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsNetManagerHttpEtsTest" +} +ohos_js_assets("ace_demo_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("ace_demo_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/telephony/telephonyjstest/netmanager_http/Test.json b/telephony/telephonyjstest/netmanager_http/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..4a6a322834e2ae745683cd406edd5b5734d7375e --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "1800000", + "package": "com.ohos.netmanagerhttp", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsNetManagerHttpEtsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/config.json b/telephony/telephonyjstest/netmanager_http/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..aca07cdb71d88d23b828586af3095478847e5697 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/config.json @@ -0,0 +1,93 @@ +{ + "app": { + "bundleName": "com.ohos.netmanagerhttp", + "vendor": "open", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.netmanagerhttp", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/Button", + "pages/Blank", + "pages/DataPanel", + "pages/Divider", + "pages/Text", + "pages/RowSplit", + "pages/Scroll", + "pages/Stack", + "pages/Image", + "pages/Progress", + "pages/Qrcode", + "pages/Rating", + "pages/Span", + "pages/Slider", + "pages/Badge", + "pages/Column", + "pages/ColumnSplit", + "pages/Counter", + "pages/Flex", + "pages/GridContainer" + + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/app.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..261fadca29ff0ea310a8bc105ddd1af65e2dd2f6 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Badge.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Badge.ets new file mode 100644 index 0000000000000000000000000000000000000000..66de6f8e3b9c0360931602dd25d1511878ac63ab --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Badge.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct badge { + @State counts: number = 33 + @State message: string = 'new' + @State active: boolean = false + private content: string = "badge Page"; + + onPageShow() { + console.info('badge page show called'); + } + + onBuildDone() { + console.info('badge page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Scroll() { + Column() { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Badge({ + count: this.counts, + position: BadgePosition.Right, + maxCount: 99, + style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge') + + Text("BadgePosition.RightTop").fontSize(16) + Badge({ + count: this.counts, + position: BadgePosition.RightTop, + maxCount: 99, + style: { color: 0xFFFFFF, fontSize: '16', badgeSize: '20', badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge1') + + Text("BadgePosition.Left").fontSize(16) + Badge({ + count: this.counts, + position: BadgePosition.Left, + maxCount: 99, + style: { color: Color.Pink, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge2') + } + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Blank.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Blank.ets new file mode 100644 index 0000000000000000000000000000000000000000..a50fc719e09ab27c91f9705ac06008e936830f33 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Blank.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct blank_testcase { + @State Color: Color = Color.Pink + @State active: boolean = false + private content: string = "Blank Page" + + onPageShow() { + console.info('Blank page show called'); + } + + onBuildDone() { + console.info('Blank page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Blank(100) + .color(this.Color) + .key('blank') + Text('on/off').fontSize(18).height(60) + } + .key('flex') + .width('100%') + .height('100%') + + + } +} diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Button.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Button.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac2271ea3a13664bbbb6afe4f173abae9e66f867 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Button.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct button_testcase { + @State stateEffect: boolean = true + @State ButtonType: ButtonType = ButtonType.Circle + private content: string = "Button Page"; + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button('1.value', { type: ButtonType.Circle, stateEffect: this.stateEffect }) + .fontSize(12) + .fontWeight(FontWeight.Bold) + .fontColor(0xCCCCCC) + .height(40) + .width(40) + .key('button') + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + .padding(10) + Button() { + Text("2.Capsule") + } + .type(ButtonType.Capsule) + .stateEffect(false) + .backgroundColor('#0D9FFB') + .padding(10) + .key('button1') + + Button() { + Text("3.Normal") + }.type(ButtonType.Normal) + .backgroundColor('#0D9FFB') + .key('button2') + + }.key('flex') + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Column.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Column.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9e5c84e21ccf25419be432d8f95418fac82070a --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Column.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct column { + @State active: boolean = false + private content: string = "Column Page" + + onPageShow() { + console.info('Column page show called'); + } + + onBuildDone() { + console.info('Column page build done called'); + } + + build() { + Column({ space: 5 }) { + Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Center).width('90%').border({ width: 1 }).key('column') + + Text('alignItems(Start)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column({ space: '5' }) { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Start).width('90%').border({ width: 1 }).key('column1') + + Text('alignItems(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.End).width('90%').border({ width: 1 }).key('column2') + }.width('100%').padding({ top: 5 }) + } +} diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb0597310a15be8ab4503a3ae89385e3708fac96 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct columnSplit { + private content: string = "ColumnSplit Page" + + onPageShow() { + console.info('ColumnSplit page show called'); + } + + onBuildDone() { + console.info('ColumnSplit page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Scroll() { + Column() { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Column() { + Text('ColumnSplit').fontSize(9).fontColor(0xCCCCCC).width('90%') + ColumnSplit() { + Text('1').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('2').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('3').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + }.key('columnSplit') + .resizeable(true) + .width('90%').height('60%') + + }.width("100%") + + Column() { + Text('ColumnSplit1').fontSize(9).fontColor(0xCCCCCC).width('90%') + ColumnSplit() { + Text('1').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('2').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('3').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + }.key('columnSplit1') + .resizeable(false) + .width('90%').height('60%') + + }.width("100%") + } + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Counter.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Counter.ets new file mode 100644 index 0000000000000000000000000000000000000000..ecdbfaf10393e7a348fd76098868e6455505b07f --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Counter.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct counter { + @State value: number = 0 + @State active: boolean = false + private content: string = "Counter Page" + + onPageShow() { + console.info('Counter page show called'); + } + + onBuildDone() { + console.info('Counter page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Counter() { + Text(this.value.toString()) + }.margin(100) + .key('counter') + .onInc(() => { + this.value++ + }) + .onDec(() => { + this.value-- + }) + }.width("100%") + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/DataPanel.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/DataPanel.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c624848482b22998b2a1d137796ddaedbcf198c --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/DataPanel.ets @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct dataPanel_testcase { + @State width: string= "200" + @State height: string= "100" + @State active: boolean = false + private content: string = "DataPanel Page" + + onPageShow() { + console.info('Blank page show called'); + } + + onBuildDone() { + console.info('Blank page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + DataPanel({ values: [20, 40, 20], max: 100, type: DataPanelType.Line }) + .width(this.width) + .height(this.height) + .key('DataPanel') + .onClick(() => { + router.back() + }) + .closeEffect(false) + + DataPanel({ values: [20, 40, 20], max: 100, type: DataPanelType.Circle}) + .width(this.width) + .height(this.height) + .key('DataPanel2') + .onClick(() => { + router.back() + }) + .closeEffect(true) + DataPanel({ values: [20, 40, 20], max: 100}) + .width(this.width) + .height(this.height) + .key('DataPanel3') + .onClick(() => { + router.back() + }) + .closeEffect(false) + } + .key('flex') + .width('100%') + .height('100%') + + } +} diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Divider.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Divider.ets new file mode 100644 index 0000000000000000000000000000000000000000..02bf60779418674d1fd58127907fdb3915bd8f8f --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Divider.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct divider_textcase { + @State vertical: boolean = true + @State color: Color = Color.Red + @State strokeWidth: number = 7 + @State lineCap: LineCapStyle = LineCapStyle.Butt + @State active: boolean = false + private content: string = "Divider Page"; + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + Divider() + .lineCap(LineCapStyle.Butt) + .strokeWidth(this.strokeWidth) + .color(this.color) + .vertical(this.vertical) + .height(150) + .key('divider') + .onClick(() => { + router.back() + }) + Divider() + .lineCap(LineCapStyle.Round) + .vertical(false) + .color(Color.Green) + .strokeWidth(10) + .height(150) + .key('divider1') + Divider() + .lineCap(LineCapStyle.Square) + .color(Color.Green) + .vertical(true) + .strokeWidth(10) + .height(150) + .key('divider2') + } + .key('flex') + .width('100%') + .height('100%') + } +} + + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Flex.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Flex.ets new file mode 100644 index 0000000000000000000000000000000000000000..a0e21251e80008c5be9f29aa52074acc5eb24a78 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Flex.ets @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct flex { + private content: string = "Flex Page" + + onPageShow() { + console.info('Flex page show called'); + } + + onBuildDone() { + console.info('Flex page build done called'); + } + + build() { + Column() { + Column({ space : 2 }) { + Text('direction:Column').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Column, + wrap: FlexWrap.NoWrap, + justifyContent: FlexAlign.Center, + alignItems:ItemAlign.Start, + alignContent: FlexAlign.Start, + }) { + Text('1').width('100%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('100%').height(20).backgroundColor(0xD2B48C) + Text('3').width('100%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex') + .height(70) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('direction:Row').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.Start, + alignItems:ItemAlign.Start, + alignContent: FlexAlign.Center, + }) { + Text('1').width('20%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('20%').height(20).backgroundColor(0xD2B48C) + Text('3').width('20%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex1') + .height(70) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('direction:RowReverse').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.RowReverse, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.End, + alignItems:ItemAlign.End, + alignContent: FlexAlign.End, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex2') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent:SpaceBetween').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceBetween, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('100%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('100%').height(20).backgroundColor(0xD2B48C) + Text('3').width('100%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex3') + .height(100) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent AND alignContent').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceEvenly, + alignContent: FlexAlign.SpaceEvenly, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex4') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent AND alignContent').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceAround, + alignContent: FlexAlign.SpaceAround, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex5') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + }.width('100%').margin({ top: 5 }) + }.width('100%') + } +} diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/GridContainer.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/GridContainer.ets new file mode 100644 index 0000000000000000000000000000000000000000..57358110413406263e70a2a5f650cbfeb22a4387 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/GridContainer.ets @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct gridContainer { + @State sizeType: SizeType = SizeType.XS + @State active: boolean = false + private content: string = "GridContainer Page" + + onPageShow() { + console.info('GridContainer page show called'); + } + + onBuildDone() { + console.info('GridContainer page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Scroll() { + Column({ space: 5 }) { + GridContainer({ columns: 12, sizeType: this.sizeType, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer') + .width('90%') + .alignItems(HorizontalAlign.Start) + + Text('Click Simulate to change the device width').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() { + Button('XS') + .onClick(() => { + this.sizeType = SizeType.XS + }).backgroundColor(0x317aff) + Button('SM') + .onClick(() => { + this.sizeType = SizeType.SM + }).backgroundColor(0x317aff) + Button('MD') + .onClick(() => { + this.sizeType = SizeType.MD + }).backgroundColor(0x317aff) + Button('LG') + .onClick(() => { + this.sizeType = SizeType.LG + }).backgroundColor(0x317aff) + } + + GridContainer({ columns: "auto", sizeType: SizeType.MD, gutter: '10', margin: '20' }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer1') + .width('90%') + .alignItems(HorizontalAlign.Center) + + GridContainer({ columns: 12, sizeType: SizeType.SM, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer2') + .width('90%') + .alignItems(HorizontalAlign.End) + + GridContainer({ columns: 12, sizeType: SizeType.LG, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer3') + .width('90%') + .alignItems(HorizontalAlign.End) + + GridContainer({ columns: 12, sizeType: SizeType.Auto, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer4') + .width('90%') + .alignItems(HorizontalAlign.End) + + }.width('100%').margin({ top: 5 }) + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Image.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Image.ets new file mode 100644 index 0000000000000000000000000000000000000000..5cc583e931f51aa8e4f2bd55decfeeb14a40afb4 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Image.ets @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct image_textcase { + @State Width: number = 0 + @State height: number = 0 + + onPageShow() { + console.info('Image page show called'); + } + + onBuildDone() { + console.info('Image page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Image page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Image("/resources/rawfile/hand.png") + .matchTextDirection(false) + .fitOriginalSize(false) + .fillColor(0xCCCCCC) + .objectFit(ImageFit.Cover) + .objectRepeat(ImageRepeat.NoRepeat) + .interpolation(ImageInterpolation.None) + .renderMode(ImageRenderMode.Original) + .autoResize(false) + .syncLoad(false) + .sourceSize({ width: 200, height: 100 }) + .alt("/resources/rawfile/person.png") + .key('image1') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.Contain) + .objectRepeat(ImageRepeat.X) + .interpolation(ImageInterpolation.High) + .renderMode(ImageRenderMode.Template) + .key('image2') + .height(180) + .width(180) + .onComplete((msg: { + width: number, + height: number + }) => { + this.Width = msg.width + this.height = msg.height + console.info('Width ----' + this.Width) + console.info('height ----' + this.height) + }) + .onError(() => { + console.info('load image fail') + }) + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.Fill) + .objectRepeat(ImageRepeat.Y) + .interpolation(ImageInterpolation.Low) + .key('image3') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.None) + .objectRepeat(ImageRepeat.XY) + .interpolation(ImageInterpolation.Medium) + .key('image4') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.ScaleDown) + .key('image5') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(4) + } + } +} + + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Navigator.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Navigator.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c50769cf2ab045cbe48b52e294b4105a21e1c3d --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Navigator.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct navigator_testcase { + @State active: boolean = false + @State params: Object = { text: 'news' } + + onPageShow() { + console.info('Navigator page show called'); + } + + onBuildDone() { + console.info('Navigator page build done called'); + } + + build() { + Column() { + Navigator({ target: "pages/index", type: NavigationType.Back }) { + Text('Navigator test in Navigator,back') + }.active(this.active) + .key('navigator') + .params({ + data: 24 + }) + + Navigator({ target: "pages/index", type: NavigationType.Push }) { + Text('Navigator test in Navigator,push') + }.active(this.active) + .key('navigator2') + .params({ + data: 24 + }) + + Navigator({ target: "pages/index", type: NavigationType.Replace }) { + Text('Navigator test in Navigator,replace') + }.active(this.active) + .key('navigator3') + .params({ + data: 24 + }) + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } +} diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Panel.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Panel.ets new file mode 100644 index 0000000000000000000000000000000000000000..32ddabbd1ccbae3805dd462e6f04b28364d6a1e7 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Panel.ets @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct PanelExample { + @State show: boolean = true + + onPageShow() { + console.info('Panel page show called'); + } + + onBuildDone() { + console.info('Panel page build done called'); + } + + build() { + Column() { + Text('2021-09-30 Today Calendar: 1.afternoon......Click for details') + .width('90%') + .height(50) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + .padding({ left: 20 }) + .onClick(() => { + this.show = !this.show + }) + Panel(this.show) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel') + .type(PanelType.Foldable) + .mode(PanelMode.Half) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + Panel(this.show) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel2') + .type(PanelType.Minibar) + .mode(PanelMode.Mini) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + Panel(false) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel3') + .type(PanelType.Temporary) + .mode(PanelMode.Full) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + }.width('100%').height('50%').backgroundColor(0xDCDCDC).padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Progress.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Progress.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8608089fe51e1988fd305fc49db028b6c2efe76 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Progress.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct progress_testcase { + onPageShow() { + console.info('Progress page show called'); + } + + onBuildDone() { + console.info('Progress page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Progress page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Progress({ value: 20, total: 40, style: ProgressStyle.Linear }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress') + + Progress({ value: 20, total: 40, style: ProgressStyle.Eclipse }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress2') + + Progress({ value: 20, total: 40, style: ProgressStyle.Ring }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress3') + + Progress({ value: 20, total: 40, style: ProgressStyle.ScaleRing }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress4') + + Progress({ value: 20, total: 40, style: ProgressStyle.Capsule }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress5') + + } + .width(400) + .height(400) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Qrcode.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Qrcode.ets new file mode 100644 index 0000000000000000000000000000000000000000..5c0dd84eff5a6653ee5fd940662d141025a1bb4e --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Qrcode.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct qrcode_textcase { + @State Color: Color = Color.Pink + + onPageShow() { + console.info('Qrcode page show called'); + } + + onBuildDone() { + console.info('Qrcode page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`Qrcode page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + QRCode('hello world') + .color("#FFFFC0CB") + .backgroundColor(this.Color) + .width("200") + .height("100") + .key('qrcode') + } + } +} + + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Rating.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Rating.ets new file mode 100644 index 0000000000000000000000000000000000000000..b29e26a392fca6f15a5b7f0eb4156dd3bc767c3f --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Rating.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct rating_testcase { + @State rating: number = 2 + + onPageShow() { + console.info('Rating page show called'); + } + + onBuildDone() { + console.info('Rating page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Rating page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Rating({ rating: 2, indicator: false }) + .stepSize(0.5) + .stars(5) + .starStyle({ + backgroundUri: '/resources/rawfile/star-1-1.png', + foregroundUri: '/resources/rawfile/star-1-3.png', + secondaryUri: '/resources/rawfile/star-1-2.png' + }) + .onChange((value: number) => { + this.rating = value + }) + .key('rating1') + Rating({ rating: 2, indicator: true }) + .stepSize(0.5) + .stars(5) + .starStyle({ + backgroundUri: '/resources/rawfile/star-1-1.png', + foregroundUri: '/resources/rawfile/star-1-3.png', + secondaryUri: '/resources/rawfile/star-1-2.png' + }) + .key('rating2') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/RowSplit.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/RowSplit.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f4f397b13b83e98ac643633309b02858f337eb0 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/RowSplit.ets @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct rowSplit_testcase { + @State resizeable: boolean = false + private content: string = "rowSplit Page"; + + onPageShow() { + console.info('RowSplit page show called'); + } + + onBuildDone() { + console.info('RowSplit page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + RowSplit() { + Column() { + Text('Demo1.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + + Column() { + Text('Demo2.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + } + .height(100) + .key('rowSplit') + .resizeable(this.resizeable) + .onClick(() => { + router.back() + }) + + RowSplit() { + Column() { + Text('Demo3.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + + Column() { + Text('Demo4.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + }.height(100) + .key('rowSplit1') + .resizeable(true) + } + .key('flex') + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Scroll.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Scroll.ets new file mode 100644 index 0000000000000000000000000000000000000000..363089d22580febed16b983d8a4b2877cde52bec --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Scroll.ets @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct scroll_testcase { + @State scrollBarWidth: number = 20 + @State scrollable: ScrollDirection = ScrollDirection.None + @State scrollBarColor: Color = Color.Pink + @State scrollBar: BarState= BarState.On + private value1: Array = [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30] + @State edge: Edge= Edge.Top + private content: string = "Scroll Page"; + scroller: Scroller = new Scroller(); + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Scroll(this.scroller) { + Column() { + ForEach( + this.value1, + item => { + Text(`${item}`) + .fontSize(15) + .width(400) + .margin(10) + .height(70) + .backgroundColor(0xfff5deb3) + }, + item => item + ) + } + } + .scrollable(ScrollDirection.Vertical) + .scrollBar(this.scrollBar) + .scrollBarColor(this.scrollBarColor) + .scrollBarWidth(this.scrollBarWidth) + .key('scroll') + .width(400) + .height(200) + .onScroll((xOffset: number, yOffset: number) => { + console.info(` current offset is ${xOffset} ${yOffset}`) + }) + .onScrollEnd(() => { + console.info(` now on scroll end`) + }) + .onScrollEdge((side: Edge) => { + console.info(`To the edge`) + }) + Scroll() { + Row() { + Text('scroll uppppp') + .width(60) + .height(100) + .backgroundColor(Color.Yellow) + .margin({ + right: 5, + left: 5 + }) + .key('text') + + Text('scroll to') + .width(60) + .height(100) + .backgroundColor(Color.Green) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollTo({ + xOffset: 100, + yOffset: 100, + }) + }) + Text('scroll page') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollPage({ + next: true + }) + }) + Text('scroll Edge') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollEdge(Edge.Top) + }) + Text('scroll Edge') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.currentOffset() + }) + Text('scroll to index') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollToIndex(0) + console.info(` now on scroll end`) + }) + } + } + .key('scroll1') + .height(100) + .scrollable(ScrollDirection.Horizontal) + + Scroll() { + Column() { + Text("start").fontSize(30) + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + } + } + .padding(10) + .scrollable(ScrollDirection.None) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Red) + .scrollBarWidth(5) + .width(300) + .height(200) + .key('scroll2') + + Scroll() { + Column() { + Text("start").fontSize(30) + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + } + } + .padding(10) + .scrollable(ScrollDirection.Free) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Red) + .scrollBarWidth(5) + .width(300) + .height(200) + .key('scroll3') + } + .key('flex') + + } +} diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Slider.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Slider.ets new file mode 100644 index 0000000000000000000000000000000000000000..625cd02874f16e9debb7638322624f890e08fa62 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Slider.ets @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct slider { + @State inSetValue: number= 40 + @State outSetValue: number= 40 + @State direction: Axis= Axis.Horizontal + @State Begin: number = SliderChangeMode.Begin + + onPageShow() { + console.info('Slider page show called'); + } + + onBuildDone() { + console.info('Slider page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Slider page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Slider({ + value: this.outSetValue, + min: 0, + max: 100, + step: 1, + direction: Axis.Horizontal, + reverse: false, + style: SliderStyle.OutSet + }) + .blockColor('#FFFF0000') + .selectedColor('#FF0000FF') + .trackColor('#FF808080') + .minLabel('10') + .maxLabel('10') + .showTips(false) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + this.outSetValue = value + this.Begin = mode + console.info('value: ' + value + '---mode: ' + mode) + }) + .width("100") + .height("100") + .key('slider1') + Slider({ + value: 40, + min: 0, + max: 100, + step: 1, + style: SliderStyle.InSet + }) + .blockColor(Color.Red) + .selectedColor(Color.Blue) + .trackColor(Color.Gray) + .showTips(true) + .showSteps(true) + .key('slider2') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Span.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Span.ets new file mode 100644 index 0000000000000000000000000000000000000000..df5a71043f1ae000b822646f6b56df7ae103fa1f --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Span.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct span_textcase { + + onPageShow() { + console.info('Span page show called'); + } + + onBuildDone() { + console.info('Span page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text() { + Span('Test Span demo') + .decoration({ type: TextDecorationType.LineThrough, "color": Color.Red }) + .textCase(TextCase.UpperCase) + .fontColor(Color.Blue) + .fontSize("20fp") + .letterSpacing(5) + .fontFamily("sans-serif") + .fontWeight(FontWeight.Bold) + .fontStyle(FontStyle.Italic) + .key('span1') + Span('The second test Span demo') + .textCase(TextCase.LowerCase) + .fontColor(Color.Black) + .letterSpacing('5') + .fontSize(30) + .key('span2') + Span('The third test Span demo') + .textCase(TextCase.Normal) + .fontColor(Color.Yellow) + .fontSize("30fp") + .key('span3') + } + } + .width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(4) + } + } +} + + + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Stack.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Stack.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a694889f0e768afbd3e3af6a17c3af9d8738cfb --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Stack.ets @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct stack_testcase { + @State alignContent: Alignment = Alignment.Bottom + private content: string = "Stack Page"; + + onPageShow() { + console.info('Stack page show called'); + } + + onBuildDone() { + console.info('Stack page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Stack({ alignContent: this.alignContent }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + } + .width('100%') + .height(80) + .margin({ top: 5 }) + .key('stack') + .onClick(() => { + router.back() + }) + + Stack({ alignContent: Alignment.BottomStart }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack1') + + Stack({ alignContent: Alignment.BottomEnd }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack2') + + Stack({ alignContent: Alignment.Start }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack3') + + Stack({ alignContent: Alignment.Center }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack4') + + Stack({ alignContent: Alignment.End }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack5') + + Stack({ alignContent: Alignment.Top }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack6') + + Stack({ alignContent: Alignment.TopStart }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack7') + + Stack({ alignContent: Alignment.TopEnd }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack8') + } + .key('flex') + .width('100%') + .height('100%') + + } +} + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Text.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Text.ets new file mode 100644 index 0000000000000000000000000000000000000000..fbd1415dc815b0f1966476c430f7d69e28e587ee --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/Text.ets @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2021 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. + */ + +// @ts-nocheck +import router from '@system.router' + +var paramInfo = router.getParams() +console.info("cd paramInfo" + JSON.stringify(paramInfo)) + +@Entry +@Component +struct text_textcase { + @State textAlign: TextAlign= TextAlign.End + @State lineHeight: string= '15fp' + @State overflow: TextOverflow = TextOverflow.Ellipsis + @State textOverflow: textOverflow<{ "overflow": TextOverflow }> = { "overflow": this.overflow } + @State maxLines: number = 2 + @State baselineOffset: number = 0 + @State textCase: TextCase= TextCase.Normal + @State decoration: decoration<{ + type: TextDecorationType, + color: Color + }> = { type: TextDecorationType.Underline, color: Color.Red } + @State color: Color = Color.Red + @State width: string= "200" + @State height: string= "100" + @State size: size = { width: 200, height: 100 } + @State marginBottom: string = "10px" + @State marginTop: string = "10px" + @State marginLeft: string = "10px" + @State marginRingt: string= "10px" + @State paddingBottom: string= "5" + @State paddingTop: string= "5" + @State paddingLeft: string= "5" + @State paddingRingt: string= "5" + @State constraintSize: constraintSize = { minWidth: 20, maxWidth: 200, minHeight: 0, maxHeight: 50 } + @State layoutPriority: string= "9px" + @State layoutWeight: string = "10px" + @State align: Alignment = Alignment.Center + @State direction: Direction = Direction.Auto + @State position: position<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State markAnchor: markAnchor<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State offset: offset<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State flexGrow: number = 5 + @State flexShrink: number = 2 + @State flexBasis: number = 0 + @State alignSelf: ItemAlign = ItemAlign.Auto + @State borderStyle: BorderStyle = BorderStyle.Dashed + @State borderRadius: number = 10 + @State borderWidth: string= "4px" + @State borderColor: Color= Color.Blue + @State backgroundColor: Color = Color.Pink + @State backgroundImageSize: ImageSize = ImageSize.Cover + @State backgroundImagePosition: Alignment= Alignment.Center + @State opacity: number= 1 + @State visibility: Visibility= Visibility.Visible + @State enabled: boolean = false + @State zIndex: number = 1 + @State fontStyle: FontStyle = FontStyle.Italic + @State fontSize: number = 15 + @State minFontSize: number = 15 + @State maxFontSize: number = 15 + @State letterSpacing: number= 10 + @State fontWeight: FontWeight= FontWeight.Bold + @State fontColor: Color= Color.Black + @State active: boolean = false + private content: string = "Text Page"; + + onPageShow() { + console.info('Text page show called'); + } + + onBuildDone() { + console.info('Text page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .width(this.width) + .height(this.height) + .padding({ bottom: this.paddingBottom, top: this.paddingTop, right: this.paddingRingt, left: this.paddingLeft }) + .margin({ bottom: this.marginBottom, top: this.marginTop, right: this.marginRingt, left: this.marginLeft }) + .constraintSize(this.constraintSize) + .layoutWeight(this.layoutWeight) + .align(this.align) + .direction(this.direction) + .position(this.position) + .markAnchor(this.markAnchor) + .offset(this.offset) + .flexBasis(this.flexBasis) + .flexGrow(this.flexGrow) + .flexShrink(this.flexShrink) + .alignSelf(this.alignSelf) + .borderStyle(this.borderStyle) + .borderRadius(this.borderRadius) + .borderWidth(this.borderWidth) + .borderColor(this.borderColor) + .backgroundColor(this.backgroundColor) + .opacity(this.opacity) + .visibility(this.visibility) + .enabled(this.enabled) + .zIndex(this.zIndex) + .fontColor(this.fontColor) + .fontSize(this.fontSize) + .minFontSize(this.minFontSize) + .letterSpacing(this.letterSpacing) + .maxFontSize(this.maxFontSize) + .fontWeight(this.fontWeight) + .fontStyle(this.fontStyle) + .fontFamily("sans-serif") + .textAlign(this.textAlign) + .textOverflow(this.textOverflow) + .lineHeight(this.lineHeight) + .baselineOffset(this.baselineOffset) + .maxLines(2) + .textCase(this.textCase) + .decoration(this.decoration) + .aspectRatio(1) + .fontColor(Color.Black) + .key('Text') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .size({ width: 100, height: 50 }) + .padding({ bottom: 5, top: 5, right: 5, left: 10 }) + .margin({ bottom: 15, top: 10, right: 10, left: 10 }) + .fontSize('13') + .textAlign(TextAlign.Start) + .align(Alignment.Start) + .direction(Direction.Ltr) + .alignSelf(ItemAlign.Start) + .borderStyle(BorderStyle.Dotted) + .borderWidth(2) + .visibility(Visibility.Hidden) + .enabled(true) + .fontWeight(FontWeight.Normal) + .textAlign(TextAlign.Start) + .textOverflow(TextOverflow.Clip) + .maxLines(2) + .textCase(TextCase.LowerCase) + .decoration({ "type": TextDecorationType.LineThrough, "color": Color.Red }) + .fontColor(Color.White) + .key('Text1') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .width('100%') + .textAlign(TextAlign.Center) + .align(Alignment.TopEnd) + .direction(Direction.Rtl) + .alignSelf(ItemAlign.Center) + .borderStyle(BorderStyle.Solid) + .borderWidth(2) + .visibility(Visibility.None) + .fontWeight(FontWeight.Bolder) + .textAlign(TextAlign.Center) + .textOverflow(TextOverflow.None) + .textCase(TextCase.UpperCase) + .decoration({ "type": TextDecorationType.None, "color": Color.Red }) + .fontColor(Color.Blue) + .key('Text2') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.Top) + .alignSelf(ItemAlign.End) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Lighter) + .decoration({ type: TextDecorationType.Overline, color: Color.Red }) + .fontColor(Color.Gray) + .key('Text3') + Text('Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.TopStart) + .alignSelf(ItemAlign.Baseline) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Medium) + .fontColor(Color.Brown) + .key('Text4') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.End) + .alignSelf(ItemAlign.Stretch) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Regular) + .fontColor(Color.Grey) + .key('Text5') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.BottomEnd) + .width('100%') + .fontColor(Color.Orange) + .key('Text6') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.Bottom) + .width('100%') + .fontColor(Color.Yellow) + .key('Text7') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.BottomStart) + .width('100%') + .key('Text8') + + } + .key('flex') + .width('100%') + .height('100%') + } +} + + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/index.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..10359134da915c9b44b0836ba4881bca71f43f33 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,65 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 file from '@system.file'; + +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; +import testsuite from "../test/List.test.ets"; +import featureAbility from "@ohos.ability.featureAbility"; + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + Want.parameters['timeout'] = 100000 + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('ACE ETS TEST') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..04700bf744eac5b21e99ed5e02d6cb3a9e00d40e --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpJsunit.test.ets @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2021 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 {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index.ets'; +import http from '@ohos.net.http'; + +export default function httpJsunit() { + describe("httpJsunitTest", function () { + /** + * @tc.number Telephony_Http_Http_createHttp_0100 + * @tc.name createHttp + * @tc.desc Test Create HTTP authentication. + */ + it("Telephony_Http_Http_createHttp_0100", 0, async function (done) { + console.log("-----------------------http createHttp Test is starting-----------------------"); + var httpRequest = http.createHttp(); + expect(httpRequest != null).assertTrue(); + console.log("-----------------------http createHttp Test end-----------------------"); + done(); + }); + + }) + +}; + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpRequestJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpRequestJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3dcab425b76e949b068fdd295cfd2c0438a354cb --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpRequestJsunit.test.ets @@ -0,0 +1,280 @@ +/* + * Copyright (C) 2021 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 {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index.ets'; +import http from '@ohos.net.http'; +import utils from './Utils.ets' + +export default function httpRequestJsunit() { + describe("HttpRequestJsunitTest", function () { + /** + * @tc.number Telephony_http_HttpRequest_request_0100 + * @tc.name httprequest::request + * @tc.desc Test Test httprequest property. + */ + it("Telephony_http_HttpRequest_request_0100", 0, async function (done) { + var casename = "Telephony_http_HttpRequest_0100" + console.log("-----------------------HttpRequest_request Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequest_request Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequest_request_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequest_request_0200 + * @tc.name httprequest::request + * @tc.desc Test Test httprequest property. + */ + it("Telephony_http_HttpRequest_request_0200", 0, async function (done) { + var casename = "Telephony_http_HttpRequest_0100" + console.log("-----------------------HttpRequest_request_01 Test is starting-----------------------"); + try { + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequest_request_01 Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequest_request_0200 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequest_request_0300 + * @tc.name httprequest::request + * @tc.desc Test Test httprequest property. + */ + it("Telephony_http_HttpRequest_request_0300", 0, async function (done) { + var casename = "Telephony_http_HttpRequest_0100" + console.log("-----------------------HttpRequest_request_02 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequest_request_02 Test end-----------------------"); + done(); + }).catch(error => { + console.info('HttpRequest_request_0300 asyncCallback error : ' + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequest_request_0300 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_http_HttpRequest_destroy_0100 + * @tc.name httprequest::destroy + * @tc.desc Test Test httprequest property. + */ + + it("Telephony_http_HttpRequest_destroy_0100", 0, async function (done) { + var casename = "Telephony_http_HttpRequest_0200" + console.log("-----------------------HttpRequest_destroy Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + try{ + httpRequest.destroy(); + expect(true).assertTrue(); + console.log("-----------------------HttpRequest_destroy Test end-----------------------"); + done(); + }catch(error){ + expect().assertFail(); + done(); + } + }); + } catch (error) { + console.log("Telephony_http_HttpRequest_destroy_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequest_on_headerReceive_0100 + * @tc.name httprequest::on_headerReceive + * @tc.desc Test Test httprequest property. + */ + + it("Telephony_http_HttpRequest_on_headerReceive_0100", 0, async function (done) { + var casename = "Telephony_http_HttpRequest_0300" + console.log("-----------------------HttpRequest_on_headerReceive Test is starting-----------------------"); + try { + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.on_headerReceive((data) => { + console.log(casename + " data: " + JSON.stringify(data)); + expect(true).assertTrue(); + console.log("-----------------------HttpRequest_on_headerReceive Test end-----------------------"); + done(); + }); + + } catch (error) { + console.log("Telephony_http_HttpRequest_on_headerReceive_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequest_off_headerReceive_0100 + * @tc.name httprequest::off_headerReceive + * @tc.desc Test Test httprequest property. + */ + it("Telephony_http_HttpRequest_off_headerReceive_0100", 0, async function (done) { + var casename = "Telephony_http_HttpRequest_0400" + console.log("-----------------------HttpRequest_off_headerReceive Test is starting-----------------------"); + try { + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.off_headerReceive((data) => { + console.log(casename + " data: " + JSON.stringify(data)); + expect(true).assertTrue(); + console.log("-----------------------HttpRequest_off_headerReceive Test end-----------------------"); + done(); + }); + + } catch (error) { + console.log("Telephony_http_HttpRequest_off_headerReceive_0100 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_http_HttpRequest_on_headersReceive_0100 + * @tc.name httprequest::on_headersReceive + * @tc.desc Test Test httprequest property. + */ + + it("Telephony_http_HttpRequest_on_headersReceive_0100", 0, function (done) { + var casename = "Telephony_http_HttpRequest_0500" + console.log("-----------------------HttpRequest_on_headersReceive Test is starting-----------------------"); + try { + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.on("headersReceive", (data) => { + console.log(casename + " data: " + JSON.stringify(data)); + expect(true).assertTrue(); + console.log("-----------------------HttpRequest_on_headersReceive Test end-----------------------"); + done(); + }); + + } catch (error) { + console.log("Telephony_http_HttpRequest_on_headersReceive_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_http_HttpRequest_off_headersReceive_0100 + * @tc.name httprequest::off_headersReceive + * @tc.desc Test Test httprequest property. + */ + it("Telephony_http_HttpRequest_off_headersReceive_0100", 0, function (done) { + var casename = "Telephony_http_HttpRequest_0600" + console.log("-----------------------HttpRequest_off_headersReceive Test is starting-----------------------"); + try { + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.off("headersReceive", (data) => { + console.log(casename + " data: " + JSON.stringify(data)); + expect(true).assertTrue(); + console.log("-----------------------HttpRequest_off_headersReceive Test end-----------------------"); + done(); + }); + + } catch (error) { + console.log("Telephony_http_HttpRequest_off_headersReceive_0100 : error = " + error); + done(); + } + }); + + + }) + +}; + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpRequestOptionsJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpRequestOptionsJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7d711790c160bfb286d3599966346be766881731 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpRequestOptionsJsunit.test.ets @@ -0,0 +1,522 @@ +/* + * Copyright (C) 2021 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 {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index.ets'; +import http from '@ohos.net.http'; +import utils from './Utils.ets' + + +export default function HttpRequestOptionsJsunit() { + describe("HttpRequestOptionsJsunitTest", function () { + + + /** + * @tc.number Telephony_Http_HttpRequestOptions_method_0100 + * @tc.name HttpRequestOptions::method + * @tc.desc Test Test HttpRequestOptions property. + */ + it("Telephony_http_HttpRequestOptions_method_0100", 0, async function (done) { + var casename = 'Telephony_Http_HttpRequestOptions_0100'; + console.log("-----------------------HttpRequestOptions_method Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestOptions_method Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_method_0100 : error = " + error); + done(); + } + }); + + + + /** + * @tc.number Telephony_http_HttpRequestOptions_method_0200 + * @tc.name HttpRequestOptions::method + * @tc.desc Test Test HttpRequestOptions property. + */ + it("Telephony_http_HttpRequestOptions_method_0200", 0, async function (done) { + var casename = 'Telephony_Http_HttpRequestOptions_0100'; + console.log("-----------------------HttpRequestOptions_method_01 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestOptions_method_01 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequestOptions_method_0200 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_Http_HttpRequestOptions_extraData_0100 + * @tc.name HttpRequestOptions::extraData + * @tc.desc Test Test HttpRequestOptions property. + */ + it("Telephony_Http_HttpRequestOptions_extraData_0100", 0, async function (done) { + var casename = 'Telephony_Http_HttpRequestOptions_0200'; + console.log("-----------------------HttpRequestOptions_extraData Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: { + //tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30 + tn: "albumsdetail", + work: "渐变风格插画", + fr: "albumslist", + album_tab: "设计素材", + album_id: "409", + rn: "30" + }, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestOptions_extraData Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_extraData_0100 : error = " + error); + done(); + } + }); + + + + /** + * @tc.number Telephony_Http_HttpRequestOptions_extraData_0200 + * @tc.name HttpRequestOptions::extraData + * @tc.desc Test Test HttpRequestOptions property. + */ + it("Telephony_Http_HttpRequestOptions_extraData_0200", 0, async function (done) { + var casename = 'Telephony_Http_HttpRequestOptions_0200'; + console.log("-----------------------HttpRequestOptions_extraData_01 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: { + //tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30 + tn: "albumsdetail", + work: "渐变风格插画", + fr: "albumslist", + album_tab: "设计素材", + album_id: "409", + rn: "30" + }, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestOptions_extraData_01 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_extraData_0200 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_Http_HttpRequestOptions_header_0100 + * @tc.name HttpRequestOptions::header + * @tc.desc Test Test HttpRequestOptions property. + */ + + it("Telephony_Http_HttpRequestOptions_header_0100", 0, async function (done) { + var casename = 'Telephony_Http_HttpRequestOptions_0300'; + console.log("-----------------------HttpRequestOptions_header Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + try { + var entity = JSON.parse(data.getResult()); + expect(true).assertTrue(); + console.log("-----------------------HttpRequestOptions_header Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_header_0100 : JSON parse error = " + error); + expect().assertFail(); + done(); + } + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_header_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_HttpRequestOptions_header_0200 + * @tc.name HttpRequestOptions::header + * @tc.desc Test Test HttpRequestOptions property. + */ + + it("Telephony_Http_HttpRequestOptions_header_0200", 0, async function (done) { + var casename = 'Telephony_Http_HttpRequestOptions_0300'; + console.log("-----------------------HttpRequestOptions_header_01 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + try { + var entity = JSON.parse(data.getResult()); + expect(true).assertTrue(); + console.log("-----------------------HttpRequestOptions_header_01 Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_header_0200 : JSON parse error = " + error); + expect().assertFail(); + done(); + } + + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_header_0200 : error = " + error); + done(); + } + }); + + + + + /** + * @tc.number Telephony_Http_HttpRequestOptions_header_0300 + * @tc.name HttpRequestOptions::header + * @tc.desc Test Test HttpRequestOptions property. + */ + + it("Telephony_Http_HttpRequestOptions_header_0300", 0, async function (done) { + var casename = 'Telephony_Http_HttpRequestOptions_0300'; + console.log("-----------------------HttpRequestOptions_header_02 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/xml", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + try { + var result = ''; + expect(data.getResult().contains(result)).assertTrue(); + console.log("-----------------------HttpRequestOptions_header_02 Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_header_0300 : JSON parse error = " + error); + expect().assertFail(); + done(); + } + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_header_0300 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_HttpRequestOptions_header_0400 + * @tc.name HttpRequestOptions::header + * @tc.desc Test Test HttpRequestOptions property. + */ + + it("Telephony_Http_HttpRequestOptions_header_0400", 0, async function (done) { + var casename = 'Telephony_Http_HttpRequestOptions_0300'; + console.log("-----------------------HttpRequestOptions_header_03 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/xml", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + try { + var result = ''; + expect(data.getResult().contains(result)).assertTrue(); + console.log("-----------------------HttpRequestOptions_header_03 Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_header_0400 : JSON parse error = " + error); + expect().assertFail(); + done(); + } + + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_header_0400 : error = " + error); + done(); + } + }); + + + + + + /** + * @tc.number Telephony_Http_HttpRequestOptions_readTimeout_0100 + * @tc.name HttpRequestOptions::readTimeout + * @tc.desc Test Test HttpRequestOptions property. + */ + + it("Telephony_Http_HttpRequestOptions_readTimeout_0100", 0, async function (done) { + var casename = 'Telephony_Http_HttpRequestOptions_0400'; + console.log("-----------------------HttpRequestOptions_readTimeout Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 0.1, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResponseCode == 408).assertTrue(); + console.log("-----------------------HttpRequestOptions_readTimeout Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_readTimeout_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_HttpRequestOptions_readTimeout_0200 + * @tc.name HttpRequestOptions::readTimeout + * @tc.desc Test Test HttpRequestOptions property. + */ + + it("Telephony_Http_HttpRequestOptions_readTimeout_0200", 0, async function (done) { + var casename = 'Telephony_Http_HttpRequestOptions_0400'; + console.log("-----------------------HttpRequestOptions_readTimeout_01 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 0.1, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + expect(data.getResponseCode == 408).assertTrue(); + console.log("-----------------------HttpRequestOptions_readTimeout_01 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_readTimeout_0200 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_Http_HttpRequestOptions_connectTimeout_0100 + * @tc.name HttpRequestOptions::connectTimeout + * @tc.desc Test Test HttpRequestOptions property. + */ + + it("Telephony_Http_HttpRequestOptions_connectTimeout_0100", 0, async function (done) { + var casename = 'Telephony_Http_HttpRequestOptions_0500'; + console.log("-----------------------HttpRequestOptions_connectTimeout Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 0.1 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResponseCode == 504).assertTrue(); + console.log("-----------------------HttpRequestOptions_connectTimeout Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_connectTimeout_0100 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_Http_HttpRequestOptions_connectTimeout_0200 + * @tc.name HttpRequestOptions::connectTimeout + * @tc.desc Test Test HttpRequestOptions property. + */ + + it("Telephony_Http_HttpRequestOptions_connectTimeout_0200", 0, async function (done) { + var casename = 'Telephony_Http_HttpRequestOptions_0500'; + console.log("-----------------------HttpRequestOptions_connectTimeout_01 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 0.1 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + expect(data.getResponseCode == 504).assertTrue(); + console.log("-----------------------HttpRequestOptions_connectTimeout_01 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestOptions_connectTimeout_0200 : error = " + error); + done(); + } + }); + + }) + +}; + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpResponseJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpResponseJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..215913b1f3b8f1797c37aa3a985b38d5f80b09df --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/HttpResponseJsunit.test.ets @@ -0,0 +1,449 @@ +/* + * Copyright (C) 2021 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 {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index.ets'; +import http from '@ohos.net.http'; +import utils from './Utils.ets' + +export default function httpResponseJsunit() { + describe("HttpResponseJsunitTest", function () { + + /** + * @tc.number Telephony_Http_HttpResponse_result_0100 + * @tc.name HttpResponse::result + * @tc.desc Test Test HttpResponse property. + */ + + it("Telephony_Http_HttpResponse_result_0100", 0, async function (done) { + var casename = 'Telephony_Http_HttpResponse_0100'; + console.log("-----------------------HttpResponse result Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResult() != null).assertTrue(); + console.log("-----------------------HttpResponse result Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpResponse_result_0100 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_Http_HttpResponse_result_0200 + * @tc.name HttpResponse::result + * @tc.desc Test Test HttpResponse property. + */ + + it("Telephony_Http_HttpResponse_result_0200", 0, async function (done) { + var casename = 'Telephony_Http_HttpResponse_0100'; + console.log("-----------------------HttpResponse result_01 Test is starting-----------------------"); + try { + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResult() != null).assertTrue(); + console.log("-----------------------HttpResponse result_01 Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpResponse_result_0200 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_Http_HttpResponse_result_0300 + * @tc.name HttpResponse::result + * @tc.desc Test Test HttpResponse property. + */ + + it("Telephony_Http_HttpResponse_result_0300", 0, async function (done) { + var casename = 'Telephony_Http_HttpResponse_0100'; + console.log("-----------------------HttpResponse result_02 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + expect(data.getResult() != null).assertTrue(); + console.log("-----------------------HttpResponse result_02 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpResponse_result_0300 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_Http_HttpResponse_responseCode_0100 + * @tc.name HttpResponse::responseCode + * @tc.desc Test Test HttpResponse property. + */ + + it("Telephony_Http_HttpResponse_responseCode_0100", 0, async function (done) { + var casename = 'Telephony_Http_HttpResponse_0200'; + console.log("-----------------------HttpResponse responseCode Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResponseCode() != 0).assertTrue(); + console.log("-----------------------HttpResponse responseCode Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpResponse_responseCode_0100 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_Http_HttpResponse_responseCode_0200 + * @tc.name HttpResponse::responseCode + * @tc.desc Test Test HttpResponse property. + */ + + it("Telephony_Http_HttpResponse_responseCode_0200", 0, async function (done) { + var casename = 'Telephony_Http_HttpResponse_0200'; + console.log("-----------------------HttpResponse responseCode_01 Test is starting-----------------------"); + try { + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResponseCode() != 0).assertTrue(); + console.log("-----------------------HttpResponse responseCode_01 Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpResponse_responseCode_0200 : error = " + error); + done(); + } + }); + + + + /** + * @tc.number Telephony_Http_HttpResponse_responseCode_0300 + * @tc.name HttpResponse::responseCode + * @tc.desc Test Test HttpResponse property. + */ + + it("Telephony_Http_HttpResponse_responseCode_0300", 0, async function (done) { + var casename = 'Telephony_Http_HttpResponse_0200'; + console.log("-----------------------HttpResponse responseCode_02 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + expect(data.getResponseCode() != 0).assertTrue(); + console.log("-----------------------HttpResponse responseCode_02 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpResponse_responseCode_0300 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_HttpResponse_header_0100 + * @tc.name HttpResponse::header + * @tc.desc Test Test HttpResponse property. + */ + + it("Telephony_Http_HttpResponse_header_0100", 0, async function (done) { + var casename = 'Telephony_Http_HttpResponse_0300'; + console.log("-----------------------HttpResponse header Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getHead() != null).assertTrue(); + console.log("-----------------------header result Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpResponse_header_0100 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_Http_HttpResponse_header_0200 + * @tc.name HttpResponse::header + * @tc.desc Test Test HttpResponse property. + */ + + it("Telephony_Http_HttpResponse_header_0200", 0, async function (done) { + var casename = 'Telephony_Http_HttpResponse_0300'; + console.log("-----------------------HttpResponse header_01 Test is starting-----------------------"); + try { + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getHead() != null).assertTrue(); + console.log("-----------------------header header_01 Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpResponse_header_0200 : error = " + error); + done(); + } + }); + + + + /** + * @tc.number Telephony_Http_HttpResponse_header_0300 + * @tc.name HttpResponse::header + * @tc.desc Test Test HttpResponse property. + */ + + it("Telephony_Http_HttpResponse_header_0300", 0, async function (done) { + var casename = 'Telephony_Http_HttpResponse_0300'; + console.log("-----------------------HttpResponse header_02 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + expect(data.getHead() != null).assertTrue(); + console.log("-----------------------HttpResponse header_02 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpResponse_header_0300 : error = " + error); + done(); + } + }); + + + + + /** + * @tc.number Telephony_Http_HttpResponse_cookies_0100 + * @tc.name HttpResponse::cookies + * @tc.desc Test Test HttpResponse property. + */ + + + it("Telephony_Http_HttpResponse_cookies_0100", 0, async function (done) { + var casename = 'Telephony_Http_HttpResponse_0400'; + console.log("-----------------------HttpResponse cookies Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getCookies != null).assertTrue(); + console.log("-----------------------HttpResponse cookies Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpResponse_cookies_0100 : error = " + error); + done(); + } + }); + + + + /** + * @tc.number Telephony_Http_HttpResponse_cookies_0200 + * @tc.name HttpResponse::cookies + * @tc.desc Test Test HttpResponse property. + */ + + + it("Telephony_Http_HttpResponse_cookies_0200", 0, async function (done) { + var casename = 'Telephony_Http_HttpResponse_0400'; + console.log("-----------------------HttpResponse cookies_01 Test is starting-----------------------"); + try { + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getCookies != null).assertTrue(); + console.log("-----------------------HttpResponse cookies_01 Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpResponse_cookies_0200 : error = " + error); + done(); + } + }); + + + + + /** + * @tc.number Telephony_Http_HttpResponse_cookies_0300 + * @tc.name HttpResponse::cookies + * @tc.desc Test Test HttpResponse property. + */ + + + it("Telephony_Http_HttpResponse_cookies_0300", 0, async function (done) { + var casename = 'Telephony_Http_HttpResponse_0400'; + console.log("-----------------------HttpResponse cookies_02 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: 'GET', + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + expect(data.getCookies() != null).assertTrue(); + console.log("-----------------------HttpResponse cookies_02 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpResponse_cookies_0300 : error = " + error); + done(); + } + }); + + }) + +}; + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/List.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..34a0f9c29ffae557e1aae1a16e19a7e2c327057c --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2021 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. + */ + +//other import +import httpJsunit from './HttpJsunit.test.ets' +import responseCodeJsunit from './ResponseCodeJsunit.test.ets'; +import requestMethodJsunit from './RequestMethodJsunit.test.ets'; +import httpResponseJsunit from './HttpResponseJsunit.test.ets'; +import HttpRequestOptionsJsunit from './HttpRequestOptionsJsunit.test.ets'; +import httpRequestJsunit from './HttpRequestJsunit.test.ets'; + +export default function testsuite() { + //other + httpJsunit(); + responseCodeJsunit(); + requestMethodJsunit(); + httpResponseJsunit(); + HttpRequestOptionsJsunit(); + httpRequestJsunit(); +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/RequestMethodJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/RequestMethodJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ebf9e7d171b8612699480b8c7d8a47eac2d69f00 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/RequestMethodJsunit.test.ets @@ -0,0 +1,347 @@ +/* + * Copyright (C) 2021 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 {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index.ets'; +import http from '@ohos.net.http'; +import utils from './Utils.ets' + +export default function requestMethodJsunit() { + describe("requestMethodJsunit", function () { + + /** + * @tc.number Telephony_http_HttpRequestMethod_options_0100 + * @tc.name HttpRequestMethod::options + * @tc.desc Test Test HttpRequestMethod property. + */ + + it("Telephony_http_HttpRequestMethod_options_0100", 0, async function (done) { + var casename = 'Telephony_http_HttpRequestMethod_0100'; + console.log("-----------------------HttpRequestMethod_options Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "OPTIONS", + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestMethod_options Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestMethod_options_0100 : error = " + error); + done(); + } + }); + + + + /** + * @tc.number Telephony_http_HttpRequestMethod_options_0200 + * @tc.name HttpRequestMethod::options + * @tc.desc Test Test HttpRequestMethod property. + */ + + it("Telephony_http_HttpRequestMethod_options_0200", 0, async function (done) { + var casename = 'Telephony_http_HttpRequestMethod_0100'; + console.log("-----------------------HttpRequestMethod_options_01 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "OPTIONS", + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestMethod_options_01 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequestMethod_options_0200 : error = " + error); + done(); + } + }); + + + + /** + * @tc.number Telephony_http_HttpRequestMethod_GET_0100 + * @tc.name HttpRequestMethod::GET + * @tc.desc Test Test HttpRequestMethod property. + */ + + it("Telephony_http_HttpRequestMethod_GET_0100", 0, async function (done) { + var casename = "Telephony_http_HttpRequestMethod_0200" + console.log("-----------------------HttpRequestMethod_GET Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "GET", + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestMethod_GET Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestMethod_GET_0100 : error = " + error); + done(); + } + }); + + + + /** + * @tc.number Telephony_http_HttpRequestMethod_GET_0200 + * @tc.name HttpRequestMethod::GET + * @tc.desc Test Test HttpRequestMethod property. + */ + + it("Telephony_http_HttpRequestMethod_GET_0200", 0, async function (done) { + var casename = "Telephony_http_HttpRequestMethod_0200" + console.log("-----------------------HttpRequestMethod_GET_01 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "GET", + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestMethod_GET_01 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequestMethod_GET_0200 : error = " + error); + done(); + } + }); + + + + /** + * @tc.number Telephony_http_HttpRequestMethod_POST_0100 + * @tc.name HttpRequestMethod::POST + * @tc.desc Test Test HttpRequestMethod property. + */ + + it("Telephony_http_HttpRequestMethod_POST_0100", 0, async function (done) { + var casename = "Telephony_http_HttpRequestMethod_0300" + console.log("-----------------------HttpRequestMethod_POST Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "POST", + extraData: { + //tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30 + tn: "albumsdetail", + work: "渐变风格插画", + fr: "albumslist", + album_tab: "设计素材", + album_id: "409", + rn: "30" + }, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestMethod_POST Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestMethod_POST_0100 : error = " + error); + done(); + } + }); + + + + /** + * @tc.number Telephony_http_HttpRequestMethod_POST_0100 + * @tc.name HttpRequestMethod::POST + * @tc.desc Test Test HttpRequestMethod property. + */ + + it("Telephony_http_HttpRequestMethod_POST_0200", 0, async function (done) { + var casename = "Telephony_http_HttpRequestMethod_0300" + console.log("-----------------------HttpRequestMethod_POST_01 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "POST", + extraData: { + //tn=albumsdetail&word=渐变风格插画&fr=albumslist&album_tab=设计素材&album_id=409&rn=30 + tn: "albumsdetail", + work: "渐变风格插画", + fr: "albumslist", + album_tab: "设计素材", + album_id: "409", + rn: "30" + }, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://image.baidu.com/search/albumsdetail/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestMethod_POST_01 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequestMethod_POST_0200 : error = " + error); + done(); + } + }); + + + + /** + * @tc.number Telephony_http_HttpRequestMethod_TRACE_0100 + * @tc.name HttpRequestMethod::TRACE + * @tc.desc Test Test HttpRequestMethod property. + */ + + it("Telephony_http_HttpRequestMethod_TRACE_0100", 0, async function (done) { + var casename = "Telephony_http_HttpRequestMethod_0400" + console.log("-----------------------HttpRequestMethod_TRACE Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "TRACE", + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions, (err, data) => { + console.log(casename + JSON.stringify(err) + " data: " + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestMethod_TRACE Test end-----------------------"); + done(); + }); + } catch (error) { + console.log("Telephony_Http_HttpRequestMethod_TRACE_0100 : error = " + error); + done(); + } + }); + + + /** + * @tc.number Telephony_http_HttpRequestMethod_TRACE_0200 + * @tc.name HttpRequestMethod::TRACE + * @tc.desc Test Test HttpRequestMethod property. + */ + + it("Telephony_http_HttpRequestMethod_TRACE_0200", 0, async function (done) { + var casename = "Telephony_http_HttpRequestMethod_0400" + console.log("-----------------------HttpRequestMethod_TRACE_01 Test is starting-----------------------"); + try { + let httpRequestOptions = { + method: "TRACE", + extraData: null, + header: "content-type': 'application/json", + readTimeout: 60, + connectTimeout: 60 + } + var httpRequest = http.createHttp(); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + httpRequest.request("https://www.baidu.com/", httpRequestOptions).then(data => { + console.log(casename + JSON.stringify(data)); + expect(data.getResponseCode = 200).assertTrue(); + console.log("-----------------------HttpRequestMethod_TRACE_01 Test end-----------------------"); + done(); + }).catch(error => { + console.info(casename+"errocode" + JSON.stringify(error)); + done(); + }); + } catch (error) { + console.log("Telephony_http_HttpRequestMethod_TRACE_0200 : error = " + error); + done(); + } + }); + + + }) + +}; + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/ResponseCodeJsunit.test.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/ResponseCodeJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3f36dea146e9224bd860dbef032b3ec45df8c48e --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/ResponseCodeJsunit.test.ets @@ -0,0 +1,456 @@ +/* + * Copyright (C) 2021 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 {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index.ets'; +import http from '@ohos.net.http'; + +export default function responseCodeJsunit() { + describe("responseCodeJsunitTest", function () { + + /** + * @tc.number Telephony_Http_ResponseCode_ACCEPTED_0100 + * @tc.name ResponseCode::ACCEPTED + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_ACCEPTED_0100", 0, async function (done) { + console.log("-----------------------ResponseCode_ACCEPTED Test is starting-----------------------"); + try { + expect(202).assertEqual(http.ResponseCode.ACCEPTED); + console.log("-----------------------ResponseCode ACCEPTED Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_ACCEPTED_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_NOT_AUTHORITATIVE_0100 + * @tc.name ResponseCode::NOT_AUTHORITATIVE + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_NOT_AUTHORITATIVE_0100", 0, async function (done) { + console.log("-----------------------ResponseCode NOT_AUTHORITATIVE Test is starting-----------------------"); + try { + expect(203).assertEqual(http.ResponseCode.NOT_AUTHORITATIVE); + console.log("-----------------------ResponseCode NOT_AUTHORITATIVE Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_NOT_AUTHORITATIVE_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_NO_CONTENT_0100 + * @tc.name ResponseCode::NO_CONTENT + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_NO_CONTENT_0100", 0, async function (done) { + console.log("-----------------------ResponseCode NO_CONTENT Test is starting-----------------------"); + try { + expect(204).assertEqual(http.ResponseCode.NO_CONTENT); + console.log("-----------------------ResponseCode NO_CONTENT Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_NO_CONTENT_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_MULT_CHOICE_0100 + * @tc.name ResponseCode::MULT_CHOICE + * @tc.desc Test Test ResponseCode property. + */ + it("Telephony_Http_ResponseCode_MULT_CHOICE_0100", 0, async function (done) { + console.log("-----------------------ResponseCode MULT_CHOICE Test is starting-----------------------"); + try { + expect(300).assertEqual(http.ResponseCode.MULT_CHOICE); + console.log("-----------------------ResponseCode MULT_CHOICE Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_MULT_CHOICE_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_MOVED_PERM_0100 + * @tc.name ResponseCode::MOVED_PERM + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_MOVED_PERM_0100", 0, async function (done) { + console.log("-----------------------ResponseCode MOVED_PERM Test is starting-----------------------"); + try { + expect(301).assertEqual(http.ResponseCode.MOVED_PERM); + console.log("-----------------------ResponseCode MOVED_PERM Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_MOVED_PERM_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_SEE_OTHER_0100 + * @tc.name ResponseCode::SEE_OTHER + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_SEE_OTHER_0100", 0, async function (done) { + console.log("-----------------------ResponseCode SEE_OTHER Test is starting-----------------------"); + try { + expect(303).assertEqual(http.ResponseCode.SEE_OTHER); + console.log("-----------------------ResponseCode SEE_OTHER Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_SEE_OTHER_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_NOT_MODIFIED_0100 + * @tc.name ResponseCode::NOT_MODIFIED + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_NOT_MODIFIED_0100", 0, async function (done) { + console.log("-----------------------ResponseCode NOT_MODIFIED Test is starting-----------------------"); + try { + expect(304).assertEqual(http.ResponseCode.NOT_MODIFIED); + console.log("-----------------------ResponseCode NOT_MODIFIED Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_NOT_MODIFIED_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_USE_PROXY_0100 + * @tc.name ResponseCode::USE_PROXY + * @tc.desc Test Test ResponseCode property. + */ + it("Telephony_Http_ResponseCode_USE_PROXY_0100", 0, async function (done) { + console.log("-----------------------ResponseCode USE_PROXY Test is starting-----------------------"); + try { + expect(305).assertEqual(http.ResponseCode.USE_PROXY); + console.log("-----------------------ResponseCode USE_PROXY Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_USE_PROXY_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_BAD_REQUEST_0100 + * @tc.name ResponseCode::BAD_REQUEST + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_BAD_REQUEST_0100", 0, async function (done) { + console.log("-----------------------ResponseCode BAD_REQUEST Test is starting-----------------------"); + try { + expect(400).assertEqual(http.ResponseCode.BAD_REQUEST); + console.log("-----------------------ResponseCode BAD_REQUEST Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_BAD_REQUEST_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_UNAUTHORIZED_0100 + * @tc.name ResponseCode::ResponseCode_UNAUTHORIZED + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_UNAUTHORIZED_0100", 0, async function (done) { + console.log("-----------------------ResponseCode UNAUTHORIZED Test is starting-----------------------"); + try { + expect(401).assertEqual(http.ResponseCode.UNAUTHORIZED); + console.log("-----------------------ResponseCode UNAUTHORIZED Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_UNAUTHORIZED_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_PAYMENT_REQUIRED_0100 + * @tc.name ResponseCode::PAYMENT_REQUIRED + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_PAYMENT_REQUIRED_0100", 0, async function (done) { + console.log("-----------------------ResponseCode PAYMENT_REQUIRED Test is starting-----------------------"); + try { + expect(402).assertEqual(http.ResponseCode.PAYMENT_REQUIRED); + console.log("-----------------------ResponseCode PAYMENT_REQUIRED Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_PAYMENT_REQUIRED_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_BAD_METHOD_0100 + * @tc.name ResponseCode::BAD_METHOD + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_BAD_METHOD_0100", 0, async function (done) { + console.log("-----------------------ResponseCode BAD_METHOD Test is starting-----------------------"); + try { + expect(405).assertEqual(http.ResponseCode.BAD_METHOD); + console.log("-----------------------ResponseCode BAD_METHOD Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_BAD_METHOD_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_NOT_ACCEPTABLE_0100 + * @tc.name ResponseCode::NOT_ACCEPTABLE + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_NOT_ACCEPTABLE_0100", 0, async function (done) { + console.log("-----------------------ResponseCode NOT_ACCEPTABLE Test is starting-----------------------"); + try { + expect(406).assertEqual(http.ResponseCode.NOT_ACCEPTABLE); + console.log("-----------------------ResponseCode NOT_ACCEPTABLE Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_NOT_ACCEPTABLED_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_PROXY_AUTH_0100 + * @tc.name ResponseCode::PROXY_AUTH + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_PROXY_AUTH_0100", 0, async function (done) { + console.log("-----------------------ResponseCode PROXY_AUTH Test is starting-----------------------"); + try { + expect(407).assertEqual(http.ResponseCode.PROXY_AUTH); + console.log("-----------------------ResponseCode PROXY_AUTH Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_PROXY_AUTH_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_CLIENT_TIMEOUT_0100 + * @tc.name ResponseCode::CLIENT_TIMEOUT + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_CLIENT_TIMEOUT_0100", 0, async function (done) { + console.log("-----------------------ResponseCode CLIENT_TIMEOUT Test is starting-----------------------"); + try { + expect(408).assertEqual(http.ResponseCode.CLIENT_TIMEOUT); + console.log("-----------------------ResponseCode CLIENT_TIMEOUT Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_CLIENT_TIMEOUT_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_LENGTH_REQUIRED_0100 + * @tc.name ResponseCode::LENGTH_REQUIRED + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_LENGTH_REQUIRED_0100", 0, async function (done) { + console.log("-----------------------ResponseCode LENGTH_REQUIRED Test is starting-----------------------"); + try { + expect(411).assertEqual(http.ResponseCode.LENGTH_REQUIRED); + console.log("-----------------------ResponseCode LENGTH_REQUIRED Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_LENGTH_REQUIRED_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_PRECON_FAILED_0100 + * @tc.name ResponseCode::PRECON_FAILED + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_PRECON_FAILED_0100", 0, async function (done) { + console.log("-----------------------ResponseCode PRECON_FAILED Test is starting-----------------------"); + try { + expect(412).assertEqual(http.ResponseCode.PRECON_FAILED); + console.log("-----------------------ResponseCode PRECON_FAILED Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_PRECON_FAILED_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_ENTITY_TOO_LARGE_0100 + * @tc.name ResponseCode::ENTITY_TOO_LARGE + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_ENTITY_TOO_LARGE_0100", 0, async function (done) { + console.log("-----------------------ResponseCode ENTITY_TOO_LARGE Test is starting-----------------------"); + try { + expect(413).assertEqual(http.ResponseCode.ENTITY_TOO_LARGE); + console.log("-----------------------ResponseCode ENTITY_TOO_LARGE Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_ENTITY_TOO_LARGE_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_REQ_TOO_LONG_0100 + * @tc.name ResponseCode::REQ_TOO_LONG + * @tc.desc Test Test ResponseCode property. + */ + + + it("Telephony_Http_ResponseCode_REQ_TOO_LONG_0100", 0, async function (done) { + console.log("-----------------------ResponseCode REQ_TOO_LONG Test is starting-----------------------"); + try { + expect(414).assertEqual(http.ResponseCode.REQ_TOO_LONG); + console.log("-----------------------ResponseCode REQ_TOO_LONG Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_REQ_TOO_LONG_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_UNSUPPORTED_TYPE_0100 + * @tc.name ResponseCode::UNSUPPORTED_TYPE + * @tc.desc Test Test ResponseCode property. + */ + + + it("Telephony_Http_ResponseCode_UNSUPPORTED_TYPE_0100", 0, async function (done) { + console.log("-----------------------ResponseCode UNSUPPORTED_TYPE Test is starting-----------------------"); + try { + expect(415).assertEqual(http.ResponseCode.UNSUPPORTED_TYPE); + console.log("-----------------------ResponseCode UNSUPPORTED_TYPE Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_UNSUPPORTED_TYPE_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_INTERNAL_ERROR_0100 + * @tc.name ResponseCode::INTERNAL_ERROR + * @tc.desc Test Test ResponseCode property. + */ + it("Telephony_Http_ResponseCode_INTERNAL_ERROR_0100", 0, async function (done) { + console.log("-----------------------ResponseCode INTERNAL_ERROR Test is starting-----------------------"); + try { + expect(500).assertEqual(http.ResponseCode.INTERNAL_ERROR); + console.log("-----------------------ResponseCode INTERNAL_ERROR Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_INTERNAL_ERROR_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_NOT_IMPLEMENTED_0100 + * @tc.name ResponseCode::NOT_IMPLEMENTED + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_NOT_IMPLEMENTED_0100", 0, async function (done) { + console.log("-----------------------ResponseCode NOT_IMPLEMENTED Test is starting-----------------------"); + try { + expect(501).assertEqual(http.ResponseCode.NOT_IMPLEMENTED); + console.log("-----------------------ResponseCode NOT_IMPLEMENTED Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_NOT_IMPLEMENTED_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_BAD_GATEWAY_0100 + * @tc.name ResponseCode::BAD_GATEWAY + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_BAD_GATEWAY_0100", 0, async function (done) { + console.log("-----------------------ResponseCode BAD_GATEWAY Test is starting-----------------------"); + try { + expect(502).assertEqual(http.ResponseCode.BAD_GATEWAY); + console.log("-----------------------ResponseCode BAD_GATEWAY Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_BAD_GATEWAY_0100 : error = " + error); + done(); + } + }); + + /** + * @tc.number Telephony_Http_ResponseCode_GATEWAY_TIMEOUT_0100 + * @tc.name ResponseCode::GATEWAY_TIMEOUT + * @tc.desc Test Test ResponseCode property. + */ + + it("Telephony_Http_ResponseCode_GATEWAY_TIMEOUT_0100", 0, async function (done) { + console.log("-----------------------ResponseCode GATEWAY_TIMEOUT Test is starting-----------------------"); + try { + expect(504).assertEqual(http.ResponseCode.GATEWAY_TIMEOUT); + console.log("-----------------------ResponseCode GATEWAY_TIMEOUT Test end-----------------------"); + done(); + } catch (error) { + console.log("Telephony_Http_ResponseCode_GATEWAY_TIMEOUT_0100 : error = " + error); + done(); + } + }); + + + }) + +}; + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/Utils.ets b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..65f70088ddb62bcf80f4e0ec07dc841a8ab033f0 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,119 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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. + */ + +export default class Utils { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + static notCheck = true; + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } + + static async swipe(downX, downY, upX, upY, steps) { + console.info('start to swipe') + this.drags(downX, downY, upX, upY, steps, false) + } + + static async drag(downX, downY, upX, upY, steps) { + console.info('start to drag') + this.drags(downX, downY, upX, upY, steps, true) + } + + static async drags(downX, downY, upX, upY, steps, drag) { + var xStep; + var yStep; + var swipeSteps; + var ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + var downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('start to move') + if (drag) { + await this.sleep(500) + } + for (var i = 1;i <= swipeSteps; i++) { + var movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('start to up') + if (drag) { + await this.sleep(100) + } + var upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) + } +} + + + + diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/lib/Const.js b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/lib/Const.js new file mode 100644 index 0000000000000000000000000000000000000000..f9263cd46dee1a0ffdfaa1e5ef5c29755c7e13f7 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/ets/MainAbility/test/lib/Const.js @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2021 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. + */ + +// sim slot id +export const DEFAULT_SLOTID = 0; +export const SLOTID3 = 3; +export const SLOTID2 = 2; +export const SLOTID_MINUS1 = -1; + +// sim correct password +export const CORRECT_PIN = '1234'; +export const CORRECT_PIN2 = '18099014'; + +// sim incorrect password +export const INCORRECT_PIN = '134679'; +export const INCORRECT_PIN_LEN3 = '123'; +export const INCORRECT_PUK = '134679'; +export const INCORRECT_PIN2 = '134679'; +export const INCORRECT_PIN2_LEN3 = '123'; +export const INCORRECT_PIN2_LEN9 = '123456789'; +export const INCORRECT_PUK2 = '134679'; + +// lock status response +export const LOCK_RESULT = { SUCCESS: 0, FAILURE: -1, EXCEPTION: -2 }; \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03b8532c53ca563f8ed6b1e21d20ad3f67a68906 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/base/media/icon.png b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/hand.png b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/hand.png new file mode 100644 index 0000000000000000000000000000000000000000..9f1fa16ee073093b40920e273502513fa66fa980 Binary files /dev/null and b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/hand.png differ diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/icon.png b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/icon.png differ diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/images.jpg b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/images.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c75ddfc5ead15e8d49ca7cae9f97c03585565be1 Binary files /dev/null and b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/images.jpg differ diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/person.png b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/person.png new file mode 100644 index 0000000000000000000000000000000000000000..f0f540d078e6c0441a763ca2cc375a551d6cf736 Binary files /dev/null and b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/person.png differ diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/star-1-1.png b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/star-1-1.png new file mode 100644 index 0000000000000000000000000000000000000000..990c5e5ad20698c7701faf641bc80eb004a127b7 Binary files /dev/null and b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/star-1-1.png differ diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/star-1-2.png b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/star-1-2.png new file mode 100644 index 0000000000000000000000000000000000000000..450c3dd3ca68bf601bd08e5f41797d376e20d00d Binary files /dev/null and b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/star-1-2.png differ diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/star-1-3.png b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/star-1-3.png new file mode 100644 index 0000000000000000000000000000000000000000..1044869832b423a5dfc2559a395529377bd34f0c Binary files /dev/null and b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/star-1-3.png differ diff --git a/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/video/show.mp4 b/telephony/telephonyjstest/netmanager_http/entry/src/main/resources/rawfile/video/show.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/telephony/telephonyjstest/netmanager_http/signature/openharmony_sx.p7b b/telephony/telephonyjstest/netmanager_http/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/telephony/telephonyjstest/netmanager_http/signature/openharmony_sx.p7b differ diff --git a/telephony/telephonyjstest/netmanager_socket/BUILD.gn b/telephony/telephonyjstest/netmanager_socket/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..60f5120fd5adf0dd502a56cd5c500b048bdbc124 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 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("ActsNetManagerSocketEtsTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":ace_demo_ets_assets", + ":ace_demo_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsNetManagerSocketEtsTest" +} +ohos_js_assets("ace_demo_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("ace_demo_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/telephony/telephonyjstest/netmanager_socket/Test.json b/telephony/telephonyjstest/netmanager_socket/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..4131329b22f012ff379b3abb7cb214b47303dba0 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "1800000", + "package": "com.ohos.netmanagersocket", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsNetManagerSocketEtsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/config.json b/telephony/telephonyjstest/netmanager_socket/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..e881b685b20fbc0e8f22ec761a79f1def09ece29 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/config.json @@ -0,0 +1,93 @@ +{ + "app": { + "bundleName": "com.ohos.netmanagersocket", + "vendor": "open", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.netmanagersocket", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/Button", + "pages/Blank", + "pages/DataPanel", + "pages/Divider", + "pages/Text", + "pages/RowSplit", + "pages/Scroll", + "pages/Stack", + "pages/Image", + "pages/Progress", + "pages/Qrcode", + "pages/Rating", + "pages/Span", + "pages/Slider", + "pages/Badge", + "pages/Column", + "pages/ColumnSplit", + "pages/Counter", + "pages/Flex", + "pages/GridContainer" + + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/app.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..261fadca29ff0ea310a8bc105ddd1af65e2dd2f6 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Badge.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Badge.ets new file mode 100644 index 0000000000000000000000000000000000000000..66de6f8e3b9c0360931602dd25d1511878ac63ab --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Badge.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct badge { + @State counts: number = 33 + @State message: string = 'new' + @State active: boolean = false + private content: string = "badge Page"; + + onPageShow() { + console.info('badge page show called'); + } + + onBuildDone() { + console.info('badge page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Scroll() { + Column() { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Badge({ + count: this.counts, + position: BadgePosition.Right, + maxCount: 99, + style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge') + + Text("BadgePosition.RightTop").fontSize(16) + Badge({ + count: this.counts, + position: BadgePosition.RightTop, + maxCount: 99, + style: { color: 0xFFFFFF, fontSize: '16', badgeSize: '20', badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge1') + + Text("BadgePosition.Left").fontSize(16) + Badge({ + count: this.counts, + position: BadgePosition.Left, + maxCount: 99, + style: { color: Color.Pink, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge2') + } + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Blank.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Blank.ets new file mode 100644 index 0000000000000000000000000000000000000000..a50fc719e09ab27c91f9705ac06008e936830f33 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Blank.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct blank_testcase { + @State Color: Color = Color.Pink + @State active: boolean = false + private content: string = "Blank Page" + + onPageShow() { + console.info('Blank page show called'); + } + + onBuildDone() { + console.info('Blank page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Blank(100) + .color(this.Color) + .key('blank') + Text('on/off').fontSize(18).height(60) + } + .key('flex') + .width('100%') + .height('100%') + + + } +} diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Button.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Button.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac2271ea3a13664bbbb6afe4f173abae9e66f867 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Button.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct button_testcase { + @State stateEffect: boolean = true + @State ButtonType: ButtonType = ButtonType.Circle + private content: string = "Button Page"; + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button('1.value', { type: ButtonType.Circle, stateEffect: this.stateEffect }) + .fontSize(12) + .fontWeight(FontWeight.Bold) + .fontColor(0xCCCCCC) + .height(40) + .width(40) + .key('button') + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + .padding(10) + Button() { + Text("2.Capsule") + } + .type(ButtonType.Capsule) + .stateEffect(false) + .backgroundColor('#0D9FFB') + .padding(10) + .key('button1') + + Button() { + Text("3.Normal") + }.type(ButtonType.Normal) + .backgroundColor('#0D9FFB') + .key('button2') + + }.key('flex') + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Column.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Column.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9e5c84e21ccf25419be432d8f95418fac82070a --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Column.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct column { + @State active: boolean = false + private content: string = "Column Page" + + onPageShow() { + console.info('Column page show called'); + } + + onBuildDone() { + console.info('Column page build done called'); + } + + build() { + Column({ space: 5 }) { + Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Center).width('90%').border({ width: 1 }).key('column') + + Text('alignItems(Start)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column({ space: '5' }) { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Start).width('90%').border({ width: 1 }).key('column1') + + Text('alignItems(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.End).width('90%').border({ width: 1 }).key('column2') + }.width('100%').padding({ top: 5 }) + } +} diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb0597310a15be8ab4503a3ae89385e3708fac96 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct columnSplit { + private content: string = "ColumnSplit Page" + + onPageShow() { + console.info('ColumnSplit page show called'); + } + + onBuildDone() { + console.info('ColumnSplit page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Scroll() { + Column() { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Column() { + Text('ColumnSplit').fontSize(9).fontColor(0xCCCCCC).width('90%') + ColumnSplit() { + Text('1').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('2').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('3').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + }.key('columnSplit') + .resizeable(true) + .width('90%').height('60%') + + }.width("100%") + + Column() { + Text('ColumnSplit1').fontSize(9).fontColor(0xCCCCCC).width('90%') + ColumnSplit() { + Text('1').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('2').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('3').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + }.key('columnSplit1') + .resizeable(false) + .width('90%').height('60%') + + }.width("100%") + } + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Counter.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Counter.ets new file mode 100644 index 0000000000000000000000000000000000000000..ecdbfaf10393e7a348fd76098868e6455505b07f --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Counter.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct counter { + @State value: number = 0 + @State active: boolean = false + private content: string = "Counter Page" + + onPageShow() { + console.info('Counter page show called'); + } + + onBuildDone() { + console.info('Counter page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Counter() { + Text(this.value.toString()) + }.margin(100) + .key('counter') + .onInc(() => { + this.value++ + }) + .onDec(() => { + this.value-- + }) + }.width("100%") + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/DataPanel.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/DataPanel.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c624848482b22998b2a1d137796ddaedbcf198c --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/DataPanel.ets @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct dataPanel_testcase { + @State width: string= "200" + @State height: string= "100" + @State active: boolean = false + private content: string = "DataPanel Page" + + onPageShow() { + console.info('Blank page show called'); + } + + onBuildDone() { + console.info('Blank page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + DataPanel({ values: [20, 40, 20], max: 100, type: DataPanelType.Line }) + .width(this.width) + .height(this.height) + .key('DataPanel') + .onClick(() => { + router.back() + }) + .closeEffect(false) + + DataPanel({ values: [20, 40, 20], max: 100, type: DataPanelType.Circle}) + .width(this.width) + .height(this.height) + .key('DataPanel2') + .onClick(() => { + router.back() + }) + .closeEffect(true) + DataPanel({ values: [20, 40, 20], max: 100}) + .width(this.width) + .height(this.height) + .key('DataPanel3') + .onClick(() => { + router.back() + }) + .closeEffect(false) + } + .key('flex') + .width('100%') + .height('100%') + + } +} diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Divider.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Divider.ets new file mode 100644 index 0000000000000000000000000000000000000000..02bf60779418674d1fd58127907fdb3915bd8f8f --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Divider.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct divider_textcase { + @State vertical: boolean = true + @State color: Color = Color.Red + @State strokeWidth: number = 7 + @State lineCap: LineCapStyle = LineCapStyle.Butt + @State active: boolean = false + private content: string = "Divider Page"; + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + Divider() + .lineCap(LineCapStyle.Butt) + .strokeWidth(this.strokeWidth) + .color(this.color) + .vertical(this.vertical) + .height(150) + .key('divider') + .onClick(() => { + router.back() + }) + Divider() + .lineCap(LineCapStyle.Round) + .vertical(false) + .color(Color.Green) + .strokeWidth(10) + .height(150) + .key('divider1') + Divider() + .lineCap(LineCapStyle.Square) + .color(Color.Green) + .vertical(true) + .strokeWidth(10) + .height(150) + .key('divider2') + } + .key('flex') + .width('100%') + .height('100%') + } +} + + diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Flex.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Flex.ets new file mode 100644 index 0000000000000000000000000000000000000000..a0e21251e80008c5be9f29aa52074acc5eb24a78 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Flex.ets @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct flex { + private content: string = "Flex Page" + + onPageShow() { + console.info('Flex page show called'); + } + + onBuildDone() { + console.info('Flex page build done called'); + } + + build() { + Column() { + Column({ space : 2 }) { + Text('direction:Column').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Column, + wrap: FlexWrap.NoWrap, + justifyContent: FlexAlign.Center, + alignItems:ItemAlign.Start, + alignContent: FlexAlign.Start, + }) { + Text('1').width('100%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('100%').height(20).backgroundColor(0xD2B48C) + Text('3').width('100%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex') + .height(70) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('direction:Row').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.Start, + alignItems:ItemAlign.Start, + alignContent: FlexAlign.Center, + }) { + Text('1').width('20%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('20%').height(20).backgroundColor(0xD2B48C) + Text('3').width('20%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex1') + .height(70) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('direction:RowReverse').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.RowReverse, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.End, + alignItems:ItemAlign.End, + alignContent: FlexAlign.End, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex2') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent:SpaceBetween').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceBetween, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('100%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('100%').height(20).backgroundColor(0xD2B48C) + Text('3').width('100%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex3') + .height(100) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent AND alignContent').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceEvenly, + alignContent: FlexAlign.SpaceEvenly, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex4') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent AND alignContent').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceAround, + alignContent: FlexAlign.SpaceAround, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex5') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + }.width('100%').margin({ top: 5 }) + }.width('100%') + } +} diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/GridContainer.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/GridContainer.ets new file mode 100644 index 0000000000000000000000000000000000000000..57358110413406263e70a2a5f650cbfeb22a4387 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/GridContainer.ets @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct gridContainer { + @State sizeType: SizeType = SizeType.XS + @State active: boolean = false + private content: string = "GridContainer Page" + + onPageShow() { + console.info('GridContainer page show called'); + } + + onBuildDone() { + console.info('GridContainer page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Scroll() { + Column({ space: 5 }) { + GridContainer({ columns: 12, sizeType: this.sizeType, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer') + .width('90%') + .alignItems(HorizontalAlign.Start) + + Text('Click Simulate to change the device width').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() { + Button('XS') + .onClick(() => { + this.sizeType = SizeType.XS + }).backgroundColor(0x317aff) + Button('SM') + .onClick(() => { + this.sizeType = SizeType.SM + }).backgroundColor(0x317aff) + Button('MD') + .onClick(() => { + this.sizeType = SizeType.MD + }).backgroundColor(0x317aff) + Button('LG') + .onClick(() => { + this.sizeType = SizeType.LG + }).backgroundColor(0x317aff) + } + + GridContainer({ columns: "auto", sizeType: SizeType.MD, gutter: '10', margin: '20' }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer1') + .width('90%') + .alignItems(HorizontalAlign.Center) + + GridContainer({ columns: 12, sizeType: SizeType.SM, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer2') + .width('90%') + .alignItems(HorizontalAlign.End) + + GridContainer({ columns: 12, sizeType: SizeType.LG, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer3') + .width('90%') + .alignItems(HorizontalAlign.End) + + GridContainer({ columns: 12, sizeType: SizeType.Auto, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer4') + .width('90%') + .alignItems(HorizontalAlign.End) + + }.width('100%').margin({ top: 5 }) + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Image.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Image.ets new file mode 100644 index 0000000000000000000000000000000000000000..5cc583e931f51aa8e4f2bd55decfeeb14a40afb4 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Image.ets @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct image_textcase { + @State Width: number = 0 + @State height: number = 0 + + onPageShow() { + console.info('Image page show called'); + } + + onBuildDone() { + console.info('Image page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Image page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Image("/resources/rawfile/hand.png") + .matchTextDirection(false) + .fitOriginalSize(false) + .fillColor(0xCCCCCC) + .objectFit(ImageFit.Cover) + .objectRepeat(ImageRepeat.NoRepeat) + .interpolation(ImageInterpolation.None) + .renderMode(ImageRenderMode.Original) + .autoResize(false) + .syncLoad(false) + .sourceSize({ width: 200, height: 100 }) + .alt("/resources/rawfile/person.png") + .key('image1') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.Contain) + .objectRepeat(ImageRepeat.X) + .interpolation(ImageInterpolation.High) + .renderMode(ImageRenderMode.Template) + .key('image2') + .height(180) + .width(180) + .onComplete((msg: { + width: number, + height: number + }) => { + this.Width = msg.width + this.height = msg.height + console.info('Width ----' + this.Width) + console.info('height ----' + this.height) + }) + .onError(() => { + console.info('load image fail') + }) + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.Fill) + .objectRepeat(ImageRepeat.Y) + .interpolation(ImageInterpolation.Low) + .key('image3') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.None) + .objectRepeat(ImageRepeat.XY) + .interpolation(ImageInterpolation.Medium) + .key('image4') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.ScaleDown) + .key('image5') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(4) + } + } +} + + diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Navigator.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Navigator.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c50769cf2ab045cbe48b52e294b4105a21e1c3d --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Navigator.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct navigator_testcase { + @State active: boolean = false + @State params: Object = { text: 'news' } + + onPageShow() { + console.info('Navigator page show called'); + } + + onBuildDone() { + console.info('Navigator page build done called'); + } + + build() { + Column() { + Navigator({ target: "pages/index", type: NavigationType.Back }) { + Text('Navigator test in Navigator,back') + }.active(this.active) + .key('navigator') + .params({ + data: 24 + }) + + Navigator({ target: "pages/index", type: NavigationType.Push }) { + Text('Navigator test in Navigator,push') + }.active(this.active) + .key('navigator2') + .params({ + data: 24 + }) + + Navigator({ target: "pages/index", type: NavigationType.Replace }) { + Text('Navigator test in Navigator,replace') + }.active(this.active) + .key('navigator3') + .params({ + data: 24 + }) + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } +} diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Panel.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Panel.ets new file mode 100644 index 0000000000000000000000000000000000000000..32ddabbd1ccbae3805dd462e6f04b28364d6a1e7 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Panel.ets @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct PanelExample { + @State show: boolean = true + + onPageShow() { + console.info('Panel page show called'); + } + + onBuildDone() { + console.info('Panel page build done called'); + } + + build() { + Column() { + Text('2021-09-30 Today Calendar: 1.afternoon......Click for details') + .width('90%') + .height(50) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + .padding({ left: 20 }) + .onClick(() => { + this.show = !this.show + }) + Panel(this.show) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel') + .type(PanelType.Foldable) + .mode(PanelMode.Half) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + Panel(this.show) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel2') + .type(PanelType.Minibar) + .mode(PanelMode.Mini) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + Panel(false) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel3') + .type(PanelType.Temporary) + .mode(PanelMode.Full) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + }.width('100%').height('50%').backgroundColor(0xDCDCDC).padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Progress.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Progress.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8608089fe51e1988fd305fc49db028b6c2efe76 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Progress.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct progress_testcase { + onPageShow() { + console.info('Progress page show called'); + } + + onBuildDone() { + console.info('Progress page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Progress page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Progress({ value: 20, total: 40, style: ProgressStyle.Linear }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress') + + Progress({ value: 20, total: 40, style: ProgressStyle.Eclipse }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress2') + + Progress({ value: 20, total: 40, style: ProgressStyle.Ring }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress3') + + Progress({ value: 20, total: 40, style: ProgressStyle.ScaleRing }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress4') + + Progress({ value: 20, total: 40, style: ProgressStyle.Capsule }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress5') + + } + .width(400) + .height(400) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Qrcode.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Qrcode.ets new file mode 100644 index 0000000000000000000000000000000000000000..5c0dd84eff5a6653ee5fd940662d141025a1bb4e --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Qrcode.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct qrcode_textcase { + @State Color: Color = Color.Pink + + onPageShow() { + console.info('Qrcode page show called'); + } + + onBuildDone() { + console.info('Qrcode page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`Qrcode page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + QRCode('hello world') + .color("#FFFFC0CB") + .backgroundColor(this.Color) + .width("200") + .height("100") + .key('qrcode') + } + } +} + + diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Rating.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Rating.ets new file mode 100644 index 0000000000000000000000000000000000000000..b29e26a392fca6f15a5b7f0eb4156dd3bc767c3f --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Rating.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct rating_testcase { + @State rating: number = 2 + + onPageShow() { + console.info('Rating page show called'); + } + + onBuildDone() { + console.info('Rating page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Rating page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Rating({ rating: 2, indicator: false }) + .stepSize(0.5) + .stars(5) + .starStyle({ + backgroundUri: '/resources/rawfile/star-1-1.png', + foregroundUri: '/resources/rawfile/star-1-3.png', + secondaryUri: '/resources/rawfile/star-1-2.png' + }) + .onChange((value: number) => { + this.rating = value + }) + .key('rating1') + Rating({ rating: 2, indicator: true }) + .stepSize(0.5) + .stars(5) + .starStyle({ + backgroundUri: '/resources/rawfile/star-1-1.png', + foregroundUri: '/resources/rawfile/star-1-3.png', + secondaryUri: '/resources/rawfile/star-1-2.png' + }) + .key('rating2') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/RowSplit.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/RowSplit.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f4f397b13b83e98ac643633309b02858f337eb0 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/RowSplit.ets @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct rowSplit_testcase { + @State resizeable: boolean = false + private content: string = "rowSplit Page"; + + onPageShow() { + console.info('RowSplit page show called'); + } + + onBuildDone() { + console.info('RowSplit page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + RowSplit() { + Column() { + Text('Demo1.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + + Column() { + Text('Demo2.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + } + .height(100) + .key('rowSplit') + .resizeable(this.resizeable) + .onClick(() => { + router.back() + }) + + RowSplit() { + Column() { + Text('Demo3.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + + Column() { + Text('Demo4.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + }.height(100) + .key('rowSplit1') + .resizeable(true) + } + .key('flex') + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Scroll.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Scroll.ets new file mode 100644 index 0000000000000000000000000000000000000000..363089d22580febed16b983d8a4b2877cde52bec --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Scroll.ets @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct scroll_testcase { + @State scrollBarWidth: number = 20 + @State scrollable: ScrollDirection = ScrollDirection.None + @State scrollBarColor: Color = Color.Pink + @State scrollBar: BarState= BarState.On + private value1: Array = [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30] + @State edge: Edge= Edge.Top + private content: string = "Scroll Page"; + scroller: Scroller = new Scroller(); + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Scroll(this.scroller) { + Column() { + ForEach( + this.value1, + item => { + Text(`${item}`) + .fontSize(15) + .width(400) + .margin(10) + .height(70) + .backgroundColor(0xfff5deb3) + }, + item => item + ) + } + } + .scrollable(ScrollDirection.Vertical) + .scrollBar(this.scrollBar) + .scrollBarColor(this.scrollBarColor) + .scrollBarWidth(this.scrollBarWidth) + .key('scroll') + .width(400) + .height(200) + .onScroll((xOffset: number, yOffset: number) => { + console.info(` current offset is ${xOffset} ${yOffset}`) + }) + .onScrollEnd(() => { + console.info(` now on scroll end`) + }) + .onScrollEdge((side: Edge) => { + console.info(`To the edge`) + }) + Scroll() { + Row() { + Text('scroll uppppp') + .width(60) + .height(100) + .backgroundColor(Color.Yellow) + .margin({ + right: 5, + left: 5 + }) + .key('text') + + Text('scroll to') + .width(60) + .height(100) + .backgroundColor(Color.Green) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollTo({ + xOffset: 100, + yOffset: 100, + }) + }) + Text('scroll page') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollPage({ + next: true + }) + }) + Text('scroll Edge') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollEdge(Edge.Top) + }) + Text('scroll Edge') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.currentOffset() + }) + Text('scroll to index') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollToIndex(0) + console.info(` now on scroll end`) + }) + } + } + .key('scroll1') + .height(100) + .scrollable(ScrollDirection.Horizontal) + + Scroll() { + Column() { + Text("start").fontSize(30) + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + } + } + .padding(10) + .scrollable(ScrollDirection.None) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Red) + .scrollBarWidth(5) + .width(300) + .height(200) + .key('scroll2') + + Scroll() { + Column() { + Text("start").fontSize(30) + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + } + } + .padding(10) + .scrollable(ScrollDirection.Free) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Red) + .scrollBarWidth(5) + .width(300) + .height(200) + .key('scroll3') + } + .key('flex') + + } +} diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Slider.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Slider.ets new file mode 100644 index 0000000000000000000000000000000000000000..625cd02874f16e9debb7638322624f890e08fa62 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Slider.ets @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct slider { + @State inSetValue: number= 40 + @State outSetValue: number= 40 + @State direction: Axis= Axis.Horizontal + @State Begin: number = SliderChangeMode.Begin + + onPageShow() { + console.info('Slider page show called'); + } + + onBuildDone() { + console.info('Slider page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Slider page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Slider({ + value: this.outSetValue, + min: 0, + max: 100, + step: 1, + direction: Axis.Horizontal, + reverse: false, + style: SliderStyle.OutSet + }) + .blockColor('#FFFF0000') + .selectedColor('#FF0000FF') + .trackColor('#FF808080') + .minLabel('10') + .maxLabel('10') + .showTips(false) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + this.outSetValue = value + this.Begin = mode + console.info('value: ' + value + '---mode: ' + mode) + }) + .width("100") + .height("100") + .key('slider1') + Slider({ + value: 40, + min: 0, + max: 100, + step: 1, + style: SliderStyle.InSet + }) + .blockColor(Color.Red) + .selectedColor(Color.Blue) + .trackColor(Color.Gray) + .showTips(true) + .showSteps(true) + .key('slider2') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Span.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Span.ets new file mode 100644 index 0000000000000000000000000000000000000000..df5a71043f1ae000b822646f6b56df7ae103fa1f --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Span.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct span_textcase { + + onPageShow() { + console.info('Span page show called'); + } + + onBuildDone() { + console.info('Span page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text() { + Span('Test Span demo') + .decoration({ type: TextDecorationType.LineThrough, "color": Color.Red }) + .textCase(TextCase.UpperCase) + .fontColor(Color.Blue) + .fontSize("20fp") + .letterSpacing(5) + .fontFamily("sans-serif") + .fontWeight(FontWeight.Bold) + .fontStyle(FontStyle.Italic) + .key('span1') + Span('The second test Span demo') + .textCase(TextCase.LowerCase) + .fontColor(Color.Black) + .letterSpacing('5') + .fontSize(30) + .key('span2') + Span('The third test Span demo') + .textCase(TextCase.Normal) + .fontColor(Color.Yellow) + .fontSize("30fp") + .key('span3') + } + } + .width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(4) + } + } +} + + + diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Stack.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Stack.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a694889f0e768afbd3e3af6a17c3af9d8738cfb --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Stack.ets @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct stack_testcase { + @State alignContent: Alignment = Alignment.Bottom + private content: string = "Stack Page"; + + onPageShow() { + console.info('Stack page show called'); + } + + onBuildDone() { + console.info('Stack page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Stack({ alignContent: this.alignContent }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + } + .width('100%') + .height(80) + .margin({ top: 5 }) + .key('stack') + .onClick(() => { + router.back() + }) + + Stack({ alignContent: Alignment.BottomStart }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack1') + + Stack({ alignContent: Alignment.BottomEnd }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack2') + + Stack({ alignContent: Alignment.Start }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack3') + + Stack({ alignContent: Alignment.Center }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack4') + + Stack({ alignContent: Alignment.End }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack5') + + Stack({ alignContent: Alignment.Top }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack6') + + Stack({ alignContent: Alignment.TopStart }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack7') + + Stack({ alignContent: Alignment.TopEnd }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack8') + } + .key('flex') + .width('100%') + .height('100%') + + } +} + diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Text.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Text.ets new file mode 100644 index 0000000000000000000000000000000000000000..fbd1415dc815b0f1966476c430f7d69e28e587ee --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/Text.ets @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2021 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. + */ + +// @ts-nocheck +import router from '@system.router' + +var paramInfo = router.getParams() +console.info("cd paramInfo" + JSON.stringify(paramInfo)) + +@Entry +@Component +struct text_textcase { + @State textAlign: TextAlign= TextAlign.End + @State lineHeight: string= '15fp' + @State overflow: TextOverflow = TextOverflow.Ellipsis + @State textOverflow: textOverflow<{ "overflow": TextOverflow }> = { "overflow": this.overflow } + @State maxLines: number = 2 + @State baselineOffset: number = 0 + @State textCase: TextCase= TextCase.Normal + @State decoration: decoration<{ + type: TextDecorationType, + color: Color + }> = { type: TextDecorationType.Underline, color: Color.Red } + @State color: Color = Color.Red + @State width: string= "200" + @State height: string= "100" + @State size: size = { width: 200, height: 100 } + @State marginBottom: string = "10px" + @State marginTop: string = "10px" + @State marginLeft: string = "10px" + @State marginRingt: string= "10px" + @State paddingBottom: string= "5" + @State paddingTop: string= "5" + @State paddingLeft: string= "5" + @State paddingRingt: string= "5" + @State constraintSize: constraintSize = { minWidth: 20, maxWidth: 200, minHeight: 0, maxHeight: 50 } + @State layoutPriority: string= "9px" + @State layoutWeight: string = "10px" + @State align: Alignment = Alignment.Center + @State direction: Direction = Direction.Auto + @State position: position<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State markAnchor: markAnchor<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State offset: offset<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State flexGrow: number = 5 + @State flexShrink: number = 2 + @State flexBasis: number = 0 + @State alignSelf: ItemAlign = ItemAlign.Auto + @State borderStyle: BorderStyle = BorderStyle.Dashed + @State borderRadius: number = 10 + @State borderWidth: string= "4px" + @State borderColor: Color= Color.Blue + @State backgroundColor: Color = Color.Pink + @State backgroundImageSize: ImageSize = ImageSize.Cover + @State backgroundImagePosition: Alignment= Alignment.Center + @State opacity: number= 1 + @State visibility: Visibility= Visibility.Visible + @State enabled: boolean = false + @State zIndex: number = 1 + @State fontStyle: FontStyle = FontStyle.Italic + @State fontSize: number = 15 + @State minFontSize: number = 15 + @State maxFontSize: number = 15 + @State letterSpacing: number= 10 + @State fontWeight: FontWeight= FontWeight.Bold + @State fontColor: Color= Color.Black + @State active: boolean = false + private content: string = "Text Page"; + + onPageShow() { + console.info('Text page show called'); + } + + onBuildDone() { + console.info('Text page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .width(this.width) + .height(this.height) + .padding({ bottom: this.paddingBottom, top: this.paddingTop, right: this.paddingRingt, left: this.paddingLeft }) + .margin({ bottom: this.marginBottom, top: this.marginTop, right: this.marginRingt, left: this.marginLeft }) + .constraintSize(this.constraintSize) + .layoutWeight(this.layoutWeight) + .align(this.align) + .direction(this.direction) + .position(this.position) + .markAnchor(this.markAnchor) + .offset(this.offset) + .flexBasis(this.flexBasis) + .flexGrow(this.flexGrow) + .flexShrink(this.flexShrink) + .alignSelf(this.alignSelf) + .borderStyle(this.borderStyle) + .borderRadius(this.borderRadius) + .borderWidth(this.borderWidth) + .borderColor(this.borderColor) + .backgroundColor(this.backgroundColor) + .opacity(this.opacity) + .visibility(this.visibility) + .enabled(this.enabled) + .zIndex(this.zIndex) + .fontColor(this.fontColor) + .fontSize(this.fontSize) + .minFontSize(this.minFontSize) + .letterSpacing(this.letterSpacing) + .maxFontSize(this.maxFontSize) + .fontWeight(this.fontWeight) + .fontStyle(this.fontStyle) + .fontFamily("sans-serif") + .textAlign(this.textAlign) + .textOverflow(this.textOverflow) + .lineHeight(this.lineHeight) + .baselineOffset(this.baselineOffset) + .maxLines(2) + .textCase(this.textCase) + .decoration(this.decoration) + .aspectRatio(1) + .fontColor(Color.Black) + .key('Text') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .size({ width: 100, height: 50 }) + .padding({ bottom: 5, top: 5, right: 5, left: 10 }) + .margin({ bottom: 15, top: 10, right: 10, left: 10 }) + .fontSize('13') + .textAlign(TextAlign.Start) + .align(Alignment.Start) + .direction(Direction.Ltr) + .alignSelf(ItemAlign.Start) + .borderStyle(BorderStyle.Dotted) + .borderWidth(2) + .visibility(Visibility.Hidden) + .enabled(true) + .fontWeight(FontWeight.Normal) + .textAlign(TextAlign.Start) + .textOverflow(TextOverflow.Clip) + .maxLines(2) + .textCase(TextCase.LowerCase) + .decoration({ "type": TextDecorationType.LineThrough, "color": Color.Red }) + .fontColor(Color.White) + .key('Text1') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .width('100%') + .textAlign(TextAlign.Center) + .align(Alignment.TopEnd) + .direction(Direction.Rtl) + .alignSelf(ItemAlign.Center) + .borderStyle(BorderStyle.Solid) + .borderWidth(2) + .visibility(Visibility.None) + .fontWeight(FontWeight.Bolder) + .textAlign(TextAlign.Center) + .textOverflow(TextOverflow.None) + .textCase(TextCase.UpperCase) + .decoration({ "type": TextDecorationType.None, "color": Color.Red }) + .fontColor(Color.Blue) + .key('Text2') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.Top) + .alignSelf(ItemAlign.End) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Lighter) + .decoration({ type: TextDecorationType.Overline, color: Color.Red }) + .fontColor(Color.Gray) + .key('Text3') + Text('Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.TopStart) + .alignSelf(ItemAlign.Baseline) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Medium) + .fontColor(Color.Brown) + .key('Text4') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.End) + .alignSelf(ItemAlign.Stretch) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Regular) + .fontColor(Color.Grey) + .key('Text5') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.BottomEnd) + .width('100%') + .fontColor(Color.Orange) + .key('Text6') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.Bottom) + .width('100%') + .fontColor(Color.Yellow) + .key('Text7') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.BottomStart) + .width('100%') + .key('Text8') + + } + .key('flex') + .width('100%') + .height('100%') + } +} + + diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/index.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..10359134da915c9b44b0836ba4881bca71f43f33 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,65 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 file from '@system.file'; + +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; +import testsuite from "../test/List.test.ets"; +import featureAbility from "@ohos.ability.featureAbility"; + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + Want.parameters['timeout'] = 100000 + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('ACE ETS TEST') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionJsunit.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b538fa17b0e9ea3621574b498cc70958bd0aa25e --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionJsunit.test.ets @@ -0,0 +1,1002 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, it, expect} from "deccjsunit/index.ets"; +import connection from '@ohos.net.connection' +import utils from './Utils.ets' + +export default function connectionJsunit() { + describe('connectionTest', function () { + const TIMEOUT = 100; + const NETID_IVVALID = 99; + const NETID_IVVALID2 = 0; + console.log("************* connection Test start*************"); + + /* + * @tc.number : Telephony_Connection_Connection_createNetConnection_0100 + * @tc.name : createNetConnection + * @tc.desc : Create a network connection with optional netSpefifier and timeout. + */ + it('Telephony_Connection_Connection_createNetConnection_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_createNetConnection_0100 Test start*************"); + try { + connection.createNetConnection(5000); + expect(true).assertTrue(); + } catch (error) { + expect().assertFail(); + } + console.log("************* Telephony_Connection_Connection_createNetConnection_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_createNetConnection_0200 + * @tc.name : createNetConnection + * @tc.desc : Create a network connection with optional netSpefifier and timeout. + */ + it('Telephony_Connection_Connection_createNetConnection_0200', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_createNetConnection_0200 Test start*************"); + try { + connection.createNetConnection(3000); + expect(true).assertTrue(); + } catch (error) { + expect().assertFail(); + } + console.log("************* Telephony_Connection_Connection_createNetConnection_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_createNetConnection_0300 + * @tc.name : createNetConnection + * @tc.desc : Create a network connection with optional netSpefifier and timeout. + */ + it('Telephony_Connection_Connection_createNetConnection_0300', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_createNetConnection_0300 Test start*************"); + try { + connection.createNetConnection(8000); + expect(true).assertTrue(); + } catch (error) { + expect().assertFail(); + } + console.log("************* Telephony_Connection_Connection_createNetConnection_0300 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_createNetConnection_0400 + * @tc.name : createNetConnection + * @tc.desc : Create a network connection with optional netSpefifier and timeout. + */ + it('Telephony_Connection_Connection_createNetConnection_0400', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_createNetConnection_0400 Test start*************"); + try { + let netSpecifier = { + netCapabilities: { + linkUpBandwidthKbps: 1000, + linkDownBandwidthKbps: 2000, + bearerTypes: [1], + networkCap: [0], + }, bearerPrivateIdentifier: '123' + } + connection.createNetConnection(netSpecifier, 5000); + expect(true).assertTrue(); + } catch (error) { + expect().assertFail(); + } + console.log("************* Telephony_Connection_Connection_createNetConnection_0400 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_createNetConnection_0500 + * @tc.name : createNetConnection + * @tc.desc : Create a network connection with optional netSpefifier and timeout. + */ + it('Telephony_Connection_Connection_createNetConnection_0500', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_createNetConnection_0500 Test start*************"); + try { + let netSpecifier = { + netCapabilities: { + linkUpBandwidthKbps: 0, + linkDownBandwidthKbps: 0, + bearerTypes: [0], + networkCap: [0], + }, bearerPrivateIdentifier: '123' + } + connection.createNetConnection(netSpecifier, 5000); + expect(true).assertTrue(); + } catch (error) { + expect().assertFail(); + } + console.log("************* Telephony_Connection_Connection_createNetConnection_0500 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_getDefaultNet_0100 + * @tc.name : getDefaultNet + * @tc.desc : Obtains the data network that is activated by default. + */ + it('Telephony_Connection_Connection_getDefaultNet_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getDefaultNet_0100 Test start*************"); + connection.getDefaultNet((error, data) => { + expect().assertFail(); + done(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Connection_Connection_getDefaultNet_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_getDefaultNet_0200 + * @tc.name : getDefaultNet + * @tc.desc : Obtains the data network that is activated by default. + */ + it('Telephony_Connection_Connection_getDefaultNet_0200', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getDefaultNet_0200 Test start*************"); + connection.getDefaultNet().then(data => { + console.log("Telephony_Connection_Connection_getDefaultNet_0200 getDefaultNet success, case fail"); + expect().assertFail(); + }).catch(err => { + console.log("Telephony_Connection_Connection_getDefaultNet_0200 getDefaultNet error, case success"); + expect(true).assertTrue(); + }); + console.log("************* Telephony_Connection_Connection_getDefaultNet_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_getAllNets_0100 + * @tc.name : getAllNets + * @tc.desc : Obtains the list of data networks that are activated. + */ + it('Telephony_Connection_Connection_getAllNets_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getAllNets_0100 Test start*************"); + connection.getAllNets((error, data) => { + if (error) { + expect(true).assertTrue(); + return; + } + expect().assertFail(); + }); + done(); + console.log("************* Telephony_Connection_Connection_getAllNets_0100 Test end*************"); + }); + + /* + * @tc.number : Telephony_Connection_Connection_getAllNets_0200 + * @tc.name : getAllNets + * @tc.desc : Obtains the list of data networks that are activated. + */ + it('Telephony_Connection_Connection_getAllNets_0200', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getAllNets_0200 Test start*************"); + connection.getAllNets().then(data => { + expect(true).assertTrue(); + }).catch(err => { + console.log("Telephony_Connection_Connection_getAllNets_0200 getAllNets error "); + expect().assertFail(); + }); + done(); + console.log("************* Telephony_Connection_Connection_getAllNets_0200 Test end*************"); + }); + + /* + * @tc.number : Telephony_Connection_Connection_getConnectionProperties_0100 + * @tc.name : getConnectionProperties + * @tc.desc : Queries the connection properties of a network. + */ + it('Telephony_Connection_Connection_getConnectionProperties_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getConnectionProperties_0100 Test start*************"); + connection.getConnectionProperties((error, data) => { + expect().assertFail(); + done(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Connection_Connection_getConnectionProperties_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_getConnectionProperties_0200 + * @tc.name : getConnectionProperties + * @tc.desc : Queries the connection properties of a network. + */ + it('Telephony_Connection_Connection_getConnectionProperties_0200', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getConnectionProperties_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + connection.getConnectionProperties().then(data => { + expect().assertFail(); + }).catch(err => { + expect(true).assertTrue(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Connection_Connection_getConnectionProperties_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_getConnectionProperties_0300 + * @tc.name : getConnectionProperties + * @tc.desc : Queries the connection properties of a network. + */ + it('Telephony_Connection_Connection_getConnectionProperties_0300', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getConnectionProperties_0300 Test start*************"); + var handle = new connection.NetHandle(NETID_IVVALID); + connection.getConnectionProperties(handle, (error, data) => { + if (error) { + expect(true).assertTrue(); + } + }); + console.log("************* Telephony_Connection_Connection_getConnectionProperties_0300 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_getConnectionProperties_0400 + * @tc.name : getConnectionProperties + * @tc.desc : Queries the connection properties of a network. + */ + it('Telephony_Connection_Connection_getConnectionProperties_0400', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getConnectionProperties_0400 Test start*************"); + connection.getAllNets((error, value) => { + if (error) { + expect().assertFail(); + done(); + return; + } else { + connection.getConnectionProperties(value[0], (error, value_2) => { + if (!error) { + console.log(`Telephony_Connection_Connection_getConnectionProperties_0400 get value success: ${JSON.stringify(value_2)}`); + } + }); + } + }); + expect(true).assertTrue(); + done(); + console.log("************* Telephony_Connection_Connection_getConnectionProperties_0400 Test end*************"); + }); + + /* + * @tc.number : Telephony_Connection_Connection_getNetCapabilities_0100 + * @tc.name : getNetCapabilities + * @tc.desc : Obtains {@link NetCapabilities} of a {@link NetHandle} object. + */ + it('Telephony_Connection_Connection_getNetCapabilities_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getNetCapabilities_0100 Test start*************"); + connection.getNetCapabilities((error, data) => { + expect().assertFail(); + done(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Connection_Connection_getNetCapabilities_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_getNetCapabilities_0200 + * @tc.name : getNetCapabilities + * @tc.desc : Obtains {@link NetCapabilities} of a {@link NetHandle} object. + */ + it('Telephony_Connection_Connection_getNetCapabilities_0200', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getNetCapabilities_0200 Test start*************"); + var handle = new connection.NetHandle(NETID_IVVALID); + connection.getNetCapabilities(handle, (error, data) => { + if (!error) { + expect().assertFail(); + done(); + return; + } + }); + expect(true).assertTrue(); + console.log("************* Telephony_Connection_Connection_getNetCapabilities_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_getNetCapabilities_0300 + * @tc.name : getNetCapabilities + * @tc.desc : Obtains {@link NetCapabilities} of a {@link NetHandle} object. + */ + it('Telephony_Connection_Connection_getNetCapabilities_0300', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getNetCapabilities_0300 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + connection.getNetCapabilities().then(data => { + expect().assertFail(); + }).catch(err => { + expect(true).assertTrue(); + }); + console.log("************* Telephony_Connection_Connection_getNetCapabilities_0300 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_getNetCapabilities_0400 + * @tc.name : getNetCapabilities + * @tc.desc : Obtains {@link NetCapabilities} of a {@link NetHandle} object. + */ + it('Telephony_Connection_Connection_getNetCapabilities_0400', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getNetCapabilities_0400 Test start*************"); + let caseName = 'Telephony_Connection_Connection_getNetCapabilities_0400'; + connection.getAllNets((error, value) => { + if (error) { + console.log(`${caseName} get data fail: ${error}`); + expect().assertFail(); + done(); + return; + } else { + console.log(`getAllNets netID value : ${JSON.stringify(value[0].netId)}`); + connection.getNetCapabilities(value[0], (error, data) => { + if (error) { + console.log(`${caseName} get ID fail: ${error}`); + expect().assertFail(); + done(); + } else { + console.log(`${caseName} get value success: ${JSON.stringify(data)}`); + console.log(`${caseName} get value success123456: ${JSON.stringify(data.netCaps_)}`); + console.log(`${caseName} get value success122222: ${JSON.stringify(data.netCaps_[0].netCap)}`); + expect(data.netCaps_[0].netCap != "").assertTrue(); + done(); + } + }); + } + }); + console.log("************* Telephony_Connection_Connection_getNetCapabilities_0400 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_hasDefaultNet_0100 + * @tc.name : hasDefaultNet + * @tc.desc : Checks whether the default data network is activated. + */ + it('Telephony_Connection_Connection_hasDefaultNet_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_hasDefaultNet_0100 Test start*************"); + connection.hasDefaultNet((error, data) => { + if (error) { + expect(true).assertTrue(); + done(); + return; + } + expect().assertFail(); + done(); + }); + console.log("************* Telephony_Connection_Connection_hasDefaultNet_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_hasDefaultNet_0200 + * @tc.name : hasDefaultNet + * @tc.desc : Checks whether the default data network is activated. + */ + it('Telephony_Connection_Connection_hasDefaultNet_0200', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_hasDefaultNet_0200 Test start*************"); + connection.hasDefaultNet().then(activated => { + expect().assertFail(); + }).catch(error => { + console.log(`Telephony_Connection_Connection_hasDefaultNet_0200 hasDefaultNet error,case success,error:${ + toString(error)}`); + expect(true).assertTrue(); + }) + console.log("************* Telephony_Connection_Connection_hasDefaultNet_0200 Test end*************"); + done(); + }); + + + /* + * @tc.number : Telephony_Connection_Connection_enableAirplaneMode_0100 + * @tc.name : enableAirplaneMode + * @tc.desc : Enables the airplane mode for a device. + */ + it('Telephony_Connection_Connection_enableAirplaneMode_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_enableAirplaneMode_0100 Test start*************"); + connection.enableAirplaneMode((error, data) => { + if (error) { + expect(true).assertTrue(); + done(); + return; + } + expect().assertFail(); + done(); + }); + console.log("************* Telephony_Connection_Connection_enableAirplaneMode_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_enableAirplaneMode_0200 + * @tc.name : enableAirplaneMode + * @tc.desc : Enables the airplane mode for a device. + */ + it('Telephony_Connection_Connection_enableAirplaneMode_0200', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_enableAirplaneMode_0200 Test start*************"); + connection.enableAirplaneMode().then(data => { + expect(true).assertTrue(); + }).catch(err => { + expect().assertFail(); + }); + console.log("************* Telephony_Connection_Connection_enableAirplaneMode_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_disableAirplaneMode_0100 + * @tc.name : disableAirplaneMode + * @tc.desc : Disables the airplane mode for a device. + */ + it('Telephony_Connection_Connection_disableAirplaneMode_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_disableAirplaneMode_0100 Test start*************"); + connection.disableAirplaneMode((error, data) => { + if (error) { + expect(true).assertTrue(); + done(); + return; + } + expect().assertFail(); + done(); + }); + console.log("************* Telephony_Connection_Connection_disableAirplaneMode_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_disableAirplaneMode_0200 + * @tc.name : disableAirplaneMode + * @tc.desc : Disables the airplane mode for a device. + */ + it('Telephony_Connection_Connection_disableAirplaneMode_0200', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_reportNetConnected_0200 Test start*************"); + connection.disableAirplaneMode().then(data => { + expect(true).assertTrue(); + }).catch(err => { + expect().assertFail(); + }); + console.log("************* Telephony_Connection_Connection_disableAirplaneMode_0200 Test end*************"); + done(); + }); + + + /* + * @tc.number : Telephony_Connection_Connection_reportNetConnected_0100 + * @tc.name : reportNetConnected + * @tc.desc : Reports the network state is connected. + */ + it('Telephony_Connection_Connection_reportNetConnected_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_reportNetConnected_0100 Test start*************"); + connection.reportNetConnected((error, data) => { + if (error) { + expect(true).assertTrue(); + done(); + return; + } + expect().assertFail(); + done(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Connection_Connection_reportNetConnected_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_reportNetConnected_0200 + * @tc.name : reportNetConnected + * @tc.desc : Reports the network state is connected. + */ + it('Telephony_Connection_Connection_reportNetConnected_0200', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_reportNetConnected_0200 Test start*************"); + var handle = new connection.NetHandle(NETID_IVVALID); + connection.reportNetConnected(handle, (error, data) => { + if (error) { + expect(true).assertTrue(); + done(); + return; + } + expect().assertFail(); + done(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Connection_Connection_reportNetConnected_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_reportNetConnected_0300 + * @tc.name : reportNetConnected + * @tc.desc : Reports the network state is connected. + */ + it('Telephony_Connection_Connection_reportNetConnected_0300', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_reportNetConnected_0300 Test start*************"); + var handle = new connection.NetHandle(NETID_IVVALID2); + connection.reportNetConnected(handle).then(() => { + expect().assertFail(); + }).catch(err => { + expect(true).assertTrue(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Connection_Connection_reportNetConnected_0300 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_reportNetConnected_0400 + * @tc.name : reportNetConnected + * @tc.desc : Reports the network state is connected. + */ + it('Telephony_Connection_Connection_reportNetConnected_0400', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_reportNetConnected_0400 Test start*************"); + var handle = new connection.NetHandle(NETID_IVVALID); + connection.reportNetConnected(handle).then(() => { + expect().assertFail(); + }).catch(err => { + expect(true).assertTrue(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Connection_Connection_reportNetConnected_0400 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_reportNetDisconnected_0100 + * @tc.name : reportNetDisconnected + * @tc.desc : Reports the network state is disconnected. + */ + it('Telephony_Connection_Connection_reportNetDisconnected_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_reportNetDisconnected_0100 Test start*************"); + connection.reportNetDisconnected((error, data) => { + if (error) { + expect(true).assertTrue(); + done(); + return; + } + expect().assertFail(); + done(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Connection_Connection_reportNetDisconnected_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_reportNetDisconnected_0200 + * @tc.name : reportNetDisconnected + * @tc.desc : Reports the network state is disconnected. + */ + it('Telephony_Connection_Connection_reportNetDisconnected_0200', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_reportNetDisconnected_0200 Test start*************"); + var handle = new connection.NetHandle(NETID_IVVALID); + connection.reportNetDisconnected(handle, (error, data) => { + if (error) { + expect(true).assertTrue(); + done(); + return; + } + expect().assertFail(); + done(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Connection_Connection_reportNetDisconnected_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_reportNetDisconnected_0300 + * @tc.name : reportNetDisconnected + * @tc.desc : Reports the network state is disconnected. + */ + it('Telephony_Connection_Connection_reportNetDisconnected_0300', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_reportNetDisconnected_0300 Test start*************"); + var handle = new connection.NetHandle(NETID_IVVALID2); + connection.reportNetDisconnected(handle).then(() => { + expect().assertFail(); + }).catch(err => { + expect(true).assertTrue(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Connection_Connection_reportNetDisconnected_0300 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_reportNetDisconnected_0400 + * @tc.name : reportNetDisconnected + * @tc.desc : Reports the network state is disconnected. + */ + it('Telephony_Connection_Connection_reportNetDisconnected_0400', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_reportNetDisconnected_0400 Test start*************"); + var handle = new connection.NetHandle(NETID_IVVALID); + connection.reportNetDisconnected(handle).then(() => { + expect().assertFail(); + }).catch(err => { + expect(true).assertTrue(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Connection_Connection_reportNetDisconnected_0400 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_getAddressesByName_0100 + * @tc.name : getAddressesByName + * @tc.desc : Resolves the host name to obtain all IP addresses based on the default data network. + */ + it('Telephony_Connection_Connection_getAddressesByName_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getAddressesByName_0100 Test start*************"); + connection.getAddressesByName('www.test.com', (error, data) => { + if (error) { + expect(true).assertTrue(); + done(); + return; + } + expect().assertFail(); + done(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Connection_Connection_getAddressesByName_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Connection_Connection_getAddressesByName_0200 + * @tc.name : getAddressesByName + * @tc.desc : Resolves the host name to obtain all IP addresses based on the default data network. + */ + it('Telephony_Connection_Connection_getAddressesByName_0200', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getAddressesByName_0200 Test start*************"); + connection.getAddressesByName('www.test.com').then(data => { + expect().assertFail(); + done(); + return; + }).catch(error => { + console.log(`Telephony_Connection_Connection_getAddressesByName_0200 getAddressesByName error,case success,error:${ + toString(error)}`); + expect(true).assertTrue(); + }) + console.log("************* Telephony_Connection_Connection_getAddressesByName_0200 Test end*************"); + done(); + }); + + /** + * @tc.number Telephony_Connection_Connection_netAvailable_0100 + * @tc.name netAvailable + * @tc.desc Function test + */ + it('Telephony_Connection_Connection_netAvailable_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_netAvailable_0100 Test start*************"); + try { + let netConn = connection.createNetConnection(); + netConn.on('netAvailable', (error, value) => { + if (error) { + console.log(`netAvailable error: ${error}`); + } + }); + } catch (error) { + expect().assertFail(); + } + expect(true).assertTrue(); + done(); + console.log("************* Telephony_Connection_Connection_netAvailable_0100 Test end*************"); + }) + + /** + * @tc.number Telephony_Connection_Connection_netBlockStatusChange_0100 + * @tc.name netBlockStatusChange + * @tc.desc Function test + */ + it('Telephony_Connection_Connection_netBlockStatusChange_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_netBlockStatusChange_0100 Test start*************"); + try { + let netConn = connection.createNetConnection(); + netConn.on('netBlockStatusChange', (error, value) => { + if (error) { + console.log(`netBlockStatusChange error: ${error}`); + } + }); + } catch (error) { + expect().assertFail(); + } + expect(true).assertTrue(); + done(); + console.log("************* Telephony_Connection_Connection_netBlockStatusChange_0100 Test end*************"); + }) + + /** + * @tc.number Telephony_Connection_Connection_netCapabilitiesChange_0100 + * @tc.name netCapabilitiesChange + * @tc.desc Function test + */ + it('Telephony_Connection_Connection_netCapabilitiesChange_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_netCapabilitiesChange_0100 Test start*************"); + try { + let netConn = connection.createNetConnection(); + netConn.on('netCapabilitiesChange', (error, value) => { + if (error) { + console.log(`netCapabilitiesChange error: ${error}`); + } + }); + } catch (error) { + expect().assertFail(); + } + expect(true).assertTrue(); + done(); + console.log("************* Telephony_Connection_Connection_netCapabilitiesChange_0100 Test end*************"); + }) + + /** + * @tc.number Telephony_Connection_Connection_netConnectionPropertiesChange_0100 + * @tc.name netConnectionPropertiesChange + * @tc.desc Function test + */ + it('Telephony_Connection_Connection_netConnectionPropertiesChange_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_netConnectionPropertiesChange_0100 Test start*************"); + try { + let netConn = connection.createNetConnection(); + netConn.on('netConnectionPropertiesChange', (error, value) => { + if (error) { + console.log(`netConnectionPropertiesChange error: ${error}`); + } + }); + } catch (error) { + expect().assertFail(); + } + expect(true).assertTrue(); + done(); + console.log("************* Telephony_Connection_Connection_netConnectionPropertiesChange_0100 Test end*************"); + }) + + /** + * @tc.number Telephony_Connection_Connection_netLost_0100 + * @tc.name netLost + * @tc.desc Function test + */ + it('Telephony_Connection_Connection_netLost_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_netLost_0100 Test start*************"); + try { + let netConn = connection.createNetConnection(); + netConn.on('netLost', (error, value) => { + if (error) { + console.log(`netLost error: ${error}`); + } + }); + } catch (error) { + expect().assertFail(); + } + expect(true).assertTrue(); + done(); + console.log("************* Telephony_Connection_Connection_netLost_0100 Test end*************"); + }) + + /** + * @tc.number Telephony_Connection_Connection_netUnavailable_0100 + * @tc.name netUnavailable + * @tc.desc Function test + */ + it('Telephony_Connection_Connection_netUnavailable_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_netUnavailable_0100 Test start*************"); + try { + let netConn = connection.createNetConnection(); + netConn.on('netUnavailable', (error, value) => { + if (error) { + console.log(`netUnavailable error: ${error}`); + } + }); + } catch (error) { + expect().assertFail(); + } + expect(true).assertTrue(); + done(); + console.log("************* Telephony_Connection_Connection_netUnavailable_0100 Test end*************"); + }) + + /** + * @tc.number Telephony_Connection_Connection_NetSpecifier_0100 + * @tc.name NetSpecifier + * @tc.desc netCapabilities bearerPrivateIdentifier test + */ + it('Telephony_Connection_Connection_NetSpecifier_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_NetSpecifier_0100 Test start*************"); + try { + let netSpecifier = { + netCapabilities: { + linkUpBandwidthKbps: 1, + linkDownBandwidthKbps: 2, + bearerTypes: [0], + networkCap: [11], + }, bearerPrivateIdentifier: '123' + } + connection.createNetConnection(netSpecifier, TIMEOUT); + } catch (error) { + expect().assertFail(); + } + expect(true).assertTrue(); + done(); + console.log("************* Telephony_Connection_Connection_NetSpecifier_0100 Test end*************"); + }) + + /** + * @tc.number Telephony_Connection_Connection_bindSocket_0100 + * @tc.name bindSocket + * @tc.desc Function test + */ + it('Telephony_Connection_Connection_bindSocket_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_bindSocket_0100 Test start*************"); + connection.getDefaultNet().then((handle) => { + handle.bindSocket(1, (error, value) => { + if (error) { + expect().assertFail(); + done(); + } + }); + }).catch((error) => { + expect(true).assertTrue(); + }); + done(); + console.log("************* Telephony_Connection_Connection_bindSocket_0100 Test end*************"); + }) + + /** + * @tc.number Telephony_Connection_Connection_NetHandle_getAddressesByName_0100 + * @tc.name getAddressesByName + * @tc.desc Function test + */ + it('Telephony_Connection_Connection_NetHandle_getAddressesByName_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_NetHandle_getAddressesByName_0100 Test start*************"); + connection.getDefaultNet().then((handle) => { + handle.getAddressesByName(addressBaidu, (error, value) => { + if (error) { + expect().assertFail(); + done(); + } + }); + }).catch((error) => { + expect(true).assertTrue(); + }); + done(); + console.log("************* Telephony_Connection_Connection_NetHandle_getAddressesByName_0100 Test end*************"); + }) + + /** + * @tc.number Telephony_Connection_Connection_getAddressByName_0100 + * @tc.name getAddressByName + * @tc.desc Function test + */ + it('Telephony_Connection_Connection_getAddressByName_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_getAddressByName_0100 Test start*************"); + connection.getDefaultNet().then((handle) => { + handle.getAddressByName(addressBaidu, (error, value) => { + if (error) { + expect().assertFail(); + } + done(); + }); + }).catch((error) => { + expect(true).assertTrue(); + }); + done(); + console.log("************* Telephony_Connection_Connection_getAddressByName_0100 Test end*************"); + }) + + /** + * @tc.number Telephony_Connection_Connection_linkUpBandwidthKbps_0100 + * @tc.name linkUpBandwidthKbps + * @tc.desc linkUpBandwidthKbps test + */ + it('Telephony_Connection_Connection_linkUpBandwidthKbps_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_linkUpBandwidthKbps_0100 Test start*************"); + try { + let netSpecifier = { + netCapabilities: { + linkUpBandwidthKbps: 10, + linkDownBandwidthKbps: 22, + bearerTypes: [0], + networkCap: [11], + }, bearerPrivateIdentifier: '456' + } + connection.createNetConnection(netSpecifier, TIMEOUT); + } catch (error) { + expect().assertFail(); + } + expect(true).assertTrue(); + done(); + console.log("************* Telephony_Connection_Connection_linkUpBandwidthKbps_0100 Test end*************"); + }) + + /** + * @tc.number Telephony_Connection_Connection_linkDownBandwidthKbps_0100 + * @tc.name linkDownBandwidthKbps + * @tc.desc nlinkDownBandwidthKbps test + */ + it('Telephony_Connection_Connection_linkDownBandwidthKbps_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_linkDownBandwidthKbps_0100 Test start*************"); + try { + let netSpecifier = { + netCapabilities: { + linkUpBandwidthKbps: 44, + linkDownBandwidthKbps: 55, + bearerTypes: [1], + networkCap: [12], + }, bearerPrivateIdentifier: '789' + } + connection.createNetConnection(netSpecifier, TIMEOUT); + } catch (error) { + expect().assertFail(); + } + expect(true).assertTrue(); + done(); + console.log("************* Telephony_Connection_Connection_linkDownBandwidthKbps_0100 Test end*************"); + }) + + /** + * @tc.number Telephony_Connection_Connection_networkCap_0100 + * @tc.name networkCap + * @tc.desc networkCap test + */ + it('Telephony_Connection_Connection_networkCap_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_networkCap_0100 Test start*************"); + try { + let netSpecifier = { + netCapabilities: { + linkUpBandwidthKbps: 18, + linkDownBandwidthKbps: 29, + bearerTypes: [3], + networkCap: [5], + }, bearerPrivateIdentifier: '321' + } + connection.createNetConnection(netSpecifier, TIMEOUT); + } catch (error) { + expect().assertFail(); + } + expect(true).assertTrue(); + done(); + console.log("************* Telephony_Connection_Connection_networkCap_0100 Test end*************"); + }) + + /** + * @tc.number Telephony_Connection_Connection_bearerTypes_0100 + * @tc.name bearerTypes + * @tc.desc bearerTypes test + */ + it('Telephony_Connection_Connection_bearerTypes_0100', 0, async function (done) { + console.log("************* Telephony_Connection_Connection_bearerTypes_0100 Test start*************"); + try { + let netSpecifier = { + netCapabilities: { + linkUpBandwidthKbps: 41, + linkDownBandwidthKbps: 62, + bearerTypes: [1], + networkCap: [9], + }, bearerPrivateIdentifier: '876' + } + connection.createNetConnection(netSpecifier, TIMEOUT); + } catch (error) { + expect().assertFail(); + } + expect(true).assertTrue(); + done(); + console.log("************* Telephony_Connection_Connection_bearerTypes_0100 Test end*************"); + }) + + console.log("************* connection Test end*************"); + }) +} diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionSecondJsUnit.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionSecondJsUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5c621bb8c22046f8832e713da10a71b3c36e4d3e --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/ConnectionSecondJsUnit.test.ets @@ -0,0 +1,431 @@ +// @ts-nocheck +/* + * Copyright (C) 2021 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 connection from '@ohos.net.connection'; +import {describe, it, expect} from 'deccjsunit/index'; +import utils from './Utils.ets' + +export default function connectionSecondJsUnit() { + describe("connectionSecondJsunit", function () { + /** + * @tc.name: Telephony_connection_ConnectionProperties_0100 + * @tc.desc: ConnectionProperties Properties detection + * @tc.author: kangyuntao + */ + it("Telephony_connection_ConnectionProperties_0100", 0, function (done) { + console.log("-----------------------Telephony ConnectionProperties Test is starting-----------------------"); + let caseName = 'Telephony_connection_ConnectionProperties_0100'; + try { + let resultLinkAddresses = { + linkAddresses: [{ + address: { + address: "192.168.1.2" + } + }] + }; + let resultDnses = { + dnses: [{ + address: "192.168.1.3" + }] + }; + let resultRoutes = { + routes: [{ + gateway: { + address: "192.168.1.1" + } + }] + }; + let resultName = { + interfaceName: '123' + }; + let resultMtu = { + mtu: 123 + }; + console.log(caseName + ` resultLinkAddresses.linkAddresses.length: ` + resultLinkAddresses.linkAddresses.length); + console.log(caseName + ` resultDnses.dnses.length: ` + resultDnses.dnses.length); + console.log(caseName + ` resultRoutes.routes.length: ` + resultRoutes.routes.length); + expect(resultLinkAddresses.linkAddresses.length > 0).assertTrue(); + expect(resultDnses.dnses.length > 0).assertTrue(); + expect(resultRoutes.routes.length > 0).assertTrue(); + expect("123").assertEqual(resultName.interfaceName); + expect(123).assertEqual(resultMtu.mtu); + console.log("-----------------------Telephony ConnectionProperties Test end-----------------------"); + done(); + } catch (err) { + console.log(`Telephony_ConnectionProperties_0100 err ` + err); + } + }) + + /** + * @tc.name: 'Telephony_connection_getConnectionProperties_Async_0200 + * @tc.desc: getConnectionProperties detection + * @tc.author: kangyuntao + */ + it('Telephony_connection_getConnectionProperties_Async_0200', 0, async function (done) { + console.log("-----------------------Telephony getConnectionProperties Test is starting-----------------------"); + if(utils.notCheck){ + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_connection_getConnectionProperties_Async_0200'; + connection.getAllNets((error, value) => { + if (error) { + console.log(`${caseName} get data fail: ${error}`); + expect().assertFail(); + done(); + return; + } else { + console.log(`${caseName} get netID value : ${JSON.stringify(value[0])}`); + connection.getConnectionProperties(value[0], (error, value) => { + if (error) { + console.log(`${caseName} get ID fail: ${error}`); + expect().assertFail(); + done(); + } else { + console.log(`${caseName} get value success: ${JSON.stringify(value)}`); + console.log(caseName + " ifaceName: " + value.ifaceName); + console.log(caseName + " mtu: " + value.mtu); + console.log(caseName + " netAddrList.length: " + value.netAddrList.length); + expect(value.ifaceName == "").assertTrue(); + expect(value.domain == "").assertTrue(); + expect(value.mtu == 0).assertTrue(); + expect(value.netAddrList.length == 0).assertTrue(); + expect(value.dnsList.length == 0).assertTrue(); + expect(value.routeList.length == 0).assertTrue(); + done(); + } + }); + } + }); + console.log("-----------------------Telephony getConnectionProperties Test end-----------------------"); + }); + + /** + * @tc.name: Telephony_connection_RouteInfo_0300 + * @tc.desc: RouteInfo Properties detection + * @tc.author: kangyuntao + */ + it("Telephony_connection_RouteInfo_0300", 0, async function (done) { + console.log("----------------------RouteInfo Properties Test is starting-----------------------"); + try { + let resultDefaultRoute = { + isDefaultRoute: true + }; + let resultHasGateway = { + hasGateway: true + }; + expect(true).assertEqual(resultDefaultRoute.isDefaultRoute); + expect(true).assertEqual(resultHasGateway.hasGateway); + console.log("-----------------------RouteInfo Properties Test end-----------------------"); + done(); + } catch (err) { + console.log(`Telephony_connection_RouteInfo_0300 err ` + err); + } + }) + + /** + * @tc.name: 'Telephony_connection_getRouteInfo_Async_0400 + * @tc.desc: getRouteInfo Properties detection + * @tc.author: kangyuntao + */ + it('Telephony_connection_getRouteInfo_Async_0400', 0, async function (done) { + console.log("-----------------------Telephony getRouteInfo Test is starting-----------------------"); + let caseName = 'Telephony_connection_getRouteInfo_Async_0400'; + connection.getAllNets((error, value) => { + if (error) { + console.log(`${caseName} get data fail: ${error}`); + expect().assertFail(); + done(); + return; + } else { + console.log(`${caseName} get netID value : ${JSON.stringify(value[0])}`); + connection.getConnectionProperties(value[0], (error, value) => { + if (error) { + console.log(`${caseName} get ID fail: ${error}`); + expect().assertFail(); + done(); + } else { + console.log(`${caseName} get value success: ${JSON.stringify(value)}`); + console.log(caseName + " value.routeList.length: " + value.routeList.length); + if (value.routeList.length > 0) { + expect(value.routeList[0].hasGateway).assertTrue(); + expect(value.routeList[0].isDefaultRoute).assertTrue(); + } + done(); + } + }); + } + }); + console.log("----------------------Telephony getRouteInfo Test end-----------------------"); + }); + + + /** + * @tc.name: Telephony_connection_LinkAddress_0500 + * @tc.desc: LinkAddress Properties detection + * @tc.author: kangyuntao + */ + it("Telephony_connection_LinkAddress_0500", 0, async function (done) { + console.log("----------------------LinkAddress Properties Test is starting-----------------------"); + try { + let resultPrefixLength = { + prefixLength: 10 + }; + expect(10).assertEqual(resultPrefixLength.prefixLength); + console.log("-----------------------LinkAddress Properties Test end-----------------------"); + done(); + } catch (err) { + console.log(`Telephony_connection_LinkAddress_0500 err ` + err); + } + }) + + /** + * @tc.name: Telephony_connection_getLinkAddress_Async_0600 + * @tc.desc: getLinkAddress Properties detection + * @tc.author: kangyuntao + */ + it('Telephony_connection_getLinkAddress_Async_0600', 0, async function (done) { + console.log("-----------------------Telephony getLinkAddress Test is starting-----------------------"); + let caseName = 'Telephony_connection_getLinkAddress_Async_0600'; + connection.getAllNets((error, value) => { + if (error) { + console.log(`${caseName} get data fail: ${error}`); + expect().assertFail(); + done(); + return; + } else { + console.log(`${caseName} get netID value : ${JSON.stringify(value[0])}`); + connection.getConnectionProperties(value[0], (error, value) => { + if (error) { + console.log(`${caseName} get ID fail: ${error}`); + expect().assertFail(); + done(); + } else { + console.log(`${caseName} get value success: ${JSON.stringify(value)}`); + console.log(caseName + " value.dnsList.length: " + value.dnsList.length); + if (value.dnsList.length > 0) { + expect(value.dnsList[0].prefixLength != 0).assertTrue(); + } + done(); + } + }); + } + }); + console.log("-----------------------Telephony getLinkAddress Test end-----------------------"); + }); + + /** + * @tc.name: Telephony_connection_NetAddress_0700 + * @tc.desc: NetAddress Properties detection + * @tc.author: kangyuntao + */ + it("Telephony_connection_NetAddress_0700", 0, async function (done) { + console.log("----------------------NetAddress Properties Test is starting-----------------------"); + try { + let resultPort = { + port: 23 + }; + expect(23).assertEqual(resultPort.port); + console.log("-----------------------NetAddress Properties Test end-----------------------"); + done(); + } catch (err) { + console.log(`"Telephony_connection_NetAddress_0700 err ` + err); + } + }) + + /** + * @tc.name: Telephony_connection_getNetAddress_Async_0800 + * @tc.desc: getNetAddress Properties detection + * @tc.author: kangyuntao + */ + it('Telephony_connection_getNetAddress_Async_0800', 0, async function (done) { + console.log("-----------------------Telephony getNetAddress Test is starting-----------------------"); + let caseName = 'Telephony_connection_getNetAddress_Async_0800'; + connection.getAllNets((error, value) => { + if (error) { + console.log(`${caseName} get data fail: ${error}`); + expect().assertFail(); + done(); + return; + } else { + console.log(`${caseName} get netID value : ${JSON.stringify(value[0])}`); + connection.getConnectionProperties(value[0], (error, value) => { + if (error) { + console.log(`${caseName} get ID fail: ${error}`); + expect().assertFail(); + done(); + } else { + console.log(`${caseName} get value success: ${JSON.stringify(value)}`); + console.log(caseName + 'value.netAddrList.length:' + value.netAddrList.length); + if (value.netAddrList.length > 0) { + expect(value.netAddrList[0].port != 0).assertTrue(); + } + done(); + } + }); + } + }); + console.log("-----------------------Telephony getNetAddress Test end-----------------------"); + }); + + /** + * @tc.name: Telephony_connection_NetCap_0900 + * @tc.desc: NetCap Properties detection + * @tc.author: kangyuntao + */ + it("Telephony_connection_NetCap_0900", 0, async function (done) { + console.log("-----------------------Telephony NetCap Properties Test is starting-----------------------"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + try { + console.log("Telephony_connection_NetCap_0900 NetCap: " + connection.NetCap); + expect(0).assertEqual(connection.NetCap.NET_CAPABILITY_MMS); + expect(11).assertEqual(connection.NetCap.NET_CAPABILITY_NOT_METERED); + expect(12).assertEqual(connection.NetCap.NET_CAPABILITY_INTERNET); + expect(15).assertEqual(connection.NetCap.NET_CAPABILITY_NOT_VPN); + expect(16).assertEqual(connection.NetCap.NET_CAPABILITY_VALIDATED); + console.log("-----------------------Telephony NetCap Properties Test end-----------------------"); + done(); + } catch (err) { + console.log(`Telephony_connection_NetCap_0900 err ` + err); + } + }) + + /** + * @tc.name: Telephony_connection_getNetCap_Async_1000 + * @tc.desc: getNetCap Properties detection + * @tc.author: kangyuntao + */ + it('Telephony_connection_getNetCap_Async_1000', 0, async function (done) { + console.log("-----------------------Telephony getNetCap Test is starting-----------------------"); + let caseName = 'Telephony_connection_getNetCap_Async_1000'; + connection.getAllNets((error, value) => { + if (error) { + console.log(`${caseName} get data fail: ${error}`); + expect().assertFail(); + done(); + return; + } else { + console.log(`Telephony_connection getAllNets netID value : ${JSON.stringify(value[0].netId)}`); + connection.getNetCapabilities(value[0], (error, data) => { + if (error) { + console.log(`${caseName} get ID fail: ${error}`); + expect().assertFail(); + done(); + } else { + console.log(`${caseName} get value success: ${JSON.stringify(data)}`); + console.log(`${caseName} get value successNetCap: ${JSON.stringify(data.netCaps_[0].netCap)}`); + expect(data.netCaps_[0].netCap != "").assertTrue(); + done(); + } + }); + } + }); + console.log("-----------------------Telephony getNetCap Test is end-----------------------"); + }); + + /** + * @tc.name: Telephony_connection_NetBearType_1100 + * @tc.desc: NetBearType Properties detection + * @tc.author: kangyuntao + */ + it("Telephony_connection_NetBearType_1100", 0, async function (done) { + console.log("-----------------------Telephony NetBearType Properties Test is starting-----------------------"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + try { + console.log("Telephony_connection_NetBearType_1100 NetBearType: " + connection.NetBearType); + expect(0).assertEqual(connection.NetBearType.BEARER_CELLULAR); + expect(1).assertEqual(connection.NetBearType.BEARER_WIFI); + expect(3).assertEqual(connection.NetBearType.BEARER_ETHERNET); + console.log("-----------------------Telephony NetBearType Properties Test end-----------------------"); + done(); + } catch (err) { + console.log(`Telephony_connection_NetBearType_1100 err ` + err); + } + }) + + /** + * @tc.name: Telephony_connection_getNetBearType_Async_1200 + * @tc.desc:getNetBearType Properties detection + * @tc.author: kangyuntao + */ + it('Telephony_connection_getNetBearType_Async_1200', 0, async function (done) { + console.log("-----------------------Telephony getNetBearType Test is starting-----------------------"); + let caseName = 'Telephony_connection_getNetBearType_Async_1200'; + connection.getAllNets((error, value) => { + if (error) { + console.log(`${caseName} get data fail: ${error}`); + expect().assertFail(); + done(); + return; + } else { + console.log(`Telephony_connection getAllNets netID value : ${JSON.stringify(value[0].netId)}`); + connection.getNetCapabilities(value[0], (error, data) => { + if (error) { + console.log(`${caseName} get ID fail: ${error}`); + expect().assertFail(); + done(); + } else { + console.log(`${caseName} get value success: ${JSON.stringify(data)}`); + console.log(`${caseName} get value success122222: ${JSON.stringify(data.bearerTypes_[0].bearerType)}`); + expect(data.bearerTypes_[0].bearerType != "").assertTrue(); + done(); + } + }); + } + }); + console.log("-----------------------Telephony getNetBearType Test is end-----------------------"); + }); + + /** + * @tc.name: Telephony_connection_getNetCapabilities_Promise_1300 + * @tc.desc: getNetCapabilities NetCap and NetBearType Properties detection + * @tc.author: kangyuntao + */ + it('Telephony_connection_getNetCapabilities_Promise_1300', 0, async function (done) { + console.log("-----------------------Telephony getNetCapabilities Promise Test is starting-----------------------"); + let caseName = 'Telephony_connection_getNetCapabilities_Promise_1300'; + connection.getAllNets().then((handle) => { + connection.getNetCapabilities(handle[0]).then((data) => { + console.log(`${caseName} getNetCapabilities promiss data suceess: ${JSON.stringify(data)}`); + console.log(`${caseName} get value successNetCap: ${JSON.stringify(data.netCaps_[0].netCap)}`); + console.log(`${caseName} get value successNearerTypes: ${JSON.stringify(data.bearerTypes_[0].bearerType)}`); + expect(data.netCaps_[0].netCap != "").assertTrue(); + expect(data.bearerTypes_[0].bearerType != "").assertTrue(); + console.log("-----------------------Telephony getNetCapabilities Promise Test is end-----------------------"); + done(); + }).catch((error) => { + console.log(`${caseName} getNetCapabilities promiss fail: ${error}`); + expect().assertFail(); + done(); + }); + }).catch((error) => { + console.log(`${caseName} getAllNets promiss error: ${error}`); + expect().assertFail(); + done(); + }); + }); + }) + +} + diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/List.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..eed2cac75eddbcd64829b41b76be646eb592e0f3 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2021 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. + */ + +//other import +import connectionJsunit from './ConnectionJsunit.test.ets'; +import socketJsunit from './SocketJsunit.test.ets'; +import webSocketJsunit from './WebSocketJsunit.test.ets'; +import connectionSecondJsUnit from './ConnectionSecondJsUnit.test.ets'; + +export default function testsuite() { + //other + socketJsunit(); + webSocketJsunit(); + connectionJsunit(); + connectionSecondJsUnit(); +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/SocketJsunit.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/SocketJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..92e5511993df039965f9f532872f93b533195fe2 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/SocketJsunit.test.ets @@ -0,0 +1,1796 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import socket from '@ohos.net.socket' +import utils from './Utils.ets' + +export default function socketJsunit() { + describe('socketTest', function () { + console.log("************* socket Test start*************"); + + /* + * @tc.number : Telephony_Socket_Socket_constructUDPSocketInstance_0100 + * @tc.name : constructUDPSocketInstance + * @tc.desc : Creates a UDPSocket object. + */ + it('Telephony_Socket_Socket_constructUDPSocketInstance_0100', 0, async function (done) { + console.log("************* Telephony_Socket_Socket_constructUDPSocketInstance_0100 Test start*************"); + var udpSocket = socket.constructUDPSocketInstance(); + expect(udpSocket != null).assertTrue(); + console.log("************* Telephony_Socket_Socket_constructUDPSocketInstance_0100 Test end*************"); + done(); + }) + + /* + * @tc.number : Telephony_Socket_Socket_constructTCPSocketInstance_0100 + * @tc.name : constructTCPSocketInstance + * @tc.desc : Creates a TCPSocket object. + */ + it('Telephony_Socket_Socket_constructTCPSocketInstance_0100', 0, async function (done) { + console.log("************* Telephony_Socket_Socket_constructTCPSocketInstance_0100 Test start*************"); + var tcpSocket = socket.constructTCPSocketInstance(); + expect(tcpSocket != null).assertTrue(); + console.log("************* Telephony_Socket_Socket_constructTCPSocketInstance_0100 Test end*************"); + done(); + }) + + /* + * @tc.number : Telephony_Socket_Socket_NetAddress_0100 + * @tc.name : NetAddress + * @tc.desc : interface NetAddress + */ + it('Telephony_Socket_Socket_NetAddress_0100', 0, async function (done) { + console.log("************* Telephony_Socket_Socket_NetAddress_0100 Test start*************"); + let netAddress: socket.NetAddress = { + address: "test address", + family: 1, + port: 8080 + } + expect(netAddress.address === "test address").assertTrue() + expect(netAddress.family === 1).assertTrue() + expect(netAddress.port === 8080).assertTrue() + console.log("************* Telephony_Socket_Socket_NetAddress_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSendOptions_data_0100 + * @tc.name : UDPSendOptions.data + * @tc.desc : UDPSendOptions.data + */ + it('Telephony_Socket_UDPSendOptions_data_0100', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSendOptions_data_0100 Test start*************"); + let udpSendOptions: socket.UDPSendOptions = { + data: "test data", + address: { + address: "test address", + family: 1, + port: 8080 + } + } + expect(udpSendOptions.data === "test data").assertTrue() + console.log("************* Telephony_Socket_UDPSendOptions_data_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_ExtraOptionsBase_receiveBufferSize_0100 + * @tc.name : ExtraOptionsBase.receiveBufferSize + * @tc.desc : ExtraOptionsBase.receiveBufferSize + */ + it('Telephony_Socket_ExtraOptionsBase_receiveBufferSize_0100', 0, async function (done) { + console.log("************* Telephony_Socket_ExtraOptionsBase_receiveBufferSize_0100 Test start*************"); + let extraOptionsBase: socket.ExtraOptionsBase = { + receiveBufferSize: 1, + sendBufferSize: 1, + reuseAddress: true, + socketTimeout: 5000, + } + expect(extraOptionsBase.receiveBufferSize === 1).assertTrue() + console.log("************* Telephony_Socket_ExtraOptionsBase_receiveBufferSize_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_ExtraOptionsBase_sendBufferSize_0100 + * @tc.name : ExtraOptionsBase.sendBufferSize + * @tc.desc : ExtraOptionsBase.sendBufferSize + */ + it('Telephony_Socket_ExtraOptionsBase_sendBufferSize_0100', 0, async function (done) { + console.log("************* Telephony_Socket_ExtraOptionsBase_sendBufferSize_0100 Test start*************"); + let extraOptionsBase: socket.ExtraOptionsBase = { + receiveBufferSize: 1, + sendBufferSize: 1, + reuseAddress: true, + socketTimeout: 5000, + } + expect(extraOptionsBase.sendBufferSize === 1).assertTrue() + console.log("************* Telephony_Socket_ExtraOptionsBase_sendBufferSize_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_ExtraOptionsBase_reuseAddress_0100 + * @tc.name : ExtraOptionsBase.reuseAddress + * @tc.desc : ExtraOptionsBase.reuseAddress + */ + it('Telephony_Socket_ExtraOptionsBase_reuseAddress_0100', 0, async function (done) { + console.log("************* Telephony_Socket_ExtraOptionsBase_reuseAddress_0100 Test start*************"); + let extraOptionsBase: socket.ExtraOptionsBase = { + receiveBufferSize: 1, + sendBufferSize: 1, + reuseAddress: true, + socketTimeout: 5000, + } + expect(extraOptionsBase.reuseAddress).assertTrue() + console.log("************* Telephony_Socket_ExtraOptionsBase_reuseAddress_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_ExtraOptionsBase_socketTimeout_0100 + * @tc.name : ExtraOptionsBase.socketTimeout + * @tc.desc : ExtraOptionsBase.socketTimeout + */ + it('Telephony_Socket_ExtraOptionsBase_socketTimeout_0100', 0, async function (done) { + console.log("************* Telephony_Socket_ExtraOptionsBase_socketTimeout_0100 Test start*************"); + let extraOptionsBase: socket.ExtraOptionsBase = { + receiveBufferSize: 1, + sendBufferSize: 1, + reuseAddress: true, + socketTimeout: 5000, + } + expect(extraOptionsBase.socketTimeout === 5000).assertTrue() + console.log("************* Telephony_Socket_ExtraOptionsBase_socketTimeout_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_SocketStateBase_isClose_0100 + * @tc.name : SocketStateBase.isClose + * @tc.desc : SocketStateBase.isClose + */ + it('Telephony_Socket_SocketStateBase_isClose_0100', 0, async function (done) { + console.log("************* Telephony_Socket_SocketStateBase_isClose_0100 Test start*************"); + let socketStateBase: socket.SocketStateBase = { + isBound: true, + isClose: true, + isConnected: true + } + expect(socketStateBase.isClose).assertTrue() + console.log("************* Telephony_Socket_SocketStateBase_isClose_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_SocketRemoteInfo_port_0100 + * @tc.name : SocketRemoteInfo.port + * @tc.desc : SocketRemoteInfo.port + */ + it('Telephony_Socket_SocketRemoteInfo_port_0100', 0, async function (done) { + console.log("************* Telephony_Socket_SocketRemoteInfo_port_0100 Test start*************"); + let socketRemoteInfo: socket.SocketRemoteInfo = { + address: "test address", + family: 'IPv4', + port: 8080, + size: 1 + } + expect(socketRemoteInfo.port === 8080).assertTrue() + console.log("************* Telephony_Socket_SocketRemoteInfo_port_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_SocketRemoteInfo_size_0100 + * @tc.name : SocketRemoteInfo.size + * @tc.desc : SocketRemoteInfo.size + */ + it('Telephony_Socket_SocketRemoteInfo_size_0100', 0, async function (done) { + console.log("************* Telephony_Socket_SocketRemoteInfo_size_0100 Test start*************"); + let socketRemoteInfo: socket.SocketRemoteInfo = { + address: "test address", + family: 'IPv4', + port: 8080, + size: 1 + } + expect(socketRemoteInfo.size === 1).assertTrue() + console.log("************* Telephony_Socket_SocketRemoteInfo_size_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPConnectOptions_timeout_0100 + * @tc.name : TCPConnectOptions.timeout + * @tc.desc : TCPConnectOptions.timeout + */ + it('Telephony_Socket_TCPConnectOptions_timeout_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPConnectOptions_timeout_0100 Test start*************"); + let tcpConnectOptions: socket.TCPConnectOptions = { + address: { + address: "test address", + family: 1, + port: 8080 + }, + timeout: 1000 + } + expect(tcpConnectOptions.timeout === 1000).assertTrue() + console.log("************* Telephony_Socket_TCPConnectOptions_timeout_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSendOptions_data_0100 + * @tc.name : TCPSendOptions.data + * @tc.desc : TCPSendOptions.data + */ + it('Telephony_Socket_TCPSendOptions_data_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSendOptions_data_0100 Test start*************"); + let tcpSendOptions: socket.TCPSendOptions = { + data: "test data", + encoding: "test encoding" + } + expect(tcpSendOptions.data === "test data").assertTrue() + console.log("************* Telephony_Socket_TCPSendOptions_data_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSendOptions_encoding_0100 + * @tc.name : TCPSendOptions.encoding + * @tc.desc : TCPSendOptions.encoding + */ + it('Telephony_Socket_TCPSendOptions_encoding_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSendOptions_encoding_0100 Test start*************"); + let tcpSendOptions: socket.TCPSendOptions = { + data: "test data", + encoding: "test encoding" + } + expect(tcpSendOptions.encoding === "test encoding").assertTrue() + console.log("************* Telephony_Socket_TCPSendOptions_encoding_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPExtraOptions_keepAlive_0100 + * @tc.name : TCPExtraOptions.keepAlive + * @tc.desc : TCPExtraOptions.keepAlive + */ + it('Telephony_Socket_TCPExtraOptions_keepAlive_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPExtraOptions_keepAlive_0100 Test start*************"); + let tcpExtraOptions: socket.TCPExtraOptions = { + keepAlive: true, + OOBInline: false, + TCPNoDelay: true, + socketLinger: { + on: true, + linger: false + } + } + expect(tcpExtraOptions.keepAlive).assertTrue() + console.log("************* Telephony_Socket_TCPExtraOptions_keepAlive_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPExtraOptions_OOBInline_0100 + * @tc.name : TCPExtraOptions.OOBInline + * @tc.desc : TCPExtraOptions.OOBInline + */ + it('Telephony_Socket_TCPExtraOptions_OOBInline_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPExtraOptions_OOBInline_0100 Test start*************"); + let tcpExtraOptions: socket.TCPExtraOptions = { + keepAlive: true, + OOBInline: false, + TCPNoDelay: true, + socketLinger: { + on: true, + linger: false + } + } + expect(!tcpExtraOptions.OOBInline).assertTrue() + console.log("************* Telephony_Socket_TCPExtraOptions_OOBInline_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPExtraOptions_TCPNoDelay_0100 + * @tc.name : TCPExtraOptions.TCPNoDelay + * @tc.desc : TCPExtraOptions.TCPNoDelay + */ + it('Telephony_Socket_TCPExtraOptions_TCPNoDelay_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPExtraOptions_TCPNoDelay_0100 Test start*************"); + let tcpExtraOptions: socket.TCPExtraOptions = { + keepAlive: true, + OOBInline: false, + TCPNoDelay: true, + socketLinger: { + on: true, + linger: false + } + } + expect(tcpExtraOptions.TCPNoDelay).assertTrue() + console.log("************* Telephony_Socket_TCPExtraOptions_TCPNoDelay_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPExtraOptions_socketLinger_0100 + * @tc.name : TCPExtraOptions.socketLinger + * @tc.desc : TCPExtraOptions.socketLinger + */ + it('Telephony_Socket_TCPExtraOptions_socketLinger_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPExtraOptions_socketLinger_0100 Test start*************"); + let tcpExtraOptions: socket.TCPExtraOptions = { + keepAlive: true, + OOBInline: false, + TCPNoDelay: true, + socketLinger: { + on: true, + linger: false + } + } + expect(tcpExtraOptions.socketLinger.on).assertTrue() + expect(!tcpExtraOptions.socketLinger.linger).assertTrue() + console.log("************* Telephony_Socket_TCPExtraOptions_socketLinger_0100 Test end*************"); + done(); + }); + + + /* + * @tc.number : Telephony_Socket_UDPSocket_bind_0100 + * @tc.name : bind + * @tc.desc : Binds the IP address and port number. + */ + it('Telephony_Socket_UDPSocket_bind_0100', 0, async function (done) { + let caseName = "Telephony_Socket_UDPSocket_bind_0100" + console.log("************* Telephony_Socket_UDPSocket_bind_0100 Test start*************"); + let netAddress: socket.NetAddress = { + address: "test address", + family: 1, + port: 8080 + } + socket.UDPSocket.bind(netAddress, (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_Socket_UDPSocket_bind_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_bind_0200 + * @tc.name : bind + * @tc.desc : Binds the IP address and port number. + */ + it('Telephony_Socket_UDPSocket_bind_0200', 0, async function (done) { + let caseName = "Telephony_Socket_UDPSocket_bind_0200" + console.log("************* Telephony_Socket_UDPSocket_bind_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let netAddress: socket.NetAddress = { + address: "test address", + family: 1, + port: 8080 + } + try{ + await socket.UDPSocket.bind(netAddress).then(data => { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + }catch(err){ + console.log(`${caseName} failed,catch error:${toString(error)}`); + } + console.log("************* Telephony_Socket_UDPSocket_bind_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_bind_0300 + * @tc.name : bind + * @tc.desc : Binds the IP address and port number. + */ + it('Telephony_Socket_UDPSocket_bind_0300', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_bind_0300 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_bind_0300" + let netAddress: socket.NetAddress = { + address: "second test address" + } + socket.UDPSocket.bind(netAddress, (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_Socket_UDPSocket_bind_0300 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_bind_0400 + * @tc.name : bind + * @tc.desc : Binds the IP address and port number. + */ + it('Telephony_Socket_UDPSocket_bind_0400', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_bind_0400 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_bind_0400" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let netAddress: socket.NetAddress = { + address: "third test address", + family: 3, + port: 8080 + } + socket.UDPSocket.bind(netAddress).then(data => { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + console.log("************* Telephony_Socket_UDPSocket_bind_0400 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_send_0100 + * @tc.name : send + * @tc.desc : Sends data over a UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_send_0100', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_send_0100 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_send_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let udpSendOptions: socket.UDPSendOptions = { + data: "test data", + address: { + address: "test address", + family: 1, + port: 8080 + } + } + socket.UDPSocket.send(udpSendOptions, (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_Socket_UDPSocket_send_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_send_0200 + * @tc.name : send + * @tc.desc : Sends data over a UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_send_0200', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_send_0200 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_send_0200" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let udpSendOptions: socket.UDPSendOptions = { + data: "test data", + address: { + address: "test address", + family: 1, + port: 8080 + } + } + socket.UDPSocket.send(udpSendOptions).then(data => { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + console.log("************* Telephony_Socket_UDPSocket_send_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_send_0300 + * @tc.name : send + * @tc.desc : Sends data over a UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_send_0300', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_send_0300 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_send_0300" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let udpSendOptions: socket.UDPSendOptions = { + data: "test data", + address: { + address: "second test address", + } + } + socket.UDPSocket.send(udpSendOptions, (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_Socket_UDPSocket_send_0300 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_send_0400 + * @tc.name : send + * @tc.desc : Sends data over a UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_send_0400', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_send_0400 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_send_0400" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let udpSendOptions: socket.UDPSendOptions = { + data: "test data", + address: { + address: "third test address" + } + } + socket.UDPSocket.send(udpSendOptions).then(data => { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + console.log("************* Telephony_Socket_UDPSocket_send_0400 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_getState_0100 + * @tc.name : getState + * @tc.desc : Obtains the status of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_getState_0100', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_getState_0100 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_getState_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.getState((error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + let socketStateBase: socket.SocketStateBase = data + console.log(`${caseName} data:${toString(socketStateBase.isClose)}`); + done(); + }) + console.log("************* Telephony_Socket_UDPSocket_getState_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_getState_0200 + * @tc.name : getState + * @tc.desc : Obtains the status of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_getState_0200', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_getState_0200 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_getState_0200" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.getState().then(data => { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + + console.log("************* Telephony_Socket_UDPSocket_getState_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_setExtraOptions_0100 + * @tc.name : setExtraOptions + * @tc.desc : Sets other attributes of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_setExtraOptions_0100', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_setExtraOptions_0100 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_setExtraOptions_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let udpExtraOptions: socket.UDPExtraOptions = { + broadcast: true + } + socket.UDPSocket.setExtraOptions(udpExtraOptions, (error) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + expect(true).assertTrue(); + console.log(`${caseName} error, case failed`); + done(); + }) + console.log("************* Telephony_Socket_UDPSocket_setExtraOptions_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_setExtraOptions_0200 + * @tc.name : setExtraOptions + * @tc.desc : Sets other attributes of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_setExtraOptions_0200', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_setExtraOptions_0200 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_setExtraOptions_0200" + let udpExtraOptions: socket.UDPExtraOptions = { + broadcast: true + } + try { + await socket.UDPSocket.setExtraOptions(udpExtraOptions); + console.log(`${caseName} success`); + done(); + } catch (error) { + console.log(`${caseName} failed,error:${error}`); + done(); + } + console.log("************* Telephony_Socket_UDPSocket_setExtraOptions_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_setExtraOptions_0300 + * @tc.name : setExtraOptions + * @tc.desc : Sets other attributes of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_setExtraOptions_0300', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_setExtraOptions_0300 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_setExtraOptions_0300" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let udpExtraOptions: socket.UDPExtraOptions = {} + socket.UDPSocket.setExtraOptions(udpExtraOptions, (error) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed`); + done(); + }) + console.log("************* Telephony_Socket_UDPSocket_setExtraOptions_0300 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_setExtraOptions_0400 + * @tc.name : setExtraOptions + * @tc.desc : Sets other attributes of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_setExtraOptions_0400', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_setExtraOptions_0400 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_setExtraOptions_0400" + let udpExtraOptions: socket.UDPExtraOptions = {} + try { + await socket.UDPSocket.setExtraOptions(udpExtraOptions); + console.log(`${caseName} success`); + done(); + } catch (error) { + console.log(`${caseName} failed,error:${error}`); + expect(true).assertTrue(); + done(); + } + console.log("************* Telephony_Socket_UDPSocket_setExtraOptions_0400 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_on_message_0100 + * @tc.name : on + * @tc.desc : Listens for message receiving events of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_on_message_0100', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_on_message_0100 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_on_message_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.on('message', (data) => { + let socketRemoteInfo: socket.SocketRemoteInfo = data.remoteInfo; + console.log(`${caseName} port:${socketRemoteInfo.port}`); + console.log(`${caseName} size:${socketRemoteInfo.size}`); + }); + console.log("************* Telephony_Socket_UDPSocket_on_message_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_off_message_0100 + * @tc.name : off + * @tc.desc : Cancels listening for message receiving events of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_off_message_0100', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_off_message_0100 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_off_message_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.off("message", data => { + let socketRemoteInfo: socket.SocketRemoteInfo = data.remoteInfo; + console.log(`${caseName} port:${socketRemoteInfo.port}`); + console.log(`${caseName} size:${socketRemoteInfo.size}`); + }); + console.log("************* Telephony_Socket_UDPSocket_off_message_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_off_message_0200 + * @tc.name : off + * @tc.desc : Cancels listening for message receiving events of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_off_message_0200', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_off_message_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.off("message"); + expect(true).assertTrue(); + console.log("************* Telephony_Socket_UDPSocket_off_message_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_on_listening_0100 + * @tc.name : on + * @tc.desc : Listens for data packet message events or close events of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_on_listening_0100', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_on_listening_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.on("listening", data => { + expect(true).assertTrue(); + }); + console.log("************* Telephony_Socket_UDPSocket_on_listening_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_off_listening_0100 + * @tc.name : off + * @tc.desc : Cancels listening for data packet message events or close events of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_off_listening_0100', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_off_listening_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.off("listening", data => { + expect(true).assertTrue(); + }); + console.log("************* Telephony_Socket_UDPSocket_off_listening_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_off_listening_0200 + * @tc.name : off + * @tc.desc : Cancels listening for data packet message events or close events of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_off_listening_0200', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_off_listening_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.off("listening"); + expect(true).assertTrue(); + console.log("************* Telephony_Socket_UDPSocket_off_listening_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_on_close_0100 + * @tc.name : on + * @tc.desc : Listens for data packet message events or close events of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_on_close_0100', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_on_close_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.on("close", data => { + expect(true).assertTrue(); + }); + console.log("************* Telephony_Socket_UDPSocket_on_close_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_off_close_0100 + * @tc.name : off + * @tc.desc : Cancels listening for data packet message events or close events of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_off_close_0100', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_off_close_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.off("close", data => { + expect(true).assertTrue(); + }); + console.log("************* Telephony_Socket_UDPSocket_off_close_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_off_close_0200 + * @tc.name : off + * @tc.desc : Cancels listening for data packet message events or close events of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_off_close_0200', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_off_close_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.off("close"); + expect(true).assertTrue(); + console.log("************* Telephony_Socket_UDPSocket_off_close_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_on_error_0100 + * @tc.name : on + * @tc.desc : Listens for error events of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_on_error_0100', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_on_error_0100 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_on_error_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.on("error", error => { + console.log(`${caseName} fail, error:${toString(error)}`); + expect().assertFail(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Socket_UDPSocket_on_error_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_off_error_0100 + * @tc.name : off + * @tc.desc : Cancels listening for error events of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_off_error_0100', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_off_error_0100 Test start*************"); + let caseName = "Telephony_Socket_UDPSocket_off_error_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.off("error", error => { + console.log(`${caseName} fail, error:${toString(error)}`); + expect().assertFail(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Socket_UDPSocket_off_error_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_UDPSocket_off_error_0200 + * @tc.name : off + * @tc.desc : Cancels listening for error events of the UDPSocket connection. + */ + it('Telephony_Socket_UDPSocket_off_error_0200', 0, async function (done) { + console.log("************* Telephony_Socket_UDPSocket_off_error_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.UDPSocket.off("error"); + expect(true).assertTrue(); + console.log("************* Telephony_Socket_UDPSocket_off_error_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_bind_0100 + * @tc.name : bind + * @tc.desc : Binds the IP address and port number + */ + it('Telephony_Socket_TCPSocket_bind_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_bind_0100 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_bind_0100" + let netAddress: socket.NetAddress = { + address: "test address", + family: 1, + port: 8080 + } + socket.TCPSocket.bind(netAddress, (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_Socket_TCPSocket_bind_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_bind_0200 + * @tc.name : bind + * @tc.desc : Binds the IP address and port number + */ + it('Telephony_Socket_TCPSocket_bind_0200', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_bind_0200 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_bind_0200" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let netAddress: socket.NetAddress = { + address: "test address", + family: 1, + port: 8080 + } + socket.TCPSocket.bind(netAddress).then(data => { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + console.log("************* Telephony_Socket_TCPSocket_bind_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_bind_0300 + * @tc.name : bind + * @tc.desc : Binds the IP address and port number + */ + it('Telephony_Socket_TCPSocket_bind_0300', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_bind_0300 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_bind_0300" + let netAddress: socket.NetAddress = { + address: "second test address", + } + socket.TCPSocket.bind(netAddress, (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_Socket_TCPSocket_bind_0300 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_bind_0400 + * @tc.name : bind + * @tc.desc : Binds the IP address and port number + */ + it('Telephony_Socket_TCPSocket_bind_0400', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_bind_0400 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_bind_0400" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let netAddress: socket.NetAddress = { + address: "third test address" + } + socket.TCPSocket.bind(netAddress).then(data => { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + console.log("************* Telephony_Socket_TCPSocket_bind_0400 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_send_0100 + * @tc.name : send + * @tc.desc : Sends data over a TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_send_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_send_0100 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_send_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let tcpSendOptions: socket.TCPSendOptions = { + data: "test data", + encoding: "test encoding" + } + socket.TCPSocket.send(tcpSendOptions, (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_Socket_TCPSocket_send_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_send_0200 + * @tc.name : send + * @tc.desc : Sends data over a TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_send_0200', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_send_0200 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_send_0200" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let tcpSendOptions: socket.TCPSendOptions = { + data: "test data", + encoding: "test encoding" + } + socket.TCPSocket.send(tcpSendOptions).then(data => { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + console.log("************* Telephony_Socket_TCPSocket_send_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_send_0300 + * @tc.name : send + * @tc.desc : Sends data over a TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_send_0300', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_send_0300 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_send_0300" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let tcpSendOptions: socket.TCPSendOptions = { + data: "second test data", + } + socket.TCPSocket.send(tcpSendOptions, (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_Socket_TCPSocket_send_0300 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_send_0400 + * @tc.name : send + * @tc.desc : Sends data over a TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_send_0400', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_send_0400 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_send_0400" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let tcpSendOptions: socket.TCPSendOptions = { + data: "second test data", + } + socket.TCPSocket.send(tcpSendOptions).then(data => { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + console.log("************* Telephony_Socket_TCPSocket_send_0400 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_connect_0100 + * @tc.name : connect + * @tc.desc : Sets up a connection to the specified IP address and port number. + */ + it('Telephony_Socket_TCPSocket_connect_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_connect_0100 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_connect_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let tcpConnectOptions: socket.TCPConnectOptions = { + address: { + address: "test address", + family: 1, + port: 8080 + }, + timeout: 1000 + } + socket.TCPSocket.connect(tcpConnectOptions, (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_Socket_TCPSocket_connect_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_connect_0200 + * @tc.name : connect + * @tc.desc : Sets up a connection to the specified IP address and port number. + */ + it('Telephony_Socket_TCPSocket_connect_0200', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_connect_0200 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_connect_0200" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let tcpConnectOptions: socket.TCPConnectOptions = { + address: { + address: "test address", + family: 1, + port: 8080 + }, + timeout: 1000 + } + socket.TCPSocket.connect(tcpConnectOptions).then(function (data) { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + console.log("************* Telephony_Socket_TCPSocket_connect_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_connect_0300 + * @tc.name : connect + * @tc.desc : Sets up a connection to the specified IP address and port number. + */ + it('Telephony_Socket_TCPSocket_connect_0300', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_connect_0300 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_connect_0300" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let tcpConnectOptions: socket.TCPConnectOptions = { + address: { + address: "second test address", + family: 1, + port: 8080 + } + } + socket.TCPSocket.connect(tcpConnectOptions, (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_Socket_TCPSocket_connect_0300 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_connect_0400 + * @tc.name : connect + * @tc.desc : Sets up a connection to the specified IP address and port number. + */ + it('Telephony_Socket_TCPSocket_connect_0200', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_connect_0400 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_connect_0400" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let tcpConnectOptions: socket.TCPConnectOptions = { + address: { + address: "second test address", + family: 1, + port: 8080 + } + } + socket.TCPSocket.connect(tcpConnectOptions).then(function (data) { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + console.log("************* Telephony_Socket_TCPSocket_connect_0400 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_getState_0100 + * @tc.name : getState + * @tc.desc : Obtains the status of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_getState_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_getState_0100 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_getState_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.getState((error, data) => { + if (error) { + console.log(`${caseName} case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_Socket_TCPSocket_getState_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_getState_0200 + * @tc.name : getState + * @tc.desc : Obtains the status of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_getState_0200', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_getState_0200 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_getState_0200" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.getState().then(data => { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + + console.log("************* Telephony_Socket_TCPSocket_getState_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_setExtraOptions_0100 + * @tc.name : setExtraOptions + * @tc.desc : Sets other attributes of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_setExtraOptions_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_setExtraOptions_0100 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_setExtraOptions_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let tcpExtraOptions: socket.TCPExtraOptions = { + keepAlive: true, + OOBInline: true, + TCPNoDelay: true, + socketLinger: { + on: true, + linger: true + } + } + socket.TCPSocket.setExtraOptions(tcpExtraOptions, (error) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed`); + done(); + }) + console.log("************* Telephony_Socket_TCPSocket_setExtraOptions_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_setExtraOptions_0200 + * @tc.name : setExtraOptions + * @tc.desc : Sets other attributes of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_setExtraOptions_0200', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_setExtraOptions_0200 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_setExtraOptions_0200" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let tcpExtraOptions: socket.TCPExtraOptions = { + keepAlive: true, + OOBInline: true, + TCPNoDelay: true, + socketLinger: { + on: true, + linger: true + } + } + try { + await socket.TCPSocket.setExtraOptions(tcpExtraOptions); + console.log(`${caseName} success`); + expect(true).assertTrue(); + done(); + } catch (error) { + console.log(`${caseName} failed,error:${error}`); + done(); + } + console.log("************* Telephony_Socket_TCPSocket_setExtraOptions_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_setExtraOptions_0300 + * @tc.name : setExtraOptions + * @tc.desc : Sets other attributes of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_setExtraOptions_0300', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_setExtraOptions_0300 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_setExtraOptions_0300" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let tcpExtraOptions: socket.TCPExtraOptions = { + socketLinger: { + on: true, + linger: true + } + } + socket.TCPSocket.setExtraOptions(tcpExtraOptions, (error) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed`); + done(); + }) + console.log("************* Telephony_Socket_TCPSocket_setExtraOptions_0300 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_setExtraOptions_0400 + * @tc.name : setExtraOptions + * @tc.desc : Sets other attributes of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_setExtraOptions_0400', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_setExtraOptions_0400 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_setExtraOptions_0400" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let tcpExtraOptions: socket.TCPExtraOptions = { + socketLinger: { + on: true, + linger: true + } + } + try { + await socket.TCPSocket.setExtraOptions(tcpExtraOptions); + console.log(`${caseName} success`); + expect(true).assertTrue(); + done(); + } catch (error) { + console.log(`${caseName} failed,error:${error}`); + done(); + } + console.log("************* Telephony_Socket_TCPSocket_setExtraOptions_0400 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_getRemoteAddress_0100 + * @tc.name : getRemoteAddress + * @tc.desc : Obtains the peer address of a TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_getRemoteAddress_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_getRemoteAddress_0100 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_getRemoteAddress_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.getRemoteAddress((error) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + done(); + }) + console.log("************* Telephony_Socket_TCPSocket_getRemoteAddress_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_getRemoteAddress_0200 + * @tc.name : getRemoteAddress + * @tc.desc : Obtains the peer address of a TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_getRemoteAddress_0200', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_getRemoteAddress_0200 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_getRemoteAddress_0200" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.getRemoteAddress().then(data => { + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }); + console.log("************* Telephony_Socket_TCPSocket_getRemoteAddress_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_on_message_0100 + * @tc.name : on + * @tc.desc : Listens for message receiving events of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_on_message_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_on_message_0100 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_on_message_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.on("message", data => { + let socketRemoteInfo: socket.SocketRemoteInfo = data.remoteInfo; + console.log(`${caseName} port:${socketRemoteInfo.port}`); + console.log(`${caseName} size:${socketRemoteInfo.size}`); + }); + console.log("************* Telephony_Socket_TCPSocket_on_message_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_off_message_0100 + * @tc.name : off + * @tc.desc : Cancels listening for message receiving events of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_off_message_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_off_message_0100 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_off_message_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.off("message", data => { + let socketRemoteInfo: socket.SocketRemoteInfo = data.remoteInfo; + console.log(`${caseName} port:${socketRemoteInfo.port}`); + console.log(`${caseName} size:${socketRemoteInfo.size}`); + }); + console.log("************* Telephony_Socket_TCPSocket_off_message_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_off_message_0200 + * @tc.name : off + * @tc.desc : Cancels listening for message receiving events of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_off_message_0200', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_off_message_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.off("message"); + expect(true).assertTrue(); + console.log("************* Telephony_Socket_TCPSocket_off_message_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_on_connect_0100 + * @tc.name : on + * @tc.desc : Listens for connection or close events of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_on_connect_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_on_connect_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.on("connect", data => { + expect(true).assertTrue(); + }); + console.log("************* Telephony_Socket_TCPSocket_on_connect_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_off_connect_0100 + * @tc.name : off + * @tc.desc : Cancels listening for connection or close events of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_off_connect_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_off_connect_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.off("connect", data => { + expect(true).assertTrue(); + }); + console.log("************* Telephony_Socket_TCPSocket_off_connect_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_off_connect_0200 + * @tc.name : off + * @tc.desc : Cancels listening for connection or close events of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_off_connect_0200', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_off_connect_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.off("connect"); + expect(true).assertTrue(); + console.log("************* Telephony_Socket_TCPSocket_off_connect_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_on_close_0100 + * @tc.name : on + * @tc.desc : Listens for connection or close events of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_on_close_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_on_close_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.on("close", data => { + expect(true).assertTrue(); + }); + console.log("************* Telephony_Socket_TCPSocket_on_close_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_off_close_0100 + * @tc.name : off + * @tc.desc : Cancels listening for connection or close events of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_off_close_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_off_close_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.off("close", data => { + expect(true).assertTrue(); + }); + console.log("************* Telephony_Socket_TCPSocket_off_close_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_off_close_0200 + * @tc.name : off + * @tc.desc : Cancels listening for connection or close events of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_off_close_0200', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_off_close_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.off("close"); + expect(true).assertTrue(); + console.log("************* Telephony_Socket_TCPSocket_off_close_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_on_error_0100 + * @tc.name : on + * @tc.desc : Listens for error events of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_on_error_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_on_error_0100 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_on_error_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.on("error", error => { + console.log(`${caseName} fail, error:${toString(error)}`); + expect().assertFail(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Socket_TCPSocket_on_error_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_off_error_0100 + * @tc.name : off + * @tc.desc : Cancels listening for error events of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_off_error_0100', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_off_error_0100 Test start*************"); + let caseName = "Telephony_Socket_TCPSocket_off_error_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.off("error", error => { + console.log(`${caseName} fail, error:${toString(error)}`); + expect().assertFail(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_Socket_TCPSocket_off_error_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_Socket_TCPSocket_off_error_0200 + * @tc.name : off + * @tc.desc : Cancels listening for error events of the TCPSocket connection. + */ + it('Telephony_Socket_TCPSocket_off_error_0200', 0, async function (done) { + console.log("************* Telephony_Socket_TCPSocket_off_error_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + socket.TCPSocket.off("error"); + expect(true).assertTrue(); + console.log("************* Telephony_Socket_TCPSocket_off_error_0200 Test end*************"); + done(); + }); + + console.log("************* socket Test end*************"); + + }) +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/Utils.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..65f70088ddb62bcf80f4e0ec07dc841a8ab033f0 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,119 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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. + */ + +export default class Utils { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + static notCheck = true; + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } + + static async swipe(downX, downY, upX, upY, steps) { + console.info('start to swipe') + this.drags(downX, downY, upX, upY, steps, false) + } + + static async drag(downX, downY, upX, upY, steps) { + console.info('start to drag') + this.drags(downX, downY, upX, upY, steps, true) + } + + static async drags(downX, downY, upX, upY, steps, drag) { + var xStep; + var yStep; + var swipeSteps; + var ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + var downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('start to move') + if (drag) { + await this.sleep(500) + } + for (var i = 1;i <= swipeSteps; i++) { + var movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('start to up') + if (drag) { + await this.sleep(100) + } + var upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) + } +} + + + + diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/WebSocketJsunit.test.ets b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/WebSocketJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..79008189d96303b6bceca944f2b23a78b9b66a89 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/WebSocketJsunit.test.ets @@ -0,0 +1,515 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import webSocket from '@ohos.net.webSocket' +import utils from './Utils.ets' + +export default function webSocketJsunit() { + describe('webSocketTest', function () { + console.log("************* webSocket Test start*************"); + + /* + * @tc.number : Telephony_WebSocket_WebSocket_createWebSocket_0100 + * @tc.name : createWebSocket + * @tc.desc : Creates a web socket connection. + */ + it('Telephony_WebSocket_WebSocket_createWebSocket_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_createWebSocket_0100 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + var mWebSocket = webSocket.createWebSocket(); + expect(mWebSocket != null).assertTrue(); + console.log("************* Telephony_WebSocket_WebSocket_createWebSocket_0100 Test end*************"); + done(); + }) + + /* + * @tc.number : Telephony_WebSocket_WebSocketRequestOptions_header_0100 + * @tc.name : webSocketRequestOptions.header + * @tc.desc : webSocketRequestOptions.header + */ + it('Telephony_WebSocket_WebSocketRequestOptions_header_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocketRequestOptions_header_0100 Test start*************"); + let webSocketRequestOptions: webSocket.WebSocketRequestOptions = { + header: "test header" + } + expect(webSocketRequestOptions.header === "test header").assertTrue(); + console.log("************* Telephony_WebSocket_WebSocketRequestOptions_header_0100 Test end*************"); + done(); + }) + + /* + * @tc.number : Telephony_WebSocket_WebSocketCloseOptions_code_0100 + * @tc.name : webSocketCloseOptions.code + * @tc.desc : webSocketCloseOptions.code + */ + it('Telephony_WebSocket_WebSocketCloseOptions_code_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocketCloseOptions_code_0100 Test start*************"); + let webSocketCloseOptions: webSocket.WebSocketCloseOptions = { + code: 1 + } + expect(webSocketCloseOptions.code === 1).assertTrue(); + console.log("************* Telephony_WebSocket_WebSocketCloseOptions_code_0100 Test end*************"); + done(); + }) + + /* + * @tc.number : Telephony_WebSocket_WebSocket_connect_0100 + * @tc.name : connect + * @tc.desc : Initiates a WebSocket request to establish a WebSocket connection to a given URL. + */ + it('Telephony_WebSocket_WebSocket_connect_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_connect_0100 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_connect_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.connect({ + url: "www.baidu.com" + }, (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_WebSocket_WebSocket_connect_0100 Test end*************"); + done(); + }) + + /* + * @tc.number : Telephony_WebSocket_WebSocket_connect_0200 + * @tc.name : connect + * @tc.desc : Initiates a WebSocket request to establish a WebSocket connection to a given URL. + */ + it('Telephony_WebSocket_WebSocket_connect_0200', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_connect_0200 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_connect_0200" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let webSocketRequestOptions: webSocket.WebSocketRequestOptions = { + header: "test header" + } + webSocket.connect("www.baidu.com", webSocketRequestOptions, (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_WebSocket_WebSocket_connect_0200 Test end*************"); + done(); + }) + + /* + * @tc.number : Telephony_WebSocket_WebSocket_connect_0300 + * @tc.name : connect + * @tc.desc : Initiates a WebSocket request to establish a WebSocket connection to a given URL. + */ + it('Telephony_WebSocket_WebSocket_connect_0300', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_connect_0300 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_connect_0300" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let webSocketRequestOptions: webSocket.WebSocketRequestOptions = { + header: "test header" + } + webSocket.connect("www.baidu.com", webSocketRequestOptions).then(data => { + expect(true).assertTrue(); + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }) + console.log("************* Telephony_WebSocket_WebSocket_connect_0300 Test end*************"); + done(); + }) + + /* + * @tc.number : Telephony_WebSocket_WebSocket_connect_0400 + * @tc.name : connect + * @tc.desc : Initiates a WebSocket request to establish a WebSocket connection to a given URL. + */ + it('Telephony_WebSocket_WebSocket_connect_0400', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_connect_0400 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_connect_0400" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.connect("www.baidu.com").then(data => { + expect(true).assertTrue(); + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }) + console.log("************* Telephony_WebSocket_WebSocket_connect_0400 Test end*************"); + done(); + }) + + /* + * @tc.number : Telephony_WebSocket_WebSocket_send_0100 + * @tc.name : send + * @tc.desc : Sends data through a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_send_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_send_0100 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_send_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.send("test data", (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }) + console.log("************* Telephony_WebSocket_WebSocket_send_0100 Test end*************"); + done(); + }) + + /* + * @tc.number : Telephony_WebSocket_WebSocket_send_0200 + * @tc.name : send + * @tc.desc : Sends data through a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_send_0200', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_send_0200 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_send_0200" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.send("test data").then(data => { + expect(true).assertTrue(); + console.log(`${caseName} success,data:${toString(data)}`); + }).catch((error) => { + console.log(`${caseName} failed,error:${toString(error)}`); + }) + console.log("************* Telephony_WebSocket_WebSocket_send_0200 Test end*************"); + done(); + }) + + /* + * @tc.number : Telephony_WebSocket_WebSocket_on_open_0100 + * @tc.name : on + * @tc.desc : Enables listening for the open events of a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_on_open_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_on_open_0100 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_on_open_0100" + try{ + webSocket.on("open", (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }); + expect(true).assertTrue(); + done(); + }catch(err){ + expect(true).assertTrue(); + console.log(`${caseName} error, catch error:${toString(err)}`); + done(); + } + console.log("************* Telephony_WebSocket_WebSocket_on_open_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_WebSocket_WebSocket_off_open_0100 + * @tc.name : off + * @tc.desc : Cancels listening for the open events of a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_off_open_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_off_open_0100 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_off_open_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.off("open", (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }); + console.log("************* Telephony_WebSocket_WebSocket_off_open_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_WebSocket_WebSocket_off_open_0200 + * @tc.name : off + * @tc.desc : Cancels listening for the open events of a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_off_open_0200', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_off_open_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.off("open"); + expect(true).assertTrue(); + console.log("************* Telephony_WebSocket_WebSocket_off_open_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_WebSocket_WebSocket_on_message_0100 + * @tc.name : on + * @tc.desc : Enables listening for the message events of a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_on_message_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_on_message_0100 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_on_message_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.on("message", (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }); + console.log("************* Telephony_WebSocket_WebSocket_on_message_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_WebSocket_WebSocket_off_message_0100 + * @tc.name : off + * @tc.desc : Cancels listening for the message events of a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_off_message_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_off_message_0100 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_off_message_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.off("message", (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }); + console.log("************* Telephony_WebSocket_WebSocket_off_message_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_WebSocket_WebSocket_off_message_0200 + * @tc.name : off + * @tc.desc : Cancels listening for the message events of a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_off_message_0200', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_off_message_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.off("message"); + expect(true).assertTrue(); + console.log("************* Telephony_WebSocket_WebSocket_off_message_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_WebSocket_WebSocket_on_close_0100 + * @tc.name : on + * @tc.desc : Enables listening for the close events of a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_on_close_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_on_close_0100 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_on_close_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.on("close", (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }); + console.log("************* Telephony_WebSocket_WebSocket_on_close_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_WebSocket_WebSocket_off_close_0100 + * @tc.name : off + * @tc.desc : Cancels listening for the close events of a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_off_close_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_off_close_0100 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_off_close_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.off("close", (error, data) => { + if (error) { + console.log(`${caseName} error, case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} error, case failed,data:${toString(data)}`); + done(); + }); + console.log("************* Telephony_WebSocket_WebSocket_off_close_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_WebSocket_WebSocket_off_close_0200 + * @tc.name : off + * @tc.desc : Cancels listening for the close events of a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_off_close_0200', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_off_close_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.off("close"); + expect(true).assertTrue(); + console.log("************* Telephony_WebSocket_WebSocket_off_close_0200 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_WebSocket_WebSocket_on_error_0100 + * @tc.name : on + * @tc.desc : Enables listening for the error events of a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_on_error_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_on_error_0100 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_on_error_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.on("error", error => { + console.log(`${caseName} fail, error:${toString(error)}`); + expect().assertFail(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_WebSocket_WebSocket_on_error_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_WebSocket_WebSocket_off_error_0100 + * @tc.name : off + * @tc.desc : Cancels listening for the error events of a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_off_error_0100', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_off_error_0100 Test start*************"); + let caseName = "Telephony_WebSocket_WebSocket_off_error_0100" + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.off("error", error => { + console.log(`${caseName} fail, error:${toString(error)}`); + expect().assertFail(); + }); + expect(true).assertTrue(); + console.log("************* Telephony_WebSocket_WebSocket_off_error_0100 Test end*************"); + done(); + }); + + /* + * @tc.number : Telephony_WebSocket_WebSocket_off_error_0200 + * @tc.name : off + * @tc.desc : Cancels listening for the error events of a WebSocket connection. + */ + it('Telephony_WebSocket_WebSocket_off_error_0200', 0, async function (done) { + console.log("************* Telephony_WebSocket_WebSocket_off_error_0200 Test start*************"); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + webSocket.off("error"); + expect(true).assertTrue(); + console.log("************* Telephony_WebSocket_WebSocket_off_error_0200 Test end*************"); + done(); + }); + + console.log("************* webSocket Test end*************"); + + }) +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/lib/Const.js b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/lib/Const.js new file mode 100644 index 0000000000000000000000000000000000000000..f9263cd46dee1a0ffdfaa1e5ef5c29755c7e13f7 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/ets/MainAbility/test/lib/Const.js @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2021 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. + */ + +// sim slot id +export const DEFAULT_SLOTID = 0; +export const SLOTID3 = 3; +export const SLOTID2 = 2; +export const SLOTID_MINUS1 = -1; + +// sim correct password +export const CORRECT_PIN = '1234'; +export const CORRECT_PIN2 = '18099014'; + +// sim incorrect password +export const INCORRECT_PIN = '134679'; +export const INCORRECT_PIN_LEN3 = '123'; +export const INCORRECT_PUK = '134679'; +export const INCORRECT_PIN2 = '134679'; +export const INCORRECT_PIN2_LEN3 = '123'; +export const INCORRECT_PIN2_LEN9 = '123456789'; +export const INCORRECT_PUK2 = '134679'; + +// lock status response +export const LOCK_RESULT = { SUCCESS: 0, FAILURE: -1, EXCEPTION: -2 }; \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03b8532c53ca563f8ed6b1e21d20ad3f67a68906 --- /dev/null +++ b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/base/media/icon.png b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/hand.png b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/hand.png new file mode 100644 index 0000000000000000000000000000000000000000..9f1fa16ee073093b40920e273502513fa66fa980 Binary files /dev/null and b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/hand.png differ diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/icon.png b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/icon.png differ diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/images.jpg b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/images.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c75ddfc5ead15e8d49ca7cae9f97c03585565be1 Binary files /dev/null and b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/images.jpg differ diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/person.png b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/person.png new file mode 100644 index 0000000000000000000000000000000000000000..f0f540d078e6c0441a763ca2cc375a551d6cf736 Binary files /dev/null and b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/person.png differ diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/star-1-1.png b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/star-1-1.png new file mode 100644 index 0000000000000000000000000000000000000000..990c5e5ad20698c7701faf641bc80eb004a127b7 Binary files /dev/null and b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/star-1-1.png differ diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/star-1-2.png b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/star-1-2.png new file mode 100644 index 0000000000000000000000000000000000000000..450c3dd3ca68bf601bd08e5f41797d376e20d00d Binary files /dev/null and b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/star-1-2.png differ diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/star-1-3.png b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/star-1-3.png new file mode 100644 index 0000000000000000000000000000000000000000..1044869832b423a5dfc2559a395529377bd34f0c Binary files /dev/null and b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/star-1-3.png differ diff --git a/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/video/show.mp4 b/telephony/telephonyjstest/netmanager_socket/entry/src/main/resources/rawfile/video/show.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/telephony/telephonyjstest/netmanager_socket/signature/openharmony_sx.p7b b/telephony/telephonyjstest/netmanager_socket/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/telephony/telephonyjstest/netmanager_socket/signature/openharmony_sx.p7b differ diff --git a/telephony/telephonyjstest/new_add/BUILD.gn b/telephony/telephonyjstest/new_add/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9feab10c4ebb26934a9146053976007e397577e1 --- /dev/null +++ b/telephony/telephonyjstest/new_add/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2021 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("ActsNewAddEtsTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":ace_demo_ets_assets", + ":ace_demo_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsNewAddEtsTest" +} +ohos_js_assets("ace_demo_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("ace_demo_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/telephony/telephonyjstest/new_add/Test.json b/telephony/telephonyjstest/new_add/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..cb0f0ae2e56cb366f2352288ffa4f8a50f9ff476 --- /dev/null +++ b/telephony/telephonyjstest/new_add/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "1800000", + "package": "com.ohos.newadd", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsNewAddEtsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/config.json b/telephony/telephonyjstest/new_add/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..0a3639dd755aeda46f4c07b43dc3997c73a3f947 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/config.json @@ -0,0 +1,93 @@ +{ + "app": { + "bundleName": "com.ohos.newadd", + "vendor": "open", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.ohos.newadd", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/Button", + "pages/Blank", + "pages/DataPanel", + "pages/Divider", + "pages/Text", + "pages/RowSplit", + "pages/Scroll", + "pages/Stack", + "pages/Image", + "pages/Progress", + "pages/Qrcode", + "pages/Rating", + "pages/Span", + "pages/Slider", + "pages/Badge", + "pages/Column", + "pages/ColumnSplit", + "pages/Counter", + "pages/Flex", + "pages/GridContainer" + + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/app.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..261fadca29ff0ea310a8bc105ddd1af65e2dd2f6 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Badge.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Badge.ets new file mode 100644 index 0000000000000000000000000000000000000000..66de6f8e3b9c0360931602dd25d1511878ac63ab --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Badge.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct badge { + @State counts: number = 33 + @State message: string = 'new' + @State active: boolean = false + private content: string = "badge Page"; + + onPageShow() { + console.info('badge page show called'); + } + + onBuildDone() { + console.info('badge page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Scroll() { + Column() { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Badge({ + count: this.counts, + position: BadgePosition.Right, + maxCount: 99, + style: { color: 0xFFFFFF, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge') + + Text("BadgePosition.RightTop").fontSize(16) + Badge({ + count: this.counts, + position: BadgePosition.RightTop, + maxCount: 99, + style: { color: 0xFFFFFF, fontSize: '16', badgeSize: '20', badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge1') + + Text("BadgePosition.Left").fontSize(16) + Badge({ + count: this.counts, + position: BadgePosition.Left, + maxCount: 99, + style: { color: Color.Pink, fontSize: 16, badgeSize: 20, badgeColor: Color.Red } + }) { + Button('message') + .onClick(() => { + this.counts++ + }) + .width(100).height(50).backgroundColor(0x317aff) + } + .width(100) + .height(50) + .key('badge2') + } + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Blank.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Blank.ets new file mode 100644 index 0000000000000000000000000000000000000000..a50fc719e09ab27c91f9705ac06008e936830f33 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Blank.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct blank_testcase { + @State Color: Color = Color.Pink + @State active: boolean = false + private content: string = "Blank Page" + + onPageShow() { + console.info('Blank page show called'); + } + + onBuildDone() { + console.info('Blank page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Blank(100) + .color(this.Color) + .key('blank') + Text('on/off').fontSize(18).height(60) + } + .key('flex') + .width('100%') + .height('100%') + + + } +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Button.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Button.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac2271ea3a13664bbbb6afe4f173abae9e66f867 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Button.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct button_testcase { + @State stateEffect: boolean = true + @State ButtonType: ButtonType = ButtonType.Circle + private content: string = "Button Page"; + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button('1.value', { type: ButtonType.Circle, stateEffect: this.stateEffect }) + .fontSize(12) + .fontWeight(FontWeight.Bold) + .fontColor(0xCCCCCC) + .height(40) + .width(40) + .key('button') + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + .padding(10) + Button() { + Text("2.Capsule") + } + .type(ButtonType.Capsule) + .stateEffect(false) + .backgroundColor('#0D9FFB') + .padding(10) + .key('button1') + + Button() { + Text("3.Normal") + }.type(ButtonType.Normal) + .backgroundColor('#0D9FFB') + .key('button2') + + }.key('flex') + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Column.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Column.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9e5c84e21ccf25419be432d8f95418fac82070a --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Column.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct column { + @State active: boolean = false + private content: string = "Column Page" + + onPageShow() { + console.info('Column page show called'); + } + + onBuildDone() { + console.info('Column page build done called'); + } + + build() { + Column({ space: 5 }) { + Text('alignItems(Center)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Center).width('90%').border({ width: 1 }).key('column') + + Text('alignItems(Start)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column({ space: '5' }) { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.Start).width('90%').border({ width: 1 }).key('column1') + + Text('alignItems(End)').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(50).backgroundColor(0xAFEEEE) + Column().width('50%').height(50).backgroundColor(0x00FFFF) + }.alignItems(HorizontalAlign.End).width('90%').border({ width: 1 }).key('column2') + }.width('100%').padding({ top: 5 }) + } +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb0597310a15be8ab4503a3ae89385e3708fac96 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/ColumnSplit.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct columnSplit { + private content: string = "ColumnSplit Page" + + onPageShow() { + console.info('ColumnSplit page show called'); + } + + onBuildDone() { + console.info('ColumnSplit page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Scroll() { + Column() { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Column() { + Text('ColumnSplit').fontSize(9).fontColor(0xCCCCCC).width('90%') + ColumnSplit() { + Text('1').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('2').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('3').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + }.key('columnSplit') + .resizeable(true) + .width('90%').height('60%') + + }.width("100%") + + Column() { + Text('ColumnSplit1').fontSize(9).fontColor(0xCCCCCC).width('90%') + ColumnSplit() { + Text('1').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('2').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('3').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + Text('4').width('100%').height(50).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + Text('5').width('100%').height(50).backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + }.key('columnSplit1') + .resizeable(false) + .width('90%').height('60%') + + }.width("100%") + } + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Counter.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Counter.ets new file mode 100644 index 0000000000000000000000000000000000000000..ecdbfaf10393e7a348fd76098868e6455505b07f --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Counter.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct counter { + @State value: number = 0 + @State active: boolean = false + private content: string = "Counter Page" + + onPageShow() { + console.info('Counter page show called'); + } + + onBuildDone() { + console.info('Counter page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Counter() { + Text(this.value.toString()) + }.margin(100) + .key('counter') + .onInc(() => { + this.value++ + }) + .onDec(() => { + this.value-- + }) + }.width("100%") + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/DataPanel.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/DataPanel.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c624848482b22998b2a1d137796ddaedbcf198c --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/DataPanel.ets @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct dataPanel_testcase { + @State width: string= "200" + @State height: string= "100" + @State active: boolean = false + private content: string = "DataPanel Page" + + onPageShow() { + console.info('Blank page show called'); + } + + onBuildDone() { + console.info('Blank page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + DataPanel({ values: [20, 40, 20], max: 100, type: DataPanelType.Line }) + .width(this.width) + .height(this.height) + .key('DataPanel') + .onClick(() => { + router.back() + }) + .closeEffect(false) + + DataPanel({ values: [20, 40, 20], max: 100, type: DataPanelType.Circle}) + .width(this.width) + .height(this.height) + .key('DataPanel2') + .onClick(() => { + router.back() + }) + .closeEffect(true) + DataPanel({ values: [20, 40, 20], max: 100}) + .width(this.width) + .height(this.height) + .key('DataPanel3') + .onClick(() => { + router.back() + }) + .closeEffect(false) + } + .key('flex') + .width('100%') + .height('100%') + + } +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Divider.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Divider.ets new file mode 100644 index 0000000000000000000000000000000000000000..02bf60779418674d1fd58127907fdb3915bd8f8f --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Divider.ets @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct divider_textcase { + @State vertical: boolean = true + @State color: Color = Color.Red + @State strokeWidth: number = 7 + @State lineCap: LineCapStyle = LineCapStyle.Butt + @State active: boolean = false + private content: string = "Divider Page"; + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + Divider() + .lineCap(LineCapStyle.Butt) + .strokeWidth(this.strokeWidth) + .color(this.color) + .vertical(this.vertical) + .height(150) + .key('divider') + .onClick(() => { + router.back() + }) + Divider() + .lineCap(LineCapStyle.Round) + .vertical(false) + .color(Color.Green) + .strokeWidth(10) + .height(150) + .key('divider1') + Divider() + .lineCap(LineCapStyle.Square) + .color(Color.Green) + .vertical(true) + .strokeWidth(10) + .height(150) + .key('divider2') + } + .key('flex') + .width('100%') + .height('100%') + } +} + + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Flex.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Flex.ets new file mode 100644 index 0000000000000000000000000000000000000000..a0e21251e80008c5be9f29aa52074acc5eb24a78 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Flex.ets @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct flex { + private content: string = "Flex Page" + + onPageShow() { + console.info('Flex page show called'); + } + + onBuildDone() { + console.info('Flex page build done called'); + } + + build() { + Column() { + Column({ space : 2 }) { + Text('direction:Column').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Column, + wrap: FlexWrap.NoWrap, + justifyContent: FlexAlign.Center, + alignItems:ItemAlign.Start, + alignContent: FlexAlign.Start, + }) { + Text('1').width('100%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('100%').height(20).backgroundColor(0xD2B48C) + Text('3').width('100%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex') + .height(70) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('direction:Row').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.Row, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.Start, + alignItems:ItemAlign.Start, + alignContent: FlexAlign.Center, + }) { + Text('1').width('20%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('20%').height(20).backgroundColor(0xD2B48C) + Text('3').width('20%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex1') + .height(70) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('direction:RowReverse').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + direction: FlexDirection.RowReverse, + wrap: FlexWrap.Wrap, + justifyContent: FlexAlign.End, + alignItems:ItemAlign.End, + alignContent: FlexAlign.End, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex2') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent:SpaceBetween').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceBetween, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('100%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('100%').height(20).backgroundColor(0xD2B48C) + Text('3').width('100%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex3') + .height(100) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent AND alignContent').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceEvenly, + alignContent: FlexAlign.SpaceEvenly, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex4') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + + Text('justifyContent AND alignContent').fontSize(9).fontColor(0xCCCCCC).width('90%') + Flex({ + justifyContent: FlexAlign.SpaceAround, + alignContent: FlexAlign.SpaceAround, + wrap: FlexWrap.Wrap, + }) { + Text('1').width('50%').height(20).backgroundColor(0xF5DEB3) + Text('2').width('50%').height(20).backgroundColor(0xD2B48C) + Text('3').width('50%').height(20).backgroundColor(0xF5DEB3) + } + .key('flex5') + .height(90) + .width('90%') + .padding(10) + .backgroundColor(0xAFEEEE) + }.width('100%').margin({ top: 5 }) + }.width('100%') + } +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/GridContainer.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/GridContainer.ets new file mode 100644 index 0000000000000000000000000000000000000000..57358110413406263e70a2a5f650cbfeb22a4387 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/GridContainer.ets @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct gridContainer { + @State sizeType: SizeType = SizeType.XS + @State active: boolean = false + private content: string = "GridContainer Page" + + onPageShow() { + console.info('GridContainer page show called'); + } + + onBuildDone() { + console.info('GridContainer page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Scroll() { + Column({ space: 5 }) { + GridContainer({ columns: 12, sizeType: this.sizeType, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer') + .width('90%') + .alignItems(HorizontalAlign.Start) + + Text('Click Simulate to change the device width').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() { + Button('XS') + .onClick(() => { + this.sizeType = SizeType.XS + }).backgroundColor(0x317aff) + Button('SM') + .onClick(() => { + this.sizeType = SizeType.SM + }).backgroundColor(0x317aff) + Button('MD') + .onClick(() => { + this.sizeType = SizeType.MD + }).backgroundColor(0x317aff) + Button('LG') + .onClick(() => { + this.sizeType = SizeType.LG + }).backgroundColor(0x317aff) + } + + GridContainer({ columns: "auto", sizeType: SizeType.MD, gutter: '10', margin: '20' }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer1') + .width('90%') + .alignItems(HorizontalAlign.Center) + + GridContainer({ columns: 12, sizeType: SizeType.SM, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer2') + .width('90%') + .alignItems(HorizontalAlign.End) + + GridContainer({ columns: 12, sizeType: SizeType.LG, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer3') + .width('90%') + .alignItems(HorizontalAlign.End) + + GridContainer({ columns: 12, sizeType: SizeType.Auto, gutter: 10, margin: 20 }) { + Row() { + Text('1') + .useSizeType({ + xs: { span: 6, offset: 0 }, + sm: { span: 2, offset: 0 }, + md: { span: 2, offset: 0 }, + lg: { span: 2, offset: 0 } + }) + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + Text('2').gridSpan(2) + + .height(50).backgroundColor(0x00BFFF).textAlign(TextAlign.Center) + Text('3').gridOffset(3) + + .height(50).backgroundColor(0x4682B4).textAlign(TextAlign.Center) + } + }.key('gridContainer4') + .width('90%') + .alignItems(HorizontalAlign.End) + + }.width('100%').margin({ top: 5 }) + } + } + .key('flex') + .width('100%') + .height('100%') + } +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Image.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Image.ets new file mode 100644 index 0000000000000000000000000000000000000000..5cc583e931f51aa8e4f2bd55decfeeb14a40afb4 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Image.ets @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct image_textcase { + @State Width: number = 0 + @State height: number = 0 + + onPageShow() { + console.info('Image page show called'); + } + + onBuildDone() { + console.info('Image page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Image page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Image("/resources/rawfile/hand.png") + .matchTextDirection(false) + .fitOriginalSize(false) + .fillColor(0xCCCCCC) + .objectFit(ImageFit.Cover) + .objectRepeat(ImageRepeat.NoRepeat) + .interpolation(ImageInterpolation.None) + .renderMode(ImageRenderMode.Original) + .autoResize(false) + .syncLoad(false) + .sourceSize({ width: 200, height: 100 }) + .alt("/resources/rawfile/person.png") + .key('image1') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.Contain) + .objectRepeat(ImageRepeat.X) + .interpolation(ImageInterpolation.High) + .renderMode(ImageRenderMode.Template) + .key('image2') + .height(180) + .width(180) + .onComplete((msg: { + width: number, + height: number + }) => { + this.Width = msg.width + this.height = msg.height + console.info('Width ----' + this.Width) + console.info('height ----' + this.height) + }) + .onError(() => { + console.info('load image fail') + }) + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.Fill) + .objectRepeat(ImageRepeat.Y) + .interpolation(ImageInterpolation.Low) + .key('image3') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.None) + .objectRepeat(ImageRepeat.XY) + .interpolation(ImageInterpolation.Medium) + .key('image4') + Image("/resources/rawfile/hand.png") + .objectFit(ImageFit.ScaleDown) + .key('image5') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(4) + } + } +} + + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Navigator.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Navigator.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c50769cf2ab045cbe48b52e294b4105a21e1c3d --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Navigator.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct navigator_testcase { + @State active: boolean = false + @State params: Object = { text: 'news' } + + onPageShow() { + console.info('Navigator page show called'); + } + + onBuildDone() { + console.info('Navigator page build done called'); + } + + build() { + Column() { + Navigator({ target: "pages/index", type: NavigationType.Back }) { + Text('Navigator test in Navigator,back') + }.active(this.active) + .key('navigator') + .params({ + data: 24 + }) + + Navigator({ target: "pages/index", type: NavigationType.Push }) { + Text('Navigator test in Navigator,push') + }.active(this.active) + .key('navigator2') + .params({ + data: 24 + }) + + Navigator({ target: "pages/index", type: NavigationType.Replace }) { + Text('Navigator test in Navigator,replace') + }.active(this.active) + .key('navigator3') + .params({ + data: 24 + }) + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Panel.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Panel.ets new file mode 100644 index 0000000000000000000000000000000000000000..32ddabbd1ccbae3805dd462e6f04b28364d6a1e7 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Panel.ets @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct PanelExample { + @State show: boolean = true + + onPageShow() { + console.info('Panel page show called'); + } + + onBuildDone() { + console.info('Panel page build done called'); + } + + build() { + Column() { + Text('2021-09-30 Today Calendar: 1.afternoon......Click for details') + .width('90%') + .height(50) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + .padding({ left: 20 }) + .onClick(() => { + this.show = !this.show + }) + Panel(this.show) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel') + .type(PanelType.Foldable) + .mode(PanelMode.Half) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + Panel(this.show) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel2') + .type(PanelType.Minibar) + .mode(PanelMode.Mini) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + Panel(false) { + Column() { + Text('Today Calendar') + Divider() + Text('1. afternoon 4:00 The project meeting') + } + } + .key('panel3') + .type(PanelType.Temporary) + .mode(PanelMode.Full) + .dragBar(true) + .fullHeight(500) + .halfHeight(250) + .miniHeight(100) + .onChange((value: any) => { + console.info(`width:${value.width},height:${value.height},mode:${value.mode}`) + }) + + }.width('100%').height('50%').backgroundColor(0xDCDCDC).padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Progress.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Progress.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8608089fe51e1988fd305fc49db028b6c2efe76 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Progress.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct progress_testcase { + onPageShow() { + console.info('Progress page show called'); + } + + onBuildDone() { + console.info('Progress page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Progress page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Progress({ value: 20, total: 40, style: ProgressStyle.Linear }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress') + + Progress({ value: 20, total: 40, style: ProgressStyle.Eclipse }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress2') + + Progress({ value: 20, total: 40, style: ProgressStyle.Ring }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress3') + + Progress({ value: 20, total: 40, style: ProgressStyle.ScaleRing }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress4') + + Progress({ value: 20, total: 40, style: ProgressStyle.Capsule }) + .value(3) + .color(Color.Blue) + .width(50) + .height(70) + .key('progress5') + + } + .width(400) + .height(400) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Qrcode.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Qrcode.ets new file mode 100644 index 0000000000000000000000000000000000000000..5c0dd84eff5a6653ee5fd940662d141025a1bb4e --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Qrcode.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct qrcode_textcase { + @State Color: Color = Color.Pink + + onPageShow() { + console.info('Qrcode page show called'); + } + + onBuildDone() { + console.info('Qrcode page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`Qrcode page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + QRCode('hello world') + .color("#FFFFC0CB") + .backgroundColor(this.Color) + .width("200") + .height("100") + .key('qrcode') + } + } +} + + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Rating.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Rating.ets new file mode 100644 index 0000000000000000000000000000000000000000..b29e26a392fca6f15a5b7f0eb4156dd3bc767c3f --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Rating.ets @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct rating_testcase { + @State rating: number = 2 + + onPageShow() { + console.info('Rating page show called'); + } + + onBuildDone() { + console.info('Rating page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Rating page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Rating({ rating: 2, indicator: false }) + .stepSize(0.5) + .stars(5) + .starStyle({ + backgroundUri: '/resources/rawfile/star-1-1.png', + foregroundUri: '/resources/rawfile/star-1-3.png', + secondaryUri: '/resources/rawfile/star-1-2.png' + }) + .onChange((value: number) => { + this.rating = value + }) + .key('rating1') + Rating({ rating: 2, indicator: true }) + .stepSize(0.5) + .stars(5) + .starStyle({ + backgroundUri: '/resources/rawfile/star-1-1.png', + foregroundUri: '/resources/rawfile/star-1-3.png', + secondaryUri: '/resources/rawfile/star-1-2.png' + }) + .key('rating2') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/RowSplit.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/RowSplit.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f4f397b13b83e98ac643633309b02858f337eb0 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/RowSplit.ets @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct rowSplit_testcase { + @State resizeable: boolean = false + private content: string = "rowSplit Page"; + + onPageShow() { + console.info('RowSplit page show called'); + } + + onBuildDone() { + console.info('RowSplit page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + RowSplit() { + Column() { + Text('Demo1.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + + Column() { + Text('Demo2.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + } + .height(100) + .key('rowSplit') + .resizeable(this.resizeable) + .onClick(() => { + router.back() + }) + + RowSplit() { + Column() { + Text('Demo3.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + + Column() { + Text('Demo4.RowSplit') + .fontSize(15) + .fontWeight(FontWeight.Bold) + } + }.height(100) + .key('rowSplit1') + .resizeable(true) + } + .key('flex') + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Scroll.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Scroll.ets new file mode 100644 index 0000000000000000000000000000000000000000..363089d22580febed16b983d8a4b2877cde52bec --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Scroll.ets @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct scroll_testcase { + @State scrollBarWidth: number = 20 + @State scrollable: ScrollDirection = ScrollDirection.None + @State scrollBarColor: Color = Color.Pink + @State scrollBar: BarState= BarState.On + private value1: Array = [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30] + @State edge: Edge= Edge.Top + private content: string = "Scroll Page"; + scroller: Scroller = new Scroller(); + + onPageShow() { + console.info('Button page show called'); + } + + onBuildDone() { + console.info('Button page build done called'); + } + + build() { + + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Scroll(this.scroller) { + Column() { + ForEach( + this.value1, + item => { + Text(`${item}`) + .fontSize(15) + .width(400) + .margin(10) + .height(70) + .backgroundColor(0xfff5deb3) + }, + item => item + ) + } + } + .scrollable(ScrollDirection.Vertical) + .scrollBar(this.scrollBar) + .scrollBarColor(this.scrollBarColor) + .scrollBarWidth(this.scrollBarWidth) + .key('scroll') + .width(400) + .height(200) + .onScroll((xOffset: number, yOffset: number) => { + console.info(` current offset is ${xOffset} ${yOffset}`) + }) + .onScrollEnd(() => { + console.info(` now on scroll end`) + }) + .onScrollEdge((side: Edge) => { + console.info(`To the edge`) + }) + Scroll() { + Row() { + Text('scroll uppppp') + .width(60) + .height(100) + .backgroundColor(Color.Yellow) + .margin({ + right: 5, + left: 5 + }) + .key('text') + + Text('scroll to') + .width(60) + .height(100) + .backgroundColor(Color.Green) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollTo({ + xOffset: 100, + yOffset: 100, + }) + }) + Text('scroll page') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollPage({ + next: true + }) + }) + Text('scroll Edge') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollEdge(Edge.Top) + }) + Text('scroll Edge') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.currentOffset() + }) + Text('scroll to index') + .width(60) + .height(100) + .backgroundColor(Color.Blue) + .margin({ + right: 5, + left: 5 + }) + .onClick(() => { + this.scroller.scrollToIndex(0) + console.info(` now on scroll end`) + }) + } + } + .key('scroll1') + .height(100) + .scrollable(ScrollDirection.Horizontal) + + Scroll() { + Column() { + Text("start").fontSize(30) + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + } + } + .padding(10) + .scrollable(ScrollDirection.None) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Red) + .scrollBarWidth(5) + .width(300) + .height(200) + .key('scroll2') + + Scroll() { + Column() { + Text("start").fontSize(30) + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + Text("scrollable1") + Text("scrollable2") + Text("scrollable3") + Text("scrollable4") + } + } + .padding(10) + .scrollable(ScrollDirection.Free) + .scrollBar(BarState.Off) + .scrollBarColor(Color.Red) + .scrollBarWidth(5) + .width(300) + .height(200) + .key('scroll3') + } + .key('flex') + + } +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Slider.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Slider.ets new file mode 100644 index 0000000000000000000000000000000000000000..625cd02874f16e9debb7638322624f890e08fa62 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Slider.ets @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct slider { + @State inSetValue: number= 40 + @State outSetValue: number= 40 + @State direction: Axis= Axis.Horizontal + @State Begin: number = SliderChangeMode.Begin + + onPageShow() { + console.info('Slider page show called'); + } + + onBuildDone() { + console.info('Slider page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text(`Slider page`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Slider({ + value: this.outSetValue, + min: 0, + max: 100, + step: 1, + direction: Axis.Horizontal, + reverse: false, + style: SliderStyle.OutSet + }) + .blockColor('#FFFF0000') + .selectedColor('#FF0000FF') + .trackColor('#FF808080') + .minLabel('10') + .maxLabel('10') + .showTips(false) + .showSteps(false) + .onChange((value: number, mode: SliderChangeMode) => { + this.outSetValue = value + this.Begin = mode + console.info('value: ' + value + '---mode: ' + mode) + }) + .width("100") + .height("100") + .key('slider1') + Slider({ + value: 40, + min: 0, + max: 100, + step: 1, + style: SliderStyle.InSet + }) + .blockColor(Color.Red) + .selectedColor(Color.Blue) + .trackColor(Color.Gray) + .showTips(true) + .showSteps(true) + .key('slider2') + }.width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(2) + } + } +} + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Span.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Span.ets new file mode 100644 index 0000000000000000000000000000000000000000..df5a71043f1ae000b822646f6b56df7ae103fa1f --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Span.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021 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. + */ + +@Entry +@Component +struct span_textcase { + + onPageShow() { + console.info('Span page show called'); + } + + onBuildDone() { + console.info('Span page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Column() { + Text() { + Span('Test Span demo') + .decoration({ type: TextDecorationType.LineThrough, "color": Color.Red }) + .textCase(TextCase.UpperCase) + .fontColor(Color.Blue) + .fontSize("20fp") + .letterSpacing(5) + .fontFamily("sans-serif") + .fontWeight(FontWeight.Bold) + .fontStyle(FontStyle.Italic) + .key('span1') + Span('The second test Span demo') + .textCase(TextCase.LowerCase) + .fontColor(Color.Black) + .letterSpacing('5') + .fontSize(30) + .key('span2') + Span('The third test Span demo') + .textCase(TextCase.Normal) + .fontColor(Color.Yellow) + .fontSize("30fp") + .key('span3') + } + } + .width(300) + .height(300) + .borderColor(Color.Pink) + .borderWidth(4) + } + } +} + + + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Stack.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Stack.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a694889f0e768afbd3e3af6a17c3af9d8738cfb --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Stack.ets @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2021 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 router from '@system.router' + +@Entry +@Component +struct stack_testcase { + @State alignContent: Alignment = Alignment.Bottom + private content: string = "Stack Page"; + + onPageShow() { + console.info('Stack page show called'); + } + + onBuildDone() { + console.info('Stack page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Stack({ alignContent: this.alignContent }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + } + .width('100%') + .height(80) + .margin({ top: 5 }) + .key('stack') + .onClick(() => { + router.back() + }) + + Stack({ alignContent: Alignment.BottomStart }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack1') + + Stack({ alignContent: Alignment.BottomEnd }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack2') + + Stack({ alignContent: Alignment.Start }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack3') + + Stack({ alignContent: Alignment.Center }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack4') + + Stack({ alignContent: Alignment.End }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(80).margin({ top: 5 }) + .key('stack5') + + Stack({ alignContent: Alignment.Top }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack6') + + Stack({ alignContent: Alignment.TopStart }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack7') + + Stack({ alignContent: Alignment.TopEnd }) { + Text('First child, show in bottom').width('90%').height('100%').backgroundColor(0xd2cab3).align(Alignment.Top) + Text('Second child, show in top').width('70%').height('60%').backgroundColor(0xc1cbac).align(Alignment.Top) + }.width('100%').height(60).margin({ top: 5 }) + .key('stack8') + } + .key('flex') + .width('100%') + .height('100%') + + } +} + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Text.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Text.ets new file mode 100644 index 0000000000000000000000000000000000000000..fbd1415dc815b0f1966476c430f7d69e28e587ee --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/Text.ets @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2021 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. + */ + +// @ts-nocheck +import router from '@system.router' + +var paramInfo = router.getParams() +console.info("cd paramInfo" + JSON.stringify(paramInfo)) + +@Entry +@Component +struct text_textcase { + @State textAlign: TextAlign= TextAlign.End + @State lineHeight: string= '15fp' + @State overflow: TextOverflow = TextOverflow.Ellipsis + @State textOverflow: textOverflow<{ "overflow": TextOverflow }> = { "overflow": this.overflow } + @State maxLines: number = 2 + @State baselineOffset: number = 0 + @State textCase: TextCase= TextCase.Normal + @State decoration: decoration<{ + type: TextDecorationType, + color: Color + }> = { type: TextDecorationType.Underline, color: Color.Red } + @State color: Color = Color.Red + @State width: string= "200" + @State height: string= "100" + @State size: size = { width: 200, height: 100 } + @State marginBottom: string = "10px" + @State marginTop: string = "10px" + @State marginLeft: string = "10px" + @State marginRingt: string= "10px" + @State paddingBottom: string= "5" + @State paddingTop: string= "5" + @State paddingLeft: string= "5" + @State paddingRingt: string= "5" + @State constraintSize: constraintSize = { minWidth: 20, maxWidth: 200, minHeight: 0, maxHeight: 50 } + @State layoutPriority: string= "9px" + @State layoutWeight: string = "10px" + @State align: Alignment = Alignment.Center + @State direction: Direction = Direction.Auto + @State position: position<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State markAnchor: markAnchor<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State offset: offset<{ + x: string, + y: string + }> = { x: "50", y: "50" } + @State flexGrow: number = 5 + @State flexShrink: number = 2 + @State flexBasis: number = 0 + @State alignSelf: ItemAlign = ItemAlign.Auto + @State borderStyle: BorderStyle = BorderStyle.Dashed + @State borderRadius: number = 10 + @State borderWidth: string= "4px" + @State borderColor: Color= Color.Blue + @State backgroundColor: Color = Color.Pink + @State backgroundImageSize: ImageSize = ImageSize.Cover + @State backgroundImagePosition: Alignment= Alignment.Center + @State opacity: number= 1 + @State visibility: Visibility= Visibility.Visible + @State enabled: boolean = false + @State zIndex: number = 1 + @State fontStyle: FontStyle = FontStyle.Italic + @State fontSize: number = 15 + @State minFontSize: number = 15 + @State maxFontSize: number = 15 + @State letterSpacing: number= 10 + @State fontWeight: FontWeight= FontWeight.Bold + @State fontColor: Color= Color.Black + @State active: boolean = false + private content: string = "Text Page"; + + onPageShow() { + console.info('Text page show called'); + } + + onBuildDone() { + console.info('Text page build done called'); + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .width(this.width) + .height(this.height) + .padding({ bottom: this.paddingBottom, top: this.paddingTop, right: this.paddingRingt, left: this.paddingLeft }) + .margin({ bottom: this.marginBottom, top: this.marginTop, right: this.marginRingt, left: this.marginLeft }) + .constraintSize(this.constraintSize) + .layoutWeight(this.layoutWeight) + .align(this.align) + .direction(this.direction) + .position(this.position) + .markAnchor(this.markAnchor) + .offset(this.offset) + .flexBasis(this.flexBasis) + .flexGrow(this.flexGrow) + .flexShrink(this.flexShrink) + .alignSelf(this.alignSelf) + .borderStyle(this.borderStyle) + .borderRadius(this.borderRadius) + .borderWidth(this.borderWidth) + .borderColor(this.borderColor) + .backgroundColor(this.backgroundColor) + .opacity(this.opacity) + .visibility(this.visibility) + .enabled(this.enabled) + .zIndex(this.zIndex) + .fontColor(this.fontColor) + .fontSize(this.fontSize) + .minFontSize(this.minFontSize) + .letterSpacing(this.letterSpacing) + .maxFontSize(this.maxFontSize) + .fontWeight(this.fontWeight) + .fontStyle(this.fontStyle) + .fontFamily("sans-serif") + .textAlign(this.textAlign) + .textOverflow(this.textOverflow) + .lineHeight(this.lineHeight) + .baselineOffset(this.baselineOffset) + .maxLines(2) + .textCase(this.textCase) + .decoration(this.decoration) + .aspectRatio(1) + .fontColor(Color.Black) + .key('Text') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .size({ width: 100, height: 50 }) + .padding({ bottom: 5, top: 5, right: 5, left: 10 }) + .margin({ bottom: 15, top: 10, right: 10, left: 10 }) + .fontSize('13') + .textAlign(TextAlign.Start) + .align(Alignment.Start) + .direction(Direction.Ltr) + .alignSelf(ItemAlign.Start) + .borderStyle(BorderStyle.Dotted) + .borderWidth(2) + .visibility(Visibility.Hidden) + .enabled(true) + .fontWeight(FontWeight.Normal) + .textAlign(TextAlign.Start) + .textOverflow(TextOverflow.Clip) + .maxLines(2) + .textCase(TextCase.LowerCase) + .decoration({ "type": TextDecorationType.LineThrough, "color": Color.Red }) + .fontColor(Color.White) + .key('Text1') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .width('100%') + .textAlign(TextAlign.Center) + .align(Alignment.TopEnd) + .direction(Direction.Rtl) + .alignSelf(ItemAlign.Center) + .borderStyle(BorderStyle.Solid) + .borderWidth(2) + .visibility(Visibility.None) + .fontWeight(FontWeight.Bolder) + .textAlign(TextAlign.Center) + .textOverflow(TextOverflow.None) + .textCase(TextCase.UpperCase) + .decoration({ "type": TextDecorationType.None, "color": Color.Red }) + .fontColor(Color.Blue) + .key('Text2') + Text('Text Anto test,Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.Top) + .alignSelf(ItemAlign.End) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Lighter) + .decoration({ type: TextDecorationType.Overline, color: Color.Red }) + .fontColor(Color.Gray) + .key('Text3') + Text('Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.TopStart) + .alignSelf(ItemAlign.Baseline) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Medium) + .fontColor(Color.Brown) + .key('Text4') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.End) + .alignSelf(ItemAlign.Stretch) + .borderWidth(2) + .width('100%') + .fontWeight(FontWeight.Regular) + .fontColor(Color.Grey) + .key('Text5') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.BottomEnd) + .width('100%') + .fontColor(Color.Orange) + .key('Text6') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.Bottom) + .width('100%') + .fontColor(Color.Yellow) + .key('Text7') + Text('Text Anto test,Text Anto test,Text Anto test') + .fontSize(13) + .align(Alignment.BottomStart) + .width('100%') + .key('Text8') + + } + .key('flex') + .width('100%') + .height('100%') + } +} + + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/index.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..10359134da915c9b44b0836ba4881bca71f43f33 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,65 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 file from '@system.file'; + +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; +import testsuite from "../test/List.test.ets"; +import featureAbility from "@ohos.ability.featureAbility"; + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + Want.parameters['timeout'] = 100000 + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('ACE ETS TEST') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/CallJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/CallJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd87b836016e5664c060e93121c1ba5529e2c1bd --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/CallJsunit.test.ets @@ -0,0 +1,850 @@ +// @ts-nocheck +/** + * Copyright (C) 2021 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index.ets' +import call from '@ohos.telephony.call'; +import utils from './Utils.ets' + +export const PHONE_NUMBER = ''; +export const DEFAULT_SLOT_ID = 0; +export const MEDIA_TYPE_VOICE = 0; +export const DIAL_SCENCE_CALL_NORMAL = 0; +export const DIAL_CARRIER_TYPE = 0; +export const DIAL_SCENCE_CALL_PRIVILEGED = 1; +export const BOUNDARY_NUMBER_INT = 2147483649; +export const CALL_ID_NOT_EXIST = 999; + +export function toString (data) { + if (typeof data === 'object') { + return JSON.stringify(data); + } else { + return data; + } +} + +class CallAttributeOptions { + constructor (callId) { + this.callId = callId; + } +} + +export default function callJsunit(){ + describe('callTest', function(){ + console.log("==========> call Test start ==========>"); + + /** + * @tc.number Telephony_Call_Call_Dial_0100 + * @tc.name Makes a call. + * @tc.desc Function test + */ + it("Telephony_Call_Call_Dial_0100",0,async function(done){ + let caseName:string = "Telephony_Call_Call_Dial_0100"; + console.log(`==========> ${caseName} Test start ==========>`); + call.dial(PHONE_NUMBER,(err,data) => { + if(err){ + console.log(`${caseName} error,case success,error:${toString(err)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} success,case fail`); + done(); + }); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_Call_Dial_0200 + * @tc.name Makes a call. + * @tc.desc Function test + */ + it("Telephony_Call_Call_Dial_0200",0,async function(done){ + let caseName:string = "Telephony_Call_Call_Dial_0200"; + console.log(`==========> ${caseName} Test start ==========>`); + let options = {extras:false, accountId:DEFAULT_SLOT_ID, videoState:MEDIA_TYPE_VOICE, + dialScene:DIAL_SCENCE_CALL_PRIVILEGED, dialType:DIAL_CARRIER_TYPE}; + call.dial(PHONE_NUMBER,options,(err,data) => { + if(err){ + console.log(`${caseName} error,case success,error:${toString(err)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} success,case fail`); + done(); + }); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_Call_Dial_0200 + * @tc.name Makes a call. + * @tc.desc Function test + */ + it("Telephony_Call_Call_Dial_0200",0,async function(done){ + let caseName:string = "Telephony_Call_Call_Dial_0200"; + console.log(`==========> ${caseName} Test start ==========>`); + let options = {extras:false, accountId:DEFAULT_SLOT_ID, videoState:MEDIA_TYPE_VOICE, + dialScene:DIAL_SCENCE_CALL_PRIVILEGED, dialType:DIAL_CARRIER_TYPE}; + call.dial(PHONE_NUMBER,options,(err,data) => { + if(err){ + console.log(`${caseName} error,case success,error:${toString(err)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} success,case fail`); + done(); + }); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + + + /** + * @tc.number Telephony_Call_Call_Dial_0300 + * @tc.name Makes a call. + * @tc.desc Function test + */ + it("Telephony_Call_Call_Dial_0300",0,async function(done){ + let caseName:string = "Telephony_Call_Call_Dial_0300"; + console.log(`==========> ${caseName} Test start ==========>`); + let options = {extras:false, accountId:DEFAULT_SLOT_ID, videoState:MEDIA_TYPE_VOICE, + dialScene:DIAL_SCENCE_CALL_PRIVILEGED, dialType:DIAL_CARRIER_TYPE}; + call.dial(PHONE_NUMBER,options).then(data=>{ + expect(true).assertTrue(); + }).catch(error =>{ + console.log(caseName+ " dial error :"+ toString(error)); + done(); + return; + }); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_Call_MakeCall_0100 + * @tc.name Make a call. + * @tc.desc Function test + */ + it("Telephony_Call_Call_MakeCall_0100",0,async function(done){ + let caseName:string = "Telephony_Call_Call_MakeCall_0100"; + console.log(`==========> ${caseName} Test start ==========>`); + try{ + let telNumber = ""; + call.makeCall(telNumber,(error) => { + if(error){ + console.log(`${caseName} fail,case success,error:${toString(error)}`); + expect(true).assertTrue(); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} success,case fail`); + done(); + }); + }catch(err){ + console.log(`${caseName} fail,case success,error:${toString(err)}`); + expect(true).assertTrue(); + done(); + return; + } + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_Call_MakeCall_0200 + * @tc.name Makes a call. + * @tc.desc Function test + */ + it("Telephony_Call_Call_MakeCall_0200",0,async function(done){ + let caseName:string = "Telephony_Call_Call_MakeCall_0200"; + console.log(`==========> ${caseName} Test start ==========>`); + let telNumber = ""; + try{ + call.makeCall(telNumber).then(()=>{ + console.log(`${caseName} success,case fail`); + done(); + }).catch(error =>{ + console.log(`${caseName} fail,case success,error:${toString(error)}`); + expect(true).assertTrue(); + done(); + return; + }); + }catch(err){ + console.log(`${caseName} fail,case success,error:${toString(err)}`); + expect(true).assertTrue(); + done(); + return; + } + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_HasVoiceCapability_HasVoiceCapability + * @tc.name Checks whether a device supports voice calls. + * @tc.desc Return type test + */ + it("Telephony_Call_HasVoiceCapability_HasVoiceCapability",0,async function(done){ + let caseName = 'Telephony_Call_HasVoiceCapability_HasVoiceCapability'; + console.log(`==========> ${caseName} Test start ==========>`); + let ret = false; + let voiceCapablity = call.hasVoiceCapability(); + if(voiceCapablity === true || voiceCapablity === false){ + ret = true; + } + expect(ret).assertTrue(); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_Call_Reject_0100 + * @tc.name call_reject + * @tc.desc Function test + */ + it("Telephony_Call_Call_Reject_0100",0,async function(done){ + let caseName = 'Telephony_Call_Call_Reject_0100'; + console.log(`==========> ${caseName} Test start ==========>`); + call.reject(BOUNDARY_NUMBER_INT, (error) => { + if (error) { + console.log(`${caseName} error,case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} success,case failed`); + done(); + }); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_Call_Reject_0200 + * @tc.name call_reject + * @tc.desc Function test + */ + it("Telephony_Call_Call_Reject_0200",0,async function(done){ + let caseName = 'Telephony_Call_Call_Reject_0200'; + console.log(`==========> ${caseName} Test start ==========>`); + let options = {messageContent:"hello"} + call.reject(BOUNDARY_NUMBER_INT,options, (error) => { + if (error) { + console.log(`${caseName} error,case success,error:${toString(error)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} success,case failed`); + done(); + }); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_Call_Reject_0300 + * @tc.name call_reject + * @tc.desc Function test + */ + it("Telephony_Call_Call_Reject_0300",0,async function(done){ + let caseName = 'Telephony_Call_Call_Reject_0300'; + console.log(`==========> ${caseName} Test start ==========>`); + call.reject(CALL_ID_NOT_EXIST).then(() => { + expect().assertFail(); + console.log(`${caseName} success,case failed`); + done(); + }).catch(error => { + console.log(`${caseName} error,case success,error:${toString(error)}`); + done(); + return; + }); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_On_CallDetailsChange_0100 + * @tc.name Method in call_on of type callDetailsChange + * @tc.desc Function test + */ + it("Telephony_Call_On_CallDetailsChange_0100",0,async function(done){ + let caseName:string = "Telephony_Call_On_CallDetailsChange_0100"; + console.log(`==========> ${caseName} Test start ==========>`); + try{ + call.on("callDetailsChange",(err,data) => { + if(err){ + console.log(`${caseName} error,error :${toString(err)}`); + done(); + return; + } + expect(true).assertTrue(); + done(); + }); + done(); + }catch(err){ + expect().assertFail(); + console.log(`${caseName} fail, err:${err}`); + done(); + } + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_Off_callDetailsChange_0100 + * @tc.name Method in call_off of type callDetailsChange + * @tc.desc Function test + */ + it("Telephony_Call_Off_CallDetailsChange_0100",0,async function(done){ + let caseName:string = "Telephony_Call_Off_CallDetailsChange_0100"; + console.log(`==========> ${caseName} Test start ==========>`); + try{ + call.off("callDetailsChange",(err,data) => { + if(err){ + console.log(`${caseName} error,error :${toString(err)}`); + done(); + return; + } + expect(true).assertTrue(); + done(); + }); + done(); + }catch(err){ + expect().assertFail(); + console.log(`${caseName} fail, err:${err}`); + done(); + } + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_On_CallEventChange_0200 + * @tc.name Method in call_on of type callEventChange + * @tc.desc Function test + */ + it("Telephony_Call_On_CallEventChange_0200",0,async function(done){ + let caseName:string = "Telephony_Call_On_CallEventChange_0200"; + console.log(`==========> ${caseName} Test start ==========>`); + try{ + call.on("callEventChange",(err,data) => { + if(err){ + console.log(`${caseName} error,error :${toString(err)}`); + done(); + return; + } + expect(true).assertTrue(); + done(); + }); + done(); + }catch(err){ + expect().assertFail(); + console.log(`${caseName} fail, err:${err}`); + done(); + } + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_Off_CallEventChange_0200 + * @tc.name Method in call_off of type callEventChange + * @tc.desc Function test + */ + it("Telephony_Call_Off_CallEventChange_0200",0,async function(done){ + let caseName:string = "Telephony_Call_Off_CallEventChange_0200"; + console.log(`==========> ${caseName} Test start ==========>`); + try{ + call.off("callEventChange",(err,data) => { + if(err){ + console.log(`${caseName} error,error :${toString(err)}`); + done(); + return; + } + expect(true).assertTrue(); + done(); + }); + done(); + }catch(err){ + expect().assertFail(); + console.log(`${caseName} fail, err:${err}`); + done(); + } + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_Off_CallEventChange_0200 + * @tc.name Method in call_off of type callDisconnectedCause + * @tc.desc Function test + */ + it("Telephony_Call_On_CallDisconnectedCause_0300",0,async function(done){ + let caseName:string = "Telephony_Call_On_CallDisconnectedCause_0300"; + console.log(`==========> ${caseName} Test start ==========>`); + try{ + call.on("callDisconnectedCause",(err,data) => { + if(err){ + console.log(`${caseName} error,error :${toString(err)}`); + done(); + return; + } + expect(true).assertTrue(); + done(); + }); + done(); + }catch(err){ + expect().assertFail(); + console.log(`${caseName} fail, err:${err}`); + done(); + } + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_Off_CallEventChange_0200 + * @tc.name Method in call_off of type callDisconnectedCause + * @tc.desc Function test + */ + it("Telephony_Call_Off_CallDisconnectedCause_0300",0,async function(done){ + let caseName:string = "Telephony_Call_Off_CallDisconnectedCause_0300"; + console.log(`==========> ${caseName} Test start ==========>`); + try{ + call.off("callDisconnectedCause",(err,data) => { + if(err){ + console.log(`${caseName} error,error :${toString(err)}`); + done(); + return; + } + expect(true).assertTrue(); + done(); + }); + done(); + }catch(err){ + expect().assertFail(); + console.log(`${caseName} fail, err:${err}`); + done(); + } + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_AudioDevice_DEVICE_MIC + * @tc.name Enum AudioDevice + * @tc.desc Enum value test + */ + it("Telephony_Call_AudioDevice_DEVICE_MIC",0,async function(done){ + let caseName = 'Telephony_Call_AudioDevice_DEVICE_MIC'; + console.log(`==========> ${caseName} Test start ==========>`); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(0).assertEqual(call.AudioDevice.DEVICE_MIC); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_Dial_Dial_0200 + * @tc.name Makes a call. + * @tc.desc Function test + */ + it("Telephony_Call_DialOptions_Extras",0,async function(done){ + let caseName:string = "Telephony_Call_DialOptions_extras"; + console.log(`==========> ${caseName} Test start ==========>`); + let options = {extras:false, accountId:DEFAULT_SLOT_ID, videoState:MEDIA_TYPE_VOICE, + dialScene:DIAL_SCENCE_CALL_PRIVILEGED, dialType:DIAL_CARRIER_TYPE}; + call.dial(PHONE_NUMBER,options,(err,data) => { + if(err){ + console.log(`${caseName} error,case success,error:${toString(err)}`); + done(); + return; + } + expect().assertFail(); + console.log(`${caseName} success,case fail`); + done(); + }); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_CallTransferType_TRANSFER_TYPE_BUSY + * @tc.name Enum CallTransferType + * @tc.desc Enum value test + */ + it("Telephony_Call_CallTransferType_TRANSFER_TYPE_BUSY",0,async function(done){ + let caseName = 'Telephony_Call_CallTransferType_TRANSFER_TYPE_BUSY'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(1).assertEqual(call.CallTransferType.TRANSFER_TYPE_BUSY); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_CallTransferSettingType_CALL_TRANSFER_REGISTRATION + * @tc.name Enum CallTransferSettingType + * @tc.desc Enum value test + */ + it("Telephony_Call_CallTransferSettingType_CALL_TRANSFER_REGISTRATION",0,async function(done){ + let caseName = 'Telephony_Call_CallTransferSettingType_CALL_TRANSFER_REGISTRATION'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(3).assertEqual(call.CallTransferSettingType.CALL_TRANSFER_REGISTRATION); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_CallTransferSettingType_CALL_TRANSFER_ERASURE + * @tc.name Enum CallTransferSettingType + * @tc.desc Enum value test + */ + it("Telephony_Call_CallTransferSettingType_CALL_TRANSFER_ERASURE",0, function(done){ + let caseName = 'Telephony_Call_CallTransferSettingType_CALL_TRANSFER_ERASURE'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(4).assertEqual(call.CallTransferSettingType.CALL_TRANSFER_ERASURE); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_CallAbilityEventId_EVENT_DIAL_NO_CARRIER + * @tc.name Enum CallAbilityEventId + * @tc.desc Enum value test + */ + it("Telephony_Call_CallAbilityEventId_EVENT_DIAL_NO_CARRIER",0, function(done){ + let caseName = 'Telephony_Call_CallAbilityEventId_EVENT_DIAL_NO_CARRIER'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(1).assertEqual(call.CallAbilityEventId.EVENT_DIAL_NO_CARRIER); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_CallAbilityEventId_EVENT_INVALID_FDN_NUMBER + * @tc.name Enum CallAbilityEventId + * @tc.desc Enum value test + */ + it("Telephony_Call_CallAbilityEventId_EVENT_INVALID_FDN_NUMBER",0, function(done){ + let caseName = 'Telephony_Call_CallAbilityEventId_EVENT_INVALID_FDN_NUMBER'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(2).assertEqual(call.CallAbilityEventId.EVENT_INVALID_FDN_NUMBER); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_CallTransferInfo_Type + * @tc.name Interface CallTransferInfo + * @tc.desc Interface value test + */ + it('Telephony_Call_CallTransferInfo_Type', 0, function (done) { + let caseName = 'Telephony_Call_CallTransferInfo_Type'; + console.log(`==========> ${caseName} Test start ==========>`); + let callTransferInfo = {transferNum:'10000000001', type: 2, settingType: 1} + expect(callTransferInfo.type === 2).assertTrue(); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_CallTransferResult_Status + * @tc.name Interface CallTransferResult + * @tc.desc Interface value test + */ + it('Telephony_Call_CallTransferResult_Status', 0, function (done) { + let caseName = 'Telephony_Call_CallTransferResult_Status'; + console.log(`==========> ${caseName} Test start ==========>`); + let callTransferResult = {status:0, number: '10000000001'} + expect(callTransferResult.status === 0).assertTrue(); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_CallTransferResult_Number + * @tc.name Interface CallTransferResult + * @tc.desc Interface value test + */ + it('Telephony_Call_CallTransferResult_Number', 0, function (done) { + let caseName = 'Telephony_Call_CallTransferResult_Number'; + console.log(`==========> ${caseName} Test start ==========>`); + let callTransferResult = {status:0, number: '10000000001'} + expect(callTransferResult.number === '10000000001').assertTrue(); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_CallAttributeOptions_CallId + * @tc.name Interface CallAttributeOptions + * @tc.desc Interface value test + */ + it('Telephony_Call_CallAttributeOptions_CallId', 0, function (done) { + let caseName = 'Telephony_Call_CallAttributeOptions_CallId'; + console.log(`==========> ${caseName} Test start ==========>`); + let callAttributeOptions = {call:1}; + expect(callAttributeOptions.call === 1).assertTrue(); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_CallRestrictionInfo_Type + * @tc.name Interface CallRestrictionInfo + * @tc.desc Interface value test + */ + it('Telephony_Call_CallRestrictionInfo_Type', 0, function (done) { + let caseName = 'Telephony_Call_CallRestrictionInfo_Type'; + console.log(`==========> ${caseName} Test start ==========>`); + let callRestrictionInfo = {type:0, password: '123456', mode:1} + expect(callRestrictionInfo.type === 0).assertTrue(); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_CallRestrictionInfo_Mode + * @tc.name Interface CallRestrictionInfo + * @tc.desc Interface value test + */ + it('Telephony_Call_CallRestrictionInfo_Mode', 0, function (done) { + let caseName = 'Telephony_Call_CallRestrictionInfo_Mode'; + console.log(`==========> ${caseName} Test start ==========>`); + let callRestrictionInfo = {type:0, password: '123456', mode:1} + expect(callRestrictionInfo.mode === 1).assertTrue(); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_CallEventOptions_EventId + * @tc.name Interface CallEventOptions + * @tc.desc Interface value test + */ + it('Telephony_Call_CallEventOptions_EventId', 0, function (done) { + let caseName = 'Telephony_Call_CallEventOptions_EventId'; + console.log(`==========> ${caseName} Test start ==========>`); + let callEventOptions = {eventId:1} + expect(callEventOptions.eventId === 1).assertTrue(); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_DisconnectedDetails_NO_ROUTE_TO_DESTINATION + * @tc.name Enum DisconnectedDetails + * @tc.desc Enum value test + */ + it("Telephony_Call_DisconnectedDetails_UNASSIGNED_NUMBER",0,async function(done){ + let caseName = 'Telephony_Call_DisconnectedDetails_UNASSIGNED_NUMBER'; + console.log(`==========> ${caseName} Test start ==========>`); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(1).assertEqual(call.DisconnectedDetails.UNASSIGNED_NUMBER); + expect(3).assertEqual(call.DisconnectedDetails.NO_ROUTE_TO_DESTINATION); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + + /** + * @tc.number Telephony_Call_DisconnectedDetails_CHANNEL_UNACCEPTABLE + * @tc.name Enum DisconnectedDetails + * @tc.desc Enum value test + */ + it("Telephony_Call_DisconnectedDetails_CHANNEL_UNACCEPTABLE",0,async function(done){ + let caseName = 'Telephony_Call_DisconnectedDetails_CHANNEL_UNACCEPTABLE'; + console.log(`==========> ${caseName} Test start ==========>`); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(6).assertEqual(call.DisconnectedDetails.CHANNEL_UNACCEPTABLE); + expect(8).assertEqual(call.DisconnectedDetails.OPERATOR_DETERMINED_BARRING); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_DisconnectedDetails_NORMAL_CALL_CLEARING + * @tc.name Enum DisconnectedDetails + * @tc.desc Enum value test + */ + it("Telephony_Call_DisconnectedDetails_NORMAL_CALL_CLEARING",0,async function(done){ + let caseName = 'Telephony_Call_DisconnectedDetails_NORMAL_CALL_CLEARING'; + console.log(`==========> ${caseName} Test start ==========>`); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(16).assertEqual(call.DisconnectedDetails.NORMAL_CALL_CLEARING); + expect(17).assertEqual(call.DisconnectedDetails.USER_BUSY); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_DisconnectedDetails_NO_USER_RESPONDING + * @tc.name Enum DisconnectedDetails + * @tc.desc Enum value test + */ + it("Telephony_Call_DisconnectedDetails_NO_USER_RESPONDING",0,async function(done){ + let caseName = 'Telephony_Call_DisconnectedDetails_NO_USER_RESPONDING'; + console.log(`==========> ${caseName} Test start ==========>`); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(18).assertEqual(call.DisconnectedDetails.NO_USER_RESPONDING); + expect(19).assertEqual(call.DisconnectedDetails.USER_ALERTING_NO_ANSWER); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_DisconnectedDetails_CALL_REJECTED + * @tc.name Enum DisconnectedDetails + * @tc.desc Enum value test + */ + it("Telephony_Call_DisconnectedDetails_CALL_REJECTED",0,async function(done){ + let caseName = 'Telephony_Call_DisconnectedDetails_CALL_REJECTED'; + console.log(`==========> ${caseName} Test start ==========>`); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(21).assertEqual(call.DisconnectedDetails.CALL_REJECTED); + expect(22).assertEqual(call.DisconnectedDetails.NUMBER_CHANGED); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_DisconnectedDetails_DESTINATION_OUT_OF_ORDER + * @tc.name Enum DisconnectedDetails + * @tc.desc Enum value test + */ + it("Telephony_Call_DisconnectedDetails_DESTINATION_OUT_OF_ORDER",0,async function(done){ + let caseName = 'Telephony_Call_DisconnectedDetails_DESTINATION_OUT_OF_ORDER'; + console.log(`==========> ${caseName} Test start ==========>`); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(27).assertEqual(call.DisconnectedDetails.DESTINATION_OUT_OF_ORDER); + expect(28).assertEqual(call.DisconnectedDetails.INVALID_NUMBER_FORMAT); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_DisconnectedDetails_DESTINATION_NETWORK_OUT_OF_ORDER + * @tc.name Enum DisconnectedDetails + * @tc.desc Enum value test + */ + it("Telephony_Call_DisconnectedDetails_DESTINATION_NETWORK_OUT_OF_ORDER",0,async function(done){ + let caseName = 'Telephony_Call_DisconnectedDetails_NETWORK_OUT_OF_ORDER'; + console.log(`==========> ${caseName} Test start ==========>`); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(38).assertEqual(call.DisconnectedDetails.NETWORK_OUT_OF_ORDER); + expect(41).assertEqual(call.DisconnectedDetails.TEMPORARY_FAILURE); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_DisconnectedDetails_INVALID_PARAMETER + * @tc.name Enum DisconnectedDetails + * @tc.desc Enum value test + */ + it("Telephony_Call_DisconnectedDetails_INVALID_PARAMETER",0,async function(done){ + let caseName = 'Telephony_Call_DisconnectedDetails_INVALID_PARAMETER'; + console.log(`==========> ${caseName} Test start ==========>`); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(1025).assertEqual(call.DisconnectedDetails.INVALID_PARAMETER); + expect(1026).assertEqual(call.DisconnectedDetails.SIM_NOT_EXIT); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_DisconnectedDetails_SIM_PIN_NEED + * @tc.name Enum DisconnectedDetails + * @tc.desc Enum value test + */ + it("Telephony_Call_DisconnectedDetails_SIM_PIN_NEED",0,async function(done){ + let caseName = 'Telephony_Call_DisconnectedDetails_SIM_PIN_NEED'; + console.log(`==========> ${caseName} Test start ==========>`); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(1027).assertEqual(call.DisconnectedDetails.SIM_PIN_NEED); + expect(1029).assertEqual(call.DisconnectedDetails.CALL_NOT_ALLOW); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Call_DisconnectedDetails_SIM_INVALID + * @tc.name Enum DisconnectedDetails + * @tc.desc Enum value test + */ + it("Telephony_Call_DisconnectedDetails_SIM_INVALID",0,async function(done){ + let caseName = 'Telephony_Call_DisconnectedDetails_SIM_INVALID'; + console.log(`==========> ${caseName} Test start ==========>`); + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + expect(1045).assertEqual(call.DisconnectedDetails.SIM_INVALID); + expect(1045).assertEqual(call.DisconnectedDetails.SIM_INVALID); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + }); + +} \ No newline at end of file diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/ConvertOptionsJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/ConvertOptionsJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e1cd292ba8f6995b95cd93843a0544d1af465c1 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/ConvertOptionsJsunit.test.ets @@ -0,0 +1,1262 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import ConvertXML from '@ohos.convertxml' +export default function convertOptionsJsunit() { + describe('XmlTest',function () { + console.log("************* settings Test start*************"); + it('Telephony_convertxml_ConvertXML_0100', 0, async function (done) { + var xml = + '' + + '' + + ' Happy ' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false,trim :true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_0200', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreDeclaration: true}); + var str1 = '{"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_0300', 0,async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreDeclaration: true}); + var str1 = '{"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_0400', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreAttributes: true}); + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_0500', 0,async function (done) { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreComment: true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_0600', 0, async function (done) { + var xml = + '' + + '' + + ' ]]>'+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreCDATA: true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_0700', 0, async function (done) { + var xml = + '' + + ''+ + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreDoctype: true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_0800', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreText: true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title"},'+ + '{"_type":"element",'+ + '"_name":"todo"},'+ + '{"_type":"element",'+ + '"_name":"todo"}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_0900', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, declarationKey: "123"}) + var str1 = '{"123":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_1000', 0, async function (done) { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, instructionKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"123":"there",'+ + '"_type":"instruction",'+ + '"_name":"go"},'+ + '{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_1100', 0, async function (done) { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, attributesKey: "123"}) + var str1 = '{"_declaration":{"123":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"123":{"importance":"high",'+ + '"logged":"true"},'+ + '"_type":"element",'+ + '"_name":"note",'+ + '"_elements":[{"_type":"instruction",'+ + '"_name":"go",'+ + '"_instruction":"there"},'+ + '{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_1200', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, textKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"123":"Happy",'+ + '"_type":"text"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"123":"Work",'+ + '"_type":"text"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"123":"Play",'+ + '"_type":"text"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_1300', 0, async function (done) { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, cdataKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"123":"1 is < 2",'+ + '"_type":"cdata"},'+ + '{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_1400', 0, async function (done) { + var xml = + '' + + ''+ + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, doctypeKey: 'doctype'}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"doctype","doctype":"foo"},'+ + '{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_1500', 0, async function (done) { + var xml = + '' + + ''+ + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, commentKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"123":"note",'+ + '"_type":"comment"},'+ + '{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_1600', 0, async function (done) { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, parentKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"a",'+ + '"_elements":[{"_type":"element",'+ + '"_name":"b"}]},'+ + '{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_1700', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, typeKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"123":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"123":"element",'+ + '"_name":"title",'+ + '"_elements":[{"123":"text",'+ + '"_text":"Happy"}]},'+ + '{"123":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"123":"text",'+ + '"_text":"Work"}]},'+ + '{"123":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"123":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_1800', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, nameKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"123":"note",'+ + '"_type":"element",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"123":"title",'+ + '"_type":"element",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"123":"todo",'+ + '"_type":"element",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"123":"todo",'+ + '"_type":"element",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_1900', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, elementsKey: "123"}) + var str1 = '{"123":[{"123":[{"123":[{"_type":"text",'+ + '"_text":"Happy"}],'+ + '"_type":"element",'+ + '"_name":"title"},'+ + '{"123":[{"_type":"text",'+ + '"_text":"Work"}],'+ + '"_type":"element",'+ + '"_name":"todo"},'+ + '{"123":[{"_type":"text",'+ + '"_text":"Play"}],'+ + '"_type":"element",'+ + '"_name":"todo"}],'+ + '"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"}}],'+ + '"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}}}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_2000', 0, async function (done) { + var xml = + '' + + '' + + ' Happy ' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false,trim :true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_2100', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreDeclaration: true}); + var str1 = '{"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_2200', 0,async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreDeclaration: true}); + var str1 = '{"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_2300', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreAttributes: true}); + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_2400', 0,async function (done) { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreComment: true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_2500', 0, async function (done) { + var xml = + '' + + '' + + ' ]]>'+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreCDATA: true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_2600', 0, async function (done) { + var xml = + '' + + ''+ + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreDoctype: true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_2700', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreText: true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title"},'+ + '{"_type":"element",'+ + '"_name":"todo"},'+ + '{"_type":"element",'+ + '"_name":"todo"}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_2800', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, declarationKey: "456"}) + var str1 = '{"456":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_2900', 0, async function (done) { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, instructionKey: "456"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"456":"there",'+ + '"_type":"instruction",'+ + '"_name":"go"},'+ + '{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_3000', 0, async function (done) { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, attributesKey: "456"}) + var str1 = '{"_declaration":{"456":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"456":{"importance":"high",'+ + '"logged":"true"},'+ + '"_type":"element",'+ + '"_name":"note",'+ + '"_elements":[{"_type":"instruction",'+ + '"_name":"go",'+ + '"_instruction":"there"},'+ + '{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_3100', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, textKey: "456"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"456":"Happy",'+ + '"_type":"text"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"456":"Work",'+ + '"_type":"text"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"456":"Play",'+ + '"_type":"text"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_3200', 0, async function (done) { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, cdataKey: "456"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"456":"1 is < 2",'+ + '"_type":"cdata"},'+ + '{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_3300', 0, async function (done) { + var xml = + '' + + ''+ + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, doctypeKey: 'doctype_next'}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"doctype","doctype_next":"foo"},'+ + '{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_3400', 0, async function (done) { + var xml = + '' + + ''+ + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, commentKey: "456"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"456":"note",'+ + '"_type":"comment"},'+ + '{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_3500', 0, async function (done) { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, parentKey: "456"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"a",'+ + '"_elements":[{"_type":"element",'+ + '"_name":"b"}]},'+ + '{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_3600', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, typeKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"123":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"123":"element",'+ + '"_name":"title",'+ + '"_elements":[{"123":"text",'+ + '"_text":"Happy"}]},'+ + '{"123":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"123":"text",'+ + '"_text":"Work"}]},'+ + '{"123":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"123":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_3700', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, nameKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"123":"note",'+ + '"_type":"element",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"123":"title",'+ + '"_type":"element",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"123":"todo",'+ + '"_type":"element",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"123":"todo",'+ + '"_type":"element",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + done(); + }) + + it('Telephony_convertxml_ConvertXML_3800', 0, async function (done) { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, elementsKey: "123"}) + var str1 = '{"123":[{"123":[{"123":[{"_type":"text",'+ + '"_text":"Happy"}],'+ + '"_type":"element",'+ + '"_name":"title"},'+ + '{"123":[{"_type":"text",'+ + '"_text":"Work"}],'+ + '"_type":"element",'+ + '"_name":"todo"},'+ + '{"123":[{"_type":"text",'+ + '"_text":"Play"}],'+ + '"_type":"element",'+ + '"_name":"todo"}],'+ + '"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"}}],'+ + '"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}}}' + expect(result1).assertEqual(str1); + done(); + }) + }) +} \ No newline at end of file diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/DataJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/DataJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e633a798e1867222c805e744c4e672c0dda5758d --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/DataJsunit.test.ets @@ -0,0 +1,166 @@ +/** + * Copyright (C) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index.ets' +import data from '@ohos.telephony.data'; + + +export function toString(data) { + if (typeof data === 'object') { + return JSON.stringify(data); + } else { + return data; + } +} + +export default function dataJsunit() { + describe('dataTest', function () { + console.log("==========> data Test start ==========>"); + + + /** + * @tc.number Telephony_Data_DataFlowType_DATA_FLOW_TYPE_NONE + * @tc.name Enum DataFlowType + * @tc.desc Enum value test + */ + it("Telephony_Data_DataFlowType_DATA_FLOW_TYPE_NONE", 0, async function (done) { + let caseName = 'Telephony_Data_DataFlowType_DATA_FLOW_TYPE_NONE'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(0).assertEqual(data.DataFlowType.DATA_FLOW_TYPE_NONE); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Data_DataFlowType_DATA_FLOW_TYPE_DOWN + * @tc.name Enum DataFlowType + * @tc.desc Enum value test + */ + it("Telephony_Data_DataFlowType_DATA_FLOW_TYPE_DOWN", 0, async function (done) { + let caseName = 'Telephony_Data_DataFlowType_DATA_FLOW_TYPE_DOWN'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(1).assertEqual(data.DataFlowType.DATA_FLOW_TYPE_DOWN); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Data_DataFlowType_DATA_FLOW_TYPE_UP + * @tc.name Enum DataFlowType + * @tc.desc Enum value test + */ + it("Telephony_Data_DataFlowType_DATA_FLOW_TYPE_UP", 0, async function (done) { + let caseName = 'Telephony_Data_DataFlowType_DATA_FLOW_TYPE_UP'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(2).assertEqual(data.DataFlowType.DATA_FLOW_TYPE_UP); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Data_DataFlowType_DATA_FLOW_TYPE_UP + * @tc.name Enum DataFlowType + * @tc.desc Enum value test + */ + it("Telephony_Data_DataFlowType_DATA_FLOW_TYPE_UP_DOWN", 0, async function (done) { + let caseName = 'Telephony_Data_DataFlowType_DATA_FLOW_TYPE_UP_DOWN'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(3).assertEqual(data.DataFlowType.DATA_FLOW_TYPE_UP_DOWN); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Data_DataFlowType_DATA_FLOW_TYPE_DORMANT + * @tc.name Enum DataFlowType + * @tc.desc Enum value test + */ + it("Telephony_Data_DataFlowType_DATA_FLOW_TYPE_DORMANT", 0, async function (done) { + let caseName = 'Telephony_Data_DataFlowType_DATA_FLOW_TYPE_DORMANT'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(4).assertEqual(data.DataFlowType.DATA_FLOW_TYPE_DORMANT); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Data_DataConnectState_DATA_STATE_UNKNOWN + * @tc.name Enum DataConnectState + * @tc.desc Enum value test + */ + it("Telephony_Data_DataConnectState_DATA_STATE_UNKNOWN", 0, async function (done) { + let caseName = 'Telephony_Data_DataConnectState_DATA_DATA_STATE_UNKNOWN'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(-1).assertEqual(data.DataConnectState.DATA_STATE_UNKNOWN); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Data_DataConnectState_DATA_STATE_DISCONNECTED + * @tc.name Enum DataConnectState + * @tc.desc Enum value test + */ + it("Telephony_Data_DataConnectState_DATA_STATE_DISCONNECTED", 0, async function (done) { + let caseName = 'Telephony_Data_DataConnectState_DATA_DATA_STATE_DISCONNECTED'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(0).assertEqual(data.DataConnectState.DATA_STATE_DISCONNECTED); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Data_DataConnectState_DATA_STATE_CONNECTING + * @tc.name Enum DataConnectState + * @tc.desc Enum value test + */ + it("Telephony_Data_DataConnectState_DATA_STATE_CONNECTING", 0, async function (done) { + let caseName = 'Telephony_Data_DataConnectState_DATA_STATE_CONNECTING'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(1).assertEqual(data.DataConnectState.DATA_STATE_CONNECTING); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Data_DataConnectState_DATA_STATE_CONNECTED + * @tc.name Enum DataConnectState + * @tc.desc Enum value test + */ + it("Telephony_Data_DataConnectState_DATA_STATE_CONNECTED", 0, async function (done) { + let caseName = 'Telephony_Data_DataConnectState_DATA_STATE_CONNECTED'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(2).assertEqual(data.DataConnectState.DATA_STATE_CONNECTED); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + /** + * @tc.number Telephony_Data_DataConnectState_DATA_STATE_SUSPENDED + * @tc.name Enum DataConnectState + * @tc.desc Enum value test + */ + it("Telephony_Data_DataConnectState_DATA_STATE_SUSPENDED", 0, async function (done) { + let caseName = 'Telephony_Data_DataConnectState_DATA_STATE_SUSPENDED'; + console.log(`==========> ${caseName} Test start ==========>`); + expect(3).assertEqual(data.DataConnectState.DATA_STATE_SUSPENDED); + console.log(`==========> ${caseName} Test end ==========>`); + done(); + }); + + + }); +} + + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/List.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5ebbc36cbeebfd745bd354e169e3664b4de948b0 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2021 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. + */ + +//other import +import convertOptionsJsunit from './ConvertOptionsJsunit.test.ets' +import radioJsunit from './RadioJsunit.test.ets' +import radioSecondJsunit from './RadioSecondJsunit.test.ets' +import observerJsunit from './ObserverJsunit.test.ets' +import smsUiJsunit from './SmsMmsJsunit.test.ets'; +import callJsunit from './CallJsunit.test.ets'; +import dataJsunit from './DataJsunit.test.ets'; +import simJsunit from './SimJsunit.test.ets'; +import statisticsUiJsunit from './StatisticsJsunit.test.ets'; + +export default function testsuite() { + //other + dataJsunit(); + callJsunit(); + smsUiJsunit(); + convertOptionsJsunit(); + observerJsunit(); + radioJsunit(); + radioSecondJsunit(); + simJsunit(); + statisticsUiJsunit(); +} \ No newline at end of file diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/ObserverJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/ObserverJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7aaeec92e83a4a23a5d8573115ad28647dc6420f --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/ObserverJsunit.test.ets @@ -0,0 +1,766 @@ +// @ts-nocheck +/** + * Copyright (C) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import observer from '@ohos.telephony.observer' +import cellular from '@ohos.telephony.data' +import radio from '@ohos.telephony.radio' +import utils from './Utils.ets' +import {SimStateData} from '@ohos.telephony.observer' +import {LockReason} from '@ohos.telephony.observer' +import sim from "@ohos.telephony.sim" + +export default function observerJsunit() { + describe('ObserverTest', function () { + console.log("************* Observer Test start *************") + + const SLOT_0 = 0; + const SLOT_2 = -1; + + /* + * @tc.number : Telephony_observer_observer_DataConnectState_0100 + * @tc.name : DataConnectState + * @tc.desc : check the getCellularDataState callback to verify the call back data + */ + it('Telephony_observer_observer_DataConnectState_0100', 0, function (done) { + console.log("************* Telephony_observer_observer_DataConnectState_0100 Test start *************") + cellular.getCellularDataState((err, data) => { + if (!err) { + var dataConnectStateList = [cellular.DataConnectState.DATA_STATE_UNKNOWN, + cellular.DataConnectState.DATA_STATE_DISCONNECTED, + cellular.DataConnectState.DATA_STATE_CONNECTING, + cellular.DataConnectState.DATA_STATE_CONNECTED, + cellular.DataConnectState.DATA_STATE_SUSPENDED] + expect(dataConnectStateList.indexOf(data) >= 0).assertTrue() + done(); + return; + } + console.log("Telephony_CellularData_getCellularDataState_0100 end"); + done() + }) + console.log("************* Telephony_observer_observer_DataConnectState_0100 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_observer_DataConnectState_0200 + * @tc.name : DataConnectState + * @tc.desc : check the getCellularDataState callback to verify the call back data + */ + it('Telephony_observer_observer_DataConnectState_0200', 0, function (done) { + console.log("************* Telephony_observer_observer_DataConnectState_0200 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + // console.log(observer.DataConnectState) + console.log("************* Telephony_observer_observer_DataConnectState_0200 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_observer_RatType_0100 + * @tc.name : RatType + * @tc.desc : Obtains the data connect state + */ + it('Telephony_observer_observer_RatType_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_RatType_0100 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + // console.log(observer.RatType) + console.log("************* Telephony_observer_observer_RatType_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_on_networkStateChange_0100 + * @tc.name : on_networkStateChange + * @tc.desc : call the on method of networkStateChange + */ + it('Telephony_observer_observer_on_networkStateChange_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_on_networkStateChange_0100 Test start *************") + observer.on('networkStateChange', (networkState) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_on_networkStateChange_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_on_networkStateChange_0200 + * @tc.name : on_networkStateChange + * @tc.desc : call the on method of networkStateChange + */ + it('Telephony_observer_observer_on_networkStateChange_0200', 0, async function (done) { + console.log("************* Telephony_observer_observer_on_networkStateChange_0200 Test start *************") + observer.on('networkStateChange', { + slotId: SLOT_0 + }, (networkState) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_on_networkStateChange_0200 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_off_networkStateChange_0100 + * @tc.name : off_networkStateChange + * @tc.desc : call the off method of networkStateChange + */ + it('Telephony_observer_observer_off_networkStateChange_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_off_networkStateChange_0100 Test start *************") + observer.off('networkStateChange', (networkState) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_off_networkStateChange_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_on_signalInfoChange_0100 + * @tc.name : on_signalInfoChange + * @tc.desc : call the on method of signalInfoChange + */ + it('Telephony_observer_observer_on_signalInfoChange_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_on_signalInfoChange_0100 Test start *************") + observer.on('signalInfoChange', (signalInformation) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_on_signalInfoChange_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_on_signalInfoChange_0200 + * @tc.name : on_signalInfoChange + * @tc.desc : call the on method of signalInfoChange + */ + it('Telephony_observer_observer_on_signalInfoChange_0200', 0, async function (done) { + console.log("************* Telephony_observer_observer_on_signalInfoChange_0200 Test start *************") + observer.on('signalInfoChange', { + slotId: SLOT_0 + }, (signalInformation) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_on_signalInfoChange_0200 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_off_signalInfoChange_0100 + * @tc.name : off_signalInfoChange + * @tc.desc : call the off method of signalInfoChange + */ + it('Telephony_observer_observer_off_signalInfoChange_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_off_signalInfoChange_0100 Test start *************") + observer.off('signalInfoChange', (networkState) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_off_signalInfoChange_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_on_cellInfoChange_0100 + * @tc.name : on_cellInfoChange + * @tc.desc : call the on method of cellInfoChange + */ + it('Telephony_observer_observer_on_cellInfoChange_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_on_cellInfoChange_0100 Test start *************") + observer.on('cellInfoChange', (cellInformation) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_on_cellInfoChange_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_on_cellInfoChange_0200 + * @tc.name : on_cellInfoChange + * @tc.desc : call the on method of cellInfoChange + */ + it('Telephony_observer_observer_on_cellInfoChange_0200', 0, async function (done) { + console.log("************* Telephony_observer_observer_on_cellInfoChange_0200 Test start *************") + observer.on('cellInfoChange', { + slotId: SLOT_0 + }, (cellInformation) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_on_cellInfoChange_0200 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_off_cellInfoChange_0100 + * @tc.name : off_cellInfoChange + * @tc.desc : call the off method of cellInfoChange + */ + it('Telephony_observer_observer_off_cellInfoChange_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_off_cellInfoChange_0100 Test start *************") + observer.off('cellInfoChange', (cellInformation) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_off_cellInfoChange_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_on_cellularDataConnectionStateChange_0100 + * @tc.name : on_cellularDataConnectionStateChange + * @tc.desc : call the on method of cellularDataConnectionStateChange + */ + it('Telephony_observer_observer_on_cellularDataConnectionStateChange_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0100 Test start *************") + observer.on('cellularDataConnectionStateChange', (data) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_on_cellularDataConnectionStateChange_0200 + * @tc.name : on_cellularDataConnectionStateChange + * @tc.desc : call the on method of cellularDataConnectionStateChange + */ + it('Telephony_observer_observer_on_cellularDataConnectionStateChange_0200', 0, async function (done) { + console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0200 Test start *************") + observer.on('cellularDataConnectionStateChange', { + slotId: SLOT_0 + }, (data) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0200 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_off_cellularDataConnectionStateChange_0100 + * @tc.name : off_cellularDataConnectionStateChange + * @tc.desc : call the off method of cellularDataConnectionStateChange + */ + it('Telephony_observer_observer_off_cellularDataConnectionStateChange_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_off_cellularDataConnectionStateChange_0100 Test start *************") + observer.off('cellularDataConnectionStateChange', (data) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_off_cellularDataConnectionStateChange_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_on_cellularDataFlowChange_0100 + * @tc.name : on_cellularDataFlowChange + * @tc.desc : call the on method of cellularDataFlowChange + */ + it('Telephony_observer_observer_on_cellularDataFlowChange_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0100 Test start *************") + observer.on('cellularDataFlowChange', (data) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_on_cellularDataFlowChange_0200 + * @tc.name : on_cellularDataFlowChange + * @tc.desc : call the on method of cellularDataFlowChange + */ + it('Telephony_observer_observer_on_cellularDataFlowChange_0200', 0, async function (done) { + console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0200 Test start *************") + observer.on('cellularDataFlowChange', { + slotId: SLOT_0 + }, (data) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0200 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_off_cellularDataFlowChange_0100 + * @tc.name : off_cellularDataFlowChange + * @tc.desc : call the off method of cellularDataFlowChange + */ + it('Telephony_observer_observer_off_cellularDataFlowChange_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_off_cellularDataFlowChange_0100 Test start *************") + observer.off('cellularDataFlowChange', (data) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_off_cellularDataFlowChange_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_on_callStateChange_0100 + * @tc.name : on_callStateChange + * @tc.desc : call the on method of callStateChange + */ + it('Telephony_observer_observer_on_callStateChange_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_on_callStateChange_0100 Test start *************") + observer.on('callStateChange', (data) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_on_callStateChange_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_on_callStateChange_0200 + * @tc.name : on_callStateChange + * @tc.desc : call the on method of callStateChange + */ + it('Telephony_observer_observer_on_callStateChange_0200', 0, async function (done) { + console.log("************* Telephony_observer_observer_on_callStateChange_0200 Test start *************") + observer.on('callStateChange', { + slotId: SLOT_0 + }, (data) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_on_callStateChange_0200 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_off_callStateChange_0100 + * @tc.name : off_callStateChange + * @tc.desc : call the off method of callStateChange + */ + it('Telephony_observer_observer_off_callStateChange_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_off_callStateChange_0100 Test start *************") + observer.off('callStateChange', (data) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_off_callStateChange_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_on_simStateChange_0100 + * @tc.name : on_simStateChange + * @tc.desc : call the on method of simStateChange + */ + it('Telephony_observer_observer_on_simStateChange_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_on_simStateChange_0100 Test start *************") + observer.on('simStateChange', (data) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_on_simStateChange_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_on_simStateChange_0200 + * @tc.name : on_simStateChange + * @tc.desc : call the on method of simStateChange + */ + it('Telephony_observer_observer_on_simStateChange_0200', 0, async function (done) { + console.log("************* Telephony_observer_observer_on_simStateChange_0200 Test start *************") + observer.on('simStateChange', { + slotId: SLOT_0 + }, (data) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_on_simStateChange_0200 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_observer_off_simStateChange_0100 + * @tc.name : off_simStateChange + * @tc.desc : call the off method of simStateChange + */ + it('Telephony_observer_observer_off_simStateChange_0100', 0, async function (done) { + console.log("************* Telephony_observer_observer_off_simStateChange_0100 Test start *************") + observer.off('simStateChange', (data) => { + expect().assertFail() + done() + return + }) + setTimeout(timeout, 3000) + console.log("************* Telephony_observer_observer_off_simStateChange_0100 Test end *************") + done() + }) + + /* + * @tc.number : Telephony_observer_SimStateData_type_0100 + * @tc.name : type + * @tc.desc : check the type value of SimStateData object + */ + it('Telephony_observer_SimStateData_type_0100', 0, function (done) { + console.log("************* Telephony_observer_SimStateData_type_0100 Test start *************") + const unknown: SimStateData = { + type: sim.CardType.UNKNOWN_CARD + } + expect(-1).assertEqual(unknown.type) + + const singleMode: SimStateData = { + type: sim.CardType.SINGLE_MODE_SIM_CARD + } + expect(10).assertEqual(singleMode.type) + + const singleModeUSim: SimStateData = { + type: sim.CardType.SINGLE_MODE_USIM_CARD + } + expect(20).assertEqual(singleModeUSim.type) + done() + console.log("************* Telephony_observer_SimStateData_type_0100 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_SimStateData_type_0200 + * @tc.name : type + * @tc.desc : check the type value of SimStateData object + */ + it('Telephony_observer_SimStateData_type_0200', 0, function (done) { + console.log("************* Telephony_observer_SimStateData_type_0200 Test start *************") + const singleModeRUim: SimStateData = { + type: sim.CardType.SINGLE_MODE_RUIM_CARD + } + expect(30).assertEqual(singleModeRUim.type) + + const dualModeCG: SimStateData = { + type: sim.CardType.DUAL_MODE_CG_CARD + } + expect(40).assertEqual(dualModeCG.type) + + const ctNationalRoaming: SimStateData = { + type: sim.CardType.CT_NATIONAL_ROAMING_CARD + } + expect(41).assertEqual(ctNationalRoaming.type) + done() + console.log("************* Telephony_observer_SimStateData_type_0200 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_SimStateData_type_0300 + * @tc.name : type + * @tc.desc : check the type value of SimStateData object + */ + it('Telephony_observer_SimStateData_type_0300', 0, function (done) { + console.log("************* Telephony_observer_SimStateData_type_0300 Test start *************") + const cuDualMode: SimStateData = { + type: sim.CardType.CU_DUAL_MODE_CARD + } + expect(42).assertEqual(cuDualMode.type) + + const dualModeTelecomLte: SimStateData = { + type: sim.CardType.DUAL_MODE_TELECOM_LTE_CARD + } + expect(43).assertEqual(dualModeTelecomLte.type) + + const dualModeUg: SimStateData = { + type: sim.CardType.DUAL_MODE_UG_CARD + } + expect(50).assertEqual(dualModeUg.type) + + const singleModeIsim: SimStateData = { + type: sim.CardType.SINGLE_MODE_ISIM_CARD + } + expect(60).assertEqual(singleModeIsim.type) + done() + console.log("************* Telephony_observer_SimStateData_type_0300 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_SimStateData_state_0100 + * @tc.name : state + * @tc.desc : check the state value of SimStateData object + */ + it('Telephony_observer_SimStateData_state_0100', 0, function (done) { + console.log("************* Telephony_observer_SimStateData_state_0100 Test start *************") + const unknown: SimStateData = { + state: sim.SimState.SIM_STATE_UNKNOWN + } + expect(0).assertEqual(unknown.state) + const notPresent: SimStateData = { + state: sim.SimState.SIM_STATE_NOT_PRESENT + } + expect(1).assertEqual(notPresent.state) + done() + console.log("************* Telephony_observer_SimStateData_state_0100 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_SimStateData_state_0200 + * @tc.name : state + * @tc.desc : check the state value of SimStateData object + */ + it('Telephony_observer_SimStateData_state_0200', 0, function (done) { + console.log("************* Telephony_observer_SimStateData_state_0200 Test start *************") + const locked: SimStateData = { + state: sim.SimState.SIM_STATE_LOCKED + } + expect(2).assertEqual(locked.state) + const notReady: SimStateData = { + state: sim.SimState.SIM_STATE_NOT_READY + } + expect(3).assertEqual(notReady.state) + done() + console.log("************* Telephony_observer_SimStateData_state_0200 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_SimStateData_state_0300 + * @tc.name : state + * @tc.desc : check the state value of SimStateData object + */ + it('Telephony_observer_SimStateData_state_0300', 0, function (done) { + console.log("************* Telephony_observer_SimStateData_state_0300 Test start *************") + const ready: SimStateData = { + state: sim.SimState.SIM_STATE_READY + } + expect(4).assertEqual(ready.state) + const loaded: SimStateData = { + state: sim.SimState.SIM_STATE_LOADED + } + expect(5).assertEqual(loaded.state) + done() + console.log("************* Telephony_observer_SimStateData_state_0300 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_LockReason_SIM_NONE_0100 + * @tc.name : SIM_NONE + * @tc.desc : check the SIM_NONE property of LockReason + */ + it('Telephony_observer_LockReason_SIM_NONE_0100', 0, function (done) { + console.log("************* Telephony_observer_LockReason_SIM_NONE_0100 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + // expect(0).assertEqual(LockReason.SIM_NONE) + done() + console.log("************* Telephony_observer_LockReason_SIM_NONE_0100 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_LockReason_SIM_PN_PUK_0100 + * @tc.name : SIM_PN_PUK + * @tc.desc : check the SIM_PN_PUK property of LockReason + */ + it('Telephony_observer_LockReason_SIM_PN_PUK_0100', 0, function (done) { + console.log("************* Telephony_observer_LockReason_SIM_PN_PUK_0100 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + // expect(4).assertEqual(LockReason.SIM_PN_PUK) + done() + console.log("************* Telephony_observer_LockReason_SIM_PN_PUK_0100 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_LockReason_SIM_PU_PIN_0100 + * @tc.name : SIM_PU_PIN + * @tc.desc : check the SIM_PU_PIN property of LockReason + */ + it('Telephony_observer_LockReason_SIM_PU_PIN_0100', 0, function (done) { + console.log("************* Telephony_observer_LockReason_SIM_PU_PIN_0100 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + // expect(5).assertEqual(LockReason.SIM_PU_PIN) + done() + console.log("************* Telephony_observer_LockReason_SIM_PU_PIN_0100 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_LockReason_SIM_PU_PUK_0100 + * @tc.name : SIM_PU_PUK + * @tc.desc : check the SIM_PU_PUK property of LockReason + */ + it('Telephony_observer_LockReason_SIM_PU_PUK_0100', 0, function (done) { + console.log("************* Telephony_observer_LockReason_SIM_PU_PUK_0100 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + // expect(6).assertEqual(LockReason.SIM_PU_PUK) + done() + console.log("************* Telephony_observer_LockReason_SIM_PU_PUK_0100 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_LockReason_SIM_PP_PIN_0100 + * @tc.name : SIM_PP_PIN + * @tc.desc : check the SIM_PP_PIN property of LockReason + */ + it('Telephony_observer_LockReason_SIM_PP_PIN_0100', 0, function (done) { + console.log("************* Telephony_observer_LockReason_SIM_PP_PIN_0100 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + // expect(7).assertEqual(LockReason.SIM_PP_PIN) + done() + console.log("************* Telephony_observer_LockReason_SIM_PP_PIN_0100 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_LockReason_SIM_PP_PUK_0100 + * @tc.name : SIM_PP_PUK + * @tc.desc : check the SIM_PP_PUK property of LockReason + */ + it('Telephony_observer_LockReason_SIM_PP_PUK_0100', 0, function (done) { + console.log("************* Telephony_observer_LockReason_SIM_PP_PUK_0100 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + // expect(8).assertEqual(LockReason.SIM_PP_PUK) + done() + console.log("************* Telephony_observer_LockReason_SIM_PP_PUK_0100 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_LockReason_SIM_PC_PIN_0100 + * @tc.name : SIM_PC_PIN + * @tc.desc : check the SIM_PC_PIN property of LockReason + */ + it('Telephony_observer_LockReason_SIM_PC_PIN_0100', 0, function (done) { + console.log("************* Telephony_observer_LockReason_SIM_PC_PIN_0100 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + // expect(9).assertEqual(LockReason.SIM_PC_PIN) + done() + console.log("************* Telephony_observer_LockReason_SIM_PC_PIN_0100 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_LockReason_SIM_PC_PUK_0100 + * @tc.name : SIM_PC_PUK + * @tc.desc : check the SIM_PC_PUK property of LockReason + */ + it('Telephony_observer_LockReason_SIM_PC_PUK_0100', 0, function (done) { + console.log("************* Telephony_observer_LockReason_SIM_PC_PUK_0100 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + // expect(10).assertEqual(LockReason.SIM_PC_PUK) + done() + console.log("************* Telephony_observer_LockReason_SIM_PC_PUK_0100 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_LockReason_SIM_SIM_PIN_0100 + * @tc.name : SIM_SIM_PIN + * @tc.desc : check the SIM_SIM_PIN property of LockReason + */ + it('Telephony_observer_LockReason_SIM_SIM_PIN_0100', 0, function (done) { + console.log("************* Telephony_observer_LockReason_SIM_SIM_PIN_0100 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + // expect(11).assertEqual(LockReason.SIM_SIM_PIN) + done() + console.log("************* Telephony_observer_LockReason_SIM_SIM_PIN_0100 Test end *************") + }) + + /* + * @tc.number : Telephony_observer_LockReason_SIM_SIM_PUK_0100 + * @tc.name : SIM_SIM_PUK + * @tc.desc : check the SIM_SIM_PUK property of LockReason + */ + it('Telephony_observer_LockReason_SIM_SIM_PUK_0100', 0, function (done) { + console.log("************* Telephony_observer_LockReason_SIM_SIM_PUK_0100 Test start *************") + if (utils.notCheck) { + expect(true).assertTrue() + done() + } + // expect(12).assertEqual(LockReason.SIM_SIM_PUK) + done() + console.log("************* Telephony_observer_LockReason_SIM_SIM_PUK_0100 Test end *************") + }) + + function timeout(done) { + expect(true).assertTrue() + console.debug('Observer Test=========timeout========'); + done() + } + + console.log("************* Observer Test end *************") + }) +} + + + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/RadioJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/RadioJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a6222c0256ae4c37fd270abb3186d252443a3480 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/RadioJsunit.test.ets @@ -0,0 +1,302 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import radio from '@ohos.telephony.radio'; +import utils from './Utils.ets' + +export default function radioJsunit() { + describe('ActsNetworkSearchTest',function () { + + const SLOT_2 = -1; + const SLOT_0 = 0; + + /** + * @tc.number Telephony_NetworkSearch_getMEID_Async_0100 + * @tc.name Test getMEID(-1) to view the callback result + * @tc.desc Function test + */ + it('Telephony_NetworkSearch_getMEID_Async_0100', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + radio.getMEID(SLOT_2, (err, data) => { + if (err) { + console.log(`Telephony_NetworkSearch_getMEID_Async_0100 fail: ${err}`); + expect().assertFail(); + done(); + return; + } + console.log(`Telephony_NetworkSearch_getMEID_Async_0100 end data: ${data}`); + expect(data === '').assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_NetworkSearch_getMEID_Promise_0100 + * @tc.name Test getMEID(-1) to check the callback result + * @tc.desc FunctigetMEIDon test + */ + it('Telephony_NetworkSearch_getMEID_Promise_0100', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + radio.getMEID(SLOT_2).then(data => { + console.log(`Telephony_NetworkSearch_getMEID_Promise_0100 end data: ${data}`); + expect(data === '').assertTrue(); + done(); + }).catch(err => { + console.log(`Telephony_NetworkSearch_getMEID_Promise_0100 fail: ${err}`); + expect().assertFail(); + done(); + }) + }); + + /** + * @tc.number Telephony_NetworkSearch_getPrimarySlotId_Async_0200 + * @tc.name Test getPrimarySlotId(-1) to check the callback result + * @tc.desc Function test + */ + it('Telephony_NetworkSearch_getPrimarySlotId_Async_0200', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + radio.getPrimarySlotId((err, data) => { + if (err) { + console.log(`Telephony_NetworkSearch_getPrimarySlotId_Async_0200 fail: ${err}`); + expect(data === undefined).assertTrue(); + done(); + return; + } + console.log(`Telephony_NetworkSearch_getPrimarySlotId_Async_0200 end data: ${data}`); + expect(data === '').assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_NetworkSearch_setPrimarySlotId_Async_0300 + * @tc.name Test The function setPrimarySlotId(0) + * @tc.desc Function test + */ + it('Telephony_NetworkSearch_setPrimarySlotId_Async_0300', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + radio.setPrimarySlotId(SLOT_0, (err, data) => { + if (err) { + console.log(`Telephony_NetworkSearch_setPrimarySlotId_Async_0300 fail: ${err}`); + expect(data === undefined).assertTrue(); + done(); + return; + } + console.log(`Telephony_NetworkSearch_setPrimarySlotId_Async_0300 end data: ${data}`); + expect(data === '').assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_NetworkSearch_setPrimarySlotId_Async_0300 + * @tc.name Test The function setPrimarySlotId(0) + * @tc.desc Function test + */ + it('Telephony_NetworkSearch_setPrimarySlotId_Promise_0300', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + try { + await radio.setPrimarySlotId(SLOT_0); + console.log('Telephony_NetworkSearch_setPrimarySlotId_Promise_0300 success'); + done(); + } catch (err) { + console.log(`Telephony_NetworkSearch_setPrimarySlotId_Promiss_0300 fail ${err}`); + done(); + } + }); + + /** + * @tc.number Telephony_NetworkSearch_isNrSupported_Promise_0400 + * @tc.name Test The function setPrimarySlotId(0) + * @tc.desc Function test + */ + it('Telephony_NetworkSearch_isNrSupported_Promise_0400', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + try { + await radio.isNrSupported(SLOT_0); + console.log('radio.isNrSupported(SLOT_0) = ' + radio.isNrSupported(SLOT_0)); + console.log('Telephony_NetworkSearch_isNrSupported_Promise_0400 success'); + done(); + } catch (err) { + console.log(`Telephony_NetworkSearch_isNrSupported_Promise_0400 fail ${err}`); + done(); + } + }); + + /** + * @tc.number Telephony_radio_PreferredNetworkMode_0500 + * @tc.name Test The PreferredNetworkMode enum + * @tc.desc Function test + */ + it('Telephony_radio_PreferredNetworkMode_0500', 0, async function (done) { + console.info("Telephony_radio_PreferredNetworkMode_0500 start") + if(utils.notCheck){ + done(); + return; + } + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA === 2).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE === 3).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA === 4).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM === 5).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA_GSM === 6).assertTrue(); + console.info("Telephony_radio_PreferredNetworkMode_0500 end") + done(); + }); + + /** + * @tc.number Telephony_radio_PreferredNetworkMode_0600 + * @tc.name Test The PreferredNetworkMode enum + * @tc.desc Function test + */ + it('Telephony_radio_PreferredNetworkMode_0600', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + console.info("Telephony_radio_PreferredNetworkMode_0600 start") + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_CDMA === 7).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_EVDO === 8).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_EVDO_CDMA === 9).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_WCDMA_GSM_EVDO_CDMA === 10).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_EVDO_CDMA === 11).assertTrue(); + console.info("Telephony_radio_PreferredNetworkMode_0600 end") + done(); + }); + + /** + * @tc.number Telephony_radio_PreferredNetworkMode_0700 + * @tc.name Test The PreferredNetworkMode enum + * @tc.desc Function test + */ + it('Telephony_radio_PreferredNetworkMode_0700', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + console.info("Telephony_radio_PreferredNetworkMode_0700 start") + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM_EVDO_CDMA === 12).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA === 13).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_GSM === 14).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA === 15).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM === 16).assertTrue(); + console.info("Telephony_radio_PreferredNetworkMode_0700 end") + done(); + }); + + /** + * @tc.number Telephony_radio_PreferredNetworkMode_0800 + * @tc.name Test The PreferredNetworkMode enum + * @tc.desc Function test + */ + it('Telephony_radio_PreferredNetworkMode_0800', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + console.info("Telephony_radio_PreferredNetworkMode_0800 start") + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA === 17).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM === 18).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA === 19).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM === 20).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM_EVDO_CDMA ===21).assertTrue(); + console.info("Telephony_radio_PreferredNetworkMode_0800 end") + done(); + }); + + /** + * @tc.number Telephony_radio_PreferredNetworkMode_0900 + * @tc.name Test The PreferredNetworkMode enum + * @tc.desc Function test + */ + it('Telephony_radio_PreferredNetworkMode_0900', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + console.info("Telephony_radio_PreferredNetworkMode_0900 start") + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA === 17).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM === 18).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA === 19).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM === 20).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM_EVDO_CDMA ===21).assertTrue(); + console.info("Telephony_radio_PreferredNetworkMode_0900 end") + done(); + }); + + /** + * @tc.number Telephony_radio_PreferredNetworkMode_1000 + * @tc.name Test The PreferredNetworkMode enum + * @tc.desc Function test + */ + it('Telephony_radio_PreferredNetworkMode_1000', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + console.info("Telephony_radio_PreferredNetworkMode_1000 start") + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA === 22).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR === 31).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE === 32).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA === 33).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM ===34).assertTrue(); + console.info("Telephony_radio_PreferredNetworkMode_1000 end") + done(); + }); + + /** + * @tc.number Telephony_radio_PreferredNetworkMode_1100 + * @tc.name Test The PreferredNetworkMode enum + * @tc.desc Function test + */ + it('Telephony_radio_PreferredNetworkMode_1100', 0, async function (done) { + if(utils.notCheck){ + done(); + return; + } + console.info("Telephony_radio_PreferredNetworkMode_1100 start") + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_EVDO_CDMA === 35).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM_EVDO_CDMA === 36).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA === 37).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_GSM === 38).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA ===39).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM === 40).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA === 41).assertTrue(); + expect(PreferredNetworkMode.PREFERRED_NETWORK_MODE_MAX_VALUE === 99).assertTrue(); + console.info("Telephony_radio_PreferredNetworkMode_1100 end") + done(); + }); + + }) +} \ No newline at end of file diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/RadioSecondJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/RadioSecondJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d1de270b275d466a9d4b26a4c553dd8bbb659719 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/RadioSecondJsunit.test.ets @@ -0,0 +1,209 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import radio from '@ohos.telephony.radio'; +import utils from './Utils.ets' + +export default function radioSecondJsunit() { + describe('radioSecondTest', function () { + const NROPTION_MODE = [ + radio.NR_OPTION_UNKNOWN, + radio.NR_OPTION_NSA_ONLY, + radio.NR_OPTION_SA_ONLY, + radio.NR_OPTION_NSA_AND_SA + ]; + //Network status + let garrNetworkState = [ + radio.NETWORK_UNKNOWN, + radio.NETWORK_AVAILABLE, + radio.NETWORK_CURRENT, + radio.NETWORK_FORBIDDEN, + ]; + //NetworkRadioTech + let garrNetworkRadioTech = [ + 'UNKNOWN', 'GSM', '1XRTT', 'WCDMA', + 'HSPA', 'HSPAP', 'TD_SCDMA', 'EVDO', + 'EHRPD', 'LTE', 'LTE_CA', 'IWLAN', 'NR']; + + const SLOT_0 = 0; + const SLOT_1 = 5; + const SLOT_2 = 2; + const SLOT_3 = -1; + const NETWORK_TYPES = [ + radio.NETWORK_TYPE_UNKNOWN, + radio.NETWORK_TYPE_GSM, + radio.NETWORK_TYPE_CDMA, + radio.NETWORK_TYPE_WCDMA, + radio.NETWORK_TYPE_TDSCDMA, + radio.NETWORK_TYPE_LTE, + radio.NETWORK_TYPE_NR, + ]; + const NETWORK_SIGNAL = [0, 1, 2, 3, 4, 5]; + const CELL_LAC_TAC_MAX = 0xffff; + const CELL_CELLID_MAX = 0xfffffff; + const CELL_GSM_CELLID_MAX = 0xffff; + const CELL_ARFCN_MAX = 1023; + const CELL_EARFCN_MAX = 41589; + const CELL_BSIC_MAX = 63; + const CELL_PSC_MAX = 511; + const CELL_PCI_MAX = 503; + const CELL_MCC = 460; + const CELL_MNC_MAX = 20; + const CELL_INFO_MIN = 0; + const TIME_RADIO_TURNON = 10000; + console.log("************* radio Test start*************"); + it('Telephony_NetworkSearch_getCellInformation_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + radio.getCellInformation((err, data) => { + if (err) { + console.log(`Telephony_NetworkSearch_getCellInformation_Async_0100 fail: ${err}`); + expect().assertFail(); + done(); + return; + } + console.log(`Telephony_NetworkSearch_getCellInformation_Async_0100 end data: ${JSON.stringify(data)}`); + if (true) { + console.log(`Telephony_NetworkSearch_getCellInformation_Async_0100 1`); + expect(true).assertTrue(); + done(); + return; + } else { + assertCellInformation(data); + done(); + } + }); + }); + + /** + * @tc.number Telephony_NetworkSearch_getNrOptionMode_Async_0100 + * @tc.name Test getNrOptionMode() to check the callback result + * @tc.desc Function test + */ + it('Telephony_NetworkSearch_getNrOptionMode_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + radio.getNrOptionMode((err, data) => { + if (err) { + console.log(`Telephony_NetworkSearch_getNrOptionMode_Async_0100 get fail err: ${err}`); + expect().assertFail(); + done(); + return; + } + console.log(`Telephony_NetworkSearch_getNrOptionMode_Async_0100 end data: ${JSON.stringify(data)}`); + if (true) { + console.log(`Telephony_NetworkSearch_getNrOptionMode_Async_0100 1`); + expect(true).assertTrue(); + done(); + return; + } else { + expect(NROPTION_MODE).assertContain(data); + done(); + } + }); + }) + + /** + * @tc.number Telephony_NetworkSearch_getNetworkSearchInformation_Async_0100 + * @tc.name Test the getNetworkSearchInformation() query function and set the slotId parameter input to 0, + * test the return value isNetworkSearchSuccess is true and specific operator information + * @tc.desc Function test + */ + it('Telephony_NetworkSearch_getNetworkSearchInformation_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + radio.getNetworkSearchInformation(SLOT_0, (err, data) => { + if (err) { + console.log(`Telephony_NetworkSearch_getNetworkSearchInformation_Async_0100 fail err: ${err}`); + expect().assertFail(); + done(); + return; + } + if (true){ + console.log(`Telephony_NetworkSearch_getNetworkSearchInformation_Async_0100 1`); + expect(true).assertTrue(); + done(); + return; + } + expect(data != null && data != undefined).assertTrue(); + if (data.networkSearchResult.length === 0) { + console.log('Telephony_NetworkSearch_getNetworkSearchInformation_Async_0100 fail'); + expect().assertFail(); + done(); + return; + } + console.log( + `Telephony_NetworkSearch_getNetworkSearchInformation_Async_0100 finish data: ${JSON.stringify(data)}`); + expect(data.isNetworkSearchSuccess).assertTrue(); + expect( + data.networkSearchResult[0].operatorName != undefined && + data.networkSearchResult[0].operatorName != '' && + data.networkSearchResult[0].operatorName != null + ).assertTrue(); + expect(garrNetworkState).assertContain(data.networkSearchResult[0].state); + expect(garrNetworkRadioTech).assertContain(data.networkSearchResult[0].radioTech); + expect(data.networkSearchResult[0].operatorNumeric.substr(0, 3) === '460').assertTrue(); + done(); + }); + }); + console.log("************* radio Test end*************"); + function assertCellInformation(data) { + expect(data !== '' && data != undefined && data != null).assertTrue(); + expect(data.length).assertLarger(0); + for (let i = 0; i < data.length; i++) { + expect(NETWORK_TYPES).assertContain(data[i].networkType); + expect(data[i].isCamped).assertTrue(); + expect(data[i].timeStamp).assertLarger(0); + expect(NETWORK_TYPES).assertContain(data[i].signalInformation.signalType); + expect(NETWORK_SIGNAL).assertContain(data[i].signalInformation.signalLevel); + expect(data[i].data != undefined && data[i].data != '' && data[i].data != null).assertTrue(); + if (data[0].networkType === radio.NETWORK_TYPE_LTE) { + expect(data[i].data.tac >= CELL_INFO_MIN && data[i].data.tac <= CELL_LAC_TAC_MAX).assertTrue(); + expect(data[i].data.cgi >= CELL_INFO_MIN && data[i].data.cgi <= CELL_CELLID_MAX).assertTrue(); + expect(data[i].data.earfcn >= CELL_INFO_MIN && data[i].data.earfcn <= CELL_EARFCN_MAX).assertTrue(); + expect(data[i].data.pci >= CELL_INFO_MIN && data[i].data.pci <= CELL_PCI_MAX).assertTrue(); + expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue(); + expect(data[i].data.mcc).assertEqual(CELL_MCC); + } else if (data[i].networkType === radio.NETWORK_TYPE_WCDMA) { + expect(data[i].data.lac >= CELL_INFO_MIN && data[i].data.lac <= CELL_LAC_TAC_MAX).assertTrue(); + expect(data[i].data.cellId >= CELL_INFO_MIN && data[i].data.cellId <= CELL_CELLID_MAX).assertTrue(); + expect(data[i].data.uarfcn >= CELL_INFO_MIN && data[i].data.uarfcn <= CELL_ARFCN_MAX).assertTrue(); + expect(data[i].data.psc >= CELL_INFO_MIN && data[i].data.psc <= CELL_PSC_MAX).assertTrue(); + expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue(); + expect(data[i].data.mcc).assertEqual(CELL_MCC); + } else if (data[i].networkType === radio.NETWORK_TYPE_GSM) { + expect(data[i].data.lac >= CELL_INFO_MIN && data[i].data.lac <= CELL_LAC_TAC_MAX).assertTrue(); + expect(data[i].data.cellId >= CELL_INFO_MIN && data[i].data.cellId <= CELL_GSM_CELLID_MAX).assertTrue(); + expect(data[i].data.arfcn >= CELL_INFO_MIN && data[i].data.arfcn <= CELL_ARFCN_MAX).assertTrue(); + expect(data[i].data.bsic >= CELL_INFO_MIN && data[i].data.bsic <= CELL_BSIC_MAX).assertTrue(); + expect(data[i].data.mnc >= CELL_INFO_MIN && data[i].data.mnc <= CELL_MNC_MAX).assertTrue(); + expect(data[i].data.mcc).assertEqual(CELL_MCC); + } else { + expect().assertFail(); + } + } + } + }) +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/SimJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/SimJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7707cc9d7d9c0eb09d654327e4ffc212d92640b8 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/SimJsunit.test.ets @@ -0,0 +1,164 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import sim from '@ohos.telephony.sim'; +import * as env from './lib/Const.js'; +import utils from './Utils.ets' +export default function simJsunit() { + describe('appInfoTest', function () { + console.log("************* sim Test start*************"); + /** + * @tc.number Telephony_Sim_getOperatorConfigs_Async_0100 + * @tc.name The slotId parameter is 0 and the OperatorConfig structure is not expected to be empty + * @tc.desc Function test + */ + it('Telephony_Sim_getOperatorConfigs_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + console.log('Telephony_Sim_getOperatorConfigs_Async_0100 start'); + let containerIsEmpty = 0; + sim.getOperatorConfigs(env.DEFAULT_SLOTID, (err, data) => { + console.log('Telephony_Sim_getOperatorConfigs_Async_0100 result'); + if (err) { + console.log(`Telephony_Sim_getOperatorConfigs_Async_0100 fail, err : ${err.message}`); + done(); + return; + } + expect(Object.keys(data).length !== containerIsEmpty).assertTrue(); + console.log('Telephony_Sim_getOperatorConfigs_Async_0100 finish'); + done(); + }); + }); + + /** + * @tc.number Telephony_Sim_getSimAccountInfo_Async_0100 + * @tc.name Get the return value by calling the GetSimAccountInfo interface SIM ID input parameter 0. + * @tc.desc Function test + */ + it('Telephony_Sim_getSimAccountInfo_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + const CASE_NAME = 'Telephony_Sim_getSimAccountInfo_Async_0100'; + let iccIdValue; + sim.getSimAccountInfo(env.DEFAULT_SLOTID, (err, info) => { + if (err) { + console.log(`${CASE_NAME} fail ,err : ${err.message}`); + done(); + return; + } + console.log(`${CASE_NAME} getSimAccountInfo: ${JSON.stringify(info)}`); + expect(info.slotIndex === env.DEFAULT_SLOTID + && info.isEsim === false + && info.isActive === true + && info.iccId === iccIdValue + && info.showName === env.SIM_SLOT_NAME + && info.showNumber === env.SIM_SLOT_NUMBER + ).assertTrue(); + console.log(`${CASE_NAME} finish`); + done(); + }); + }); + /** + * @tc.number Telephony_Sim_unlockPin_Async_0100 + * @tc.name Test the unlockPin interface when the card status is ready state. + * @tc.desc Function test + */ + it('Telephony_Sim_unlockPin_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let PIN = '1234'; + sim.unlockPin(env.DEFAULT_SLOTID, PIN, (err, data) => { + if (err) { + console.log(`Telephony_Sim_unlockPin_Async_0100 fail, err: ${err.message}`); + done(); + return; + } + expect(data.result === env.OTHER_ABNORMAL).assertTrue(); + console.log('Telephony_Sim_unlockPin_Async_0100 finish'); + done(); + }); + }); + /** + * @tc.number Telephony_Sim_addIccDiallingNumbers_Async_0100 + * @tc.name Test sim.addIccDiallingNumbers(soltId: -1, type: 1, diallingNumbers: + * {recordNumber: 1, alphaTag: 'test', number: '12345678', pin2: '123@#ABCD'}, + * callback: AsyncCallback) async callback interface, expect enter error. + * @tc.desc Function test + */ + const CONTACT_INFO = { 'recordNumber': 1, 'alphaTag': 'test', 'number': '12345678' }; + const GENERAL_CONTACT_INFO = Object.assign({}, { 'pin2': env.INCORRECT_PIN2 }, CONTACT_INFO); + it('Telephony_Sim_addIccDiallingNumbers_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + const CASE_NAME = 'Telephony_Sim_addIccDiallingNumbers_Async_0100'; + sim.addIccDiallingNumbers(env.SLOTID_MINUS1, + sim.GENERAL_CONTACT, + GENERAL_CONTACT_INFO, + error => { + if (error) { + console.log(`${CASE_NAME} expect error: ${error.message}`); + console.log(`${CASE_NAME} finish.`); + } else { + console.log(`${CASE_NAME} test fail.`); + expect().assertFail(); + } + done(); + }); + }); + /** + * @tc.number Telephony_Sim_SetLockState_Async_0100 + * @tc.name Test the SetLockState async callback interface to open the PIN lock and check the callback value + * @tc.desc Function test + */ + it('Telephony_Sim_SetLockState_Async_0100', 0, async function (done) { + const CASE_NAME = 'Telephony_Sim_SetLockState_Async_0100'; + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + const lockInfo = { lockType: sim.PIN_LOCK, state: sim.LOCK_ON, password: env.CORRECT_PIN }; + await setPinLockState(sim.LOCK_OFF); + sim.setLockState(env.DEFAULT_SLOTID, lockInfo, (error, lockStatusResponse) => { + if (error) { + console.log(`${CASE_NAME} setLockState error: ${error.message}`); + expect().assertFail(); + done(); + return; + } + if (lockStatusResponse.result !== env.LOCK_RESULT.SUCCESS) { + console.log(`${CASE_NAME} setLockState failure, lock status response: ${lockStatusResponse.result}`); + expect().assertFail(); + done(); + return; + } + }); + }); + console.log("************* sim Test end*************"); + }) +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/SmsMmsJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/SmsMmsJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..70df080efa1ac8dc6093c4eae244d40719261d46 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/SmsMmsJsunit.test.ets @@ -0,0 +1,892 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import mms from '@ohos.telephony.sms'; +import utils from './Utils.ets' +export default function smsUiJsunit() { + describe('appInfoTest', function () { + /** + * @tc.number Telephony_SmsMms_encodeMms_Async_0100 + * @tc.name SendReq type MMS, encoding after decoding, the content after decoding and coding before the same + * @tc.desc Function test + */ + it('Telephony_SmsMms_encodeMms_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let mmsType = { + "from": { + address: '+861381234****/TYPE=PLMN', charset: mms.UTF_8 + }, + to: [{ + address: '+861388888****/TYPE=PLMN', charset: mms.UTF_8 + }], + transactionId: '2077.1427358451410', + version: mms.MMS_VERSION_1_2, + date: 1639378126, + cc: [{ + address: "+861381111****/TYPE=PLMN", charset: mms.UTF_8 + }], + bcc: [{ + address: "+861382222****/TYPE=PLMN", charset: mms.UTF_8 + }], + subject: "Test mms", + messageClass: 130, + expiry: 1639378126, + priority: mms.MMS_LOW, + senderVisibility: 129, + deliveryReport: 128, + readReport: 129, + contentType: "application/vnd.wap.multipart.related", + }; + let attachment = [ + { + path: '/data/telephony/enSrc/content.text', + fileName: 'content.text', + contentId: '', + contentLocation: 'content.text', + contentDisposition: mms.FROM_DATA, + contentTransferEncoding: 'base64', + contentType: 'text/plain', + isSmil: false, + inBuff: [], + charset: mms.UTF_8 + }, + { + path: '/data/telephony/enSrc/618C0A89.smil', + fileName: '618C0A89.smil', + contentId: '<0000>', + contentLocation: '618C0A89.smil', + contentDisposition: mms.ATTACHMENT, + contentTransferEncoding: 'base64', + contentType: 'application/smil', + isSmil: true, + inBuff: [], + charset: mms.UTF_8 + }, + { + path: '/data/telephony/enSrc/picture.gif', + fileName: 'picture.gif', + contentId: '', + contentLocation: 'picture.gif', + contentDisposition: mms.INLINE, + contentTransferEncoding: 'base64', + contentType: 'image/gif', + isSmil: false, + inBuff: [], + charset: mms.UTF_8 + }]; + + mms.encodeMms({ + messageType: mms.TYPE_MMS_SEND_REQ, mmsType, attachment + }, (err, encodeData) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0100 encodeMms fail'); + done(); + return; + } + console.log('Telephony_SmsMms_encodeMms_Async_0100 encodeMms finish'); + mms.decodeMms(encodeData, (err, data) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0100 fail'); + done(); + return; + } + expect(data.messageType === mms.TYPE_MMS_SEND_REQ).assertTrue(); + expect(data.mmsType.from.address === '+861381234****/TYPE=PLMN').assertTrue(); + expect(data.mmsType.from.charset === mms.UTF_8).assertTrue(); + expect(data.mmsType.to.length > 0).assertTrue(); + expect(data.mmsType.to[0].address === '+861388888****/TYPE=PLMN').assertTrue(); + expect(data.mmsType.to[0].charset === mms.UTF_8).assertTrue(); + expect(data.mmsType.transactionId === '2077.1427358451410').assertTrue(); + expect(data.mmsType.version === mms.MMS_VERSION_1_2).assertTrue(); + expect(data.mmsType.date > 0).assertTrue(); + expect(data.mmsType.cc.length > 0).assertTrue(); + expect(data.mmsType.cc[0].address === '+861381111****/TYPE=PLMN').assertTrue(); + expect(data.mmsType.cc[0].charset === mms.UTF_8).assertTrue(); + expect(data.mmsType.bcc.length > 0).assertTrue(); + expect(data.mmsType.bcc[0].address === '+861382222****/TYPE=PLMN').assertTrue(); + expect(data.mmsType.bcc[0].charset === mms.UTF_8).assertTrue(); + expect(data.mmsType.subject === 'Test mms').assertTrue(); + expect(data.mmsType.messageClass === 130).assertTrue(); + expect(data.mmsType.expiry !== 0).assertTrue(); + expect(data.mmsType.priority === mms.MMS_LOW).assertTrue(); + expect(data.mmsType.senderVisibility === 129).assertTrue(); + expect(data.mmsType.deliveryReport === 128).assertTrue(); + expect(data.mmsType.readReport === 129).assertTrue(); + expect(data.mmsType.contentType === 'application/vnd.wap.multipart.related').assertTrue(); + if (data.attachment != null) { + expect(data.attachment.length > 0).assertTrue(); + expect(data.attachment[0].path === '').assertTrue(); + expect(data.attachment[0].fileName === '618C0A89.smil').assertTrue(); + expect(data.attachment[0].contentId === '<0000>').assertTrue(); + expect(data.attachment[0].contentLocation === '618C0A89.smil').assertTrue(); + expect(data.attachment[0].contentDisposition === mms.ATTACHMENT).assertTrue(); + expect(data.attachment[0].contentTransferEncoding === 'base64').assertTrue(); + expect(data.attachment[0].contentType === 'application/smil').assertTrue(); + expect(data.attachment[0].isSmil).assertTrue(); + expect(data.attachment[0].inBuff.length > 0).assertTrue(); + expect(data.attachment[0].charset === mms.UTF_8).assertTrue(); + expect(data.attachment[1].path === '').assertTrue(); + expect(data.attachment[1].fileName === 'content.text').assertTrue(); + expect(data.attachment[1].contentId === '').assertTrue(); + expect(data.attachment[1].contentLocation === 'content.text').assertTrue(); + expect(data.attachment[1].contentDisposition === mms.FROM_DATA).assertTrue(); + expect(data.attachment[1].contentTransferEncoding === 'base64').assertTrue(); + expect(data.attachment[1].contentType === 'text/plain').assertTrue(); + expect(data.attachment[1].isSmil).assertFalse(); + expect(data.attachment[1].inBuff.length > 0).assertTrue(); + expect(data.attachment[1].charset === mms.UTF_8).assertTrue(); + expect(data.attachment[2].path === '').assertTrue(); + expect(data.attachment[2].fileName === 'picture.gif').assertTrue(); + expect(data.attachment[2].contentId === '').assertTrue(); + expect(data.attachment[2].contentLocation === 'picture.gif').assertTrue(); + expect(data.attachment[2].contentDisposition === mms.INLINE).assertTrue(); + expect(data.attachment[2].contentTransferEncoding === 'base64').assertTrue(); + expect(data.attachment[2].contentType === 'image/gif').assertTrue(); + expect(data.attachment[2].isSmil).assertFalse(); + expect(data.attachment[2].inBuff.length > 0).assertTrue(); + expect(data.attachment[2].charset === mms.UTF_8).assertTrue(); + console.log('Telephony_SmsMms_encodeMms_Async_0100 finish'); + } + done(); + }); + }); + }); + + /** + * @tc.number Telephony_SmsMms_encodeMms_Async_0200 + * @tc.name SendConf type MMS, encoding after decoding, the content after decoding and coding before the same + * @tc.desc Function test + */ + it('Telephony_SmsMms_encodeMms_Async_0200', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let mmsType = { + responseState: 128, + transactionId: '2077.1427358451410', + version: mms.MMS_VERSION_1_1, + messageId: '0001', + }; + mms.encodeMms({ + messageType: mms.TYPE_MMS_SEND_CONF, mmsType + }, (err, encodeData) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0200 encodeMms fail'); + done(); + return; + } + console.log('Telephony_SmsMms_encodeMms_Async_0200 encodeMms finish'); + mms.decodeMms(encodeData, (err, data) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0200 fail'); + done(); + return; + } + expect(data.messageType === mms.TYPE_MMS_SEND_CONF).assertTrue(); + expect(data.mmsType.responseState === 128).assertTrue(); + expect(data.mmsType.transactionId === '2077.1427358451410').assertTrue(); + expect(data.mmsType.version === mms.MMS_VERSION_1_1).assertTrue(); + expect(data.mmsType.messageId === '0001').assertTrue(); + console.log('Telephony_SmsMms_encodeMms_Async_0200 finish'); + done(); + }); + }); + }); + + /** + * @tc.number Telephony_SmsMms_encodeMms_Async_0300 + * @tc.name NotificationInd type MMS, encoding after decoding, + * the content after decoding and coding before the same + * @tc.desc Function test + */ + it('Telephony_SmsMms_encodeMms_Async_0300', 0, async function (done) { + let mmsType = { + transactionId: "2080.142730", + messageClass: 128, + messageSize: 12345678, + expiry: 1639378126, + version: mms.MMS_VERSION_1_3, + "from": { + address: '+861381234****/TYPE=PLMN', charset: mms.UTF_8 + }, + subject: "Test mms", + deliveryReport: 128, + contentLocation: "Test", + contentClass: 128, + }; + mms.encodeMms({ + messageType: mms.TYPE_MMS_NOTIFICATION_IND, mmsType + }, (err, encodeData) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0300 encodeMms fail'); + done(); + return; + } + console.log('Telephony_SmsMms_encodeMms_Async_0300 encodeMms finish'); + mms.decodeMms(encodeData, (err, data) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0300 fail'); + done(); + return; + } + expect(data.messageType === mms.TYPE_MMS_NOTIFICATION_IND).assertTrue(); + expect(data.mmsType.transactionId === '2080.142730').assertTrue(); + expect(data.mmsType.messageClass === 128).assertTrue(); + expect(data.mmsType.messageSize === 12345678).assertTrue(); + expect(data.mmsType.expiry !== 0).assertTrue(); + expect(data.mmsType.version === mms.MMS_VERSION_1_3).assertTrue(); + expect(data.mmsType.from.address.length > 0).assertTrue(); + expect(data.mmsType.from.charset === mms.UTF_8).assertTrue(); + expect(data.mmsType.subject === 'Test mms').assertTrue(); + expect(data.mmsType.deliveryReport === 128).assertTrue(); + expect(data.mmsType.contentLocation === 'Test').assertTrue(); + expect(data.mmsType.contentClass === 128).assertTrue(); + console.log('Telephony_SmsMms_encodeMms_Async_0300 finish'); + done(); + }); + }); + }); + + /** + * @tc.number Telephony_SmsMms_encodeMms_Async_0400 + * @tc.name NotifyRespInd type MMS, encoding after decoding,the content after decoding and coding before the same + * @tc.desc Function test + */ + it('Telephony_SmsMms_encodeMms_Async_0400', 0, async function (done) { + let mmsType = { + transactionId: '2920.1410', + status: 128, + version: mms.MMS_VERSION_1_0, + reportAllowed: mms.MMS_YES, + }; + mms.encodeMms({ + messageType: mms.TYPE_MMS_RESP_IND, mmsType + }, (err, encodeData) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0400 encodeMms fail'); + done(); + return; + } + console.log('Telephony_SmsMms_encodeMms_Async_0400 encodeMms finish'); + mms.decodeMms(encodeData, (err, data) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0400 fail'); + done(); + return; + } + expect(data.messageType === mms.TYPE_MMS_RESP_IND).assertTrue(); + expect(data.mmsType.transactionId === '2920.1410').assertTrue(); + expect(data.mmsType.status === 128).assertTrue(); + expect(data.mmsType.version === mms.MMS_VERSION_1_0).assertTrue(); + expect(data.mmsType.reportAllowed === mms.MMS_YES).assertTrue(); + console.log('Telephony_SmsMms_encodeMms_Async_0400 finish'); + done(); + }); + }); + }); + + /** + * @tc.number Telephony_SmsMms_encodeMms_Async_0500 + * @tc.name RetrieveConf type MMS, encoding after decoding, the content after decoding and coding before the same + * @tc.desc Function test + */ + it('Telephony_SmsMms_encodeMms_Async_0500', 0, async function (done) { + let mmsType = { + transactionId: "3077.142410", + messageId: "0001", + date: 1639378126, + version: mms.MMS_VERSION_1_2, + to: [{ + address: "+861388888****/TYPE=PLMN", charset: mms.UTF_8 + }], + "from": { + address: '+861381234****/TYPE=PLMN', charset: mms.UTF_8 + }, + cc: [{ + address: '+861381111****/TYPE=PLMN', charset: mms.UTF_8 + }], + subject: "Test mms", + priority: mms.MMS_HIGH, + deliveryReport: 128, + readReport: 128, + retrieveStatus: 128, + retrieveText: "0002", + contentType: "application/vnd.wap.multipart.related", + }; + mms.encodeMms({ + messageType: mms.TYPE_MMS_RETRIEVE_CONF, mmsType + }, (err, encodeData) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0500 encodeMms fail'); + done(); + return; + } + console.log('Telephony_SmsMms_encodeMms_Async_0500 encodeMms finish'); + mms.decodeMms(encodeData, (err, data) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0500 fail'); + done(); + return; + } + expect(data.messageType === mms.TYPE_MMS_RETRIEVE_CONF).assertTrue(); + expect(data.mmsType.transactionId === '3077.142410').assertTrue(); + expect(data.mmsType.messageId === '0001').assertTrue(); + expect(data.mmsType.date > 0).assertTrue(); + expect(data.mmsType.version === mms.MMS_VERSION_1_2).assertTrue(); + expect(data.mmsType.to.length > 0).assertTrue(); + expect(data.mmsType.to[0].address.length > 0).assertTrue(); + expect(data.mmsType.to[0].charset === mms.UTF_8).assertTrue(); + expect(data.mmsType.from.address.length > 0).assertTrue(); + expect(data.mmsType.from.charset === mms.UTF_8).assertTrue(); + expect(data.mmsType.cc.length > 0).assertTrue(); + expect(data.mmsType.cc[0].address.length > 0).assertTrue(); + expect(data.mmsType.cc[0].charset == mms.UTF_8).assertTrue(); + expect(data.mmsType.subject === 'Test mms').assertTrue(); + expect(data.mmsType.priority === mms.MMS_HIGH).assertTrue(); + expect(data.mmsType.deliveryReport === 128).assertTrue(); + expect(data.mmsType.readReport === 128).assertTrue(); + expect(data.mmsType.retrieveStatus === 128).assertTrue(); + expect(data.mmsType.retrieveText === '0002').assertTrue(); + expect(data.mmsType.contentType === 'application/vnd.wap.multipart.related').assertTrue(); + console.log('Telephony_SmsMms_encodeMms_Async_0500 finish'); + done(); + }); + }); + }); + + /** + * @tc.number Telephony_SmsMms_encodeMms_Async_0600 + * @tc.name AcknowledgeInd type MMS, encoding after decoding, + * the content after decoding and coding before the same + * @tc.desc Function test + */ + it('Telephony_SmsMms_encodeMms_Async_0600', 0, async function (done) { + let mmsType = { + transactionId: "27.14210", + version: mms.MMS_VERSION_1_2, + reportAllowed: mms.MMS_NO, + }; + mms.encodeMms({ + messageType: mms.TYPE_MMS_ACKNOWLEDGE_IND, mmsType + }, (err, encodeData) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0600 encodeMms fail'); + done(); + return; + } + console.log('Telephony_SmsMms_encodeMms_Async_0600 encodeMms finish'); + mms.decodeMms(encodeData, (err, data) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0600 fail'); + done(); + return; + } + expect(data.messageType === mms.TYPE_MMS_ACKNOWLEDGE_IND).assertTrue(); + expect(data.mmsType.transactionId === '27.14210').assertTrue(); + expect(data.mmsType.version === mms.MMS_VERSION_1_2).assertTrue(); + expect(data.mmsType.reportAllowed === mms.MMS_NO).assertTrue(); + console.log('Telephony_SmsMms_encodeMms_Async_0600 finish'); + done(); + }); + }); + }); + + /** + * @tc.number Telephony_SmsMms_encodeMms_Async_0700 + * @tc.name DeliveryInd type MMS, encoding after decoding, the content after decoding and coding before the same + * @tc.desc Function test + */ + it('Telephony_SmsMms_encodeMms_Async_0700', 0, async function (done) { + let mmsType = { + messageId: "0001", + date: 1639378126, + to: [{ + address: "+861388888****/TYPE=PLMN", charset: mms.UTF_8 + }], + status: 134, + version: mms.MMS_VERSION_1_2, + }; + mms.encodeMms({ + messageType: mms.TYPE_MMS_DELIVERY_IND, mmsType + }, (err, encodeData) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0700 encodeMms fail'); + done(); + return; + } + console.log('Telephony_SmsMms_encodeMms_Async_0700 encodeMms finish'); + mms.decodeMms(encodeData, (err, data) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0700 fail'); + done(); + return; + } + expect(data.messageType === mms.TYPE_MMS_DELIVERY_IND).assertTrue(); + expect(data.mmsType.messageId === '0001').assertTrue(); + expect(data.mmsType.date > 0).assertTrue(); + expect(data.mmsType.to.length > 0).assertTrue(); + expect(data.mmsType.to[0].address.length > 0).assertTrue(); + expect(data.mmsType.to[0].charset === mms.UTF_8).assertTrue(); + expect(data.mmsType.status === 134).assertTrue(); + expect(data.mmsType.version === mms.MMS_VERSION_1_2).assertTrue(); + console.log('Telephony_SmsMms_encodeMms_Async_0700 finish'); + done(); + }); + }); + }); + + /** + * @tc.number Telephony_SmsMms_encodeMms_Async_0800 + * @tc.name ReadRecInd type MMS, encoding after decoding, the content after decoding and coding before the same + * @tc.desc Function test + */ + it('Telephony_SmsMms_encodeMms_Async_0800', 0, async function (done) { + let mmsType = { + version: mms.MMS_VERSION_1_0, + messageId: "0001", + to: [{ + address: "+861388888****/TYPE=PLMN", charset: mms.UTF_8 + }], + "from": { + address: "+861381234****/TYPE=PLMN", charset: mms.UTF_8 + }, + date: 1639378126, + readStatus: 128, + }; + mms.encodeMms({ + messageType: mms.TYPE_MMS_READ_REC_IND, mmsType + }, (err, encodeData) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0800 encodeMms fail'); + done(); + return; + } + console.log('Telephony_SmsMms_encodeMms_Async_0800 encodeMms finish'); + mms.decodeMms(encodeData, (err, data) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0800 fail'); + done(); + return; + } + expect(data.messageType === mms.TYPE_MMS_READ_REC_IND).assertTrue(); + expect(data.mmsType.version === mms.MMS_VERSION_1_0).assertTrue(); + expect(data.mmsType.messageId === '0001').assertTrue(); + expect(data.mmsType.to.length > 0).assertTrue(); + expect(data.mmsType.to[0].address.length > 0).assertTrue(); + expect(data.mmsType.to[0].charset === mms.UTF_8).assertTrue(); + expect(data.mmsType.from.address.length > 0).assertTrue(); + expect(data.mmsType.from.charset === mms.UTF_8).assertTrue(); + expect(data.mmsType.readStatus === 128).assertTrue(); + expect(data.mmsType.date > 0).assertTrue(); + console.log('Telephony_SmsMms_encodeMms_Async_0800 finish'); + done(); + }); + }); + }); + + /** + * @tc.number Telephony_SmsMms_encodeMms_Async_0900 + * @tc.name ReadOrigInd type MMS, encoding after decoding, the content after decoding and coding before the same + * @tc.desc Function test + */ + it('Telephony_SmsMms_encodeMms_Async_0900', 0, async function (done) { + let mmsType = { + version: mms.MMS_VERSION_1_1, + messageId: "0001", + to: [{ + address: "+861388888****/TYPE=PLMN", charset: mms.UTF_8 + }], + "from": { + address: "+861381234****/TYPE=PLMN", charset: mms.UTF_8 + }, + readStatus: 129, + date: 1639378126, + }; + mms.encodeMms({ + messageType: mms.TYPE_MMS_READ_ORIG_IND, mmsType + }, (err, encodeData) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0900 encodeMms fail'); + done(); + return; + } + console.log('Telephony_SmsMms_encodeMms_Async_0900 encodeMms finish'); + mms.decodeMms(encodeData, (err, data) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0900 fail'); + done(); + return; + } + expect(data.messageType === mms.TYPE_MMS_READ_ORIG_IND).assertTrue(); + expect(data.mmsType.version === mms.MMS_VERSION_1_1).assertTrue(); + expect(data.mmsType.messageId === '0001').assertTrue(); + expect(data.mmsType.to.length > 0).assertTrue(); + expect(data.mmsType.to[0].address.length > 0).assertTrue(); + expect(data.mmsType.to[0].charset === mms.UTF_8).assertTrue(); + expect(data.mmsType.from.address.length > 0).assertTrue(); + expect(data.mmsType.from.charset === mms.UTF_8).assertTrue(); + expect(data.mmsType.date > 0).assertTrue(); + expect(data.mmsType.readStatus === 129).assertTrue(); + console.log('Telephony_SmsMms_encodeMms_Async_0900 finish'); + done(); + }); + }); + }); + /** + * @tc.number Telephony_SmsMms_encodeMms_Async_0900 + * @tc.name RetrieveConf type MMS, encoding after decoding, the content after decoding and coding before the same + * @tc.desc Function test + */ + it('Telephony_SmsMms_encodeMms_Async_0900', 0, async function (done) { + let mmsType = { + transactionId: "3077.142410", + messageId: "0001", + date: 1639378126, + version: mms.MMS_VERSION_1_2, + to: [{ + address: "+861388888****/TYPE=PLMN", charset: mms.UTF_8 + }], + "from": { + address: '+861381234****/TYPE=PLMN', charset: mms.UTF_8 + }, + cc: [{ + address: '+861381111****/TYPE=PLMN', charset: mms.UTF_8 + }], + subject: "Test mms", + priority: mms.MMS_NORMAL, + deliveryReport: 128, + readReport: 128, + retrieveStatus: 128, + retrieveText: "0002", + contentType: "application/vnd.wap.multipart.related", + }; + mms.encodeMms({ + messageType: mms.TYPE_MMS_RETRIEVE_CONF, mmsType + }, (err, encodeData) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0900 encodeMms fail'); + done(); + return; + } + console.log('Telephony_SmsMms_encodeMms_Async_0900 encodeMms finish'); + mms.decodeMms(encodeData, (err, data) => { + if (err) { + console.log('Telephony_SmsMms_encodeMms_Async_0500 fail'); + done(); + return; + } + expect(data.messageType === mms.TYPE_MMS_RETRIEVE_CONF).assertTrue(); + expect(data.mmsType.transactionId === '3077.142410').assertTrue(); + expect(data.mmsType.messageId === '0001').assertTrue(); + expect(data.mmsType.date > 0).assertTrue(); + expect(data.mmsType.version === mms.MMS_VERSION_1_2).assertTrue(); + expect(data.mmsType.to.length > 0).assertTrue(); + expect(data.mmsType.to[0].address.length > 0).assertTrue(); + expect(data.mmsType.to[0].charset === mms.UTF_8).assertTrue(); + expect(data.mmsType.from.address.length > 0).assertTrue(); + expect(data.mmsType.from.charset === mms.UTF_8).assertTrue(); + expect(data.mmsType.cc.length > 0).assertTrue(); + expect(data.mmsType.cc[0].address.length > 0).assertTrue(); + expect(data.mmsType.cc[0].charset == mms.UTF_8).assertTrue(); + expect(data.mmsType.subject === 'Test mms').assertTrue(); + expect(data.mmsType.priority === mms.MMS_NORMAL).assertTrue(); + expect(data.mmsType.deliveryReport === 128).assertTrue(); + expect(data.mmsType.readReport === 128).assertTrue(); + expect(data.mmsType.retrieveStatus === 128).assertTrue(); + expect(data.mmsType.retrieveText === '0002').assertTrue(); + expect(data.mmsType.contentType === 'application/vnd.wap.multipart.related').assertTrue(); + console.log('Telephony_SmsMms_encodeMms_Async_0500 finish'); + done(); + }); + }); + }); + + const SMS_SEND_DST_NUMBER = ''; + const TRUE_SLOT_ID = 0; + const FALSE_SLOT_ID = 9; + const OTHER_SLOT_ID = 1; + const SECOND_SLOT_ID = 2; + const IDENTIFIER_MIN = 0; + const IDENTIFIER_MAX = 0xFFFF; + const RANTYPE_GSM = 1; + const RANTYPE_CDMA = 2; + const RANTYPE_ERROR = 3; + var rawArray = [ + 0x08, 0x91, 0x68, 0x31, 0x08, 0x20, 0x00, 0x75, 0xF4, 0x24, 0x0D, 0x91, + 0x68, 0x81, 0x29, 0x56, 0x29, 0x83, 0xF6, 0x00, 0x00, 0x12, 0x40, 0x80, + 0x01, 0x02, 0x14, 0x23, 0x02, 0xC1, 0x30 + ] + /** + * @tc.number Telephony_SmsMms_setCBConfig_Async_0100 + * @tc.name Set "StartMessageld" to minimum(0x0000) and "EndMessageld" to minimum(0x0000) for cell broadcast, + * Configure a cell broadcast for an identity. + * @tc.desc Function test + */ + it('Telephony_SmsMms_setCBConfig_Async_0100', 0, async function (done) { + if (true) { + expect(true).assertTrue(); + done(); + return; + } + let data = { + slotId: TRUE_SLOT_ID, + enable: true, + startMessageId: IDENTIFIER_MIN, + endMessageId: IDENTIFIER_MIN, + ranType: RANTYPE_GSM + }; + sms.setCBConfig(data, (err) => { + if (err) { + expect().assertFail(); + console.log('Telephony_SmsMms_setCBConfig_Async_0100 fail'); + done(); + return; + } + console.log('Telephony_SmsMms_setCBConfig_Async_0100 finish'); + done(); + }); + }); + + /** + * @tc.number Telephony_SmsMms_getAllSimMessages_CDMA_Async_0100 + * @tc.name When SLOTID is the correct value,Query all SMS records of the SIM card. + * @tc.desc Function test + */ + it('Telephony_SmsMms_getAllSimMessages_CDMA_Async_0100', 0, async function (done) { + if (true) { + expect(true).assertTrue(); + done(); + return; + } + let data = { + slotId: TRUE_SLOT_ID, + smsc: '', + pdu: CORRECT_SMS_PDU, + status: sms.SIM_MESSAGE_STATUS_SENT + }; + sms.addSimMessage(data, (adderr) => { + if (adderr) { + expect().assertFail(); + console.log('Telephony_SmsMms_getAllSimMessages_CDMA_Async_0100 add fail'); + done(); + return; + } + console.log('Telephony_SmsMms_getAllSimMessages_CDMA_Async_0100 finish '); + sms.getAllSimMessages(TRUE_SLOT_ID, (geterr, getresult) => { + if (geterr) { + expect().assertFail(); + console.log('Telephony_SmsMms_getAllSimMessages_CDMA_Async_0100 get fail'); + done(); + return; + } + expect(getresult.length > 0).assertTrue(); + let addOfPdu = interceptionPdu(getresult[0].shortMessage.pdu); + let isAdd = (addOfPdu === CORRECT_SMS_PDU && + getresult[0].simMessageStatus === sms.SIM_MESSAGE_STATUS_SENT); + expect(isAdd).assertTrue(); + console.log('Telephony_SmsMms_getAllSimMessages_CDMA_Async_0100 getAllSimMessages cur finish'); + sms.delSimMessage(TRUE_SLOT_ID, getresult[0].indexOnSim, (delerr) => { + if (delerr) { + expect().assertFail(); + console.log('Telephony_SmsMms_getAllSimMessages_CDMA_Async_0100 del fail'); + done(); + return; + } + console.log('Telephony_SmsMms_getAllSimMessages_CDMA_Async_0100 delSimMessage finish'); + sms.getAllSimMessages(TRUE_SLOT_ID, (geterr, getresult) => { + if (geterr) { + expect().assertFail(); + console.log('Telephony_SmsMms_getAllSimMessages_CDMA_Async_0100 get 2 fail'); + done(); + return; + } + expect(getresult.length === 0).assertTrue(); + console.log('Telephony_SmsMms_getAllSimMessages_CDMA_Async_0100 getAllSimMessages cur finish'); + done(); + }); + }); + }); + }); + }); + /* + * @tc.number Telephony_SmsMms_createMessage_Async_0100 + * @tc.name Call interface CreateMessage, + * pass in the PDU(rawArray) in line with the coding specification, the specification is 3GPP, + * shortMessage Don't empty + * @tc.desc Function test + */ + it('Telephony_SmsMms_createMessage_Async_0100', 0, async function (done) { + if (true) { + expect(true).assertTrue(); + done(); + return; + } + sms.createMessage(rawArray, '3gpp', (err, shortMessage) => { + if (err) { + expect().assertFail(); + console.log('Telephony_SmsMms_createMessage_Async_0100 fail'); + done(); + return; + } + expect(shortMessage.visibleMessageBody === MESSAGEBODY).assertTrue(); + expect(shortMessage.visibleRawAddress.length === ADDR_LENGTH).assertTrue(); + expect(shortMessage.messageClass === sms.FORWARD_MESSAGE).assertTrue(); + expect(shortMessage.protocolId === 0).assertTrue(); + expect(shortMessage.scAddress.length === ADDR_LENGTH).assertTrue(); + expect(shortMessage.scTimestamp === SC_TIMESTAMP).assertTrue(); + expect(shortMessage.isReplaceMessage).assertFalse(); + expect(shortMessage.hasReplyPath).assertFalse(); + expect(shortMessage.pdu.length > 0).assertTrue(); + expect(shortMessage.status === 0).assertTrue(); + expect(shortMessage.isSmsStatusReportMessage).assertTrue(); + console.log('Telephony_SmsMms_createMessage_Async_0100 finish'); + done(); + }); + }); + + /* + * @tc.number Telephony_SmsMms_sendMessage_0100 + * @tc.name Call the interface sendMessage, set the card slot parameter "slotId" to 1, + * and send SMS successfully + * @tc.desc Function test + */ + it('Telephony_SmsMms_sendMessage_0100', 0, async function (done) { + if (true) { + expect(true).assertTrue(); + done(); + return; + } + sms.sendMessage({ + slotId: TRUE_SLOT_ID, + destinationHost: SMS_SEND_DST_NUMBER, + content: '111111', + sendCallback: (err, value) => { + if (err) { + expect().assertFail(); + console.log('Telephony_SmsMms_sendMessage_0100 sendCallback fail'); + done(); + return; + } + expect(value.result === sms.SEND_SMS_SUCCESS).assertTrue(); + console.log('Telephony_SmsMms_sendMessage_0100 sendCallback finish'); + done() + }, + deliveryCallback: (err, value) => { + if (err) { + expect().assertFail(); + console.log('Telephony_SmsMms_sendMessage_0100 deliveryCallback fail'); + done(); + return; + } + expect(value.pdu.length !== 0).assertTrue(); + console.log('Telephony_SmsMms_sendMessage_0100 deliveryCallback finish'); + done(); + } + }); + }); + /* + * @tc.number Telephony_SmsMms_getSmsSegmentsInfo_Async_0100 + * @tc.name set message to plain Chinese with a length of MAX_CHINESE_MESSAGE_LENTH(63) characters, + * and view the result + * @tc.desc Function test + */ + it('Telephony_SmsMms_getSmsSegmentsInfo_Async_0100', 0, async function (done) { + if (true) { + expect(true).assertTrue(); + done(); + return; + } + let message = ''; + for (let index = 0;index < MAX_CHINESE_MESSAGE_LENTH; index++) { + message += '中'; + } + let force7BitCode = true; + sms.getSmsSegmentsInfo(TRUE_SLOT_ID, message, force7BitCode, (error, result) => { + if (error) { + console.log("Telephony_SmsMms_getSmsSegmentsInfo_Async_0100 getSmsSegmentsInfoon error " + error.message); + console.log('Telephony_SmsMms_getSmsSegmentsInfo_Async_0100 fail'); + expect().assertFail(); + } else { + console.log("Telephony_SmsMms_getSmsSegmentsInfo_Async_0100 splitCount " + result.splitCount); + console.log("Telephony_SmsMms_getSmsSegmentsInfo_Async_0100 encodeCount " + result.encodeCount); + console.log("Telephony_SmsMms_getSmsSegmentsInfo_Async_0100 encodeCountRemaining " + + result.encodeCountRemaining); + console.log("Telephony_SmsMms_getSmsSegmentsInfo_Async_0100 scheme " + result.scheme); + + expect(result.splitCount === DIVIDE_MESSAGE_INTO_1).assertTrue(); + expect(result.encodeCount === MAX_CHINESE_MESSAGE_LENTH).assertTrue(); + let remaining = result.splitCount * MAX_CHAR_MESSAGE_LENTH - result.encodeCount; + console.log("Telephony_SmsMms_getSmsSegmentsInfo_Async_0100 remaining " + remaining); + expect(result.encodeCountRemaining === remaining).assertTrue(); + expect(result.scheme === sms.SMS_ENCODING_7BIT).assertTrue(); + console.log('Telephony_SmsMms_getSmsSegmentsInfo_Async_0100 finish'); + } + done(); + }); + }); + /* + * @tc.number Telephony_SmsMms_getSmsEncodingScheme_Async_0100 + * @tc.name + * @tc.desc Function test + */ + it('Telephony_SmsMms_getSmsEncodingScheme_Async_0100', 0, async function (done) { + if (true) { + expect(true).assertTrue(); + done(); + return; + } + expect(sms.SmsEncodingScheme == 0).assertTrue(); + expect(sms.SMS_ENCODING_7BIT == 1).assertTrue(); + expect(sms.SMS_ENCODING_8BIT == 2).assertTrue(); + expect(sms.SMS_ENCODING_16BIT == 3).assertTrue(); + done(); + }); + + /* + * @tc.number Telephony_SmsMms_getMmsCharSets_Async_0100 + * @tc.name + * @tc.desc Function test + */ + it('Telephony_SmsMms_getMmsCharSets_Async_0100', 0, async function (done) { + if (true) { + expect(true).assertTrue(); + done(); + return; + } + expect(sms.BIG5 == 0X07EA).assertTrue(); + expect(sms.ISO_10646_UCS_2 == 0X03E8).assertTrue(); + expect(sms.ISO_8859_1 == 0X04).assertTrue(); + expect(sms.ISO_8859_2 == 0X05).assertTrue(); + expect(sms.ISO_8859_3 == 0X06).assertTrue(); + expect(sms.ISO_8859_4 == 0X07).assertTrue(); + expect(sms.ISO_8859_5 == 0X08).assertTrue(); + expect(sms.ISO_8859_6 == 0X09).assertTrue(); + expect(sms.ISO_8859_7 == 0X10).assertTrue(); + expect(sms.ISO_8859_8 == 0X12).assertTrue(); + expect(sms.ISO_8859_9 == 0X13).assertTrue(); + expect(sms.SHIFT_JIS == 0X11).assertTrue(); + expect(sms.US_ASCII == 0X03).assertTrue(); + expect(sms.UTF_8 == 0X6A).assertTrue(); + done(); + }); + }) +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/StatisticsJsunit.test.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/StatisticsJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1e89921078666526077633446d37aaee269b88b7 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/StatisticsJsunit.test.ets @@ -0,0 +1,1383 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import statistics from '@ohos.net.statistics'; +import utils from './Utils.ets' +export default function statisticsUiJsunit() { + describe('appInfoTest', function () { + const DATA_0 = 0; + + /** + * @tc.number Telephony_statistics_getCellularRxBytes_Async_0100 + * @tc.name The APP calls getCellularRxBytes() and gets traffic successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getCellularRxBytes_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getCellularRxBytes_Async_0100'; + console.log(`${caseName} done`); + statistics.getCellularRxBytes((err, data) => { + if (err) { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + } + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getCellularRxBytes_Promise_0100 + * @tc.name The APP calls getCellularRxBytes() and gets traffic successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getCellularRxBytes_Promise_0100', 0, async function (done) { + let caseName = 'Telephony_statistics_getCellularRxBytes_Promise_0100'; + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + statistics.getCellularRxBytes().then((data) => { + console.log(`${caseName} get data = ${data.message}:${ data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }).catch((err) => { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getCellularTxBytes_Async_0100 + * @tc.name The APP calls getCellularTxBytes() and gets traffic successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getCellularTxBytes_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getCellularTxBytes_Async_0100'; + statistics.getCellularTxBytes((err, data) => { + if (err) { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + } + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getCellularTxBytes_Promise_0100 + * @tc.name The APP calls getCellularTxBytes() and gets traffic successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getCellularTxBytes_Promise_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getCellularTxBytes_Promise_0100'; + statistics.getCellularTxBytes().then((data) => { + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }).catch((err) => { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getUidRxBytes_Async_0100 + * @tc.name The APP calls getUidRxBytes() and gets traffic successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getUidRxBytes_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidRxBytess_Async_0100'; + statistics.getUidRxBytes(1,(err, data) => { + if (err) { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + } + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.message == 'successful').assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getUidRxBytes_Promise_0100 + * @tc.name The APP calls getUidRxBytes() and gets traffic successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getUidRxBytes_Promise_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidRxBytes_Promise_0100'; + statistics.getUidRxBytes(1).then((data) => { + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.message == 'successful').assertTrue(); + done(); + }).catch((err) => { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getUidTxBytes_Async_0100 + * @tc.name The APP calls getUidTxBytes and gets traffic successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getUidTxBytes_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidTxBytes_Async_0100'; + statistics.getUidTxBytes(1,(err, data) => { + if (err) { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + } + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.message == 'successful').assertTrue(); + done(); + }); + }); + /** + * @tc.number Telephony_statistics_getUidTxBytess_Promise_0100 + * @tc.name The APP calls getUidTxBytes() and gets traffic successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getUidTxBytes_Promise_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidTxBytes_Promise_0100'; + statistics.getUidTxBytes(1).then((data) => { + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.message == 'successful').assertTrue(); + done(); + }).catch((err) => { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + }); + }); + + + /** + * @tc.number Telephony_statistics_getIfaceRxBytes_Async_0100 + * @tc.name Set the network interface to cellular, + * call getIfaceRxBytes() and get the traffic value successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceRxBytes_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceRxBytes_Async_0100'; + let ifaceName = "usb0"; + statistics.getIfaceRxBytes(ifaceName, (err, data) => { + if (err) { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + } + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceRxBytes_Async_0200 + * @tc.name Set network interface to WIFI network interface, + * call getIfaceRxBytes(), successfully obtain traffic value (>=DATA_0) + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceRxBytes_Async_0200', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceRxBytes_Async_0200'; + let ifaceName = "wlan0"; + statistics.getIfaceRxBytes(ifaceName, (err, data) => { + if (err) { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + } + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceRxBytes_Async_0300 + * @tc.name Set the network interface to an Ethernet interface, + * call getIfaceRxBytes(), and get the traffic value successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceRxBytes_Async_0300', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceRxBytes_Async_0300'; + let ifaceName = "eth0"; + statistics.getIfaceRxBytes(ifaceName, (err, data) => { + if (err) { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + } + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceRxBytes_Async_0400 + * @tc.name Set the network interface to a nonexistent one, call getIfaceRxBytes(), + * and get a traffic value of DATA_0 + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceRxBytes_Async_0400', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceRxBytes_Async_0400'; + let ifaceName = "xlan0"; + statistics.getIfaceRxBytes(ifaceName, (err, data) => { + if (err) { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + } + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code == DATA_0).assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceRxBytes_Promise_0100 + * @tc.name Set the network interface to cellular, + * call getIfaceRxBytes() and get the traffic value successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceRxBytes_Promise_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceRxBytes_Promise_0100'; + let ifaceName = "usb0"; + statistics.getIfaceRxBytes(ifaceName).then((data) => { + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }).catch((err) => { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceRxBytes_Promise_0200 + * @tc.name Set network interface to WIFI network interface, + * call getIfaceRxBytes(), successfully obtain traffic value (>=DATA_0) + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceRxBytes_Promise_0200', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceRxBytes_Promise_0200'; + let ifaceName = "wlan0"; + statistics.getIfaceRxBytes(ifaceName).then((data) => { + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }).catch((err) => { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceRxBytes_Promise_0300 + * @tc.name Set the network interface to an Ethernet interface, + * call getIfaceRxBytes(), and get the traffic value successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceRxBytes_Promise_0300', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceRxBytes_Promise_0300'; + let ifaceName = "eth0"; + statistics.getIfaceRxBytes(ifaceName).then((data) => { + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }).catch((err) => { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceRxBytes_Promise_0400 + * @tc.name Set the network interface to a nonexistent one, call getIfaceRxBytes(), + * and get a traffic value of DATA_0 + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceRxBytes_Promise_0400', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceRxBytes_Promise_0400'; + let ifaceName = "xlan0"; + statistics.getIfaceRxBytes(ifaceName).then((data) => { + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code == DATA_0).assertTrue(); + done(); + }).catch((err) => { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceTxBytes_Async_0100 + * @tc.name Set the network interface to cellular, + * call getIfaceTxBytes() and get the traffic value successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceTxBytes_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceTxBytes_Async_0100'; + let ifaceName = "usb0"; + statistics.getIfaceTxBytes(ifaceName, (err, data) => { + if (err) { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + } + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceTxBytes_Async_0200 + * @tc.name Set network interface to WIFI network interface, + * call getIfaceTxBytes(), successfully obtain traffic value (>=DATA_0) + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceTxBytes_Async_0200', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceTxBytes_Async_0200'; + let ifaceName = "wlan0"; + statistics.getIfaceTxBytes(ifaceName, (err, data) => { + if (err) { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + } + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceTxBytes_Async_0300 + * @tc.name Set the network interface to an Ethernet interface, + * call getIfaceTxBytes(), and get the traffic value successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceTxBytes_Async_0300', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceTxBytes_Async_0300'; + let ifaceName = "eth0"; + statistics.getIfaceTxBytes(ifaceName, (err, data) => { + if (err) { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + } + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceTxBytes_Async_0400 + * @tc.name Set the network interface to a nonexistent one, call getIfaceTxBytes(), + * and get a traffic value of DATA_0 + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceTxBytes_Async_0400', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceTxBytes_Async_0400'; + let ifaceName = "xlan0"; + statistics.getIfaceTxBytes(ifaceName, (err, data) => { + if (err) { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + } + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code == DATA_0).assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceTxBytes_Promise_0100 + * @tc.name Set the network interface to cellular, + * call getIfaceTxBytes() and get the traffic value successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceTxBytes_Promise_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceTxBytes_Promise_0100'; + let ifaceName = "usb0"; + statistics.getIfaceTxBytes(ifaceName).then((data) => { + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }).catch((err) => { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceTxBytes_Promise_0200 + * @tc.name Set network interface to WIFI network interface, + * call getIfaceTxBytes(), successfully obtain traffic value (>=DATA_0) + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceTxBytes_Promise_0200', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceTxBytes_Promise_0200'; + let ifaceName = "wlan0"; + statistics.getIfaceTxBytes(ifaceName).then((data) => { + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }).catch((err) => { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceTxBytes_Promise_0300 + * @tc.name Set the network interface to an Ethernet interface, + * call getIfaceTxBytes(), and get the traffic value successfully (>=DATA_0). + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceTxBytes_Promise_0300', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceTxBytes_Promise_0300'; + let ifaceName = "eth0"; + statistics.getIfaceTxBytes(ifaceName).then((data) => { + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }).catch((err) => { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceTxBytes_Promise_0400 + * @tc.name Set the network interface to a nonexistent one, call getIfaceTxBytes(), + * and get a traffic value of DATA_0 + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceTxBytes_Promise_0400', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceTxBytes_Promise_0400'; + let ifaceName = "xlan0"; + statistics.getIfaceTxBytes(ifaceName).then((data) => { + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code == DATA_0).assertTrue(); + done(); + }).catch((err) => { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getAllRxBytes_Async_0100 + * @tc.name Call getAllRxBytes() and get traffic successfully (>=DATA_0) + * @tc.desc Function test + */ + it('Telephony_statistics_getAllRxBytes_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getAllRxBytes_Async_0100'; + statistics.getAllRxBytes((err, data) => { + if (err) { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + } + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getAllRxBytes_Promise_0100 + * @tc.name Call getAllRxBytes() and get traffic successfully (>=DATA_0) + * @tc.desc Function test + */ + it('Telephony_statistics_getAllRxBytes_Promise_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getAllRxBytes_Promise_0100'; + statistics.getAllRxBytes().then((data) => { + console.log(`${caseName} get data = ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }).catch((err) => { + console.log(`${caseName} get erro = ` + err); + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getAllRxBytes_Async_0100 + * @tc.name Call getAllTxBytes() and get traffic successfully (>=DATA_0) + * @tc.desc Function test + */ + it('Telephony_statistics_getAllTxBytes_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getAllTxBytes_Async_0100'; + statistics.getAllTxBytes((err, data) => { + if (err) { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + + } + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getAllTxBytes_Promise_0100 + * @tc.name Call getAllTxBytes() and get traffic successfully (>=DATA_0) + * @tc.desc Function test + */ + it('Telephony_statistics_getAllTxBytes_Promise_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getAllTxBytes_Promise_0100'; + statistics.getAllTxBytes().then((data) => { + console.log(`${caseName} get data: ${data.message} + ${data.code}`); + expect(data.code >= DATA_0).assertTrue(); + done(); + }).catch((err) => { + console.log(`${caseName} get data fail: ${err.message} ${err.code}`); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_statistics_on_0100 + * @tc.name Test on() to check the callback result + * @tc.desc Function test + */ + it('Telephony_statistics_statistics_on_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_statistics_on_0100'; + statistics.on('netStatsChange', (data) => { + console.log(`${caseName} on data: ${JSON.stringify(data)}`); + expect(data).assertUndefined(); + done(); + }); + done(); + }); + + /** + * @tc.number Telephony_statistics_statistics_off_0100 + * @tc.name Test off() to check the callback result + * @tc.desc Function test + */ + it('Telephony_statistics_statistics_off_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_statistics_off_0100'; + statistics.off('netStatsChange', (data) => { + console.log(`${caseName} off data: ${JSON.stringify(data)}`); + expect(data).assertUndefined(); + done(); + }); + done(); + }); + /** + * @tc.number Telephony_statistics_getIfaceStatsDetail_Async_0100 + * @tc.name Test getIfaceStatsDetail() to check the callback result when iface is test + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceStatsDetail_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceStatsDetail_Async_0100'; + let ifaceInfo = { + "iface": "test", + "startTime": Date.now() - 60 * 60, + "endTime": Date.now() + }; + statistics.getIfaceStatsDetail(ifaceInfo, (err, data) => { + if (err) { + console.log(`${caseName} getIfaceStatsDetail fail: ${JSON.stringify(err)}`); + done(); + return; + } + console.log(`${caseName} getIfaceStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceStatsDetail_Async_0200 + * @tc.name Test getIfaceStatsDetail() to check the callback result when endTime more than the statTime + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceStatsDetail_Async_0200', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceStatsDetail_Async_0200'; + let ifaceInfo = { + "iface": "eth0", + "startTime": Date.now(), + "endTime": Date.now() - 60 * 60 + }; + statistics.getIfaceStatsDetail(ifaceInfo, (err, data) => { + if (err) { + console.log(`${caseName} getIfaceStatsDetail fail: ${JSON.stringify(err)}`); + done(); + return; + } + console.log(`${caseName} getIfaceStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceStatsDetail_Async_0500 + * @tc.name Test getIfaceStatsDetail() to check the callback result when endTime equal statTime + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceStatsDetail_Async_0500', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceStatsDetail_Async_0500'; + let time = Date.now(); + let ifaceInfo = { + "iface": "eth0", + "startTime": time, + "endTime": time + }; + statistics.getIfaceStatsDetail(ifaceInfo, (err, data) => { + if (err) { + console.log(`${caseName} getIfaceStatsDetail fail: ${JSON.stringify(err)}`); + done(); + return; + } + console.log(`${caseName} getIfaceStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceStatsDetail_Async_0600 + * @tc.name Test getIfaceStatsDetail() to check the callback result when endTime and statTime before system time + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceStatsDetail_Async_0600', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceStatsDetail_Async_0600'; + let ifaceInfo = { + "iface": "eth0", + "startTime": 1, + "endTime": 2 + }; + statistics.getIfaceStatsDetail(ifaceInfo, (err, data) => { + if (err) { + console.log(`${caseName} getIfaceStatsDetail fail: ${JSON.stringify(err)}`); + done(); + return; + } + console.log(`${caseName} getIfaceStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceStatsDetail_Async_0700 + * @tc.name Test getIfaceStatsDetail() to check the callback result when endTime and statTime after system time + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceStatsDetail_Async_0700', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceStatsDetail_Async_0700'; + let ifaceInfo = { + "iface": "eth0", + "startTime": 1981080000, + "endTime": 1981083600 + }; + statistics.getIfaceStatsDetail(ifaceInfo, (err, data) => { + if (err) { + console.log(`${caseName} getIfaceStatsDetail fail: ${JSON.stringify(err)}`); + done(); + return; + } + console.log(`${caseName} getIfaceStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getIfaceStatsDetail_Promise_0100 + * @tc.name Test getIfaceStatsDetail() to check the callback result when iface is test + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceStatsDetail_Promise_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceStatsDetail_Promise_0100'; + let ifaceInfo = { + "iface": "test", + "startTime": Date.now() - 60 * 60, + "endTime": Date.now() + }; + statistics.getIfaceStatsDetail(ifaceInfo).then(data => { + console.log(`${caseName} getIfaceStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }).catch(err => { + console.log(`${caseName} getIfaceStatsDetail fail: ${JSON.stringify(err)}`); + done(); + }) + }); + + /** + * @tc.number Telephony_statistics_getIfaceStatsDetail_Promise_0200 + * @tc.name Test getIfaceStatsDetail() to check the callback result when endTime more than the statTime + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceStatsDetail_Promise_0200', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceStatsDetail_Promise_0200'; + let ifaceInfo = { + "iface": "eth0", + "startTime": Date.now(), + "endTime": Date.now() - 60 * 60 + }; + statistics.getIfaceStatsDetail(ifaceInfo).then(data => { + console.log(`${caseName} getIfaceStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }).catch(err => { + console.log(`${caseName} getIfaceStatsDetail fail: ${JSON.stringify(err)}`); + done(); + }) + }); + + /** + * @tc.number Telephony_statistics_getIfaceStatsDetail_Promise_0500 + * @tc.name Test getIfaceStatsDetail() to check the callback result when endTime equal statTime + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceStatsDetail_Promise_0500', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceStatsDetail_Promise_0500'; + let time = Date.now(); + let ifaceInfo = { + "iface": "eth0", + "startTime": time, + "endTime": time + }; + statistics.getIfaceStatsDetail(ifaceInfo).then(data => { + console.log(`${caseName} getIfaceStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }).catch(err => { + console.log(`${caseName} getIfaceStatsDetail fail: ${JSON.stringify(err)}`); + done(); + }) + }); + + /** + * @tc.number Telephony_statistics_getIfaceStatsDetail_Promise_0600 + * @tc.name Test getIfaceStatsDetail() to check the callback result when endTime and statTime before system time + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceStatsDetail_Promise_0600', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceStatsDetail_Promise_0600'; + let ifaceInfo = { + "iface": "eth0", + "startTime": 1, + "endTime": 2 + }; + statistics.getIfaceStatsDetail(ifaceInfo).then(data => { + console.log(`${caseName} getIfaceStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }).catch(err => { + console.log(`${caseName} getIfaceStatsDetail fail: ${JSON.stringify(err)}`); + done(); + }) + }); + + /** + * @tc.number Telephony_statistics_getIfaceStatsDetail_Promise_0700 + * @tc.name Test getIfaceStatsDetail() to check the callback result when endTime and statTime after system time + * @tc.desc Function test + */ + it('Telephony_statistics_getIfaceStatsDetail_Promise_0700', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getIfaceStatsDetail_Promise_0700'; + let ifaceInfo = { + "iface": "eth0", + "startTime": 1981080000, + "endTime": 1981083600 + }; + statistics.getIfaceStatsDetail(ifaceInfo).then(data => { + console.log(`${caseName} getIfaceStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }).catch(err => { + console.log(`${caseName} getIfaceStatsDetail fail: ${JSON.stringify(err)}`); + done(); + }) + }); + + /** + * @tc.number Telephony_statistics_getUidStatsDetail_Async_0100 + * @tc.name Test getUidStatsDetail() to check the callback result when iface is test + * @tc.desc Function test + */ + it('Telephony_statistics_getUidStatsDetail_Async_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidStatsDetail_Async_0100'; + let uidInfo = { + "ifaceInfo": { + "iface": "test", + "startTime": Date.now() - 60 * 60, + "endTime": Date.now() + }, + "uid": 1001 + }; + statistics.getUidStatsDetail(uidInfo, (err, data) => { + if (err) { + console.log(`${caseName} getUidStatsDetail fail: ${JSON.stringify(err)}`); + done(); + return; + } + console.log(`${caseName} getUidStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getUidStatsDetail_Async_0200 + * @tc.name Test getUidStatsDetail() to check the callback result when endTime more than the statTime + * @tc.desc Function test + */ + it('Telephony_statistics_getUidStatsDetail_Async_0200', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidStatsDetail_Async_0200'; + let uidInfo = { + "ifaceInfo": { + "iface": "eth0", + "startTime": Date.now(), + "endTime": Date.now() - 60 * 60 + }, + "uid": 1001 + }; + statistics.getUidStatsDetail(uidInfo, (err, data) => { + if (err) { + console.log(`${caseName} getUidStatsDetail fail: ${JSON.stringify(err)}`); + done(); + return; + } + console.log(`${caseName} getUidStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getUidStatsDetail_Async_0500 + * @tc.name Test getUidStatsDetail() to check the callback result when endTime equal statTime + * @tc.desc Function test + */ + it('Telephony_statistics_getUidStatsDetail_Async_0500', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidStatsDetail_Async_0500'; + let time = Date.now(); + let uidInfo = { + "ifaceInfo": { + "iface": "eth0", + "startTime": time, + "endTime": time + }, + "uid": 1001 + }; + statistics.getUidStatsDetail(uidInfo, (err, data) => { + if (err) { + console.log(`${caseName} getUidStatsDetail fail: ${JSON.stringify(err)}`); + done(); + return; + } + console.log(`${caseName} getUidStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getUidStatsDetail_Async_0600 + * @tc.name Test getUidStatsDetail() to check the callback result when uid is 0 + * @tc.desc Function test + */ + it('Telephony_statistics_getUidStatsDetail_Async_0600', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidStatsDetail_Async_0600'; + let uidInfo = { + "ifaceInfo": { + "iface": "eth0", + "startTime": Date.now() - 60 * 60, + "endTime": Date.now() + }, + "uid": 0 + }; + statistics.getUidStatsDetail(uidInfo, (err, data) => { + if (err) { + console.log(`${caseName} getUidStatsDetail fail: ${JSON.stringify(err)}`); + done(); + return; + } + console.log(`${caseName} getUidStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getUidStatsDetail_Async_0700 + * @tc.name Test getUidStatsDetail() to check the callback result when endTime and statTime before system time + * @tc.desc Function test + */ + it('Telephony_statistics_getUidStatsDetail_Async_0700', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidStatsDetail_Async_0700'; + let uidInfo = { + "ifaceInfo": { + "iface": "eth0", + "startTime": 1, + "endTime": 2 + }, + "uid": 1001 + }; + statistics.getUidStatsDetail(uidInfo, (err, data) => { + if (err) { + console.log(`${caseName} getUidStatsDetail fail: ${JSON.stringify(err)}`); + done(); + return; + } + console.log(`${caseName} getUidStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getUidStatsDetail_Async_0800 + * @tc.name Test getUidStatsDetail() to check the callback result when endTime and statTime after system time + * @tc.desc Function test + */ + it('Telephony_statistics_getUidStatsDetail_Async_0800', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidStatsDetail_Async_0800'; + let uidInfo = { + "ifaceInfo": { + "iface": "eth0", + "startTime": 1981080000, + "endTime": 1981083600 + }, + "uid": 1001 + }; + statistics.getUidStatsDetail(uidInfo, (err, data) => { + if (err) { + console.log(`${caseName} getUidStatsDetail fail: ${JSON.stringify(err)}`); + done(); + return; + } + console.log(`${caseName} getUidStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }); + }); + + /** + * @tc.number Telephony_statistics_getUidStatsDetail_Promise_0100 + * @tc.name Test getUidStatsDetail() to check the callback result when iface is test + * @tc.desc Function test + */ + it('Telephony_statistics_getUidStatsDetail_Promise_0100', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidStatsDetail_Promise_0100'; + let uidInfo = { + "ifaceInfo": { + "iface": "test", + "startTime": Date.now() - 60 * 60, + "endTime": Date.now() + }, + "uid": 1001 + }; + statistics.getUidStatsDetail(uidInfo).then(data => { + console.log(`${caseName} getUidStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }).catch(err => { + console.log(`${caseName} getUidStatsDetail fail: ${JSON.stringify(err)}`); + done(); + }) + }); + + /** + * @tc.number Telephony_statistics_getUidStatsDetail_Promise_0200 + * @tc.name Test getUidStatsDetail() to check the callback result when endTime more than the statTime + * @tc.desc Function test + */ + it('Telephony_statistics_getUidStatsDetail_Promise_0200', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidStatsDetail_Promise_0200'; + let uidInfo = { + "ifaceInfo": { + "iface": "eth0", + "startTime": Date.now(), + "endTime": Date.now() - 60 * 60 + }, + "uid": 1001 + }; + statistics.getUidStatsDetail(uidInfo).then(data => { + console.log(`${caseName} getUidStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }).catch(err => { + console.log(`${caseName} getUidStatsDetail fail: ${JSON.stringify(err)}`); + done(); + }) + }); + + /** + * @tc.number Telephony_statistics_getUidStatsDetail_Promise_0500 + * @tc.name Test getUidStatsDetail() to check the callback result when endTime equal statTime + * @tc.desc Function test + */ + it('Telephony_statistics_getUidStatsDetail_Promise_0500', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidStatsDetail_Promise_0500'; + let time = Date.now(); + let uidInfo = { + "ifaceInfo": { + "iface": "eth0", + "startTime": time, + "endTime": time + }, + "uid": 1001 + }; + statistics.getUidStatsDetail(uidInfo).then(data => { + console.log(`${caseName} getUidStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }).catch(err => { + console.log(`${caseName} getUidStatsDetail fail: ${JSON.stringify(err)}`); + done(); + }) + }); + + /** + * @tc.number Telephony_statistics_getUidStatsDetail_Promise_0600 + * @tc.name Test getUidStatsDetail() to check the callback result when uid is 0 + * @tc.desc Function test + */ + it('Telephony_statistics_getUidStatsDetail_Promise_0600', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidStatsDetail_Promise_0600'; + let uidInfo = { + "ifaceInfo": { + "iface": "eth0", + "startTime": Date.now() - 60 * 60, + "endTime": Date.now() + }, + "uid": 0 + }; + statistics.getUidStatsDetail(uidInfo).then(data => { + console.log(`${caseName} getUidStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }).catch(err => { + console.log(`${caseName} getUidStatsDetail fail: ${JSON.stringify(err)}`); + done(); + }) + }); + + /** + * @tc.number Telephony_statistics_getUidStatsDetail_Promise_0700 + * @tc.name Test getUidStatsDetail() to check the callback result when endTime and statTime before system time + * @tc.desc Function test + */ + it('Telephony_statistics_getUidStatsDetail_Promise_0700', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidStatsDetail_Promise_0700'; + let uidInfo = { + "ifaceInfo": { + "iface": "eth0", + "startTime": 1, + "endTime": 2 + }, + "uid": 1001 + }; + statistics.getUidStatsDetail(uidInfo).then(data => { + console.log(`${caseName} getUidStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }).catch(err => { + console.log(`${caseName} getUidStatsDetail fail: ${JSON.stringify(err)}`); + done(); + }) + }); + + /** + * @tc.number Telephony_statistics_getUidStatsDetail_Promise_0800 + * @tc.name Test getUidStatsDetail() to check the callback result when endTime and statTime after system time + * @tc.desc Function test + */ + it('Telephony_statistics_getUidStatsDetail_Promise_0800', 0, async function (done) { + if (utils.notCheck) { + expect(true).assertTrue(); + done(); + return; + } + let caseName = 'Telephony_statistics_getUidStatsDetail_Promise_0800'; + let uidInfo = { + "ifaceInfo": { + "iface": "eth0", + "startTime": 1981080000, + "endTime": 1981083600 + }, + "uid": 1001 + }; + statistics.getUidStatsDetail(uidInfo).then(data => { + console.log(`${caseName} getUidStatsDetail data: ${JSON.stringify(data)}`); + expect().assertFail(); + done(); + }).catch(err => { + console.log(`${caseName} getUidStatsDetail fail: ${JSON.stringify(err)}`); + done(); + }) + }); + }) +} diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/Utils.ets b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..65f70088ddb62bcf80f4e0ec07dc841a8ab033f0 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,119 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 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. + */ + +export default class Utils { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + static notCheck = true; + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } + + static async swipe(downX, downY, upX, upY, steps) { + console.info('start to swipe') + this.drags(downX, downY, upX, upY, steps, false) + } + + static async drag(downX, downY, upX, upY, steps) { + console.info('start to drag') + this.drags(downX, downY, upX, upY, steps, true) + } + + static async drags(downX, downY, upX, upY, steps, drag) { + var xStep; + var yStep; + var swipeSteps; + var ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + var downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('start to move') + if (drag) { + await this.sleep(500) + } + for (var i = 1;i <= swipeSteps; i++) { + var movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('start to up') + if (drag) { + await this.sleep(100) + } + var upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) + } +} + + + + diff --git a/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/lib/Const.js b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/lib/Const.js new file mode 100644 index 0000000000000000000000000000000000000000..f9263cd46dee1a0ffdfaa1e5ef5c29755c7e13f7 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/ets/MainAbility/test/lib/Const.js @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2021 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. + */ + +// sim slot id +export const DEFAULT_SLOTID = 0; +export const SLOTID3 = 3; +export const SLOTID2 = 2; +export const SLOTID_MINUS1 = -1; + +// sim correct password +export const CORRECT_PIN = '1234'; +export const CORRECT_PIN2 = '18099014'; + +// sim incorrect password +export const INCORRECT_PIN = '134679'; +export const INCORRECT_PIN_LEN3 = '123'; +export const INCORRECT_PUK = '134679'; +export const INCORRECT_PIN2 = '134679'; +export const INCORRECT_PIN2_LEN3 = '123'; +export const INCORRECT_PIN2_LEN9 = '123456789'; +export const INCORRECT_PUK2 = '134679'; + +// lock status response +export const LOCK_RESULT = { SUCCESS: 0, FAILURE: -1, EXCEPTION: -2 }; \ No newline at end of file diff --git a/telephony/telephonyjstest/new_add/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/new_add/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03b8532c53ca563f8ed6b1e21d20ad3f67a68906 --- /dev/null +++ b/telephony/telephonyjstest/new_add/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/telephony/telephonyjstest/new_add/entry/src/main/resources/base/media/icon.png b/telephony/telephonyjstest/new_add/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/new_add/entry/src/main/resources/base/media/icon.png differ diff --git a/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/hand.png b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/hand.png new file mode 100644 index 0000000000000000000000000000000000000000..9f1fa16ee073093b40920e273502513fa66fa980 Binary files /dev/null and b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/hand.png differ diff --git a/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/icon.png b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/icon.png differ diff --git a/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/images.jpg b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/images.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c75ddfc5ead15e8d49ca7cae9f97c03585565be1 Binary files /dev/null and b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/images.jpg differ diff --git a/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/person.png b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/person.png new file mode 100644 index 0000000000000000000000000000000000000000..f0f540d078e6c0441a763ca2cc375a551d6cf736 Binary files /dev/null and b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/person.png differ diff --git a/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/star-1-1.png b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/star-1-1.png new file mode 100644 index 0000000000000000000000000000000000000000..990c5e5ad20698c7701faf641bc80eb004a127b7 Binary files /dev/null and b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/star-1-1.png differ diff --git a/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/star-1-2.png b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/star-1-2.png new file mode 100644 index 0000000000000000000000000000000000000000..450c3dd3ca68bf601bd08e5f41797d376e20d00d Binary files /dev/null and b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/star-1-2.png differ diff --git a/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/star-1-3.png b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/star-1-3.png new file mode 100644 index 0000000000000000000000000000000000000000..1044869832b423a5dfc2559a395529377bd34f0c Binary files /dev/null and b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/star-1-3.png differ diff --git a/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/video/show.mp4 b/telephony/telephonyjstest/new_add/entry/src/main/resources/rawfile/video/show.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/telephony/telephonyjstest/new_add/signature/openharmony_sx.p7b b/telephony/telephonyjstest/new_add/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/telephony/telephonyjstest/new_add/signature/openharmony_sx.p7b differ