提交 395a8e3f 编写于 作者: 1 15829070344

add account testcases

Signed-off-by: N15829070344 <hehaitao5@huawei.com>
上级 48c7ee0f
......@@ -18,7 +18,7 @@
"mainAbility": ".MainAbility",
"srcPath":"",
"deviceType": [
"default",
"default",
"phone"
],
"distro": {
......@@ -37,6 +37,10 @@
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
},
{
"name": "ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS",
"reason": "ceshi"
}
],
"abilities": [
......
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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, done } from '@ohos/hypium'
import account from '@ohos.account.distributedAccount'
const LOGININFO = {
name: 'ZhangSan',
id: '12345',
event: "Ohos.account.event.LOGIN"
}
const LOGOUTINFO = {
name: 'ZhangSan',
id: '12345',
event: "Ohos.account.event.LOGOUT"
}
export default function ActsDAGetSetTest() {
describe('ActsDAGetSetTest', function () {
beforeEach(function () {
})
afterEach(function () {
})
/**
* @tc.number ActsDistributedAccountDeviceId_0100
* @tc.name Test query the distribruted id by callback.
* @tc.desc Test distributedAccount.getOsAccountDistributedInfo API functionality by callback.
*/
it('ActsDistributedAccountDeviceId_0100', 0, async function(done){
console.log("====>test query distribtued id start");
const distributedId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5'; //'12345'sha256的值
const accountAbility = account.getDistributedAccountAbility();
accountAbility.setOsAccountDistributedInfo(LOGININFO, (err)=>{
console.log("====>set distributedInfo err:" + JSON.stringify(err));
accountAbility.getOsAccountDistributedInfo((err, distributedInfo)=>{
console.log("====>get distributedInfo err:" + JSON.stringify(err));
console.log("====>get distributedInfo:" + JSON.stringify(distributedInfo));
expect(distributedInfo.name).assertEqual('ZhangSan');
expect(distributedInfo.id).assertEqual(distributedId);
accountAbility.setOsAccountDistributedInfo(LOGOUTINFO, (err)=>{
console.debug('====>ActsDistributedAccountDeviceId_0100 logout_result:'+ JSON.stringify(err))
expect(err).assertEqual(null)
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, async function (done) {
var ret = false;
const accountAbility = account.getDistributedAccountAbility()
console.debug("====>account_getDistributedAccountAbility_test result:" + JSON.stringify(accountAbility))
if(accountAbility !== null){
ret = true;
}
expect(ret).assertTrue()
done();
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0200
* @tc.name Test distributedAccount.getOsAccountDistributedInfo.
* @tc.desc Test distributedAccount.getOsAccountDistributedInfo API functionality.
*/
it('account_getOsAccountDistributedInfo_test001', 0, async function (done) {
let accountAbility = account.getDistributedAccountAbility()
accountAbility.getOsAccountDistributedInfo().then(function (data) {
console.debug('====>account_getOsAccountDistributedInfo_test001 data:' + JSON.stringify(data))
expect(data.name).assertEqual('ohosAnonymousName')
expect(data.id).assertEqual('ohosAnonymousUid')
done();
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0300
* @tc.name Test distributedAccount.getOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.getOsAccountDistributedInfo API functionality by callback.
*/
it('account_getOsAccountDistributedInfo_test002', 0, async function (done) {
let accountAbility = account.getDistributedAccountAbility()
accountAbility.getOsAccountDistributedInfo(function (err, data) {
console.debug('====>account_getOsAccountDistributedInfo_test002 err:' + JSON.stringify(err))
console.debug('====>account_getOsAccountDistributedInfo_test002 data:' + JSON.stringify(data))
expect(err).assertEqual(null)
expect(data.name).assertEqual('ohosAnonymousName')
expect(data.id).assertEqual('ohosAnonymousUid')
done();
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0400
* @tc.name Test distributedAccount.setOsAccountDistributedInfo.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality.
*/
it('account_setOsAccountDistributedInfo_test001', 0, async function (done) {
const accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGIN',
scalableData:{}
};
accountAbility.setOsAccountDistributedInfo(obj).then(function () {
accountAbility.getOsAccountDistributedInfo(function (data) {
console.debug('====>account_setOsAccountDistributedInfo_test001 data:' + JSON.stringify(data))
expect(data.name).assertEqual('ZhangSan')
expect(data.id).assertEqual('12345')
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOUT'
};
accountAbility.setOsAccountDistributedInfo(obj).then(function (err) {
expect(err).assertEqual(null)
});
});
});
accountAbility.getOsAccountDistributedInfo(function (data) {
console.debug('====>account_setOsAccountDistributedInfo_test001 get data:' + JSON.stringify(data))
expect(data).assertEqual(null)
done();
})
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0500
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
*/
it('account_setOsAccountDistributedInfo_test002', 0, async function (done) {
var accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGIN',
scalableData:{}
};
accountAbility.setOsAccountDistributedInfo(obj, function () {
accountAbility.getOsAccountDistributedInfo(function (err, data) {
console.debug("====>account_setOsAccountDistributedInfo_test002 data:" + JSON.stringify(data))
expect(data.name).assertEqual('ZhangSan')
expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5')
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOUT'
};
accountAbility.setOsAccountDistributedInfo(obj).then(function (data) {
expect(data).assertEqual(null)
done();
});
});
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0300
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
*/
it('account_setOsAccountDistributedInfo_test003', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.TOKEN_INVALID',
scalableData:{}
};
accountAbility.setOsAccountDistributedInfo(obj, function (result) {
console.debug("====>account_setOsAccountDistributedInfo_test003 update_err:" + JSON.stringify(result))
accountAbility.getOsAccountDistributedInfo(obj).then(function (data) {
console.debug("====>account_setOsAccountDistributedInfo_test003 data:" + JSON.stringify(data))
expect(data.name).assertNull()
done();
})
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0500
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
*/
it('account_setOsAccountDistributedInfo_test004', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGIN',
scalableData:{}
};
accountAbility.setOsAccountDistributedInfo(obj, function (err) {
console.debug("====>account_setOsAccountDistributedInfo_test004 update_err:" + JSON.stringify(err))
accountAbility.getOsAccountDistributedInfo(function (err, data) {
console.debug("====>account_setOsAccountDistributedInfo_test004 query_err:" + JSON.stringify(err))
console.debug("====>account_setOsAccountDistributedInfo_test004 query_data:" + JSON.stringify(data))
expect(data.name).assertEqual('ZhangSan')
expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5')
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOFF'
};
accountAbility.setOsAccountDistributedInfo(obj).then(function (result) {
expect(err).assert(null)
done();
});
});
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0600
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
*/
it('account_setOsAccountDistributedInfo_test005', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGIN',
scalableData:{age:'12'}
};
accountAbility.setOsAccountDistributedInfo(obj, function (err) {
console.debug("====>account_setOsAccountDistributedInfo_test005 update_err:" + JSON.stringify(err))
accountAbility.getOsAccountDistributedInfo(function (err, data) {
console.debug("====>account_setOsAccountDistributedInfo_test005 query_err:" + JSON.stringify(err))
console.debug("====>account_setOsAccountDistributedInfo_test005 query_data:" + JSON.stringify(data))
expect(data.scalableData.age).assertEqual('12')
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOFF'
};
accountAbility.setOsAccountDistributedInfo(obj).then(function (result) {
expect(err).assert(null)
done();
});
});
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0700
* @tc.name Test distributedAccount.setOsAccountDistributedInfo by callback.
* @tc.desc Test distributedAccount.setOsAccountDistributedInfo API functionality by callback.
*/
it('account_setOsAccountDistributedInfo_test006', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGIN',
scalableData:{age:'12'}
};
accountAbility.setOsAccountDistributedInfo(obj, function (err) {
console.debug("====>account_setOsAccountDistributedInfo_test006 update_err:" + JSON.stringify(err))
accountAbility.getOsAccountDistributedInfo(function (err, data) {
console.debug("====>account_setOsAccountDistributedInfo_test006 query_err:" + JSON.stringify(err))
console.debug("====>account_setOsAccountDistributedInfo_test006 query_data:" + JSON.stringify(data))
expect(data.scalableData.age).assertEqual('12')
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOFF'
};
accountAbility.setOsAccountDistributedInfo(obj).then(function (result) {
expect(err).assert(null)
done();
});
});
});
})
})
}
......@@ -13,7 +13,9 @@
* limitations under the License.
*/
import AccountTest from './OsAccount.test.js'
import ActsDAGetSetTest from './ActsDSGetSet.test.js'
export default function testsuite() {
AccountTest()
ActsDAGetSetTest()
}
\ No newline at end of file
......@@ -14,9 +14,19 @@
*/
// @ts-nocheck
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, done } from '@ohos/hypium'
import account from '@ohos.account.distributedAccount'
const LOGININFO = {
name: 'ZhangSan',
id: '12345',
event: "Ohos.account.event.LOGIN"
}
const LOGOUTINFO = {
name: 'ZhangSan',
id: '12345',
event: "Ohos.account.event.LOGOUT"
}
export default function AccountTest() {
describe('AccountTest', function () {
beforeEach(function () {
......@@ -29,24 +39,25 @@ export default function AccountTest() {
* @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';
it('ActsDistributedAccountDeviceId_0100', 0, async function(done){
console.log("====>test query distribtued id start");
const distributedId = '5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5'; //'12345'sha256的值
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.updateOsAccountDistributedInfo(LOGININFO, (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));
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();
console.debug('success')
accountAbility.updateOsAccountDistributedInfo(LOGOUTINFO, (err)=>{
console.debug('====>ActsDistributedAccountDeviceId_0100 logout_result:'+ JSON.stringify(err))
expect(err).assertEqual(undefined)
console.log("====>test query distribtued id end");
done();
})
})
})
})
......@@ -56,13 +67,15 @@ export default function AccountTest() {
* @tc.name Test distributedAccount.getDistributedAccountAbility.
* @tc.desc Test distributedAccount.getDistributedAccountAbility API functionality.
*/
it('account_getDistributedAccountAbility_test', 0, function () {
it('account_getDistributedAccountAbility_test', 0, async function (done) {
var ret = false;
const accountAbility = account.getDistributedAccountAbility()
console.debug("====>account_getDistributedAccountAbility_test result:" + JSON.stringify(accountAbility))
if(accountAbility !== null){
ret = true;
}
expect(ret).assertTrue()
done();
})
/**
......@@ -70,10 +83,13 @@ export default function AccountTest() {
* @tc.name Test distributedAccount.queryOsAccountDistributedInfo.
* @tc.desc Test distributedAccount.queryOsAccountDistributedInfo API functionality.
*/
it('account_queryOsAccountDistributedInfo_test001', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
it('account_queryOsAccountDistributedInfo_test001', 0, async function (done) {
let accountAbility = account.getDistributedAccountAbility()
accountAbility.queryOsAccountDistributedInfo().then(function (data) {
expect(data.name).assertEqual('anonymous')
console.debug('====>account_queryOsAccountDistributedInfo_test001 data:' + JSON.stringify(data))
expect(data.name).assertEqual('ohosAnonymousName')
expect(data.id).assertEqual('ohosAnonymousUid')
done();
});
})
......@@ -82,10 +98,15 @@ export default function AccountTest() {
* @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')
it('account_queryOsAccountDistributedInfo_test002', 0, async function (done) {
let accountAbility = account.getDistributedAccountAbility()
accountAbility.queryOsAccountDistributedInfo(function (err, data) {
console.debug('====>account_queryOsAccountDistributedInfo_test002 err:' + JSON.stringify(err))
console.debug('====>account_queryOsAccountDistributedInfo_test002 data:' + JSON.stringify(data))
expect(err).assertEqual(undefined)
expect(data.name).assertEqual('ohosAnonymousName')
expect(data.id).assertEqual('ohosAnonymousUid')
done();
});
})
......@@ -94,18 +115,18 @@ export default function AccountTest() {
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo.
* @tc.desc Test distributedAccount.updateOsAccountDistributedInfo API functionality.
*/
it('account_updateOsAccountDistributedInfo_test001', 0, function () {
it('account_updateOsAccountDistributedInfo_test001', 0, async function (done) {
const accountAbility = account.getDistributedAccountAbility()
let data = null
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.updateOsAccountDistributedInfo(obj).then(function () {
accountAbility.queryOsAccountDistributedInfo(function (data) {
console.debug('====>account_updateOsAccountDistributedInfo_test001 data:' + JSON.stringify(data))
expect(data.name).assertEqual('ZhangSan')
expect(data.id).assertEqual('12345')
let obj = {
......@@ -113,13 +134,15 @@ export default function AccountTest() {
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOUT'
};
accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) {
expect(result).assertTrue()
accountAbility.updateOsAccountDistributedInfo(obj).then(function (err) {
expect(err).assertEqual(undefined)
});
});
});
accountAbility.queryOsAccountDistributedInfo(function (data) {
execpt(data).assertNull()
expect(data).assertEqual(undefined)
done();
})
})
......@@ -128,34 +151,32 @@ export default function AccountTest() {
* @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()
it('account_updateOsAccountDistributedInfo_test002', 0, async function (done) {
var accountAbility = account.getDistributedAccountAbility()
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGIN',
scalableData:data
scalableData:{}
};
accountAbility.updateOsAccountDistributedInfo(obj, function (result) {
expect(result).assertTrue()
accountAbility.queryOsAccountDistributedInfo(function (data) {
accountAbility.updateOsAccountDistributedInfo(obj, function () {
accountAbility.queryOsAccountDistributedInfo(function (err, data) {
console.debug("====>account_updateOsAccountDistributedInfo_test002 data:" + JSON.stringify(data))
expect(data.name).assertEqual('ZhangSan')
expect(data.id).assertEqual('12345')
const accountAbility = account.getDistributedAccountAbility()
expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5')
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOUT'
};
accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) {
expect(result).assertTrue()
accountAbility.updateOsAccountDistributedInfo(obj).then(function (data) {
expect(data).assertEqual(undefined)
done();
});
});
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0300
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
......@@ -163,7 +184,7 @@ export default function AccountTest() {
*/
it('account_updateOsAccountDistributedInfo_test003', 0, function () {
const accountAbility = account.getDistributedAccountAbility()
let data = null
let data = null
let obj = {
id: '12345',
name: 'ZhangSan',
......@@ -171,13 +192,15 @@ export default function AccountTest() {
scalableData:data
};
accountAbility.updateOsAccountDistributedInfo(obj, function (result) {
expect(result).assertTrue()
console.debug("====>account_updateOsAccountDistributedInfo_test003 update_err:" + JSON.stringify(result))
accountAbility.queryOsAccountDistributedInfo(obj).then(function (data) {
except(data.name).assertNull()
console.debug("====>account_updateOsAccountDistributedInfo_test003 data:" + JSON.stringify(data))
expect(data.name).assertNull()
done();
})
});
})
/**
* @tc.number SUB_Account_distributedAccount_JS_API_0500
* @tc.name Test distributedAccount.updateOsAccountDistributedInfo by callback.
......@@ -185,27 +208,27 @@ export default function AccountTest() {
*/
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
scalableData:{}
};
accountAbility.updateOsAccountDistributedInfo(obj, function (result) {
expect(result).assertTrue()
accountAbility.queryOsAccountDistributedInfo(function (data) {
accountAbility.updateOsAccountDistributedInfo(obj, function (err) {
console.debug("====>account_updateOsAccountDistributedInfo_test004 update_err:" + JSON.stringify(err))
accountAbility.queryOsAccountDistributedInfo(function (err, data) {
console.debug("====>account_updateOsAccountDistributedInfo_test004 query_err:" + JSON.stringify(err))
console.debug("====>account_updateOsAccountDistributedInfo_test004 query_data:" + JSON.stringify(data))
expect(data.name).assertEqual('ZhangSan')
expect(data.id).assertEqual('12345')
const accountAbility = account.getDistributedAccountAbility()
expect(data.id).assertEqual('5994471ABB01112AFCC18159F6CC74B4F511B99806DA59B3CAF5A9C173CACFC5')
let obj = {
id: '12345',
name: 'ZhangSan',
event: 'Ohos.account.event.LOGOFF'
};
accountAbility.updateOsAccountDistributedInfo(obj).then(function (result) {
expect(result).assertNull()
accountAbility.updateOsAccountDistributedInfo(obj).then(function (err) {
expect(err).assert(undefined)
done();
});
});
});
......
......@@ -17,11 +17,15 @@ group("appaccount_hap") {
testonly = true
if (is_standard_system) {
deps = [
"actsaccountoperatetest:ActsAccountOperateTest",
"actsaccounttest:ActsAccountTest",
"actsaccounttstest:ActsAccountTsTest",
"actsgetaccountsbyowner:ActsGetAccountsByOwnerTest",
"actsgetallaccounts:ActsGetAllAccountsTest",
"actssetcheckdatasyncenable:ActsSetCheckDataSyncEnableTest",
"actssetchecksyncenable:ActsSetCheckSyncEnableTest",
"getallaccessibleaccounts:accessibleaccounts",
"getallaccounts:getallaccounts",
"sceneProject:appaccount_scene",
]
}
......
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES 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("ActsAccountOperateTest") {
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAccountOperateTest"
subsystem_name = "account"
part_name = "os_account"
}
ohos_js_assets("hjs_demo_js_assets") {
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "3000000",
"bundle-name": "com.example.actsaccountoperatetest",
"package-name": "com.example.actsaccountoperatetest",
"shell-timeout": "3000000"
},
"kits": [
{
"test-file-name": [
"ActsAccountOperateTest.hap",
"ActsAccountSceneAppAccess.hap",
"ActsAccountSceneOnOff.hap",
"ActsAccountOauthtoken.hap",
"ActsAccountAuthenticator.hap",
"ActsAccountTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsaccountoperatetest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsaccountoperatetest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"reqPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
}
],
"abilities": [
{
"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": [
"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.
*/
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
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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>
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
onInit() {
this.title = "ActsAccountOpertaeTest";
},
onShow() {
console.info('onShow finish')
},
onReady() {
},
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;
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.
*/
import account from '@ohos.account.appAccount'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
const TIMEOUT = 5000;
export default function ActsAccountManager() {
describe('ActsAccountManager', 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 : ActsAccountManager_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('ActsAccountManager_0100', 0, async function (done) {
console.debug("====>ActsAccountManager_0100 start====");
var appAccountManager = account.createAppAccountManager();
var appAccountManagerTwo = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.createAccount("creatappaccount_name_first", (err)=>{
console.debug("====>add account ActsAccountManager_0100 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManagerTwo.removeAccount("creatappaccount_name_first", (err)=>{
console.debug("====>delete Account ActsAccountManager_0100 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
console.debug("====>ActsAccountManager_0100 end====");
done();
});
});
});
/*
* @tc.number : ActsAccountManager_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('ActsAccountManager_0200', 0, async function (done) {
console.debug("====>ActsAccountManager_0200 start====");
var appAccountManager = account.createAppAccountManager();
var appAccountManagerTwo = account.createAppAccountManager();
console.debug("====>creat finish====");
appAccountManager.createAccount("creatappaccount_name_second", (err)=>{
console.debug("====>add account ActsAccountManager_0200 err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManagerTwo.setAccountExtraInfo("creatappaccount_name_second", "creatappaccount_extra", (err)=>{
console.debug("====>setAccountExtraInfo err:" + JSON.stringify(err));
expect(err).assertEqual(null);
appAccountManager.getAccountExtraInfo("creatappaccount_name_second", (err, data)=>{
console.debug("====>getAccountExtraInfo err:" + JSON.stringify(err));
console.debug("====>getAccountExtraInfo data:" + JSON.stringify(data));
expect(err).assertEqual(null);
expect(data).assertEqual("creatappaccount_extra");
appAccountManagerTwo.removeAccount("creatappaccount_name_second", (err)=>{
console.debug("====>delete Account err:" + JSON.stringify(err));
expect(err).assertEqual(null);
console.debug("====>ActsAccountManager_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 ActsAccountCreateAccount from './CreateAccount.test.js'
import ActsAccountRemoveAccount from './RemoveAccount.test.js'
import ActsAccountSetAppAccess from './SetAppAccess.test.js'
import ActsAccountCustomData from './CustomData.test.js'
import ActsAppAccountCredential from './AccountCredential.test.js'
import ActsAccountAuthToken from './AuthToken.test.js'
import ActsAccountManager from './AccountManager.test.js'
import ActsAccountErrPermission from './ErrPermission.test.js'
import ActsAccountOnOff from './ChangeOnOff.js'
import ActsAccountAuthenticator from './Authenticator.test.js'
import ActsAccountErrCode from './ErrCode.test.js'
export default function testsuite() {
ActsAccountCreateAccount()
ActsAccountSetAppAccess()
ActsAccountCustomData()
ActsAccountManager()
ActsAppAccountCredential()
ActsAccountRemoveAccount()
ActsAccountErrPermission()
ActsAccountAuthToken()
ActsAccountOnOff()
ActsAccountAuthenticator()
ActsAccountErrCode()
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsAccountTest"
},
{
"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,8 @@
"ActsAccountSceneAppAccess.hap",
"ActsAccountSceneOnOff.hap",
"ActsAccountOauthtoken.hap",
"ActsAccountAuthenticator.hap"
"ActsAccountAuthenticator.hap",
"ActsAccountOperateTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
......
......@@ -352,11 +352,12 @@ export default function ActsAccountAddAccount() {
var specialStr = " ";
try{
await appAccountManager.addAccount(specialStr, "account_extraInfo_promise_eighth");
expect().assertFail();
done();
}
catch(err){
console.debug("====>add Account ActsAccountAddAccount_1600 err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsAccountAddAccount_1600 end====");
console.debug("====>add Account ActsAccountAddAccount_1600 throw_err:" + JSON.stringify(err));
expect(err.code != 0 ).assertEqual(true);
done();
}
});
......
......@@ -1120,7 +1120,6 @@ export default function ActsAccountAssociatedData() {
console.debug("====>getAssociatedData 2900 err:" + JSON.stringify(err));
console.debug("====>getAssociatedData 2900 data:" + JSON.stringify(data));
expect(err.code != 0).assertEqual(true);
expect(data).assertEqual(null);
console.debug("====>ActsAccountAssociatedData_2900 end====");
done();
});
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册