提交 0486e5af 编写于 作者: C chengxingzhen

delete

Signed-off-by: Nchengxingzhen <chengxingzhen@huawei.com>
上级 4e9cb8c1
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT 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("ActsFWKDataAccessorTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsFWKDataAccessorTest"
}
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"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.amsst.fwkdataaccessor",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsFWKDataAccessorTest.hap",
"./resource/appexecfwk/amsStDataAbility.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.amsst.fwkdataaccessor",
"vendor": "amsst",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.amsst.fwkdataaccessor",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home",
"flag.home.intent.from.system"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.amsst.fwkdataaccessor.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
STDataAbility
</text>
</div>
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 app from '@system.app'
import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index'
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'
})
const reportExtend = new ReportExtend(file)
core.addService('expect', expectExtend)
core.addService('report', reportExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "STDataAbility"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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 featureAbility from '@ohos.ability.featureAbility'
import ohosDataAbility from '@ohos.data.dataability'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe('ActsDataAbilityHelperTest', function () {
let dataAbilityUri = ("dataability:///com.ix.VerifyActDataAbility");
let dataAbilityUri2 = ("dataability:///com.ix.VerifyActDataAbility2");
let DAHelper;
let gSetTimeout = 500
beforeAll(async (done) => {
console.debug('= ACTS_beforeAll ====<begin');
try {
DAHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
console.debug('ACTS_beforeAll DAHelper ====>: ' + DAHelper + " ,JSON. " + JSON.stringify(DAHelper));
} catch (err) {
console.error('=ACTS_beforeAll acquireDataAbilityHelper catch(err)====>:' + err);
}
console.debug('= ACTS_beforeAll ====<end');
done();
})
afterAll((done) => {
console.debug('= ACTS_afterAll ====<begin');
console.debug('= ACTS_afterAll ====<end');
done();
})
/*
* @tc.number: ACTS_AcquireDataAbilityHelper_0100
* @tc.name: GetDataAbilityHelper : Connects an ability to a Service ability
* @tc.desc: Check the return value of the interface ()
*/
it('ACTS_AcquireDataAbilityHelper_0100', 0, async function (done) {
console.log('ACTS_AcquireDataAbilityHelper_0100====<begin');
console.debug("=ACTS_AcquireDataAbilityHelper_0100 dataAbilityUri====>" + dataAbilityUri)
try {
var abilityHelper = featureAbility.acquireDataAbilityHelper(dataAbilityUri)
console.log('ACTS_AcquireDataAbilityHelper_0100 abilityHelper ====>: '
+ abilityHelper + " ,JSON. " + JSON.stringify(abilityHelper))
expect(typeof (abilityHelper)).assertEqual("object");
} catch (err) {
console.error('=ACTS_GetDataAbilityHelper_0100 acquireDataAbilityHelper catch(err)====>:' + err);
expect(false).assertTrue();
}
done();
console.log('ACTS_AcquireDataAbilityHelper_0100====<end')
})
/*
* @tc.number: ACTS_AcquireDataAbilityHelper_0200
* @tc.name: GetDataAbilityHelper : Connects an ability to a Service ability
* @tc.desc: Check the return value of the interface ()
*/
it('ACTS_AcquireDataAbilityHelper_0200', 0, async function (done) {
console.log('ACTS_AcquireDataAbilityHelper_0200====<begin');
try {
var abilityHelper = featureAbility.acquireDataAbilityHelper("")
console.log('ACTS_AcquireDataAbilityHelper_0200 abilityHelper ====>: '
+ abilityHelper + " ,JSON. " + JSON.stringify(abilityHelper))
if (JSON.stringify(abilityHelper) == 'undefined' || JSON.stringify(abilityHelper) == 'null')
expect(true).assertTrue();
else
expect(false).assertTrue();
} catch (err) {
console.error('=ACTS_GetDataAbilityHelper_0200 acquireDataAbilityHelper catch(err)====>:' + err);
expect(false).assertTrue();
}
done();
console.log('ACTS_AcquireDataAbilityHelper_0200====<end')
})
/*
* @tc.number: ACTS_Insert_0100
* @tc.name: Insert : Indicates the path of the data to operate
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_Insert_0100', 0, async function (done) {
console.log('ACTS_Insert_0100====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('Insert_0100 DAHelper ====>: ' + DAHelper)
let valueBucket
try {
DAHelper.insert(dataAbilityUri, valueBucket)
.then(function (data) {
console.debug("=ACTS_Insert_0100 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
expect(data).assertEqual(1);
ret = true;
done();
}).catch(function (err) {
console.debug("=ACTS_Insert_0100 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false;
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_Insert_0100 catch(err)====>:' + err);
ret = false;
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Insert_0100====<end');
})
/*
* @tc.number: ACTS_Insert_0200
* @tc.name: Insert : Indicates the path of the data to operate
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_Insert_0200', 0, async function (done) {
console.log('ACTS_Insert_0200====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility getDataAbilityHelper ====>: ' + DAHelper)
let valueBucket
try {
await DAHelper.insert(dataAbilityUri, valueBucket,
(err, data) => {
console.debug("=ACTS_Insert_0200 err,data=======>"
+ ("json err【") + JSON.stringify(err) + (" 】data【") + data + (" 】;"));
expect(data).assertEqual(1);
ret = true;
done();
}
);
} catch (err) {
console.error('=ACTS_Insert_0200 catch(err)====>:' + err);
ret = false;
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Insert_0200====<end');
})
/*
* @tc.number: ACTS_Insert_0300
* @tc.name: Insert : Indicates the path of the data to operate
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_Insert_0300', 0, async function (done) {
console.log('ACTS_Insert_0300====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('Insert_0300 DAHelper ====<: ' + JSON.stringify(DAHelper) + "," + DAHelper)
const valueBucket = {
"name": "ACTS_Insert_0300_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
try {
DAHelper.insert(dataAbilityUri, valueBucket)
.then((data) => {
console.debug("=ACTS_Insert_0300 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
expect(typeof (data)).assertEqual("number");
ret = true;
done();
}).catch((err) => {
console.debug("=ACTS_Insert_0300 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false;
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_Insert_0300 catch(err)====>:' + err);
ret = false;
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Insert_0300====<end');
})
/*
* @tc.number: ACTS_Insert_0400
* @tc.name: Insert : Indicates the path of the data to operate
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_Insert_0400', 0, async function (done) {
console.log('ACTS_Insert_0400====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility getDataAbilityHelper ====>: ' + DAHelper)
const valueBucket = {
"name": "ACTS_Insert_0400_rose1",
"age": 221,
"salary": 20.5,
"blobType": "u8",
}
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);
ret = true;
done();
}
);
} catch (err) {
console.error('=ACTS_Insert_0400 catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Insert_0400====<end');
})
/*
* @tc.number: ACTS_BatchInsert_0100
* @tc.name: Inserts multiple data records into the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_BatchInsert_0100', 0, async function (done) {
console.log('ACTS_BatchInsert_0100====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility BatchInsert getDataAbilityHelper ====>: ' + DAHelper)
var valueBucket;
try {
DAHelper.batchInsert(
dataAbilityUri,
valueBucket
).then((data) => {
console.debug("=ACTS_BatchInsert_0100 then data====>"
+ ("json data 【") + JSON.stringify(data) + (" 】; ====>"));
expect(data).assertEqual(0);
ret = true;
done();
}).catch((err) => {
console.debug("=ACTS_BatchInsert_0100 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_BatchInsert_0100 catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_BatchInsert_0100====<end');
})
/*
* @tc.number: ACTS_BatchInsert_0200
* @tc.name: Inserts multiple data records into the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_BatchInsert_0200', 0, async function (done) {
console.log('ACTS_BatchInsert_0200====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility BatchInsert getDataAbilityHelper ====>: ' + DAHelper)
var valueBucket;
try {
await DAHelper.batchInsert(
dataAbilityUri,
valueBucket,
(err, data) => {
console.debug("=ACTS_BatchInsert_0200 err,data=======>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;"));
expect(data).assertEqual(0);
ret = true;
done();
},
);
} catch (err) {
console.error('=ACTS_BatchInsert_0200 catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_BatchInsert_0200====<end');
})
/*
* @tc.number: ACTS_BatchInsert_0300
* @tc.name: Inserts multiple data records into the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_BatchInsert_0300', 0, async function (done) {
console.log('ACTS_BatchInsert_0300====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility BatchInsert getDataAbilityHelper ====>: ' + DAHelper)
var valueBucketArray = new Array({}, {}, {})
try {
DAHelper.batchInsert(
dataAbilityUri,
valueBucketArray,
).then((data) => {
console.debug("=ACTS_BatchInsert_0300 then data====>"
+ ("json data 【") + JSON.stringify(data) + (" 】; ====>"));
expect(data).assertEqual(3);
ret = true;
done();
}).catch((err) => {
console.debug("=ACTS_BatchInsert_0300 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_BatchInsert_0300 batchInsert AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_BatchInsert_0300====<end');
})
/*
* @tc.number: ACTS_BatchInsert_0400
* @tc.name: Inserts multiple data records into the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_BatchInsert_0400', 0, async function (done) {
console.log('ACTS_BatchInsert_0400====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility BatchInsert getDataAbilityHelper ====>: ' + DAHelper)
var valueBucketArray = new Array({}, {}, {})
try {
await DAHelper.batchInsert(
dataAbilityUri,
valueBucketArray,
(err, data) => {
console.debug("=ACTS_BatchInsert_0400 err,data=======>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;"));
expect(data).assertEqual(3);
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_BatchInsert_0400 catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_BatchInsert_0400====<end');
})
/*
* @tc.number: ACTS_BatchInsert_0500
* @tc.name: Inserts multiple data records into the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_BatchInsert_0500', 0, async function (done) {
console.log('ACTS_BatchInsert_0500====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility BatchInsert getDataAbilityHelper ====>: ' + DAHelper)
try {
const valueBucket = {
"name": "ACTS_BatchInsert_0500_roe1",
"age": 21,
"salary": 20.5,
}
var valueBucketArray = new Array({ "name": "BatchInsert_0500_roe11", "age": 21, "salary": 20.5, },
{ "name": "BatchInsert_0500_roe12", "age": 21, "salary": 20.5, },
{ "name": "BatchInsert_0500_roe13", "age": 21, "salary": 20.5, })
DAHelper.batchInsert(
dataAbilityUri,
valueBucketArray,
).then((data) => {
console.debug("=ACTS_BatchInsert_0500 BatchInsert Promise then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
expect(data).assertEqual(3);
ret = true
done();
}).catch((err) => {
console.debug("=ACTS_BatchInsert_0500 BatchInsert Promise catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_BatchInsert_0500 catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_BatchInsert_0500====<end');
})
/*
* @tc.number: ACTS_BatchInsert_0600
* @tc.name: Inserts multiple data records into the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_BatchInsert_0600', 0, async function (done) {
console.log('ACTS_BatchInsert_0600====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility BatchInsert getDataAbilityHelper ====>: ' + DAHelper)
const valueBucket = {
"name": "BatchInsert_0600_roe1",
"age": 21,
"salary": 20.5,
}
var valueBucketArray = new Array({ "name": "BatchInsert_0600_roe11", "age": 21, "salary": 20.5, },
{ "name": "BatchInsert_0600_roe12", "age": 21, "salary": 20.5, },
{ "name": "BatchInsert_0600_roe13", "age": 21, "salary": 20.5, })
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);
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_BatchInsert_0600 catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_BatchInsert_0600====<end');
})
/*
* @tc.number: ACTS_Query_0300
* @tc.name: Queries one or more data records in the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_Query_0300', 0, async function (done) {
console.log('ACTS_Query_0300====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
var columnsArray = new Array("value1", "value2", "value3", "value4")
try {
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
let queryPromise = DAHelper.query(
dataAbilityUri,
columnsArray,
predicates
);
console.debug("=ACTS_Query_0300 queryPromise ====>"
+ ("json queryPromise 【") + JSON.stringify(queryPromise) + ("") + " , " + queryPromise);
expect(typeof (queryPromise)).assertEqual("object");
done();
} catch (err) {
console.error('=ACTS_Query_0300 query catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Query_0300====<end');
})
/*
* @tc.number: ACTS_Query_0400
* @tc.name: Queries one or more data records in the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_Query_0400', 0, async function (done) {
console.log('ACTS_Query_0400====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
var columnsArray = new Array("ACTS_Query_0400_roe1", "value2", "value3", "value4")
try {
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
await DAHelper.query(
dataAbilityUri,
columnsArray,
predicates,
(err, data) => {
console.debug("=ACTS_Query_0400 query err,data=======>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【")
+ JSON.stringify(data) + (" 】;") + " , " + data);
expect(typeof (data)).assertEqual("object");
ret = true
done();
});
} catch (err) {
console.error('=ACTS_Query_0400 catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Query_0400====<end');
})
/*
* @tc.number: ACTS_Update_0100
* @tc.name: Updates one or more data records in the database.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_Update_0100', 0, async function (done) {
console.log('ACTS_Update_0100====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility Update getDataAbilityHelper ====>: ' + DAHelper)
try {
let valueBucketNull = {};
let predicates = new ohosDataAbility.DataAbilityPredicates();
console.debug("=ACTS_Update_0100 predicates====>"
+ ("json predicates 【") + JSON.stringify(predicates) + ("") + " , " + predicates);
DAHelper.update(
dataAbilityUri,
valueBucketNull,
predicates
).then((data) => {
console.debug("=ACTS_Update_0100 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
expect(typeof (data)).assertEqual("number");
ret = true
done();
}).catch((err) => {
console.debug("=ACTS_Update_0100 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_Update_0100 catch(err)====>:' + err);
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Update_0100====<end');
})
/*
* @tc.number: ACTS_Update_0200
* @tc.name: Updates one or more data records in the database.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_Update_0200', 0, async function (done) {
console.log('ACTS_Update_0200====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
try {
let valueBucketNull = {};
let predicates = new ohosDataAbility.DataAbilityPredicates();
console.debug("=ACTS_Update_0200 predicates====>"
+ ("json predicates 【") + JSON.stringify(predicates) + ("") + " , " + predicates);
await DAHelper.update(
dataAbilityUri,
valueBucketNull,
predicates,
(err, data) => {
console.debug("=ACTS_Update_0200 err,data=======>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;"));
expect(typeof (data)).assertEqual("number");
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_Update_0200 catch(err)====>:' + err);
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Update_0200====<end');
})
/*
* @tc.number: ACTS_Update_0300
* @tc.name: Updates one or more data records in the database.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_Update_0300', 0, async function (done) {
console.log('ACTS_Update_0300====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility Update getDataAbilityHelper ====>: ' + DAHelper)
const valueBucket = { "name": "ACTS_Update_0300_roe1", "age": 21, "salary": 20.5, }
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_0300 predicates====>"
+ ("json predicates 【") + JSON.stringify(predicates) + ("") + " , " + predicates);
DAHelper.update(
dataAbilityUri,
valueBucket,
predicates
).then((data) => {
console.debug("=ACTS_Update_0300 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
expect(data).assertEqual(1);
ret = true
done();
}).catch((err) => {
console.debug("=ACTS_Update_0300 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_Update_0300 update catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Update_0300====<end');
})
/*
* @tc.number: ACTS_Update_0400
* @tc.name: Updates one or more data records in the database.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_Update_0400', 0, async function (done) {
console.log('ACTS_Update_0400====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility Update getDataAbilityHelper ====>: ' + DAHelper)
const valueBucket = { "name": "ACTS_Update_0400_roe1", "age": 21, "salary": 20.5, }
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);
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_Update_0400 catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Update_0400====<end');
})
/*
* @tc.number: ACTS_Delete_0100
* @tc.name: Deletes one or more data records. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_Delete_0100', 0, async function (done) {
console.log('ACTS_Delete_0100====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility getDataAbilityHelper ====>: ' + DAHelper)
try {
let predicates = new ohosDataAbility.DataAbilityPredicates();
console.debug("=ACTS_Delete_0100 predicates====>"
+ ("json predicates 【") + JSON.stringify(predicates) + ("") + " , " + predicates);
DAHelper.delete(
dataAbilityUri,
predicates
).then((data) => {
console.debug("=ACTS_Delete_0100 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
expect(typeof (data)).assertEqual("number");
ret = true
done();
}).catch((err) => {
console.debug("=ACTS_Delete_0100 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_Delete_0100 catch(err)====>:' + err);
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Delete_0100====<end');
})
/*
* @tc.number: ACTS_Delete_0200
* @tc.name: Deletes one or more data records. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_Delete_0200', 0, async function (done) {
console.log('ACTS_Delete_0200====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility getDataAbilityHelper ====>: ' + DAHelper)
try {
let predicates = new ohosDataAbility.DataAbilityPredicates();
console.debug("=ACTS_Delete_0200 predicates====>"
+ ("json predicates 【") + JSON.stringify(predicates) + ("") + " , " + predicates);
await DAHelper.delete(
dataAbilityUri,
predicates,
(err, data) => {
console.debug("=ACTS_Delete_0200 err,data=======>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;"));
expect(typeof (data)).assertEqual("number");
expect(data).assertEqual(1);
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_Delete_0200 catch(err)====>:' + err);
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Delete_0200====<end');
})
/*
* @tc.number: ACTS_Delete_0300
* @tc.name: Deletes one or more data records. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_Delete_0300', 0, async function (done) {
console.log('ACTS_Delete_0300====<begin');
let ret = false;
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_0300 predicates====>"
+ ("json predicates 【") + JSON.stringify(predicates) + ("") + " , " + predicates);
var datadelete = DAHelper.delete(
dataAbilityUri,
predicates
).then((data) => {
console.debug("=ACTS_Delete_0300 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
expect(data).assertEqual(1);
ret = true
done();
}).catch((err) => {
console.debug("=ACTS_Delete_0300 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
console.debug("=ACTS_Delete_0300 datadelete====>"
+ ("json datadelete 【") + JSON.stringify(datadelete) + ("") + " , " + datadelete);
} catch (err) {
console.error('=ACTS_Delete_0300 catch(err)====>:' + err);
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Delete_0300====<end');
})
/*
* @tc.number: ACTS_Delete_0400
* @tc.name: Deletes one or more data records. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_Delete_0400', 0, async function (done) {
console.log('ACTS_Delete_0400====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility getDataAbilityHelper ====>: ' + 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(1);
ret = true
done();
});
} catch (err) {
console.error('=ACTS_Delete_0400 catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Delete_0400====<end');
})
/*
* @tc.number: ACTS_GetFileTypes_0100
* @tc.name: Obtains the MIME type of files.
* @tc.desc: Check the return value of the interface (by promise)
*/
it('ACTS_GetFileTypes_0100', 0, async function (done) {
console.log('ACTS_GetFileTypes_0100====<begin');
let ret = false;
let mimeTypeFilter = '*/*'
try {
var promise = DAHelper.getFileTypes(
dataAbilityUri,
mimeTypeFilter,
).then((data) => {
console.debug("=ACTS_GetFileTypes_0100 getFileTypes then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
console.log('DataAbilityHelper getFileTypes data.length ====>: ' + data.length);
for (var i = 0; i < data.length; i++) {
expect(typeof (data[i])).assertEqual("string");
console.log('=ACTS_GetFileTypes_0100 for data[' + i + '] ====>: ' + data[i])
expect(data[i]).assertEqual("");
}
ret = true
done();
}).catch(err => {
console.debug("=ACTS_GetFileTypes_0100 getFileTypes catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
console.log('featureAbility getFileTypes promise ====>: ' + promise)
} catch (err) {
console.error('=ACTS_GetFileTypes_0100 getFileTypes AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_GetFileTypes_0100====<end');
})
/*
* @tc.number: ACTS_GetFileTypes_0200
* @tc.name: Obtains the MIME type of files.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_GetFileTypes_0200', 0, async function (done) {
console.log('ACTS_GetFileTypes_0200====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility getFileTypes getDataAbilityHelper ====>: ' + 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]);
expect(data[i]).assertEqual("");
}
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_GetFileTypes_0200 getFileTypes AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_GetFileTypes_0200====<end');
})
/*
* @tc.number: ACTS_GetFileTypes_0300
* @tc.name: Obtains the MIME type of files.
* @tc.desc: Check the return value of the interface (by promise)
*/
it('ACTS_GetFileTypes_0300', 0, async function (done) {
console.log('ACTS_GetFileTypes_0300====<begin');
let ret = false;
let mimeTypeFilter = 'image/*'
try {
var promise = DAHelper.getFileTypes(
dataAbilityUri,
mimeTypeFilter,
).then((data) => {
console.debug("=ACTS_GetFileTypes_0300 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
console.log('DataAbilityHelper getFileTypes data.length ====>: ' + data.length);
for (var i = 0; i < data.length; i++) {
expect(typeof (data[i])).assertEqual("string");
console.log('= =ACTS_GetFileTypes_0300 for data[' + i + '] ====>: ' + data[i])
expect(data[i]).assertEqual("");
}
ret = true
done();
}).catch(err => {
console.debug("=ACTS_GetFileTypes_0300 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
console.log('DataAbilityHelper getFileTypes error ====>: ' + err)
ret = false
expect(false).assertTrue();
done();
});
console.log('featureAbility getFileTypes promise ====>: ' + promise)
} catch (err) {
console.error('=ACTS_GetFileTypes_0300 getFileTypes AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_GetFileTypes_0300====<end');
})
/*
* @tc.number: ACTS_GetFileTypes_0400
* @tc.name: Obtains the MIME type of files.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_GetFileTypes_0400', 0, async function (done) {
console.log('ACTS_GetFileTypes_0400====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility getFileTypes getDataAbilityHelper ====>: ' + DAHelper)
let mimeTypeFilter = 'image/*'
try {
await DAHelper.getFileTypes(
dataAbilityUri,
mimeTypeFilter,
(err, data) => {
console.debug("=ACTS_GetFileTypes_0400 err,data=======>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;"));
console.log('DataAbilityHelper getFileTypes data.length ====>: ' + data.length);
for (var i = 0; i < data.length; i++) {
expect(typeof (data[i])).assertEqual("string");
console.log('=ACTS_GetFileTypes_0400 for ====>: ' + err.code + " data[" + i + "]: " + data[i]);
expect(data[i]).assertEqual("");
}
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_GetFileTypes_0400 getFileTypes AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_GetFileTypes_0400====<end');
})
/*
* @tc.number: ACTS_GetFileTypes_0500
* @tc.name: Obtains the MIME type of files.
* @tc.desc: Check the return value of the interface (by promise)
*/
it('ACTS_GetFileTypes_0500', 0, async function (done) {
console.log('ACTS_GetFileTypes_0500====<begin');
let ret = false;
let mimeTypeFilter = '*/jpg'
try {
var promise = DAHelper.getFileTypes(
dataAbilityUri,
mimeTypeFilter,
).then((data) => {
console.debug("=ACTS_GetFileTypes_0500 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
console.log('DataAbilityHelper getFileTypes data.length ====>: ' + data.length);
for (var i = 0; i < data.length; i++) {
expect(typeof (data[i])).assertEqual("string");
console.log('=ACTS_GetFileTypes_0500 for data [' + i + '] ====>: ' + data[i])
expect(data[i]).assertEqual("");
}
ret = true
done();
}).catch(err => {
console.debug("=ACTS_GetFileTypes_0500 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
console.log('DataAbilityHelper getFileTypes error ====>: ' + err)
ret = false
done();
});
console.log('=ACTS_GetFileTypes_0500 promise ====>: ' + promise)
} catch (err) {
console.error('=ACTS_GetFileTypes_0500 getFileTypes AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_GetFileTypes_0500====<end');
})
/*
* @tc.number: ACTS_GetFileTypes_0600
* @tc.name: Obtains the MIME type of files.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_GetFileTypes_0600', 0, async function (done) {
console.log('ACTS_GetFileTypes_0600====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility getFileTypes getDataAbilityHelper ====>: ' + DAHelper)
let mimeTypeFilter = '*/jpg'
try {
await DAHelper.getFileTypes(
dataAbilityUri,
mimeTypeFilter,
(err, data) => {
console.debug("=ACTS_GetFileTypes_0600 err,data=======>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;"));
console.log('=ACTS_GetFileTypes_0600 data.length ====>: ' + data.length);
for (var i = 0; i < data.length; i++) {
expect(typeof (data[i])).assertEqual("string");
console.log('=ACTS_GetFileTypes_0600 for errCode ====>: ' + err.code +
" data[" + i + "]: " + data[i]);
expect(data[i]).assertEqual("");
}
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_GetFileTypes_0600 catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_GetFileTypes_0600====<end');
})
/*
* @tc.number: ACTS_GetType_0100
* @tc.name: Obtains the MIME type matching the data specified by the URI of the Data ability.
* @tc.desc: Check the return value of the interface (by promise)
*/
it('ACTS_GetType_0100', 0, async function (done) {
console.log('ACTS_GetType_0100====<begin');
let ret = false;
try {
var promise = DAHelper.getType(
dataAbilityUri,
).then(data => {
console.debug("=ACTS_GetType_0100 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
//expect(typeof(data)).assertEqual("string")
expect(data).assertEqual(dataAbilityUri);
ret = true
done();
}).catch(err => {
console.debug("=ACTS_GetFileTypes_0500 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
console.log('featureAbility getType promise ====>: ' + promise)
} catch (err) {
console.error('=ACTS_GetType_0100 getType AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_GetType_0100====<end');
})
/*
* @tc.number: ACTS_GetType_0200
* @tc.name: Obtains the MIME type matching the data specified by the URI of the Data ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_GetType_0200', 0, async function (done) {
console.log('ACTS_GetType_0200====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility GetType getDataAbilityHelper ====>: ' + 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(typeof(data)).assertEqual("string");
expect(data).assertEqual(dataAbilityUri);
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_GetType_0200 getType AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_GetType_0200====<end');
})
/*
* @tc.number: ACTS_OpenFile_0100
* @tc.name: Opens a file. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by promise)
*/
it('ACTS_OpenFile_0100', 0, async function (done) {
console.log('ACTS_OpenFile_0100====<begin');
let ret = false;
var mode = "r";
try {
DAHelper.openFile(
dataAbilityUri,
mode,
).then((data) => {
console.debug("=ACTS_OpenFile_0100 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
expect(typeof (data)).assertEqual("number")
ret = true
done();
}).catch(err => {
console.debug("=ACTS_OpenFile_0100 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_OpenFile_0100 getType catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_OpenFile_0100====<end');
})
/*
* @tc.number: ACTS_OpenFile_0200
* @tc.name: Opens a file. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by promise)
*/
it('ACTS_OpenFile_0200', 0, async function (done) {
console.log('ACTS_OpenFile_0200====<begin');
let ret = false;
var mode = "w";
try {
DAHelper.openFile(
dataAbilityUri,
mode,
).then((data) => {
console.debug("=ACTS_OpenFile_0200 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
expect(typeof (data)).assertEqual("number")
console.log('DataAbilityHelper ACTS_OpenFile_0200 OpenFile promise ====>: ' + data)
ret = true
done();
}).catch(err => {
console.debug("=ACTS_OpenFile_0200 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
done();
});
} catch (err) {
console.error('=ACTS_OpenFile_0200 getType AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_OpenFile_0200====<end');
})
/*
* @tc.number: ACTS_OpenFile_0300
* @tc.name: Opens a file. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by promise)
*/
it('ACTS_OpenFile_0300', 0, async function (done) {
console.log('ACTS_OpenFile_0300====<begin');
let ret = false;
var mode = "wt";
try {
DAHelper.openFile(
dataAbilityUri,
mode,
).then((data) => {
console.debug("=ACTS_OpenFile_0300 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
expect(typeof (data)).assertEqual("number")
console.log('DataAbilityHelper ACTS_OpenFile_0300 OpenFile promise ====>: ' + data)
ret = true
done();
}).catch(err => {
console.debug("=ACTS_OpenFile_0300 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_OpenFile_0300 getType AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_OpenFile_0300====<end');
})
/*
* @tc.number: ACTS_OpenFile_0400
* @tc.name: Opens a file. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by promise)
*/
it('ACTS_OpenFile_0400', 0, async function (done) {
console.log('ACTS_OpenFile_0400====<begin');
let ret = false;
var mode = "wa";
try {
var promise = DAHelper.openFile(
dataAbilityUri,
mode,
).then((data) => {
console.debug("=ACTS_OpenFile_0400 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
expect(typeof (data)).assertEqual("number")
console.log('DataAbilityHelper ACTS_OpenFile_0400 OpenFile promise ====>: ' + data)
ret = true
done();
}).catch(err => {
console.debug("=ACTS_OpenFile_0400 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_OpenFile_0400 getType AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_OpenFile_0400====<end');
})
/*
* @tc.number: ACTS_OpenFile_0500
* @tc.name: Opens a file. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by promise)
*/
it('ACTS_OpenFile_0500', 0, async function (done) {
console.log('ACTS_OpenFile_0500====<begin');
let ret = false;
var mode = "rw";
try {
var promise = DAHelper.openFile(
dataAbilityUri,
mode,
).then((data) => {
console.debug("=ACTS_OpenFile_0500 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
expect(typeof (data)).assertEqual("number")
console.log('DataAbilityHelper ACTS_OpenFile_0500 OpenFile promise ====>: ' + data)
ret = true
done();
}).catch(err => {
console.debug("=ACTS_OpenFile_0500 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_OpenFile_0500 getType AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_OpenFile_0500====<end');
})
/*
* @tc.number: ACTS_OpenFile_0600
* @tc.name: Opens a file. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by promise)
*/
it('ACTS_OpenFile_0600', 0, async function (done) {
console.log('ACTS_OpenFile_0600====<begin');
let ret = false;
var mode = "rwt";
try {
var promise = DAHelper.openFile(
dataAbilityUri,
mode,
).then((data) => {
console.debug("=ACTS_OpenFile_0600 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
expect(typeof (data)).assertEqual("number")
console.log('DataAbilityHelper ACTS_OpenFile_0600 OpenFile promise ====>: ' + data)
ret = true
done();
}).catch(err => {
console.debug("=ACTS_OpenFile_0600 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_OpenFile_0600 getType AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_OpenFile_0600====<end');
})
/*
* @tc.number: ACTS_OpenFile_0700
* @tc.name: Opens a file. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_OpenFile_0700', 0, async function (done) {
console.log('ACTS_OpenFile_0700====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility ACTS_OpenFile_0700 OpenFile getDataAbilityHelper ====>: ' + 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
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_OpenFile_0700====<end');
})
/*
* @tc.number: ACTS_OpenFile_0800
* @tc.name: Opens a file. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_OpenFile_0800', 0, async function (done) {
console.log('ACTS_OpenFile_0800====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility ACTS_OpenFile_0800 OpenFile getDataAbilityHelper ====>: ' + DAHelper)
var mode = "w";
try {
DAHelper.openFile(
dataAbilityUri,
mode,
(err, data) => {
console.debug("=ACTS_OpenFile_0800 err,data=======>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;"));
expect(typeof (data)).assertEqual("number");
console.log('DataAbilityHelper ACTS_OpenFile_0800 OpenFile asyncCallback errCode ====>: '
+ err.code + " data: " + data);
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_OpenFile_0800 getType AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_OpenFile_0800====<end');
})
/*
* @tc.number: ACTS_OpenFile_0900
* @tc.name: Opens a file. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_OpenFile_0900', 0, async function (done) {
console.log('ACTS_OpenFile_0900====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility ACTS_OpenFile_0900 OpenFile getDataAbilityHelper ====>: ' + DAHelper)
var mode = "wt";
try {
DAHelper.openFile(
dataAbilityUri,
mode,
(err, data) => {
console.debug("=ACTS_OpenFile_0900 err,data=======>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;"));
expect(typeof (data)).assertEqual("number");
console.log('DataAbilityHelper ACTS_OpenFile_0900 OpenFile asyncCallback errCode ====>: '
+ err.code + " data: " + data);
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_OpenFile_0900 getType AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_OpenFile_0900====<end');
})
/*
* @tc.number: ACTS_OpenFile_1000
* @tc.name: Opens a file. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_OpenFile_1000', 0, async function (done) {
console.log('ACTS_OpenFile_1000====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility ACTS_OpenFile_1000 OpenFile getDataAbilityHelper ====>: ' + DAHelper)
var mode = "wa";
try {
DAHelper.openFile(
dataAbilityUri,
mode,
(err, data) => {
console.debug("=ACTS_OpenFile_1000 err,data====>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;"));
expect(typeof (data)).assertEqual("number");
console.log('DataAbilityHelper ACTS_OpenFile_1000 OpenFile asyncCallback errCode ====>: '
+ err.code + " data: " + data);
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_OpenFile_1000 getType AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_OpenFile_1000====<end');
})
/*
* @tc.number: ACTS_OpenFile_1100
* @tc.name: Opens a file. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_OpenFile_1100', 0, async function (done) {
console.log('ACTS_OpenFile_1100====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility ACTS_OpenFile_1100 OpenFile getDataAbilityHelper ====>: ' + DAHelper)
var mode = "rw";
try {
DAHelper.openFile(
dataAbilityUri,
mode,
(err, data) => {
console.debug("=ACTS_OpenFile_1100 err,data=======>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;"));
expect(typeof (data)).assertEqual("number");
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_OpenFile_1100 getType AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_OpenFile_1100====<end');
})
/*
* @tc.number: ACTS_OpenFile_1200
* @tc.name: Opens a file. This method should be implemented by a Data ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_OpenFile_1200', 0, async function (done) {
console.log('ACTS_OpenFile_1200====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility ACTS_OpenFile_1200 OpenFile getDataAbilityHelper ====>: ' + DAHelper)
var mode = "rwt";
try {
DAHelper.openFile(
dataAbilityUri,
mode,
(err, data) => {
console.debug("=ACTS_OpenFile_1200 err,data=======>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;"));
expect(typeof (data)).assertEqual("number");
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_OpenFile_1200 getType AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_OpenFile_1200====<end');
})
/*
* @tc.number: ACTS_Release_0100
* @tc.name: Releases the client resource of the Data ability.
* @tc.desc: Check the return value of the interface (by promise)
*/
it('ACTS_Release_0100', 0, async function (done) {
console.log('ACTS_Release_0100====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility ACTS_Release_0100 getDataAbilityHelper ====>: ' + DAHelper)
try {
DAHelper.release(
dataAbilityUri,
).then((data) => {
console.debug("=ACTS_Release_0100 then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + " , " + data);
// expect(typeof(data)).assertEqual("boolean")
expect(data).assertEqual(true);
ret = true
done();
}).catch(err => {
console.debug("=ACTS_Release_0100 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_Release_0100 release promise catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Release_0100====<end');
})
/*
* @tc.number: ACTS_Release_0200
* @tc.name: Releases the client resource of the Data ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_Release_0200', 0, async function (done) {
console.log('ACTS_Release_0200====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility ACTS_Release_0200 getDataAbilityHelper ====>: ' + DAHelper)
try {
DAHelper.release(
dataAbilityUri,
(err, data) => {
console.debug("=ACTS_Release_0200 err,data=======>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data) + (" 】;"));
console.log('featureAbility getDataAbilityHelper ACTS_Release_0100 data: ' + data)
//expect(typeof(data)).assertEqual("boolean");
expect(data).assertEqual(false);
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_Release_0200 release AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_Release_0200====<end');
})
/*
* @tc.number: ACTS_NormalizeUri_0100
* @tc.name: Converts the given uri that refer to the Data ability into a normalized URI.
* @tc.desc: Check the return value of the interface (by promise)
*/
it('ACTS_NormalizeUri_0100', 0, async function (done) {
console.log('ACTS_NormalizeUri_0100====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility normalizeUri getDataAbilityHelper ====>: ' + DAHelper)
try {
DAHelper.normalizeUri(
dataAbilityUri,
).then((data) => {
console.debug("=ACTS_NormalizeUri_0100 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
//expect(typeof(data)).assertEqual("string")
expect(data).assertEqual(dataAbilityUri);
ret = true
done();
}).catch(err => {
console.debug("=ACTS_NormalizeUri_0100 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_NormalizeUri_0100 normalizeUri promise catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_NormalizeUri_0100====<end');
})
/*
* @tc.number: ACTS_NormalizeUri_0200
* @tc.name: Converts the given uri that refer to the Data ability into a normalized URI.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_NormalizeUri_0200', 0, async function (done) {
console.log('ACTS_NormalizeUri_0200====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility normalizeUri getDataAbilityHelper ====>: ' + 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(typeof (data)).assertEqual("string");
expect(data).assertEqual(dataAbilityUri);
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_NormalizeUri_0200 normalizeUri AsyncCallback catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_NormalizeUri_0200====<end');
})
/*
* @tc.number: ACTS_DenormalizeUri_0100
* @tc.name: Converts the given normalized uri generated by normalizeUri into a denormalized one.
* @tc.desc: Check the return value of the interface (by promise)
*/
it('ACTS_DenormalizeUri_0100', 0, async function (done) {
console.log('ACTS_DenormalizeUri_0100====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility DenormalizeUri getDataAbilityHelper ====>: ' + DAHelper)
try {
DAHelper.denormalizeUri(
dataAbilityUri,
).then((data) => {
console.debug("=ACTS_DenormalizeUri_0100 then data====>"
+ ("json data 【") + JSON.stringify(data) + (""));
//expect(typeof(data)).assertEqual("string")
expect(data).assertEqual(dataAbilityUri);
ret = true
done();
}).catch(err => {
console.debug("=ACTS_DenormalizeUri_0100 catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
ret = false
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_DenormalizeUri_0100 denormalizeUri promise catch(err)====>:' + err);
ret = false
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_DenormalizeUri_0100====<end');
})
/*
* @tc.number: ACTS_DenormalizeUri_0200
* @tc.name: Converts the given normalized uri generated by normalizeUri into a denormalized one.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_DenormalizeUri_0200', 0, async function (done) {
console.log('ACTS_DenormalizeUri_0200====<begin');
let ret = false;
expect(typeof (DAHelper)).assertEqual("object");
console.log('featureAbility DenormalizeUri getDataAbilityHelper ====>: ' + 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(typeof(data)).assertEqual("string");
expect(data).assertEqual(dataAbilityUri);
ret = true
done();
},
);
} catch (err) {
console.error('=ACTS_DenormalizeUri_0200 denormalizeUri AsyncCallback catch(err)====>:' + err);
ret = true
expect(false).assertTrue();
done();
}
setTimeout(function () {
console.log('setTimeout function====<');
}, gSetTimeout);
console.log('ACTS_DenormalizeUri_0200====<end');
})
/*
* @tc.number: ACTS_OnOff_0100
* @tc.name: On/Off : Registers an observer to observe data specified by the given Uri
* @tc.desc: Check the return value of the interface ()
*/
it('ACTS_OnOff_0100', 0, async function (done) {
console.log('ACTS_OnOff_0100====<begin');
try {
var currentAlertTimeout;
expect(typeof (DAHelper)).assertEqual("object");
function onAsyncCallback_0100(err) {
expect(err.code).assertEqual(0);
clearTimeout(currentAlertTimeout);
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback_0100);
done();
}
DAHelper.on("dataChange", dataAbilityUri, onAsyncCallback_0100);
setTimeout(mySetTimeout, gSetTimeout);
function mySetTimeout() {
DAHelper.notifyChange(
dataAbilityUri,
(err) => {
if (err.code != 0) {
console.debug("=ACTS_OnOff_0100 err=======>"
+ ("err【") + JSON.stringify(err) + ("") + " , " + err);
expect(false).assertTrue();
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback_0100);
done();
} else {
currentAlertTimeout = setTimeout(() => {
console.debug('ACTS_OnOff_0100====< else true');
done();
}, gSetTimeout);
}
}
);
}
} catch (err) {
console.error('=ACTS_OnOff_0100 catch(err)====>:' + err);
expect(false).assertTrue();
done();
}
console.log('ACTS_OnOff_0100====<end');
})
/*
* @tc.number: ACTS_OnOff_0200
* @tc.name: On/Off : Registers an observer to observe data specified by the given Uri
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_OnOff_0200', 0, async function (done) {
console.log('ACTS_OnOff_0200====<begin');
try {
var currentAlertTimeout;
expect(typeof (DAHelper)).assertEqual("object");
function onAsyncCallback_0200(err) {
console.debug("=ACTS_OnOff_0200 onAsyncCallback_0200=======>");
expect(false).assertTrue();
clearTimeout(currentAlertTimeout);
done();
}
DAHelper.on("dataChange", dataAbilityUri, onAsyncCallback_0200);
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback_0200);
setTimeout(mySetTimeout, gSetTimeout);
function mySetTimeout() {
DAHelper.notifyChange(
dataAbilityUri,
(err) => {
if (err.code != 0) {
console.debug("=ACTS_OnOff_0200 err=======>"
+ ("err【") + JSON.stringify(err) + ("") + " , " + err);
expect(false).assertTrue();
done();
} else {
currentAlertTimeout = setTimeout(() => {
console.debug('ACTS_OnOff_0200====<setTimeout done()');
done();
}, gSetTimeout);
}
}
);
}
} catch (err) {
console.error('=ACTS_OnOff_0200 catch(err)====>:' + err);
expect(false).assertTrue();
done();
}
console.log('ACTS_OnOff_0200====<end');
})
/*
* @tc.number: ACTS_OnOff_0300
* @tc.name: On/Off : Registers an observer to observe data specified by the given Uri
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_OnOff_0300', 0, async function (done) {
console.log('ACTS_OnOff_0300====<begin');
var currentAlertTimeout;
var flagCallback01 = 0
var flagCallback02 = 0
var flagCallback03 = 0
function onAsyncCallback0301(err) {
expect(err.code).assertEqual(0);
flagCallback01++;
waitDone("onAsyncCallback0301");
}
function onAsyncCallback0302(err) {
expect(err.code).assertEqual(0);
flagCallback02++;
waitDone("onAsyncCallback0302");
}
function onAsyncCallback0303(err) {
expect(err.code).assertEqual(0);
flagCallback03++;
waitDone("onAsyncCallback0303");
}
function waitDone(caller) {
console.debug("=ACTS_OnOff_0300 caller ====>" + caller);
if (flagCallback01 == 1 && flagCallback02 == 1 && flagCallback03 == 1) {
clearTimeout(currentAlertTimeout);
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback0301);
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback0302);
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback0303);
done();
} else {
if (caller == "notifyChange") {
currentAlertTimeout = setTimeout(() => {
console.debug('ACTS_OnOff_0300====<setTimeout false done()');
expect(false).assertTrue();
done();
}, gSetTimeout);
}
}
}
try {
expect(typeof (DAHelper)).assertEqual("object");
DAHelper.on("dataChange", dataAbilityUri, onAsyncCallback0301);
DAHelper.on("dataChange", dataAbilityUri, onAsyncCallback0302);
DAHelper.on("dataChange", dataAbilityUri, onAsyncCallback0303);
setTimeout(mySetTimeout, gSetTimeout);
function mySetTimeout() {
DAHelper.notifyChange(
dataAbilityUri,
(err) => {
expect(err.code).assertEqual(0);
waitDone("notifyChange");
}
);
}
} catch (err) {
console.error('=ACTS_OnOff_0300 catch(err)====>:' + err);
expect(false).assertTrue();
done();
}
console.log('ACTS_OnOff_0300====<end');
})
/*
* @tc.number: ACTS_OnOff_0400
* @tc.name: On/Off : Registers an observer to observe data specified by the given Uri
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_OnOff_0400', 0, async function (done) {
console.log('ACTS_OnOff_0400====<begin');
var currentAlertTimeout;
var flagCallback01 = 0
var flagCallback02 = 0
var flagCallback03 = 0
function onAsyncCallback0401(err) {
expect(err.code).assertEqual(0);
flagCallback01++;
waitDone("onAsyncCallback0401");
}
function onAsyncCallback0402(err) {
flagCallback02++;
console.debug("=ACTS_OnOff_0400 flagCallback02 ====>"
+ ("json flagCallback02【") + JSON.stringify(flagCallback02) + ("") + " , " + flagCallback02);
expect(false).assertTrue();
clearTimeout(currentAlertTimeout);
done();
}
function onAsyncCallback0403(err) {
expect(err.code).assertEqual(0);
flagCallback03++;
waitDone("onAsyncCallback0403");
}
function waitDone(caller) {
console.debug("=ACTS_OnOff_0400 caller ====>" + caller);
if (flagCallback01 == 1 && flagCallback02 == 0 && flagCallback03 == 1) {
clearTimeout(currentAlertTimeout);
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback0401);
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback0403);
done();
} else {
if (caller == "notifyChange") {
currentAlertTimeout = setTimeout(() => {
console.debug('ACTS_OnOff_0400====<setTimeout false done()');
expect(false).assertTrue();
done();
}, gSetTimeout);
}
}
}
try {
expect(typeof (DAHelper)).assertEqual("object");
DAHelper.on("dataChange", dataAbilityUri, onAsyncCallback0401);
DAHelper.on("dataChange", dataAbilityUri, onAsyncCallback0402);
DAHelper.on("dataChange", dataAbilityUri, onAsyncCallback0403);
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback0402);
setTimeout(mySetTimeout, gSetTimeout);
function mySetTimeout() {
DAHelper.notifyChange(
dataAbilityUri,
(err) => {
expect(err.code).assertEqual(0);
waitDone("notifyChange");
}
);
}
} catch (err) {
console.error('=ACTS_OnOff_0400 catch(err)====>:' + err);
expect(false).assertTrue();
done();
}
console.log('ACTS_OnOff_0400====<end');
})
/*
* @tc.number: ACTS_OnOff_0500
* @tc.name: On/Off : Registers an observer to observe data specified by the given Uri
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_OnOff_0500', 0, async function (done) {
console.log('ACTS_OnOff_0500====<begin');
var currentAlertTimeout;
function onAsyncCallback0501(err) {
console.debug("=ACTS_OnOff_0500 err ====>"
+ ("json err【") + JSON.stringify(err) + ("") + " , " + err);
expect(false).assertTrue();
clearTimeout(currentAlertTimeout);
done();
}
function onAsyncCallback0502(err) {
console.debug("=ACTS_OnOff_0500 err ====>"
+ ("json err【") + JSON.stringify(err) + ("") + " , " + err);
expect(false).assertTrue();
clearTimeout(currentAlertTimeout);
done();
}
function onAsyncCallback0503(err) {
console.debug("=ACTS_OnOff_0500 err ====>"
+ ("json err") + JSON.stringify(err) + ("") + " , " + err);
expect(false).assertTrue();
clearTimeout(currentAlertTimeout);
done();
}
try {
expect(typeof (DAHelper)).assertEqual("object");
DAHelper.on("dataChange", dataAbilityUri, onAsyncCallback0501);
DAHelper.on("dataChange", dataAbilityUri, onAsyncCallback0502);
DAHelper.on("dataChange", dataAbilityUri, onAsyncCallback0503);
DAHelper.off("dataChange", dataAbilityUri);
setTimeout(mySetTimeout, gSetTimeout);
function mySetTimeout() {
DAHelper.notifyChange(
dataAbilityUri,
(err) => {
if (err.code != 0) {
console.debug("=ACTS_OnOff_0500 err=======>"
+ ("err【") + JSON.stringify(err) + ("") + " , " + err);
expect(false).assertTrue();
clearTimeout(currentAlertTimeout);
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback_0100);
done();
} else {
currentAlertTimeout = setTimeout(() => {
console.debug('ACTS_OnOff_0500====<setTimeout done()');
done();
}, gSetTimeout);
}
}
);
}
} catch (err) {
console.error('=ACTS_OnOff_0500 catch(err)====>:' + err);
expect(false).assertTrue();
done();
}
console.log('ACTS_OnOff_0500====<end');
})
/*
* @tc.number: ACTS_OnOff_0600
* @tc.name: On/Off : Registers an observer to observe data specified by the given Uri
* @tc.desc: Check the return value of the interface ()
*/
it('ACTS_OnOff_0600', 0, async function (done) {
console.log('ACTS_OnOff_0600====<begin');
try {
var currentAlertTimeout;
expect(typeof (DAHelper)).assertEqual("object");
var flagCallback01 = 0;
function onAsyncCallback_0600(err) {
expect(err.code).assertEqual(0);
flagCallback01++;
waitDone(flagCallback01)
}
var DAHelper2 = featureAbility.acquireDataAbilityHelper(dataAbilityUri2);
expect(typeof (DAHelper2)).assertEqual("object");
DAHelper.on("dataChange", dataAbilityUri, onAsyncCallback_0600);
DAHelper2.on("dataChange", dataAbilityUri2, onAsyncCallback_0600);
function waitDone(caller) {
console.debug("=ACTS_OnOff_0600 caller ====>" + caller);
if (flagCallback01 == 2) {
clearTimeout(currentAlertTimeout);
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback_0600);
DAHelper2.off("dataChange", dataAbilityUri2, onAsyncCallback_0600);
done();
} else {
if (caller == "notifyChange") {
currentAlertTimeout = setTimeout(() => {
console.debug('ACTS_OnOff_0600====<setTimeout false done()');
expect(false).assertTrue();
done();
}, gSetTimeout);
}
}
}
setTimeout(mySetTimeout, gSetTimeout);
function mySetTimeout() {
DAHelper.notifyChange(
dataAbilityUri,
(err) => {
if (err.code != 0) {
console.debug("=ACTS_OnOff_0600 err=======>"
+ ("err【") + JSON.stringify(err) + ("") + " , " + err);
expect(false).assertTrue();
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback_0600);
DAHelper2.off("dataChange", dataAbilityUri2, onAsyncCallback_0600);
done();
} else {
DAHelper2.notifyChange(
dataAbilityUri2,
(err) => {
if (err.code != 0) {
console.debug("=ACTS_OnOff_0600 err=======>"
+ ("err【") + JSON.stringify(err) + ("") + " , " + err);
expect(false).assertTrue();
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback_0600);
DAHelper2.off("dataChange", dataAbilityUri2, onAsyncCallback_0600);
done();
} else {
waitDone("notifyChange");
}
}
);
}
}
);
}
} catch (err) {
console.error('=ACTS_OnOff_0600 catch(err)====>:' + err);
expect(false).assertTrue();
done();
}
console.log('ACTS_OnOff_0600====<end');
})
/*
* @tc.number: ACTS_OnOff_0700
* @tc.name: On/Off : Registers an observer to observe data specified by the given Uri
* @tc.desc: Check the return value of the interface ()
*/
it('ACTS_OnOff_0700', 0, async function (done) {
console.log('ACTS_OnOff_0700====<begin');
try {
var currentAlertTimeout;
expect(typeof (DAHelper)).assertEqual("object");
function onAsyncCallback_0700(err) {
clearTimeout(currentAlertTimeout);
expect(false).assertTrue();
done();
}
var DAHelper2 = featureAbility.acquireDataAbilityHelper(dataAbilityUri);
expect(typeof (DAHelper2)).assertEqual("object");
DAHelper.on("dataChange", dataAbilityUri, onAsyncCallback_0700);
DAHelper2.on("dataChange", dataAbilityUri2, onAsyncCallback_0700);
DAHelper.off("dataChange", dataAbilityUri);
DAHelper2.off("dataChange", dataAbilityUri2);
setTimeout(mySetTimeout, gSetTimeout);
function mySetTimeout() {
DAHelper.notifyChange(
dataAbilityUri,
(err) => {
if (err.code != 0) {
console.debug("=ACTS_OnOff_0700 err=======>"
+ ("err【") + JSON.stringify(err) + ("") + " , " + err);
expect(false).assertTrue();
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback_0700);
DAHelper2.off("dataChange", dataAbilityUri2, onAsyncCallback_0700);
done();
} else {
DAHelper2.notifyChange(
dataAbilityUri2,
(err) => {
if (err.code != 0) {
console.debug("=ACTS_OnOff_0700 err=======>"
+ ("err【") + JSON.stringify(err) + ("") + " , " + err);
expect(false).assertTrue();
DAHelper.off("dataChange", dataAbilityUri, onAsyncCallback_0700);
DAHelper2.off("dataChange", dataAbilityUri2, onAsyncCallback_0700);
done();
} else {
currentAlertTimeout = setTimeout(() => {
done();
}, gSetTimeout);
}
}
);
}
}
);
}
} catch (err) {
console.error('=ACTS_OnOff_0700 catch(err)====>:' + err);
expect(false).assertTrue();
done();
}
console.log('ACTS_OnOff_0700====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Insert_0100
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_ExecuteBatch_Insert_0100', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Insert_0100====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Insert_0100_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
).then((data) => {
console.debug("=ACTS_ExecuteBatch_Insert_0100 executeBatch then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + " , " + data.length);
expect(true).assertTrue();
done();
}).catch((err) => {
console.debug("=ACTS_ExecuteBatch_Insert_0100 executeBatch catch err ====>"
+ ("json err 【") + JSON.stringify(err) + ("") + " , " + err);
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_ExecuteBatch_Insert_0100 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Insert_0100====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Insert_0200
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_ExecuteBatch_Insert_0200', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Insert_0200====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Insert_0200_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
).then((data) => {
console.debug("=ACTS_ExecuteBatch_Insert_0200 executeBatch then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + " , " + data.length);
expect(true).assertTrue();
done();
}).catch((err) => {
console.debug("=ACTS_ExecuteBatch_Insert_0200 executeBatch catch err ====>"
+ ("json err 【") + JSON.stringify(err) + ("") + " , " + err);
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_ExecuteBatch_Insert_0200 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Insert_0200====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Insert_0300
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_ExecuteBatch_Insert_0300', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Insert_0300====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Insert_0300_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
).then((data) => {
console.debug("=ACTS_ExecuteBatch_Insert_0300 executeBatch then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + " , " + data.length);
expect(true).assertTrue();
done();
}).catch((err) => {
console.debug("=ACTS_ExecuteBatch_Insert_0300 executeBatch catch err ====>"
+ ("json err 【") + JSON.stringify(err) + ("") + " , " + err);
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_ExecuteBatch_Insert_0300 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Insert_0300====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Insert_0400
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_ExecuteBatch_Insert_0400', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Insert_0400====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Insert_0400_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
(err, data) => {
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);
done();
}
);
} catch (err) {
console.error('=ACTS_ExecuteBatch_Insert_0400 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Insert_0400====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Insert_0500
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_ExecuteBatch_Insert_0500', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Insert_0500====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Insert_0500_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
(err, data) => {
console.debug("=ACTS_ExecuteBatch_Insert_0500 executeBatch err,data====>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data)
+ (" 】;") + data.length);
expect(err.code).assertEqual(0);
done();
}
);
} catch (err) {
console.error('=ACTS_ExecuteBatch_Insert_0500 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Insert_0500====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Insert_0600
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_ExecuteBatch_Insert_0600', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Insert_0600====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Insert_0600_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
(err, data) => {
console.debug("=ACTS_ExecuteBatch_Insert_0600 executeBatch err,data====>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data)
+ (" 】;") + data.length);
expect(err.code).assertEqual(0);
done();
}
);
} catch (err) {
console.error('=ACTS_ExecuteBatch_Insert_0600 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Insert_0600====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Update_0100
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_ExecuteBatch_Update_0100', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Update_0100====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Update_0100_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
).then((data) => {
console.debug("=ACTS_ExecuteBatch_Update_0100 executeBatch then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Update_0100 for data[' + i + '].count ====>: ' + data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}).catch((err) => {
console.debug("=ACTS_ExecuteBatch_Update_0100 executeBatch catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_ExecuteBatch_Update_0100 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Update_0100====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Update_0200
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_ExecuteBatch_Update_0200', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Update_0200====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Update_0200_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('name', "ACTS_ExecuteBatch_Update_0200_rose");
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
).then((data) => {
console.debug("=ACTS_ExecuteBatch_Update_0200 executeBatch then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Update_0200 for data[' + i + '].count ====>: ' + data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}).catch((err) => {
console.debug("=ACTS_ExecuteBatch_Update_0200 executeBatch catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_ExecuteBatch_Update_0200 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Update_0200====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Update_0300
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_ExecuteBatch_Update_0300', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Update_0300====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Update_0300_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
).then((data) => {
console.debug("=ACTS_ExecuteBatch_Update_0300 executeBatch then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Update_0300 for data[' + i + '].count ====>: ' + data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}).catch((err) => {
console.debug("=ACTS_ExecuteBatch_Update_0300 executeBatch catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_ExecuteBatch_Update_0300 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Update_0300====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Update_0400
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_ExecuteBatch_Update_0400', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Update_0400====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Update_0400_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
(err, data) => {
console.debug("=ACTS_ExecuteBatch_Update_0400 executeBatch err,data====>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【")
+ JSON.stringify(data) + (" 】;") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Update_0400 for data[' + i + '].count ====>: '
+ data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}
);
} catch (err) {
console.error('=ACTS_ExecuteBatch_Update_0400 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Update_0400====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Update_0500
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_ExecuteBatch_Update_0500', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Update_0500====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Update_0500_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
(err, data) => {
console.debug("=ACTS_ExecuteBatch_Update_0500 executeBatch err,data====>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data)
+ (" 】;") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Update_0300 for data[' + i + '].count ====>: '
+ data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}
);
} catch (err) {
console.error('=ACTS_ExecuteBatch_Update_0500 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Update_0500====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Update_0600
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_ExecuteBatch_Update_0600', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Update_0600====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Update_0600_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
(err, data) => {
console.debug("=ACTS_ExecuteBatch_Update_0600 executeBatch err,data====>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data)
+ (" 】;") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Update_0300 for data[' + i + '].count ====>: '
+ data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}
);
} catch (err) {
console.error('=ACTS_ExecuteBatch_Update_0600 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Update_0600====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Assert_0100
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_ExecuteBatch_Assert_0100', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Assert_0100====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Assert_0100_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
).then((data) => {
console.debug("=ACTS_ExecuteBatch_Assert_0100 executeBatch then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Assert_0100 for data[' + i + '].count ====>: ' + data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}).catch((err) => {
console.debug("=ACTS_ExecuteBatch_Assert_0100 executeBatch catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_ExecuteBatch_Assert_0100 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Assert_0100====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Assert_0200
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_ExecuteBatch_Assert_0200', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Assert_0200====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Assert_0200_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
).then((data) => {
console.debug("=ACTS_ExecuteBatch_Assert_0200 executeBatch then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Assert_0200 for data[' + i + '].count ====>: ' + data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}).catch((err) => {
console.debug("=ACTS_ExecuteBatch_Assert_0200 executeBatch catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_ExecuteBatch_Assert_0200 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Assert_0200====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Assert_0300
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_ExecuteBatch_Assert_0300', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Assert_0300====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Assert_0300_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
).then((data) => {
console.debug("=ACTS_ExecuteBatch_Assert_0300 executeBatch then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Assert_0300 for data[' + i + '].count ====>: ' + data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}).catch((err) => {
console.debug("=ACTS_ExecuteBatch_Assert_0300 executeBatch catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_ExecuteBatch_Assert_0300 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Assert_0300====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Assert_0400
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_ExecuteBatch_Assert_0400', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Assert_0400====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Assert_0400_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
(err, data) => {
console.debug("=ACTS_ExecuteBatch_Assert_0400 executeBatch err,data====>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data)
+ (" 】;") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Assert_0400 for data[' + i + '].count ====>: '
+ data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}
);
} catch (err) {
console.error('=ACTS_ExecuteBatch_Assert_0400 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Assert_0400====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Assert_0500
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_ExecuteBatch_Assert_0500', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Assert_0500====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Assert_0500_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
(err, data) => {
console.debug("=ACTS_ExecuteBatch_Assert_0500 executeBatch err,data====>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data)
+ (" 】;") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Assert_0500 for data[' + i + '].count ====>: '
+ data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}
);
} catch (err) {
console.error('=ACTS_ExecuteBatch_Assert_0500 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Assert_0500====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Assert_0600
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_ExecuteBatch_Assert_0600', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Assert_0600====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Assert_0600_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
(err, data) => {
console.debug("=ACTS_ExecuteBatch_Assert_0600 executeBatch err,data====>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data)
+ (" 】;") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Assert_0600 for data[' + i + '].count ====>: '
+ data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}
);
} catch (err) {
console.error('=ACTS_ExecuteBatch_Assert_0600 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Assert_0600====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Delete_0100
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_ExecuteBatch_Delete_0100', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Delete_0100====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Delete_0100_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
).then((data) => {
console.debug("=ACTS_ExecuteBatch_Delete_0100 executeBatch then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Delete_0100 for data[' + i + '].count ====>: ' + data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}).catch((err) => {
console.debug("=ACTS_ExecuteBatch_Delete_0100 executeBatch catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_ExecuteBatch_Delete_0100 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Delete_0100====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Delete_0200
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_ExecuteBatch_Delete_0200', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Delete_0200====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Delete_0200_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
).then((data) => {
console.debug("=ACTS_ExecuteBatch_Delete_0200 executeBatch then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Delete_0200 for data[' + i + '].count ====>: ' + data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}).catch((err) => {
console.debug("=ACTS_ExecuteBatch_Delete_0200 executeBatch catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_ExecuteBatch_Delete_0200 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Delete_0200====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Delete_0300
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_ExecuteBatch_Delete_0300', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Delete_0300====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Delete_0300_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
).then((data) => {
console.debug("=ACTS_ExecuteBatch_Delete_0300 executeBatch then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Delete_0300 for data[' + i + '].count ====>: ' + data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}).catch((err) => {
console.debug("=ACTS_ExecuteBatch_Delete_0300 executeBatch catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_ExecuteBatch_Delete_0300 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Delete_0300====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Delete_0400
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_ExecuteBatch_Delete_0400', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Delete_0400====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Delete_0400_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
(err, data) => {
console.debug("=ACTS_ExecuteBatch_Delete_0400 executeBatch err,data====>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data)
+ (" 】;") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Delete_0400 for data[' + i + '].count ====>: '
+ data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}
);
} catch (err) {
console.error('=ACTS_ExecuteBatch_Delete_0400 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Delete_0400====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Delete_0500
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_ExecuteBatch_Delete_0500', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Delete_0500====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Delete_0500_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
(err, data) => {
console.debug("=ACTS_ExecuteBatch_Delete_0500 executeBatch err,data====>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data)
+ (" 】;") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Delete_0500 for data[' + i + '].count ====>: '
+ data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}
);
} catch (err) {
console.error('=ACTS_ExecuteBatch_Delete_0500 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Delete_0500====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_Delete_0600
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_ExecuteBatch_Delete_0600', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_Delete_0600====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_Delete_0600_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
(err, data) => {
console.debug("=ACTS_ExecuteBatch_Delete_0600 executeBatch err,data====>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data)
+ (" 】;") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_Delete_0600 for data[' + i + '].count ====>: '
+ data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}
);
} catch (err) {
console.error('=ACTS_ExecuteBatch_Delete_0600 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_Delete_0600====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_0100
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_ExecuteBatch_0100', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_0100====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_0100_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
).then((data) => {
console.debug("=ACTS_ExecuteBatch_0100 executeBatch then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_0100 for data[' + i + '].count ====>: ' + data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}).catch((err) => {
console.debug("=ACTS_ExecuteBatch_0100 executeBatch catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_ExecuteBatch_0100 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_0100====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_0200
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_ExecuteBatch_0200', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_0200====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_0200_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
(err, data) => {
console.debug("=ACTS_ExecuteBatch_0200 executeBatch err,data====>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data)
+ (" 】;") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_0200 for data[' + i + '].count ====>: ' + data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}
);
} catch (err) {
console.error('=ACTS_ExecuteBatch_0200 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_0200====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_0300
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_ExecuteBatch_0300', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_0300====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_0300_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
).then((data) => {
console.debug("=ACTS_ExecuteBatch_0300 executeBatch then data====>"
+ ("json data 【") + JSON.stringify(data) + ("") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_0300 for data[' + i + '].count ====>: ' + data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}).catch((err) => {
console.debug("=ACTS_ExecuteBatch_0300 executeBatch catch err ====>"
+ ("json err 【") + JSON.stringify(err) + (""));
expect(false).assertTrue();
done();
});
} catch (err) {
console.error('=ACTS_ExecuteBatch_0300 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_0300====<end');
})
/*
* @tc.number: ACTS_ExecuteBatch_0400
* @tc.name: ExecuteBatch : Preforms batch operations on the database
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_ExecuteBatch_0400', 0, async function (done) {
console.debug('ACTS_ExecuteBatch_0400====<begin');
try {
expect(typeof (DAHelper)).assertEqual("object");
const valuesBucket = {
"name": "ACTS_ExecuteBatch_0400_rose",
"age": 22,
"salary": 200.5,
"blobType": "u8",
}
let predicates = new ohosDataAbility.DataAbilityPredicates();
predicates.equalTo('contact_id', 1);
predicates.limitAs(10);
predicates.orderByAsc("order_by_class");
predicates.offsetAs(1);
DAHelper.executeBatch(dataAbilityUri,
[
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_INSERT,
valuesBucket: valuesBucket,
predicates: null,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_UPDATE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_ASSERT,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
},
{
uri: dataAbilityUri2,
type: featureAbility.DataAbilityOperationType.TYPE_DELETE,
valuesBucket: valuesBucket,
predicates: predicates,
expectedCount: 1,
PredicatesBackReferences: {},
interrupted: true,
}
],
(err, data) => {
console.debug("=ACTS_ExecuteBatch_0400 executeBatch err,data====>"
+ ("json err【") + JSON.stringify(err) + (" 】json data【") + JSON.stringify(data)
+ (" 】;") + data.length);
expect(true).assertTrue();
for (var i = 0; i < data.length; i++) {
console.debug('=ACTS_ExecuteBatch_0400 for data[' + i + '].count ====>: ' + data[i].count)
expect(data[i].count).assertEqual(1);
}
done();
}
);
} catch (err) {
console.error('=ACTS_ExecuteBatch_0400 catch(err)====>:'
+ ("json err 【") + JSON.stringify(err) + (" 】 ,") + err);
expect(false).assertTrue();
done();
}
console.debug('ACTS_ExecuteBatch_0400====<end');
})
})
\ 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.
*/
require('./DataAbilityHelperJsSt.test.js')
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsParticleAbilityTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsParticleAbilityTest"
}
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"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "com.example.actsparticleabilitytest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsParticleAbilityTest.hap",
"ParticleStartAbility.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"./resource/appexecfwk/amsStDataAbility.hap->/data/test/amsStDataAbility.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/test/*.hap",
"bm install -p /data/test/amsStDataAbility.hap"
]
}
]
}
{
"app": {
"bundleName": "com.example.actsparticleabilitytest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsparticleabilitytest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsparticleabilitytest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.btn {
width: 200px;
height: 80px;
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<button class="btn" type="capsule" value="start" onclick="start"></button>
</div>
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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: ""
},
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.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
{
"string": [
{
"name": "app_name",
"value": "actsparticleabilitytest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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 commonEvent from "@ohos.commonevent"
import rpc from "@ohos.rpc"
import featureAbility from '@ohos.ability.featureAbility'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
const START_ABILITY_TIMEOUT = 4000;
var subscriberInfoStartAbility_0100 = {
events: ["ACTS_Particle_StartAbility_0100_CommonEvent", "DISCONNECT_0100"],
};
var subscriberInfoStartAbility_0200 = {
events: ["ACTS_Particle_StartAbility_0200_CommonEvent", "DISCONNECT_0200"],
};
var subscriberInfoAcquireDataHelper_0100 = {
events: ["ACTS_AcquireDataHelper_01001", "DISCONNECT_0300"],
};
var subscriberInfoAcquireDataHelper_0200 = {
events: ["ACTS_AcquireDataHelper_02000", "DISCONNECT_0400"],
};
describe('ActsParticleAbilityTest', function () {
let bundleName = "com.example.particletestserver";
let abilityName = "com.example.particletestserver.MainAbility";
var mRemote;
function onConnectCallback(element, remote) {
console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.deviceId : ' + element.deviceId)
console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.bundleName : ' + element.bundleName)
console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.abilityName : ' + element.abilityName)
console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.uri : ' + element.uri)
console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.shortName : ' + element.shortName)
console.log('ACTS_featureAbilityTest ConnectAbility onConnect remote : ' + remote);
mRemote = remote;
console.log('ACTS_featureAbilityTest ConnectAbility onConnect remote 是否为proxy:' + (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback1(element) {
commonEvent.publish("DISCONNECT_0100", ()=>{console.log('disconnect finish1')});
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.bundleName : ' + element.bundleName)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.abilityName : ' + element.abilityName)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.uri : ' + element.uri)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.shortName : ' + element.shortName)
}
function onDisconnectCallback2(element) {
commonEvent.publish("DISCONNECT_0200", ()=>{console.log('disconnect finish2')});
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.bundleName : ' + element.bundleName)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.abilityName : ' + element.abilityName)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.uri : ' + element.uri)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.shortName : ' + element.shortName)
}
function onDisconnectCallback3(element) {
commonEvent.publish("DISCONNECT_0300", ()=>{console.log('disconnect finish3')});
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.bundleName : ' + element.bundleName)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.abilityName : ' + element.abilityName)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.uri : ' + element.uri)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.shortName : ' + element.shortName)
}
function onDisconnectCallback4(element) {
commonEvent.publish("DISCONNECT_0400", ()=>{console.log('disconnect finish4')});
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.bundleName : ' + element.bundleName)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.abilityName : ' + element.abilityName)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.uri : ' + element.uri)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.shortName : ' + element.shortName)
}
function onFailedCallback(code) {
console.log('ACTS_featureAbilityTest ConnectAbility onFailed errCode : ' + code)
}
/*
* @tc.number: ACTS_ParticleAbility_startAbility_0100
* @tc.name: ConnectAbility : Connects an ability to a Service ability and use service to test startAbiltiy.
* @tc.desc: Check the event of the interface startAbiltiy (by promise)
*/
it('ACTS_ParticleAbility_startAbility_0100', 0, async function (done) {
console.log('ACTS_ParticleAbility_startAbility_0100====<begin');
console.log('========StartConnect called');
var subscriber;
let id;
let connId;
let events = new Map();
function subscribeCallBack(err, data) {
console.debug("====>Subscribe CallBack data:====>" + JSON.stringify(data));
events.set(data.event, 0);
if(events.size == 1){
if(data.event != "DISCONNECT_0100"){
clearTimeout(id);
expect(data.event).assertEqual("ACTS_Particle_StartAbility_0100_CommonEvent");
featureAbility.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
},
);
} else {
expect(data.event).assertEqual("DISCONNECT_0100");
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
done();
}
} else {
expect(data.event).assertEqual("DISCONNECT_0100");
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
done();
}
}
commonEvent.createSubscriber(subscriberInfoStartAbility_0100).then(async (data) => {
console.debug("====>Create Subscriber====>");
subscriber = data;
await commonEvent.subscribe(subscriber, subscribeCallBack);
})
function unSubscribeCallback() {
console.debug("====>UnSubscribe CallBack====>");
}
function timeout() {
expect().assertFail();
console.debug('ACTS_ParticleAbility_startAbility_0100 timeout');
featureAbility.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
},
);
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
connId = await featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "StartAbilityPromise"
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback1,
onFailed: onFailedCallback,
},
);
console.log('StartConnectNative ConnectAbility connId : ' + connId);
})
/*
* @tc.number: ACTS_ParticleAbility_startAbility_0200
* @tc.name: ConnectAbility : Connects an ability to a Service ability and use service to test startAbiltiy.
* @tc.desc: Check the event of the interface startAbiltiy (by callback)
*/
it('ACTS_ParticleAbility_startAbility_0200', 0, async function (done) {
console.log('ACTS_ParticleAbility_startAbility_0200====<begin');
console.log('========StartConnect called');
var subscriber;
let id;
let connId;
let events = new Map();
function subscribeCallBack(err, data) {
console.debug("====>Subscribe CallBack data:====>" + JSON.stringify(data));
events.set(data.event, 0);
if(events.size == 1){
if(data.event != "DISCONNECT_0200"){
clearTimeout(id);
expect(data.event).assertEqual("ACTS_Particle_StartAbility_0200_CommonEvent");
featureAbility.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
},
);
} else {
expect(data.event).assertEqual("DISCONNECT_0200");
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
done();
}
} else {
expect(data.event).assertEqual("DISCONNECT_0200");
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
done();
}
}
commonEvent.createSubscriber(subscriberInfoStartAbility_0200).then(async (data) => {
console.debug("====>Create Subscriber====>");
subscriber = data;
await commonEvent.subscribe(subscriber, subscribeCallBack);
})
function unSubscribeCallback() {
console.debug("====>UnSubscribe CallBack====>");
}
function timeout() {
expect().assertFail();
console.debug('ACTS_ParticleAbility_startAbility_0200 timeout');
featureAbility.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
},
);
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
connId = await featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "StartAbilityCallback"
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback2,
onFailed: onFailedCallback,
},
);
console.log('StartConnectNative ConnectAbility connId : ' + connId);
})
/*
* @tc.number: ACTS_ParticleAbility_acquireDataAbilityHelper_0100
* @tc.name: ConnectAbility : Connects an ability to a Service ability and
* use service to test acquireDataAbilityHelper.
* @tc.desc: Check the event of the interface
*/
it('ACTS_ParticleAbility_acquireDataAbilityHelper_0100', 0, async function (done) {
console.log('ACTS_ParticleAbility_acquireDataAbilityHelper_0100====<begin');
console.log('========StartConnect called');
var subscriber;
let id;
let connId;
let events = new Map();
function subscribeCallBack(err, data) {
console.debug("====>Subscribe CallBack data:====>" + JSON.stringify(data));
events.set(data.event, 0);
if(events.size == 1){
if(data.event != "DISCONNECT_0300"){
clearTimeout(id);
expect(data.event).assertEqual("ACTS_AcquireDataHelper_01001");
featureAbility.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
},
);
} else {
expect(data.event).assertEqual("DISCONNECT_0300");
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
done();
}
} else {
expect(data.event).assertEqual("DISCONNECT_0300");
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
done();
}
}
commonEvent.createSubscriber(subscriberInfoAcquireDataHelper_0100).then(async (data) => {
console.debug("====>Create Subscriber====>");
subscriber = data;
await commonEvent.subscribe(subscriber, subscribeCallBack);
})
function unSubscribeCallback() {
console.debug("====>UnSubscribe CallBack====>");
}
function timeout() {
expect().assertFail();
console.debug('ACTS_ParticleAbility_acquireDataAbilityHelper_0100 timeout');
featureAbility.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
},
);
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
connId = await featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "AcquireDataHelper"
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback3,
onFailed: onFailedCallback,
},
);
console.log('StartConnectNative ConnectAbility connId : ' + connId);
})
/*
* @tc.number: ACTS_ParticleAbility_acquireDataAbilityHelper_0200
* @tc.name: ConnectAbility : Connects an ability to a Service ability and
* use service to test acquireDataAbilityHelper.
* @tc.desc: Check the event of the interface
*/
it('ACTS_ParticleAbility_acquireDataAbilityHelper_0200', 0, async function (done) {
console.log('ACTS_ParticleAbility_acquireDataAbilityHelper_0200====<begin');
console.log('========StartConnect called');
var subscriber;
let id;
let connId;
let events = new Map();
function subscribeCallBack(err, data) {
console.debug("====>Subscribe CallBack data:====>" + JSON.stringify(data));
events.set(data.event, 0);
if(events.size == 1){
if(data.event != "DISCONNECT_0400"){
clearTimeout(id);
expect(data.event).assertEqual("ACTS_AcquireDataHelper_02000");
featureAbility.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
},
);
} else {
expect(data.event).assertEqual("DISCONNECT_0400");
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
done();
}
} else {
expect(data.event).assertEqual("DISCONNECT_0400");
commonEvent.unsubscribe(subscriber, unSubscribeCallback)
done();
}
}
commonEvent.createSubscriber(subscriberInfoAcquireDataHelper_0200).then(async (data) => {
console.debug("====>Create Subscriber====>");
subscriber = data;
await commonEvent.subscribe(subscriber, subscribeCallBack);
})
function unSubscribeCallback() {
console.debug("====>UnSubscribe CallBack====>");
}
function timeout() {
expect().assertFail();
console.debug('ACTS_ParticleAbility_acquireDataAbilityHelper_0200 timeout');
featureAbility.disconnectAbility(
connId,
(error, data) => {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
},
);
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
connId = await featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "AcquireDataHelper_no"
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback4,
onFailed: onFailedCallback,
},
);
console.log('StartConnectNative ConnectAbility connId : ' + connId);
})
})
\ 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.
*/
require('./ActsParticleAbilityTest.test.js')
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAmsStServiceAbilityClientTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAmsStServiceAbilityClientTest"
}
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"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.amsst.stserviceabilityclient",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAmsStServiceAbilityClientTest.hap",
"amsStServiceAilityServer.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.amsst.stserviceabilityclient",
"vendor": "amsst",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.amsst.stserviceabilityclient",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.amsst.stserviceabilityclient.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
StServiceAbilityClient
</text>
</div>
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 app from '@system.app'
import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index'
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'
})
const reportExtend = new ReportExtend(file)
core.addService('expect', expectExtend)
core.addService('report', reportExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "StSeAbClient"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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.
*/
require('./StServiceAbilityClient.test.js')
\ 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 featureAbility from '@ohos.ability.featureAbility'
import commonEvent from '@ohos.commonevent'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe('ActsStServiceAbilityTest', function () {
let bundleName = "com.amsst.stserviceabilityserver";
let abilityName = "com.amsst.stserviceabilityserver.MainAbility";
var subscriber_0100;
var CommonEventSubscribeInfo_0100 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0100",
],
};
var subscriber_0200;
var CommonEventSubscribeInfo_0200 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0200",
],
};
var subscriber_0300;
var CommonEventSubscribeInfo_0300 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0300",
"ACTS_SerivceAbilityServer_onCommand_PageStartService_0301",
],
};
var subscriber_0400;
var CommonEventSubscribeInfo_0400 = {
events: ["ACTS_SerivceAbilityServer_onCommand_PageStartService_0400",
"ACTS_SerivceAbilityServer_onCommand_PageStartService_0401",
],
};
var subscriber_0500;
var CommonEventSubscribeInfo_0500 = {
events: ["ACTS_SerivceAbilityServer_onConnect_PageConnectService_0500",
"ACTS_SerivceAbilityServer_onDisConnect",
],
};
var subscriber_0600;
var CommonEventSubscribeInfo_0600 = {
events: ["ACTS_SerivceAbilityServer_onConnect_PageConnectService_0600",
"ACTS_SerivceAbilityServer_onDisConnect",
],
};
var subscriber_0900;
var CommonEventSubscribeInfo_0900 = {
events: ["ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_0900",
],
};
var subscriber_1000;
var CommonEventSubscribeInfo_1000 = {
events: ["ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_1000",
],
};
var subscriber_1300;
var CommonEventSubscribeInfo_1300 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1300",
"ACTS_SerivceAbilityServerSecond_onDisConnect",
],
};
var subscriber_1400;
var CommonEventSubscribeInfo_1400 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1400",
"ACTS_SerivceAbilityServerSecond_onDisConnect",
],
};
var subscriber_1500;
var CommonEventSubscribeInfo_1500 = {
events: ["ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1500",
"ACTS_SerivceAbilityServer_onDisConnect",
],
};
function unsubscribe(caller, subscriber) {
commonEvent.unsubscribe(subscriber, (err, data) => {
console.debug("=ACTS_unsubscribe (err,data)=======>"
+ (caller)
+ (" , json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
});
}
let g_setTimeout = 1000
beforeAll(async (done) => {
console.debug('= ACTS_beforeAll ====<begin');
console.debug('= ACTS_beforeAll ====<end');
done();
})
beforeEach(async (done) => {
setTimeout(function () {
done();
}, g_setTimeout);
})
afterEach(async (done) => {
setTimeout(function () {
done();
}, g_setTimeout);
})
afterAll((done) => {
console.debug('= ACTS_afterAll ====<begin');
setTimeout(function () {
console.debug('= ACTS_afterAll ====<end');
featureAbility.terminateSelf();
done();
}, g_setTimeout);
})
/*
* @tc.number: ACTS_JsServiceAbility_0100
* @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_JsServiceAbility_0100', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0100====<begin');
try {
commonEvent.createSubscriber(CommonEventSubscribeInfo_0100).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_0100 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber_0100 = data;
await commonEvent.subscribe(subscriber_0100, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0100 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0100").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0100_unsubscribe", subscriber_0100);
console.debug('ACTS_JsServiceAbility_0100====<end');
done();
});
})
featureAbility.startAbility(
{
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0100",
},
}
).then(data => {
console.debug("=ACTS_JsServiceAbility_0100 .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
}).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0100====<end .catch(err)');
done();
})
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0100====<end catch(err)');
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_0200
* @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_JsServiceAbility_0200', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0200====<begin');
try {
commonEvent.createSubscriber(CommonEventSubscribeInfo_0200).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_0200 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber_0200 = data;
await commonEvent.subscribe(subscriber_0200, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0200 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0200").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0200_unsubscribe", subscriber_0200);
console.debug('ACTS_JsServiceAbility_0200====<end');
done()
});
})
await featureAbility.startAbility(
{
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0200",
},
}, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0200 startAbility (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
}
)
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0200====<end catch(err)');
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_0300
* @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_JsServiceAbility_0300', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0300====<begin');
try {
commonEvent.createSubscriber(CommonEventSubscribeInfo_0300).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_0300 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber_0300 = data;
await commonEvent.subscribe(subscriber_0300, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0300 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
if (data.event == "ACTS_SerivceAbilityServer_onCommand_PageStartService_0300") {
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0300").assertEqual(
data.event);
featureAbility.startAbility(
{
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0301",
},
}
).then(data => {
console.debug("=ACTS_JsServiceAbility_0300 .then(data) 2=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
}).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0300====<end .catch(err) 2');
done();
})
} else {
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0301").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0300_unsubscribe", subscriber_0300);
console.debug('ACTS_JsServiceAbility_0300====<end');
done();
}
});
})
featureAbility.startAbility(
{
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0300",
},
}
).then(data => {
console.debug("=ACTS_JsServiceAbility_0300 .then(data) 1=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
}).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0300====<end .catch(err) 1');
done();
})
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0300====<end catch(err)');
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_0400
* @tc.name: featureAbility.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_JsServiceAbility_0400', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0400====<begin');
try {
commonEvent.createSubscriber(CommonEventSubscribeInfo_0400).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_0400 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber_0400 = data;
await commonEvent.subscribe(subscriber_0400, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0400 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
if (data.event == "ACTS_SerivceAbilityServer_onCommand_PageStartService_0400") {
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0400").assertEqual(
data.event);
featureAbility.startAbility(
{
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0401",
},
}, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0400 startAbility (err,data) 2=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
}
)
} else {
expect("ACTS_SerivceAbilityServer_onCommand_PageStartService_0401").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0400_unsubscribe", subscriber_0400);
console.debug('ACTS_JsServiceAbility_0400====<end');
done();
}
});
})
featureAbility.startAbility(
{
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageStartService_0400",
},
}, (err, data) => {
console.debug("=ACTS_JsServiceAbility_0400 startAbility (err,data) 1=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
}
)
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0400====<end catch(err)');
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_0500
* @tc.name: featureAbility.ConnectAbility : Connects an ability to a Service ability.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_JsServiceAbility_0500', 0, async function (done) {
console.log('ACTS_JsServiceAbility_0500====<begin');
try {
var mConnIdJsPromise;
commonEvent.createSubscriber(CommonEventSubscribeInfo_0500).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_0500 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber_0500 = data;
await commonEvent.subscribe(subscriber_0500, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0500 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
if (data.event != "ACTS_SerivceAbilityServer_onDisConnect") {
expect("ACTS_SerivceAbilityServer_onConnect_PageConnectService_0500").assertEqual(
data.event);
featureAbility.disconnectAbility(mConnIdJsPromise).then(() => {
}).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0500====<end .catch(err)');
done();
})
} else {
expect("ACTS_SerivceAbilityServer_onDisConnect").assertEqual(data.event);
unsubscribe("ACTS_JsServiceAbility_0500_unsubscribe", subscriber_0500);
console.debug('ACTS_JsServiceAbility_0500====<end');
done();
}
});
})
function onConnectCallback(element, remote) {
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> mConnIdJsPromise='
+ JSON.stringify(mConnIdJsPromise) + " , " + mConnIdJsPromise);
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
console.debug('ACTS_JsServiceAbility_0500_onConnectCallback ====> remote is proxy:'
+ (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_0500_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
}
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_0500_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
}
mConnIdJsPromise = featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageConnectService_0500",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_0500====<end err')
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_0600
* @tc.name: featureAbility.ConnectAbility : Connects an ability to a Service ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_JsServiceAbility_0600', 0, async function (done) {
console.log('ACTS_JsServiceAbility_0600====<begin');
try {
var mConnIdJsAsyncCallback;
commonEvent.createSubscriber(CommonEventSubscribeInfo_0600).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_0600 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber_0600 = data;
await commonEvent.subscribe(subscriber_0600, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0600 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
if (data.event != "ACTS_SerivceAbilityServer_onDisConnect") {
expect("ACTS_SerivceAbilityServer_onConnect_PageConnectService_0600").assertEqual(
data.event);
featureAbility.disconnectAbility(mConnIdJsAsyncCallback, (err) => {
console.debug("=ACTS_JsServiceAbility_0600 disconnectAbility err====>"
+ ("json err=") + JSON.stringify(err));
})
} else {
expect("ACTS_SerivceAbilityServer_onDisConnect").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0600_unsubscribe", subscriber_0600);
console.log('ACTS_JsServiceAbility_0600====<end')
done();
}
});
})
function onConnectCallback(element, remote) {
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> mConnIdJsAsyncCallback='
+ JSON.stringify(mConnIdJsAsyncCallback) + " , " + mConnIdJsAsyncCallback);
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
console.debug('ACTS_JsServiceAbility_0600_onConnectCallback ====> remote is proxy:'
+ (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_0600_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
}
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_0600_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
}
mConnIdJsAsyncCallback = featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "PageConnectService_0600",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_0600====<end err')
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_0900
* @tc.name: particleability.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_JsServiceAbility_0900', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_0900====<begin');
try {
commonEvent.createSubscriber(CommonEventSubscribeInfo_0900).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_0900 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber_0900 = data;
await commonEvent.subscribe(subscriber_0900, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_0900 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
expect("ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_0900").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_0900_unsubscribe", subscriber_0900);
console.debug('ACTS_JsServiceAbility_0900====<end');
done();
});
})
featureAbility.startAbility(
{
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceStartService_0900",
},
}
).then(data => {
console.debug("=ACTS_JsServiceAbility_0900 .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
}).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0900====<end .catch(err)');
done();
})
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_0900====<end catch(err)');
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_1000
* @tc.name: particleability.startAbility : Use page to test startAbiltiy service.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_JsServiceAbility_1000', 0, async function (done) {
console.debug('ACTS_JsServiceAbility_1000====<begin');
try {
commonEvent.createSubscriber(CommonEventSubscribeInfo_1000).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_1000 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber_1000 = data;
await commonEvent.subscribe(subscriber_1000, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_1000 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
expect("ACTS_SerivceAbilityServerSecond_onCommand_ServiceStartService_1000").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_1000_unsubscribe", subscriber_1000);
console.debug('ACTS_JsServiceAbility_1000====<end');
done()
});
})
await featureAbility.startAbility(
{
want:
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceStartService_1000",
},
}, (err, data) => {
console.debug("=ACTS_JsServiceAbility_1000 startAbility (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
}
)
} catch (err) {
expect("catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_1000====<end catch(err)');
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_1300
* @tc.name: particleability.ConnectAbility : Connects an ability to a Service ability.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_JsServiceAbility_1300', 0, async function (done) {
console.log('ACTS_JsServiceAbility_1300====<begin');
try {
var mConnIdJsPromise;
commonEvent.createSubscriber(CommonEventSubscribeInfo_1300).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_1300 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber_1300 = data;
await commonEvent.subscribe(subscriber_1300, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_1300 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
if (data.event != "ACTS_SerivceAbilityServerSecond_onDisConnect") {
expect("ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1300"
).assertEqual(data.event);
featureAbility.disconnectAbility(mConnIdJsPromise).then((err) => {
console.debug("=ACTS_JsServiceAbility_1300 disconnectAbility err====>"
+ ("json err=") + JSON.stringify(err));
})
} else {
expect("ACTS_SerivceAbilityServerSecond_onDisConnect").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_1300_unsubscribe", subscriber_1300);
console.log('ACTS_JsServiceAbility_1300====<end')
done();
}
});
})
function onConnectCallback(element, remote) {
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> mConnIdJsPromise='
+ JSON.stringify(mConnIdJsPromise) + " , " + mConnIdJsPromise);
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
console.debug('ACTS_JsServiceAbility_1300_onConnectCallback ====> remote is proxy:'
+ (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_1300_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
unsubscribe("ACTS_JsServiceAbility_1300_unsubscribe", subscriber_1300);
console.log('ACTS_JsServiceAbility_1300====<end onDisconnectCallback')
done();
}
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_1300_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
}
mConnIdJsPromise = featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceConnectService_1300",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_1300====<end err')
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_1400
* @tc.name: particleability.ConnectAbility : Connects an ability to a Service ability.
* @tc.desc: Check the return value of the interface (by AsyncCallback)
*/
it('ACTS_JsServiceAbility_1400', 0, async function (done) {
console.log('ACTS_JsServiceAbility_1400====<begin');
try {
var mConnIdJsAsyncCallback;
commonEvent.createSubscriber(CommonEventSubscribeInfo_1400).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_1400 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber_1400 = data;
await commonEvent.subscribe(subscriber_1400, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_1400 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
if (data.event != "ACTS_SerivceAbilityServerSecond_onDisConnect") {
expect("ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1400"
).assertEqual(data.event);
featureAbility.disconnectAbility(mConnIdJsAsyncCallback, (err) => {
console.debug("=ACTS_JsServiceAbility_1400 disconnectAbility err====>"
+ ("json err=") + JSON.stringify(err));
})
} else {
expect("ACTS_SerivceAbilityServerSecond_onDisConnect").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_1400_unsubscribe", subscriber_1400);
console.log('ACTS_JsServiceAbility_1400====<end')
done();
}
});
})
function onConnectCallback(element, remote) {
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> mConnIdJsAsyncCallback='
+ JSON.stringify(mConnIdJsAsyncCallback) + " , " + mConnIdJsAsyncCallback);
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
console.debug('ACTS_JsServiceAbility_1400_onConnectCallback ====> remote is proxy:'
+ (remote instanceof rpc.RemoteProxy));
}
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_1400_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
}
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_1400_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
}
mConnIdJsAsyncCallback = featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceConnectService_1400",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_1400====<end err')
done();
}
})
/*
* @tc.number: ACTS_JsServiceAbility_1500
* @tc.name: particleability.ConnectAbility : Connects an ability to a Service ability.
* @tc.desc: Check the return value of the interface (by Promise)
*/
it('ACTS_JsServiceAbility_1500', 0, async function (done) {
console.log('ACTS_JsServiceAbility_1500====<begin');
try {
var mConnIdJsPromise;
commonEvent.createSubscriber(CommonEventSubscribeInfo_1500).then(async (data) => {
console.debug("=ACTS_JsServiceAbility_1500 createSubscriber .then(data)=======>"
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,data=" + data);
subscriber_1500 = data;
await commonEvent.subscribe(subscriber_1500, async (err, data) => {
console.debug("=ACTS_JsServiceAbility_1500 subscribe (err,data)=======>"
+ ("json err【") + JSON.stringify(err) + ("")
+ ("json data【") + JSON.stringify(data) + ("")
+ " ,err=" + err + " ,data=" + data);
if (data.event != "ACTS_SerivceAbilityServer_onDisConnect") {
expect("ACTS_SerivceAbilityServerSecond_onConnect_ServiceConnectService_1500").assertEqual(
data.event);
featureAbility.disconnectAbility(mConnIdJsPromise).then(() => {
}).catch(err => {
expect(".catch").assertEqual(err);
console.debug('ACTS_JsServiceAbility_1500====<end .catch(err)');
done();
})
} else {
expect("ACTS_SerivceAbilityServer_onDisConnect").assertEqual(
data.event);
unsubscribe("ACTS_JsServiceAbility_1500_unsubscribe", subscriber_1500);
console.log('ACTS_JsServiceAbility_1500====<end')
done();
}
});
})
function onConnectCallback(element, remote) {
console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> mConnIdJsPromise='
+ JSON.stringify(mConnIdJsPromise) + " , " + mConnIdJsPromise);
console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
console.debug('ACTS_JsServiceAbility_1500_onConnectCallback ====> remote='
+ JSON.stringify(remote) + " , " + remote);
}
function onDisconnectCallback(element) {
console.debug('ACTS_JsServiceAbility_1500_onDisconnectCallback ====> element='
+ JSON.stringify(element) + " , " + element);
unsubscribe("ACTS_JsServiceAbility_1500_unsubscribe", subscriber_1500);
console.log('ACTS_JsServiceAbility_1500====<end onDisconnectCallback')
done();
}
function onFailedCallback(code) {
console.debug('ACTS_JsServiceAbility_1500_onFailedCallback ====> code='
+ JSON.stringify(code) + " , " + code)
}
mConnIdJsPromise = featureAbility.connectAbility(
{
bundleName: bundleName,
abilityName: abilityName,
action: "ServiceConnectService_1500",
},
{
onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback,
onFailed: onFailedCallback,
},
)
} catch (err) {
expect("catch").assertEqual(err);
console.log('ACTS_JsServiceAbility_1500====<end err')
done();
}
})
})
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAmsJsStMainTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAmsJsStMainTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
}
{
"app": {
"bundleName": "com.amsst.amsjsstmain",
"vendor": "amsst",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"defPermissions": [
{
"name": "com.amsst.permission.SYSPERMISSION",
"grantMode": "system_grant",
"availableScope": []
},
{
"name": "ohos.permission.GET_NETWORK_INFO",
"grantMode": "system_grant",
"availableScope": []
},
{
"name": "ohos.permission.GET_WIFI_INFO",
"grantMode": "system_grant",
"availableScope": []
},
{
"name": "ohos.permission.SET_NETWORK_INFO",
"grantMode": "system_grant",
"availableScope": []
},
{
"name": "ohos.permission.SET_WIFI_INFO",
"grantMode": "system_grant",
"availableScope": []
},
{
"name": "ohos.permission.CAMERA",
"grantMode": "user_grant",
"availableScope": []
},
{
"name": "ohos.permission.PERMISSIONA",
"grantMode": "user_grant",
"availableScope": []
},
{
"name": "ohos.permission.PERMISSIONB",
"grantMode": "user_grant",
"availableScope": []
},
{
"name": "ohos.permission.PERMISSIONC",
"grantMode": "user_grant",
"availableScope": []
},
{
"name": "ohos.permission.PERMISSIOND",
"grantMode": "user_grant",
"availableScope": []
}
],
"reqPermissions": [
{
"name": "ohos.permission.CAMERA",
"reason": "$string:permreason_camera",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "com.amsst.permission.SYSPERMISSION",
"reason": "$string:permreason_sys",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.PERMISSIONA",
"reason": "NEED ohos.permission.PERMISSIONA",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.PERMISSIONB",
"reason": "NEED ohos.permission.PERMISSIONB",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.PERMISSIONC",
"reason": "NEED ohos.permission.PERMISSIONC",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.PERMISSIOND",
"reason": "NEED ohos.permission.PERMISSIOND",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.GET_NETWORK_INFO",
"reason": "$string:permreason_getnetworkinfo",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.USE_BLUETOOTH"
},
{
"name": "ohos.permission.DISCOVER_BLUETOOTH"
},
{
"name": "ohos.permission.SET_NETWORK_INFO"
},
{
"name": "ohos.permission.SET_WIFI_INFO"
},
{
"name": "ohos.permission.SPREAD_STATUS_BAR"
},
{
"name": "ohos.permission.INTERNET"
},
{
"name": "ohos.permission.MODIFY_AUDIO_SETTINGS"
},
{
"name": "ohos.permission.RECEIVER_STARTUP_COMPLETED"
},
{
"name": "ohos.permission.RUNNING_LOCK"
},
{
"name": "ohos.permission.ACCESS_BIOMETRIC"
},
{
"name": "ohos.permission.RCV_NFC_TRANSACTION_EVENT"
},
{
"name": "ohos.permission.COMMONEVENT_STICKY"
},
{
"name": "ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.VIBRATE"
},
{
"name": "ohos.permission.USE_TRUSTCIRCLE_MANAGER"
},
{
"name": "ohos.permission.USE_WHOLE_SCREEN"
},
{
"name": "ohos.permission.SET_WALLPAPER"
},
{
"name": "ohos.permission.SET_WALLPAPER_DIMENSION"
},
{
"name": "ohos.permission.REARRANGE_MISSIONS"
},
{
"name": "ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name": "ohos.permission.KEEP_BACKGROUND_RUNNING"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO"
},
{
"name": "ohos.permission.ACCELEROMETER"
},
{
"name": "ohos.permission.GYROSCOPE"
},
{
"name": "ohos.permission.MULTIMODAL_INTERACTIVE"
},
{
"name": "ohos.permission.radio.ACCESS_FM_AM"
},
{
"name": "ohos.permission.NFC_TAG"
},
{
"name": "ohos.permission.NFC_CARD_EMULATION"
},
{
"name": "ohos.permission.DISTRIBUTED_DEVICE_STATE_CHANGE"
},
{
"name": "ohos.permission.GET_DISTRIBUTED_DEVICE_INFO"
}
],
"package": "com.amsst.amsjsstmain",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.amsst.amsjsstmain.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index",
"pages/permissionPage/permissionPage"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
}
\ 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 32px;
color: #000000;
opacity: 0.9;
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFFFFF;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url("../../common/images/Wallpaper.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.title {
font-size: 100px;
color: #FFFFFF;
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
div>div{
width: 100%;
height: 200px;
flex-direction: column;
align-items: center;
justify-content: center;
}
.btn{
margin-bottom: 20px;
}
\ No newline at end of file
<div class="container">
<div>
<text class="title">
{{ title }}
</text>
</div>
<div>
<input class="btn" type="button" value="permissionTest" on:click="clickAction"></input>
</div>
</div>
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 app from '@system.app'
import router from '@system.router';
import featureAbility from '@ohos.ability.featureability'
export default {
data: {
title: "AmsJsStMain"
},
onInit() {
console.debug('====onInit()====<')
this.title = "AmsJsStMain";
},
onShow() {
console.debug('====onShow()====<')
},
onReady() {
console.debug('====onReady finish====<')
},
onBackPress(){
console.debug('====onBackPress()====<')
},
async stopAbility(){
console.debug('====close====<')
await featureAbility.terminateAbility();
},
clickAction(){
console.debug('====clickAction====<')
router.replace({
uri: 'pages/permissionPage/permissionPage'
})
},
titleAction(){
console.debug('====titleAction()====<')
this.title += "\nMyTest"
},
}
.container {
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 30px;
text-align: center;
width: 100%;
height: 80px;
}
div{
flex-direction: column;
align-items: center;
justify-content: center;
}
.btn{
margin-bottom: 10px;
width: 200px;
height: 50px;
justify-content: center;
}
.log {
font-size: 20px;
text-align: center;
width: 100%;
height: 250px;
}
.todo-wraper {
width: 100%;
height: 600px;
justify-content: center;
}
.todo-item {
width: 100%;
justify-content: center;
}
.text {
margin: 20%;
}
.menu-wraper {
width: 100%;
height: 100px;
justify-content: center;
}
\ No newline at end of file
<div class="container">
<div>
<text class="title">
{{ title }}
</text>
</div>
<div class="log">
<textarea class="log">
{{logmessage}}
</textarea>
</div>
<div>
<list class="todo-wraper">
<list-item for="{{testcase}}" class="todo-item">
<input class="btn" type="button" value="{{$item}}" on:click="runCase({{$item}})"></input>
</list-item>
</list>
</div>
</div>
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 app from '@system.app'
import router from '@system.router';
import featureAbility from '@ohos.ability.featureability'
import bundle from '@ohos.bundle'
import { Core, ExpectExtend, ReportExtend } from 'deccjsunit/index'
export default {
currentCase: "",
data: {
title: "AbilityA1",
logmessage: "this is log message",
testcase: [
"ACTS_AppPermission_0100",
"ACTS_AppPermission_0200",
"ACTS_AppPermission_0300",
"ACTS_AppPermission_0400",
"ACTS_AppPermission_0500",
"ACTS_AppPermission_0600",
"ACTS_AppPermission_0700",
"ACTS_AppPermission_0800",
"ACTS_AppPermission_0900",
"ACTS_AppPermission_1000",
"ACTS_AppPermission_1100",
"ACTS_AppPermission_1200",
"ACTS_AppPermission_1300",
"ACTS_AppPermission_1400",
"ACTS_AppPermission_1500",
"ACTS_AppPermission_1600",
"ACTS_AppPermission_1700",
"ACTS_AppPermission_1800",
"ACTS_AppPermission_1900",
"ACTS_AppPermission_2000",
"ACTS_AppPermission_2100",
"ACTS_AppPermission_2200",
"ACTS_AppPermission_2300",
"ACTS_AppPermission_2400",
"ACTS_AppPermission_2500",
"ACTS_AppPermission_2600",
"ACTS_AppPermission_2700",
"ACTS_AppPermission_2800",
],
},
onInit() {
this.title = "AbilityA1";
this.logmessage = "this is log message";
},
onShow() {
},
onReady() {
console.info('====per onReady finish====>')
},
onBackPress() {
},
async stopAbility() {
console.info('===========per close===========>')
await featureAbility.terminateAbility();
await app.killProcessesByBundleName();
},
clickAction() {
router.replace({
uri: 'pages/index/index'
})
},
runCase(caseName) {
console.debug("======per runCase======>:" + JSON.stringify(caseName))
this.logmessage += caseName + "\n"
console.debug("======per runallcase======<:")
let { runAllCase } = require('./permissioncase.js')
runAllCase(caseName, this)
}
}
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 bundle from '@ohos.bundle'
import featureAbility from '@ohos.ability.featureability'
import abilityManager from '@ohos.app.abilitymanager'
export function runAllCase(caseName, obj) {
console.debug("====runAllCase1====>:" + JSON.stringify(caseName))
console.debug("====runAllCase2====>:" + JSON.stringify(allCase))
allCase[caseName].func(obj)
}
export function getCaseInfo(caseName) {
console.debug("====getCaseInfo====>:" + JSON.stringify(caseName))
return allCase[caseName].info;
}
var MY_PERMISSIONS_REQUEST_PERMISSION = 1;
var allCase = {
"ACTS_AppPermission_0100": {
func: ACTS_AppPermission_0100,
info: "Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_0200": {
func: ACTS_AppPermission_0200,
info: "Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_0300": {
func: ACTS_AppPermission_0300,
info: "Verify that a user_grant system`s permission(ohos.permission.CAMERA) "
+ "is not automatically requested during installation."
},
"ACTS_AppPermission_0400": {
func: ACTS_AppPermission_0400,
info: "Verify that a user_grant system`s permission(ohos.permission.CAMERA) "
+ "is not automatically requested during installation."
},
"ACTS_AppPermission_0500": {
func: ACTS_AppPermission_0500,
info: "Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_0600": {
func: ACTS_AppPermission_0600,
info: "Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_0700": {
func: ACTS_AppPermission_0700,
info: "Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_0800": {
func: ACTS_AppPermission_0800,
info: "Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_0900": {
func: ACTS_AppPermission_0900,
info: "Verify that a user_grant system`s permission(ohos.permission.CAMERA) "
+ "is not automatically requested during installation."
},
"ACTS_AppPermission_1000": {
func: ACTS_AppPermission_1000,
info: "Verify that a user_grant system`s permission(ohos.permission.CAMERA) "
+ "is not automatically requested during installation."
},
"ACTS_AppPermission_1100": {
func: ACTS_AppPermission_1100,
info: "Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_1200": {
func: ACTS_AppPermission_1200,
info: "Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION) "
+ "is automatically requested during installation."
},
"ACTS_AppPermission_1300": {
func: ACTS_AppPermission_1300,
info: "Verify that calling application(different application in the same device) "
+ "is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)"
},
"ACTS_AppPermission_1400": {
func: ACTS_AppPermission_1400,
info: "Verify that calling application(different application in the same device) "
+ "is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)"
},
"ACTS_AppPermission_1500": {
func: ACTS_AppPermission_1500,
info: "Verify that calling application(different application in the same device) "
+ "is not requested the user_grant system`s permission(ohos.permission.CAMERA)"
},
"ACTS_AppPermission_1600": {
func: ACTS_AppPermission_1600,
info: "Verify that calling application(different application in the same device) "
+ "is not requested the user_grant system`s permission(ohos.permission.CAMERA)"
},
"ACTS_AppPermission_1700": {
func: ACTS_AppPermission_1700,
info: "Verify that calling application(different application in the same device) "
+ "is requested the system_grant user`s permission(com.amsst.permission.SYSPERMISSION)"
},
"ACTS_AppPermission_1800": {
func: ACTS_AppPermission_1800,
info: "Verify that calling application(different application in the same device) "
+ "is requested the system_grant user`s permission(com.amsst.permission.SYSPERMISSION)"
},
"ACTS_AppPermission_1900": {
func: ACTS_AppPermission_1900,
info: "Verify that application without calling application(other device) "
+ "is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)"
},
"ACTS_AppPermission_2000": {
func: ACTS_AppPermission_2000,
info: "Verify that application without calling application(other device) "
+ "is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)"
},
"ACTS_AppPermission_2100": {
func: ACTS_AppPermission_2100,
info: "Verify that application without calling application(other device) "
+ "is not requested the system_grant system`s permission(ohos.permission.GET_WIFI_INFO)"
},
"ACTS_AppPermission_2200": {
func: ACTS_AppPermission_2200,
info: "Verify that application without calling application(other device) "
+ "is not requested the system_grant system`s permission(ohos.permission.GET_WIFI_INFO)"
},
"ACTS_AppPermission_2300": {
func: ACTS_AppPermission_2300,
info: "Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO) "
+ "can not requested during runtime."
},
"ACTS_AppPermission_2400": {
func: ACTS_AppPermission_2400,
info: "Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO) "
+ "can not requested during runtime."
},
"ACTS_AppPermission_2500": {
func: ACTS_AppPermission_2500,
info: "Verify that a user_grant system`s permission(ohos.permission.CAMERA) "
+ "can requested during runtime."
},
"ACTS_AppPermission_2600": {
func: ACTS_AppPermission_2600,
info: "Verify that a user_grant system`s permission(ohos.permission.CAMERA) can requested during runtime."
},
"ACTS_AppPermission_2700": {
func: ACTS_AppPermission_2700,
info: "Verify that a user_grant system`s permission(ohos.permission.PERMISSIOND) can requested during runtime."
},
"ACTS_AppPermission_2800": {
func: ACTS_AppPermission_2800,
info: "Verify that a user_grant system`s permission(2 permissions) can requested during runtime."
},
}
async function getThisProcessInfo() {
console.debug("====getThisProcessInfo:begin====<");
var processInfoArray = await abilityManager.getAllRunningProcesses();
var thisProcessInfo = processInfoArray[0];
for (let i = 0; i < processInfoArray.length; i++) {
if (processInfoArray[i].processName == "com.amsst.amsjsstmain") {
thisProcessInfo = processInfoArray[i]
break
}
}
console.debug("======getThisProcessInfo:end======<");
return thisProcessInfo;
}
/*
* @tc.number : ACTS_AppPermission_0100
* @tc.name : Verify that ohos.permission.GET_NETWORK_INFO is requested
* @tc.desc : Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
* is automatically requested during installation.
*/
async function ACTS_AppPermission_0100(thisobj) {
var thisFunctionName = ACTS_AppPermission_0100.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
await context.verifyPermission("ohos.permission.GET_NETWORK_INFO",
{
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
},
(err, data) => {
console.debug("====verifyPermission:data====>:" + JSON.stringify(data))
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
} else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
);
}
/*
* @tc.number : ACTS_AppPermission_0200
* @tc.name : Verify that ohos.permission.GET_NETWORK_INFO is requested
* @tc.desc : Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
* is automatically requested during installation.
*/
async function ACTS_AppPermission_0200(thisobj) {
var thisFunctionName = ACTS_AppPermission_0200.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
var result = await context.verifyPermission("ohos.permission.GET_NETWORK_INFO", {
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
});
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
} else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : ACTS_AppPermission_0300
* @tc.name : Verify that ohos.permission.CAMERA is not requested
* @tc.desc : Verify that a user_grant system`s permission(ohos.permission.CAMERA)
* is not automatically requested during installation.
*/
async function ACTS_AppPermission_0300(thisobj) {
var thisFunctionName = ACTS_AppPermission_0300.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
await context.verifyPermission("ohos.permission.CAMERA",
{
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
},
(err, data) => {
console.debug("======verifyPermission:data======>:" + JSON.stringify(data))
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == -1) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
);
}
/*
* @tc.number : ACTS_AppPermission_0400
* @tc.name : Verify that ohos.permission.CAMERA is requested
* @tc.desc : Verify that a user_grant system`s permission(ohos.permission.CAMERA)
* is automatically requested during installation.
*/
async function ACTS_AppPermission_0400(thisobj) {
var thisFunctionName = ACTS_AppPermission_0400.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
var result = await context.verifyPermission("ohos.permission.CAMERA", {
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
});
console.debug("======verifyPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == -1) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : ACTS_AppPermission_0500
* @tc.name : Verify that com.amsst.permission.SYSPERMISSION is requested
* @tc.desc : Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION)
* is automatically requested during installation.
*/
async function ACTS_AppPermission_0500(thisobj) {
var thisFunctionName = ACTS_AppPermission_0500.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
await context.verifyPermission("com.amsst.permission.SYSPERMISSION",
{
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
},
(err, data) => {
console.debug("======verifyPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : ACTS_AppPermission_0600
* @tc.name : Verify that com.amsst.permission.SYSPERMISSION is requested
* @tc.desc : Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION)
* is automatically requested during installation.
*/
async function ACTS_AppPermission_0600(thisobj) {
var thisFunctionName = ACTS_AppPermission_0600.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
var result = await context.verifyPermission("com.amsst.permission.SYSPERMISSION", {
options: {
pid: thisProcessInfo.pid,
uid: thisProcessInfo.uid,
}
});
console.debug("======verifyPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : ACTS_AppPermission_0700
* @tc.name : Verify that ohos.permission.GET_NETWORK_INFO is requested
* @tc.desc : Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
* is automatically requested during installation.
*/
async function ACTS_AppPermission_0700(thisobj) {
var thisFunctionName = ACTS_AppPermission_0700.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext();
await context.verifySelfPermission("ohos.permission.GET_NETWORK_INFO",
(err, data) => {
console.debug("======verifySelfPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : ACTS_AppPermission_0800
* @tc.name : Verify that ohos.permission.GET_NETWORK_INFO is requested by self
* @tc.desc : Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
* is automatically requested during installation.
*/
async function ACTS_AppPermission_0800(thisobj) {
var thisFunctionName = ACTS_AppPermission_0800.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext();
var result = await context.verifySelfPermission("ohos.permission.GET_NETWORK_INFO");
console.debug("======verifySelfPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : ACTS_AppPermission_0900
* @tc.name : Verify that ohos.permission.CAMERA is not requested by self
* @tc.desc : Verify that a user_grant system`s permission(ohos.permission.CAMERA)
* is not automatically requested during installation.
*/
async function ACTS_AppPermission_0900(thisobj) {
var thisFunctionName = ACTS_AppPermission_0900.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext();
await context.verifySelfPermission("ohos.permission.CAMERA",
(err, data) => {
console.debug("======verifySelfPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == -1) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : ACTS_AppPermission_1000
* @tc.name : Verify that ohos.permission.CAMERA is requested by self
* @tc.desc : Verify that a user_grant system`s permission(ohos.permission.CAMERA)
* is automatically requested during installation.
*/
async function ACTS_AppPermission_1000(thisobj) {
var thisFunctionName = ACTS_AppPermission_1000.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext();
var result = await context.verifySelfPermission("ohos.permission.CAMERA")
console.debug("======verifySelfPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == -1) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : ACTS_AppPermission_1100
* @tc.name : Verify that com.amsst.permission.SYSPERMISSION is requested by self
* @tc.desc : Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION)
* is automatically requested during installation.
*/
async function ACTS_AppPermission_1100(thisobj) {
var thisFunctionName = ACTS_AppPermission_1100.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext();
await context.verifySelfPermission("com.amsst.permission.SYSPERMISSION",
(err, data) => {
console.debug("======verifySelfPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : ACTS_AppPermission_1200
* @tc.name : Verify that com.amsst.permission.SYSPERMISSION is requested by self
* @tc.desc : Verify that a system_grant user`s permission(com.amsst.permission.SYSPERMISSION)
* is automatically requested during installation.
*/
async function ACTS_AppPermission_1200(thisobj) {
var thisFunctionName = ACTS_AppPermission_1200.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext();
var result = await context.verifySelfPermission("com.amsst.permission.SYSPERMISSION");
console.debug("======verifySelfPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n"
return -1;;
}
}
/*
* @tc.number : ACTS_AppPermission_1300
* @tc.name : Verify that calling application(different application in the same device)
* have requested ohos.permission.GET_NETWORK_INFO
* @tc.desc : Verify that calling application(different application in the same device) is requested
* the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
*/
async function ACTS_AppPermission_1300(thisobj) {
var thisFunctionName = ACTS_AppPermission_1300.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
featureAbility.startAbility(
{
want:
{
bundleName: "com.amsst.amsjsstsubpermission",
abilityName: "com.amsst.amsjsstsubpermission.MainAbility"
}
}
);
return 0;
}
/*
* @tc.number : ACTS_AppPermission_1400
* @tc.name : Verify that calling application(different application in the same device)
* have requested ohos.permission.GET_NETWORK_INFO
* @tc.desc : Verify that calling application(different application in the same device) is requested
* the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
*/
async function ACTS_AppPermission_1400(thisobj) {
var thisFunctionName = ACTS_AppPermission_1400.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
featureAbility.startAbility(
{
want:
{
bundleName: "com.amsst.amsjsstsubpermission",
abilityName: "com.amsst.amsjsstsubpermission.MainAbility"
}
}
)
return 0;
}
/*
* @tc.number : ACTS_AppPermission_1500
* @tc.name : Verify that calling application(different application in the same device)
* have not requested ohos.permission.CAMERA
* @tc.desc : Verify that calling application(different application in the same device)
* is not requested the user_grant system`s permission(ohos.permission.CAMERA)
*/
async function ACTS_AppPermission_1500(thisobj) {
var thisFunctionName = ACTS_AppPermission_1500.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
featureAbility.startAbility(
{
want:
{
bundleName: "com.amsst.amsjsstsubpermission",
abilityName: "com.amsst.amsjsstsubpermission.MainAbility"
}
}
)
return 0;
}
/*
* @tc.number : ACTS_AppPermission_1600
* @tc.name : Verify that calling application(different application in the same device)
* have not requested ohos.permission.CAMERA
* @tc.desc : Verify that calling application(different application in the same device)
* is not requested the user_grant system`s permission(ohos.permission.CAMERA)
*/
async function ACTS_AppPermission_1600(thisobj) {
var thisFunctionName = ACTS_AppPermission_1600.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
featureAbility.startAbility(
{
want:
{
bundleName: "com.amsst.amsjsstsubpermission",
abilityName: "com.amsst.amsjsstsubpermission.MainAbility"
}
}
);
return 0;
}
/*
* @tc.number : ACTS_AppPermission_1700
* @tc.name : Verify that calling application(different application in the same device)
* have requested com.amsst.permission.SYSPERMISSION
* @tc.desc : Verify that calling application(different application in the same device)
* is requested the system_grant user`s permission(com.amsst.permission.SYSPERMISSION)
*/
async function ACTS_AppPermission_1700(thisobj) {
var thisFunctionName = ACTS_AppPermission_1700.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
await featureAbility.startAbility(
{
want:
{
bundleName: "com.amsst.amsjsstsubpermission",
abilityName: "com.amsst.amsjsstsubpermission.MainAbility"
}
}
);
return 0;
}
/*
* @tc.number : ACTS_AppPermission_1800
* @tc.name : Verify that calling application(different application in the same device)
* have requested com.amsst.permission.SYSPERMISSION
* @tc.desc : Verify that calling application(different application in the same device)
* is requested the system_grant user`s permission(com.amsst.permission.SYSPERMISSION)
*/
async function ACTS_AppPermission_1800(thisobj) {
var thisFunctionName = ACTS_AppPermission_1800.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
await featureAbility.startAbility(
{
want:
{
bundleName: "com.amsst.amsjsstsubpermission",
abilityName: "com.amsst.amsjsstsubpermission.MainAbility"
}
}
)
return 0;
}
/*
* @tc.number : ACTS_AppPermission_1900
* @tc.name : Verify that application without calling application(other device)
* have requested ohos.permission.GET_NETWORK_INFO
* @tc.desc : Verify that application without calling application(other device)
* is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
*/
async function ACTS_AppPermission_1900(thisobj) {
var thisFunctionName = ACTS_AppPermission_1900.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext();
await context.verifyCallingOrSelfPermission("ohos.permission.GET_NETWORK_INFO",
(err, data) => {
console.debug("======verifyCallingOrSelfPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : ACTS_AppPermission_2000
* @tc.name : Verify that application without calling application(other device)
* have requested ohos.permission.GET_NETWORK_INFO
* @tc.desc : Verify that application without calling application(other device)
* is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
*/
async function ACTS_AppPermission_2000(thisobj) {
var thisFunctionName = ACTS_AppPermission_2000.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
var result = await context.verifyCallingOrSelfPermission("ohos.permission.GET_NETWORK_INFO");
console.debug("======verifyCallingOrSelfPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : ACTS_AppPermission_2100
* @tc.name : Verify that application without calling application(other device)
* have not requested .GET_WIFI_INFO
* @tc.desc : Verify that application without calling application(other device)
* is requested the system_grant system`s permission(ohos.permission..GET_WIFI_INFO)
*/
async function ACTS_AppPermission_2100(thisobj) {
var thisFunctionName = ACTS_AppPermission_2100.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
await context.verifyCallingOrSelfPermission("ohos.permission.GET_WIFI_INFO",
(err, data) => {
console.debug("======verifyCallingOrSelfPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == -1) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : ACTS_AppPermission_2200
* @tc.name : Verify that application without calling application(other device) have not requested .GET_WIFI_INFO
* @tc.desc : Verify that application without calling application(other device)
* is requested the system_grant system`s permission(ohos.permission..GET_WIFI_INFO)
*/
async function ACTS_AppPermission_2200(thisobj) {
var thisFunctionName = ACTS_AppPermission_2200.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var thisProcessInfo = await getThisProcessInfo();
var context = await featureAbility.getContext();
var result = await context.verifyCallingOrSelfPermission("ohos.permission.GET_WIFI_INFO")
console.debug("======verifyCallingOrSelfPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == -1) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : ACTS_AppPermission_2300
* @tc.name : Verify that ohos.permission.GET_NETWORK_INFO can not requested by user
* @tc.desc : Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
* can not requested during runtime.
*/
async function ACTS_AppPermission_2300(thisobj) {
var thisFunctionName = ACTS_AppPermission_2300.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext();
await context.canRequestPermission("ohos.permission.GET_NETWORK_INFO",
(err, data) => {
console.debug("======canRequestPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n"
if (data == false) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : ACTS_AppPermission_2400
* @tc.name : Verify that ohos.permission.GET_NETWORK_INFO can not requested by user
* @tc.desc : Verify that a system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)
* can not requested during runtime.
*/
async function ACTS_AppPermission_2400(thisobj) {
var thisFunctionName = ACTS_AppPermission_2400.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext();
var result = await context.canRequestPermission("ohos.permission.GET_NETWORK_INFO");
console.debug("======canRequestPermission:result======>:" + JSON.stringify(result));
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n"
if (result == false) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : ACTS_AppPermission_2500
* @tc.name : Verify that ohos.permission.CAMERA can requested by user
* @tc.desc : Verify that a user_grant system`s permission(ohos.permission.CAMERA)
* can requested during runtime.
*/
async function ACTS_AppPermission_2500(thisobj) {
var thisFunctionName = ACTS_AppPermission_2500.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext();
await context.canRequestPermission("ohos.permission.CAMERA",
(err, data) => {
console.debug("======canRequestPermission:data======>:" + JSON.stringify(data));;
thisobj.logmessage += "result: " + JSON.stringify(data) + "\n";
if (data == true) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
})
}
/*
* @tc.number : ACTS_AppPermission_2600
* @tc.name : Verify that ohos.permission.CAMERA can requested by user
* @tc.desc : Verify that a user_grant system`s permission(ohos.permission.CAMERA)
* can requested during runtime.
*/
async function ACTS_AppPermission_2600(thisobj) {
var thisFunctionName = ACTS_AppPermission_2600.name;
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext();
var result = await context.canRequestPermission("ohos.permission.CAMERA");
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n"
if (result == true) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
return 0;
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : ACTS_AppPermission_2700
* @tc.name : Verify that ohos.permission.PERMISSIOND can requested by user
* @tc.desc : Verify that a user_grant system`s permission(ohos.permission.PERMISSIOND)
* can requested during runtime.
*/
async function ACTS_AppPermission_2700(thisobj) {
var thisFunctionName = ACTS_AppPermission_2700.name
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var result = await context.canRequestPermission("ohos.permission.PERMISSIOND")
thisobj.logmessage += "result: " + JSON.stringify(result) + "\n";
if (result == true) {
await context.requestPermissionsFromUser(["ohos.permission.PERMISSIOND"],
MY_PERMISSIONS_REQUEST_PERMISSION,
(err, data) => {
thisobj.logmessage += "data = " + JSON.stringify(data) + "\n";
thisobj.logmessage += "err = " + JSON.stringify(err) + "\n";
if (data.requestCode == MY_PERMISSIONS_REQUEST_PERMISSION
&& data.authResults.length > 0
&& data.permissions.length > 0
&& data.permissions[0] == "ohos.permission.PERMISSIOND"
&& data.authResults[0] == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
} else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
}
});
return 0;
} else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
/*
* @tc.number : ACTS_AppPermission_2800
* @tc.name : Verify that ohos.permission.PERMISSIONB, ohos.permission.PERMISSIONC, can requested by user
* @tc.desc : Verify that a user_grant system`s permission
* (ohos.permission.PERMISSIONB, ohos.permission.PERMISSIONC) can requested during runtime.
*/
async function ACTS_AppPermission_2800(thisobj) {
var thisFunctionName = ACTS_AppPermission_2800.name
thisobj.logmessage = "";
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += getCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext();
var result1 = await context.canRequestPermission("ohos.permission.PERMISSIONB");
var result2 = await context.canRequestPermission("ohos.permission.PERMISSIONC");
thisobj.logmessage += JSON.stringify(result1) + "\n";
thisobj.logmessage += JSON.stringify(result2) + "\n";
if (result1 && result2) {
await context.requestPermissionsFromUser(["ohos.permission.PERMISSIONB", "ohos.permission.PERMISSIONC"],
MY_PERMISSIONS_REQUEST_PERMISSION,
(err, data) => {
thisobj.logmessage += "data = " + JSON.stringify(data) + "\n";
thisobj.logmessage += "err = " + JSON.stringify(err) + "\n";
if (data.requestCode == MY_PERMISSIONS_REQUEST_PERMISSION
&& data.authResults.length == 2
&& data.permissions.length == 2
&& data.permissions[0] == "ohos.permission.PERMISSIONB"
&& data.authResults[0] == 0
&& data.permissions[1] == "ohos.permission.PERMISSIONC"
&& data.authResults[1] == 0) {
thisobj.logmessage += "case " + thisFunctionName + " success\n";
} else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
}
});
return 0;
} else {
thisobj.logmessage += "case " + thisFunctionName + " failure\n";
return -1;
}
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "AmsStMain"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
},
{
"name": "permreason_camera",
"value": "请求使用摄像头"
},
{
"name": "permreason_sys",
"value": "自定义system_grand权限"
},
{
"name": "permreason_getnetworkinfo",
"value": "请求访问网络信息"
},
{
"name": "secondability_description",
"value": "JS_Empty Ability"
},
{
"name": "entry_SecondAbility",
"value": "entry_SecondAbility"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAmsJsStSubPermissionTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAmsJsStSubPermissionTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
}
{
"app": {
"bundleName": "com.amsst.amsjsstsubpermission",
"vendor": "amsst",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.amsst.amsjsstsubpermission",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.amsst.amsjsstsubpermission.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
],
"reqPermissions": [
{
"name": "com.amsst.permission.SYSPERMISSION",
"reason": "$string:permreason_sys",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
},
{
"name": "ohos.permission.GET_NETWORK_INFO",
"reason": "$string:permreason_getnetworkinfo",
"usedScene": {
"ability": [
"com.amsst.amsjsstmain.MainAbility"
],
"when": "always"
}
}]
}
}
\ 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 40px;
color: #000000;
opacity: 0.9;
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFFFFF;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url("../../common/images/Wallpaper.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.title {
font-size: 100px;
color: #FFFFFF;
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
.log {
font-size: 20px;
text-align: center;
width: 100%;
height: 400px;
}
\ No newline at end of file
<div class="container">
<text>{{title}}</text>
<div class="log">
<textarea class="log">
{{logmessage}}
</textarea>
</div>
<div>
<list class="todo-wraper">
<list-item for="{{testcase}}" class="todo-item">
<input class="btn" type="button" value="{{$item}}" on:click="runCase({{$item}})"></input>
</list-item>
</list>
<button type="capsule" class="btn" value="back" on:click="stopAbility"></button>
</div>
</div>
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 app from '@system.app'
import router from '@system.router';
import featureAbility from '@ohos.ability.featureability'
import { Core, ExpectExtend, ReportExtend } from 'deccjsunit/index'
export default {
currentCase: "",
data: {
title: "AbilityA1",
logmessage: "this is log message",
testcase: [
"ACTS_AppPermission_1300",
"ACTS_AppPermission_1400",
"ACTS_AppPermission_1500",
"ACTS_AppPermission_1600",
"ACTS_AppPermission_1700",
"ACTS_AppPermission_1800",
],
},
onInit() {
this.title = "AbilityA1";
this.logmessage = "this is log message";
},
onShow() {
},
onReady() {
console.info('onReady finish')
},
onBackPress() {
},
async stopAbility() {
console.info('===========AmsJsStSubPermission close===========<')
await featureAbility.terminateAbility();
await app.killProcessesByBundleName();
},
runCase(caseName) {
console.debug("======runCase======>:" + JSON.stringify(caseName))
this.logmessage += caseName + "\n"
console.debug("======runallcase======<:")
let { runAllCase } = require('./permissioncase.js')
runAllCase(caseName, this)
},
CaseChange(newValue) {
let { GetCaseInfo } = require('./permissioncase.js')
this.logmessage = newValue.value
this.logmessage += GetCaseInfo(newValue.value)
this.currentCase = newValue.value
},
}
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 bundle from '@ohos.bundle'
import featureAbility from '@ohos.ability.featureability'
import abilityManager from '@ohos.app.abilitymanager'
export function runAllCase(caseName, obj) {
console.debug("======runAllCase1======>:" + JSON.stringify(caseName))
console.debug("======runAllCase2======>:" + JSON.stringify(allCase))
allCase[caseName].func(obj)
}
export function GetCaseInfo(caseName) {
console.debug("======GetCaseInfo======>:" + JSON.stringify(caseName))
return allCase[caseName].info;
}
var allCase = {
ACTS_AppPermission_1300: {
func: ACTS_AppPermission_1300,
info: "Verify that calling application(different application in the same device) is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)."
},
ACTS_AppPermission_1400: {
func: ACTS_AppPermission_1400,
info: "Verify that calling application(different application in the same device) is requested the system_grant system`s permission(ohos.permission.GET_NETWORK_INFO)."
},
ACTS_AppPermission_1500: {
func: ACTS_AppPermission_1500,
info: "Verify that calling application(different application in the same device) is not requested the user_grant system`s permission(ohos.permission.CAMERA)."
},
ACTS_AppPermission_1600: {
func: ACTS_AppPermission_1600,
info: "Verify that calling application(different application in the same device) is not requested the user_grant system`s permission(ohos.permission.CAMERA)."
},
ACTS_AppPermission_1700: {
func: ACTS_AppPermission_1700,
info: "Verify that calling application(different application in the same device) is requested the system_grant user`s permission(com.amsst.permission.SYSPERMISSION)."
},
ACTS_AppPermission_1800: {
func: ACTS_AppPermission_1800,
info: "Verify that calling application(different application in the same device) is requested the system_grant user`s permission(com.amsst.permission.SYSPERMISSION)."
},
}
async function ACTS_AppPermission_1300(thisobj) {
var thisFunctionName = ACTS_AppPermission_1300.name
thisobj.logmessage = ""
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += GetCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
await context.verifyCallingPermission("ohos.permission.GET_NETWORK_INFO",
(err, data) => {
console.debug("======verifyCallingPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n"
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n"
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n"
}
})
}
async function ACTS_AppPermission_1400(thisobj) {
var thisFunctionName = ACTS_AppPermission_1400.name
thisobj.logmessage = ""
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += GetCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var result = await context.verifyCallingPermission("ohos.permission.GET_NETWORK_INFO")
console.debug("======verifyCallingPermission:result======>:" + JSON.stringify(result))
thisobj.logmessage += JSON.stringify(result) + "\n"
if (result == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n"
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n"
}
}
async function ACTS_AppPermission_1500(thisobj) {
var thisFunctionName = ACTS_AppPermission_1500.name
thisobj.logmessage = ""
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += GetCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
await context.verifyCallingPermission("ohos.permission.CAMERA",
(err, data) => {
console.debug("======verifyCallingPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n"
if (data == -1) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n"
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n"
}
})
}
async function ACTS_AppPermission_1600(thisobj) {
var thisFunctionName = ACTS_AppPermission_1600.name
thisobj.logmessage = ""
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += GetCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var result = await context.verifyCallingPermission("ohos.permission.CAMERA")
console.debug("======verifyCallingPermission:result======>:" + JSON.stringify(result))
thisobj.logmessage += JSON.stringify(result) + "\n"
if (result == -1) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n"
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n"
}
}
async function ACTS_AppPermission_1700(thisobj) {
var thisFunctionName = ACTS_AppPermission_1700.name
thisobj.logmessage = ""
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += GetCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
await context.verifyCallingPermission("com.amsst.permission.SYSPERMISSION",
(err, data) => {
console.debug("======verifyCallingPermission:data======>:" + JSON.stringify(data));
thisobj.logmessage += JSON.stringify(data) + "\n"
if (data == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n"
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n"
}
})
}
async function ACTS_AppPermission_1800(thisobj) {
var thisFunctionName = ACTS_AppPermission_1800.name
thisobj.logmessage = ""
thisobj.logmessage += thisFunctionName + "\n";
thisobj.logmessage += GetCaseInfo(thisFunctionName) + "\n";
var context = await featureAbility.getContext()
var result = await context.verifyCallingPermission("com.amsst.permission.SYSPERMISSION")
console.debug("======verifyCallingPermission:result======>:" + JSON.stringify(result))
thisobj.logmessage += JSON.stringify(result) + "\n"
if (result == 0) {
thisobj.logmessage += "case " + thisFunctionName + " successed\n"
}
else {
thisobj.logmessage += "case " + thisFunctionName + " failed\n"
}
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "Permission"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
group("verifypermission") {
testonly = true
if (is_standard_system) {
deps = [
"AmsJsStMain:ActsAmsJsStMainTest",
"AmsJsStSubPermission:ActsAmsJsStSubPermissionTest",
]
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册