diff --git a/startup/startup_standard/BUILD.gn b/startup/startup_standard/BUILD.gn index 928cdcbb59b9875c9b94f3f53f1ebfba04b4f751..fbcac9e27c5c1bd643f13abf6b1c07a14eeac652 100644 --- a/startup/startup_standard/BUILD.gn +++ b/startup/startup_standard/BUILD.gn @@ -18,6 +18,7 @@ group("startup_standard") { if (is_standard_system) { deps = [ "deviceinfo:startup_deviceinfo_js_test", + "syscap_ndk:startup_syscapability_js_test", "systemparamter:startup_sysparam_js_test", ] } diff --git a/startup/startup_standard/syscap_ndk/BUILD.gn b/startup/startup_standard/syscap_ndk/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..5f9272174908e98641e3bcccfd36d52a1b5cd256 --- /dev/null +++ b/startup/startup_standard/syscap_ndk/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (C) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("startup_syscapability_js_test") { + hap_profile = "./src/main/config.json" + deps = [ + ":startup_js_assets", + ":startup_js_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsStartupSysCapabilityTest" +} +ohos_js_assets("startup_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("startup_js_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/startup/startup_standard/syscap_ndk/Test.json b/startup/startup_standard/syscap_ndk/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..55bc1127ea8f15922383fa2eaeb82e0a22625e91 --- /dev/null +++ b/startup/startup_standard/syscap_ndk/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for startup syscap js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "ohos.acts.startup.syscap.function", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsStartupSysCapabilityTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/startup/startup_standard/syscap_ndk/signature/openharmony_sx.p7b b/startup/startup_standard/syscap_ndk/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/startup/startup_standard/syscap_ndk/signature/openharmony_sx.p7b differ diff --git a/startup/startup_standard/syscap_ndk/src/main/config.json b/startup/startup_standard/syscap_ndk/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..988832820442e3f3857e7d5d1664587e56e7a587 --- /dev/null +++ b/startup/startup_standard/syscap_ndk/src/main/config.json @@ -0,0 +1,60 @@ +{ + "app": { + "bundleName": "ohos.acts.startup.syscap.function", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.acts.startup.syscap.function", + "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.acts.startup.syscap.function.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/startup/startup_standard/syscap_ndk/src/main/js/default/app.js b/startup/startup_standard/syscap_ndk/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..e423f4bce4698ec1d7dc86c3eea3990a5e7b1085 --- /dev/null +++ b/startup/startup_standard/syscap_ndk/src/main/js/default/app.js @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/startup/startup_standard/syscap_ndk/src/main/js/default/i18n/en-US.json b/startup/startup_standard/syscap_ndk/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..25b4997e50df3af032339fe395b293b95a44c275 --- /dev/null +++ b/startup/startup_standard/syscap_ndk/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "OpenHarmony" + } +} \ No newline at end of file diff --git a/startup/startup_standard/syscap_ndk/src/main/js/default/i18n/zh-CN.json b/startup/startup_standard/syscap_ndk/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..b9543e1912f72ea9075609981bf64496330cbb41 --- /dev/null +++ b/startup/startup_standard/syscap_ndk/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "鸿蒙OS" + } +} \ No newline at end of file diff --git a/startup/startup_standard/syscap_ndk/src/main/js/default/pages/index/index.css b/startup/startup_standard/syscap_ndk/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/startup/startup_standard/syscap_ndk/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/startup/startup_standard/syscap_ndk/src/main/js/default/pages/index/index.hml b/startup/startup_standard/syscap_ndk/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/startup/startup_standard/syscap_ndk/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/startup/startup_standard/syscap_ndk/src/main/js/default/pages/index/index.js b/startup/startup_standard/syscap_ndk/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..0c564bb030d56eb17a14063cee23df41abced5ba --- /dev/null +++ b/startup/startup_standard/syscap_ndk/src/main/js/default/pages/index/index.js @@ -0,0 +1,45 @@ +/* + * 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 {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/startup/startup_standard/syscap_ndk/src/main/js/default/test/List.test.js b/startup/startup_standard/syscap_ndk/src/main/js/default/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..bd46e06aab5a3923d5d9830153fa6725ea9ebbf2 --- /dev/null +++ b/startup/startup_standard/syscap_ndk/src/main/js/default/test/List.test.js @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +require('./SystemCapability.test.js') + + + diff --git a/startup/startup_standard/syscap_ndk/src/main/js/default/test/SystemCapability.test.js b/startup/startup_standard/syscap_ndk/src/main/js/default/test/SystemCapability.test.js new file mode 100644 index 0000000000000000000000000000000000000000..146d8ad57f455c27bfa56c5ecb5ac7fa0d159ebc --- /dev/null +++ b/startup/startup_standard/syscap_ndk/src/main/js/default/test/SystemCapability.test.js @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// @ts-nocheck + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + +describe('SystemCapabilityTest', function () { + + console.info('SystemCapabilityTest start################################start'); + + /** + * @tc.number SUB_STARTUP_JS_SYSTEM_CAPABILITY_001 + * @tc.name testSysCaps01 + * @tc.desc Verify the availability of SystemCapability AccessToken. + */ + it('testSysCaps01', 0, async function (done) { + console.info('testSysCaps01 start'); + let ret = false; + try { + var isAccessToken = canIUse("SystemCapability.Security.AccessToken"); + console.info("testSysCaps01 test.syscap.param.001 : " + isAccessToken); + if (isAccessToken) { + ret = true; + } + expect(isAccessToken).assertTrue(); + done(); + } catch (e) { + expect(ret).assertTrue(); + console.info("testSysCaps01 canIUse isAccessToken error: " + e); + } + console.info('testSysCaps01 end'); + }) +}) \ No newline at end of file diff --git a/startup/startup_standard/syscap_ndk/src/main/resources/base/element/string.json b/startup/startup_standard/syscap_ndk/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a5239a2b383f65174036cf864f016078bbc4733d --- /dev/null +++ b/startup/startup_standard/syscap_ndk/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "StartupJSApiTest" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/startup/startup_standard/syscap_ndk/src/main/resources/base/media/icon.png b/startup/startup_standard/syscap_ndk/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/startup/startup_standard/syscap_ndk/src/main/resources/base/media/icon.png differ