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

!5000 XTS元能力FA-JS测试框架适配

Merge pull request !5000 from chengxingzhen/master
......@@ -12,9 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file'
import app from '@system.app'
import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index'
export default {
data: {
......@@ -25,19 +22,6 @@ export default {
},
onShow() {
console.info('====onShow finish====<')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
const reportExtend = new ReportExtend(file)
core.addService('expect', expectExtend)
core.addService('report', reportExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
},
......
......@@ -21,14 +21,15 @@ ohos_js_hap_suite("ActsFeatureAbilityTest") {
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsFeatureAbilityTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
js2abc = true
hap_profile = "./entry/src/main/config.json"
source_dir = "./entry/src/main/js"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"type": "OHJSUnitTest",
"test-timeout": "300000",
"package": "com.example.actsfeatureabilitytest",
"shell-timeout": "600000"
"bundle-name": "com.example.actsfeatureabilitytest",
"package-name": "com.example.actsfeatureabilitytest",
"shell-timeout": "600000",
"testcase-timeout":"30000"
},
"kits": [
{
......
......@@ -14,7 +14,7 @@
},
"deviceConfig": {
"default": {
"process": "processTest"
"process": "processTestAbility"
}
},
"module": {
......@@ -47,6 +47,8 @@
"dataTransfer"
],
"name": "com.example.actsfeatureabilitytest.MainAbility",
"srcPath": "MainAbility",
"srcLanguage": "js",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
......@@ -57,6 +59,23 @@
"deviceCapability": ["SystemCapability.Ability.AbilityBase"],
"uri": "uriTest",
"visible": true
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "singleton",
"permissions": ["ohos.permission.ACCELEROMETER"],
"deviceCapability": ["SystemCapability.Ability.AbilityBase"],
"uri": "uriTest",
"process": "processTestAbility"
}
],
"reqCapabilities": ["reqCapabilitiesTest1","reqCapabilitiesTest2"],
......@@ -114,7 +133,21 @@
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
}
}
}
\ No newline at end of file
......@@ -13,12 +13,6 @@
* limitations under the License.
*/
import {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
let once = true
export default {
data: {
title: ''
......@@ -27,23 +21,7 @@ export default {
this.title = this.$t('strings.world');
},
onActive() {
if (!once) {
return;
}
once = false;
console.info('onShow finish');
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
id: 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = 10000;
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
console.info('onReady');
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('abilityDelegator' + abilityDelegator)
console.info('abilityDelegator' + abilityDelegator)
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
.btn {
width: 50%;
height: 100px;
font-size: 40px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<!--
Copyright (c) 2021 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div class="container" onswipe="touchMove">
<text class="title">
{{ $t('strings.hello') }} {{title}}
</text>
<input class="btn" type="button" value="{{ $t('strings.next') }}" onclick="onclick"></input>
</div>
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
......@@ -14,7 +14,7 @@
*/
import featureAbility from '@ohos.ability.featureAbility'
import wantconstant from '@ohos.ability.wantConstant'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import commonEvent from '@ohos.commonEvent'
import particleAbility from '@ohos.ability.particleAbility'
import backgroundTaskManager from '@ohos.backgroundTaskManager'
......@@ -57,7 +57,7 @@ let subscriberInfoActsGetCallingBundle0100 = {
function sleep(time) {
return new Promise((resolve)=>setTimeout(resolve,time));
}
export default function actsFeatureAbilityTest() {
describe('ActsFeatureAbilityTest', function () {
beforeAll(function() {
......@@ -847,7 +847,7 @@ describe('ActsFeatureAbilityTest', function () {
// expect(info.labelId).assertEqual(0); //create by DevEco when building HAP.
expect(info.icon).assertEqual("$media:icon");
// expect(info.iconId).assertEqual(0); //create by DevEco when building HAP.
expect(info.process).assertEqual("processTest");
expect(info.process).assertEqual("processTestAbility");
expect(info.supportedModes).assertEqual(0);
expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/" +
"com.example.actsfeatureabilitytest/com.example.actsfeatureabilitytest");
......@@ -964,7 +964,7 @@ describe('ActsFeatureAbilityTest', function () {
expect(info.deviceId).assertEqual("");
expect(info.bundleName).assertEqual("com.example.actsfeatureabilitytest");
expect(info.abilityName).assertEqual("com.example.actsfeatureabilitytest.MainAbility");
expect(info.abilityName).assertEqual("com.example.actsfeatureabilitytest.TestAbility");
expect(info.uri).assertEqual("");
expect(info.shortName).assertEqual("");
console.info("getElementName : end");
......@@ -1094,15 +1094,15 @@ describe('ActsFeatureAbilityTest', function () {
expect(data.bundleName).assertEqual("com.example.actsfeatureabilitytest");
expect(data.name).assertEqual("com.example.actsfeatureabilitytest.MainAbility");
expect(data.label).assertEqual("$string:app_name");
expect(data.description).assertEqual("$string:mainability_description");
expect(data.name).assertEqual("com.example.actsfeatureabilitytest.TestAbility");
expect(data.label).assertEqual("$string:TestAbility_label");
expect(data.description).assertEqual("$string:TestAbility_desc");
expect(data.icon).assertEqual("$media:icon");
expect(data.moduleName).assertEqual("entry");
expect(data.process).assertEqual("processTestAbility");
expect(data.targetAbility).assertEqual("");
expect(data.backgroundModes).assertEqual(1);
expect(data.backgroundModes).assertEqual(0);
expect(data.isVisible).assertEqual(true);
expect(data.formEnabled).assertEqual(false);
expect(data.type).assertEqual(1);
......@@ -1188,8 +1188,8 @@ describe('ActsFeatureAbilityTest', function () {
expect(data.descriptionId).assertEqual(0);
expect(data.icon).assertEqual("$media:icon");
expect(data.label).assertEqual("$string:app_name");
expect(data.labelId).assertEqual(16777216);
expect(data.iconId).assertEqual(16777219);
expect(data.labelId).assertEqual(16777218);
expect(data.iconId).assertEqual(16777221);
expect(data.backgroundImg).assertEqual("");
expect(data.supportedModes).assertEqual(0);
expect(data.reqCapabilities[0]).assertEqual("reqCapabilitiesTest1");
......@@ -1731,3 +1731,4 @@ describe('ActsFeatureAbilityTest', function () {
}
});
})
}
\ No newline at end of file
......@@ -12,5 +12,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./FeatureAbilityJsunit.test.js')
require('./StartAbilityJsunit.test.js')
\ No newline at end of file
import actsFeatureAbilityTest from './FeatureAbilityJsunit.test.js'
import startAbilityTest from './StartAbilityJsunit.test.js'
export default function testsuite() {
actsFeatureAbilityTest()
startAbilityTest()
}
\ No newline at end of file
......@@ -13,15 +13,15 @@
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
let resultCode = 123;
let bundleName = 'ohso.act.aafwk';
let mainAbilityName = 'ohos.acts.aafwk.jsap';
const errCode = 1;
const errCode1 = 202;
describe('ConnectAbilityTest', function () {
export default function startAbilityTest() {
describe('StartAbilityTest', function () {
/*
* @tc.number: SUB_AA_JsApi_StartAbility_0100
......@@ -449,3 +449,4 @@ describe('ConnectAbilityTest', function () {
})
})
})
}
......@@ -11,6 +11,14 @@
{
"name": "permreason_camera",
"value": "permreason camera"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
......@@ -12,20 +12,19 @@
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("FinishWithResultEmptyTest") {
ohos_hap("FinishWithResultEmptyTest") {
hap_profile = "./src/main/config.json"
js_build_mode = "debug"
hap_name = "FinishWithResultEmptyTest"
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"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
......
......@@ -12,20 +12,19 @@
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("FinishWithResultPromiseParametersTest") {
ohos_hap("FinishWithResultPromiseParametersTest") {
hap_profile = "./src/main/config.json"
js_build_mode = "debug"
hap_name = "FinishWithResultPromiseParametersTest"
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"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
......
......@@ -12,20 +12,19 @@
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("FinishWithResultTest") {
ohos_hap("FinishWithResultTest") {
hap_profile = "./src/main/config.json"
js_build_mode = "debug"
hap_name = "FinishWithResultTest"
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"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
......
......@@ -12,20 +12,19 @@
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("GetCallingBundlePromiseTest") {
ohos_hap("GetCallingBundlePromiseTest") {
hap_profile = "./src/main/config.json"
js_build_mode = "debug"
hap_name = "GetCallingBundlePromiseTest"
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"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
......
......@@ -12,20 +12,19 @@
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("StartAbility") {
ohos_hap("StartAbility") {
hap_profile = "./src/main/config.json"
js_build_mode = "debug"
hap_name = "StartAbility"
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"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
......
......@@ -12,20 +12,19 @@
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("StartAbilityForResult") {
ohos_hap("StartAbilityForResult") {
hap_profile = "./src/main/config.json"
js_build_mode = "debug"
hap_name = "StartAbilityForResult"
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"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
......
......@@ -12,20 +12,19 @@
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("TerminateAbilityTest") {
ohos_hap("TerminateAbilityTest") {
hap_profile = "./src/main/config.json"
js_build_mode = "debug"
hap_name = "TerminateAbilityTest"
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"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册