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

!5684 xts接口覆盖

Merge pull request !5684 from chengxingzhen/OpenHarmony-3.2-Beta3
...@@ -28,7 +28,7 @@ struct Index { ...@@ -28,7 +28,7 @@ struct Index {
@State bundle: string = "com.example.apicoverhaptest"; @State bundle: string = "com.example.apicoverhaptest";
@State ability: string = "FormAbility"; @State ability: string = "FormAbility";
@State moduleName: string = "phone"; @State moduleName: string = "phone";
@State name: string = "widget"; @State name: string = "form1";
private dimension: FormDimension = FormDimension.Dimension_2_2; private dimension: FormDimension = FormDimension.Dimension_2_2;
private temporary = false; private temporary = 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 Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] FormHostAbility onCreate")
globalThis.abilityWant = want;
globalThis.applicationContext = this.context.getApplicationContext();
}
onDestroy() {
console.log("[Demo] FormHostAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] FormHostAbility onWindowStageCreate")
globalThis.abilityContext = this.context;
windowStage.setUIContent(this.context, "FormHostAbility/pages/MainAbility_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] FormHostAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] FormHostAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] FormHostAbility onBackground")
}
};
// @ts-nocheck
/*
* 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 '@ohos.router';
@Entry
@Component
struct Index {
@State message: string = 'FormHostAbility'
@State isShowing: boolean = true;
@State formId: number = 0;
@State bundle: string = "com.example.apicoverhaptest";
@State ability: string = "FormAbility";
@State moduleName: string = "phone";
@State name: string = "widget";
private dimension: FormDimension = FormDimension.Dimension_2_1;
private temporary = false;
build() {
Row() {
Column() {
FormComponent({
id: this.formId,
name: this.name,
bundle: this.bundle,
ability: this.ability,
module: this.moduleName,
dimension: this.dimension,
temporary: this.temporary,
})
.allowUpdate(this.allowUpate)
.visibility(this.isShowing ? Visibility.Visible : Visibility.Hidden)
.onAcquired((form) => {
console.log("[FormComponent.FormHostAbility] get form, form id:" + form.id);
globalThis.formId21 = form.id
})
.onError((error) => {
console.log("[FormComponent.FormHostAbility] error code:" + error.errcode);
console.log("[FormComponent.FormHostAbility] error msg:" + error.msg);
})
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
...@@ -20,6 +20,7 @@ import rpc from '@ohos.rpc'; ...@@ -20,6 +20,7 @@ import rpc from '@ohos.rpc';
export default class ServiceAbility extends ServiceExtension { export default class ServiceAbility extends ServiceExtension {
onCreate(want:Want) { onCreate(want:Want) {
globalThis.abilityWant = want; globalThis.abilityWant = want;
globalThis.serviceContext = this.context
let direction = this.context.config.direction let direction = this.context.config.direction
let pointerDervice = this.context.config.hasPointerDevice let pointerDervice = this.context.config.hasPointerDevice
let AbilityInfo = this.context.extensionAbilityInfo.bundleName let AbilityInfo = this.context.extensionAbilityInfo.bundleName
......
...@@ -35,7 +35,6 @@ function sleep(time) { ...@@ -35,7 +35,6 @@ function sleep(time) {
export default function ApiCoverTest() { export default function ApiCoverTest() {
describe('ApiCoverTestTest', function () { describe('ApiCoverTestTest', function () {
afterEach(async (done) => { afterEach(async (done) => {
setTimeout(function () { setTimeout(function () {
done(); done();
...@@ -244,6 +243,8 @@ export default function ApiCoverTest() { ...@@ -244,6 +243,8 @@ export default function ApiCoverTest() {
expect(1).assertEqual(globalThis.abilityContext.area) expect(1).assertEqual(globalThis.abilityContext.area)
let moduleContext = globalThis.abilityContext.createModuleContext("module1") let moduleContext = globalThis.abilityContext.createModuleContext("module1")
expect("/data/storage/el2/base/cache").assertEqual(moduleContext.cacheDir) expect("/data/storage/el2/base/cache").assertEqual(moduleContext.cacheDir)
globalThis.abilityContext.area = 0
expect(0).assertEqual(globalThis.abilityContext.area)
globalThis.abilityContext.resourceManager.getConfiguration((err, data) => { globalThis.abilityContext.resourceManager.getConfiguration((err, data) => {
if(err == undefined){ if(err == undefined){
console.log(`Ability: getConfiguration success: ${JSON.stringify(data)}`); console.log(`Ability: getConfiguration success: ${JSON.stringify(data)}`);
...@@ -338,6 +339,12 @@ export default function ApiCoverTest() { ...@@ -338,6 +339,12 @@ export default function ApiCoverTest() {
expect(-1).assertEqual(FormInfo.FormState.UNKNOWN) expect(-1).assertEqual(FormInfo.FormState.UNKNOWN)
expect(0).assertEqual(FormInfo.ColorMode.MODE_DARK) expect(0).assertEqual(FormInfo.ColorMode.MODE_DARK)
expect(1).assertEqual(FormInfo.ColorMode.MODE_LIGHT) expect(1).assertEqual(FormInfo.ColorMode.MODE_LIGHT)
console.info("SUB_AA_Form_provider_TestFormInfo_0100:" + FormInfo.FormDimension.Dimension_2_1);
expect(1).assertEqual(FormInfo.FormDimension.Dimension_1_2)
expect(2).assertEqual(FormInfo.FormDimension.Dimension_2_2)
expect(3).assertEqual(FormInfo.FormDimension.Dimension_2_4)
expect(4).assertEqual(FormInfo.FormDimension.Dimension_4_4)
expect(5).assertEqual(FormInfo.FormDimension.Dimension_2_1)
done(); done();
}); });
...@@ -391,10 +398,13 @@ export default function ApiCoverTest() { ...@@ -391,10 +398,13 @@ export default function ApiCoverTest() {
* @tc.desc Function test * @tc.desc Function test
* @tc.level 3 * @tc.level 3
*/ */
it('SUB_AA_AbilityConstant_0200', 0, async function (done) { it('SUB_AA_Test_AbilityConstant_0100', 0, async function (done) {
expect(1).assertEqual(abilityConstant.LaunchReason.START_ABILITY) expect(1).assertEqual(abilityConstant.LaunchReason.START_ABILITY)
expect(1).assertEqual(abilityConstant.LastExitReason.ABILITY_NOT_RESPONDING) expect(1).assertEqual(abilityConstant.LastExitReason.ABILITY_NOT_RESPONDING)
expect(2).assertEqual(abilityConstant.LastExitReason.NORMAL) expect(2).assertEqual(abilityConstant.LastExitReason.NORMAL)
expect(0).assertEqual(abilityConstant.MemoryLevel.MEMORY_LEVEL_MODERATE)
expect(1).assertEqual(abilityConstant.MemoryLevel.MEMORY_LEVEL_LOW)
expect(2).assertEqual(abilityConstant.MemoryLevel.MEMORY_LEVEL_CRITICAL)
done() done()
}); });
...@@ -462,6 +472,9 @@ export default function ApiCoverTest() { ...@@ -462,6 +472,9 @@ export default function ApiCoverTest() {
* @tc.level 3 * @tc.level 3
*/ */
it('SUB_AA_FMS_AbilityStage_0100', 0, async function (done) { it('SUB_AA_FMS_AbilityStage_0100', 0, async function (done) {
console.info("SUB_AA_FMS_AbilityStage_0100===AbilityStage===" + JSON.stringify(globalThis.stageContext))
console.info("SUB_AA_FMS_AbilityStage_0100===AbilityStage===" + JSON.stringify(globalThis.stageContext.config))
let directions = globalThis.stageContext.config.direction
let subscriber = null let subscriber = null
let subscribeInfo = { let subscribeInfo = {
events: ["AbilityStage_StartAbility"] events: ["AbilityStage_StartAbility"]
...@@ -470,10 +483,12 @@ export default function ApiCoverTest() { ...@@ -470,10 +483,12 @@ export default function ApiCoverTest() {
console.info("SUB_AA_FMS_AbilityStage_0100===UnSubscribeInfoCallback===") console.info("SUB_AA_FMS_AbilityStage_0100===UnSubscribeInfoCallback===")
done() done()
} }
function SubscribeInfoCallback(err, data) { async function SubscribeInfoCallback(err, data) {
console.info("SUB_AA_FMS_AbilityStage_0100===SubscribeInfoCallback===" + JSON.stringify(data)) console.info("SUB_AA_FMS_AbilityStage_0100===SubscribeInfoCallback===" + JSON.stringify(data))
expect(data.parameters["config"]).assertEqual(-1) expect(data.parameters["config"]).assertEqual(-1)
expect(data.parameters["config"]).assertEqual(directions)
commonEvent.unsubscribe(subscriber, UnSubscribeInfoCallback) commonEvent.unsubscribe(subscriber, UnSubscribeInfoCallback)
await sleep(4000)
done() done()
} }
commonEvent.createSubscriber(subscribeInfo, (err, data) => { commonEvent.createSubscriber(subscribeInfo, (err, data) => {
...@@ -490,6 +505,7 @@ export default function ApiCoverTest() { ...@@ -490,6 +505,7 @@ export default function ApiCoverTest() {
if(err.code == 0){ if(err.code == 0){
console.info("SUB_AA_FMS_AbilityStage_0100===CreateSubscriberCallback===") console.info("SUB_AA_FMS_AbilityStage_0100===CreateSubscriberCallback===")
}else{ }else{
console.info("SUB_AA_FMS_AbilityStage_0100===failed===")
expect().assertFail() expect().assertFail()
done() done()
} }
...@@ -510,12 +526,21 @@ export default function ApiCoverTest() { ...@@ -510,12 +526,21 @@ export default function ApiCoverTest() {
function UnSubscribeInfoCallback(err, data) { function UnSubscribeInfoCallback(err, data) {
console.info("SUB_AA_FMS_AbilityStage_0200===UnSubscribeInfoCallback===") console.info("SUB_AA_FMS_AbilityStage_0200===UnSubscribeInfoCallback===")
} }
function SubscribeInfoCallback(err, data) { async function SubscribeInfoCallback(err, data) {
console.info("SUB_AA_FMS_AbilityStage_0200===SubscribeInfoCallback===" + JSON.stringify(data)) console.info("SUB_AA_FMS_AbilityStage_0200===SubscribeInfoCallback===" + JSON.stringify(data))
console.info("SUB_AA_FMS_AbilityStage_0200===serviceContext===" + JSON.stringify(globalThis.serviceContext))
console.info("SUB_AA_FMS_AbilityStage_0200===config===" + JSON.stringify(globalThis.serviceContext.config))
expect(data.parameters["config"]).assertLess(2) expect(data.parameters["config"]).assertLess(2)
expect(data.parameters["poniterDevices"]).assertFalse() expect(data.parameters["poniterDevices"]).assertFalse()
expect(data.parameters["AbilityInfo"]).assertEqual("com.example.apicoverhaptest") expect(data.parameters["AbilityInfo"]).assertEqual("com.example.apicoverhaptest")
let direction = globalThis.serviceContext.config.direction
let pointerDervice = globalThis.serviceContext.config.hasPointerDevice
let AbilityInfo = globalThis.serviceContext.extensionAbilityInfo.bundleName
expect(direction).assertLess(2)
expect(pointerDervice).assertFalse()
expect(AbilityInfo).assertEqual("com.example.apicoverhaptest")
commonEvent.unsubscribe(subscriber, UnSubscribeInfoCallback) commonEvent.unsubscribe(subscriber, UnSubscribeInfoCallback)
await sleep(4000)
done() done()
} }
commonEvent.createSubscriber(subscribeInfo, (err, data) => { commonEvent.createSubscriber(subscribeInfo, (err, data) => {
...@@ -582,5 +607,56 @@ export default function ApiCoverTest() { ...@@ -582,5 +607,56 @@ export default function ApiCoverTest() {
} }
}) })
}) })
/*
* @tc.number SUB_AA_FormDisplaySpecifications_0100
* @tc.name Create a form and delete.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_FormDisplaySpecifications_0100', 0, async function (done) {
let formWant ={
deviceId:"",
bundleName:"com.example.apicoverhaptest",
abilityName:"FormHostAbility",
}
globalThis.abilityContext.startAbility(formWant, (err, data)=>{
if(err.code == 0){
console.info("SUB_AA_FormDisplaySpecifications_0100===abilityContext startAbility success===")
}else{
expect().assertFail()
done()
}
})
await sleep(2000)
console.info("SUB_AA_FormDisplaySpecifications_0100===globalThis.formId21 success===" + globalThis.formId21)
expect(globalThis.formId21 != undefined).assertTrue()
formHost.deleteForm(globalThis.formId21).then((data)=>{
console.info("SUB_AA_FormDisplaySpecifications_0100===deleteForm success===")
done()
}).catch((err)=>{
console.info("SUB_AA_FormDisplaySpecifications_0100===deleteForm failed===")
expect().assertFail()
done()
})
})
/*
* @tc.number SUB_AA_FormDisplaySpecifications_0200
* @tc.name get the form info.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_FormDisplaySpecifications_0200', 0, async function (done) {
await formHost.getFormsInfo("com.example.apicoverhaptest", "phone").then((data)=>{
console.info("SUB_AA_FormDisplaySpecifications_0200===deleteForm success===" + JSON.stringify(data))
expect(5).assertEqual(data[0].defaultDimension)
done()
}).catch((err)=>{
console.info("SUB_AA_FormDisplaySpecifications_0200===deleteForm failed===" + JSON.stringify(err))
expect().assertFail()
done()
})
})
}) })
} }
...@@ -55,6 +55,17 @@ ...@@ -55,6 +55,17 @@
"startWindowBackground": "$color:white", "startWindowBackground": "$color:white",
"visible": true, "visible": true,
"launchType": "singleton" "launchType": "singleton"
},
{
"name": "FormHostAbility",
"srcEntrance": "./ets/FormHostAbility/FormHostAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"visible": true,
"launchType": "singleton"
} }
], ],
"extensionAbilities": [ "extensionAbilities": [
...@@ -76,7 +87,8 @@ ...@@ -76,7 +87,8 @@
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
"label": "$string:MainAbility_label", "label": "$string:MainAbility_label",
"description": "$string:MainAbility_desc", "description": "$string:MainAbility_desc",
"type": "service" "type": "service",
"visible": true
} }
], ],
"requestPermissions":[ "requestPermissions":[
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"isDefault": true, "isDefault": true,
"src": "./js/widget/pages/index/index", "src": "./js/widget/pages/index/index",
"scheduledUpdateTime": "10:30", "scheduledUpdateTime": "10:30",
"defaultDimension": "2*2", "defaultDimension": "2*1",
"name": "widget", "name": "widget",
"description": "This is a service widget.", "description": "This is a service widget.",
"colorMode": "auto", "colorMode": "auto",
...@@ -13,6 +13,25 @@ ...@@ -13,6 +13,25 @@
"autoDesignWidth": true "autoDesignWidth": true
}, },
"formConfigAbility": "ability://xxxxx", "formConfigAbility": "ability://xxxxx",
"supportDimensions": [
"2*1"
],
"updateEnabled": true,
"updateDuration": 1
},
{
"isDefault": false,
"src": "./js/widget/pages/index/index",
"scheduledUpdateTime": "10:30",
"defaultDimension": "2*2",
"name": "form1",
"description": "This is a service widget.",
"colorMode": "auto",
"window": {
"designWidth": 720,
"autoDesignWidth": true
},
"formConfigAbility": "ability://xxxxx",
"supportDimensions": [ "supportDimensions": [
"2*2" "2*2"
], ],
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
"src": [ "src": [
"MainAbility/pages/MainAbility_pages", "MainAbility/pages/MainAbility_pages",
"SecondAbility/pages/MainAbility_pages", "SecondAbility/pages/MainAbility_pages",
"CreateFormAbility/pages/MainAbility_pages" "CreateFormAbility/pages/MainAbility_pages",
"FormHostAbility/pages/MainAbility_pages"
] ]
} }
\ No newline at end of file
...@@ -16,6 +16,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from " ...@@ -16,6 +16,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "
import FormInfo from '@ohos.application.formInfo'; import FormInfo from '@ohos.application.formInfo';
import formError from '@ohos.application.formError'; import formError from '@ohos.application.formError';
import featureAbility from '@ohos.ability.featureAbility'
export default function ApiCoverTest() { export default function ApiCoverTest() {
describe('ApiCoverTestTest', function () { describe('ApiCoverTestTest', function () {
...@@ -75,5 +76,40 @@ export default function ApiCoverTest() { ...@@ -75,5 +76,40 @@ export default function ApiCoverTest() {
expect(1).assertEqual(FormInfo.FormState.READY) expect(1).assertEqual(FormInfo.FormState.READY)
done(); done();
}); });
/*
* @tc.number SUB_AA_OpenHarmony_CoverApiContext_0100
* @tc.name Test getExternalCacheDir by callback.
* @tc.desc Function test
* @tc.level 0
*/
it('SUB_AA_OpenHarmony_CoverApiContext_0100', 0, async function (done) {
console.log("------------start SUB_AA_OpenHarmony_CoverApi_0500-------------");
let appContext = featureAbility.getContext()
appContext.getExternalCacheDir((err, data) => {
console.info('SUB_AA_OpenHarmony_CoverApiContext_0100 successful. data: ' + JSON.stringify(data));
expect(true).assertTrue()
done()
})
})
/*
* @tc.number SUB_AA_OpenHarmony_CoverApiContext_0200
* @tc.name Test getExternalCacheDir by promise.
* @tc.desc Function test
* @tc.level 0
*/
it('SUB_AA_OpenHarmony_CoverApiContext_0200', 0, async function (done) {
console.log("------------start SUB_AA_OpenHarmony_CoverApi_0500-------------");
let appContext = featureAbility.getContext()
appContext.getExternalCacheDir().then((data)=>{
console.info('SUB_AA_OpenHarmony_CoverApiContext_0200 successful. data: ' + JSON.stringify(data));
expect(true).assertTrue()
done()
}).catch((err)=>{
expect().assertFalse();
done()
})
})
}) })
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册