提交 10213a13 编写于 作者: C chengxingzhen

XTS用例上库

Signed-off-by: Nchengxingzhen <chengxingzhen@huawei.com>
上级 35373c9f
......@@ -16,6 +16,9 @@ import("//test/xts/tools/build/suite.gni")
group("formmanager") {
testonly = true
if (is_standard_system) {
deps = [ "fa:formmanager" ]
deps = [
"fa:formmanager",
"stage:stage"
]
}
}
# 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")
group("stage") {
testonly = true
if (is_standard_system) {
deps = [
"actsformprovidergetformsinfo:actsformprovidergetformsinfo",
]
}
}
{
"app": {
"bundleName": "com.example.getformsinfotest",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
# 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")
group("actsformprovidergetformsinfo") {
testonly = true
if (is_standard_system) {
deps = [
"entry:ActsFormProviderGetFormsInfoTest",
"module1:ActsFormProviderGetFormsInfoModule1",
"module2:ActsFormProviderGetFormsInfoModule2"
]
}
}
# 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("ActsFormProviderGetFormsInfoTest") {
hap_profile = "src/main/module.json"
deps = [
":actsformprovidergetformsinfotest_js_assets",
":actsformprovidergetformsinfotest_resources",
]
certificate_profile = "../signature/openharmony_sx.p7b"
hap_name = "ActsFormProviderGetFormsInfoTest"
}
ohos_app_scope("actsformprovidergetformsinfotest_app_profile") {
app_profile = "../AppScope/app.json"
sources = [ "../AppScope/resources" ]
}
ohos_js_assets("actsformprovidergetformsinfotest_js_assets") {
ets2abc = true
source_dir = "src/main/ets"
}
ohos_resources("actsformprovidergetformsinfotest_resources") {
sources = [ "src/main/resources" ]
deps = [ ":actsformprovidergetformsinfotest_app_profile" ]
hap_profile = "src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.example.getformsinfotest",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsFormProviderGetFormsInfoTest.hap",
"ActsFormProviderGetFormsInfoModule1.hap",
"ActsFormProviderGetFormsInfoModule2.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/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")
}
};
/*
* 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"
import List from '../test/List.test'
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
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()
}
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'
import formProvider from '@ohos.application.formProvider';
import formInfo from '@ohos.application.formInfo';
import formError from '@ohos.application.formError';
let module1FormInfo: formInfo.FormInfo = {
bundleName: "com.example.getformsinfotest",
moduleName: "module1",
abilityName: "FormAbility",
name: "module1_widget",
description: "This is a service widget.",
type:1,
jsComponentName: "",
colorMode: -1,
isDefault: true,
updateEnabled: true,
formVisibleNotify: true,
relatedBundleName : "com.example.getformsinfotest",
scheduledUpdateTime: "10:30",
formConfigAbility: "ability://xxxxx",
updateDuration: 1,
defaultDimension:2,
supportDimensions:[2],
customizeData: {}
}
let module2FormInfo: formInfo.FormInfo = {
bundleName: "com.example.getformsinfotest",
moduleName: "module2",
abilityName: "FormAbility",
name: "module2_widget",
description: "This is a service widget.",
type:1,
jsComponentName: "",
colorMode: -1,
isDefault: true,
updateEnabled: true,
formVisibleNotify: true,
relatedBundleName : "com.example.getformsinfotest",
scheduledUpdateTime: "10:30",
formConfigAbility: "ability://xxxxx",
updateDuration: 1,
defaultDimension:2,
supportDimensions:[2],
customizeData: {}
}
var expectResult = Array();
expectResult.push(module1FormInfo);
expectResult.push(module2FormInfo);
export default function abilityTest() {
describe('ProviderGetFormsInfoTest', function () {
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0100
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0100
* @tc.desc: #1: getFormsInfo(callback)
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0100', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0100");
formProvider.getFormsInfo((err, value) => {
console.info("formProvider::GetFormsInfoTest err: " + JSON.stringify(err));
console.info("formProvider::GetFormsInfoTest value: " + JSON.stringify(value));
expect(err.code).assertEqual(0);
expect(value.length).assertEqual(2);
checkResultArray(expectResult, value)
done();
});
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0200
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0200
* @tc.desc: #2 getFormsInfo(filter, undefined) # Have no idea how to test it.
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0200', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0200");
const filter : formInfo.FormInfoFilter = {
moduleName : "module1"
};
try {
formProvider.getFormsInfo(filter, undefined);
} catch(err) {
expect().assertFail();
}
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0300
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0300
* @tc.desc: #3 getFormsInfo()
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0300', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0300");
formProvider.getFormsInfo().then((value) => {
expect(value.length).assertEqual(2);
checkResultArray(expectResult, value);
}).catch((err) => {
console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err));
expect().assertFail();
})
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0400
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0400
* @tc.desc: #4 getFormsInfo(undefined, callback)
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0400', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0400");
formProvider.getFormsInfo(undefined, 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);
done();
});
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0500
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0500
* @tc.desc: #5 getFormsInfo(filter, callback) where filter = {}
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0500', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_getFormsInfo_0105");
const filter : formInfo.FormInfoFilter = {};
formProvider.getFormsInfo(filter, function(err, value) {
console.info("formProvider::GetFormsInfoTest: " + JSON.stringify(err));
console.info("formProvider::GetFormsInfoTest: " + JSON.stringify(value));
expect(err.code).assertEqual(0);
expect(value.length).assertEqual(2);
checkResultArray(expectResult, value);
done();
});
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0600
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0600
* @tc.desc: #6 getFormsInfo(filter, callback) where moduleName = ""
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0600', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0600");
const filter : formInfo.FormInfoFilter = {
moduleName: ""
};
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(0);
expect(value.length).assertEqual(2);
checkResultArray(expectResult, value);
done();
});
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0700
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0700
* @tc.desc: #7 getFormsInfo(filter, callback) where moduleName = undefined
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0700', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0700");
const filter : formInfo.FormInfoFilter = {
moduleName: undefined
};
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);
done();
});
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0800
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0800
* @tc.desc: #8 getFormsInfo(filter, callback) where moduleName = "HelloWorld" which doesn't exist
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0800', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0800");
const filter : formInfo.FormInfoFilter = {
moduleName: "HelloWorld"
};
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(0);
expect(value.length).assertEqual(0);
done();
});
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_0900
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_0900
* @tc.desc: #9 getFormsInfo(filter, callback) where moduleName = "module1" which does exist
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_0900', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_0900");
const filter : formInfo.FormInfoFilter = {
moduleName: "module1"
};
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(0);
expect(value.length).assertEqual(1);
checkResult(module1FormInfo, value[0]);
done();
});
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_1000
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_1000
* @tc.desc: #10 getFormsInfo(filter, callback) where moduleName = "entry" exists but has no forms.
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_1000', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_1000");
const filter : formInfo.FormInfoFilter = {
moduleName: "entry"
};
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(0);
expect(value.length).assertEqual(0);
done();
});
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_1200
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_1200
* @tc.desc: #12 getFormsInfo(filter) where filter = {}
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_1200', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_1200");
const filter : formInfo.FormInfoFilter = {};
await formProvider.getFormsInfo(filter).then((value) => {
expect(value.length).assertEqual(2);
checkResultArray(expectResult, value);
}).catch((err) => {
console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err));
expect().assertFail();
})
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_1300
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_1300
* @tc.desc: #13 getFormsInfo(filter) where moduleName = ""
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_1300', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_1300");
const filter : formInfo.FormInfoFilter = {
moduleName: ""
};
await formProvider.getFormsInfo(filter).then((value) => {
expect(value.length).assertEqual(2);
checkResultArray(expectResult, value);
}).catch((err) => {
console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err));
expect().assertFail();
})
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_1400
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_1400
* @tc.desc: #14 getFormsInfo(filter) where moduleName = undefined
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_1400', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_1400");
const filter : formInfo.FormInfoFilter = {
moduleName: undefined
};
formProvider.getFormsInfo(filter).then((value) => {
expect().assertFail();
}).catch((err) => {
console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err));
expect(err.code).assertEqual(formError.FormError.ERR_ADD_INVALID_PARAM);
})
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_1500
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_1500
* @tc.desc: #15 getFormsInfo(filter) where moduleName = "HelloWorld" which doesn't exist
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_1500', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_1500");
const filter : formInfo.FormInfoFilter = {
moduleName: "HelloWorld"
};
await formProvider.getFormsInfo(filter).then((value) => {
expect(value.length).assertEqual(0);
}).catch((err) => {
console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err));
expect().assertFail();
})
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_1600
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_1600
* @tc.desc: #16 getFormsInfo(filter) where moduleName = "module1" which does exist
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_1600', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_1600");
const filter : formInfo.FormInfoFilter = {
moduleName: "module1"
};
await formProvider.getFormsInfo(filter).then((value) => {
expect(value.length).assertEqual(1);
checkResult(module1FormInfo, value[0])
}).catch((err) => {
console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err));
expect().assertFail();
})
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ProviderGetForsInfo_1700
* @tc.name: SUB_AA_OpenHarmony_ProviderGetForsInfo_1700
* @tc.desc: #17 getFormsInfo(filter) where moduleName = "entry" which exists but has no forms
*/
it('SUB_AA_OpenHarmony_ProviderGetForsInfo_1700', 0, async function (done) {
console.info("SUB_AA_OpenHarmony_ProviderGetForsInfo_1700");
const filter : formInfo.FormInfoFilter = {
moduleName: "entry"
};
formProvider.getFormsInfo(filter).then((value) => {
expect(value.length).assertEqual(0);
}).catch((err) => {
console.info('formProvider::GetFormsInfoTest failed' + JSON.stringify(err));
expect().assertFail();
})
done();
});
})
function checkResultArray(expectInfos: Array<formInfo.FormInfo>, result:Array<formInfo.FormInfo>) {
console.info("formProvider::GetForsInfoTest checkResultArray");
for (var index = 0; index < expectInfos.length; index++) {
console.info("formProvider::GetForsInfoTest checkResul index is " + index);
checkResult(expectInfos[index], result[index])
}
}
function checkResult(expectInfo: formInfo.FormInfo, result: formInfo.FormInfo) {
console.info("formProvider::GetFormsInfoTest: bundleName expect " + expectInfo.bundleName);
expect(expectInfo.bundleName).assertEqual(result.bundleName);
console.info("formProvider::GetFormsInfoTest: abilityName expect " + expectInfo.abilityName);
expect(expectInfo.abilityName).assertEqual(result.abilityName);
console.info("formProvider::GetFormsInfoTest: name expect " + expectInfo.name);
expect(expectInfo.name).assertEqual(result.name);
console.info("formProvider::GetFormsInfoTest: description expect " + expectInfo.description);
expect(expectInfo.description).assertEqual(result.description);
console.info("formProvider::GetFormsInfoTest: type expect " + expectInfo.type);
expect(expectInfo.type).assertEqual(result.type);
console.info("formProvider::GetFormsInfoTest: jsComponentName expect " + expectInfo.jsComponentName);
expect(expectInfo.jsComponentName).assertEqual(result.jsComponentName);
console.info("formProvider::GetFormsInfoTest: colorMode expect " + expectInfo.colorMode);
expect(expectInfo.colorMode).assertEqual(result.colorMode);
console.info("formProvider::GetFormsInfoTest: isDefault expect " + expectInfo.isDefault);
expect(expectInfo.isDefault).assertEqual(result.isDefault);
console.info("formProvider::GetFormsInfoTest: formVisibleNotify expect " + expectInfo.formVisibleNotify);
expect(expectInfo.formVisibleNotify).assertEqual(result.formVisibleNotify);
console.info("formProvider::GetFormsInfoTest: relatedBundleName expect " + expectInfo.relatedBundleName);
expect(expectInfo.relatedBundleName).assertEqual(result.relatedBundleName);
console.info("formProvider::GetFormsInfoTest: scheduledUpdateTime expect " + expectInfo.scheduledUpdateTime);
expect(expectInfo.scheduledUpdateTime).assertEqual(result.scheduledUpdateTime);
console.info("formProvider::GetFormsInfoTest: formConfigAbility expect " + expectInfo.formConfigAbility);
expect(expectInfo.formConfigAbility).assertEqual(result.formConfigAbility);
console.info("formProvider::GetFormsInfoTest: updateDuration expect " + expectInfo.updateDuration);
expect(expectInfo.updateDuration).assertEqual(result.updateDuration);
console.info("formProvider::GetFormsInfoTest: defaultDimension expect " + expectInfo.defaultDimension);
expect(expectInfo.defaultDimension).assertEqual(result.defaultDimension);
console.info("formProvider::GetFormsInfoTest: supportDimensions expect " + JSON.stringify(expectInfo.supportDimensions));
expect(JSON.stringify(expectInfo.supportDimensions)).assertEqual(JSON.stringify(result.supportDimensions));
console.info("formProvider::GetFormsInfoTest: customizeData expect " + JSON.stringify(expectInfo.customizeData));
expect(JSON.stringify(expectInfo.customizeData)).assertEqual(JSON.stringify(result.customizeData));
}
}
\ 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 getFormsInfoTest from './GetFormsInfoTest.test'
export default function testsuite() {
getFormsInfoTest()
}
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:entry_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "com.example.getformsinfotest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap("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",
":actsformprovidergetformsinfomodule1_resources",
]
ets2abc = true
certificate_profile = "../signature/openharmony_sx.p7b"
}
ohos_app_scope("actsformprovidergetformsinfomodule1_app_profile") {
app_profile = "../AppScope/app.json"
sources = [ "../AppScope/resources" ]
}
ohos_js_assets("actsformprovidergetformsinfomodule1_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("actsformprovidergetformsinfomodule1_resources") {
sources = [ "src/main/resources" ]
deps = [ ":actsformprovidergetformsinfomodule1_app_profile" ]
hap_profile = "src/main/module.json"
}
/*
* 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ 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 FormExtension from '@ohos.application.FormExtension';
import formBindingData from '@ohos.application.formBindingData';
import formInfo from '@ohos.application.formInfo';
export default class FormAbility extends FormExtension {
onCreate(want) {
// Called to return a FormBindingData object.
let formData = {};
return formBindingData.createFormBindingData(formData);
}
onCastToNormal(formId) {
// Called when the form provider is notified that a temporary form is successfully
// converted to a normal form.
}
onUpdate(formId) {
// Called to notify the form provider to update a specified form.
}
onVisibilityChange(newStatus) {
// Called when the form provider receives form events from the system.
}
onEvent(formId, message) {
// Called when a specified message event defined by the form provider is triggered.
}
onDestroy(formId) {
// Called to notify the form provider that a specified form has been destroyed.
}
onAcquireFormState(want) {
// Called to return a {@link FormState} object.
return formInfo.FormState.READY;
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/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")
}
};
/*
* 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.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
#wrapper {
flex-direction: column;
}
#div1 {
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
background-color: white;
}
#text1 {
height: 45px;
width: 150px;
font-size: 16px;
text-align: center;
}
<div>
<div id="wrapper">
<div id="div1">
<text id="text1">{{title}}</text>
</div>
</div>
</div>
\ No newline at end of file
{
"module": {
"name": "module1",
"type": "feature",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:module1_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white"
}
],
"extensionAbilities": [
{
"name": "FormAbility",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc",
"type": "form",
"metadata": [
{
"name": "ohos.extension.form",
"resource": "$profile:form_config"
}
]
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module1_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "form_FormAbility_desc",
"value": "form_description"
},
{
"name": "form_FormAbility_label",
"value": "form_label"
}
]
}
\ No newline at end of file
{
"forms": [
{
"name": "module1_widget",
"description": "This is a service widget.",
"src": "./js/module1_widget/pages/index/index",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"colorMode": "auto",
"isDefault": true,
"updateEnabled": true,
"scheduledUpdateTime": "10:30",
"updateDuration": 1,
"defaultDimension": "2*2",
"supportDimensions": [
"2*2"
],
"formConfigAbility": "ability://xxxxx",
"formVisibleNotify":true
}
]
}
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap("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",
":actsformprovidergetformsinfomodule2_resources",
]
ets2abc = true
certificate_profile = "../signature/openharmony_sx.p7b"
}
ohos_app_scope("actsformprovidergetformsinfomodule2_app_profile") {
app_profile = "../AppScope/app.json"
sources = [ "../AppScope/resources" ]
}
ohos_js_assets("actsformprovidergetformsinfomodule2_js_assets") {
source_dir = "src/main/ets"
}
ohos_resources("actsformprovidergetformsinfomodule2_resources") {
sources = [ "src/main/resources" ]
deps = [ ":actsformprovidergetformsinfomodule2_app_profile" ]
hap_profile = "src/main/module.json"
}
/*
* 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ 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 FormExtension from '@ohos.application.FormExtension';
import formBindingData from '@ohos.application.formBindingData';
import formInfo from '@ohos.application.formInfo';
export default class FormAbility extends FormExtension {
onCreate(want) {
// Called to return a FormBindingData object.
let formData = {};
return formBindingData.createFormBindingData(formData);
}
onCastToNormal(formId) {
// Called when the form provider is notified that a temporary form is successfully
// converted to a normal form.
}
onUpdate(formId) {
// Called to notify the form provider to update a specified form.
}
onVisibilityChange(newStatus) {
// Called when the form provider receives form events from the system.
}
onEvent(formId, message) {
// Called when a specified message event defined by the form provider is triggered.
}
onDestroy(formId) {
// Called to notify the form provider that a specified form has been destroyed.
}
onAcquireFormState(want) {
// Called to return a {@link FormState} object.
return formInfo.FormState.READY;
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/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")
}
};
/*
* 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.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
#wrapper {
flex-direction: column;
}
#div1 {
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
background-color: white;
}
#text1 {
height: 45px;
width: 150px;
font-size: 16px;
text-align: center;
}
<div>
<div id="wrapper">
<div id="div1">
<text id="text1">{{title}}</text>
</div>
</div>
</div>
\ No newline at end of file
{
"module": {
"name": "module2",
"type": "feature",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:module2_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white"
}
],
"extensionAbilities": [
{
"name": "FormAbility",
"srcEntrance": "./ets/FormAbility/FormAbility.ts",
"label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc",
"type": "form",
"metadata": [
{
"name": "ohos.extension.form",
"resource": "$profile:form_config"
}
]
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module2_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "form_FormAbility_desc",
"value": "form_description"
},
{
"name": "form_FormAbility_label",
"value": "form_label"
}
]
}
\ No newline at end of file
{
"forms": [
{
"name": "module2_widget",
"description": "This is a service widget.",
"src": "./js/module2widget/pages/index/index",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"colorMode": "auto",
"isDefault": true,
"updateEnabled": true,
"scheduledUpdateTime": "10:30",
"updateDuration": 1,
"defaultDimension": "2*2",
"supportDimensions": [
"2*2"
],
"formConfigAbility": "ability://xxxxx",
"formVisibleNotify":true
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册