未验证 提交 4c344187 编写于 作者: O openharmony_ci 提交者: Gitee

!1530 Update xts osaccount test

Merge pull request !1530 from 高曦/master_osaccount_0110
...@@ -18,6 +18,7 @@ group("account") { ...@@ -18,6 +18,7 @@ group("account") {
deps = [ deps = [
"OsAccountTest_js:ActsOsAccountJSApiTest", "OsAccountTest_js:ActsOsAccountJSApiTest",
"appaccount:appaccount_hap", "appaccount:appaccount_hap",
"osaccount:osaccount_hap",
] ]
} else { } else {
deps = [] deps = []
......
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
group("osaccount_hap") {
testonly = true
if (is_standard_system) {
deps = [
"actsosaccountsystemtest:ActsOsAccountSystemTest",
"actsosaccountthirdpartytest:ActsOsAccountThirdPartyTest",
]
}
}
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES 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("ActsOsAccountSystemTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsOsAccountSystemTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "com.example.actsosaccountsystemtest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsOsAccountSystemTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsosaccountsystemtest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsosaccountsystemtest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION"
}
],
"reqPermissions": [
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
},
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "ceshi"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsosaccountsystemtest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
STActsOsAccountSystemTest
</text>
</div>
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file'
import {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = 8000;
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsOsAccountSystemTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import osaccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('ActsOsAccountSystemTest', function () {
/*
* @tc.number : ActsOsAccountActivate_0100
* @tc.name : activateOsAccount callback
* @tc.desc : Verify repeat switch 100 local user
*/
it('ActsOsAccountActivate_0100', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_0100 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.isOsAccountActived(100, (err, data)=>{
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>isOsAccountActived data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertTrue();
osAccountManager.activateOsAccount(100, (err)=>{
console.debug("====>activateOsAccount err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountActivate_0100 end====");
done();
})
})
});
/*
* @tc.number : ActsOsAccountActivate_0200
* @tc.name : activateOsAccount promise
* @tc.desc : Verify repeat switch 100 local user
*/
it('ActsOsAccountActivate_0200', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_0200 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
var isActived = await osAccountManager.isOsAccountActived(100);
}catch(err){
console.error("====>catch isOsAccountActived 0200 err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isOsAccountActived err:" + JSON.stringify(isActived));
expect(isActived).assertTrue();
try{
await osAccountManager.activateOsAccount(100);
}catch(err){
console.debug("====>catch activateOsAccount 0200 err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountActivate_0200 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountActivate_0300
* @tc.name : activateOsAccount callback
* @tc.desc : Authenticate switch to newly created local user
*/
it('ActsOsAccountActivate_0300', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_0300 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var osLocalId;
osAccountManager.createOsAccount("osAccountNameTestActivate", 1, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
osLocalId = osAccountInfo.localId;
expect(err.code).assertEqual(0);
osAccountManager.isOsAccountActived(osLocalId, (err, data)=>{
console.debug("====>localId: " + osLocalId + " isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>localId: " + osLocalId + " isOsAccountActived data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertFalse();
osAccountManager.activateOsAccount(osLocalId, (err)=>{
console.debug("====>activateOsAccount localId: " + osLocalId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.isOsAccountActived(osLocalId, (err, data)=>{
console.debug("====>localId: " + osLocalId + " isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>localId: " + osLocalId + " isOsAccountActived data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertTrue();
osAccountManager.isOsAccountActived(100, (err, data)=>{
console.debug("====>localId: 100 isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>localId: 100 isOsAccountActived data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertFalse();
osAccountManager.activateOsAccount(100, (err)=>{
console.debug("====>activateOsAccount localId: 100 err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.removeOsAccount(osLocalId, (err)=>{
console.debug("====>remove localId: " + osLocalId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountActivate_0300 end====");
done();
})
})
})
})
})
})
})
});
/*
* @tc.number : ActsOsAccountActivate_0400
* @tc.name : activateOsAccount promise
* @tc.desc : Authenticate switch to newly created local user
*/
it('ActsOsAccountActivate_0400', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_0400 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var osLocalId;
var osAccountInfo = await osAccountManager.createOsAccount("osAccountNameTestActivate", 1);
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
osLocalId = osAccountInfo.localId;
var isActived = await osAccountManager.isOsAccountActived(osLocalId);
console.debug("====>localId: " + osLocalId + " isOsAccountActived:" + isActived);
expect(isActived).assertFalse();
await osAccountManager.activateOsAccount(osLocalId);
var isActivedTwice = await osAccountManager.isOsAccountActived(osLocalId);
console.debug("====>after activing localId: " + osLocalId + " isOsAccountActived:" + isActivedTwice);
expect(isActivedTwice).assertTrue();
var isActiveHandred = await osAccountManager.isOsAccountActived(100);
console.debug("====>localId: 100 isOsAccountActived:" + isActiveHandred);
expect(isActiveHandred).assertFalse();
await osAccountManager.activateOsAccount(100);
await osAccountManager.removeOsAccount(osLocalId);
console.debug("====>ActsOsAccountActivate_0400 end====");
done();
});
/*
* @tc.number : ActsOsAccountActivate_0500
* @tc.name : activateOsAccount callback
* @tc.desc : Authenticate failed to switch to 0 user
*/
it('ActsOsAccountActivate_0500', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_0500 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.activateOsAccount(0, (err)=>{
console.debug("====>activateOsAccount to 0 user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountActivate_0500 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountActivate_0600
* @tc.name : activateOsAccount promise
* @tc.desc : Authenticate failed to switch to 0 user
*/
it('ActsOsAccountActivate_0600', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_0600 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.activateOsAccount(0);
}catch(err){
console.debug("====>activateOsAccount to 0 user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountActivate_0600 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountActivate_0700
* @tc.name : activateOsAccount callback
* @tc.desc : Authenticate failed to switch to -1 user
*/
it('ActsOsAccountActivate_0700', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_0700 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.activateOsAccount(-1, (err)=>{
console.debug("====>activateOsAccount to -1 user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountActivate_0700 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountActivate_0800
* @tc.name : activateOsAccount promise
* @tc.desc : Authenticate failed to switch to -1 user
*/
it('ActsOsAccountActivate_0800', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_0800 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.activateOsAccount(-1);
}catch(err){
console.debug("====>activateOsAccount to -1 user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountActivate_0800 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountActivate_0900
* @tc.name : activateOsAccount callback
* @tc.desc : Authenticate failed to switch to "Abc" user
*/
it('ActsOsAccountActivate_0900', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_0900 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.activateOsAccount("Abc", (err)=>{
console.debug("====>activateOsAccount to 'Abc' user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountActivate_0900 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountActivate_1000
* @tc.name : activateOsAccount promise
* @tc.desc : Authenticate failed to switch to "Abc" user
*/
it('ActsOsAccountActivate_1000', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_1000 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.activateOsAccount("Abc");
}catch(err){
console.debug("====>activateOsAccount to 'Abc' user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountActivate_1000 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountActivate_1100
* @tc.name : activateOsAccount callback
* @tc.desc : Authenticate failed to switch to undefined user
*/
it('ActsOsAccountActivate_1100', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_1100 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.activateOsAccount(undefined, (err)=>{
console.debug("====>activateOsAccount to undefined user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountActivate_1100 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountActivate_1200
* @tc.name : activateOsAccount promise
* @tc.desc : Authenticate failed to switch to undefined user
*/
it('ActsOsAccountActivate_1200', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_1200 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.activateOsAccount(undefined);
}catch(err){
console.debug("====>activateOsAccount to undefined user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountActivate_1200 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountActivate_1300
* @tc.name : activateOsAccount callback
* @tc.desc : Authenticate failed to switch to non-existent user
*/
it('ActsOsAccountActivate_1300', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_1300 start====");
var osAccountManager = osaccount.getAccountManager();
var nonExistentLocalId = 1000;
console.debug("====>get AccountManager finish====");
osAccountManager.activateOsAccount(nonExistentLocalId, (err)=>{
console.debug("====>activateOsAccount to nonexist user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountActivate_1300 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountActivate_1400
* @tc.name : activateOsAccount promise
* @tc.desc : Authenticate failed to switch to non-existent user
*/
it('ActsOsAccountActivate_1400', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_1400 start====");
var osAccountManager = osaccount.getAccountManager();
var nonExistentLocalId = 1000;
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.activateOsAccount(nonExistentLocalId);
}catch(err){
console.debug("====>activateOsAccount to nonexist user err:" + JSON.stringify(err));
expect(err.code != 0).assertTrue();
console.debug("====>ActsOsAccountActivate_1400 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountActivate_1500
* @tc.name : activateOsAccount callback
* @tc.desc : Authenticate delete newly created active user
*/
it('ActsOsAccountActivate_1500', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_1500 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
osAccountManager.createOsAccount("osAccountNameTestDelete", 1, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
localId = osAccountInfo.localId;
expect(err.code).assertEqual(0);
osAccountManager.isOsAccountActived(localId, (err, data)=>{
console.debug("====>localId: " + localId + " isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>localId: " + localId + " isOsAccountActived data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertFalse();
osAccountManager.activateOsAccount(localId, (err)=>{
console.debug("====>activateOsAccount localId: " + localId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.isOsAccountActived(localId, (err, data)=>{
console.debug("====>localId: " + localId + " isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>localId: " + localId + " isOsAccountActived data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertTrue();
osAccountManager.removeOsAccount(localId, (err)=>{
console.debug("====>remove localId: " + localId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
osAccountManager.isOsAccountActived(100, (err, data)=>{
console.debug("====>localId: 100 isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>localId: 100 isOsAccountActived data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertTrue();
console.debug("====>ActsOsAccountActivate_1500 end====");
done();
})
})
})
})
})
})
});
/*
* @tc.number : ActsOsAccountActivate_1600
* @tc.name : activateOsAccount promise
* @tc.desc : Authenticate delete newly created active user
*/
it('ActsOsAccountActivate_1600', 0, async function (done) {
console.debug("====>ActsOsAccountActivate_1600 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var localId;
var osAccountInfo = await osAccountManager.createOsAccount("osAccountNameTestActivate", 1);
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
localId = osAccountInfo.localId;
var isActived = await osAccountManager.isOsAccountActived(localId);
console.debug("====>localId: " + localId + " isOsAccountActived:" + isActived);
expect(isActived).assertFalse();
await osAccountManager.activateOsAccount(localId);
var isActivedTwice = await osAccountManager.isOsAccountActived(localId);
console.debug("====>after activing localId: " + localId + " isOsAccountActived:" + isActivedTwice);
expect(isActivedTwice).assertTrue();
await osAccountManager.removeOsAccount(localId);
var isActiveHandred = await osAccountManager.isOsAccountActived(100);
console.debug("====>localId: 100 isOsAccountActived:" + isActiveHandred);
expect(isActiveHandred).assertTrue();
console.debug("====>ActsOsAccountActivate_1600 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.
*/
require('./Query.test.js')
require('./Activate.test.js')
require('./OnOff.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 osaccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
const OSACCOUNTMAXNUMBER = 999;
describe('ActsOsAccountSystemTest', function () {
/*
* @tc.number : ActsOsAccountQuery_0100
* @tc.name : queryOsAccountById callback
* @tc.desc : Authenticate to get local user 100 information and compare
*/
it('ActsOsAccountQuery_0100', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_0100 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.queryOsAccountById(100, (err, data)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
console.debug("====>queryOsAccountById data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data.localId).assertEqual(100);
expect(data.type.ADMIN).assertEqual(0);
var serialNumberStr = data.serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
expect(serialIntercept).assertEqual("00000001");
expect(data.isCreateCompleted).assertTrue();
console.debug("====>ActsOsAccountQuery_0100 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountQuery_0200
* @tc.name : queryOsAccountById promise
* @tc.desc : Authenticate to get local user 100 information and compare
*/
it('ActsOsAccountQuery_0200', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_0200 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var osAccountInfo = await osAccountManager.queryOsAccountById(100);
console.debug("====>queryOsAccountById osAccountInfo:" + JSON.stringify(osAccountInfo));
expect(osAccountInfo.localId).assertEqual(100);
expect(osAccountInfo.type.ADMIN).assertEqual(0);
var serialNumberStr = osAccountInfo.serialNumber.toString();
var serialIntercept = serialNumberStr.substring(8);
console.debug("====>truncate the last eight characters: " + serialIntercept);
expect(serialIntercept).assertEqual("00000001");
expect(osAccountInfo.isCreateCompleted).assertTrue();
console.debug("====>ActsOsAccountQuery_0200 end====");
done();
});
/*
* @tc.number : ActsOsAccountQuery_0300
* @tc.name : queryOsAccountById callback
* @tc.desc : Authenticate failed to obtain local user 0 information
*/
it('ActsOsAccountQuery_0300', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_0300 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.queryOsAccountById(0, (err)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsOsAccountQuery_0300 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountQuery_0400
* @tc.name : queryOsAccountById promise
* @tc.desc : Authenticate failed to obtain local user 0 information
*/
it('ActsOsAccountQuery_0400', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_0400 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.queryOsAccountById(0);
}catch(err){
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsOsAccountQuery_0400 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountQuery_0500
* @tc.name : queryOsAccountById callback
* @tc.desc : Authenticate failed to obtain local user -1 information
*/
it('ActsOsAccountQuery_0500', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_0500 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.queryOsAccountById(-1, (err)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsOsAccountQuery_0500 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountQuery_0600
* @tc.name : queryOsAccountById promise
* @tc.desc : Authenticate failed to obtain local user 0 information
*/
it('ActsOsAccountQuery_0600', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_0600 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.queryOsAccountById(-1);
}catch(err){
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsOsAccountQuery_0600 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountQuery_0700
* @tc.name : queryOsAccountById callback
* @tc.desc : Authenticate failed to obtain local user "100" information
*/
it('ActsOsAccountQuery_0700', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_0700 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.queryOsAccountById("100", (err)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsOsAccountQuery_0700 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountQuery_0800
* @tc.name : queryOsAccountById promise
* @tc.desc : Authenticate failed to obtain local user "100" information
*/
it('ActsOsAccountQuery_0800', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_0800 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.queryOsAccountById("100");
}catch(err){
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsOsAccountQuery_0800 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountQuery_0900
* @tc.name : queryOsAccountById callback
* @tc.desc : Authenticate failed to obtain local user undefined information
*/
it('ActsOsAccountQuery_0900', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_0900 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.queryOsAccountById(undefined, (err)=>{
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsOsAccountQuery_0900 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountQuery_1000
* @tc.name : queryOsAccountById promise
* @tc.desc : Authenticate failed to obtain local user undefined information
*/
it('ActsOsAccountQuery_1000', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_1000 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
try{
await osAccountManager.queryOsAccountById(undefined);
}catch(err){
console.debug("====>queryOsAccountById err:" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
console.debug("====>ActsOsAccountQuery_1000 end====");
done();
}
});
/*
* @tc.number : ActsOsAccountQuery_1100
* @tc.name : queryAllCreatedOsAccounts callback
* @tc.desc : Verify that all local users contain 100 user
*/
it('ActsOsAccountQuery_1100', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_1100 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
let dataMap = new Map();
osAccountManager.queryAllCreatedOsAccounts((err, data)=>{
console.debug("====>queryAllCreatedOsAccounts err:" + JSON.stringify(err));
console.debug("====>queryAllCreatedOsAccounts data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
for (let i = 0, len = data.length; i < len; i++) {
dataMap.set(data[i].localId, data[i].localName)
}
expect(dataMap.has(100)).assertTrue();
console.debug("====>ActsOsAccountQuery_1100 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountQuery_1200
* @tc.name : queryAllCreatedOsAccounts promise
* @tc.desc : Verify that all local users contain 100 user
*/
it('ActsOsAccountQuery_1200', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_1200 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
let dataMap = new Map();
var osAccountCreated = await osAccountManager.queryAllCreatedOsAccounts();
console.debug("====>queryAllCreatedOsAccounts:" + JSON.stringify(osAccountCreated));
for (let i = 0, len = osAccountCreated.length; i < len; i++) {
dataMap.set(osAccountCreated[i].localId, osAccountCreated[i].localName)
}
expect(dataMap.has(100)).assertTrue();
console.debug("====>ActsOsAccountQuery_1200 end====");
done();
});
/*
* @tc.number : ActsOsAccountQuery_1300
* @tc.name : queryAllCreatedOsAccounts callback
* @tc.desc : Verify that all local users contain 100 user and created users
*/
it('ActsOsAccountQuery_1300', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_1300 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var createIocalId;
let dataMap = new Map();
osAccountManager.createOsAccount("osAccountNameQueryA", 1, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" + JSON.stringify(err));
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
createIocalId = osAccountInfo.localId;
expect(err.code).assertEqual(0);
expect(osAccountInfo.localName).assertEqual("osAccountNameQueryA");
osAccountManager.queryAllCreatedOsAccounts((err, data)=>{
console.debug("====>queryAllCreatedOsAccounts err:" + JSON.stringify(err));
console.debug("====>queryAllCreatedOsAccounts data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
for (let i = 0, len = data.length; i < len; i++) {
dataMap.set(data[i].localId, data[i].localName)
}
expect(dataMap.has(100)).assertTrue();
expect(dataMap.has(createIocalId)).assertTrue();
if (dataMap.has(createIocalId)) {
let createdlocalName = dataMap.get(createIocalId);
console.debug("====>query all local users containing localId: " + createIocalId);
console.debug("====>created localName" + createdlocalName);
expect(createdlocalName).assertEqual("osAccountNameQueryA");
osAccountManager.removeOsAccount(createIocalId, (err)=>{
console.debug("====>remove localId: " + createIocalId + " err:" + JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountQuery_1300 end====");
done();
})
}
})
});
});
/*
* @tc.number : ActsOsAccountQuery_1400
* @tc.name : queryAllCreatedOsAccounts promise
* @tc.desc : Verify that all local users contain 100 user and created users
*/
it('ActsOsAccountQuery_1400', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_1400 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var createIocalId;
let dataMap = new Map();
var osAccountInfo = await osAccountManager.createOsAccount("osAccountNameQueryB", 1);
console.debug("====>createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
createIocalId = osAccountInfo.localId;
expect(osAccountInfo.localName).assertEqual("osAccountNameQueryB");
var data = await osAccountManager.queryAllCreatedOsAccounts();
console.debug("====>queryAllCreatedOsAccounts data:" + JSON.stringify(data));
for (let i = 0, len = data.length; i < len; i++) {
dataMap.set(data[i].localId, data[i].localName)
}
expect(dataMap.has(100)).assertTrue();
expect(dataMap.has(createIocalId)).assertTrue();
if (dataMap.has(createIocalId)) {
let createdlocalName = dataMap.get(createIocalId);
console.debug("====>query all local users containing localId: " + createIocalId);
expect(createdlocalName).assertEqual("osAccountNameQueryB");
}
await osAccountManager.removeOsAccount(createIocalId);
console.debug("====>ActsOsAccountQuery_1400 end====");
done();
});
/*
* @tc.number : ActsOsAccountQuery_1500
* @tc.name : queryMaxOsAccountNumber callback
* @tc.desc : Query the maximum number of users that can be created on the device
*/
it('ActsOsAccountQuery_1500', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_1500 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
osAccountManager.queryMaxOsAccountNumber((err, data)=>{
console.debug("====>queryMaxOsAccountNumber err:" + JSON.stringify(err));
console.debug("====>queryMaxOsAccountNumber data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertEqual(OSACCOUNTMAXNUMBER);
console.debug("====>ActsOsAccountQuery_1500 end====");
done();
})
});
/*
* @tc.number : ActsOsAccountQuery_1600
* @tc.name : queryMaxOsAccountNumber callback
* @tc.desc : Query the maximum number of users that can be created on the device
*/
it('ActsOsAccountQuery_1600', 0, async function (done) {
console.debug("====>ActsOsAccountQuery_1600 start====");
var osAccountManager = osaccount.getAccountManager();
console.debug("====>get AccountManager finish====");
var maxOsAccount = await osAccountManager.queryMaxOsAccountNumber();
console.debug("====>queryMaxOsAccountNumber:" + maxOsAccount);
expect(maxOsAccount).assertEqual(OSACCOUNTMAXNUMBER);
console.debug("====>ActsOsAccountQuery_1600 end====");
done();
});
/*
* @tc.number : ActsOsAccountIsVerified_0100
* @tc.name : isOsAccountVerified callback
* @tc.desc : create a os account and check whether the initial state of the os account is verified
*/
it('ActsOsAccountIsVerified_0100', 0, async function(done){
console.debug("====>ActsOsAccountIsVerified_0100 start====");
var AccountManager = osaccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var osLocalId;
AccountManager.createOsAccount("OsAccountNameVerfiedA", 1, (err, osAccountInfo)=>{
console.debug("====>createOsAccount err:" +JSON.stringify(err));
console.debug("====>createOsAccount data:" +JSON.stringify(osAccountInfo));
osLocalId = osAccountInfo.localId;
expect(err.code).assertEqual(0);
expect(osAccountInfo.localName).assertEqual("OsAccountNameVerfiedA");
AccountManager.isOsAccountVerified(osLocalId, (err, data)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
console.debug("====>isOsAccountVerified data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data).assertEqual(false);
AccountManager.removeOsAccount(osLocalId, (err)=>{
console.debug("====>removeOsAccount err:" +JSON.stringify(err));
expect(err.code).assertEqual(0);
console.debug("====>ActsOsAccountIsVerified_0100 end====");
done();
})
})
})
})
/*
* @tc.number : ActsOsAccountIsVerified_0200
* @tc.name : isOsAccountVerified promise
* @tc.desc : create a os account and check whether the initial state of the os account is verified
*/
it('ActsOsAccountIsVerified_0200', 0, async function(done){
console.debug("====>ActsOsAccountIsVerified_0200 start====");
var AccountManager = osaccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var data = await AccountManager.createOsAccount("OsAccountNameVerfiedB", 1);
console.debug("====>createOsAccount data:" + JSON.stringify(data));
expect(data.localName).assertEqual("OsAccountNameVerfiedB");
var osAccountLocalId = data.localId;
try{
var data = await AccountManager.isOsAccountVerified(osAccountLocalId);
}
catch(err){
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isOsAccountVerified data:" + data);
expect(data).assertEqual(false);
await AccountManager.removeOsAccount(osAccountLocalId);
console.debug("====>ActsOsAccountIsVerified_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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsOsAccountThirdPartyTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsOsAccountThirdPartyTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "100000",
"package": "com.example.actsosaccountthirdpartytest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsOsAccountThirdPartyTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsosaccountthirdpartytest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsosaccountthirdpartytest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.DISTRIBUTED_DATASYNC"
}
],
"reqPermissions": [
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
},
{
"name": "ohos.permission.DISTRIBUTED_DATASYNC",
"reason": "ceshi"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsosaccountthirdpartytest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.titleST {
font-size: 32px;
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
<text class="titleST">
STActsOsAccountThirdPartyTest
</text>
</div>
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file'
import {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsAccountTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./OsAccountIs.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 osAccount from '@ohos.account.osAccount'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('ActsOsAccountThirdPartyTest', function () {
/*
* @tc.number : ActsOsAccountDeviceId_0100
* @tc.name : getDistributedVirtualDeviceId callback
* @tc.desc : get distributed virtual device ID
*/
it('ActsOsAccountDeviceId_0100', 0, async function(done){
console.debug("====>ActsOsAccountDeviceId_0100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.getDistributedVirtualDeviceId((err, deviceId)=>{
console.debug("====>getDistributedVirtualDeviceId err:" + JSON.stringify(err));
console.debug("====>getDistributedVirtualDeviceId deviceId:" + deviceId);
expect(err.code).assertEqual(0);
expect(deviceId).assertEqual("0");
console.debug("====>ActsOsAccountDeviceId_0100 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountDeviceId_0200
* @tc.name : getDistributedVirtualDeviceId promise
* @tc.desc : get distributed virtual device ID
*/
it('ActsOsAccountDeviceId_0200', 0, async function(done){
console.debug("====>ActsOsAccountDeviceId_0200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var deviceId = await AccountManager.getDistributedVirtualDeviceId();
}
catch(err){
console.error("====>catch getDistributedVirtualDeviceId err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>getDistributedVirtualDeviceId:" + deviceId);
expect(deviceId).assertEqual("0");
console.debug("====>ActsOsAccountDeviceId_0200 end====");
done();
})
/*
* @tc.number : ActsOsAccountIsActived_0100
* @tc.name : isOsAccountActived callback
* @tc.desc : Verify that users are not switched and query 100 users as active
*/
it('ActsOsAccountIsActived_0100', 0, async function(done){
console.debug("====>ActsOsAccountIsActived_0100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountActived(100, (err, isActived)=>{
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
console.debug("====>isOsAccountActived isActived:" + isActived);
expect(err.code).assertEqual(0);
expect(isActived).assertEqual(true);
console.debug("====>ActsOsAccountIsActived_0100 end");
done();
})
})
/*
* @tc.number : ActsOsAccountIsActived_0200
* @tc.name : isOsAccountActived promise
* @tc.desc : Verify that users are not switched and query 100 users as active
*/
it('ActsOsAccountIsActived_0200', 0, async function(done){
console.debug("====>ActsOsAccountIsActived_0200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var isActived = await AccountManager.isOsAccountActived(100);
}
catch(err){
console.debug("====>catch isOsAccountActived err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isOsAccountActived:" + isActived);
expect(isActived).assertEqual(true);
console.debug("====>ActsOsAccountIsActived_0200 end");
done();
})
/*
* @tc.number : ActsOsAccountIsActived_0300
* @tc.name : isOsAccountActived callback
* @tc.desc : Authentication query 0 user active status failed
*/
it('ActsOsAccountIsActived_0300', 0, async function(done){
console.debug("====>ActsOsAccountIsActived_0300 start");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountActived(0, (err)=>{
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect(err.code !=0 ).assertEqual(true);
console.debug("====>ActsOsAccountIsActived_0300 end");
done();
})
})
/*
* @tc.number : ActsOsAccountIsActived_0400
* @tc.name : isOsAccountActived promise
* @tc.desc : Authentication query 0 user active status failed
*/
it('ActsOsAccountIsActived_0400', 0, async function(done){
console.debug("====>isOsAccountActived_0400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
await AccountManager.isOsAccountActived(0);
}
catch(err){
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect(err.code !=0 ).assertTrue();
done();
}
})
/*
* @tc.number : ActsOsAccountIsActived_0500
* @tc.name : isOsAccountActived callback
* @tc.desc : Authentication failed to query the active status of the user that does not exist
*/
it('ActsOsAccountIsActived_0500', 0, async function(done){
console.debug("====>ActsOsAccountIsActived_0500 start");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var nonExistLocalId = 1000;
AccountManager.isOsAccountActived(nonExistLocalId, (err)=>{
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect(err.code !=0).assertEqual(true);
console.debug("====>ActsOsAccountIsActived_0500 end");
done();
})
})
/*
* @tc.number : ActsOsAccountIsActived_0600
* @tc.name : isOsAccountActived promise
* @tc.desc : Authentication failed to query the active status of the user that does not exist
*/
it('ActsOsAccountIsActived_0600', 0, async function(done){
console.debug("====>ActsOsAccountIsActived_0600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var nonExistLocalId = 1000;
try{
await AccountManager.isOsAccountActived(nonExistLocalId);
}
catch(err){
console.debug("====>isOsAccountActived err:" + JSON.stringify(err));
expect(err.code !=0 ).assertTrue();
console.debug("====>ActsOsAccountIsActived_0600 end");
done();
}
})
/*
* @tc.number : ActsOsAccountIsMulty_0100
* @tc.name : isMultiOsAccountEnable callback
* @tc.desc : Check whether the function of supporting multiple os account is enabled
*/
it('ActsOsAccountIsMulty_0100', 0, async function(done){
console.debug("====>ActsOsAccountIsMulty_0100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isMultiOsAccountEnable((err, data)=>{
console.debug("====>isMultiOsAccountEnable err:" + JSON.stringify(err));
console.debug("====>isMultiOsAccountEnable data:" + data);
expect(err.code).assertEqual(0);
expect(data).assertEqual(true);
console.debug("====>ActsOsAccountIsMulty_0100 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountIsMulty_0200
* @tc.name : isMultiOsAccountEnable promise
* @tc.desc : Check whether the function of supporting multiple os account is enabled
*/
it('ActsOsAccountIsMulty_0200', 0, async function(done){
console.debug("====>ActsOsAccountIsMulty_0200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
var data = await AccountManager.isMultiOsAccountEnable();
}
catch(err){
console.debug("====>catch isMultiOsAccountEnable err:" + JSON.stringify(err));
expect().assertFail();
done();
}
console.debug("====>isMultiOsAccountEnable data:" + JSON.stringify(data));
expect(data).assertEqual(true);
console.debug("====>ActsOsAccountIsMulty_0200 end====");
done();
})
/*
* @tc.number : ActsOsAccountIsVerified_0300
* @tc.name : isOsAccountVerified callback
* @tc.desc : Verify query 0 user is unlocked failed
*/
it('ActsOsAccountIsVerified_0300', 0, async function(done){
console.debug("====>ActsOsAccountIsVerified_0300 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountVerified(0, (err)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code !=0 ).assertEqual(true);
console.debug("====>ActsOsAccountIsVerified_0300 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountIsVerified_0400
* @tc.name : isOsAccountVerified promise
* @tc.desc : Verify query 0 user is unlocked failed
*/
it('ActsOsAccountIsVerified_0400', 0, async function(done){
console.debug("====>ActsOsAccountIsVerified_0400 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
await AccountManager.isOsAccountVerified(0);
}
catch(err){
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code !=0 ).assertTrue();
console.debug("====>ActsOsAccountIsVerified_0400 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountIsVerified_0500
* @tc.name : isOsAccountVerified callback
* @tc.desc : Verify query "100" user is unlocked failed
*/
it('ActsOsAccountIsVerified_0500', 0, async function(done){
console.debug("====>ActsOsAccountIsVerified_0500 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountVerified("100", (err)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code !=0 ).assertEqual(true);
console.debug("====>ActsOsAccountIsVerified_0500 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountIsVerified_0600
* @tc.name : isOsAccountVerified promise
* @tc.desc : Verify query "100" user is unlocked failed
*/
it('ActsOsAccountIsVerified_0600', 0, async function(done){
console.debug("====>ActsOsAccountIsVerified_0600 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
await AccountManager.isOsAccountVerified("100");
}
catch(err){
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code !=0 ).assertTrue();
console.debug("====>ActsOsAccountIsVerified_0600 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountIsVerified_0700
* @tc.name : isOsAccountVerified callback
* @tc.desc : Verify query undefined user is unlocked failed
*/
it('ActsOsAccountIsVerified_0700', 0, async function(done){
console.debug("====>ActsOsAccountIsVerified_0700 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isOsAccountVerified(undefined, (err)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code !=0 ).assertEqual(true);
console.debug("====>ActsOsAccountIsVerified_0700 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountIsVerified_0800
* @tc.name : isOsAccountVerified promise
* @tc.desc : Verify query undefined user is unlocked failed
*/
it('ActsOsAccountIsVerified_0800', 0, async function(done){
console.debug("====>ActsOsAccountIsVerified_0800 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
try{
await AccountManager.isOsAccountVerified(undefined);
}
catch(err){
console.debug("====>ActsOsAccountIsVerified_0800 err:" + JSON.stringify(err));
expect(err.code !=0 ).assertTrue();
console.debug("====>ActsOsAccountIsVerified_0800 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountIsVerified_0900
* @tc.name : isOsAccountVerified callback
* @tc.desc : Verify query does not exist user unlock failed
*/
it('ActsOsAccountIsVerified_0900', 0, async function(done){
console.debug("====>ActsOsAccountIsVerified_0900 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var osAccountLocalId = 1000;
AccountManager.isOsAccountVerified(osAccountLocalId, (err)=>{
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code !=0 ).assertEqual(true);
console.debug("====>ActsOsAccountIsVerified_0900 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountIsVerified_1000
* @tc.name : isOsAccountVerified promise
* @tc.desc : Verify query does not exist user unlock failed
*/
it('ActsOsAccountIsVerified_1000', 0, async function(done){
console.debug("====>ActsOsAccountIsVerified_1000 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var osAccountLocalId = 1000;
try{
await AccountManager.isOsAccountVerified(osAccountLocalId);
}
catch(err){
console.debug("====>isOsAccountVerified err:" + JSON.stringify(err));
expect(err.code !=0 ).assertTrue();
console.debug("====>ActsOsAccountIsVerified_1000 end====");
done();
}
})
/*
* @tc.number : ActsOsAccountIsTest_0100
* @tc.name : isTestOsAccount callback
* @tc.desc : check whether this OS account is a test OS account
*/
it('ActsOsAccountIsTest_0100', 0, async function(done){
console.debug("====>ActsOsAccountIsTest_0100 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
AccountManager.isTestOsAccount((err, data)=>{
console.debug("====>isTestOsAccount err:" + JSON.stringify(err));
console.debug("====>isTestOsAccount data:" + JSON.stringify(data));
expect(err.code).assertEqual(0);
expect(data).assertEqual(false);
console.debug("====>ActsOsAccountIsTest_0100 end====");
done();
})
})
/*
* @tc.number : ActsOsAccountIsTest_0200
* @tc.name : isTestOsAccount promise
* @tc.desc : check whether this OS account is a test OS account
*/
it('ActsOsAccountIsTest_0200', 0, async function(done){
console.debug("====>ActsOsAccountIsTest_0200 start====");
var AccountManager = osAccount.getAccountManager();
console.debug("====>get os AccountManager finish====");
var isTest = await AccountManager.isTestOsAccount();
expect(isTest).assertFalse();
console.debug("====>ActsOsAccountIsTest_0200 end====");
done();
})
})
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册