提交 1b00520e 编写于 作者: C caiminggang

Stage mode of enterprise_device_management xts

Signed-off-by: Ncaiminggang <caiminggang1@huawei.com>
上级 a6e94671
......@@ -13,9 +13,19 @@
import("//build/ohos_var.gni")
group("edm_test_grop") {
testonly = true
if (is_standard_system) {
deps = [
"TestExtensionAbility_001:ExtensionZeroTest",
"edm_xts_stage:ActsEdmTest",
]
}
}
group("customization") {
testonly = true
if (is_standard_system) {
deps = [ "enterprise_device_management:edm_test_grop" ]
deps = [ ":edm_test_grop" ]
}
}
{
"app": {
"bundleName": "com.example.extensionzerotest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon" : "$media:icon",
"label" : "$string:app_name",
"description" : "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 8,
"targetAPIVersion": 8,
"car": {
"apiCompatibleVersion": 8,
"singleUser": false
}
}
}
\ No newline at end of file
......@@ -2,11 +2,7 @@
"string": [
{
"name": "app_name",
"value": "L2Test"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
"value": "ohosProject"
}
]
}
\ No newline at end of file
}
......@@ -10,25 +10,32 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap("edmJstest1") {
hap_profile = "./src/main/config.json"
hap_name = "edmJstest1"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
ohos_js_hap_suite("ExtensionZeroTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
":extensionZeroTest_js_assets",
":extensionZeroTest_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ExtensionZeroTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
ohos_app_scope("extensionZeroTest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/js/resources" ]
hap_profile = "./src/main/config.json"
ohos_js_assets("extensionZeroTest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("extensionZeroTest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":extensionZeroTest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
......@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
......@@ -12,11 +12,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
console.log("MyAbilityStage onCreate")
globalThis.stageContext = this.context;
console.log("MyAbilityStage finish")
}
};
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
......@@ -12,14 +12,15 @@
* 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 {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
import EnterpriseAdminExtensionAbility from '@ohos.EnterpriseAdminExtensionAbility'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
onAdminEnabled() {
console.log('EnterpriseAdminExtensionAbility onAdminEnabled');
}
onAdminDisabled(){
console.log('EnterpriseAdminExtensionAbility onAdminDisabled');
}
}
\ 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 Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate");
globalThis.abilityWant = want;
globalThis.abilityContext = this.context
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index/index", null);
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("MainAbility onBackground");
}
};
/*
* 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"
@Entry
@Component
struct Index {
aboutToAppear() {
console.info("start run testcase!!!!")
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file)
core.addService('report', reportExtend)
core.init()
core.subscribeEvent('task', reportExtend)
console.info("subscribeEvent run !!!!")
const configService = core.getDefaultService('config')
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
configService.setConfig(globalThis.abilityWant.parameters)
core.execute()
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('MainAbility')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ 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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.extensionzerotest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"srcEntrance": "./ets/EnterpriseAdminAbility/EnterpriseAdminAbility.ts",
"name": "com.example.extensionzerotest.EnterpriseAdminAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "enterpriseAdmin",
"visible": true
}
],
"requestPermissions": [
{
"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.MANAGE_LOCAL_ACCOUNTS",
"reason": "ceshi"
},
{
"name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION",
"reason": "ceshi"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS",
"reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.INSTALL_BUNDLE",
"reason":"need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.MANAGE_MISSIONS",
"reason":"need use ohos.permission.MANAGE_MISSIONS"
},
{
"name":"ohos.permission.GET_RUNNING_INFO",
"reason":"need use ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name":"ohos.permission.CLEAN_APPLICATION_DATA",
"reason":"need use ohos.permission.CLEAN_APPLICATION_DATA"
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
\ No newline at end of file
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.myapplication",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ No newline at end of file
# Copyright (C) 2022 Huawei Device Co., Ltd.
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
......@@ -13,28 +13,29 @@
import("//test/xts/tools/build/suite.gni")
group("edm_test_grop") {
testonly = true
if (is_standard_system) {
deps = [
":edm_test",
"edmsceneone:edmJstest1",
]
}
}
ohos_js_hap_suite("edm_test") {
hap_profile = "./src/main/config.json"
ohos_js_hap_suite("ActsEdmTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":edm_assets",
":edm_js_assets",
":edm_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsEdmJsTest"
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsEdmTest"
}
ohos_js_assets("edm_assets") {
source_dir = "./src/main/js/default"
ohos_app_scope("edm_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("edm_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("edm_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
sources = [ "entry/src/main/resources" ]
deps = [ ":edm_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for enterprise device management Tests",
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "ohos.edm.test",
"shell-timeout": "60000"
"test-timeout": "180000",
"package": "com.example.myapplication",
"shell-timeout": "600000"
},
"kits": [
{
......@@ -17,12 +17,12 @@
]
},
{
"test-file-name": [
"ActsEdmJsTest.hap",
"edmJstest1.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
"test-file-name": [
"ActsEdmTest.hap",
"ExtensionZeroTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
}
\ No newline at end of file
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
......@@ -12,4 +12,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./EnterpriseDeviceManager.test.js')
import EnterpriseAdminExtensionAbility from '@ohos.EnterpriseAdminExtensionAbility'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
onAdminEnabled() {
console.log('EnterpriseAdminExtensionAbility onAdminEnabled');
}
onAdminDisabled(){
console.log('EnterpriseAdminExtensionAbility onAdminDisabled');
}
}
\ No newline at end of file
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage)
globalThis.windowStage = windowStage
globalThis.abilityStorage = this.storage
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
//Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
};
\ 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"
import testsuite from "../../test/List.test.ets"
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file)
core.addService('report', reportExtend)
core.init()
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters)
// testsuite(globalThis.abilityContext,globalThis.windowStage,globalThis.abilityStorage)
testsuite()
core.execute()
}
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
})
}
.width('100%')
.height('100%')
}
}
\ 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 router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -12,12 +12,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import edmPromiseTest from './edmPromise.test.ets'
import edmCallbackTest from './edmCallback.test.ets'
export default {
onCreate() {
console.info('TestApplication onCreate');
},
onDestroy() {
console.info('TestApplication onDestroy');
}
};
export default function testsuite() {
edmCallbackTest()
edmPromiseTest()
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -13,33 +13,33 @@
* limitations under the License.
*/
import {Core, ExpectExtend} from 'deccjsunit/index'
const WANT1 = {
bundleName: "com.example.extensionzerotest",
abilityName: "com.example.extensionzerotest.EnterpriseAdminAbility"
};
const ENTINFO1 = {
name: "company",
description: "edm demo"
};
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
const SELFWANT = {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.EnterpriseAdminAbility"
};
const SELFHAPNAME = "com.example.myapplication"
const COMPANYNAME2 = "company2"
const DESCRIPTION2 = "edm demo2"
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 ENTINFO2 = {
name: "company2",
description: "edm demo2"
};
const configService = core.getDefaultService('config')
configService.setConfig(this)
const DEFAULT_USER_ID = 100;
const TEST_USER_ID = 101;
const ERR_USER_ID = 102;
require('../../test/List.test')
core.execute()
},
onReady() {
},
}
export {
WANT1, ENTINFO1, SELFWANT, SELFHAPNAME, COMPANYNAME2, DESCRIPTION2, ENTINFO2,
DEFAULT_USER_ID, TEST_USER_ID, ERR_USER_ID
}
\ 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "hypium/index"
import {
WANT1, ENTINFO1, SELFWANT, SELFHAPNAME, COMPANYNAME2, DESCRIPTION2,
ENTINFO2, DEFAULT_USER_ID, TEST_USER_ID, ERR_USER_ID
} from "./commom.ets";
import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager'
export default function edmCallbackTest() {
describe('edmCallback_test', function () {
/**
* @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0001
* @tc.name test enableAdmin method in callback mode without user id
* @tc.desc enable admin in callback mode
*/
it('enableAdmin_test_002', 0, async function (done) {
var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1,
enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, OnReceiveEvent);
async function OnReceiveEvent(err, datainfo) {
console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL :' + datainfo);
expect(datainfo).assertTrue();
var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1);
console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled);
expect(isEnabled).assertTrue();
retValue = await enterpriseDeviceManager.disableAdmin(WANT1);
console.log('enterpriseDeviceManager.disableAdmin : ' + retValue);
expect(retValue).assertTrue();
isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1);
console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled);
expect(isEnabled).assertFalse();
done();
}
})
/**
* @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0004
* @tc.name test enableAdmin method in callback mode with ADMIN_TYPE_SUPER param without user id
* @tc.desc enable super admin in callback mode
*/
it('enableAdmin_test_004', 0, async function (done) {
var retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1,
enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER, OnReceiveEvent);
async function OnReceiveEvent(err, datainfo) {
console.log('enterpriseDeviceManager.enableAdmin : ' + retValue);
expect(datainfo).assertTrue();
var isEnabled = await enterpriseDeviceManager.isSuperAdmin(SELFHAPNAME);
console.log('enterpriseDeviceManager.isSuperAdmin :' + isEnabled);
expect(isEnabled).assertTrue();
retValue = await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME);
console.log('enterpriseDeviceManager.disableSuperAdmin : ' + retValue);
expect(retValue).assertTrue();
isEnabled = await enterpriseDeviceManager.isSuperAdmin(SELFHAPNAME);
console.log('enterpriseDeviceManager.isSuperAdmin : ' + isEnabled);
expect(isEnabled).assertFalse();
done();
}
})
/**
* @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0006
* @tc.name test enableAdmin method in callback mode without user id
* @tc.desc enable admin in callback mode
*/
it('enableAdmin_test_006', 0, async function (done) {
console.log(' enableAdmin()');
var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1,
enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, OnReceiveEvent);
async function OnReceiveEvent(err, datainfo) {
console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL :' + datainfo);
expect(datainfo).assertTrue();
var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1);
console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled);
expect(isEnabled).assertTrue();
retValue = await enterpriseDeviceManager.disableAdmin(WANT1);
console.log('enterpriseDeviceManager.disableAdmin : ' + retValue);
expect(retValue).assertTrue();
isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1);
console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled);
expect(isEnabled).assertFalse();
done();
}
})
/**
* @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0008
* @tc.name test enableAdmin method with user id in callback mode with default user id
* @tc.desc enable admin in multi-user
*/
it('enableAdmin_test_008', 0, async function (done) {
var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1,
enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID, OnReceiveEvent);
async function OnReceiveEvent(err, datainfo) {
console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL :' + datainfo);
expect(datainfo).assertTrue();
var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, DEFAULT_USER_ID);
console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled);
expect(isEnabled).assertTrue();
retValue = await enterpriseDeviceManager.disableAdmin(WANT1, DEFAULT_USER_ID);
console.log('enterpriseDeviceManager.disableAdmin : ' + retValue);
expect(retValue).assertTrue();
isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, DEFAULT_USER_ID);
console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled);
expect(isEnabled).assertFalse();
done();
}
})
/**
* @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0012
* @tc.name test enableAdmin method in callback mode with test user id
* @tc.desc enable admin in multi-user
*/
it('enableAdmin_test_012', 0, async function (done) {
var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1,
enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, TEST_USER_ID, OnReceiveEvent);
async function OnReceiveEvent(err, datainfo) {
console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL :' + datainfo);
expect(datainfo).assertTrue();
var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_USER_ID);
console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled);
expect(isEnabled).assertTrue();
retValue = await enterpriseDeviceManager.disableAdmin(WANT1, TEST_USER_ID);
console.log('enterpriseDeviceManager.disableAdmin : ' + retValue);
expect(retValue).assertTrue();
isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_USER_ID);
console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled);
expect(isEnabled).assertFalse();
done();
}
})
/**
* @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0013
* @tc.name test enableAdmin method in promise mode and query with error user id
* @tc.desc enable admin in multi-user
*/
it('enableAdmin_test_013', 0, async function (done) {
var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1,
enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID, OnReceiveEvent);
async function OnReceiveEvent(err, datainfo) {
console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL :' + datainfo);
expect(datainfo).assertTrue();
var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_USER_ID);
console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled);
expect(isEnabled).assertFalse();
retValue = await enterpriseDeviceManager.disableAdmin(WANT1, DEFAULT_USER_ID);
console.log('enterpriseDeviceManager.disableAdmin : ' + retValue);
expect(retValue).assertTrue();
isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, DEFAULT_USER_ID);
console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled);
expect(isEnabled).assertFalse();
done();
}
})
/**
* @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0014
* @tc.name test enableAdmin method in callback mode and disable with error user id
* @tc.desc enable and disable admin in multi-user
*/
it('enableAdmin_test_014', 0, async function (done) {
var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1,
enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, TEST_USER_ID, OnReceiveEvent);
async function OnReceiveEvent(err, datainfo) {
console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL :' + datainfo);
expect(datainfo).assertTrue();
var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_USER_ID);
console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled);
expect(isEnabled).assertTrue();
try {
retValue = await enterpriseDeviceManager.disableAdmin(WANT1, DEFAULT_USER_ID);
console.log('enterpriseDeviceManager.disableAdmin over');
} catch (error) {
expect(error != null).assertTrue();
console.log("enableAdmin_test_014 throw error code : " + error.code + "message :" + error.message);
}
isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_USER_ID);
console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled);
expect(isEnabled).assertTrue();
retValue = await enterpriseDeviceManager.disableAdmin(WANT1, TEST_USER_ID);
console.log('enterpriseDeviceManager.disableAdmin : ' + retValue);
expect(retValue).assertTrue();
isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_USER_ID);
console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled);
expect(isEnabled).assertFalse();
done();
}
})
/**
* @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0017
* @tc.name test setEnterpriseInfo method in callback mode
* @tc.desc set enterprise info in callback mode
*/
it('setEnterpriseInfo_test_002', 0, async function (done) {
var retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1,
enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL);
console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL : ' + retValue);
expect(retValue).assertTrue();
var isEnabled = await enterpriseDeviceManager.isAdminEnabled(SELFWANT);
expect(isEnabled).assertTrue();
console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled);
retValue = await enterpriseDeviceManager.setEnterpriseInfo(SELFWANT, ENTINFO2, OnReceiveEvent);
async function OnReceiveEvent(err, datainfo) {
console.log('enterpriseDeviceManager.setEnterpriseInfo : ' + datainfo);
expect(datainfo).assertTrue();
var entInfo = await enterpriseDeviceManager.getEnterpriseInfo(SELFWANT);
expect(entInfo.name).assertEqual(COMPANYNAME2);
expect(entInfo.description).assertEqual(DESCRIPTION2);
retValue = await enterpriseDeviceManager.disableAdmin(SELFWANT);
console.log('enterpriseDeviceManager.disableAdmin : ' + retValue);
expect(retValue).assertTrue();
isEnabled = await enterpriseDeviceManager.isAdminEnabled(SELFWANT);
console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled);
expect(isEnabled).assertFalse();
done();
}
})
/**
* @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0018
* @tc.name test getDeviceSettingsManager method in callback mode
* @tc.desc get the device settings manager in callback mode
*/
it('getDeviceSettingsManager_test_001', 0, async function (done) {
enterpriseDeviceManager.getDeviceSettingsManager((error, mgr) => {
expect(mgr !== null).assertTrue();
})
console.log('getDeviceSettingsManager_test_001 done');
done();
})
/**
* @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0021
* @tc.name test setDateTime method in callback mode
* @tc.desc set system date time in callback mode
*/
it('setDateTime_test_002', 0, async function (done) {
await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1,
enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER);
let dsmgr = await enterpriseDeviceManager.getDeviceSettingsManager();
expect(dsmgr !== null).assertTrue();
console.log('before setDateTime');
await dsmgr.setDateTime(SELFWANT, 1526003846000, (error, data) => {
console.log("setDateTime ===data: " + data);
console.log("setDateTime ===error: " + error);
});
await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME);
done();
})
})
}
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [{
"name": "com.example.myapplication.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}]
}],
"extensionAbilities": [
{
"srcEntrance": "./ets/EnterpriseAdminAbility/EnterpriseAdminAbility.ts",
"name": "com.example.myapplication.EnterpriseAdminAbility",
"icon": "$media:icon",
"srcLanguage": "ets",
"description": "$string:phone_entry_main",
"type": "enterpriseAdmin",
"visible": true
}
],
"requestPermissions": [
{
"name": "ohos.permission.SYSTEM_FLOAT_WINDOW",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.CAPTURE_SCREEN",
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO",
"reason": "need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name": "ohos.permission.EDM_MANAGE_DATETIME",
"reason": "need use EDM_MANAGE_DATETIME"
},
{
"name": "ohos.permission.MANAGE_ADMIN",
"reason": "need use MANAGE_ADMIN"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.myapplication1",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 5,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.myapplication1",
"name": ".MyApplication1",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": ".MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"isVisible": "true",
"launchType": "standard",
"language": "C++",
"metaData": {
"customizeData": [
{
"name": "originWidgetName",
"value": "com.weather.testWidget"
}
]
}
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
{
"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;
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
{
"string": [
{
"name": "app_name",
"value": "bmssceneone"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.edm.test",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.edm.test",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.edm.test.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "MyApplication",
"type": "page",
"launchType": "standard"
}
],
"reqPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.INSTALL_BUNDLE",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.EDM_MANAGE_DATETIME",
"reason":"need use EDM_MANAGE_DATETIME"
},
{
"name":"ohos.permission.MANAGE_ADMIN",
"reason":"need use MANAGE_ADMIN"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
{
"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;
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{title}}
</text>
</div>
{
"plural":[
{
"name":"plural_name",
"value":[
{
"quantity":"zero",
"value":"%d test zero"
},
{
"quantity":"one",
"value":"%d test one"
},
{
"quantity":"two",
"value":"%d test two"
},
{
"quantity":"few",
"value":"%d test few"
},
{
"quantity":"many",
"value":"%d test many"
},
{
"quantity":"other",
"value":"%d test other"
}
]
}
]
}
\ No newline at end of file
{
"strarray": [
{
"name": "sizeList",
"value":[
{
"value":"small"
},
{
"value":"middle"
},
{
"value":"large"
},
{
"value":"extra large"
}
]
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册