提交 76c8bf81 编写于 作者: C chengxingzhen

XTS用例上库

Signed-off-by: Nchengxingzhen <chengxingzhen@huawei.com>
上级 10213a13
......@@ -16,9 +16,9 @@ import("//test/xts/tools/build/suite.gni")
group("formmanager") {
testonly = true
if (is_standard_system) {
deps = [
deps = [
"fa:formmanager",
"stage:stage"
#"stage:stage",
]
}
}
......@@ -16,8 +16,6 @@ import("//test/xts/tools/build/suite.gni")
group("stage") {
testonly = true
if (is_standard_system) {
deps = [
"actsformprovidergetformsinfo:actsformprovidergetformsinfo",
]
deps = [ "actsformprovidergetformsinfo:actsformprovidergetformsinfo" ]
}
}
......@@ -19,7 +19,7 @@ group("actsformprovidergetformsinfo") {
deps = [
"entry:ActsFormProviderGetFormsInfoTest",
"module1:ActsFormProviderGetFormsInfoModule1",
"module2:ActsFormProviderGetFormsInfoModule2"
"module2:ActsFormProviderGetFormsInfoModule2",
]
}
}
......@@ -19,8 +19,12 @@ ohos_js_hap_suite("ActsFormProviderGetFormsInfoTest") {
":actsformprovidergetformsinfotest_js_assets",
":actsformprovidergetformsinfotest_resources",
]
ets2abc = true
certificate_profile = "../signature/openharmony_sx.p7b"
hap_name = "ActsFormProviderGetFormsInfoTest"
js_build_mode = "debug"
subsystem_name = "ability"
part_name = "form_fwk"
}
ohos_app_scope("actsformprovidergetformsinfotest_app_profile") {
......@@ -29,7 +33,6 @@ ohos_app_scope("actsformprovidergetformsinfotest_app_profile") {
}
ohos_js_assets("actsformprovidergetformsinfotest_js_assets") {
ets2abc = true
source_dir = "src/main/ets"
}
......
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.example.getformsinfotest",
"shell-timeout": "600000"
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.getformsinfotest",
"module-name": "entry",
"shell-timeout": "600000",
"testcase-timeout": 20000
},
"kits": [
{
......
......@@ -28,7 +28,7 @@ export default class MainAbility extends Ability {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index", null)
windowStage.setUIContent(this.context, "MainAbility/pages/index", null)
}
onWindowStageDestroy() {
......
......@@ -12,31 +12,24 @@
* 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"
import List from '../test/List.test'
import router from '@ohos.router';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../test/List.test'
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
@State message: string = 'Hello World entry'
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()
globalThis.abilityWant.parameters.timeout = 10000;
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
configService.setConfig(globalThis.abilityWant.parameters);
List()
core.execute()
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
......
/*
* 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 TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
}
onDestroy() {
console.log('TestAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
windowStage.loadContent("TestAbility/pages/index", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
});
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility onBackground')
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.example.getformsinfotest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
......@@ -12,7 +12,7 @@
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import formProvider from '@ohos.application.formProvider';
import formInfo from '@ohos.application.formInfo';
import formError from '@ohos.application.formError';
......@@ -183,7 +183,9 @@ export default function abilityTest() {
formProvider.getFormsInfo(filter, function(err, value) {
console.info("formProvider::GetFormsInfoTest err: " + JSON.stringify(err));
console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(value));
expect(err.code).assertEqual(formError.FormError.ERR_ADD_INVALID_PARAM);
expect(err.code).assertEqual(0);
expect(value.length).assertEqual(2);
checkResultArray(expectResult, value);
done();
});
});
......@@ -294,10 +296,11 @@ export default function abilityTest() {
moduleName: undefined
};
formProvider.getFormsInfo(filter).then((value) => {
expect().assertFail();
expect(value.length).assertEqual(2);
checkResultArray(expectResult, value);
}).catch((err) => {
console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err));
expect(err.code).assertEqual(formError.FormError.ERR_ADD_INVALID_PARAM);
expect().assertFail();
})
done();
});
......
......@@ -13,12 +13,9 @@
import("//test/xts/tools/build/suite.gni")
ohos_hap("ActsFormProviderGetFormsInfoModule1") {
ohos_hap_assist_suite("ActsFormProviderGetFormsInfoModule1") {
hap_name = "ActsFormProviderGetFormsInfoModule1"
hap_profile = "src/main/module.json"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":actsformprovidergetformsinfomodule1_js_assets",
......@@ -26,6 +23,9 @@ ohos_hap("ActsFormProviderGetFormsInfoModule1") {
]
ets2abc = true
certificate_profile = "../signature/openharmony_sx.p7b"
js_build_mode = "debug"
subsystem_name = "ability"
part_name = "form_fwk"
}
ohos_app_scope("actsformprovidergetformsinfomodule1_app_profile") {
......
......@@ -15,7 +15,7 @@
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
@State message: string = 'Hello World module1'
build() {
Row() {
......
......@@ -13,12 +13,9 @@
import("//test/xts/tools/build/suite.gni")
ohos_hap("ActsFormProviderGetFormsInfoModule2") {
ohos_hap_assist_suite("ActsFormProviderGetFormsInfoModule2") {
hap_name = "ActsFormProviderGetFormsInfoModule2"
hap_profile = "src/main/module.json"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":actsformprovidergetformsinfomodule2_js_assets",
......@@ -26,6 +23,9 @@ ohos_hap("ActsFormProviderGetFormsInfoModule2") {
]
ets2abc = true
certificate_profile = "../signature/openharmony_sx.p7b"
js_build_mode = "debug"
subsystem_name = "ability"
part_name = "form_fwk"
}
ohos_app_scope("actsformprovidergetformsinfomodule2_app_profile") {
......
......@@ -15,7 +15,7 @@
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
@State message: string = 'Hello World module2'
build() {
Row() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册