未验证 提交 6f15949a 编写于 作者: O openharmony_ci 提交者: Gitee

!4293 modifiec FA_JS PART_2

Merge pull request !4293 from jiyong/master
......@@ -16,16 +16,19 @@ import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsOsAccountJSApiTest") {
hap_profile = "./src/main/config.json"
deps = [
":osaccount_js_assets",
":osaccount_resources",
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsOsAccountJSApiTest"
}
ohos_js_assets("osaccount_js_assets") {
source_dir = "./src/main/js/default"
ohos_js_assets("hjs_demo_js_assets") {
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("osaccount_resources") {
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for osaccount js api Tests",
"driver": {
"type": "JSUnitTest",
"type": "OHJSUnitTest",
"test-timeout": "60000",
"package": "ohos.acts.account.osaccount",
"bundle-name": "ohos.acts.account.osaccount",
"package-name": "ohos.acts.account.osaccount",
"shell-timeout": "60000"
},
"kits": [
......
......@@ -14,7 +14,9 @@
"deviceConfig": {},
"module": {
"package": "ohos.acts.account.osaccount",
"name": ".MyApplication",
"name": ".entry",
"mainAbility": ".MainAbility",
"srcPath":"",
"deviceType": [
"phone"
],
......@@ -38,25 +40,42 @@
],
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.acts.account.osaccount.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
],
"js": [
{
"pages": [
......@@ -67,7 +86,21 @@
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
}
}
}
......@@ -12,4 +12,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./Pressure.test.js')
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<!--
Copyright (c) 2021 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</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 app from '@system.app'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
},
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ 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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ 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.
-->
<div class="container" onswipe="touchMove">
<text class="title">
{{ $t('strings.hello') }} {{title}}
</text>
<input class="btn" type="button" value="{{ $t('strings.next') }}" onclick="onclick"></input>
</div>
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</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 app from '@system.app'
//import {Core, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index'
import {Core, ExpectExtend} from 'deccjsunit/index'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
// const instrumentLog = new InstrumentLog({
// 'id': 'report'
// })
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
// core.addService('report', instrumentLog)
core.init()
// core.subscribeEvent('spec', instrumentLog)
// core.subscribeEvent('suite', instrumentLog)
// core.subscribeEvent('task', instrumentLog)
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../test/List.test')
core.execute()
},
onReady() {
},
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import {describe, beforeEach, afterEach, it, expect} from 'deccjsunit/index'
import account from '@ohos.account.distributedAccount'
describe('AccountTest', function () {
beforeEach(function () {
})
afterEach(function () {
})
/**
* @tc.number ActsDistributedAccountDeviceId_0100
* @tc.name Test query the distribruted id by callback.
* @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality by callback.
*/
it('ActsDistributedAccountDeviceId_0100', 0, async function(done){
console.log("test query distribtued id start");
const distributedId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5';
const accountAbility = account.getDistributedAccountAbility();
accountAbility.updateOsAccountDistributedInfo(
{
name: 'ZhangSan',
id: '12345',
event: "Ohos.account.event.LOGIN"
}, (err)=>{
console.log("update distributedInfo err:" + JSON.stringify(err));
accountAbility.queryOsAccountDistributedInfo((err, distributedInfo)=>{
console.log("query distributedInfo err:" + JSON.stringify(err));
console.log("query distributedInfo:" + JSON.stringify(distributedInfo));
expect(distributedInfo.name).assertEqual('ZhangSan');
expect(distributedInfo.id).assertEqual(distributedId);
console.log("test query distribtued id end");
done();
})
})
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0100
* @tc.name Test distributedAccount.getDistributedAccountAbility.
* @tc.desc Test distributedAccount.getDistributedAccountAbility API functionality.
*/
it('account_getDistributedAccountAbility_test', 0, function () {
var ret = false;
const accountAbility = account.getDistributedAccountAbility()
if(accountAbility !== null){
ret = true;
}
expect(ret).assertTrue()
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0200
* @tc.name Test distributedAccount.queryOsAccountDistributedInfo.
* @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality.
*/
it('account_queryOsAccountDistributedInfo_test001', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
accountAbility.queryOsAccountDistributedInfo().then(function (data) {
expect(data.name).assertEqual('anonymous')
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0300
* @tc.name Test distributedAccount.queryOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality by callback.
*/
it('account_queryOsAccountDistributedInfo_test002', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
accountAbility.queryOsAccountDistributedInfo(function (data) {
expect(data.name).assertEqual('anonymous')
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0400
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality.
*/
it('account_updateOsAccountDistributedInfo_test001', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
let data = null
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGIN',
scalableData:data
};
accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) {
expect(result).assertTrue()
accountAbility.queryOsAccountDistributedInfo(function (data) {
expect(data.name).assertEqual('ZhangSan')
expect(data.id).assertEqual('12345')
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOUT'
};
accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) {
expect(result).assertTrue()
});
});
});
accountAbility.queryOsAccountDistributedInfo(function (data) {
execpt(data).assertNull()
})
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0500
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback.
*/
it('account_updateOsAccountDistributedInfo_test002', 0, function () {
let data = null
const accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGIN',
scalableData:data
};
accountAbility.updateOsAccountDistributedInfo(obj, function (result) {
expect(result).assertTrue()
accountAbility.queryOsAccountDistributedInfo(function (data) {
expect(data.name).assertEqual('ZhangSan')
expect(data.id).assertEqual('12345')
const accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOUT'
};
accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) {
expect(result).assertTrue()
});
});
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0300
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback.
*/
it('account_updateOsAccountDistributedInfo_test003', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
let data = null
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.TOKEN_INVALID',
scalableData:data
};
accountAbility.updateOsAccountDistributedInfo(obj, function (result) {
expect(result).assertTrue()
accountAbility.queryOsAccountDistributedInfo(obj).then(function (data) {
except(data.name).assertNull()
})
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0500
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback.
*/
it('account_updateOsAccountDistributedInfo_test004', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
let data = null
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGIN',
scalableData:data
};
accountAbility.updateOsAccountDistributedInfo(obj, function (result) {
expect(result).assertTrue()
accountAbility.queryOsAccountDistributedInfo(function (data) {
expect(data.name).assertEqual('ZhangSan')
expect(data.id).assertEqual('12345')
const accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOFF'
};
accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) {
expect(result).assertNull()
});
});
});
})
})
......@@ -12,5 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AccountTest from './OsAccount.test.js'
require('./OsAccount.test.js')
\ No newline at end of file
export default function testsuite() {
AccountTest()
}
\ 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.
*/
// @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import account from '@ohos.account.distributedAccount'
export default function AccountTest() {
describe('AccountTest', function () {
beforeEach(function () {
})
afterEach(function () {
})
/**
* @tc.number ActsDistributedAccountDeviceId_0100
* @tc.name Test query the distribruted id by callback.
* @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality by callback.
*/
it('ActsDistributedAccountDeviceId_0100', 0, async function(done){
console.log("test query distribtued id start");
const distributedId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5';
const accountAbility = account.getDistributedAccountAbility();
accountAbility.updateOsAccountDistributedInfo(
{
name: 'ZhangSan',
id: '12345',
event: "Ohos.account.event.LOGIN"
}, (err)=>{
console.log("update distributedInfo err:" + JSON.stringify(err));
accountAbility.queryOsAccountDistributedInfo((err, distributedInfo)=>{
console.log("query distributedInfo err:" + JSON.stringify(err));
console.log("query distributedInfo:" + JSON.stringify(distributedInfo));
expect(distributedInfo.name).assertEqual('ZhangSan');
expect(distributedInfo.id).assertEqual(distributedId);
console.log("test query distribtued id end");
done();
})
})
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0100
* @tc.name Test distributedAccount.getDistributedAccountAbility.
* @tc.desc Test distributedAccount.getDistributedAccountAbility API functionality.
*/
it('account_getDistributedAccountAbility_test', 0, function () {
var ret = false;
const accountAbility = account.getDistributedAccountAbility()
if(accountAbility !== null){
ret = true;
}
expect(ret).assertTrue()
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0200
* @tc.name Test distributedAccount.queryOsAccountDistributedInfo.
* @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality.
*/
it('account_queryOsAccountDistributedInfo_test001', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
accountAbility.queryOsAccountDistributedInfo().then(function (data) {
expect(data.name).assertEqual('anonymous')
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0300
* @tc.name Test distributedAccount.queryOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality by callback.
*/
it('account_queryOsAccountDistributedInfo_test002', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
accountAbility.queryOsAccountDistributedInfo(function (data) {
expect(data.name).assertEqual('anonymous')
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0400
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality.
*/
it('account_updateOsAccountDistributedInfo_test001', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
let data = null
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGIN',
scalableData:data
};
accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) {
expect(result).assertTrue()
accountAbility.queryOsAccountDistributedInfo(function (data) {
expect(data.name).assertEqual('ZhangSan')
expect(data.id).assertEqual('12345')
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOUT'
};
accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) {
expect(result).assertTrue()
});
});
});
accountAbility.queryOsAccountDistributedInfo(function (data) {
execpt(data).assertNull()
})
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0500
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback.
*/
it('account_updateOsAccountDistributedInfo_test002', 0, function () {
let data = null
const accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGIN',
scalableData:data
};
accountAbility.updateOsAccountDistributedInfo(obj, function (result) {
expect(result).assertTrue()
accountAbility.queryOsAccountDistributedInfo(function (data) {
expect(data.name).assertEqual('ZhangSan')
expect(data.id).assertEqual('12345')
const accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOUT'
};
accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) {
expect(result).assertTrue()
});
});
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0300
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback.
*/
it('account_updateOsAccountDistributedInfo_test003', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
let data = null
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.TOKEN_INVALID',
scalableData:data
};
accountAbility.updateOsAccountDistributedInfo(obj, function (result) {
expect(result).assertTrue()
accountAbility.queryOsAccountDistributedInfo(obj).then(function (data) {
except(data.name).assertNull()
})
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0500
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality by callback.
*/
it('account_updateOsAccountDistributedInfo_test004', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
let data = null
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGIN',
scalableData:data
};
accountAbility.updateOsAccountDistributedInfo(obj, function (result) {
expect(result).assertTrue()
accountAbility.queryOsAccountDistributedInfo(function (data) {
expect(data.name).assertEqual('ZhangSan')
expect(data.id).assertEqual('12345')
const accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOFF'
};
accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) {
expect(result).assertNull()
});
});
});
})
})
}
......@@ -7,6 +7,22 @@
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccountPressure") {
hap_profile = "./entry/src/main/config.json"
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
......@@ -23,9 +23,12 @@ ohos_js_hap_suite("ActsAccountPressure") {
hap_name = "ActsAccountPressure"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"type": "OHJSUnitTest",
"test-timeout": "1500000",
"package": "com.example.actsaccountpressure",
"shell-timeout": "60000"
"bundle-name": "com.example.actsaccountpressure",
"package-name": "com.example.actsaccountpressure",
"shell-timeout": "1500000"
},
"kits": [
{
......
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container">
<text class="title">
{{title}}
</text>
</div>
......@@ -15,7 +15,9 @@
"deviceConfig": {},
"module": {
"package": "com.example.actsaccountpressure",
"name": ".MyApplication",
"name": ".entry",
"mainAbility": ".MainAbility",
"srcPath":"",
"deviceType": [
"phone"
],
......@@ -72,36 +74,67 @@
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsaccountpressure.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
]
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
}
}
}
\ 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('./Syncenable.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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<!--
Copyright (c) 2021 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div class="container" onswipe="touchMove">
<text class="title">
{{title}}
</text>
</div>
......@@ -13,7 +13,6 @@
* limitations under the License.
*/
import file from '@system.file'
import {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
......@@ -27,19 +26,6 @@ export default {
},
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')
this.timeout = 180000;
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ 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.
*/
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
.btn {
width: 50%;
height: 100px;
font-size: 40px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ 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.
-->
<div class="container" onswipe="touchMove">
<text class="title">
{{ $t('strings.hello') }} {{title}}
</text>
<input class="btn" type="button" value="{{ $t('strings.next') }}" onclick="onclick"></input>
</div>
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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('./Getallaccounts.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 ActsAccountPressure from './Pressure.test.js'
export default function testsuite() {
ActsAccountPressure()
}
\ No newline at end of file
......@@ -7,6 +7,22 @@
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAccountTest") {
hap_profile = "./entry/src/main/config.json"
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
......@@ -23,9 +23,12 @@ ohos_js_hap_suite("ActsAccountTest") {
hap_name = "ActsAccountTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"type": "OHJSUnitTest",
"test-timeout": "3000000",
"package": "com.example.actsaccounttest",
"shell-timeout": "60000"
"bundle-name": "com.example.actsaccounttest",
"package-name": "com.example.actsaccounttest",
"shell-timeout": "3000000"
},
"kits": [
{
......
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container">
<text class="title">
{{title}}
</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 account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 5000;
describe('ActsCreatAppAccountManager', function () {
function sleep(delay) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, delay)
}).then(() => {
console.info(`sleep #{time} over ...`)
})
}
beforeAll(async function (done) {
console.debug("====>beforeAll start====");
await sleep(TIMEOUT);
console.debug("====>beforeAll end====");
done();
});
/*
* @tc.number : ActsCreatAppAccountManager_0100
* @tc.name : createAppAccountManager
* @tc.desc : Create two application account module objects, one object adds an application account,
* the other object deletes the application account
*/
it('ActsCreatAppAccountManager_0100', 0, async function (done) {
console.debug("====>ActsCreatAppAccountManager_0100 start====");
var appAccountManager = account.createAppAccountManager();
var appAccountManagerTwo = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.addAccount("creatappaccount_name_first", (err)=>{
console.debug("====>add account ActsCreatAppAccountManager_0100 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManagerTwo.deleteAccount("creatappaccount_name_first", (err)=>{
console.debug("====>delete Account ActsCreatAppAccountManager_0100 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsCreatAppAccountManager_0100 end====");
done();
});
});
});
/*
* @tc.number : ActsCreatAppAccountManager_0200
* @tc.name : createAppAccountManager
* @tc.desc : Create two application account module objects, one object adds application accounts and
* sets additional information, and the other object can obtain additional information of
* the application account
*/
it('ActsCreatAppAccountManager_0200', 0, async function (done) {
console.debug("====>ActsCreatAppAccountManager_0200 start====");
var appAccountManager = account.createAppAccountManager();
var appAccountManagerTwo = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.addAccount("creatappaccount_name_second", (err)=>{
console.debug("====>add account ActsCreatAppAccountManager_0200 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManagerTwo.setAccountExtraInfo("creatappaccount_name_second", "creatappaccount_extra", (err)=>{
console.debug("====>setAccountExtraInfo err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.getAccountExtraInfo("creatappaccount_name_second", (err, data)=>{
console.debug("====>getAccountExtraInfo err:" + JSON.stringify(err));
console.debug("====>getAccountExtraInfo data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data).assertEqual("creatappaccount_extra");
appAccountManagerTwo.deleteAccount("creatappaccount_name_second", (err)=>{
console.debug("====>delete Account err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsCreatAppAccountManager_0200 end====");
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 account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const NAMELIMIT = 512;
const TIMEOUT = 5000;
describe('ActsAccountDeleteAccount', function () {
function sleep(delay) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, delay)
}).then(() => {
console.info(`sleep #{time} over ...`)
})
}
beforeAll(async function (done) {
console.debug("====>beforeAll start====");
await sleep(TIMEOUT);
console.debug("====>beforeAll end====");
done();
});
/*
* @tc.number : ActsAccountDeleteAccount_0100
* @tc.name : Delete account callback form
* @tc.desc : Delete the added account in callback form
*/
it('ActsAccountDeleteAccount_0100', 0, async function (done) {
console.debug("====>ActsAccountDeleteAccount_0100 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.addAccount("deleteAccount_name_callback_first", "extraInfo_callback_first", (err)=>{
console.debug("====>add account ActsAccountDeleteAccount_0100 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.deleteAccount("deleteAccount_name_callback_first", (err)=>{
console.debug("====>delete Account ActsAccountDeleteAccount_0100 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsAccountDeleteAccount_0100 end====");
done();
});
});
});
/*
* @tc.number : ActsAccountDeleteAccount_0200
* @tc.name : Delete account promise form
* @tc.desc : Delete the added account in promise form
*/
it('ActsAccountDeleteAccount_0200',0,async function (done){
console.debug("====>ActsAccountDeleteAccount_0200 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>add account ActsAccountAddAccount_0200 start====");
await appAccountManager.addAccount("deleteAccount_name_promise_first","extraInfo_promise_first");
try{
await appAccountManager.deleteAccount("deleteAccount_name_promise_first");
console.debug("====>ActsAccountDeleteAccount_0200 end====");
done();
}
catch(err){
console.error("====>delete account ActsAccountDeleteAccount_0200 err:" + JSON.stringify(err));
expect().assertFail();
done();
}
});
/*
* @tc.number : ActsAccountDeleteAccount_0300
* @tc.name : Delete account callback form
* @tc.desc : Delete unadded account in callback form
*/
it('ActsAccountDeleteAccount_0300', 0, async function (done) {
console.debug("====>ActsAccountDeleteAccount_0300 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.deleteAccount("deleteAccount_name_callback_second", (err)=>{
console.debug("====>delete Account ActsAccountDeleteAccount_0300 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0300 end====");
done();
});
});
/*
* @tc.number : ActsAccountDeleteAccount_0400
* @tc.name : Delete account promise form
* @tc.desc : Delete unadded account in promise form
*/
it('ActsAccountDeleteAccount_0400', 0, async function(done){
console.debug("====>ActsAccountDeleteAccount_0400 start====");
var appAccountManager = account.createAppAccountManager();
try{
await appAccountManager.deleteAccount("deleteAccount_name_promise_second");
}
catch(err){
console.debug("====>delete account ActsAccountDeleteAccount_0400 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0400 end====");
done();
}
});
/*
* @tc.number : ActsAccountDeleteAccount_0500
* @tc.name : Delete account callback form
* @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails
*/
it('ActsAccountDeleteAccount_0500', 0, async function (done) {
console.debug("====>ActsAccountDeleteAccount_0500 start====");
var appAccountManager = account.createAppAccountManager();
appAccountManager.addAccount("deleteAccount_name_callback_third", "extraInfo_callback_third", (err)=>{
console.debug("====>add account ActsAccountDeleteAccount_0500 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.deleteAccount("deleteAccount_name_callback_third", (err)=>{
console.debug("====>delete account first time err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.deleteAccount("deleteAccount_name_callback_third", (err)=>{
console.debug("====>delete Account second time err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0500 end====");
done();
});
});
});
});
/*
* @tc.number : ActsAccountDeleteAccount_0600
* @tc.name : Delete account promise form
* @tc.desc : Delete the added account, the first time it can be deleted, the second time the deletion fails
*/
it('ActsAccountDeleteAccount_0600', 0, async function (done){
console.debug("====>ActsAccountDeleteAccount_0600 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>add account ActsAccountAddAccount_0600 start====");
await appAccountManager.addAccount("deleteAccount_name_promise_third", "extraInfo_promise_third");
console.debug("====>delete Account first time ActsAccountDeleteAccount_0600 start====");
await appAccountManager.deleteAccount("deleteAccount_name_promise_third");
console.debug("====>delete Account second time ActsAccountDeleteAccount_0600 start====");
try{
await appAccountManager.deleteAccount("deleteAccount_name_promise_third");
}
catch(err){
console.debug("====>delete account ActsAccountDeleteAccount_0600 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0600 end====");
done();
}
});
/*
* @tc.number : ActsAccountDeleteAccount_0700
* @tc.name : Delete account callback form
* @tc.desc : Delete the account name exceeds the length limit of 512 characters
*/
it('ActsAccountDeleteAccount_0700',0, async function (done){
console.debug("====>ActsAccountDeleteAccount_0700 start====");
var nameLimit = '';
for (var i = 0; i < NAMELIMIT + 1; i++) {
nameLimit += 't';
}
var appAccountManager = account.createAppAccountManager();
appAccountManager.deleteAccount(nameLimit, (err)=>{
console.debug("====>delete Account ActsAccountDeleteAccount_0700 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0700 end====");
done();
});
});
/*
* @tc.number : ActsAccountDeleteAccount_0800
* @tc.name : Delete account promise form
* @tc.desc : Delete the account name exceeds the length limit of 512 characters
*/
it('ActsAccountDeleteAccount_0800', 0, async function (done){
console.debug("====>ActsAccountDeleteAccount_0800 start====");
var nameLimit = '';
for (var i = 0; i < NAMELIMIT + 1; i++) {
nameLimit += 'n';
}
var appAccountManager = account.createAppAccountManager();
console.debug("====>delete Account ActsAccountDeleteAccount_0800 start====");
try{
await appAccountManager.deleteAccount(nameLimit);
}
catch(err){
console.debug("====>delete account ActsAccountDeleteAccount_0800 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0800 end====");
done();
}
})
/*
* @tc.number : ActsAccountDeleteAccount_0900
* @tc.name : Delete account callback form
* @tc.desc : Delete the account name is an empty string
*/
it('ActsAccountDeleteAccount_0900',0, async function (done){
console.debug("====>ActsAccountDeleteAccount_0900 start====");
var appAccountManager = account.createAppAccountManager();
appAccountManager.deleteAccount("", (err)=>{
console.debug("====>delete Account ActsAccountDeleteAccount_0900 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_0900 end====");
done();
});
});
/*
* @tc.number : ActsAccountDeleteAccount_1000
* @tc.name : Delete account promise form
* @tc.desc : Delete the account name is an empty string
*/
it('ActsAccountDeleteAccount_1000', 0, async function (done){
console.debug("====>ActsAccountDeleteAccount_1000 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>delete Account ActsAccountDeleteAccount_1000 start====");
try{
await appAccountManager.deleteAccount("");
}
catch(err){
console.debug("====>delete account ActsAccountDeleteAccount_1000 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountDeleteAccount_1000 end====");
done();
}
})
})
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./AddAccount.test.js')
require('./DeleteAccount.test.js')
require('./AppAccess.test.js')
require('./ExtraInfo.test.js')
require('./AssociatedData.test.js')
require('./Credential.test.js')
require('./OAuthToken.test.js')
require('./CreatManager.test.js')
require('./NoPermission.test.js')
require('./OnOff.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 account from '@ohos.account.appAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const TIMEOUT = 5000;
const ERR_APPACCOUNT_SERVICE_PERMISSION_DENIED = 4521993;
describe('ActsAccountNoPermission', function () {
function sleep(delay) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, delay)
}).then(() => {
console.info(`sleep #{time} over ...`)
})
}
beforeAll(async function (done) {
console.debug("====>beforeAll start====");
await sleep(TIMEOUT);
console.debug("====>beforeAll end====");
done();
});
/*
* @tc.number : ActsAccountNoPermission_0100
* @tc.name : setAppAccountSyncEnable callback
* @tc.desc : Set the added account to allow synchronization without permission
*/
it('ActsAccountNoPermission_0100', 0, async function (done) {
console.debug("====>ActsAccountNoPermission_0100 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.addAccount("syncenable_callback_setnopermission", (err)=>{
console.debug("====>add account ActsAccountNoPermission_0100 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.setAppAccountSyncEnable("syncenable_callback_setnopermission", true, (err)=>{
console.debug("====>setAppAccountSyncEnable 0100 err:" + JSON.stringify(err));
expect(err.code).assertEqual(account.ResultCode.ERROR_PERMISSION_DENIED);
appAccountManager.deleteAccount("syncenable_callback_setnopermission", (err)=>{
console.debug("====>delete Account ActsAccountNoPermission_0100 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsAccountNoPermission_0100 end====");
done();
});
})
});
});
/*
* @tc.number : ActsAccountNoPermission_0200
* @tc.name : setAppAccountSyncEnable promise
* @tc.desc : Set the added account to allow synchronization without permission
*/
it('ActsAccountNoPermission_0200', 0, async function (done) {
console.debug("====>ActsAccountNoPermission_0200 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>add account ActsAccountNoPermission_0200 start====");
await appAccountManager.addAccount("syncenable_promise_setnopermission");
console.debug("====>setAppAccountSyncEnable ActsAccountNoPermission_0200 start====");
try{
await appAccountManager.setAppAccountSyncEnable("syncenable_promise_setnopermission", true);
}
catch(err){
console.debug("====>setAppAccountSyncEnable 0200 err:" + JSON.stringify(err));
expect(err.code).assertEqual(account.ResultCode.ERROR_PERMISSION_DENIED);
console.debug("====>delete account ActsAccountNoPermission_0200 start====");
await appAccountManager.deleteAccount("syncenable_promise_setnopermission");
console.debug("====>ActsAccountNoPermission_0200 end====");
done();
}
});
/*
* @tc.number : ActsAccountNoPermission_0300
* @tc.name : Check sync flag callback form
* @tc.desc : Check the added account synchronization without permission
*/
it('ActsAccountNoPermission_0300', 0, async function (done) {
console.debug("====>ActsAccountNoPermission_0300 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.addAccount("syncenable_callback_checknopermission", (err)=>{
console.debug("====>add account ActsAccountNoPermission_0300 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.checkAppAccountSyncEnable("syncenable_callback_checknopermission", (err, data)=>{
console.debug("====>checkAppAccountSyncEnable 0300 err:" + JSON.stringify(err));
expect(err.code).assertEqual(account.ResultCode.ERROR_PERMISSION_DENIED);
appAccountManager.deleteAccount("syncenable_callback_checknopermission", (err)=>{
console.debug("====>delete Account ActsAccountNoPermission_0300 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsAccountNoPermission_0300 end====");
done();
});
})
});
});
/*
* @tc.number : ActsAccountNoPermission_0400
* @tc.name : Check sync flag promise form
* @tc.desc : Check the added account synchronization without permission
*/
it('ActsAccountNoPermission_0400', 0, async function (done) {
console.debug("====>ActsAccountNoPermission_0400 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>add account ActsAccountNoPermission_0400 start====");
await appAccountManager.addAccount("syncenable_promise_checknopermission");
console.debug("====>checkAppAccountSyncEnable ActsAccountNoPermission_0400 start====");
try{
var data = await appAccountManager.checkAppAccountSyncEnable("syncenable_promise_checknopermission");
}
catch(err){
console.debug("====>checkAppAccountSyncEnable 0400 err:" + JSON.stringify(err));
expect(err.code).assertEqual(account.ResultCode.ERROR_PERMISSION_DENIED);
await appAccountManager.deleteAccount("syncenable_promise_checknopermission");
console.debug("====>ActsAccountNoPermission_0400 end====");
done();
}
});
/*
* @tc.number : ActsAccountNoPermission_0500
* @tc.name : getAllAccessibleAccounts callback
* @tc.desc : This application gets authorization after adding a single account without permission
*/
it('ActsAccountNoPermission_0500', 0, async function (done) {
console.debug("====>ActsAccountNoPermission_0500 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.addAccount("accessibleAccount_callback_nopermission", (err)=>{
console.debug("====> add account ActsAccountNoPermission_0500 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.getAllAccessibleAccounts((err, data)=>{
console.debug("====>getAllAccessibleAccounts 0500 err:" + JSON.stringify(err));
expect(err.code).assertEqual(account.ResultCode.ERROR_PERMISSION_DENIED);
appAccountManager.deleteAccount("accessibleAccount_callback_nopermission", (err)=>{
console.debug("====>delete Account ActsAccountNoPermission_0500 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsAccountNoPermission_0500 end====");
done();
})
});
});
});
/*
* @tc.number : ActsAccountNoPermission_0600
* @tc.name : getAllAccessibleAccounts promise
* @tc.desc : This application gets authorization after adding a single account without permission
*/
it('ActsAccountNoPermission_0600', 0, async function (done) {
console.debug("====>ActsAccountNoPermission_0600 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
console.debug("====>add account ActsAccountNoPermission_0600 start====");
await appAccountManager.addAccount("accessibleAccount_promise_nopermission");
console.debug("====>getAllAccessibleAccounts 0600 start====");
try{
var data = await appAccountManager.getAllAccessibleAccounts();
}
catch(err){
console.debug("====>getAllAccessibleAccounts 0600 err:" + JSON.stringify(err));
expect(err.code).assertEqual(account.ResultCode.ERROR_PERMISSION_DENIED);
await appAccountManager.deleteAccount("accessibleAccount_promise_nopermission");
console.debug("====>ActsAccountNoPermission_0600 end====");
done();
}
});
/*
* @tc.number : ActsAccountNoPermission_0700
* @tc.name : getAllAccounts callback
* @tc.desc : This application gets its own application information after adding an account without permission
*/
it('ActsAccountNoPermission_0700', 0, async function (done) {
console.debug("====>ActsAccountNoPermission_0700 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var selfBundle = "com.example.actsaccounttest";
appAccountManager.addAccount("getAll_callback_nopermission", (err)=>{
console.debug("====>add account 0700 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
appAccountManager.getAllAccounts(selfBundle, (err, data)=>{
console.debug("====>getAllAccounts 0700 err:" + JSON.stringify(err));
expect(err.code).assertEqual(account.ResultCode.ERROR_PERMISSION_DENIED);
appAccountManager.deleteAccount("getAll_callback_nopermission", (err)=>{
console.debug("====>delete account 0700 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsAccountNoPermission_0700 end====");
done();
});
})
});
});
/*
* @tc.number : ActsAccountNoPermission_0800
* @tc.name : getAllAccounts promise
* @tc.desc : This application gets its own application information after adding an account without permission
*/
it('ActsAccountNoPermission_0800', 0, async function (done) {
console.debug("====>ActsAccountNoPermission_0800 start====");
var appAccountManager = account.createAppAccountManager();
console.debug("====>creat finish====");
var selfBundle = "com.example.actsaccounttest";
console.debug("====>add account 0800 start====");
await appAccountManager.addAccount("getAll_promise_nopermission");
console.debug("====>getAllAccounts 0800 start====");
try{
var data = await appAccountManager.getAllAccounts(selfBundle);
}
catch(err){
console.error("====>getAllAccounts 0800 err:" + JSON.stringify(err));
expect(err.code).assertEqual(account.ResultCode.ERROR_PERMISSION_DENIED);
await appAccountManager.deleteAccount("getAll_promise_nopermission");
console.debug("====>ActsAccountNoPermission_0800 end====");
done();
}
});
})
\ No newline at end of file
......@@ -48,25 +48,42 @@
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsaccounttest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"visible": true,
"launchType": "standard"
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
],
"js": [
{
"pages": [
......@@ -77,7 +94,21 @@
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
}
}
}
\ 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('./Getallaccessible.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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<!--
Copyright (c) 2021 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div class="container" onswipe="touchMove">
<text class="title">
{{title}}
</text>
</div>
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册