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

!5132 xts接口覆盖

Merge pull request !5132 from chengxingzhen/master
...@@ -109,7 +109,10 @@ export default function abilityTest() { ...@@ -109,7 +109,10 @@ export default function abilityTest() {
data.addAbilityMonitor( data.addAbilityMonitor(
{ {
abilityName: 'MainAbility2', abilityName: 'MainAbility2',
onAbilityForeground: onAbilityForeground onAbilityForeground: onAbilityForeground,
onWindowStageRestore:(Ability)=>{
console.info("===>onWindowStageRestore");
}
}, (async (err) => { }, (async (err) => {
console.debug("====>ACTS_AddAbilityMonitor_0200 success====>" + err.code); console.debug("====>ACTS_AddAbilityMonitor_0200 success====>" + err.code);
await globalThis.abilitydelegator.startAbility( await globalThis.abilitydelegator.startAbility(
......
...@@ -97,6 +97,8 @@ export default function abilityTest() { ...@@ -97,6 +97,8 @@ export default function abilityTest() {
var state = abilityDelegator.getAbilityState(ability); var state = abilityDelegator.getAbilityState(ability);
console.debug("====>ACTS_GetAbilityState_0300 state:" + state); console.debug("====>ACTS_GetAbilityState_0300 state:" + state);
expect(state).assertEqual(AbilityDelegatorRegistry.AbilityLifecycleState.FOREGROUND); expect(state).assertEqual(AbilityDelegatorRegistry.AbilityLifecycleState.FOREGROUND);
expect(state != AbilityDelegatorRegistry.AbilityLifecycleState.CREATE).assertTrue()
expect(state != AbilityDelegatorRegistry.AbilityLifecycleState.DESTROY).assertTrue()
abilityDelegator.doAbilityBackground(ability, (err, isBackground)=>{ abilityDelegator.doAbilityBackground(ability, (err, isBackground)=>{
console.debug("====>doAbilityBackground_0300 data:" + JSON.stringify(isBackground)); console.debug("====>doAbilityBackground_0300 data:" + JSON.stringify(isBackground));
expect(isBackground).assertTrue(); expect(isBackground).assertTrue();
......
/*
* 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 CreateFormAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] CreateFormAbility onCreate")
globalThis.abilityWant = want;
globalThis.applicationContext = this.context.getApplicationContext();
globalThis.isCreateForm = want.parameters["createForm"];
}
onDestroy() {
console.log("[Demo] CreateFormAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] CreateFormAbility onWindowStageCreate")
globalThis.abilityContext = this.context;
windowStage.setUIContent(this.context, "CreateFormAbility/pages/MainAbility_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] CreateFormAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] CreateFormAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] SecondAbility 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';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../test/List.test'
@Entry
@Component
struct Index {
@State message: string = 'CreateFormAbility'
@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_2;
private temporary = false;
aboutToAppear() {
this.isShowing = globalThis.isCreateForm
}
build() {
Row() {
Column() {
if (this.isShowing) {
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.host] get form, form id:" + form.id);
})
}
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
...@@ -16,13 +16,27 @@ ...@@ -16,13 +16,27 @@
import FormExtension from '@ohos.application.FormExtension'; import FormExtension from '@ohos.application.FormExtension';
import formBindingData from '@ohos.application.formBindingData'; import formBindingData from '@ohos.application.formBindingData';
import formInfo from '@ohos.application.formInfo'; import formInfo from '@ohos.application.formInfo';
import commonEvent from '@ohos.commonEvent';
var extensionInfo_config_direction
export default class FormAbility extends FormExtension { export default class FormAbility extends FormExtension {
onCreate(want) { onCreate(want) {
// Called to return a FormBindingData object. // Called to return a FormBindingData object.
let formData = {};
console.info("FormAbility onCreate") console.info("FormAbility onCreate")
let formData = {
temperature: "11°",
time: "11:00",
area: "Shenyang"
};
console.info("FormAbility onCreate===StarAbility=== ")
this.context.startAbility({
bundleName:"com.example.apicoverhaptest",
abilityName:"SecondAbility"
}).then((data)=>{
console.info("FormAbility startAbility success")
}).catch((err)=>{
console.info("FormAbility startAbility failed " + err.code)
})
console.info("FormAbility onCreate===end=== ")
return formBindingData.createFormBindingData(formData); return formBindingData.createFormBindingData(formData);
} }
...@@ -49,6 +63,7 @@ export default class FormAbility extends FormExtension { ...@@ -49,6 +63,7 @@ export default class FormAbility extends FormExtension {
onAcquireFormState(want) { onAcquireFormState(want) {
// Called to return a {@link FormState} object. // Called to return a {@link FormState} object.
console.info("FormAbility want success" + JSON.stringify(want.parameters))
return formInfo.FormState.READY; return formInfo.FormState.READY;
} }
}; };
\ 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 Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent';
export default class SecondAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] SecondAbility onCreate")
globalThis.abilityWant = want;
globalThis.applicationContext = this.context.getApplicationContext();
}
onDestroy() {
console.log("[Demo] SecondAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] SecondAbility onWindowStageCreate")
globalThis.abilityContext = this.context;
windowStage.setUIContent(this.context, "SecondAbility/pages/MainAbility_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] SecondAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] SecondAbility onForeground")
var CommonEventPublishData = {
parameters: {
"Life": "onForeground"
}
}
commonEvent.publish("Form_StartAbility", CommonEventPublishData, (err) => {
console.info("Form_StartAbility onCreate");
});
}
onBackground() {
// Ability has back to background
console.log("[Demo] SecondAbility 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';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../test/List.test'
@Entry
@Component
struct Index {
@State message: string = 'MainAbility'
@State create: string = 'MainAbility'
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 ServiceExtension from '@ohos.application.ServiceExtensionAbility'
import commonEvent from "@ohos.commonEvent";
import Want from '@ohos.application.Want';
import rpc from '@ohos.rpc';
export default class ServiceAbility extends ServiceExtension {
onCreate(want:Want) {
globalThis.abilityWant = want;
let direction = this.context.config.direction
let pointerDervice = this.context.config.hasPointerDevice
let AbilityInfo = this.context.extensionAbilityInfo.bundleName
console.log('ServiceAbility onCreate, want: ' + want.abilityName);
var CommonEventPublishData = {
parameters: {
"config": direction,
"poniterDevices": pointerDervice,
"AbilityInfo":AbilityInfo
}
}
commonEvent.publish("ExtensionConext_StartAbility", CommonEventPublishData, (err) => {
console.info("ExtensionConext_StartAbility onCreate");
});
}
onRequest(want, startId) {
console.log('ServiceAbility onRequest, want: ' + want.abilityName + ', startId: ' + startId);
console.log('ServiceAbility registerApplicationStateObserver begin');
setTimeout(()=>{
this.context.terminateSelf().then((data) => {
console.info("terminateSelf data = " + JSON.stringify(data));
}).catch((err) => {
console.info("terminateSelf err = " + JSON.stringify(err));
});
}, 3000)
}
onConnect(want) {
console.log('ServiceAbility onConnect, want:' + want.abilityName);
return null;
}
onDisconnect(want) {
console.log('ServiceAbility onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility onDestroy');
}
}
\ No newline at end of file
...@@ -17,6 +17,14 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from ...@@ -17,6 +17,14 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import formProvider from '@ohos.application.formProvider'; import formProvider from '@ohos.application.formProvider';
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 formHost from '@ohos.application.formHost';
import errorManager from '@ohos.application.errorManager';
import abilityConstant from '@ohos.application.AbilityConstant'
import appManager from '@ohos.application.appManager'
import appContext from '@ohos.application.context'
import commonEvent from '@ohos.commonEvent';
import ability from '@ohos.ability.ability'
FormDimension
var EXTENSION_INFO_ERR = 2097152 var EXTENSION_INFO_ERR = 2097152
var USERID_ERR = 2097177 var USERID_ERR = 2097177
var trueInfo; var trueInfo;
...@@ -312,9 +320,12 @@ export default function ApiCoverTest() { ...@@ -312,9 +320,12 @@ export default function ApiCoverTest() {
expect("ohos.extra.param.key.form_dimension").assertEqual(FormInfo.FormParam.DIMENSION_KEY) expect("ohos.extra.param.key.form_dimension").assertEqual(FormInfo.FormParam.DIMENSION_KEY)
expect("ohos.extra.param.key.form_height").assertEqual(FormInfo.FormParam.HEIGHT_KEY) expect("ohos.extra.param.key.form_height").assertEqual(FormInfo.FormParam.HEIGHT_KEY)
expect("ohos.extra.param.key.module_name").assertEqual(FormInfo.FormParam.MODULE_NAME_KEY) expect("ohos.extra.param.key.module_name").assertEqual(FormInfo.FormParam.MODULE_NAME_KEY)
expect("ohos.extra.param.key.form_width").assertEqual(FormInfo.FormParam.WIDTH_KEY)
expect("ohos.extra.param.key.form_name").assertEqual(FormInfo.FormParam.NAME_KEY) expect("ohos.extra.param.key.form_name").assertEqual(FormInfo.FormParam.NAME_KEY)
expect("ohos.extra.param.key.form_temporary").assertEqual(FormInfo.FormParam.TEMPORARY_KEY) expect("ohos.extra.param.key.form_temporary").assertEqual(FormInfo.FormParam.TEMPORARY_KEY)
expect("ohos.extra.param.key.form_width").assertEqual(FormInfo.FormParam.WIDTH_KEY) expect("ohos.extra.param.key.form_identity").assertEqual(FormInfo.FormParam.IDENTITY_KEY)
expect("ohos.extra.param.key.bundle_name").assertEqual(FormInfo.FormParam.BUNDLE_NAME_KEY)
expect("ohos.extra.param.key.ability_name").assertEqual(FormInfo.FormParam.ABILITY_NAME_KEY)
expect(0).assertEqual(FormInfo.FormState.DEFAULT) expect(0).assertEqual(FormInfo.FormState.DEFAULT)
expect(1).assertEqual(FormInfo.FormState.READY) expect(1).assertEqual(FormInfo.FormState.READY)
expect(-1).assertEqual(FormInfo.FormState.UNKNOWN) expect(-1).assertEqual(FormInfo.FormState.UNKNOWN)
...@@ -322,5 +333,248 @@ export default function ApiCoverTest() { ...@@ -322,5 +333,248 @@ export default function ApiCoverTest() {
expect(1).assertEqual(FormInfo.ColorMode.MODE_LIGHT) expect(1).assertEqual(FormInfo.ColorMode.MODE_LIGHT)
done(); done();
}); });
/*
* @tc.number SUB_AA_ReisterErrorObserver_0100
* @tc.name Test ReisterErrorObserver.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ReisterErrorObserver_0100', 0, async function (done) {
let errorObserver:errorManager.ErrorObserver;
errorObserver = {
onUnhandledException:(errMessage) => {
console.info("SUB_AA_ReisterErrorObserver_0100" + JSON.stringify(errMessage));
}
}
let errCodeId = errorManager.registerErrorObserver(errorObserver)
expect(errCodeId).assertEqual(0)
errorManager.unregisterErrorObserver(errCodeId).then((data)=>{
expect(data).assertEqual(undefined)
done();
}).catch((err)=>{
expect().assertFail()
done();
})
});
/*
* @tc.number SUB_AA_ReisterErrorObserver_0200
* @tc.name Test unregisterErrorObserver with error number.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ReisterErrorObserver_0200', 0, async function (done) {
errorManager.unregisterErrorObserver(-1, (err, data)=>{
console.info("SUB_AA_ReisterErrorObserver_0200:" + JSON.stringify(err) + " " + JSON.stringify(data));
console.info("SUB_AA_ReisterErrorObserver_0200:" + typeof(err.code));
if(err.code != 0){
expect(err.code).assertEqual(-2)
done()
}else{
expect().assertFail()
done();
}
})
});
/*
* @tc.number SUB_AA_Test_AbilityConstant_0100
* @tc.name Test abilityConstant.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AbilityConstant_0200', 0, async function (done) {
expect(1).assertEqual(abilityConstant.LaunchReason.START_ABILITY)
expect(1).assertEqual(abilityConstant.LastExitReason.ABILITY_NOT_RESPONDING)
expect(2).assertEqual(abilityConstant.LastExitReason.NORMAL)
done()
});
/*
* @tc.number SUB_AA_Test_ProcessRunningInformation_0100
* @tc.name Test getProcessRunningInformation in appManager.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Test_ProcessRunningInformation_0100', 0, async function (done) {
let processRunningInformation:appManager.ProcessRunningInformation;
let process;
appManager.getProcessRunningInformation().then((processRunningInformations)=>{
console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(processRunningInformations));
for(let i = 0; i < processRunningInformations.length; i++){
console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(processRunningInformations[i]));
expect(processRunningInformations[i].pid).assertLarger(0)
expect(processRunningInformations[i].uid).assertLarger(0)
if(processRunningInformations[i].processName == "com.example.apicoverhaptest"){
process = processRunningInformations[i]
}
}
expect(process.bundleNames[0]).assertEqual("com.example.apicoverhaptest")
done()
}).catch((error)=>{
console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(error));
expect().assertFail()
done()
})
});
/*
* @tc.number SUB_AA_Test_ProcessRunningInformation_0200
* @tc.name Test getProcessRunningInformation by callback in appManager.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Test_ProcessRunningInformation_0200', 0, async function (done) {
let process;
appManager.getProcessRunningInformation((error, processRunningInformations)=>{
if(error.code == 0){
console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(processRunningInformations));
for(let i = 0; i < processRunningInformations.length; i++){
console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(processRunningInformations[i]));
expect(processRunningInformations[i].pid).assertLarger(0)
expect(processRunningInformations[i].uid).assertLarger(0)
if(processRunningInformations[i].processName == "com.example.apicoverhaptest"){
process = processRunningInformations[i]
}
}
expect(process.bundleNames[0]).assertEqual("com.example.apicoverhaptest")
done()
}else{
console.info("SUB_AA_Test_ProcessRunningInformation_0100:" + JSON.stringify(error));
expect().assertFail()
done()
}
})
});
/*
* @tc.number SUB_AA_FMS_AbilityStage_0100
* @tc.name Start AbilityStage and get config.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_FMS_AbilityStage_0100', 0, async function (done) {
let subscriber = null
let subscribeInfo = {
events: ["AbilityStage_StartAbility"]
}
function UnSubscribeInfoCallback(err, data) {
console.info("SUB_AA_FMS_AbilityStage_0100===UnSubscribeInfoCallback===")
done()
}
function SubscribeInfoCallback(err, data) {
console.info("SUB_AA_FMS_AbilityStage_0100===SubscribeInfoCallback===" + JSON.stringify(data))
expect(data.parameters["config"]).assertEqual(-1)
commonEvent.unsubscribe(subscriber, UnSubscribeInfoCallback)
done()
}
commonEvent.createSubscriber(subscribeInfo, (err, data) => {
console.info("SUB_AA_FMS_AbilityStage_0100===CreateSubscriberCallback===")
subscriber = data
commonEvent.subscribe(subscriber, SubscribeInfoCallback)
})
let formWant ={
deviceId:"",
bundleName:"ohos.acts.aafwk.test.stagesupplement",
abilityName:"MainAbility3",
}
globalThis.abilityContext.startAbility(formWant, (err, data)=>{
if(err.code == 0){
console.info("SUB_AA_FMS_AbilityStage_0100===CreateSubscriberCallback===")
}else{
expect().assertFail()
done()
}
})
})
/*
* @tc.number SUB_AA_FMS_AbilityStage_0200
* @tc.name Start Service and get config.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_FMS_AbilityStage_0200', 0, async function (done) {
let subscriber = null
let subscribeInfo = {
events: ["ExtensionConext_StartAbility"]
}
function UnSubscribeInfoCallback(err, data) {
console.info("SUB_AA_FMS_AbilityStage_0200===UnSubscribeInfoCallback===")
}
function SubscribeInfoCallback(err, data) {
console.info("SUB_AA_FMS_AbilityStage_0200===SubscribeInfoCallback===" + JSON.stringify(data))
expect(data.parameters["config"]).assertEqual(0)
expect(data.parameters["poniterDevices"]).assertFalse()
expect(data.parameters["AbilityInfo"]).assertEqual("com.example.apicoverhaptest")
commonEvent.unsubscribe(subscriber, UnSubscribeInfoCallback)
done()
}
commonEvent.createSubscriber(subscribeInfo, (err, data) => {
console.info("SUB_AA_FMS_AbilityStage_0200===CreateSubscriberCallback===")
subscriber = data
commonEvent.subscribe(subscriber, SubscribeInfoCallback)
})
let formWant ={
deviceId:"",
bundleName:"com.example.apicoverhaptest",
abilityName:"ServiceAbility",
}
globalThis.abilityContext.startAbility(formWant, (err, data)=>{
if(err.code == 0){
console.info("SUB_AA_FMS_AbilityStage_0200===abilityContext startAbility success===")
}else{
expect().assertFail()
done()
}
})
})
/*
* @tc.number SUB_AA_FMS_AcquireForm_0100
* @tc.name Test startAbility in FormExtensionContext.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_FMS_AcquireForm_0100', 0, async function (done) {
let subscriber = null
let formExtensionContext:appContext.FormExtensionContext
let pacMap:ability.PacMap
let subscribeInfo = {
events: ["Form_StartAbility"]
}
function UnSubscribeInfoCallback(err, data) {
console.info("SUB_AA_FMS_AcquireFormState_0700 ===UnSubscribeInfoCallback===")
}
function SubscribeInfoCallback(err, data) {
console.info("SUB_AA_FMS_AcquireFormState_0700 ===SubscribeInfoCallback===" + JSON.stringify(data))
expect(data.parameters["Life"]).assertEqual("onForeground")
commonEvent.unsubscribe(subscriber, UnSubscribeInfoCallback)
done()
}
commonEvent.createSubscriber(subscribeInfo, (err, data) => {
console.info("SUB_AA_FMS_AcquireFormState_0700 ===CreateSubscriberCallback===")
subscriber = data
commonEvent.subscribe(subscriber, SubscribeInfoCallback)
})
let formWant ={
deviceId:"",
bundleName:"com.example.apicoverhaptest",
abilityName:"CreateFormAbility",
parameters:{
"createForm": true
}
}
globalThis.abilityContext.startAbility(formWant, (err, data)=>{
if(err.code == 0){
console.info("SUB_AA_FMS_AcquireFormState_0700 ===acquireFormState=== " + JSON.stringify(data))
}else{
expect().assertFail()
done()
}
})
})
}) })
} }
\ No newline at end of file
...@@ -67,7 +67,7 @@ export default function ContextEnvironmentTest(applicationContext) { ...@@ -67,7 +67,7 @@ export default function ContextEnvironmentTest(applicationContext) {
var code = undefined var code = undefined
console.info(TAG + "callbackId = " + callbackId + " callNum = " + callNum) console.info(TAG + "callbackId = " + callbackId + " callNum = " + callNum)
await sleep(1000) await sleep(700)
// unregisterEnvironmentCallback // unregisterEnvironmentCallback
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => { applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
console.info(TAG + "unregisterEnvironmentCallback first err is : " + JSON.stringify(error) + ", data is : " + JSON.stringify(data)) console.info(TAG + "unregisterEnvironmentCallback first err is : " + JSON.stringify(error) + ", data is : " + JSON.stringify(data))
...@@ -75,7 +75,7 @@ export default function ContextEnvironmentTest(applicationContext) { ...@@ -75,7 +75,7 @@ export default function ContextEnvironmentTest(applicationContext) {
}) })
await sleep(1000) await sleep(700)
expect(callbackId).assertEqual(callNum) expect(callbackId).assertEqual(callNum)
expect(code).assertEqual(0) expect(code).assertEqual(0)
callNum++; callNum++;
......
...@@ -24,4 +24,4 @@ export default function List() { ...@@ -24,4 +24,4 @@ export default function List() {
verificationTest() verificationTest()
wantAgentCover() wantAgentCover()
contextEnvironmentTest(globalThis.applicationContext) contextEnvironmentTest(globalThis.applicationContext)
} }
\ No newline at end of file
...@@ -33,6 +33,28 @@ ...@@ -33,6 +33,28 @@
] ]
} }
] ]
},
{
"name": "SecondAbility",
"srcEntrance": "./ets/SecondAbility/SecondAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"visible": true,
"launchType": "singleton"
},
{
"name": "CreateFormAbility",
"srcEntrance": "./ets/CreateFormAbility/CreateFormAbility.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": [
...@@ -48,6 +70,24 @@ ...@@ -48,6 +70,24 @@
"resource": "$profile:form_config" "resource": "$profile:form_config"
} }
] ]
},
{
"name": "ServiceAbility",
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
"label": "$string:MainAbility_label",
"description": "$string:MainAbility_desc",
"type": "service"
}
],
"requestPermissions":[
{
"name":"ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.REQUIRE_FORM"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
} }
] ]
} }
......
{ {
"src": [ "src": [
"MainAbility/pages/MainAbility_pages" "MainAbility/pages/MainAbility_pages",
"SecondAbility/pages/MainAbility_pages",
"CreateFormAbility/pages/MainAbility_pages"
] ]
} }
\ No newline at end of file
...@@ -5,7 +5,9 @@ import formInfo from '@ohos.application.formInfo'; ...@@ -5,7 +5,9 @@ import formInfo from '@ohos.application.formInfo';
export default class FormModuleAbility extends FormExtension { export default class FormModuleAbility extends FormExtension {
onCreate(want) { onCreate(want) {
// Called to return a FormBindingData object. // Called to return a FormBindingData object.
let formData = {}; console.info("FormAbility onCreate")
let formData = {
};
return formBindingData.createFormBindingData(formData); return formBindingData.createFormBindingData(formData);
} }
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
], ],
"extensionAbilities": [ "extensionAbilities": [
{ {
"name": "FormAbility", "name": "FormAbility2",
"srcEntrance": "./ets/FormAbility/FormAbility.ts", "srcEntrance": "./ets/FormAbility/FormAbility.ts",
"label": "$string:form_FormAbility_label", "label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc", "description": "$string:form_FormAbility_desc",
......
import AbilityStage from "@ohos.application.AbilityStage" import AbilityStage from "@ohos.application.AbilityStage"
import commonEvent from '@ohos.commonEvent';
export default class MyAbilityStage extends AbilityStage { export default class MyAbilityStage extends AbilityStage {
onCreate() { onCreate() {
console.info("[Demo] MyAbilityStage onCreate") console.info("[Demo] MyAbilityStage onCreate")
let directions = this.context.config.direction
var CommonEventPublishData = {
parameters: {
"config": directions
}
}
commonEvent.publish("AbilityStage_StartAbility", CommonEventPublishData, (err) => {
console.info("AbilityStage_StartAbility onCreate");
});
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册