diff --git a/customization/BUILD.gn b/customization/BUILD.gn index b22d774528cc37416601afa76d26533713e11c31..16f0c0c12e242e65956918230fb1f938f8373799 100755 --- a/customization/BUILD.gn +++ b/customization/BUILD.gn @@ -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" ] } } diff --git a/customization/TestExtensionAbility_001/AppScope/app.json b/customization/TestExtensionAbility_001/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..dca2f75e903360471499cee66e51cf04c45b9e98 --- /dev/null +++ b/customization/TestExtensionAbility_001/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "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 diff --git a/customization/TestExtensionAbility_001/AppScope/resources/base/element/string.json b/customization/TestExtensionAbility_001/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..be09cccde1bc7369ef47a5cd45d2b06884c88602 --- /dev/null +++ b/customization/TestExtensionAbility_001/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/customization/enterprise_device_management/edmsceneone/src/main/js/resources/base/media/icon.png b/customization/TestExtensionAbility_001/AppScope/resources/base/media/app_icon.png similarity index 100% rename from customization/enterprise_device_management/edmsceneone/src/main/js/resources/base/media/icon.png rename to customization/TestExtensionAbility_001/AppScope/resources/base/media/app_icon.png diff --git a/customization/TestExtensionAbility_001/BUILD.gn b/customization/TestExtensionAbility_001/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..317388a5ace8db64adfb47ec106c7a7594cec1cc --- /dev/null +++ b/customization/TestExtensionAbility_001/BUILD.gn @@ -0,0 +1,41 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ExtensionZeroTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":extensionZeroTest_js_assets", + ":extensionZeroTest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ExtensionZeroTest" +} + +ohos_app_scope("extensionZeroTest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +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" +} diff --git a/customization/enterprise_device_management/edmsceneone/Test.json b/customization/TestExtensionAbility_001/Test.json similarity index 98% rename from customization/enterprise_device_management/edmsceneone/Test.json rename to customization/TestExtensionAbility_001/Test.json index 7a88763ed8d2ac31dd30211b9574f47273e84549..26909f2889de98a479f076f87725fed805c7a343 100644 --- a/customization/enterprise_device_management/edmsceneone/Test.json +++ b/customization/TestExtensionAbility_001/Test.json @@ -1,3 +1,4 @@ { "description": "Configuration for hjunit demo Tests", } + diff --git a/customization/enterprise_device_management/edmsceneone/src/main/js/default/app.js b/customization/TestExtensionAbility_001/entry/src/main/ets/Application/AbilityStage.ts similarity index 65% rename from customization/enterprise_device_management/edmsceneone/src/main/js/default/app.js rename to customization/TestExtensionAbility_001/entry/src/main/ets/Application/AbilityStage.ts index 2d316a0a089b332c5c28729be9ff937aa46618c5..a51e07cc17f5fde64cd0b85de4ca6b5c6c63c2a7 100644 --- a/customization/enterprise_device_management/edmsceneone/src/main/js/default/app.js +++ b/customization/TestExtensionAbility_001/entry/src/main/ets/Application/AbilityStage.ts @@ -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 diff --git a/customization/enterprise_device_management/edmsceneone/src/main/js/default/pages/index/index.js b/customization/TestExtensionAbility_001/entry/src/main/ets/EnterpriseAdminAbility/EnterpriseAdminAbility.ts similarity index 52% rename from customization/enterprise_device_management/edmsceneone/src/main/js/default/pages/index/index.js rename to customization/TestExtensionAbility_001/entry/src/main/ets/EnterpriseAdminAbility/EnterpriseAdminAbility.ts index eb5be916aa414adb35cf8541635725d702a893dc..07426f68d4a25f3d67e3eb27d54931244e8eef57 100644 --- a/customization/enterprise_device_management/edmsceneone/src/main/js/default/pages/index/index.js +++ b/customization/TestExtensionAbility_001/entry/src/main/ets/EnterpriseAdminAbility/EnterpriseAdminAbility.ts @@ -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 diff --git a/customization/TestExtensionAbility_001/entry/src/main/ets/MainAbility/MainAbility.ts b/customization/TestExtensionAbility_001/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..56d78ede1a7d850b8f84f17745fb6228fba64f89 --- /dev/null +++ b/customization/TestExtensionAbility_001/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,50 @@ +/* + * 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"); + } +}; diff --git a/customization/TestExtensionAbility_001/entry/src/main/ets/pages/index/index.ets b/customization/TestExtensionAbility_001/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b0958581f15c3f9b21316eec8e58ecf2ec9df6d2 --- /dev/null +++ b/customization/TestExtensionAbility_001/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,47 @@ +/* + * 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 diff --git a/customization/TestExtensionAbility_001/entry/src/main/ets/pages/second/second.ets b/customization/TestExtensionAbility_001/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/customization/TestExtensionAbility_001/entry/src/main/ets/pages/second/second.ets @@ -0,0 +1,43 @@ +/* +* 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 diff --git a/customization/TestExtensionAbility_001/entry/src/main/module.json b/customization/TestExtensionAbility_001/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..07f87be0af6ac810f04ed68a08e589e94744fca9 --- /dev/null +++ b/customization/TestExtensionAbility_001/entry/src/main/module.json @@ -0,0 +1,102 @@ +{ + "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" + } + ] + } +} diff --git a/customization/TestExtensionAbility_001/entry/src/main/resources/base/element/string.json b/customization/TestExtensionAbility_001/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d75325f3cf0a50c1dfe4dbc5162c8737276c3dd9 --- /dev/null +++ b/customization/TestExtensionAbility_001/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "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 diff --git a/customization/enterprise_device_management/src/main/resources/base/media/icon.png b/customization/TestExtensionAbility_001/entry/src/main/resources/base/media/icon.png similarity index 100% rename from customization/enterprise_device_management/src/main/resources/base/media/icon.png rename to customization/TestExtensionAbility_001/entry/src/main/resources/base/media/icon.png diff --git a/customization/TestExtensionAbility_001/entry/src/main/resources/base/profile/main_pages.json b/customization/TestExtensionAbility_001/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/customization/TestExtensionAbility_001/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/customization/enterprise_device_management/signature/openharmony_sx.p7b b/customization/TestExtensionAbility_001/signature/openharmony_sx.p7b similarity index 92% rename from customization/enterprise_device_management/signature/openharmony_sx.p7b rename to customization/TestExtensionAbility_001/signature/openharmony_sx.p7b index 66b4457a8a81fb8d3356cf46d67226c850944858..cc53179a48f88f20acc379c138a001e9a15838f6 100644 Binary files a/customization/enterprise_device_management/signature/openharmony_sx.p7b and b/customization/TestExtensionAbility_001/signature/openharmony_sx.p7b differ diff --git a/customization/edm_xts_stage/AppScope/app.json b/customization/edm_xts_stage/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..2c223fed485d736ab9906abf778f3d48eeb6c7cf --- /dev/null +++ b/customization/edm_xts_stage/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "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 diff --git a/customization/edm_xts_stage/AppScope/resources/base/element/string.json b/customization/edm_xts_stage/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/customization/edm_xts_stage/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"ohosProject" + } + ] +} \ No newline at end of file diff --git a/customization/edm_xts_stage/AppScope/resources/base/media/app_icon.png b/customization/edm_xts_stage/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/customization/edm_xts_stage/AppScope/resources/base/media/app_icon.png differ diff --git a/customization/enterprise_device_management/BUILD.gn b/customization/edm_xts_stage/BUILD.gn similarity index 53% rename from customization/enterprise_device_management/BUILD.gn rename to customization/edm_xts_stage/BUILD.gn index 4f95ba3d5854bcf62e9761174ea969adf102de93..3ea3356b0e4bff97091a0f2f1446c067417eeb4e 100644 --- a/customization/enterprise_device_management/BUILD.gn +++ b/customization/edm_xts_stage/BUILD.gn @@ -1,4 +1,4 @@ -# 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" } diff --git a/customization/edm_xts_stage/Test.json b/customization/edm_xts_stage/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..2064ffd5d147b319c7f5f3bbe994f83b14894a91 --- /dev/null +++ b/customization/edm_xts_stage/Test.json @@ -0,0 +1,28 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.myapplication", + "shell-timeout": "600000" + }, + "kits": [ + { + "type": "ShellKit", + "run-command": [ + "acm create -n edmuser -t normal" + ], + "teardown-command": [ + "acm delete -i 101" + ] + }, + { + "test-file-name": [ + "ActsEdmTest.hap", + "ExtensionZeroTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/customization/edm_xts_stage/entry/src/main/ets/Application/AbilityStage.ts b/customization/edm_xts_stage/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..e3fdadfebeeeb676df2ce8f78f4b59e26fae9cf0 --- /dev/null +++ b/customization/edm_xts_stage/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,9 @@ +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; + } +} diff --git a/customization/edm_xts_stage/entry/src/main/ets/EnterpriseAdminAbility/EnterpriseAdminAbility.ts b/customization/edm_xts_stage/entry/src/main/ets/EnterpriseAdminAbility/EnterpriseAdminAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..07426f68d4a25f3d67e3eb27d54931244e8eef57 --- /dev/null +++ b/customization/edm_xts_stage/entry/src/main/ets/EnterpriseAdminAbility/EnterpriseAdminAbility.ts @@ -0,0 +1,26 @@ +/* + * 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 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 diff --git a/customization/edm_xts_stage/entry/src/main/ets/MainAbility/MainAbility.ts b/customization/edm_xts_stage/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed9de5ac32a0385ec7e83d2b09d806008314a5bb --- /dev/null +++ b/customization/edm_xts_stage/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,38 @@ +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 diff --git a/customization/edm_xts_stage/entry/src/main/ets/pages/index/index.ets b/customization/edm_xts_stage/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..fa051e9c8ed4d506508c49c315e4770c48d45911 --- /dev/null +++ b/customization/edm_xts_stage/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,67 @@ +/* + * 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 diff --git a/customization/edm_xts_stage/entry/src/main/ets/pages/second/second.ets b/customization/edm_xts_stage/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..1c1c727ff11ecc97909f482c35268db87ae23bb4 --- /dev/null +++ b/customization/edm_xts_stage/entry/src/main/ets/pages/second/second.ets @@ -0,0 +1,43 @@ +/* + * 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 diff --git a/customization/enterprise_device_management/src/main/js/default/app.js b/customization/edm_xts_stage/entry/src/main/ets/test/List.test.ets similarity index 70% rename from customization/enterprise_device_management/src/main/js/default/app.js rename to customization/edm_xts_stage/entry/src/main/ets/test/List.test.ets index c1a2274b034140503e7ef5347935c10c69a96d59..d5a2534102f373727e8f85a495bbecec2c2900db 100644 --- a/customization/enterprise_device_management/src/main/js/default/app.js +++ b/customization/edm_xts_stage/entry/src/main/ets/test/List.test.ets @@ -1,5 +1,5 @@ /* - * 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 diff --git a/customization/edm_xts_stage/entry/src/main/ets/test/commom.ets b/customization/edm_xts_stage/entry/src/main/ets/test/commom.ets new file mode 100644 index 0000000000000000000000000000000000000000..097589f6ae724e609fc39bc163a66412d1ad9f8c --- /dev/null +++ b/customization/edm_xts_stage/entry/src/main/ets/test/commom.ets @@ -0,0 +1,45 @@ +/* + * 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. + */ + +const WANT1 = { + bundleName: "com.example.extensionzerotest", + abilityName: "com.example.extensionzerotest.EnterpriseAdminAbility" +}; +const ENTINFO1 = { + name: "company", + description: "edm demo" +}; + +const SELFWANT = { + bundleName: "com.example.myapplication", + abilityName: "com.example.myapplication.EnterpriseAdminAbility" +}; +const SELFHAPNAME = "com.example.myapplication" +const COMPANYNAME2 = "company2" +const DESCRIPTION2 = "edm demo2" + +const ENTINFO2 = { + name: "company2", + description: "edm demo2" +}; + +const DEFAULT_USER_ID = 100; +const TEST_USER_ID = 101; +const ERR_USER_ID = 102; + +export { + WANT1, ENTINFO1, SELFWANT, SELFHAPNAME, COMPANYNAME2, DESCRIPTION2, ENTINFO2, + DEFAULT_USER_ID, TEST_USER_ID, ERR_USER_ID +} \ No newline at end of file diff --git a/customization/edm_xts_stage/entry/src/main/ets/test/edmCallback.test.ets b/customization/edm_xts_stage/entry/src/main/ets/test/edmCallback.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..40023fba0b781654e1036b8fbb33b4b48c4f1128 --- /dev/null +++ b/customization/edm_xts_stage/entry/src/main/ets/test/edmCallback.test.ets @@ -0,0 +1,294 @@ +/* + * 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(); + }) + }) +} diff --git a/customization/edm_xts_stage/entry/src/main/ets/test/edmPromise.test.ets b/customization/edm_xts_stage/entry/src/main/ets/test/edmPromise.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3bcaab316b7ba020e7e42235ff14286404f2f6dc --- /dev/null +++ b/customization/edm_xts_stage/entry/src/main/ets/test/edmPromise.test.ets @@ -0,0 +1,334 @@ +/* + * 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 edmPromiseTest() { + describe('edmPromise_test', function () { + /** + * @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0001 + * @tc.name test enableAdmin method in promise mode without user id + * @tc.desc enable admin in promise mode + */ + it('enableAdmin_test_001', 0, async function (done) { + var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL : ' + retValue); + expect(retValue).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_0003 + * @tc.name test enableAdmin method in promise mode with ADMIN_TYPE_SUPER param without user id + * @tc.desc enable super admin in promise mode + */ + it('enableAdmin_test_003', 0, async function (done) { + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER'); + var retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER : ' + retValue); + expect(retValue).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_0005 + * @tc.name test enableAdmin method in promise mode without user id + * @tc.desc enable admin in promise mode + */ + it('enableAdmin_test_005', 0, async function (done) { + var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL : ' + retValue); + expect(retValue).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_0007 + * @tc.name test enableAdmin method in promise mode with default user id + * @tc.desc enable admin in multi-user + */ + it('enableAdmin_test_007', 0, async function (done) { + var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL : ' + retValue); + expect(retValue).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_0009 + * @tc.name test enableAdmin method with user id in callback mode with error user id + * @tc.desc enable admin in multi-user + */ + it('enableAdmin_test_009', 0, async function (done) { + var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER, TEST_USER_ID, OnReceiveEvent); + async function OnReceiveEvent(err, datainfo) { + expect(err != null).assertTrue(); + if (err) { + // user exsit but super admin can only be enabled in user 100 + console.log("enableAdmin_test_009 throw error code : " + err.code + "message :" + err.message); + } + done(); + } + }) + + /** + * @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0010 + * @tc.name test enableAdmin method with user id in callback mode with error user id + * @tc.desc enable admin in multi-user + */ + it('enableAdmin_test_010', 0, async function (done) { + var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER, ERR_USER_ID, OnReceiveEvent); + async function OnReceiveEvent(err, datainfo) { + expect(err != null).assertTrue(); + if (err) { + // user does not exsit + console.log("enableAdmin_test_010 throw error code : " + err.code + "message :" + err.message); + } + done(); + } + }) + + /** + * @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0011 + * @tc.name test enableAdmin method in promise mode with test user id + * @tc.desc enable admin in multi-user + */ + it('enableAdmin_test_011', 0, async function (done) { + var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, TEST_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL : ' + retValue); + expect(retValue).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_0015 + * @tc.name test enableAdmin method in promise mode and disable with test user id + * @tc.desc enable admin in multi-user + */ + it('enableAdmin_test_015', 0, async function (done) { + var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); + 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, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled); + expect(isEnabled).assertTrue(); + + isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_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(); + + 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_0022 + * @tc.name test enable super admin method in promise mode and enable twice with test user id + * @tc.desc enable and disable admin in multi-user + */ + it('enableAdmin_test_0016', 0, async function (done) { + var retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER : ' + retValue); + expect(retValue).assertTrue(); + + var isEnabled = await enterpriseDeviceManager.isSuperAdmin(SELFHAPNAME); + console.log('enterpriseDeviceManager.isSuperAdmin :' + isEnabled); + expect(isEnabled).assertTrue(); + + try { + retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, TEST_USER_ID); + } catch (error) { + expect(error != null).assertTrue(); + console.log("enableAdmin_test_016 throw error code : " + error.code + "message :" + error.message); + } + + isEnabled = await enterpriseDeviceManager.isAdminEnabled(SELFWANT, TEST_USER_ID); + console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); + expect(isEnabled).assertFalse(); + + 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_0016 + * @tc.name test setEnterpriseInfo method in promise mode + * @tc.desc set enterprise info in promise mode + */ + it('setEnterpriseInfo_test_001', 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); + console.log('enterpriseDeviceManager.setEnterpriseInfo : ' + retValue); + expect(retValue).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_0019 + * @tc.name test getDeviceSettingsManager method in promise mode + * @tc.desc get the device settings manager in promise mode + */ + it('getDeviceSettingsManager_test_002', 0, async function (done) { + enterpriseDeviceManager.getDeviceSettingsManager().then(mgr => { + expect(mgr !== null).assertTrue(); + }) + console.log('getDeviceSettingsManager_test_002 done'); + done(); + }) + + /** + * @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0020 + * @tc.name test setDateTime method in promise mode + * @tc.desc set system date time in promise mode + */ + it('setDateTime_test_001', 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'); + var setSuccess = await dsmgr.setDateTime(SELFWANT, 1526003846000); + expect(setSuccess).assertTrue(); + await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); + done(); + }) + }) +} diff --git a/customization/edm_xts_stage/entry/src/main/module.json b/customization/edm_xts_stage/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..89065014cda28813e9e6ad7e0530d8aecde25bf7 --- /dev/null +++ b/customization/edm_xts_stage/entry/src/main/module.json @@ -0,0 +1,70 @@ +{ + "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 diff --git a/customization/edm_xts_stage/entry/src/main/resources/base/element/string.json b/customization/edm_xts_stage/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/customization/edm_xts_stage/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "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" + } + ] +} diff --git a/customization/edm_xts_stage/entry/src/main/resources/base/media/icon.png b/customization/edm_xts_stage/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/customization/edm_xts_stage/entry/src/main/resources/base/media/icon.png differ diff --git a/customization/edm_xts_stage/entry/src/main/resources/base/profile/main_pages.json b/customization/edm_xts_stage/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/customization/edm_xts_stage/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/customization/edm_xts_stage/signature/openharmony_sx.p7b b/customization/edm_xts_stage/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..7ffcdc78527c5c1aa24520ab7e913c5f47c703f0 Binary files /dev/null and b/customization/edm_xts_stage/signature/openharmony_sx.p7b differ diff --git a/customization/enterprise_device_management/Test.json b/customization/enterprise_device_management/Test.json deleted file mode 100644 index d3a2d5eb2cb2ee7c18e7f5f52ca6d1b538d0de2a..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/Test.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "description": "Configuration for enterprise device management Tests", - "driver": { - "type": "JSUnitTest", - "test-timeout": "300000", - "package": "ohos.edm.test", - "shell-timeout": "60000" - }, - "kits": [ - { - "type": "ShellKit", - "run-command": [ - "acm create -n edmuser -t normal" - ], - "teardown-command": [ - "acm delete -i 101" - ] - }, - { - "test-file-name": [ - "ActsEdmJsTest.hap", - "edmJstest1.hap" - ], - "type": "AppInstallKit", - "cleanup-apps": true - } - ] -} diff --git a/customization/enterprise_device_management/edmsceneone/BUILD.gn b/customization/enterprise_device_management/edmsceneone/BUILD.gn deleted file mode 100644 index 285ca9c48e90647bc5874e0eb8066470b6b0b8bb..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/edmsceneone/BUILD.gn +++ /dev/null @@ -1,34 +0,0 @@ -# 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("//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 - deps = [ - ":hjs_demo_js_assets", - ":hjs_demo_resources", - ] - certificate_profile = "./signature/openharmony_sx.p7b" -} -ohos_js_assets("hjs_demo_js_assets") { - source_dir = "./src/main/js/default" -} -ohos_resources("hjs_demo_resources") { - sources = [ "./src/main/js/resources" ] - hap_profile = "./src/main/config.json" -} diff --git a/customization/enterprise_device_management/edmsceneone/signature/openharmony_sx.p7b b/customization/enterprise_device_management/edmsceneone/signature/openharmony_sx.p7b deleted file mode 100644 index 9be1e98fa4c0c28ca997ed660112fa16b194f0f5..0000000000000000000000000000000000000000 Binary files a/customization/enterprise_device_management/edmsceneone/signature/openharmony_sx.p7b and /dev/null differ diff --git a/customization/enterprise_device_management/edmsceneone/src/main/config.json b/customization/enterprise_device_management/edmsceneone/src/main/config.json deleted file mode 100644 index c1c32d47cc53efd2668e3f263a97b420a384e3a3..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/edmsceneone/src/main/config.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "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 diff --git a/customization/enterprise_device_management/edmsceneone/src/main/js/default/i18n/en-US.json b/customization/enterprise_device_management/edmsceneone/src/main/js/default/i18n/en-US.json deleted file mode 100644 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/edmsceneone/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/customization/enterprise_device_management/edmsceneone/src/main/js/default/i18n/zh-CN.json b/customization/enterprise_device_management/edmsceneone/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/edmsceneone/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/customization/enterprise_device_management/edmsceneone/src/main/js/default/pages/index/index.css b/customization/enterprise_device_management/edmsceneone/src/main/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/edmsceneone/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/customization/enterprise_device_management/edmsceneone/src/main/js/default/pages/index/index.hml b/customization/enterprise_device_management/edmsceneone/src/main/js/default/pages/index/index.hml deleted file mode 100644 index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/edmsceneone/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{ $t('strings.hello') }} {{ title }} - -
diff --git a/customization/enterprise_device_management/edmsceneone/src/main/js/resources/base/element/string.json b/customization/enterprise_device_management/edmsceneone/src/main/js/resources/base/element/string.json deleted file mode 100644 index 21f88982736302157aad1cc00a3735adf299eccb..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/edmsceneone/src/main/js/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "bmssceneone" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file diff --git a/customization/enterprise_device_management/src/main/config.json b/customization/enterprise_device_management/src/main/config.json deleted file mode 100644 index 0aad02f50a05ab9ef2fc1e10b19b28d9d1e42a6a..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/src/main/config.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "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 - } - } - ] - } -} diff --git a/customization/enterprise_device_management/src/main/js/default/i18n/en-US.json b/customization/enterprise_device_management/src/main/js/default/i18n/en-US.json deleted file mode 100644 index e63c70d978a3a53be988388c87182f81785e170c..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "Hello", - "world": "World" - } -} \ No newline at end of file diff --git a/customization/enterprise_device_management/src/main/js/default/i18n/zh-CN.json b/customization/enterprise_device_management/src/main/js/default/i18n/zh-CN.json deleted file mode 100644 index de6ee5748322f44942c1b003319d8e66c837675f..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/src/main/js/default/i18n/zh-CN.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "strings": { - "hello": "您好", - "world": "世界" - } -} \ No newline at end of file diff --git a/customization/enterprise_device_management/src/main/js/default/pages/index/index.css b/customization/enterprise_device_management/src/main/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/src/main/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/customization/enterprise_device_management/src/main/js/default/pages/index/index.hml b/customization/enterprise_device_management/src/main/js/default/pages/index/index.hml deleted file mode 100644 index 1c26cf73deab18390844a53a103458b10ed11e93..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/src/main/js/default/pages/index/index.hml +++ /dev/null @@ -1,5 +0,0 @@ -
- - {{ $t('strings.hello') }} {{title}} - -
diff --git a/customization/enterprise_device_management/src/main/js/default/pages/index/index.js b/customization/enterprise_device_management/src/main/js/default/pages/index/index.js deleted file mode 100644 index fc9eda0c61a0529da9627bc4bb29fd34f6ce81a7..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/src/main/js/default/pages/index/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 {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() { - }, -} diff --git a/customization/enterprise_device_management/src/main/js/default/test/EnterpriseDeviceManager.test.js b/customization/enterprise_device_management/src/main/js/default/test/EnterpriseDeviceManager.test.js deleted file mode 100644 index e729d06bea6a5b3a54876da32aa3eb99052645f4..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/src/main/js/default/test/EnterpriseDeviceManager.test.js +++ /dev/null @@ -1,636 +0,0 @@ -/* - * 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 'deccjsunit/index' -import bundle from '@ohos.bundle' -import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager' - -const WANT1 = { - bundleName: "com.example.myapplication1", - abilityName: "com.example.myapplication1.MainAbility" -}; - -const SELFWANT = { - bundleName: "ohos.edm.test", - abilityName: "ohos.edm.test.MainAbility" -}; -const SELFHAPNAME = "ohos.edm.test" -const COMPANYNAME2 = "company2" -const DESCRIPTION2 = "edm demo2" -const ENTINFO1 = { - name: "company", - description: "edm demo" -}; - -const ENTINFO2 = { - name: "company2", - description: "edm demo2" -}; - -const DEFAULT_USER_ID = 100; -const TEST_USER_ID = 101; -const ERR_USER_ID = 102; - -describe('EnterpriseDeviceManagerTest', function () { - console.log('*************start EnterpriseDeviceManagerTest*************'); - - /** - * @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0001 - * @tc.name test enableAdmin method in promise mode without user id - * @tc.desc enable admin in promise mode - */ - it('enableAdmin_test_001', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, - enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL); - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL : ' + retValue); - expect(retValue).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_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_0003 - * @tc.name test enableAdmin method in promise mode with ADMIN_TYPE_SUPER param without user id - * @tc.desc enable super admin in promise mode - */ - it('enableAdmin_test_003', 0, async function (done) { - await bundle.getBundleInfo(SELFHAPNAME, - bundle.BundleFlag.GET_BUNDLE_WITH_REQUESTED_PERMISSION).then(datainfo => { - console.info("getBundleInfo success:" + JSON.stringify(datainfo)); - }); - - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER'); - var retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, - enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER); - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER : ' + retValue); - expect(retValue).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_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_0005 - * @tc.name test enableAdmin method in promise mode without user id - * @tc.desc enable admin in promise mode - */ - it('enableAdmin_test_005', 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); - console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); - expect(isEnabled).assertTrue(); - - 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_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(SELFWANT, 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(SELFWANT); - console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled); - expect(isEnabled).assertTrue(); - - 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_0007 - * @tc.name test enableAdmin method in promise mode with default user id - * @tc.desc enable admin in multi-user - */ - it('enableAdmin_test_007', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, - enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL : ' + retValue); - expect(retValue).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_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_0009 - * @tc.name test enableAdmin method with user id in callback mode with error user id - * @tc.desc enable admin in multi-user - */ - it('enableAdmin_test_009', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, - enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER, TEST_USER_ID, OnReceiveEvent); - async function OnReceiveEvent(err, datainfo) { - expect(err != null).assertTrue(); - if (err) { - // user exsit but super admin can only be enabled in user 100 - console.log("enableAdmin_test_009 throw error code : " + err.code + "message :" + err.message); - } - done(); - } - }) - - /** - * @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0010 - * @tc.name test enableAdmin method with user id in callback mode with error user id - * @tc.desc enable admin in multi-user - */ - it('enableAdmin_test_010', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, - enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER, ERR_USER_ID, OnReceiveEvent); - async function OnReceiveEvent(err, datainfo) { - expect(err != null).assertTrue(); - if (err) { - // user does not exsit - console.log("enableAdmin_test_010 throw error code : " + err.code + "message :" + err.message); - } - done(); - } - }) - - /** - * @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0011 - * @tc.name test enableAdmin method in promise mode with test user id - * @tc.desc enable admin in multi-user - */ - it('enableAdmin_test_011', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, - enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, TEST_USER_ID); - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL : ' + retValue); - expect(retValue).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_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_0015 - * @tc.name test enableAdmin method in promise mode and disable with test user id - * @tc.desc enable admin in multi-user - */ - it('enableAdmin_test_015', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, - enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); - 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, DEFAULT_USER_ID); - console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled); - expect(isEnabled).assertTrue(); - - isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_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(); - - 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_0022 - * @tc.name test enable super admin method in callback mode and enable twice with test user id - * @tc.desc enable and disable admin in multi-user - */ - it('enableAdmin_test_0016', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, - enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER); - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER : ' + retValue); - expect(retValue).assertTrue(); - - var isEnabled = await enterpriseDeviceManager.isSuperAdmin(SELFHAPNAME); - console.log('enterpriseDeviceManager.isSuperAdmin :' + isEnabled); - expect(isEnabled).assertTrue(); - - try { - retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, - enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, TEST_USER_ID); - } catch (error) { - expect(error != null).assertTrue(); - console.log("enableAdmin_test_016 throw error code : " + error.code + "message :" + error.message); - } - - isEnabled = await enterpriseDeviceManager.isAdminEnabled(SELFWANT, TEST_USER_ID); - console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); - expect(isEnabled).assertFalse(); - - 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_0016 - * @tc.name test setEnterpriseInfo method in promise mode - * @tc.desc set enterprise info in promise mode - */ - it('setEnterpriseInfo_test_001', 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); - console.log('enterpriseDeviceManager.setEnterpriseInfo : ' + retValue); - expect(retValue).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_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_0019 - * @tc.name test getDeviceSettingsManager method in promise mode - * @tc.desc get the device settings manager in promise mode - */ - it('getDeviceSettingsManager_test_002', 0, async function (done) { - enterpriseDeviceManager.getDeviceSettingsManager().then(mgr => { - expect(mgr !== null).assertTrue(); - }) - console.log('getDeviceSettingsManager_test_002 done'); - done(); - }) - - /** - * @tc.number SUB_CUSTOMIZATION_ENTERPRISE_DEVICE_MANAGER_JS_0020 - * @tc.name test setDateTime method in promise mode - * @tc.desc set system date time in promise mode - */ - it('setDateTime_test_001', 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'); - var setSuccess = await dsmgr.setDateTime(SELFWANT, 1526003846000); - expect(setSuccess).assertTrue(); - await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); - 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(); - }) - - console.log('*************end EnterpriseDeviceManagerTest*************'); -}) \ No newline at end of file diff --git a/customization/enterprise_device_management/src/main/js/default/test/List.test.js b/customization/enterprise_device_management/src/main/js/default/test/List.test.js deleted file mode 100644 index e6206c4fbdd44c3d0580457372120b98ce1edade..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/src/main/js/default/test/List.test.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - * 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. - */ -require('./EnterpriseDeviceManager.test.js') diff --git a/customization/enterprise_device_management/src/main/resources/base/element/plural.json b/customization/enterprise_device_management/src/main/resources/base/element/plural.json deleted file mode 100644 index 5df662491e2cba0cc4ca28cb1547351bea8a78f3..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/src/main/resources/base/element/plural.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "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 diff --git a/customization/enterprise_device_management/src/main/resources/base/element/strarray.json b/customization/enterprise_device_management/src/main/resources/base/element/strarray.json deleted file mode 100644 index 643b3ced65e64d0a4555e9b3c091f5809526da9b..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/src/main/resources/base/element/strarray.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "strarray": [ - { - "name": "sizeList", - "value":[ - { - "value":"small" - }, - { - "value":"middle" - }, - { - "value":"large" - }, - { - "value":"extra large" - } - ] - } - ] -} \ No newline at end of file diff --git a/customization/enterprise_device_management/src/main/resources/base/element/string.json b/customization/enterprise_device_management/src/main/resources/base/element/string.json deleted file mode 100644 index 26ee728d01904a59b0af7ca29262f6d921eadfb4..0000000000000000000000000000000000000000 --- a/customization/enterprise_device_management/src/main/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "L2Test" - }, - { - "name": "mainability_description", - "value": "JS_Phone_Empty Feature Ability" - } - ] -} \ No newline at end of file