提交 448892dc 编写于 作者: C chengxingzhen

Modify codex

Signed-off-by: Nchengxingzhen <chengxingzhen@huawei.com>
上级 63b288d5
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info( '[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async castTempToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempToNormal result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
console.info("[FormComponent] getAllFormsInfo start");
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
})
.catch((err) => {
console.info('[FormComponent] getAllFormsInfo error:' + JSON.stringify(err));
});
console.info("[FormComponent] getAllFormsInfo end");
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
bundleManager.cleanBundleCacheFiles('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
bundleManager.cleanBundleCacheFiles(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import featureAbility from "@ohos.ability.featureAbility"; import featureAbility from "@ohos.ability.featureAbility";
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import { describe, expect, it } from "deccjsunit/index.ets"; import { beforeEach, describe, expect, it } from "deccjsunit/index.ets";
var onErrorForm_Event = { var onErrorForm_Event = {
events: ["FMS_FormOnError_commonEvent"], events: ["FMS_FormOnError_commonEvent"],
...@@ -32,9 +32,22 @@ var onSupplyEvent = { ...@@ -32,9 +32,22 @@ var onSupplyEvent = {
var deleteForm_Event = "FMS_FormDelete_commonEvent"; var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnError;
var subscriberOnAcquired;
var subscriberCast;
var subscriberSupply;
export default function test() { export default function test() {
describe(`FmsAcquiredFormTest`, () => { describe(`FmsAcquiredFormTest`, () => {
beforeEach(async () => {
subscriberOnError = await commonEvent.createSubscriber(onErrorForm_Event);
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
subscriberCast = await commonEvent.createSubscriber(subscriberFormCastEvent);
subscriberSupply = await commonEvent.createSubscriber(onSupplyEvent);
await sleep(1000);
})
/** /**
* @tc.number: FMS_acquireForm_0200 * @tc.number: FMS_acquireForm_0200
* @tc.name: The form host does not have permission to use the form * @tc.name: The form host does not have permission to use the form
...@@ -42,23 +55,15 @@ export default function test() { ...@@ -42,23 +55,15 @@ export default function test() {
*/ */
it(`FMS_acquireForm_0200`, 0, async (done) => { it(`FMS_acquireForm_0200`, 0, async (done) => {
console.info(`FMS_acquireForm_0200 start`); console.info(`FMS_acquireForm_0200 start`);
var subscriberOnError; function onErrorCallBack(_, data) {
function onErrorCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_0200 onErrorCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_0200 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent"); expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
expect(data.data).assertEqual("check permission deny, need to request ohos.permission.REQUIRE_FORM."); expect(data.data).assertEqual("check permission deny, need to request ohos.permission.REQUIRE_FORM.");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallback); commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallback("FMS_acquireForm_0200"));
console.info(`FMS_acquireForm_0200 end`); console.info(`FMS_acquireForm_0200 end`);
done(); done();
} }
function unSubscribeOnErrorCallback() { commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info("====>FMS_acquireForm_0200 unSubscribeOnErrorCallback CallBack====>");
}
commonEvent.createSubscriber(onErrorForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_0200 onErrorForm_Event Subscriber====>");
subscriberOnError = data;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
console.info(`FMS_acquireForm_0200 featureAbility.startAbility start`); console.info(`FMS_acquireForm_0200 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -88,23 +93,15 @@ export default function test() { ...@@ -88,23 +93,15 @@ export default function test() {
*/ */
it(`FMS_acquireForm_0300`, 0, async (done) => { it(`FMS_acquireForm_0300`, 0, async (done) => {
console.info(`FMS_acquireForm_0300 start`); console.info(`FMS_acquireForm_0300 start`);
var subscriberOnError; function onErrorCallBack(_, data) {
function onErrorCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_0300 onErrorCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_0300 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent"); expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
expect(data.data).assertEqual("invalid params received on operating form."); expect(data.data).assertEqual("invalid params received on operating form.");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallback); commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallback("FMS_acquireForm_0300"));
console.info(`FMS_acquireForm_0300 end`); console.info(`FMS_acquireForm_0300 end`);
done(); done();
} }
function unSubscribeOnErrorCallback() { commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info("====>FMS_acquireForm_0300 unSubscribeOnErrorCallback CallBack====>");
}
commonEvent.createSubscriber(onErrorForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_0300 onErrorForm_Event Subscriber====>");
subscriberOnError = data;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
console.info(`FMS_acquireForm_0300 featureAbility.startAbility start`); console.info(`FMS_acquireForm_0300 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -134,23 +131,15 @@ export default function test() { ...@@ -134,23 +131,15 @@ export default function test() {
*/ */
it(`FMS_acquireForm_0400`, 0, async (done) => { it(`FMS_acquireForm_0400`, 0, async (done) => {
console.info(`FMS_acquireForm_0400 start`); console.info(`FMS_acquireForm_0400 start`);
var subscriberOnError; function onErrorCallBack(_, data) {
function onErrorCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_0400 onErrorCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_0400 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent"); expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
expect(data.data).assertEqual("invalid params received on operating form."); expect(data.data).assertEqual("invalid params received on operating form.");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallback); commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallback("FMS_acquireForm_0400"));
console.info(`FMS_acquireForm_0400 end`); console.info(`FMS_acquireForm_0400 end`);
done(); done();
} }
function unSubscribeOnErrorCallback() { commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info("====>FMS_acquireForm_0400 unSubscribeOnErrorCallback CallBack====>");
}
commonEvent.createSubscriber(onErrorForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_0400 onErrorForm_Event Subscriber====>");
subscriberOnError = data;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
console.info(`FMS_acquireForm_0400 featureAbility.startAbility start`); console.info(`FMS_acquireForm_0400 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -180,23 +169,15 @@ export default function test() { ...@@ -180,23 +169,15 @@ export default function test() {
*/ */
it(`FMS_acquireForm_0500`, 0, async (done) => { it(`FMS_acquireForm_0500`, 0, async (done) => {
console.info(`FMS_acquireForm_0500 start`); console.info(`FMS_acquireForm_0500 start`);
var subscriberOnError; function onErrorCallBack(_, data) {
function onErrorCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_0500 onErrorCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_0500 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent"); expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
expect(data.data).assertEqual("invalid params received on operating form."); expect(data.data).assertEqual("invalid params received on operating form.");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallback); commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallback("FMS_acquireForm_0500"));
console.info(`FMS_acquireForm_0500 end`); console.info(`FMS_acquireForm_0500 end`);
done(); done();
} }
function unSubscribeOnErrorCallback() { commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info("====>FMS_acquireForm_0500 unSubscribeOnErrorCallback CallBack====>");
}
commonEvent.createSubscriber(onErrorForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_0500 onErrorForm_Event Subscriber====>");
subscriberOnError = data;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
console.info(`FMS_acquireForm_0500 featureAbility.startAbility start`); console.info(`FMS_acquireForm_0500 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -226,23 +207,15 @@ export default function test() { ...@@ -226,23 +207,15 @@ export default function test() {
*/ */
it(`FMS_acquireForm_0600`, 0, async (done) => { it(`FMS_acquireForm_0600`, 0, async (done) => {
console.info(`FMS_acquireForm_0600 start`); console.info(`FMS_acquireForm_0600 start`);
var subscriberOnError; function onErrorCallBack(_, data) {
function onErrorCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_0600 onErrorCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_0600 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent"); expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
expect(data.data).assertEqual("invalid params received on operating form."); expect(data.data).assertEqual("invalid params received on operating form.");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallback); commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallback("FMS_acquireForm_0600"));
console.info(`FMS_acquireForm_0600 end`); console.info(`FMS_acquireForm_0600 end`);
done(); done();
} }
function unSubscribeOnErrorCallback() { commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info("====>FMS_acquireForm_0600 unSubscribeOnErrorCallback CallBack====>");
}
commonEvent.createSubscriber(onErrorForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_0600 onErrorForm_Event Subscriber====>");
subscriberOnError = data;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
console.info(`FMS_acquireForm_0600 featureAbility.startAbility start`); console.info(`FMS_acquireForm_0600 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -272,23 +245,15 @@ export default function test() { ...@@ -272,23 +245,15 @@ export default function test() {
*/ */
it(`FMS_acquireForm_0700`, 0, async (done) => { it(`FMS_acquireForm_0700`, 0, async (done) => {
console.info(`FMS_acquireForm_0700 start`); console.info(`FMS_acquireForm_0700 start`);
var subscriberOnError; function onErrorCallBack(_, data) {
function onErrorCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_0700 onErrorCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_0700 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent"); expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
expect(data.data).assertEqual("invalid params received on operating form."); expect(data.data).assertEqual("invalid params received on operating form.");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallback); commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallback("FMS_acquireForm_0700"));
console.info(`FMS_acquireForm_0700 end`); console.info(`FMS_acquireForm_0700 end`);
done(); done();
} }
function unSubscribeOnErrorCallback() { commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info("====>FMS_acquireForm_0700 unSubscribeOnErrorCallback CallBack====>");
}
commonEvent.createSubscriber(onErrorForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_0700 onErrorForm_Event Subscriber====>");
subscriberOnError = data;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
console.info(`FMS_acquireForm_0700 featureAbility.startAbility start`); console.info(`FMS_acquireForm_0700 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -318,23 +283,15 @@ export default function test() { ...@@ -318,23 +283,15 @@ export default function test() {
*/ */
it(`FMS_acquireForm_1000`, 0, async (done) => { it(`FMS_acquireForm_1000`, 0, async (done) => {
console.info(`FMS_acquireForm_1000 start`); console.info(`FMS_acquireForm_1000 start`);
var subscriberOnError; function onErrorCallBack(_, data) {
function onErrorCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_1000 onErrorCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1000 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent"); expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
expect(data.data).assertEqual("invalid params received on operating form."); expect(data.data).assertEqual("invalid params received on operating form.");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallback); commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallback("FMS_acquireForm_1000"));
console.info(`FMS_acquireForm_1000 end`); console.info(`FMS_acquireForm_1000 end`);
done(); done();
} }
function unSubscribeOnErrorCallback() { commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info("====>FMS_acquireForm_1000 unSubscribeOnErrorCallback CallBack====>");
}
commonEvent.createSubscriber(onErrorForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_1000 onErrorForm_Event Subscriber====>");
subscriberOnError = data;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
console.info(`FMS_acquireForm_1000 featureAbility.startAbility start`); console.info(`FMS_acquireForm_1000 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -366,23 +323,13 @@ export default function test() { ...@@ -366,23 +323,13 @@ export default function test() {
*/ */
it(`FMS_acquireForm_1100`, 0, async (done) => { it(`FMS_acquireForm_1100`, 0, async (done) => {
console.info(`FMS_acquireForm_1100 start`); console.info(`FMS_acquireForm_1100 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formId1; let formId1;
let formId2; let formId2;
function delPublishCallBack() { function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_1100 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_acquireForm_1100 delPublishCallBack end');
console.info(`FMS_acquireForm_1100 end`);
done();
}, 1000);
}
function onAcquiredCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_1100 onAcquiredCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1100 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_1100"));
formId1 = data.data; formId1 = data.data;
if (formId1 && formId2) { if (formId1 && formId2) {
...@@ -390,21 +337,15 @@ export default function test() { ...@@ -390,21 +337,15 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: formId1 data: formId1
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_1100", done));
} }
} }
function unSubscribeOnAcquiredCallback() {
console.info("====>FMS_acquireForm_1100 unSubscribeOnAcquiredCallback CallBack====>"); commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
} function onSupplyCallBack(_, data) {
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_1100 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
function onSupplyCallBack(err, data) {
if (data.parameters.kind == "onCreate") { if (data.parameters.kind == "onCreate") {
console.info("====>FMS_acquireForm_1100 onSupplyCallBack====>" + JSON.stringify(data)); console.info("====>FMS_acquireForm_1100 onSupplyCallBack====>" + JSON.stringify(data));
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_acquireForm_1100"));
let retData = JSON.parse(data.parameters.parameters); let retData = JSON.parse(data.parameters.parameters);
let bundleName = retData.bundleName; let bundleName = retData.bundleName;
...@@ -427,18 +368,11 @@ export default function test() { ...@@ -427,18 +368,11 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: formId1 data: formId1
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_1100", done));
} }
} }
} }
function unSubscribeSupplyCallback() { commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.info("====>FMS_acquireForm_1100 unSubscribeSupplyCallback====>");
}
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.info("====>FMS_acquireForm_1100 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
console.info(`FMS_acquireForm_1100 featureAbility.startAbility start`); console.info(`FMS_acquireForm_1100 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -469,23 +403,13 @@ export default function test() { ...@@ -469,23 +403,13 @@ export default function test() {
*/ */
it(`FMS_acquireForm_1200`, 0, async (done) => { it(`FMS_acquireForm_1200`, 0, async (done) => {
console.info(`FMS_acquireForm_1200 start`); console.info(`FMS_acquireForm_1200 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formId1; let formId1;
let formId2; let formId2;
function delPublishCallBack() { function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_1200 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_acquireForm_1200 delPublishCallBack end');
console.info(`FMS_acquireForm_1200 end`);
done();
}, 1000);
}
function onAcquiredCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_1200 onAcquiredCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1200 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback) commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_1200"))
formId1 = data.data; formId1 = data.data;
console.info("!!!====>FMS_acquireForm_1200 onAcquiredCallBack formId1:====>" + formId1); console.info("!!!====>FMS_acquireForm_1200 onAcquiredCallBack formId1:====>" + formId1);
if (formId1 && formId2) { if (formId1 && formId2) {
...@@ -493,22 +417,13 @@ export default function test() { ...@@ -493,22 +417,13 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: formId1 data: formId1
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_1200", done));
} }
} }
function unSubscribeOnAcquiredCallback() { function onSupplyCallBack(_, data) {
console.info("====>FMS_acquireForm_1200 OnAcquired UnSubscribe CallBack====>");
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_1200 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
function onSupplyCallBack(err, data) {
if (data.parameters.kind == "onCreate") { if (data.parameters.kind == "onCreate") {
console.info("====>FMS_acquireForm_1200 onSupplyCallBack====>" + JSON.stringify(data)); console.info("====>FMS_acquireForm_1200 onSupplyCallBack====>" + JSON.stringify(data));
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_acquireForm_1200"));
let retData = JSON.parse(data.parameters.parameters); let retData = JSON.parse(data.parameters.parameters);
let bundleName = retData.bundleName; let bundleName = retData.bundleName;
...@@ -525,24 +440,18 @@ export default function test() { ...@@ -525,24 +440,18 @@ export default function test() {
expect(tempFormFlag).assertEqual(false); expect(tempFormFlag).assertEqual(false);
formId2 = retData.parameters['ohos.extra.param.key.form_identity']; formId2 = retData.parameters['ohos.extra.param.key.form_identity'];
console.info("!!!====>FMS_acquireForm_1200 onAcquiredCallBack formId2:====>" + formId2); console.info("!!!====>FMS_acquireForm_1200 onSupplyCallBack formId2:====>" + formId2);
if (formId1 && formId2) { if (formId1 && formId2) {
expect(formId1).assertEqual(formId2); expect(formId1).assertEqual(formId2);
let commonEventPublishData = { let commonEventPublishData = {
data: formId1 data: formId1
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_1200", done));
} }
} }
} }
function unSubscribeSupplyCallback() { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.info("====>FMS_acquireForm_1200 unSubscribeSupplyCallback====>"); commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
}
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.info("====>FMS_acquireForm_1200 onSupplyEvent Subscriber====>");
subscriberSupply = data;
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
console.info(`FMS_acquireForm_1200 featureAbility.startAbility start`); console.info(`FMS_acquireForm_1200 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -572,44 +481,27 @@ export default function test() { ...@@ -572,44 +481,27 @@ export default function test() {
*/ */
it(`FMS_acquireForm_1400`, 0, async (done) => { it(`FMS_acquireForm_1400`, 0, async (done) => {
console.info(`FMS_acquireForm_1400 start`); console.info(`FMS_acquireForm_1400 start`);
var subscriberOnAcquired;
var subscriberOnError;
var formId; var formId;
function delPublishCallBack() { function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_1400 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_acquireForm_1400 delPublishCallBack end');
console.info(`FMS_acquireForm_1400 end`);
done();
}, 1000)
}
function onErrorCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_1400 onErrorCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1400 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent"); expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
expect(data.data).assertEqual("the requested form id is not existed on fms."); expect(data.data).assertEqual("the requested form id is not existed on fms.");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallBackCache); commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallBackCache("FMS_acquireForm_1400"));
var commonEventPublishData = { var commonEventPublishData = {
data: formId data: formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_1400", done));
} }
function unSubscribeOnErrorCallBackCache() { async function onAcquiredCallBack(_, data) {
console.info("====>FMS_acquireForm_1400 unSubscribeOnErrorCallBackCache CallBack====>");
}
function onAcquiredCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_1400 onAcquiredCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1400 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback) commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_1400"))
formId = data.data; formId = data.data;
// add cache form // add cache form
commonEvent.createSubscriber(onErrorForm_Event).then(async (data1) => { commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info("====>FMS_acquireForm_1400 onErrorForm_Event Subscriber====>");
subscriberOnError = data1;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
console.info(`FMS_acquireForm_1400 featureAbility.startAbility again start`); console.info(`FMS_acquireForm_1400 featureAbility.startAbility again start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhost", bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility", abilityName: "com.ohos.st.formsystemhost.MainAbility",
...@@ -630,16 +522,8 @@ export default function test() { ...@@ -630,16 +522,8 @@ export default function test() {
}); });
console.info(`FMS_acquireForm_1400 featureAbility.startAbility again end`); console.info(`FMS_acquireForm_1400 featureAbility.startAbility again end`);
} }
function unSubscribeOnAcquiredCallback() {
console.info("====>FMS_acquireForm_1400 unSubscribeOnAcquiredCallback====>");
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_1400 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.info(`FMS_acquireForm_1400 featureAbility.startAbility start`); console.info(`FMS_acquireForm_1400 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -669,23 +553,13 @@ export default function test() { ...@@ -669,23 +553,13 @@ export default function test() {
*/ */
it(`FMS_acquireForm_1500`, 0, async (done) => { it(`FMS_acquireForm_1500`, 0, async (done) => {
console.info(`FMS_acquireForm_1500 start`); console.info(`FMS_acquireForm_1500 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formId1; let formId1;
let formId2; let formId2;
let onCreateCount = 0; let onCreateCount = 0;
function delPublishCallBack() { function onAcquiredCallBackCache(_, data) {
console.info("!!!====>FMS_acquireForm_1500 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_acquireForm_1500 delPublishCallBack end');
console.info(`FMS_acquireForm_1500 end`);
done();
}, 1000)
}
function onAcquiredCallBackCache(err, data) {
console.info("!!!====>FMS_acquireForm_1500 onAcquiredCallBackCache data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1500 onAcquiredCallBackCache data:====>" + JSON.stringify(data));
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBackCache); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallBackCache("FMS_acquireForm_1500"));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
formId2 = data.data; formId2 = data.data;
if (formId1 && formId2) { if (formId1 && formId2) {
...@@ -693,25 +567,19 @@ export default function test() { ...@@ -693,25 +567,19 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: formId1 data: formId1
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_1500", done));
} }
} }
function unSubscribeOnAcquiredCallBackCache() { async function onAcquiredCallBack(_, data) {
console.info("====>FMS_acquireForm_1500 OnAcquired Cache UnSubscribe CallBack====>");
}
function onAcquiredCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_1500 onAcquiredCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1500 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback) commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_1500"))
formId1 = data.data; formId1 = data.data;
// add cache form // add cache form
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data1) => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
console.info("====>FMS_acquireForm_1500 Create OnAcquired Subscriber====>"); commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBackCache);
subscriberOnAcquired = data1;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBackCache);
});
console.info(`FMS_acquireForm_1500 featureAbility.startAbility again start`); console.info(`FMS_acquireForm_1500 featureAbility.startAbility again start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhostb", bundleName: "com.ohos.st.formsystemhostb",
abilityName: "com.ohos.st.formsystemhostb.MainAbility", abilityName: "com.ohos.st.formsystemhostb.MainAbility",
...@@ -732,40 +600,26 @@ export default function test() { ...@@ -732,40 +600,26 @@ export default function test() {
}); });
console.info(`FMS_acquireForm_1500 featureAbility.startAbility again end`); console.info(`FMS_acquireForm_1500 featureAbility.startAbility again end`);
} }
function unSubscribeOnAcquiredCallback() {
console.info("====>FMS_acquireForm_1500 OnAcquired UnSubscribe CallBack====>");
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.info("====>FMS_acquireForm_1500 Create OnAcquired Subscriber====>"); function onSupplyCallBack(_, data) {
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
function onSupplyCallBack(err, data) {
if (data.parameters.kind == "onCreate") { if (data.parameters.kind == "onCreate") {
console.info("====>FMS_acquireForm_1500 onSupplyCallBack====>" + JSON.stringify(data)); console.info("====>FMS_acquireForm_1500 onSupplyCallBack====>" + JSON.stringify(data));
onCreateCount++; onCreateCount++;
if (onCreateCount == 2) { if (onCreateCount == 2) {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback) commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_acquireForm_1500"))
} }
if (formId1 && formId2) { if (formId1 && formId2) {
expect(formId1).assertEqual(formId2); expect(formId1).assertEqual(formId2);
let commonEventPublishData = { let commonEventPublishData = {
data: formId1 data: formId1
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_1500", done));
} }
} }
} }
function unSubscribeSupplyCallback() {
console.info("====>FMS_acquireForm_1500 unSubscribeSupplyCallback====>");
}
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.info("====>FMS_acquireForm_1500 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
console.info(`FMS_acquireForm_1500 featureAbility.startAbility start`); console.info(`FMS_acquireForm_1500 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -798,8 +652,6 @@ export default function test() { ...@@ -798,8 +652,6 @@ export default function test() {
it(`FMS_acquireForm_1600`, 0, async (done) => { it(`FMS_acquireForm_1600`, 0, async (done) => {
console.info(`FMS_acquireForm_1600 start`); console.info(`FMS_acquireForm_1600 start`);
var subscriberOnAcquired;
function delPublishCallBack_Normal1() { function delPublishCallBack_Normal1() {
console.info("!!!====>FMS_acquireForm_1600 delPublishCallBack_Normal1====>"); console.info("!!!====>FMS_acquireForm_1600 delPublishCallBack_Normal1====>");
setTimeout(function () { setTimeout(function () {
...@@ -807,7 +659,7 @@ export default function test() { ...@@ -807,7 +659,7 @@ export default function test() {
FMS_acquireForm_1600_normal2(); FMS_acquireForm_1600_normal2();
}, 50); }, 50);
} }
function onAcquiredCallBack_Normal1(err, data) { function onAcquiredCallBack_Normal1(_, data) {
console.info("!!!====>FMS_acquireForm_1600 onAcquiredCallBack_Normal1 data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1600 onAcquiredCallBack_Normal1 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal1) commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal1)
...@@ -821,16 +673,11 @@ export default function test() { ...@@ -821,16 +673,11 @@ export default function test() {
console.info("====>FMS_acquireForm_1600 unSubscribeOnAcquiredCallBack_Normal1 CallBack====>"); console.info("====>FMS_acquireForm_1600 unSubscribeOnAcquiredCallBack_Normal1 CallBack====>");
} }
function FMS_acquireForm_1600_normal1() { async function FMS_acquireForm_1600_normal1() {
console.info(`FMS_acquireForm_1600_normal1 start`); console.info(`FMS_acquireForm_1600_normal1 start`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1);
console.info("====>FMS_acquireForm_1600_normal1 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1);
});
console.info(`FMS_acquireForm_1600_normal1 featureAbility.startAbility start`); console.info(`FMS_acquireForm_1600_normal1 featureAbility.startAbility start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhost", bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility", abilityName: "com.ohos.st.formsystemhost.MainAbility",
...@@ -861,7 +708,7 @@ export default function test() { ...@@ -861,7 +708,7 @@ export default function test() {
FMS_acquireForm_1600_Temp1(); FMS_acquireForm_1600_Temp1();
}, 50); }, 50);
} }
function onAcquiredCallBack_Normal2(err, data) { function onAcquiredCallBack_Normal2(_, data) {
console.info("!!!====>FMS_acquireForm_1600 onAcquiredCallBack_Normal2 data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1600 onAcquiredCallBack_Normal2 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal2) commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal2)
...@@ -874,16 +721,12 @@ export default function test() { ...@@ -874,16 +721,12 @@ export default function test() {
function unSubscribeOnAcquiredCallBack_Normal2() { function unSubscribeOnAcquiredCallBack_Normal2() {
console.info("====>FMS_acquireForm_1600 unSubscribeOnAcquiredCallBack_Normal2====>"); console.info("====>FMS_acquireForm_1600 unSubscribeOnAcquiredCallBack_Normal2====>");
} }
function FMS_acquireForm_1600_normal2() { async function FMS_acquireForm_1600_normal2() {
console.info(`FMS_acquireForm_1600_normal2 start`); console.info(`FMS_acquireForm_1600_normal2 start`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
console.info("====>FMS_acquireForm_1600_normal2 Create OnAcquired Subscriber====>"); commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
});
console.info(`FMS_acquireForm_1600_normal2 featureAbility.startAbility start`); console.info(`FMS_acquireForm_1600_normal2 featureAbility.startAbility start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhost", bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility", abilityName: "com.ohos.st.formsystemhost.MainAbility",
...@@ -914,7 +757,7 @@ export default function test() { ...@@ -914,7 +757,7 @@ export default function test() {
FMS_acquireForm_1600_Temp2(); FMS_acquireForm_1600_Temp2();
}, 50); }, 50);
} }
function onAcquiredCallBack_Temp1(err, data) { function onAcquiredCallBack_Temp1(_, data) {
console.info("!!!====>FMS_acquireForm_1600 onAcquiredCallBack_Temp1 data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1600 onAcquiredCallBack_Temp1 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Temp1) commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Temp1)
...@@ -928,16 +771,12 @@ export default function test() { ...@@ -928,16 +771,12 @@ export default function test() {
console.info("====>FMS_acquireForm_1600 unSubscribeOnAcquiredCallBack_Temp1====>"); console.info("====>FMS_acquireForm_1600 unSubscribeOnAcquiredCallBack_Temp1====>");
} }
function FMS_acquireForm_1600_Temp1() { async function FMS_acquireForm_1600_Temp1() {
console.info(`FMS_acquireForm_1600_Temp1 start`); console.info(`FMS_acquireForm_1600_Temp1 start`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
console.info("====>FMS_acquireForm_1600_Temp1 Create OnAcquired Subscriber====>"); commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp1);
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp1);
});
console.info(`FMS_acquireForm_1600_Temp1 featureAbility.startAbility start`); console.info(`FMS_acquireForm_1600_Temp1 featureAbility.startAbility start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhost", bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility", abilityName: "com.ohos.st.formsystemhost.MainAbility",
...@@ -970,7 +809,7 @@ export default function test() { ...@@ -970,7 +809,7 @@ export default function test() {
done(); done();
}, 500); }, 500);
} }
function onAcquiredCallBack_Temp2(err, data) { function onAcquiredCallBack_Temp2(_, data) {
console.info("!!!====>FMS_acquireForm_1600 onAcquiredCallBack_Temp2 data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1600 onAcquiredCallBack_Temp2 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Temp2) commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Temp2)
...@@ -984,16 +823,12 @@ export default function test() { ...@@ -984,16 +823,12 @@ export default function test() {
console.info("====>FMS_acquireForm_1600 unSubscribeOnAcquiredCallBack_Temp2====>"); console.info("====>FMS_acquireForm_1600 unSubscribeOnAcquiredCallBack_Temp2====>");
} }
function FMS_acquireForm_1600_Temp2() { async function FMS_acquireForm_1600_Temp2() {
console.info(`FMS_acquireForm_1600_Temp2 start`); console.info(`FMS_acquireForm_1600_Temp2 start`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
console.info("====>FMS_acquireForm_1600_Temp2 Create OnAcquired Subscriber====>"); commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp2);
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp2);
});
console.info(`FMS_acquireForm_1600_Temp2 featureAbility.startAbility start`); console.info(`FMS_acquireForm_1600_Temp2 featureAbility.startAbility start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhost", bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility", abilityName: "com.ohos.st.formsystemhost.MainAbility",
...@@ -1028,8 +863,6 @@ export default function test() { ...@@ -1028,8 +863,6 @@ export default function test() {
it(`FMS_acquireForm_1800`, 0, async (done) => { it(`FMS_acquireForm_1800`, 0, async (done) => {
console.info(`FMS_acquireForm_1800 start`); console.info(`FMS_acquireForm_1800 start`);
var subscriberOnAcquired;
function delPublishCallBack_Normal1() { function delPublishCallBack_Normal1() {
console.info("!!!====>FMS_acquireForm_1800 delPublishCallBack_Normal1====>"); console.info("!!!====>FMS_acquireForm_1800 delPublishCallBack_Normal1====>");
setTimeout(function () { setTimeout(function () {
...@@ -1037,7 +870,7 @@ export default function test() { ...@@ -1037,7 +870,7 @@ export default function test() {
FMS_acquireForm_1800_normal2(); FMS_acquireForm_1800_normal2();
}, 50); }, 50);
} }
function onAcquiredCallBack_Normal1(err, data) { function onAcquiredCallBack_Normal1(_, data) {
console.info("!!!====>FMS_acquireForm_1800 onAcquiredCallBack_Normal1 data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1800 onAcquiredCallBack_Normal1 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal1) commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal1)
...@@ -1051,16 +884,12 @@ export default function test() { ...@@ -1051,16 +884,12 @@ export default function test() {
console.info("====>FMS_acquireForm_1800 unSubscribeOnAcquiredCallBack_Normal1 CallBack====>"); console.info("====>FMS_acquireForm_1800 unSubscribeOnAcquiredCallBack_Normal1 CallBack====>");
} }
function FMS_acquireForm_1800_normal1() { async function FMS_acquireForm_1800_normal1() {
console.info(`FMS_acquireForm_1800_normal1 start`); console.info(`FMS_acquireForm_1800_normal1 start`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1);
console.info("====>FMS_acquireForm_1800_normal1 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1);
});
console.info(`FMS_acquireForm_1800_normal1 featureAbility.startAbility start`); console.info(`FMS_acquireForm_1800_normal1 featureAbility.startAbility start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhost", bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility", abilityName: "com.ohos.st.formsystemhost.MainAbility",
...@@ -1091,7 +920,7 @@ export default function test() { ...@@ -1091,7 +920,7 @@ export default function test() {
FMS_acquireForm_1800_Temp1(); FMS_acquireForm_1800_Temp1();
}, 50); }, 50);
} }
function onAcquiredCallBack_Normal2(err, data) { function onAcquiredCallBack_Normal2(_, data) {
console.info("!!!====>FMS_acquireForm_1800 onAcquiredCallBack_Normal2 data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1800 onAcquiredCallBack_Normal2 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal2) commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal2)
...@@ -1104,16 +933,13 @@ export default function test() { ...@@ -1104,16 +933,13 @@ export default function test() {
function unSubscribeOnAcquiredCallBack_Normal2() { function unSubscribeOnAcquiredCallBack_Normal2() {
console.info("====>FMS_acquireForm_1800 unSubscribeOnAcquiredCallBack_Normal2====>"); console.info("====>FMS_acquireForm_1800 unSubscribeOnAcquiredCallBack_Normal2====>");
} }
function FMS_acquireForm_1800_normal2() { async function FMS_acquireForm_1800_normal2() {
console.info(`FMS_acquireForm_1800_normal2 start`); console.info(`FMS_acquireForm_1800_normal2 start`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
console.info("====>FMS_acquireForm_1800_normal2 Create OnAcquired Subscriber====>"); commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
});
console.info(`FMS_acquireForm_1800_normal2 featureAbility.startAbility start`); console.info(`FMS_acquireForm_1800_normal2 featureAbility.startAbility start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhostb", bundleName: "com.ohos.st.formsystemhostb",
abilityName: "com.ohos.st.formsystemhostb.MainAbility", abilityName: "com.ohos.st.formsystemhostb.MainAbility",
...@@ -1144,7 +970,7 @@ export default function test() { ...@@ -1144,7 +970,7 @@ export default function test() {
FMS_acquireForm_1800_Temp2(); FMS_acquireForm_1800_Temp2();
}, 50); }, 50);
} }
function onAcquiredCallBack_Temp1(err, data) { function onAcquiredCallBack_Temp1(_, data) {
console.info("!!!====>FMS_acquireForm_1800 onAcquiredCallBack_Temp1 data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1800 onAcquiredCallBack_Temp1 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Temp1) commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Temp1)
...@@ -1158,16 +984,12 @@ export default function test() { ...@@ -1158,16 +984,12 @@ export default function test() {
console.info("====>FMS_acquireForm_1800 unSubscribeOnAcquiredCallBack_Temp1====>"); console.info("====>FMS_acquireForm_1800 unSubscribeOnAcquiredCallBack_Temp1====>");
} }
function FMS_acquireForm_1800_Temp1() { async function FMS_acquireForm_1800_Temp1() {
console.info(`FMS_acquireForm_1800_Temp1 start`); console.info(`FMS_acquireForm_1800_Temp1 start`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
console.info("====>FMS_acquireForm_1800_Temp1 Create OnAcquired Subscriber====>"); commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp1);
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp1);
});
console.info(`FMS_acquireForm_1800_Temp1 featureAbility.startAbility start`); console.info(`FMS_acquireForm_1800_Temp1 featureAbility.startAbility start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhost", bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility", abilityName: "com.ohos.st.formsystemhost.MainAbility",
...@@ -1199,7 +1021,7 @@ export default function test() { ...@@ -1199,7 +1021,7 @@ export default function test() {
done(); done();
}, 500); }, 500);
} }
function onAcquiredCallBack_Temp2(err, data) { function onAcquiredCallBack_Temp2(_, data) {
console.info("!!!====>FMS_acquireForm_1800 onAcquiredCallBack_Temp2 data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1800 onAcquiredCallBack_Temp2 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Temp2) commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Temp2)
...@@ -1213,16 +1035,13 @@ export default function test() { ...@@ -1213,16 +1035,13 @@ export default function test() {
console.info("====>FMS_acquireForm_1800 unSubscribeOnAcquiredCallBack_Temp2====>"); console.info("====>FMS_acquireForm_1800 unSubscribeOnAcquiredCallBack_Temp2====>");
} }
function FMS_acquireForm_1800_Temp2() { async function FMS_acquireForm_1800_Temp2() {
console.info(`FMS_acquireForm_1800_Temp2 start`); console.info(`FMS_acquireForm_1800_Temp2 start`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
console.info("====>FMS_acquireForm_1800_Temp2 Create OnAcquired Subscriber====>"); commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp2);
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp2);
});
console.info(`FMS_acquireForm_1800_Temp2 featureAbility.startAbility start`); console.info(`FMS_acquireForm_1800_Temp2 featureAbility.startAbility start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhostb", bundleName: "com.ohos.st.formsystemhostb",
abilityName: "com.ohos.st.formsystemhostb.MainAbility", abilityName: "com.ohos.st.formsystemhostb.MainAbility",
...@@ -1256,23 +1075,13 @@ export default function test() { ...@@ -1256,23 +1075,13 @@ export default function test() {
*/ */
it(`FMS_acquireForm_1900`, 0, async (done) => { it(`FMS_acquireForm_1900`, 0, async (done) => {
console.info(`FMS_acquireForm_1900 start`); console.info(`FMS_acquireForm_1900 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formId1; let formId1;
let formId2; let formId2;
function delPublishCallBack() { function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_1900 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_acquireForm_1900 delPublishCallBack end');
console.info(`FMS_acquireForm_1900 end`);
done();
}, 500);
}
function onAcquiredCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_1900 onAcquiredCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_1900 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack) commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_1900"))
formId1 = data.data; formId1 = data.data;
if (formId1 && formId2) { if (formId1 && formId2) {
...@@ -1280,23 +1089,16 @@ export default function test() { ...@@ -1280,23 +1089,16 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: formId1 data: formId1
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_1900", done));
} }
} }
function unSubscribeOnAcquiredCallBack() {
console.info("====>FMS_acquireForm_1900 unSubscribeOnAcquiredCallBack====>");
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.info("====>FMS_acquireForm_1900 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
function onSupplyCallBack(err, data) { function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onCreate") { if (data.parameters.kind == "onCreate") {
console.info("====>FMS_acquireForm_1900 onSupplyCallBack====>" + JSON.stringify(data)); console.info("====>FMS_acquireForm_1900 onSupplyCallBack====>" + JSON.stringify(data));
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_acquireForm_1900"));
let retData = JSON.parse(data.parameters.parameters); let retData = JSON.parse(data.parameters.parameters);
let bundleName = retData.bundleName; let bundleName = retData.bundleName;
...@@ -1318,22 +1120,15 @@ export default function test() { ...@@ -1318,22 +1120,15 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: formId1 data: formId1
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_1900", done));
} }
} }
} }
function unSubscribeSupplyCallback() {
console.info("====>FMS_acquireForm_1900 unSubscribeSupplyCallback====>");
}
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.info("====>FMS_acquireForm_1900 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
console.info(`FMS_acquireForm_1900 featureAbility.startAbility start`); console.info(`FMS_acquireForm_1900 featureAbility.startAbility start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhost", bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility", abilityName: "com.ohos.st.formsystemhost.MainAbility",
...@@ -1362,44 +1157,27 @@ export default function test() { ...@@ -1362,44 +1157,27 @@ export default function test() {
*/ */
it(`FMS_acquireForm_2100`, 0, async (done) => { it(`FMS_acquireForm_2100`, 0, async (done) => {
console.info(`FMS_acquireForm_2100 start`); console.info(`FMS_acquireForm_2100 start`);
var subscriberOnAcquired;
var subscriberOnError;
var formId; var formId;
function delPublishCallBack() { function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_2100 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_acquireForm_2100 delPublishCallBack end');
console.info(`FMS_acquireForm_2100 end`);
done();
}, 1000)
}
function onErrorCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_2100 onErrorCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_2100 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent"); expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
expect(data.data).assertEqual("invalid params received on operating form."); expect(data.data).assertEqual("invalid params received on operating form.");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallBackCache); commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallBackCache("FMS_acquireForm_2100"));
var commonEventPublishData = { var commonEventPublishData = {
data: formId data: formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_2100", done));
} }
function unSubscribeOnErrorCallBackCache() { async function onAcquiredCallBack(_, data) {
console.info("====>FMS_acquireForm_2100 unSubscribeOnErrorCallBackCache CallBack====>");
}
function onAcquiredCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_2100 onAcquiredCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_2100 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback) commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_2100"))
formId = data.data; formId = data.data;
// add cache form // add cache form
commonEvent.createSubscriber(onErrorForm_Event).then(async (data1) => { commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info("====>FMS_acquireForm_2100 onErrorForm_Event Subscriber====>");
subscriberOnError = data1;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
console.info(`FMS_acquireForm_2100 featureAbility.startAbility again start`); console.info(`FMS_acquireForm_2100 featureAbility.startAbility again start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhost", bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility", abilityName: "com.ohos.st.formsystemhost.MainAbility",
...@@ -1420,16 +1198,8 @@ export default function test() { ...@@ -1420,16 +1198,8 @@ export default function test() {
}); });
console.info(`FMS_acquireForm_2100 featureAbility.startAbility again end`); console.info(`FMS_acquireForm_2100 featureAbility.startAbility again end`);
} }
function unSubscribeOnAcquiredCallback() {
console.info("====>FMS_acquireForm_2100 unSubscribeOnAcquiredCallback====>");
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_2100 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.info(`FMS_acquireForm_2100 featureAbility.startAbility start`); console.info(`FMS_acquireForm_2100 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -1459,39 +1229,19 @@ export default function test() { ...@@ -1459,39 +1229,19 @@ export default function test() {
*/ */
it(`FMS_acquireForm_2200`, 0, async (done) => { it(`FMS_acquireForm_2200`, 0, async (done) => {
console.info(`FMS_acquireForm_2200 start`); console.info(`FMS_acquireForm_2200 start`);
var subscriberCast;
var subscriberOnError;
var formId;
function delPublishCallBack() { function onCastCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_2200 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_acquireForm_2200 delPublishCallBack end');
console.info(`FMS_acquireForm_2200 end`);
done();
}, 1000)
}
function onCastCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_2200 onCastCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_2200 onCastCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormCast_commonEvent"); expect(data.event).assertEqual("FMS_FormCast_commonEvent");
expect(data.data != "0").assertEqual(true); expect(data.data != "0").assertEqual(true);
commonEvent.unsubscribe(subscriberCast, unSubscribeOnCastCallback) commonEvent.unsubscribe(subscriberCast, () => unsubscribeOnCastCallback("FMS_acquireForm_2200"))
var commonEventPublishData = { var commonEventPublishData = {
data: data.parameters.formId data: data.parameters.formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_2200", done));
}
function unSubscribeOnCastCallback() {
console.info("====>FMS_acquireForm_2200 unSubscribeOnCastCallback====>");
} }
commonEvent.createSubscriber(subscriberFormCastEvent).then(async (data) => { commonEvent.subscribe(subscriberCast, onCastCallBack);
console.info("====>FMS_acquireForm_2200 subscriberFormCastEvent Subscriber====>");
subscriberCast = data;
await commonEvent.subscribe(subscriberCast, onCastCallBack);
});
console.info(`FMS_acquireForm_2200 featureAbility.startAbility start`); console.info(`FMS_acquireForm_2200 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -1523,38 +1273,18 @@ export default function test() { ...@@ -1523,38 +1273,18 @@ export default function test() {
*/ */
it(`FMS_acquireForm_2300`, 0, async (done) => { it(`FMS_acquireForm_2300`, 0, async (done) => {
console.info(`FMS_acquireForm_2300 start`); console.info(`FMS_acquireForm_2300 start`);
var subscriberCast;
var formId;
function delPublishCallBack() {
console.info("!!!====>FMS_acquireForm_2300 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_acquireForm_2300 delPublishCallBack end');
console.info(`FMS_acquireForm_2300 end`);
done();
}, 1000)
}
function onCastCallBack(err, data) { function onCastCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_2300 onCastCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_2300 onCastCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormCast_commonEvent"); expect(data.event).assertEqual("FMS_FormCast_commonEvent");
expect(data.data != "0").assertEqual(true); expect(data.data != "0").assertEqual(true);
commonEvent.unsubscribe(subscriberCast, unSubscribeOnCastCallback) commonEvent.unsubscribe(subscriberCast, () => unsubscribeOnCastCallback("FMS_acquireForm_2300"))
var commonEventPublishData = { var commonEventPublishData = {
data: data.parameters.formId data: data.parameters.formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_2300", done));
} }
function unSubscribeOnCastCallback() { commonEvent.subscribe(subscriberCast, onCastCallBack);
console.info("====>FMS_acquireForm_2300 unSubscribeOnCastCallback====>");
}
commonEvent.createSubscriber(subscriberFormCastEvent).then(async (data) => {
console.info("====>FMS_acquireForm_2300 subscriberFormCastEvent Subscriber====>");
subscriberCast = data;
await commonEvent.subscribe(subscriberCast, onCastCallBack);
});
console.info(`FMS_acquireForm_2300 featureAbility.startAbility start`); console.info(`FMS_acquireForm_2300 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -1586,44 +1316,24 @@ export default function test() { ...@@ -1586,44 +1316,24 @@ export default function test() {
*/ */
it(`FMS_acquireForm_2400`, 0, async (done) => { it(`FMS_acquireForm_2400`, 0, async (done) => {
console.info(`FMS_acquireForm_2400 start`); console.info(`FMS_acquireForm_2400 start`);
var subscriberOnAcquired;
var subscriberCast;
function delPublishCallBack() {
console.info("!!!====>FMS_acquireForm_2400 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_acquireForm_2400 delPublishCallBack end');
console.info(`FMS_acquireForm_2400 end`);
done();
}, 1000)
}
function onCastCallBack(err, data) { function onCastCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_2400 onCastCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_2400 onCastCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormCast_commonEvent"); expect(data.event).assertEqual("FMS_FormCast_commonEvent");
expect(data.data != "0").assertEqual(true); expect(data.data != "0").assertEqual(true);
commonEvent.unsubscribe(subscriberCast, unSubscribeOnCastCallback) commonEvent.unsubscribe(subscriberCast, () => unsubscribeOnCastCallback("FMS_acquireForm_2400"))
var commonEventPublishData = { var commonEventPublishData = {
data: data.parameters.formId data: data.parameters.formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_2400", done));
}
function unSubscribeOnCastCallback() {
console.info("====>FMS_acquireForm_2400 unSubscribeOnCastCallback====>");
} }
function onAcquiredCallBack(err, data) { async function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_2400 onAcquiredCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_2400 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback) commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_2400"))
commonEvent.subscribe(subscriberCast, onCastCallBack);
commonEvent.createSubscriber(subscriberFormCastEvent).then(async (data) => {
console.info("====>FMS_acquireForm_2400 subscriberFormCastEvent Subscriber====>");
subscriberCast = data;
await commonEvent.subscribe(subscriberCast, onCastCallBack);
});
console.info(`FMS_acquireForm_2400 featureAbility.startAbility again start`); console.info(`FMS_acquireForm_2400 featureAbility.startAbility again start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhostb", bundleName: "com.ohos.st.formsystemhostb",
abilityName: "com.ohos.st.formsystemhostb.MainAbility", abilityName: "com.ohos.st.formsystemhostb.MainAbility",
...@@ -1646,16 +1356,8 @@ export default function test() { ...@@ -1646,16 +1356,8 @@ export default function test() {
}); });
console.info(`FMS_acquireForm_2400 featureAbility.startAbility again end`); console.info(`FMS_acquireForm_2400 featureAbility.startAbility again end`);
} }
function unSubscribeOnAcquiredCallback() {
console.info("====>FMS_acquireForm_2400 OnAcquired UnSubscribe CallBack====>");
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_2400 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.info(`FMS_acquireForm_2400 featureAbility.startAbility start`); console.info(`FMS_acquireForm_2400 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -1685,38 +1387,18 @@ export default function test() { ...@@ -1685,38 +1387,18 @@ export default function test() {
*/ */
it(`FMS_acquireForm_2500`, 0, async (done) => { it(`FMS_acquireForm_2500`, 0, async (done) => {
console.info(`FMS_acquireForm_2500 start`); console.info(`FMS_acquireForm_2500 start`);
var subscriberCast;
var formId;
function delPublishCallBack() {
console.info("!!!====>FMS_acquireForm_2500 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_acquireForm_2500 delPublishCallBack end');
console.info(`FMS_acquireForm_2500 end`);
done();
}, 1000)
}
function onCastCallBack(err, data) { function onCastCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_2500 onCastCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_2500 onCastCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormCast_commonEvent"); expect(data.event).assertEqual("FMS_FormCast_commonEvent");
expect(data.data != "0").assertEqual(true); expect(data.data != "0").assertEqual(true);
commonEvent.unsubscribe(subscriberCast, unSubscribeOnCastCallback) commonEvent.unsubscribe(subscriberCast, () => unsubscribeOnCastCallback("FMS_acquireForm_2500"))
var commonEventPublishData = { var commonEventPublishData = {
data: data.parameters.formId data: data.parameters.formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_2500", done));
} }
function unSubscribeOnCastCallback() { commonEvent.subscribe(subscriberCast, onCastCallBack);
console.info("====>FMS_acquireForm_2500 unSubscribeOnCastCallback====>");
}
commonEvent.createSubscriber(subscriberFormCastEvent).then(async (data) => {
console.info("====>FMS_acquireForm_2500 subscriberFormCastEvent Subscriber====>");
subscriberCast = data;
await commonEvent.subscribe(subscriberCast, onCastCallBack);
});
console.info(`FMS_acquireForm_2500 featureAbility.startAbility start`); console.info(`FMS_acquireForm_2500 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -1749,46 +1431,31 @@ export default function test() { ...@@ -1749,46 +1431,31 @@ export default function test() {
*/ */
it(`FMS_acquireForm_2600`, 0, async (done) => { it(`FMS_acquireForm_2600`, 0, async (done) => {
console.info(`FMS_acquireForm_2600 start`); console.info(`FMS_acquireForm_2600 start`);
let subscriberOnAcquired;
let subscriberCast;
let subscriberSupply;
let formId1; let formId1;
let formId2; let formId2;
function delPublishCallBack() { function onCastCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_2600 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_acquireForm_2600 delPublishCallBack end');
console.info(`FMS_acquireForm_2600 end`);
done();
}, 1000)
}
function onCastCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_2600 onCastCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_2600 onCastCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormCast_commonEvent"); expect(data.event).assertEqual("FMS_FormCast_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberCast, unSubscribeOnCastCallback) commonEvent.unsubscribe(subscriberCast, () => unsubscribeOnCastCallback("FMS_acquireForm_2600"))
formId1 = data.parameters.formId; formId1 = data.parameters.formId;
if (formId1 && formId2) { if (formId1 && formId2) {
expect(formId1).assertEqual(formId2); expect(formId1).assertEqual(formId2);
let commonEventPublishData = { let commonEventPublishData = {
data: formId1 data: formId1
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_2600", done));
} }
} }
function unSubscribeOnCastCallback() {
console.info("====>FMS_acquireForm_2600 unSubscribeOnCastCallback====>");
}
function onAcquiredCallBack(err, data) { async function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_2600 onAcquiredCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_2600 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback) commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_2600"))
console.info(`FMS_acquireForm_2600 featureAbility.startAbility again start`); console.info(`FMS_acquireForm_2600 featureAbility.startAbility again start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhost", bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility", abilityName: "com.ohos.st.formsystemhost.MainAbility",
...@@ -1811,14 +1478,11 @@ export default function test() { ...@@ -1811,14 +1478,11 @@ export default function test() {
}); });
console.info(`FMS_acquireForm_2600 featureAbility.startAbility again end`); console.info(`FMS_acquireForm_2600 featureAbility.startAbility again end`);
} }
function unSubscribeOnAcquiredCallback() {
console.info("====>FMS_acquireForm_2600 OnAcquired UnSubscribe CallBack====>");
}
function onSupplyCallBack(err, data) { function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onCastToNormal") { if (data.parameters.kind == "onCastToNormal") {
console.info("====>FMS_acquireForm_2600 onSupplyCallBack====>" + JSON.stringify(data)); console.info("====>FMS_acquireForm_2600 onSupplyCallBack====>" + JSON.stringify(data));
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_acquireForm_2600"));
formId2 = data.parameters.parameters; formId2 = data.parameters.parameters;
if (formId1 && formId2) { if (formId1 && formId2) {
...@@ -1826,29 +1490,14 @@ export default function test() { ...@@ -1826,29 +1490,14 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: formId1 data: formId1
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_2600", done));
} }
} }
} }
function unSubscribeSupplyCallback() {
console.info("====>FMS_acquireForm_2600 unSubscribeSupplyCallback====>");
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.info("====>FMS_acquireForm_2600 Create OnAcquired Subscriber====>"); commonEvent.subscribe(subscriberCast, onCastCallBack);
subscriberOnAcquired = data; commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.createSubscriber(subscriberFormCastEvent).then(async (data) => {
console.info("====>FMS_acquireForm_2600 subscriberFormCastEvent Subscriber====>");
subscriberCast = data;
await commonEvent.subscribe(subscriberCast, onCastCallBack);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.info("====>FMS_acquireForm_2600 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
console.info(`FMS_acquireForm_2600 featureAbility.startAbility start`); console.info(`FMS_acquireForm_2600 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
...@@ -1874,3 +1523,43 @@ export default function test() { ...@@ -1874,3 +1523,43 @@ export default function test() {
}); });
}); });
} }
const sleep = async delay => {
return new Promise((resolve, _) => {
setTimeout(async () => {
resolve(0);
}, delay);
});
};
const delPublishCallBack = async (tcNumber, done) => {
console.info(`${tcNumber} delPublishCallBack start`);
setTimeout(function () {
console.info(`${tcNumber} delPublishCallBack end`);
done();
}, 1000);
}
const unsubscribeOnErrorCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unsubscribeOnErrorCallback====>`);
}
const unsubscribeOnAcquiredCallback = (tcNumber) => {
console.info(`====>${tcNumber} unSubscribeOnAcquiredCallback====>`);
}
const unsubscribeSupplyCallback = (tcNumber) => {
console.info(`====>${tcNumber} unSubscribeSupplyCallback====>`);
}
const unsubscribeOnErrorCallBackCache = (tcNumber) => {
console.info(`====>${tcNumber} unsubscribeOnErrorCallBackCache CallBack====>`);
}
const unsubscribeOnAcquiredCallBackCache = (tcNumber) => {
console.info(`====>${tcNumber} unsubscribeOnAcquiredCallBackCache CallBack====>`);
}
const unsubscribeOnCastCallback = (tcNumber) => {
console.info(`====>${tcNumber} unsubscribeOnCastCallback====>`);
}
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info( '[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async castTempToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempToNormal result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
console.info("[FormComponent] getAllFormsInfo start");
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
})
.catch((err) => {
console.info('[FormComponent] getAllFormsInfo error:' + JSON.stringify(err));
});
console.info("[FormComponent] getAllFormsInfo end");
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
bundleManager.cleanBundleCacheFiles('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
bundleManager.cleanBundleCacheFiles(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import featureAbility from "@ohos.ability.featureAbility"; import featureAbility from "@ohos.ability.featureAbility";
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import { describe, expect, it } from "deccjsunit/index.ets"; import { beforeEach, describe, expect, it } from "deccjsunit/index.ets";
var onErrorForm_Event = { var onErrorForm_Event = {
events: ["FMS_FormOnError_commonEvent"], events: ["FMS_FormOnError_commonEvent"],
...@@ -32,9 +32,21 @@ var onSupplyEvent = { ...@@ -32,9 +32,21 @@ var onSupplyEvent = {
var deleteForm_Event = "FMS_FormDelete_commonEvent"; var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnError;
var subscriberOnAcquired;
var subscriberCast;
var subscriberSupply;
export default function test() { export default function test() {
describe(`FmsAcquiredFormTest2`, () => { describe(`FmsAcquiredFormTest2`, () => {
beforeEach(async () => {
subscriberOnError = await commonEvent.createSubscriber(onErrorForm_Event);
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
subscriberCast = await commonEvent.createSubscriber(subscriberFormCastEvent);
subscriberSupply = await commonEvent.createSubscriber(onSupplyEvent);
})
/** /**
* @tc.number: FMS_acquireForm_3800 * @tc.number: FMS_acquireForm_3800
* @tc.name: Failed to add form when parameter ability is wrong. * @tc.name: Failed to add form when parameter ability is wrong.
...@@ -42,23 +54,15 @@ export default function test() { ...@@ -42,23 +54,15 @@ export default function test() {
*/ */
it(`FMS_acquireForm_3800`, 0, async (done) => { it(`FMS_acquireForm_3800`, 0, async (done) => {
console.info(`FMS_acquireForm_3800 start`); console.info(`FMS_acquireForm_3800 start`);
var subscriberOnError; function onErrorCallBack(_, data) {
function onErrorCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_3800 onErrorCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_3800 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent"); expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
expect(data.data).assertEqual("invalid params received on operating form."); expect(data.data).assertEqual("invalid params received on operating form.");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallback); commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallback("FMS_acquireForm_3800"));
console.info(`FMS_acquireForm_3800 end`); console.info(`FMS_acquireForm_3800 end`);
done(); done();
} }
function unSubscribeOnErrorCallback() { commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info("====>FMS_acquireForm_3800 unSubscribeOnErrorCallback CallBack====>");
}
commonEvent.createSubscriber(onErrorForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_3800 onErrorForm_Event Subscriber====>");
subscriberOnError = data;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
console.info(`FMS_acquireForm_3800 featureAbility.startAbility start`); console.info(`FMS_acquireForm_3800 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -88,23 +92,15 @@ export default function test() { ...@@ -88,23 +92,15 @@ export default function test() {
*/ */
it(`FMS_acquireForm_3900`, 0, async (done) => { it(`FMS_acquireForm_3900`, 0, async (done) => {
console.info(`FMS_acquireForm_3900 start`); console.info(`FMS_acquireForm_3900 start`);
var subscriberOnError; function onErrorCallBack(_, data) {
function onErrorCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_3900 onErrorCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_3900 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent"); expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
expect(data.data).assertEqual("invalid params received on operating form."); expect(data.data).assertEqual("invalid params received on operating form.");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallback); commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallback("FMS_acquireForm_3900"));
console.info(`FMS_acquireForm_3900 end`); console.info(`FMS_acquireForm_3900 end`);
done(); done();
} }
function unSubscribeOnErrorCallback() { commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info("====>FMS_acquireForm_3900 unSubscribeOnErrorCallback CallBack====>");
}
commonEvent.createSubscriber(onErrorForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_3900 onErrorForm_Event Subscriber====>");
subscriberOnError = data;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
console.info(`FMS_acquireForm_3900 featureAbility.startAbility start`); console.info(`FMS_acquireForm_3900 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -135,44 +131,26 @@ export default function test() { ...@@ -135,44 +131,26 @@ export default function test() {
*/ */
it(`FMS_acquireForm_4000`, 0, async (done) => { it(`FMS_acquireForm_4000`, 0, async (done) => {
console.info(`FMS_acquireForm_4000 start`); console.info(`FMS_acquireForm_4000 start`);
var subscriberOnAcquired;
var subscriberOnError;
var formId; var formId;
function delPublishCallBack() { function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_4000 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_acquireForm_4000 delPublishCallBack end');
console.info(`FMS_acquireForm_4000 end`);
done();
}, 1000)
}
function unSubscribeOnErrorCallback() {
console.info("!!!====>FMS_acquireForm_4000 unSubscribeOnErrorCallback====>");
}
function onErrorCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_4000 onErrorCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_4000 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent"); expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallback); commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallback("FMS_acquireForm_4000"));
expect(data.data).assertEqual("the form id and form config are not matched."); expect(data.data).assertEqual("the form id and form config are not matched.");
console.info(`FMS_acquireForm_4000 end`); console.info(`FMS_acquireForm_4000 end`);
var commonEventPublishData = { var commonEventPublishData = {
data: formId data: formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_4000", done));
} }
function onAcquiredCallBack(err, data) { function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_4000 onAcquiredCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_4000 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback) commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_4000"))
formId = data.data; formId = data.data;
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
commonEvent.createSubscriber(onErrorForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_4000 onErrorForm_Event Subscriber====>");
subscriberOnError = data;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
console.info(`FMS_acquireForm_4000 featureAbility.startAbility again start`); console.info(`FMS_acquireForm_4000 featureAbility.startAbility again start`);
featureAbility.startAbility({ featureAbility.startAbility({
...@@ -201,12 +179,7 @@ export default function test() { ...@@ -201,12 +179,7 @@ export default function test() {
console.info("====>FMS_acquireForm_4000 OnAcquired UnSubscribe CallBack====>"); console.info("====>FMS_acquireForm_4000 OnAcquired UnSubscribe CallBack====>");
} }
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.info("====>FMS_acquireForm_4000 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
console.info(`FMS_acquireForm_4000 featureAbility.startAbility start`); console.info(`FMS_acquireForm_4000 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -238,23 +211,15 @@ export default function test() { ...@@ -238,23 +211,15 @@ export default function test() {
*/ */
it(`FMS_acquireForm_4100`, 0, async (done) => { it(`FMS_acquireForm_4100`, 0, async (done) => {
console.info(`FMS_acquireForm_4100 start`); console.info(`FMS_acquireForm_4100 start`);
var subscriberOnError; function onErrorCallBack(_, data) {
function onErrorCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_4100 onErrorCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_4100 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent"); expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
expect(data.data).assertEqual("invalid params received on operating form."); expect(data.data).assertEqual("invalid params received on operating form.");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallback); commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallback("FMS_acquireForm_4100"));
console.info(`FMS_acquireForm_4100 end`); console.info(`FMS_acquireForm_4100 end`);
done(); done();
} }
function unSubscribeOnErrorCallback() { commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info("====>FMS_acquireForm_4100 unSubscribeOnErrorCallback CallBack====>");
}
commonEvent.createSubscriber(onErrorForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_4100 onErrorForm_Event Subscriber====>");
subscriberOnError = data;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
console.info(`FMS_acquireForm_4100 featureAbility.startAbility start`); console.info(`FMS_acquireForm_4100 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -286,23 +251,13 @@ export default function test() { ...@@ -286,23 +251,13 @@ export default function test() {
*/ */
it(`FMS_acquireForm_4200`, 0, async (done) => { it(`FMS_acquireForm_4200`, 0, async (done) => {
console.info(`FMS_acquireForm_4200 start`); console.info(`FMS_acquireForm_4200 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formId1; let formId1;
let formId2; let formId2;
function delPublishCallBack() { function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_4200 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_acquireForm_4200 delPublishCallBack end');
console.info(`FMS_acquireForm_4200 end`);
done();
}, 500);
}
function onAcquiredCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_4200 onAcquiredCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_4200 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack) commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_4200"))
formId1 = data.data; formId1 = data.data;
if (formId1 && formId2) { if (formId1 && formId2) {
...@@ -310,23 +265,15 @@ export default function test() { ...@@ -310,23 +265,15 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: formId1 data: formId1
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_4200", done));
} }
} }
function unSubscribeOnAcquiredCallBack() { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.info("====>FMS_acquireForm_4200 unSubscribeOnAcquiredCallBack====>");
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_4200 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
function onSupplyCallBack(err, data) { function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onCreate") { if (data.parameters.kind == "onCreate") {
console.info("====>FMS_acquireForm_4200 onSupplyCallBack====>" + JSON.stringify(data)); console.info("====>FMS_acquireForm_4200 onSupplyCallBack====>" + JSON.stringify(data));
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_acquireForm_4200"));
let retData = JSON.parse(data.parameters.parameters); let retData = JSON.parse(data.parameters.parameters);
let formName = retData.parameters['ohos.extra.param.key.form_name']; let formName = retData.parameters['ohos.extra.param.key.form_name'];
...@@ -338,22 +285,13 @@ export default function test() { ...@@ -338,22 +285,13 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: formId1 data: formId1
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_4200", done));
} }
} }
} }
function unSubscribeSupplyCallback() { commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.info("====>FMS_acquireForm_4200 unSubscribeSupplyCallback====>");
}
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.info("====>FMS_acquireForm_4200 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
console.info(`FMS_acquireForm_4200 featureAbility.startAbility start`); console.info(`FMS_acquireForm_4200 featureAbility.startAbility start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhost", bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility", abilityName: "com.ohos.st.formsystemhost.MainAbility",
...@@ -383,23 +321,15 @@ export default function test() { ...@@ -383,23 +321,15 @@ export default function test() {
*/ */
it(`FMS_acquireForm_4300`, 0, async (done) => { it(`FMS_acquireForm_4300`, 0, async (done) => {
console.info(`FMS_acquireForm_4300 start`); console.info(`FMS_acquireForm_4300 start`);
let subscriberOnAcquired; function onAcquiredCallBack(_, data) {
function onAcquiredCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_4300 onAcquiredCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_4300 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
expect(data.data != "0").assertEqual(true); expect(data.data != "0").assertEqual(true);
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_4300"));
console.info(`FMS_acquireForm_4300 end`); console.info(`FMS_acquireForm_4300 end`);
done(); done();
} }
function unSubscribeOnAcquiredCallBack() { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.info("====>FMS_acquireForm_4300 unSubscribeOnAcquiredCallBack CallBack====>");
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_4300 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
console.info(`FMS_acquireForm_4300 featureAbility.startAbility start`); console.info(`FMS_acquireForm_4300 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -430,24 +360,15 @@ export default function test() { ...@@ -430,24 +360,15 @@ export default function test() {
*/ */
it(`FMS_acquireForm_4400`, 0, async (done) => { it(`FMS_acquireForm_4400`, 0, async (done) => {
console.info(`FMS_acquireForm_4400 start`); console.info(`FMS_acquireForm_4400 start`);
var subscriberOnError; function onErrorCallBack(_, data) {
function onErrorCallBack(err, data) {
console.info("!!!====>FMS_acquireForm_4400 onErrorCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_4400 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent"); expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallback); commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallback("FMS_acquireForm_4400"));
expect(data.data).assertEqual("the dimension not exist in the form."); expect(data.data).assertEqual("the dimension not exist in the form.");
console.info(`FMS_acquireForm_4400 end`); console.info(`FMS_acquireForm_4400 end`);
done(); done();
} }
function unSubscribeOnErrorCallback() { commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info("====>FMS_acquireForm_4400 unSubscribeOnErrorCallback CallBack====>");
}
commonEvent.createSubscriber(onErrorForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_4400 onErrorForm_Event Subscriber====>");
subscriberOnError = data;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
console.info(`FMS_acquireForm_4400 featureAbility.startAbility start`); console.info(`FMS_acquireForm_4400 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -479,41 +400,22 @@ export default function test() { ...@@ -479,41 +400,22 @@ export default function test() {
*/ */
it(`FMS_acquireForm_4900`, 0, async (done) => { it(`FMS_acquireForm_4900`, 0, async (done) => {
console.info(`FMS_acquireForm_4900 start`); console.info(`FMS_acquireForm_4900 start`);
var subscriberOnAcquired;
var subscriberCast;
function delPublishCallBack() {
console.info("!!!====>FMS_acquireForm_4900 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_acquireForm_4900 delPublishCallBack end');
console.info(`FMS_acquireForm_4900 end`);
done();
}, 1000)
}
function onCastCallBack(err, data) { function onCastCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_4900 onCastCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_4900 onCastCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormCast_commonEvent"); expect(data.event).assertEqual("FMS_FormCast_commonEvent");
expect(data.data).assertEqual("9"); expect(data.data).assertEqual("9");
commonEvent.unsubscribe(subscriberCast, unSubscribeOnCastCallback) commonEvent.unsubscribe(subscriberCast, () => unsubscribeOnCastCallback("FMS_acquireForm_4900"))
var commonEventPublishData = { var commonEventPublishData = {
data: data.parameters.formId data: data.parameters.formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_4900", done));
}
function unSubscribeOnCastCallback() {
console.info("====>FMS_acquireForm_4900 unSubscribeOnCastCallback====>");
} }
function onAcquiredCallBack(err, data) { function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_4900 onAcquiredCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_acquireForm_4900 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback) commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_4900"))
commonEvent.subscribe(subscriberCast, onCastCallBack);
commonEvent.createSubscriber(subscriberFormCastEvent).then(async (data) => {
console.info("====>FMS_acquireForm_4900 subscriberFormCastEvent Subscriber====>");
subscriberCast = data;
await commonEvent.subscribe(subscriberCast, onCastCallBack);
});
console.info(`FMS_acquireForm_4900 featureAbility.startAbility again start`); console.info(`FMS_acquireForm_4900 featureAbility.startAbility again start`);
featureAbility.startAbility({ featureAbility.startAbility({
...@@ -539,16 +441,8 @@ export default function test() { ...@@ -539,16 +441,8 @@ export default function test() {
}); });
console.info(`FMS_acquireForm_4900 featureAbility.startAbility again end`); console.info(`FMS_acquireForm_4900 featureAbility.startAbility again end`);
} }
function unSubscribeOnAcquiredCallback() {
console.info("====>FMS_acquireForm_4900 OnAcquired UnSubscribe CallBack====>");
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_4900 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.info(`FMS_acquireForm_4900 featureAbility.startAbility start`); console.info(`FMS_acquireForm_4900 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -574,3 +468,28 @@ export default function test() { ...@@ -574,3 +468,28 @@ export default function test() {
}); });
} }
const delPublishCallBack = async (tcNumber, done) => {
console.info(`${tcNumber} delPublishCallBack start`);
setTimeout(function () {
console.info(`${tcNumber} delPublishCallBack end`);
done();
}, 1000);
}
const unsubscribeOnErrorCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unsubscribeOnErrorCallback====>`);
}
const unsubscribeOnAcquiredCallback = (tcNumber) => {
console.info(`====>${tcNumber} unSubscribeOnAcquiredCallback====>`);
}
const unsubscribeSupplyCallback = (tcNumber) => {
console.info(`====>${tcNumber} unSubscribeSupplyCallback====>`);
}
const unsubscribeOnCastCallback = (tcNumber) => {
console.info(`====>${tcNumber} unsubscribeOnCastCallback====>`);
}
...@@ -557,7 +557,7 @@ export default function test() { ...@@ -557,7 +557,7 @@ export default function test() {
}); });
} }
const delPublishCallBack = async (tcNumber, done) { const delPublishCallBack = async (tcNumber, done) => {
console.info(`${tcNumber} delPublishCallBack start`); console.info(`${tcNumber} delPublishCallBack start`);
setTimeout(function () { setTimeout(function () {
console.info(`${tcNumber} delPublishCallBack end`); console.info(`${tcNumber} delPublishCallBack end`);
...@@ -565,10 +565,10 @@ const delPublishCallBack = async (tcNumber, done) { ...@@ -565,10 +565,10 @@ const delPublishCallBack = async (tcNumber, done) {
}, 1000); }, 1000);
} }
const unsubscribeOnReleasedCallback = (tcNumber) { const unsubscribeOnReleasedCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unsubscribeOnReleasedCallback====>`); console.debug(`====>${tcNumber} unsubscribeOnReleasedCallback====>`);
} }
const unsubscribeOnAcquiredCallback = (tcNumber) { const unsubscribeOnAcquiredCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unsubscribeOnAcquiredCallback====>`); console.debug(`====>${tcNumber} unsubscribeOnAcquiredCallback====>`);
} }
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info( '[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async castTempToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempToNormal result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
console.info("[FormComponent] getAllFormsInfo start");
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
})
.catch((err) => {
console.info('[FormComponent] getAllFormsInfo error:' + JSON.stringify(err));
});
console.info("[FormComponent] getAllFormsInfo end");
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
bundleManager.cleanBundleCacheFiles('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
bundleManager.cleanBundleCacheFiles(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
...@@ -15,11 +15,8 @@ ...@@ -15,11 +15,8 @@
import featureAbility from "@ohos.ability.featureAbility"; import featureAbility from "@ohos.ability.featureAbility";
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import { beforeAll, describe, expect, it } from "deccjsunit/index.ets"; import { beforeAll, beforeEach, describe, expect, it } from "deccjsunit/index.ets";
var onErrorForm_Event = {
events: ["FMS_FormOnError_commonEvent"],
};
var onAcquiredForm_Event = { var onAcquiredForm_Event = {
events: ["FMS_FormOnAcquired_commonEvent"], events: ["FMS_FormOnAcquired_commonEvent"],
}; };
...@@ -38,6 +35,11 @@ var onSupplyEvent = { ...@@ -38,6 +35,11 @@ var onSupplyEvent = {
var deleteForm_Event = "FMS_FormDelete_commonEvent"; var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnAcquired;
var subscriberDel;
var subscriberOnState;
var subscriberSupply;
export default function test() { export default function test() {
describe(`FmsStateFormTest`, () => { describe(`FmsStateFormTest`, () => {
...@@ -45,6 +47,13 @@ export default function test() { ...@@ -45,6 +47,13 @@ export default function test() {
done(); done();
}) })
beforeEach(async () => {
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
subscriberDel = await commonEvent.createSubscriber(onDeletedFormEvent);
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
subscriberSupply = await commonEvent.createSubscriber(onSupplyEvent);
})
/** /**
* @tc.number: FMS_disableFormsUpdate_0200 * @tc.number: FMS_disableFormsUpdate_0200
* @tc.name: The form user does not have permission. * @tc.name: The form user does not have permission.
...@@ -53,29 +62,19 @@ export default function test() { ...@@ -53,29 +62,19 @@ export default function test() {
*/ */
it(`FMS_disableFormsUpdate_0200`, 0, async (done) => { it(`FMS_disableFormsUpdate_0200`, 0, async (done) => {
console.log(`FMS_disableFormsUpdate_0200 start`); console.log(`FMS_disableFormsUpdate_0200 start`);
let subscriberOnState; function onStateCallBack(_, data) {
function onStateCallBack(err, data) {
console.info("!!!====>FMS_disableFormsUpdate_0200 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_disableFormsUpdate_0200 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("2"); expect(data.data).assertEqual("2");
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallBack); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_disableFormsUpdate_0200"));
setTimeout(function () { setTimeout(function () {
console.info('FMS_disableFormsUpdate_0200 onStateCallBack end'); console.info('FMS_disableFormsUpdate_0200 onStateCallBack end');
console.log(`FMS_disableFormsUpdate_0200 end`); console.log(`FMS_disableFormsUpdate_0200 end`);
done(); done();
}, 1000) }, 1000)
} }
function unsubscribeOnStateCallBack() {
console.debug("====>FMS_disableFormsUpdate_0200 unsubscribeOnStateCallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_0200 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_disableFormsUpdate_0200 featureAbility.startAbility again start`); console.log(`FMS_disableFormsUpdate_0200 featureAbility.startAbility again start`);
featureAbility.startAbility({ featureAbility.startAbility({
want: { want: {
...@@ -108,13 +107,12 @@ export default function test() { ...@@ -108,13 +107,12 @@ export default function test() {
*/ */
it(`FMS_disableFormsUpdate_0300`, 0, async (done) => { it(`FMS_disableFormsUpdate_0300`, 0, async (done) => {
console.log(`FMS_disableFormsUpdate_0300 start`); console.log(`FMS_disableFormsUpdate_0300 start`);
let subscriberOnState;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_disableFormsUpdate_0300 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_disableFormsUpdate_0300 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("7"); expect(data.data).assertEqual("7");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_disableFormsUpdate_0300"))
setTimeout(function () { setTimeout(function () {
console.info('FMS_disableFormsUpdate_0300 delPublishCallBack end'); console.info('FMS_disableFormsUpdate_0300 delPublishCallBack end');
...@@ -122,15 +120,8 @@ export default function test() { ...@@ -122,15 +120,8 @@ export default function test() {
done(); done();
}, 100) }, 100)
} }
function unSubscribeOnStateCallback() {
console.debug("====>FMS_disableFormsUpdate_0300 unSubscribeOnStateCallback CallBack====>"); commonEvent.subscribe(subscriberOnState, onStateCallBack);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_0300 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_disableFormsUpdate_0300 featureAbility.startAbility start`); console.log(`FMS_disableFormsUpdate_0300 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -163,30 +154,20 @@ export default function test() { ...@@ -163,30 +154,20 @@ export default function test() {
*/ */
it(`FMS_disableFormsUpdate_0400`, 0, async (done) => { it(`FMS_disableFormsUpdate_0400`, 0, async (done) => {
console.log(`FMS_disableFormsUpdate_0400 start`); console.log(`FMS_disableFormsUpdate_0400 start`);
let subscriberOnState;
let formId;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_disableFormsUpdate_0400 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_disableFormsUpdate_0400 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("13"); expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_disableFormsUpdate_0400"))
setTimeout(function () { setTimeout(function () {
console.info('FMS_disableFormsUpdate_0400 delPublishCallBack end'); console.info('FMS_disableFormsUpdate_0400 delPublishCallBack end');
console.log(`FMS_disableFormsUpdate_0400 end`); console.log(`FMS_disableFormsUpdate_0400 end`);
done(); done();
}, 100) }, 100)
} }
function unSubscribeOnStateCallback() { commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.debug("====>FMS_disableFormsUpdate_0400 unSubscribeOnStateCallback CallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_0400 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_disableFormsUpdate_0400 featureAbility.startAbility start`); console.log(`FMS_disableFormsUpdate_0400 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -219,30 +200,20 @@ export default function test() { ...@@ -219,30 +200,20 @@ export default function test() {
*/ */
it(`FMS_disableFormsUpdate_0500`, 0, async (done) => { it(`FMS_disableFormsUpdate_0500`, 0, async (done) => {
console.log(`FMS_disableFormsUpdate_0500 start`); console.log(`FMS_disableFormsUpdate_0500 start`);
let subscriberOnState;
let formId;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_disableFormsUpdate_0500 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_disableFormsUpdate_0500 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("13"); expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_disableFormsUpdate_0500"))
setTimeout(function () { setTimeout(function () {
console.info('FMS_disableFormsUpdate_0500 delPublishCallBack end'); console.info('FMS_disableFormsUpdate_0500 delPublishCallBack end');
console.log(`FMS_disableFormsUpdate_0500 end`); console.log(`FMS_disableFormsUpdate_0500 end`);
done(); done();
}, 100) }, 100)
} }
function unSubscribeOnStateCallback() { commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.debug("====>FMS_disableFormsUpdate_0500 unSubscribeOnStateCallback CallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_0500 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_disableFormsUpdate_0500 featureAbility.startAbility start`); console.log(`FMS_disableFormsUpdate_0500 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -275,36 +246,24 @@ export default function test() { ...@@ -275,36 +246,24 @@ export default function test() {
*/ */
it(`FMS_disableFormsUpdate_0600`, 0, async (done) => { it(`FMS_disableFormsUpdate_0600`, 0, async (done) => {
console.info(`FMS_disableFormsUpdate_0600 start`); console.info(`FMS_disableFormsUpdate_0600 start`);
let subscriberOnAcquired;
let subscriberDisable;
let hostFormId; let hostFormId;
const delPublishCallback = (err, data) => { const onDisableCallback = (_, data) => {
console.info("!!!====>FMS_disableFormsUpdate_0600 delPublishCallback====>");
setTimeout(() => {
console.info('FMS_disableFormsUpdate_0600 delPublishCallback end');
console.info(`FMS_disableFormsUpdate_0600 end`);
done();
}, 1000);
}
const onDisableCallback = (err, data) => {
if (data.parameters.kind != "disable") { if (data.parameters.kind != "disable") {
return; return;
} }
console.debug("====>FMS_disableFormsUpdate_0600 onDisableCallback data:====>" + JSON.stringify(data)); console.debug("====>FMS_disableFormsUpdate_0600 onDisableCallback data:====>" + JSON.stringify(data));
expect(data.data).assertEqual("13"); expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberDisable, () => { commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnDisableCallback("FMS_disableFormsUpdate_0600"));
console.info("====>FMS_disableFormsUpdate_0600 unSubscribeOnDisableCallback====>"); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_disableFormsUpdate_0600"));
});
const commonEventPublishData = { const commonEventPublishData = {
data: hostFormId data: hostFormId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_disableFormsUpdate_0600", done));
} }
const onAcquiredCallBack = async (err, data) => { const onAcquiredCallBack = async (_, data) => {
console.debug("====>FMS_disableFormsUpdate_0600 onAcquiredCallback data:====>" + JSON.stringify(data)); console.debug("====>FMS_disableFormsUpdate_0600 onAcquiredCallback data:====>" + JSON.stringify(data));
hostFormId = data.data; hostFormId = data.data;
...@@ -329,22 +288,11 @@ export default function test() { ...@@ -329,22 +288,11 @@ export default function test() {
}).catch((err: any) => { }).catch((err: any) => {
console.debug(`FMS_disableFormsUpdate_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); console.debug(`FMS_disableFormsUpdate_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`);
}); });
commonEvent.unsubscribe(subscriberOnAcquired, () => { commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_disableFormsUpdate_0600"));
console.info("====>FMS_disableFormsUpdate_0600 unSubscribeOnAcquiredCallback====>");
});
} }
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.debug("====>FMS_disableFormsUpdate_0600 onAcquiredFormEvent Subscriber====>"); commonEvent.subscribe(subscriberOnState, onDisableCallback);
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.info("====>FMS_disableFormsUpdate_0600 onStateFormEvent Disable Subscriber====>");
subscriberDisable = data;
await commonEvent.subscribe(subscriberDisable, onDisableCallback);
});
console.info(`FMS_disableFormsUpdate_0600 featureAbility.startAbility start`); console.info(`FMS_disableFormsUpdate_0600 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -374,24 +322,22 @@ export default function test() { ...@@ -374,24 +322,22 @@ export default function test() {
*/ */
it(`FMS_disableFormsUpdate_0700`, 0, async (done) => { it(`FMS_disableFormsUpdate_0700`, 0, async (done) => {
console.info(`FMS_disableFormsUpdate_0700 start`); console.info(`FMS_disableFormsUpdate_0700 start`);
let subscriberDel;
let subscriberDisable;
let hostFormId; let hostFormId;
const onDisableCallback = (err, data) => { const onDisableCallback = (_, data) => {
if (data.parameters.kind != "disable") { if (data.parameters.kind != "disable") {
return; return;
} }
console.debug("====>FMS_disableFormsUpdate_0700 onDisableCallback data:====>" + JSON.stringify(data)); console.debug("====>FMS_disableFormsUpdate_0700 onDisableCallback data:====>" + JSON.stringify(data));
expect(data.data).assertEqual("13"); expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberDisable, () => { commonEvent.unsubscribe(subscriberOnState, () => {
console.info("====>FMS_disableFormsUpdate_0700 unSubscribeOnDisableCallback====>"); console.info("====>FMS_disableFormsUpdate_0700 unSubscribeOnDisableCallback====>");
}); });
done(); done();
} }
const onDeleteCallback = async (err, data) => { const onDeleteCallback = async (_, data) => {
console.debug("====>FMS_disableFormsUpdate_0700 onDeleteCallback data:====>" + JSON.stringify(data)); console.debug("====>FMS_disableFormsUpdate_0700 onDeleteCallback data:====>" + JSON.stringify(data));
hostFormId = data.parameters.formId; hostFormId = data.parameters.formId;
...@@ -422,17 +368,8 @@ export default function test() { ...@@ -422,17 +368,8 @@ export default function test() {
}); });
} }
commonEvent.createSubscriber(onDeletedFormEvent).then(async (data) => { commonEvent.subscribe(subscriberDel, onDeleteCallback);
console.info("====>FMS_disableFormsUpdate_0700 onDeletedFormEvent Invisible Subscriber====>"); commonEvent.subscribe(subscriberOnState, onDisableCallback);
subscriberDel = data;
await commonEvent.subscribe(subscriberDel, onDeleteCallback);
});
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.info("====>FMS_disableFormsUpdate_0700 onStateFormEvent Disable Subscriber====>");
subscriberDisable = data;
await commonEvent.subscribe(subscriberDisable, onDisableCallback);
});
console.info(`FMS_disableFormsUpdate_0700 featureAbility.startAbility start`); console.info(`FMS_disableFormsUpdate_0700 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -464,39 +401,21 @@ export default function test() { ...@@ -464,39 +401,21 @@ export default function test() {
*/ */
it(`FMS_disableFormsUpdate_0800`, 0, async (done) => { it(`FMS_disableFormsUpdate_0800`, 0, async (done) => {
console.log(`FMS_disableFormsUpdate_0800 start`); console.log(`FMS_disableFormsUpdate_0800 start`);
let subscriberOnState;
let subscriberOnAcquired;
let formId; let formId;
function delPublishCallBack() { function onStateCallBack(_, data) {
console.info("!!!====>FMS_disableFormsUpdate_0800 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_disableFormsUpdate_0800 delPublishCallBack end');
console.log(`FMS_disableFormsUpdate_0800 end`);
done();
}, 1000);
}
function onStateCallBack(err, data) {
console.info("!!!====>FMS_disableFormsUpdate_0800 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_disableFormsUpdate_0800 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
formId = data.parameters.formId; formId = data.parameters.formId;
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_disableFormsUpdate_0800"));
let commonEventPublishData = { let commonEventPublishData = {
data: formId data: formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_disableFormsUpdate_0800", done));
} }
function unsubscribeOnStateCallback() {
console.debug("====>FMS_disableFormsUpdate_0800 unsubscribeOnStateCallback====>"); commonEvent.subscribe(subscriberOnState, onStateCallBack);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_0800 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_disableFormsUpdate_0800 featureAbility.startAbility start`); console.log(`FMS_disableFormsUpdate_0800 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -530,48 +449,28 @@ export default function test() { ...@@ -530,48 +449,28 @@ export default function test() {
*/ */
it(`FMS_disableFormsUpdate_0900`, 0, async (done) => { it(`FMS_disableFormsUpdate_0900`, 0, async (done) => {
console.log(`FMS_disableFormsUpdate_0900 start`); console.log(`FMS_disableFormsUpdate_0900 start`);
let subscriberDisable;
let subscriberEnable;
let formId; let formId;
function delPublishCallBack(err, data) {
console.info("!!!====>FMS_disableFormsUpdate_0900 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_disableFormsUpdate_0900 delPublishCallBack end');
console.log(`FMS_disableFormsUpdate_0900 end`);
done();
}, 1000);
}
function unSubscribeOnDisableCallback() { function OnDisableCallBack(_, data) {
console.info("!!!====>FMS_disableFormsUpdate_0900 unSubscribeOnDisableCallback====>");
}
function OnDisableCallBack(err, data) {
console.info("!!!====>FMS_disableFormsUpdate_0900 OnDisableCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_disableFormsUpdate_0900 OnDisableCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberDisable, unSubscribeOnDisableCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnDisableCallback("FMS_disableFormsUpdate_0900"));
let commonEventPublishData = { let commonEventPublishData = {
data: formId data: formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_disableFormsUpdate_0900", done));
}
function unSubscribeOnEnableCallback() {
console.info("!!!====>FMS_disableFormsUpdate_0900 unSubscribeOnEnableCallback====>");
} }
function OnEnableCallBack(err, data) { async function OnEnableCallBack(_, data) {
console.info("!!!====>FMS_disableFormsUpdate_0900 OnEnableCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_disableFormsUpdate_0900 OnEnableCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
commonEvent.unsubscribe(subscriberEnable, unSubscribeOnEnableCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnEnableCallback("FMS_disableFormsUpdate_0900"));
formId = data.parameters.formId; formId = data.parameters.formId;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
console.debug("====>FMS_disableFormsUpdate_0900 onStateFormEvent Invisible Subscriber====>"); commonEvent.subscribe(subscriberOnState, OnDisableCallBack);
subscriberDisable = data;
await commonEvent.subscribe(subscriberDisable, OnDisableCallBack);
});
console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbility start`); console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbility start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhostg", bundleName: "com.ohos.st.formsystemhostg",
abilityName: "com.ohos.st.formsystemhostg.MainAbility", abilityName: "com.ohos.st.formsystemhostg.MainAbility",
...@@ -594,12 +493,8 @@ export default function test() { ...@@ -594,12 +493,8 @@ export default function test() {
}); });
console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbility end`); console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbility end`);
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, OnEnableCallBack);
console.debug("====>FMS_disableFormsUpdate_0900 onStateFormEvent Invisible Subscriber====>");
subscriberEnable = data;
await commonEvent.subscribe(subscriberEnable, OnEnableCallBack);
});
console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbility start`); console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -633,10 +528,6 @@ export default function test() { ...@@ -633,10 +528,6 @@ export default function test() {
*/ */
it(`FMS_disableFormsUpdate_1000`, 0, async (done) => { it(`FMS_disableFormsUpdate_1000`, 0, async (done) => {
console.log(`FMS_disableFormsUpdate_1000 start`); console.log(`FMS_disableFormsUpdate_1000 start`);
let subscriberOnAcquired;
let subscriberStatus;
let subscriberEnable;
let subscriberSupply;
let formId; let formId;
// timer speed up // timer speed up
...@@ -644,46 +535,30 @@ export default function test() { ...@@ -644,46 +535,30 @@ export default function test() {
console.log(`FMS_disableFormsUpdate_1000 time speed up`); console.log(`FMS_disableFormsUpdate_1000 time speed up`);
}); });
function unSubscribeSupplyCallback() { function onSupplyEventCallBack(_, data) {
console.debug("====>FMS_disableFormsUpdate_1000 unSubscribeSupplyCallback====>");
}
function delPublishCallBack(err, data) {
console.info("!!!====>FMS_disableFormsUpdate_1000 delPublishCallBack====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_disableFormsUpdate_1000 delPublishCallBack end');
console.log(`FMS_disableFormsUpdate_1000 end`);
done();
}, 1000);
}
function onSupplyEventCallBack(err, data) {
console.debug("====>FMS_disableFormsUpdate_1000 onSupplyEventCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_disableFormsUpdate_1000 onSupplyEventCallBack====>" + JSON.stringify(data));
if ("onUpdate" == data.parameters.kind) { if ("onUpdate" == data.parameters.kind) {
console.debug("FMS_disableFormsUpdate_1000 error, onUpdate called."); console.debug("FMS_disableFormsUpdate_1000 error, onUpdate called.");
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_disableFormsUpdate_1000"));
expect().assertFail(); expect().assertFail();
} }
} }
function onFormDisableCallBack(err, data) { function onFormDisableCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
console.debug("====>FMS_disableFormsUpdate_1000 onFormDisableCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_disableFormsUpdate_1000 onFormDisableCallBack====>" + JSON.stringify(data));
commonEvent.unsubscribe(subscriberStatus, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeSupplyCallback("FMS_disableFormsUpdate_1000"));
expect(data.parameters.kind).assertEqual("disable"); expect(data.parameters.kind).assertEqual("disable");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { commonEvent.subscribe(subscriberSupply, onSupplyEventCallBack);
console.debug("====>FMS_disableFormsUpdate_1000 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyEventCallBack);
});
setTimeout(() => { setTimeout(() => {
// timer reset // timer reset
commonEvent.publish(`fms.time_speed`, { code: 1 }, () => { commonEvent.publish(`fms.time_speed`, { code: 1 }, () => {
console.log(`FMS_disableFormsUpdate_1000 time reset`); console.log(`FMS_disableFormsUpdate_1000 time reset`);
}); });
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_disableFormsUpdate_1000"));
}, 9000); }, 9000);
setTimeout(() => { setTimeout(() => {
...@@ -691,24 +566,19 @@ export default function test() { ...@@ -691,24 +566,19 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: formId data: formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_disableFormsUpdate_1000", done));
}, 10000); }, 10000);
} }
function onAcquiredCallBack(err, data) { function onAcquiredCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeSupplyCallback("FMS_disableFormsUpdate_1000"));
console.debug("====>FMS_disableFormsUpdate_1000 onAcquiredCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_disableFormsUpdate_1000 onAcquiredCallBack====>" + JSON.stringify(data));
expect(data.parameters.kind).assertEqual("visible"); expect(data.parameters.kind).assertEqual("visible");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
formId = data.parameters.formId; formId = data.parameters.formId;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onFormDisableCallBack);
console.debug("====>FMS_disableFormsUpdate_1000 onStateFormEvent Subscriber====>");
subscriberStatus = data;
await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack);
});
console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbility notify disable start`); console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbility notify disable start`);
featureAbility.startAbility({ featureAbility.startAbility({
want: { want: {
...@@ -734,11 +604,7 @@ export default function test() { ...@@ -734,11 +604,7 @@ export default function test() {
console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbility notify disable end`); console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbility notify disable end`);
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.debug("====>FMS_disableFormsUpdate_1000 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbility servicea start`); console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -773,10 +639,6 @@ export default function test() { ...@@ -773,10 +639,6 @@ export default function test() {
*/ */
it(`FMS_disableFormsUpdate_1100`, 0, async (done) => { it(`FMS_disableFormsUpdate_1100`, 0, async (done) => {
console.log(`FMS_disableFormsUpdate_1100 start`); console.log(`FMS_disableFormsUpdate_1100 start`);
let subscriberOnAcquired;
let subscriberStatus;
let subscriberEnable;
let subscriberSupply;
let formId; let formId;
// timer speed up // timer speed up
...@@ -784,46 +646,30 @@ export default function test() { ...@@ -784,46 +646,30 @@ export default function test() {
console.log(`FMS_disableFormsUpdate_1100 time speed up`); console.log(`FMS_disableFormsUpdate_1100 time speed up`);
}); });
function unSubscribeSupplyCallback() { function onSupplyEventCallBack(_, data) {
console.debug("====>FMS_disableFormsUpdate_1100 unSubscribeSupplyCallback====>");
}
function delPublishCallBack(err, data) {
console.info("!!!====>FMS_disableFormsUpdate_1100 delPublishCallBack====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_disableFormsUpdate_1100 delPublishCallBack end');
console.log(`FMS_disableFormsUpdate_1100 end`);
done();
}, 1000);
}
function onSupplyEventCallBack(err, data) {
console.debug("====>FMS_disableFormsUpdate_1100 onSupplyEventCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_disableFormsUpdate_1100 onSupplyEventCallBack====>" + JSON.stringify(data));
if ("onUpdate" == data.parameters.kind) { if ("onUpdate" == data.parameters.kind) {
console.debug("FMS_disableFormsUpdate_1100 error, onUpdate called."); console.debug("FMS_disableFormsUpdate_1100 error, onUpdate called.");
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_disableFormsUpdate_1100"));
expect().assertFail(); expect().assertFail();
} }
} }
function onFormDisableCallBack(err, data) { function onFormDisableCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
console.debug("====>FMS_disableFormsUpdate_1100 onFormDisableCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_disableFormsUpdate_1100 onFormDisableCallBack====>" + JSON.stringify(data));
commonEvent.unsubscribe(subscriberStatus, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeSupplyCallback("FMS_disableFormsUpdate_1100"));
expect(data.parameters.kind).assertEqual("disable"); expect(data.parameters.kind).assertEqual("disable");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { commonEvent.subscribe(subscriberSupply, onSupplyEventCallBack);
console.debug("====>FMS_disableFormsUpdate_1100 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyEventCallBack);
});
setTimeout(() => { setTimeout(() => {
// timer reset // timer reset
commonEvent.publish(`fms.time_speed`, { code: 1 }, () => { commonEvent.publish(`fms.time_speed`, { code: 1 }, () => {
console.log(`FMS_disableFormsUpdate_1100 time reset`); console.log(`FMS_disableFormsUpdate_1100 time reset`);
}); });
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_disableFormsUpdate_1100"));
}, 9000); }, 9000);
setTimeout(() => { setTimeout(() => {
...@@ -831,24 +677,19 @@ export default function test() { ...@@ -831,24 +677,19 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: formId data: formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_disableFormsUpdate_1100", done));
}, 10000); }, 10000);
} }
function onAcquiredCallBack(err, data) { function onAcquiredCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeSupplyCallback("FMS_disableFormsUpdate_1100"));
console.debug("====>FMS_disableFormsUpdate_1100 onAcquiredCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_disableFormsUpdate_1100 onAcquiredCallBack====>" + JSON.stringify(data));
expect(data.parameters.kind).assertEqual("visible"); expect(data.parameters.kind).assertEqual("visible");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
formId = data.parameters.formId; formId = data.parameters.formId;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onFormDisableCallBack);
console.debug("====>FMS_disableFormsUpdate_1100 onStateFormEvent Subscriber====>");
subscriberStatus = data;
await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack);
});
console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbility notify disable start`); console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbility notify disable start`);
featureAbility.startAbility({ featureAbility.startAbility({
want: { want: {
...@@ -874,11 +715,7 @@ export default function test() { ...@@ -874,11 +715,7 @@ export default function test() {
console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbility notify disable end`); console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbility notify disable end`);
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.debug("====>FMS_disableFormsUpdate_1100 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbility servicea start`); console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -905,3 +742,31 @@ export default function test() { ...@@ -905,3 +742,31 @@ export default function test() {
}); });
}); });
} }
const delPublishCallback = async (tcNumber, done) => {
console.info(`${tcNumber} delPublishCallBack start`);
setTimeout(function () {
console.info(`${tcNumber} delPublishCallBack end`);
done();
}, 1000);
}
const unsubscribeOnStateCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unsubscribeOnStateCallback====>`);
}
const unsubscribeOnAcquiredCallback = (tcNumber) => {
console.info(`====>${tcNumber} unsubscribeOnAcquiredCallback====>`);
}
const unsubscribeOnDisableCallback = (tcNumber) => {
console.info(`====>${tcNumber} unsubscribeOnDisableCallback====>`);
}
const unsubscribeOnEnableCallback = (tcNumber) => {
console.info(`====>${tcNumber} unsubscribeOnEnableCallback====>`);
}
const unsubscribeSupplyCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unSubscribeSupplyCallback====>`);
}
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info( '[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async castTempToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempToNormal result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
console.info("[FormComponent] getAllFormsInfo start");
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
})
.catch((err) => {
console.info('[FormComponent] getAllFormsInfo error:' + JSON.stringify(err));
});
console.info("[FormComponent] getAllFormsInfo end");
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
bundleManager.cleanBundleCacheFiles('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
bundleManager.cleanBundleCacheFiles(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
...@@ -15,11 +15,8 @@ ...@@ -15,11 +15,8 @@
import featureAbility from "@ohos.ability.featureAbility"; import featureAbility from "@ohos.ability.featureAbility";
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import { beforeAll, describe, expect, it } from "deccjsunit/index.ets"; import { beforeAll, beforeEach, describe, expect, it } from "deccjsunit/index.ets";
var onErrorForm_Event = {
events: ["FMS_FormOnError_commonEvent"],
};
var onAcquiredForm_Event = { var onAcquiredForm_Event = {
events: ["FMS_FormOnAcquired_commonEvent"], events: ["FMS_FormOnAcquired_commonEvent"],
}; };
...@@ -38,6 +35,11 @@ var onSupplyEvent = { ...@@ -38,6 +35,11 @@ var onSupplyEvent = {
var deleteForm_Event = "FMS_FormDelete_commonEvent"; var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnAcquired;
var subscriberDel;
var subscriberOnState;
var subscriberSupply;
export default function test() { export default function test() {
describe(`FmsStateFormTest`, () => { describe(`FmsStateFormTest`, () => {
...@@ -45,6 +47,13 @@ export default function test() { ...@@ -45,6 +47,13 @@ export default function test() {
done(); done();
}) })
beforeEach(async () => {
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
subscriberDel = await commonEvent.createSubscriber(onDeletedFormEvent);
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
subscriberSupply = await commonEvent.createSubscriber(onSupplyEvent);
})
/** /**
* @tc.number: FMS_enableFormsUpdate_0200 * @tc.number: FMS_enableFormsUpdate_0200
* @tc.name: The form user does not have permission. * @tc.name: The form user does not have permission.
...@@ -53,29 +62,20 @@ export default function test() { ...@@ -53,29 +62,20 @@ export default function test() {
*/ */
it(`FMS_enableFormsUpdate_0200`, 0, async (done) => { it(`FMS_enableFormsUpdate_0200`, 0, async (done) => {
console.log(`FMS_enableFormsUpdate_0200 start`); console.log(`FMS_enableFormsUpdate_0200 start`);
let subscriberOnState;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_enableFormsUpdate_0200 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_enableFormsUpdate_0200 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("2"); expect(data.data).assertEqual("2");
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallBack); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_enableFormsUpdate_0200"));
setTimeout(function () { setTimeout(function () {
console.info('FMS_enableFormsUpdate_0200 onStateCallBack end'); console.info('FMS_enableFormsUpdate_0200 onStateCallBack end');
console.log(`FMS_enableFormsUpdate_0200 end`); console.log(`FMS_enableFormsUpdate_0200 end`);
done(); done();
}, 1000); }, 1000);
} }
function unsubscribeOnStateCallBack() {
console.debug("====>FMS_enableFormsUpdate_0200 unsubscribeOnStateCallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_0200 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_enableFormsUpdate_0200 featureAbility.startAbility again start`); console.log(`FMS_enableFormsUpdate_0200 featureAbility.startAbility again start`);
featureAbility.startAbility({ featureAbility.startAbility({
want: { want: {
...@@ -108,14 +108,12 @@ export default function test() { ...@@ -108,14 +108,12 @@ export default function test() {
*/ */
it(`FMS_enableFormsUpdate_0300`, 0, async (done) => { it(`FMS_enableFormsUpdate_0300`, 0, async (done) => {
console.log(`FMS_enableFormsUpdate_0300 start`); console.log(`FMS_enableFormsUpdate_0300 start`);
let subscriberOnState;
let formId;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_enableFormsUpdate_0300 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_enableFormsUpdate_0300 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("7"); expect(data.data).assertEqual("7");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_enableFormsUpdate_0300"))
setTimeout(function () { setTimeout(function () {
console.info('FMS_enableFormsUpdate_0300 delPublishCallBack end'); console.info('FMS_enableFormsUpdate_0300 delPublishCallBack end');
...@@ -123,15 +121,8 @@ export default function test() { ...@@ -123,15 +121,8 @@ export default function test() {
done(); done();
}, 100) }, 100)
} }
function unSubscribeOnStateCallback() {
console.debug("====>FMS_enableFormsUpdate_0300 unSubscribeOnStateCallback CallBack====>"); commonEvent.subscribe(subscriberOnState, onStateCallBack);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_0300 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_enableFormsUpdate_0300 featureAbility.startAbility start`); console.log(`FMS_enableFormsUpdate_0300 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -164,14 +155,12 @@ export default function test() { ...@@ -164,14 +155,12 @@ export default function test() {
*/ */
it(`FMS_enableFormsUpdate_0400`, 0, async (done) => { it(`FMS_enableFormsUpdate_0400`, 0, async (done) => {
console.log(`FMS_enableFormsUpdate_0400 start`); console.log(`FMS_enableFormsUpdate_0400 start`);
let subscriberOnState;
let formId;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_enableFormsUpdate_0400 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_enableFormsUpdate_0400 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("13"); expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_enableFormsUpdate_0400"))
setTimeout(function () { setTimeout(function () {
console.info('FMS_enableFormsUpdate_0400 delPublishCallBack end'); console.info('FMS_enableFormsUpdate_0400 delPublishCallBack end');
...@@ -179,15 +168,8 @@ export default function test() { ...@@ -179,15 +168,8 @@ export default function test() {
done(); done();
}, 100) }, 100)
} }
function unSubscribeOnStateCallback() {
console.debug("====>FMS_enableFormsUpdate_0400 unSubscribeOnStateCallback CallBack====>"); commonEvent.subscribe(subscriberOnState, onStateCallBack);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_0400 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_enableFormsUpdate_0400 featureAbility.startAbility start`); console.log(`FMS_enableFormsUpdate_0400 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -220,14 +202,12 @@ export default function test() { ...@@ -220,14 +202,12 @@ export default function test() {
*/ */
it(`FMS_enableFormsUpdate_0500`, 0, async (done) => { it(`FMS_enableFormsUpdate_0500`, 0, async (done) => {
console.log(`FMS_enableFormsUpdate_0500 start`); console.log(`FMS_enableFormsUpdate_0500 start`);
let subscriberOnState;
let formId;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_enableFormsUpdate_0500 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_enableFormsUpdate_0500 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("13"); expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_enableFormsUpdate_0500"))
setTimeout(function () { setTimeout(function () {
console.info('FMS_enableFormsUpdate_0500 delPublishCallBack end'); console.info('FMS_enableFormsUpdate_0500 delPublishCallBack end');
...@@ -235,15 +215,8 @@ export default function test() { ...@@ -235,15 +215,8 @@ export default function test() {
done(); done();
}, 100) }, 100)
} }
function unSubscribeOnStateCallback() {
console.debug("====>FMS_enableFormsUpdate_0500 unSubscribeOnStateCallback CallBack====>"); commonEvent.subscribe(subscriberOnState, onStateCallBack);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_0500 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_enableFormsUpdate_0500 featureAbility.startAbility start`); console.log(`FMS_enableFormsUpdate_0500 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -276,36 +249,23 @@ export default function test() { ...@@ -276,36 +249,23 @@ export default function test() {
*/ */
it(`FMS_enableFormsUpdate_0600`, 0, async (done) => { it(`FMS_enableFormsUpdate_0600`, 0, async (done) => {
console.info(`FMS_enableFormsUpdate_0600 start`); console.info(`FMS_enableFormsUpdate_0600 start`);
let subscriberOnAcquired;
let subscriberEnable;
let hostFormId; let hostFormId;
const delPublishCallback = (err, data) => { const onEnableCallback = (_, data) => {
console.info("!!!====>FMS_enableFormsUpdate_0600 delPublishCallback====>");
setTimeout(() => {
console.info('FMS_enableFormsUpdate_0600 delPublishCallback end');
console.info(`FMS_enableFormsUpdate_0600 end`);
done();
}, 1000);
}
const onEnableCallback = (err, data) => {
if (data.parameters.kind != "enable") { if (data.parameters.kind != "enable") {
return; return;
} }
console.debug("====>FMS_enableFormsUpdate_0600 onEnableCallback data:====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_0600 onEnableCallback data:====>" + JSON.stringify(data));
expect(data.data).assertEqual("13"); expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberEnable, () => { commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_enableFormsUpdate_0600"));
console.info("====>FMS_enableFormsUpdate_0600 unSubscribeOnEnableCallback====>");
});
const commonEventPublishData = { const commonEventPublishData = {
data: hostFormId data: hostFormId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_enableFormsUpdate_0600", done));
} }
const onAcquiredCallBack = async (err, data) => { const onAcquiredCallBack = async (_, data) => {
console.debug("====>FMS_enableFormsUpdate_0600 onAcquiredCallback data:====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_0600 onAcquiredCallback data:====>" + JSON.stringify(data));
hostFormId = data.data; hostFormId = data.data;
...@@ -330,22 +290,11 @@ export default function test() { ...@@ -330,22 +290,11 @@ export default function test() {
}).catch((err: any) => { }).catch((err: any) => {
console.debug(`FMS_enableFormsUpdate_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`); console.debug(`FMS_enableFormsUpdate_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`);
}); });
commonEvent.unsubscribe(subscriberOnAcquired, () => { commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_enableFormsUpdate_0600"));
console.info("====>FMS_enableFormsUpdate_0600 unSubscribeOnAcquiredCallback====>");
});
} }
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.debug("====>FMS_enableFormsUpdate_0600 onAcquiredFormEvent Subscriber====>"); commonEvent.subscribe(subscriberOnState, onEnableCallback);
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.info("====>FMS_enableFormsUpdate_0600 onStateFormEvent Enable Subscriber====>");
subscriberEnable = data;
await commonEvent.subscribe(subscriberEnable, onEnableCallback);
});
console.info(`FMS_enableFormsUpdate_0600 featureAbility.startAbility start`); console.info(`FMS_enableFormsUpdate_0600 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -375,24 +324,22 @@ export default function test() { ...@@ -375,24 +324,22 @@ export default function test() {
*/ */
it(`FMS_enableFormsUpdate_0700`, 0, async (done) => { it(`FMS_enableFormsUpdate_0700`, 0, async (done) => {
console.info(`FMS_enableFormsUpdate_0700 start`); console.info(`FMS_enableFormsUpdate_0700 start`);
let subscriberDel;
let subscriberEnable;
let hostFormId; let hostFormId;
const onEnableCallback = (err, data) => { const onEnableCallback = (_, data) => {
if (data.parameters.kind != "enable") { if (data.parameters.kind != "enable") {
return; return;
} }
console.debug("====>FMS_enableFormsUpdate_0700 onEnableCallback data:====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_0700 onEnableCallback data:====>" + JSON.stringify(data));
expect(data.data).assertEqual("13"); expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberEnable, () => { commonEvent.unsubscribe(subscriberOnState, () => {
console.info("====>FMS_enableFormsUpdate_0700 unSubscribeOnEnableCallback====>"); console.info("====>FMS_enableFormsUpdate_0700 unSubscribeOnEnableCallback====>");
}); });
done(); done();
} }
const onDeleteCallback = async (err, data) => { const onDeleteCallback = async (_, data) => {
console.debug("====>FMS_enableFormsUpdate_0700 onDeleteCallback data:====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_0700 onDeleteCallback data:====>" + JSON.stringify(data));
hostFormId = data.parameters.formId; hostFormId = data.parameters.formId;
...@@ -423,17 +370,8 @@ export default function test() { ...@@ -423,17 +370,8 @@ export default function test() {
}); });
} }
commonEvent.createSubscriber(onDeletedFormEvent).then(async (data) => { commonEvent.subscribe(subscriberDel, onDeleteCallback);
console.info("====>FMS_enableFormsUpdate_0700 onDeletedFormEvent Invisible Subscriber====>"); commonEvent.subscribe(subscriberOnState, onEnableCallback);
subscriberDel = data;
await commonEvent.subscribe(subscriberDel, onDeleteCallback);
});
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.info("====>FMS_enableFormsUpdate_0700 onStateFormEvent Enable Subscriber====>");
subscriberEnable = data;
await commonEvent.subscribe(subscriberEnable, onEnableCallback);
});
console.info(`FMS_enableFormsUpdate_0700 featureAbility.startAbility start`); console.info(`FMS_enableFormsUpdate_0700 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -466,10 +404,6 @@ export default function test() { ...@@ -466,10 +404,6 @@ export default function test() {
*/ */
it(`FMS_enableFormsUpdate_0900`, 0, async (done) => { it(`FMS_enableFormsUpdate_0900`, 0, async (done) => {
console.log(`FMS_enableFormsUpdate_0900 start`); console.log(`FMS_enableFormsUpdate_0900 start`);
let subscriberOnAcquired;
let subscriberStatus;
let subscriberEnable;
let subscriberSupply;
let formIds = []; let formIds = [];
// timer speed up // timer speed up
...@@ -477,25 +411,13 @@ export default function test() { ...@@ -477,25 +411,13 @@ export default function test() {
console.log(`FMS_enableFormsUpdate_0900 time speed up`); console.log(`FMS_enableFormsUpdate_0900 time speed up`);
}); });
function unSubscribeSupplyCallback() { function onUpdateCallBack(_, data) {
console.debug("====>FMS_enableFormsUpdate_0900 unSubscribeSupplyCallback====>");
}
function delPublishCallBack(err, data) {
console.info("!!!====>FMS_enableFormsUpdate_0900 delPublishCallBack====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_enableFormsUpdate_0900 delPublishCallBack end');
console.log(`FMS_enableFormsUpdate_0900 end`);
done();
}, 1000);
}
function onUpdateCallBack(err, data) {
if (data.parameters.kind == "onUpdate") { if (data.parameters.kind == "onUpdate") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_enableFormsUpdate_0900 onUpdateCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_0900 onUpdateCallBack====>" + JSON.stringify(data));
expect(data.parameters.parameters).assertEqual(formIds[0]); expect(data.parameters.parameters).assertEqual(formIds[0]);
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_0900"));
commonEvent.publish(`fms.time_speed`, { code: 1 }, () => { commonEvent.publish(`fms.time_speed`, { code: 1 }, () => {
console.log(`FMS_enableFormsUpdate_0900 time reset`); console.log(`FMS_enableFormsUpdate_0900 time reset`);
...@@ -505,41 +427,33 @@ export default function test() { ...@@ -505,41 +427,33 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: formIds[0] data: formIds[0]
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_enableFormsUpdate_0900", done));
}, 2000); }, 2000);
} }
} }
function onFormEnableCallBack(err, data) { function onFormEnableCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
console.debug("====>FMS_enableFormsUpdate_0900 onFormEnableCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_0900 onFormEnableCallBack====>" + JSON.stringify(data));
expect(data.parameters.formId).assertEqual(formIds[0]); expect(data.parameters.formId).assertEqual(formIds[0]);
expect(data.parameters.kind).assertEqual("enable"); expect(data.parameters.kind).assertEqual("enable");
commonEvent.unsubscribe(subscriberEnable, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_0900"));
} }
function onFormDisableCallBack(err, data) { async function onFormDisableCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
console.debug("====>FMS_enableFormsUpdate_0900 onFormDisableCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_0900 onFormDisableCallBack====>" + JSON.stringify(data));
expect(data.parameters.formId).assertEqual(formIds[0]); expect(data.parameters.formId).assertEqual(formIds[0]);
expect(data.parameters.kind).assertEqual("disable"); expect(data.parameters.kind).assertEqual("disable");
commonEvent.unsubscribe(subscriberStatus, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_0900"));
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_0900 onStateFormEvent Subscriber====>");
subscriberEnable = data;
await commonEvent.subscribe(subscriberEnable, onFormEnableCallBack);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
console.debug("====>FMS_enableFormsUpdate_0900 onSupplyEvent Subscriber====>"); commonEvent.subscribe(subscriberOnState, onFormEnableCallBack);
subscriberSupply = data; commonEvent.subscribe(subscriberSupply, onUpdateCallBack);
await commonEvent.subscribe(subscriberSupply, onUpdateCallBack);
});
setTimeout(() => { setTimeout(async () => {
console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility notifyVisible start`); console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility notifyVisible start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhostg", bundleName: "com.ohos.st.formsystemhostg",
abilityName: "com.ohos.st.formsystemhostg.MainAbility", abilityName: "com.ohos.st.formsystemhostg.MainAbility",
...@@ -564,20 +478,15 @@ export default function test() { ...@@ -564,20 +478,15 @@ export default function test() {
}, 10000); }, 10000);
} }
function onAcquiredCallBack(err, data) { async function onAcquiredCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_0900"));
console.debug("====>FMS_enableFormsUpdate_0900 onAcquiredCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_0900 onAcquiredCallBack====>" + JSON.stringify(data));
formIds.push(data.data); formIds.push(data.data);
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onFormDisableCallBack);
console.debug("====>FMS_enableFormsUpdate_0900 onStateFormEvent Subscriber====>");
subscriberStatus = data;
await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack);
});
console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility notify disable start`); console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility notify disable start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhostg", bundleName: "com.ohos.st.formsystemhostg",
abilityName: "com.ohos.st.formsystemhostg.MainAbility", abilityName: "com.ohos.st.formsystemhostg.MainAbility",
...@@ -601,11 +510,7 @@ export default function test() { ...@@ -601,11 +510,7 @@ export default function test() {
console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility notify disable end`); console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility notify disable end`);
} }
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.debug("====>FMS_enableFormsUpdate_0900 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility servicea start`); console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -637,10 +542,6 @@ export default function test() { ...@@ -637,10 +542,6 @@ export default function test() {
*/ */
it(`FMS_enableFormsUpdate_1000`, 0, async (done) => { it(`FMS_enableFormsUpdate_1000`, 0, async (done) => {
console.log(`FMS_enableFormsUpdate_1000 start`); console.log(`FMS_enableFormsUpdate_1000 start`);
let subscriberOnAcquired;
let subscriberStatus;
let subscriberEnable;
let subscriberSupply;
let formIds = []; let formIds = [];
// timer speed up // timer speed up
...@@ -648,25 +549,13 @@ export default function test() { ...@@ -648,25 +549,13 @@ export default function test() {
console.log(`FMS_enableFormsUpdate_1000 time speed up`); console.log(`FMS_enableFormsUpdate_1000 time speed up`);
}); });
function unSubscribeSupplyCallback() { function onUpdateCallBack(_, data) {
console.debug("====>FMS_enableFormsUpdate_1000 unSubscribeSupplyCallback====>");
}
function delPublishCallBack(err, data) {
console.info("!!!====>FMS_enableFormsUpdate_1000 delPublishCallBack====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_enableFormsUpdate_1000 delPublishCallBack end');
console.log(`FMS_enableFormsUpdate_1000 end`);
done();
}, 1000);
}
function onUpdateCallBack(err, data) {
if (data.parameters.kind == "onUpdate") { if (data.parameters.kind == "onUpdate") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_enableFormsUpdate_1000 onUpdateCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_1000 onUpdateCallBack====>" + JSON.stringify(data));
expect(data.parameters.parameters).assertEqual(formIds[0]); expect(data.parameters.parameters).assertEqual(formIds[0]);
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_1000"));
commonEvent.publish(`fms.time_speed`, { code: 1 }, () => { commonEvent.publish(`fms.time_speed`, { code: 1 }, () => {
console.log(`FMS_enableFormsUpdate_1000 time reset`); console.log(`FMS_enableFormsUpdate_1000 time reset`);
...@@ -676,42 +565,34 @@ export default function test() { ...@@ -676,42 +565,34 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: formIds[0] data: formIds[0]
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_enableFormsUpdate_1000", done));
}, 2000); }, 2000);
} }
} }
function onFormEnableCallBack(err, data) { function onFormEnableCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
console.debug("====>FMS_enableFormsUpdate_1000 onFormEnableCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_1000 onFormEnableCallBack====>" + JSON.stringify(data));
expect(data.parameters.formId).assertEqual(formIds[0]); expect(data.parameters.formId).assertEqual(formIds[0]);
expect(data.parameters.kind).assertEqual("enable"); expect(data.parameters.kind).assertEqual("enable");
commonEvent.unsubscribe(subscriberEnable, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_1000"));
} }
function onFormDisableCallBack(err, data) { async function onFormDisableCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
console.debug("====>FMS_enableFormsUpdate_1000 onFormDisableCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_1000 onFormDisableCallBack====>" + JSON.stringify(data));
expect(data.parameters.formId).assertEqual(formIds[0]); expect(data.parameters.formId).assertEqual(formIds[0]);
expect(data.parameters.kind).assertEqual("disable"); expect(data.parameters.kind).assertEqual("disable");
commonEvent.unsubscribe(subscriberStatus, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_1000"));
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_1000 onStateFormEvent Subscriber====>");
subscriberEnable = data;
await commonEvent.subscribe(subscriberEnable, onFormEnableCallBack);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
console.debug("====>FMS_enableFormsUpdate_1000 onSupplyEvent Subscriber====>"); commonEvent.subscribe(subscriberOnState, onFormEnableCallBack);
subscriberSupply = data; commonEvent.subscribe(subscriberSupply, onUpdateCallBack);
await commonEvent.subscribe(subscriberSupply, onUpdateCallBack);
});
setTimeout(() => { setTimeout(async () => {
console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility notifyVisible start`); console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility notifyVisible start`);
formIds.push("0"); formIds.push("0");
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhostg", bundleName: "com.ohos.st.formsystemhostg",
abilityName: "com.ohos.st.formsystemhostg.MainAbility", abilityName: "com.ohos.st.formsystemhostg.MainAbility",
...@@ -736,18 +617,12 @@ export default function test() { ...@@ -736,18 +617,12 @@ export default function test() {
}, 10000); }, 10000);
} }
function onAcquiredCallBack(err, data) { function onAcquiredCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_1000"));
console.debug("====>FMS_enableFormsUpdate_1000 onAcquiredCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_1000 onAcquiredCallBack====>" + JSON.stringify(data));
formIds.push(data.data); formIds.push(data.data);
commonEvent.subscribe(subscriberOnState, onFormDisableCallBack);
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_1000 onStateFormEvent Subscriber====>");
subscriberStatus = data;
await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack);
});
console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility notify disable start`); console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility notify disable start`);
featureAbility.startAbility({ featureAbility.startAbility({
want: { want: {
...@@ -773,11 +648,7 @@ export default function test() { ...@@ -773,11 +648,7 @@ export default function test() {
console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility notify disable end`); console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility notify disable end`);
} }
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.debug("====>FMS_enableFormsUpdate_1000 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility servicea start`); console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -809,12 +680,7 @@ export default function test() { ...@@ -809,12 +680,7 @@ export default function test() {
*/ */
it(`FMS_enableFormsUpdate_1200`, 0, async (done) => { it(`FMS_enableFormsUpdate_1200`, 0, async (done) => {
console.log(`FMS_enableFormsUpdate_1200 start`); console.log(`FMS_enableFormsUpdate_1200 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formIds = new Array(); let formIds = new Array();
let retFormId;
let subscriberStatus;
let subscriberEnable;
let count = 0; let count = 0;
// timer speed up // timer speed up
...@@ -822,26 +688,23 @@ export default function test() { ...@@ -822,26 +688,23 @@ export default function test() {
console.log(`FMS_enableFormsUpdate_1200 time speed up`); console.log(`FMS_enableFormsUpdate_1200 time speed up`);
}); });
function unSubscribeSupplyCallback() { function delPublishCallBack1(_, data) {
console.debug("====>FMS_enableFormsUpdate_1200 unSubscribeSupplyCallback====>"); console.info("!!!====>FMS_enableFormsUpdate_1200 delPublishCallBack1====>" + JSON.stringify(data));
}
function delPublishCallBack1(err, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1400 delPublishCallBack1====>" + JSON.stringify(data));
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyInvisibleForms_1400 delPublishCallBack1 end'); console.info('FMS_enableFormsUpdate_1200 delPublishCallBack1 end');
console.log(`FMS_notifyInvisibleForms_1400 end`); console.log(`FMS_enableFormsUpdate_1200 end`);
}, 1000); }, 1000);
} }
function delPublishCallBack2(err, data) { function delPublishCallBack2(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1400 delPublishCallBack2====>" + JSON.stringify(data)); console.info("!!!====>FMS_enableFormsUpdate_1200 delPublishCallBack2====>" + JSON.stringify(data));
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyInvisibleForms_1400 delPublishCallBack2 end'); console.info('FMS_enableFormsUpdate_1200 delPublishCallBack2 end');
console.log(`FMS_notifyInvisibleForms_1400 end`); console.log(`FMS_enableFormsUpdate_1200 end`);
done(); done();
}, 1000); }, 1000);
} }
function onUpdateCallBack(err, data) { function onUpdateCallBack(_, data) {
if (data.parameters.kind == "onUpdate") { if (data.parameters.kind == "onUpdate") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_enableFormsUpdate_1200 onUpdateCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_1200 onUpdateCallBack====>" + JSON.stringify(data));
...@@ -849,8 +712,8 @@ export default function test() { ...@@ -849,8 +712,8 @@ export default function test() {
++count; ++count;
if (count == 2) { if (count == 2) {
console.debug("====>FMS_notifyInvisibleForms_1400 OK====>"); console.debug("====>FMS_enableFormsUpdate_1200 OK====>");
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_1200"));
commonEvent.publish(`fms.time_speed`, { code: 1 }, () => { commonEvent.publish(`fms.time_speed`, { code: 1 }, () => {
console.log(`FMS_enableFormsUpdate_1200 time reset`); console.log(`FMS_enableFormsUpdate_1200 time reset`);
...@@ -870,34 +733,25 @@ export default function test() { ...@@ -870,34 +733,25 @@ export default function test() {
} }
} }
function onFormEnableCallBack(err, data) { function onFormEnableCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
console.debug("====>FMS_enableFormsUpdate_1200 onFormEnableCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_1200 onFormEnableCallBack====>" + JSON.stringify(data));
expect(data.parameters.kind).assertEqual("enable"); expect(data.parameters.kind).assertEqual("enable");
commonEvent.unsubscribe(subscriberEnable, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_1200"));
} }
function onFormDisableCallBack(err, data) { async function onFormDisableCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
console.debug("====>FMS_enableFormsUpdate_1200 onFormDisableCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_1200 onFormDisableCallBack====>" + JSON.stringify(data));
commonEvent.unsubscribe(subscriberStatus, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_1200"));
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
console.debug("====>FMS_enableFormsUpdate_1200 onStateFormEvent Subscriber====>"); commonEvent.subscribe(subscriberOnState, onFormEnableCallBack);
subscriberEnable = data; commonEvent.subscribe(subscriberSupply, onUpdateCallBack);
await commonEvent.subscribe(subscriberEnable, onFormEnableCallBack); setTimeout(async () => {
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_1200 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onUpdateCallBack);
});
setTimeout(() => {
console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility notifyVisible start`); console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility notifyVisible start`);
formIds.push("0"); formIds.push("0");
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhostg", bundleName: "com.ohos.st.formsystemhostg",
abilityName: "com.ohos.st.formsystemhostg.MainAbility", abilityName: "com.ohos.st.formsystemhostg.MainAbility",
...@@ -922,18 +776,14 @@ export default function test() { ...@@ -922,18 +776,14 @@ export default function test() {
}, 10000); }, 10000);
} }
async function onSecondAcquiredCallBack(err, data) { async function onSecondAcquiredCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_1200"));
console.debug("====>FMS_enableFormsUpdate_1200 onSecondAcquiredCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_1200 onSecondAcquiredCallBack====>" + JSON.stringify(data));
formIds.push(data.data); formIds.push(data.data);
console.debug("====>FMS_enableFormsUpdate_1200 formIds====>" + formIds); console.debug("====>FMS_enableFormsUpdate_1200 formIds====>" + formIds);
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onFormDisableCallBack);
console.debug("====>FMS_enableFormsUpdate_1200 onStateFormEvent Subscriber====>");
subscriberStatus = data;
await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack);
});
console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility notify disable start`); console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility notify disable start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
...@@ -960,17 +810,14 @@ export default function test() { ...@@ -960,17 +810,14 @@ export default function test() {
console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility notify disable end`); console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility notify disable end`);
} }
async function onFirstAcquiredCallBack(err, data) { async function onFirstAcquiredCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_1200"));
console.debug("====>FMS_enableFormsUpdate_1200 onFirstAcquiredCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_enableFormsUpdate_1200 onFirstAcquiredCallBack====>" + JSON.stringify(data));
formIds.push(data.data); formIds.push(data.data);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
console.debug("====>FMS_enableFormsUpdate_1200 onAcquiredForm_Event Subscriber====>"); commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack);
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack);
});
console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility serviceb start`); console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility serviceb start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
...@@ -995,11 +842,7 @@ export default function test() { ...@@ -995,11 +842,7 @@ export default function test() {
console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility serviceb end`); console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility serviceb end`);
} }
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack);
console.debug("====>FMS_enableFormsUpdate_1200 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack);
});
console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility servicea start`); console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -1024,3 +867,23 @@ export default function test() { ...@@ -1024,3 +867,23 @@ export default function test() {
}); });
}); });
} }
const delPublishCallback = async (tcNumber, done) => {
console.info(`${tcNumber} delPublishCallBack start`);
setTimeout(function () {
console.info(`${tcNumber} delPublishCallBack end`);
done();
}, 1000);
}
const unsubscribeOnStateCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unsubscribeOnStateCallback====>`);
}
const unsubscribeOnAcquiredCallback = (tcNumber) => {
console.info(`====>${tcNumber} unsubscribeOnAcquiredCallback====>`);
}
const unsubscribeSupplyCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unSubscribeSupplyCallback====>`);
}
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info( '[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async castTempToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempToNormal result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
console.info("[FormComponent] getAllFormsInfo start");
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
})
.catch((err) => {
console.info('[FormComponent] getAllFormsInfo error:' + JSON.stringify(err));
});
console.info("[FormComponent] getAllFormsInfo end");
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
bundleManager.cleanBundleCacheFiles('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
bundleManager.cleanBundleCacheFiles(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import featureAbility from "@ohos.ability.featureAbility"; import featureAbility from "@ohos.ability.featureAbility";
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import { describe, expect, it } from "deccjsunit/index.ets"; import { describe, beforeEach, expect, it } from "deccjsunit/index.ets";
var onAcquiredForm_Event = { var onAcquiredForm_Event = {
events: ["FMS_FormOnAcquired_commonEvent"], events: ["FMS_FormOnAcquired_commonEvent"],
...@@ -35,9 +35,21 @@ var onSupplyEvent = { ...@@ -35,9 +35,21 @@ var onSupplyEvent = {
var deleteForm_Event = "FMS_FormDelete_commonEvent"; var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnAcquired;
var subscriberDel;
var subscriberOnState;
var subscriberSupply;
export default function test() { export default function test() {
describe(`FmsStateFormTest`, () => { describe(`FmsStateFormTest`, () => {
beforeEach(async () => {
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
subscriberDel = await commonEvent.createSubscriber(onDeletedFormEvent);
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
subscriberSupply = await commonEvent.createSubscriber(onSupplyEvent);
})
/** /**
* @tc.number: FMS_notifyInvisibleForms_0200 * @tc.number: FMS_notifyInvisibleForms_0200
* @tc.name: The form user does not have permission. * @tc.name: The form user does not have permission.
...@@ -46,29 +58,20 @@ export default function test() { ...@@ -46,29 +58,20 @@ export default function test() {
*/ */
it(`FMS_notifyInvisibleForms_0200`, 0, async (done) => { it(`FMS_notifyInvisibleForms_0200`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_0200 start`); console.log(`FMS_notifyInvisibleForms_0200 start`);
let subscriberOnState;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0200 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_0200 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("2"); expect(data.data).assertEqual("2");
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallBack); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0200"));
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyInvisibleForms_0200 onStateCallBack end'); console.info('FMS_notifyInvisibleForms_0200 onStateCallBack end');
console.log(`FMS_notifyInvisibleForms_0200 end`); console.log(`FMS_notifyInvisibleForms_0200 end`);
done(); done();
}, 1000) }, 1000)
} }
function unsubscribeOnStateCallBack() {
console.debug("====>FMS_notifyInvisibleForms_0200 unsubscribeOnStateCallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0200 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyInvisibleForms_0200 featureAbility.startAbility again start`); console.log(`FMS_notifyInvisibleForms_0200 featureAbility.startAbility again start`);
featureAbility.startAbility({ featureAbility.startAbility({
want: { want: {
...@@ -101,29 +104,21 @@ export default function test() { ...@@ -101,29 +104,21 @@ export default function test() {
*/ */
it(`FMS_notifyInvisibleForms_0300`, 0, async (done) => { it(`FMS_notifyInvisibleForms_0300`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_0300 start`); console.log(`FMS_notifyInvisibleForms_0300 start`);
let subscriberOnState;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0300 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_0300 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("7"); expect(data.data).assertEqual("7");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0300"))
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyInvisibleForms_0300 delPublishCallBack end'); console.info('FMS_notifyInvisibleForms_0300 delPublishCallBack end');
console.log(`FMS_notifyInvisibleForms_0300 end`); console.log(`FMS_notifyInvisibleForms_0300 end`);
done(); done();
}, 100) }, 100)
} }
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyInvisibleForms_0300 unSubscribeOnStateCallback CallBack====>"); commonEvent.subscribe(subscriberOnState, onStateCallBack);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0300 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_notifyInvisibleForms_0300 featureAbility.startAbility start`); console.log(`FMS_notifyInvisibleForms_0300 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -156,29 +151,21 @@ export default function test() { ...@@ -156,29 +151,21 @@ export default function test() {
*/ */
it(`FMS_notifyInvisibleForms_0400`, 0, async (done) => { it(`FMS_notifyInvisibleForms_0400`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_0400 start`); console.log(`FMS_notifyInvisibleForms_0400 start`);
let subscriberOnState;
function onStateCallBack(_, data) {
function onStateCallBack(err, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0400 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_0400 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0400"))
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyInvisibleForms_0400 delPublishCallBack end'); console.info('FMS_notifyInvisibleForms_0400 delPublishCallBack end');
console.log(`FMS_notifyInvisibleForms_0400 end`); console.log(`FMS_notifyInvisibleForms_0400 end`);
done(); done();
}, 100) }, 100)
} }
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyInvisibleForms_0400 unSubscribeOnStateCallback CallBack====>"); commonEvent.subscribe(subscriberOnState, onStateCallBack);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0400 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_notifyInvisibleForms_0400 featureAbility.startAbility start`); console.log(`FMS_notifyInvisibleForms_0400 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -211,29 +198,21 @@ export default function test() { ...@@ -211,29 +198,21 @@ export default function test() {
*/ */
it(`FMS_notifyInvisibleForms_0500`, 0, async (done) => { it(`FMS_notifyInvisibleForms_0500`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_0500 start`); console.log(`FMS_notifyInvisibleForms_0500 start`);
let subscriberOnState;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0500 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_0500 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0500"))
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyInvisibleForms_0500 delPublishCallBack end'); console.info('FMS_notifyInvisibleForms_0500 delPublishCallBack end');
console.log(`FMS_notifyInvisibleForms_0500 end`); console.log(`FMS_notifyInvisibleForms_0500 end`);
done(); done();
}, 100) }, 100)
} }
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyInvisibleForms_0500 unSubscribeOnStateCallback CallBack====>"); commonEvent.subscribe(subscriberOnState, onStateCallBack);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0500 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_notifyInvisibleForms_0500 featureAbility.startAbility start`); console.log(`FMS_notifyInvisibleForms_0500 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -266,44 +245,25 @@ export default function test() { ...@@ -266,44 +245,25 @@ export default function test() {
*/ */
it(`FMS_notifyInvisibleForms_0600`, 0, async (done) => { it(`FMS_notifyInvisibleForms_0600`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_0600 start`); console.log(`FMS_notifyInvisibleForms_0600 start`);
let subscriberOnState;
let subscriberOnAcquired;
let formId; let formId;
function delPublishCallBack() { function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0600 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_notifyInvisibleForms_0600 delPublishCallBack end');
console.log(`FMS_notifyInvisibleForms_0600 end`);
done();
}, 1000);
}
function onStateCallBack(err, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0600 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_0600 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0600"));
let commonEventPublishData = { let commonEventPublishData = {
data: formId data: formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyInvisibleForms_0600", done));
} }
function unsubscribeOnStateCallback() {
console.debug("====>FMS_notifyInvisibleForms_0600 unsubscribeOnStateCallback====>"); async function onAcquiredCallBack(_, data) {
}
async function onAcquiredCallBack(err, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0600 onAcquiredCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_0600 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback) commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_notifyInvisibleForms_0600"))
formId = data.data; formId = data.data;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.debug("====>FMS_notifyInvisibleForms_0600 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbility again start`); console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbility again start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -328,15 +288,8 @@ export default function test() { ...@@ -328,15 +288,8 @@ export default function test() {
}); });
console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbility again end`); console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbility again end`);
} }
function unSubscribeOnAcquiredCallback() {
console.debug("====>FMS_notifyInvisibleForms_0600 OnAcquired UnSubscribe CallBack====>"); commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0600 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbility start`); console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -367,12 +320,9 @@ export default function test() { ...@@ -367,12 +320,9 @@ export default function test() {
*/ */
it(`FMS_notifyInvisibleForms_0700`, 0, async (done) => { it(`FMS_notifyInvisibleForms_0700`, 0, async (done) => {
console.info(`FMS_notifyInvisibleForms_0700 start`); console.info(`FMS_notifyInvisibleForms_0700 start`);
let subscriberInvisible;
let subscriberDel;
let subscriberSupply;
let hostFormId; let hostFormId;
const onSupplyCallback = (err, data) => { const onSupplyCallback = (_, data) => {
if (data.parameters.kind != "onVisibilityChange") { if (data.parameters.kind != "onVisibilityChange") {
return; return;
} }
...@@ -380,7 +330,7 @@ export default function test() { ...@@ -380,7 +330,7 @@ export default function test() {
expect().assertFail(); expect().assertFail();
} }
const onInvisibleCallback = (err, data) => { const onInvisibleCallback = (_, data) => {
if (data.parameters.kind != "invisible") { if (data.parameters.kind != "invisible") {
return; return;
} }
...@@ -388,18 +338,14 @@ export default function test() { ...@@ -388,18 +338,14 @@ export default function test() {
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
expect(data.parameters.formId).assertEqual(hostFormId); expect(data.parameters.formId).assertEqual(hostFormId);
commonEvent.unsubscribe(subscriberInvisible, () => { commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0700"));
console.info("====>FMS_notifyInvisibleForms_0700 unSubscribeOnInvisibleCallback====>");
});
setTimeout(() => { setTimeout(() => {
commonEvent.unsubscribe(subscriberSupply, () => { commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_0700"));
console.info("====>FMS_notifyInvisibleForms_0700 unSubscribeSupplyCallback====>");
});
done(); done();
}, 2000); }, 2000);
} }
const onDeleteCallback = async (err, data) => { const onDeleteCallback = async (_, data) => {
console.debug("====>FMS_notifyInvisibleForms_0700 onDeleteCallback data:====>" + JSON.stringify(data)); console.debug("====>FMS_notifyInvisibleForms_0700 onDeleteCallback data:====>" + JSON.stringify(data));
hostFormId = data.parameters.formId; hostFormId = data.parameters.formId;
...@@ -430,22 +376,9 @@ export default function test() { ...@@ -430,22 +376,9 @@ export default function test() {
}); });
} }
commonEvent.createSubscriber(onDeletedFormEvent).then(async (data) => { commonEvent.subscribe(subscriberDel, onDeleteCallback);
console.info("====>FMS_notifyInvisibleForms_0700 onDeletedFormEvent Invisible Subscriber====>"); commonEvent.subscribe(subscriberOnState, onInvisibleCallback);
subscriberDel = data; commonEvent.subscribe(subscriberSupply, onSupplyCallback);
await commonEvent.subscribe(subscriberDel, onDeleteCallback);
});
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.info("====>FMS_notifyInvisibleForms_0700 onStateFormEvent Invisible Subscriber====>");
subscriberInvisible = data;
await commonEvent.subscribe(subscriberInvisible, onInvisibleCallback);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.info("====>FMS_notifyInvisibleForms_0700 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallback);
});
console.info(`FMS_notifyInvisibleForms_0700 featureAbility.startAbility start`); console.info(`FMS_notifyInvisibleForms_0700 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -478,74 +411,49 @@ export default function test() { ...@@ -478,74 +411,49 @@ export default function test() {
*/ */
it(`FMS_notifyInvisibleForms_0800`, 0, async (done) => { it(`FMS_notifyInvisibleForms_0800`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_0800 start`); console.log(`FMS_notifyInvisibleForms_0800 start`);
let subscriberInvisible;
let subscriberVisible;
let subscriberSupply;
let formIdInvisible; let formIdInvisible;
let formIdVisible; let formIdVisible;
let onSupplyCount = 0; let onSupplyCount = 0;
function unSubscribeSupplyCallback() {
console.debug("====>FMS_notifyInvisibleForms_0800 unSubscribeSupplyCallback====>");
}
function delPublishCallBack(err, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0800 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_notifyInvisibleForms_0800 delPublishCallBack end');
console.log(`FMS_notifyInvisibleForms_0800 end`);
done();
}, 1000);
}
function onSupplyCallBack(err, data) { function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") { if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyInvisibleForms_0800 onSupplyCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyInvisibleForms_0800 onSupplyCallBack====>" + JSON.stringify(data));
onSupplyCount++; onSupplyCount++;
if (onSupplyCount == 2) { if (onSupplyCount == 2) {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_0800"));
} }
if (formIdInvisible && formIdVisible) { if (formIdInvisible && formIdVisible) {
let commonEventPublishData = { let commonEventPublishData = {
data: formIdInvisible data: formIdInvisible
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyInvisibleForms_0800", done));
} }
} }
} }
function OnInvisibleCallBack(err, data) { function OnInvisibleCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0800 OnInvisibleCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_0800 OnInvisibleCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
formIdInvisible = data.parameters.formId; formIdInvisible = data.parameters.formId;
commonEvent.unsubscribe(subscriberInvisible, unSubscribeOnInvisibleCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0800"));
if (formIdInvisible && formIdVisible && onSupplyCount == 2) { if (formIdInvisible && formIdVisible && onSupplyCount == 2) {
let commonEventPublishData = { let commonEventPublishData = {
data: formIdInvisible data: formIdInvisible
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyInvisibleForms_0800", done));
} }
} }
function unSubscribeOnVisibleCallback() { async function onVisibleCallBack(_, data) {
console.debug("====>FMS_notifyInvisibleForms_0800 unSubscribeOnVisibleCallback CallBack====>");
}
function unSubscribeOnInvisibleCallback() {
console.debug("====>FMS_notifyInvisibleForms_0800 unSubscribeOnInvisibleCallback CallBack====>");
}
async function onVisibleCallBack(err, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0800 onVisibleCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_0800 onVisibleCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberVisible, unSubscribeOnVisibleCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0800"));
formIdVisible = data.parameters.formId; formIdVisible = data.parameters.formId;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
console.debug("====>FMS_notifyInvisibleForms_0800 onStateFormEvent Invisible Subscriber====>"); commonEvent.subscribe(subscriberOnState, OnInvisibleCallBack);
subscriberInvisible = data;
await commonEvent.subscribe(subscriberInvisible, OnInvisibleCallBack);
});
console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbility again start`); console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbility again start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -570,17 +478,9 @@ export default function test() { ...@@ -570,17 +478,9 @@ export default function test() {
}); });
console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbility again end`); console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbility again end`);
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onVisibleCallBack);
console.debug("====>FMS_notifyInvisibleForms_0800 onStateFormEvent Subscriber====>"); commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
subscriberVisible = data;
await commonEvent.subscribe(subscriberVisible, onVisibleCallBack);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0800 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbility start`); console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -607,3 +507,23 @@ export default function test() { ...@@ -607,3 +507,23 @@ export default function test() {
}); });
}); });
} }
const delPublishCallback = async (tcNumber, done) => {
console.info(`${tcNumber} delPublishCallBack start`);
setTimeout(function () {
console.info(`${tcNumber} delPublishCallBack end`);
done();
}, 1000);
}
const unsubscribeOnStateCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unsubscribeOnStateCallback====>`);
}
const unsubscribeOnAcquiredCallback = (tcNumber) => {
console.info(`====>${tcNumber} unsubscribeOnAcquiredCallback====>`);
}
const unsubscribeSupplyCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unSubscribeSupplyCallback====>`);
}
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info( '[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async castTempToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempToNormal result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
console.info("[FormComponent] getAllFormsInfo start");
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
})
.catch((err) => {
console.info('[FormComponent] getAllFormsInfo error:' + JSON.stringify(err));
});
console.info("[FormComponent] getAllFormsInfo end");
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
bundleManager.cleanBundleCacheFiles('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
bundleManager.cleanBundleCacheFiles(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
...@@ -15,16 +15,12 @@ ...@@ -15,16 +15,12 @@
import featureAbility from "@ohos.ability.featureAbility"; import featureAbility from "@ohos.ability.featureAbility";
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import { describe, expect, it } from "deccjsunit/index.ets"; import { beforeEach, describe, expect, it } from "deccjsunit/index.ets";
var onAcquiredForm_Event = { var onAcquiredForm_Event = {
events: ["FMS_FormOnAcquired_commonEvent"], events: ["FMS_FormOnAcquired_commonEvent"],
}; };
var onDeletedFormEvent = {
events: ["FMS_FormOnDeleted_commonEvent"],
};
var onStateFormEvent = { var onStateFormEvent = {
events: ["FMS_FormOnState_commonEvent"], events: ["FMS_FormOnState_commonEvent"],
}; };
...@@ -35,9 +31,20 @@ var onSupplyEvent = { ...@@ -35,9 +31,20 @@ var onSupplyEvent = {
var deleteForm_Event = "FMS_FormDelete_commonEvent"; var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnAcquired;
var subscriberOnState;
var subscriberSupply;
export default function test() { export default function test() {
describe(`FmsStateFormTest`, () => { describe(`FmsStateFormTest`, () => {
beforeEach(async () => {
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
subscriberSupply = await commonEvent.createSubscriber(onSupplyEvent);
})
/** /**
* @tc.number: FMS_notifyInvisibleForms_0900 * @tc.number: FMS_notifyInvisibleForms_0900
* @tc.name: There are correct and wrong formId in the form ID parameter list * @tc.name: There are correct and wrong formId in the form ID parameter list
...@@ -47,74 +54,49 @@ export default function test() { ...@@ -47,74 +54,49 @@ export default function test() {
*/ */
it(`FMS_notifyInvisibleForms_0900`, 0, async (done) => { it(`FMS_notifyInvisibleForms_0900`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_0900 start`); console.log(`FMS_notifyInvisibleForms_0900 start`);
let subscriberInvisible;
let subscriberVisible;
let subscriberSupply;
let formIdInvisible; let formIdInvisible;
let formIdVisible; let formIdVisible;
let onSupplyCount = 0; let onSupplyCount = 0;
function unSubscribeSupplyCallback() {
console.debug("====>FMS_notifyInvisibleForms_0900 unSubscribeSupplyCallback====>");
}
function delPublishCallBack(err, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0900 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_notifyInvisibleForms_0900 delPublishCallBack end');
console.log(`FMS_notifyInvisibleForms_0900 end`);
done();
}, 1000);
}
function onSupplyCallBack(err, data) { function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") { if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyInvisibleForms_0900 onSupplyCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyInvisibleForms_0900 onSupplyCallBack====>" + JSON.stringify(data));
onSupplyCount++; onSupplyCount++;
if (onSupplyCount == 2) { if (onSupplyCount == 2) {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_0900"));
} }
if (formIdInvisible && formIdVisible) { if (formIdInvisible && formIdVisible) {
let commonEventPublishData = { let commonEventPublishData = {
data: formIdInvisible data: formIdInvisible
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyInvisibleForms_0900", done));
} }
} }
} }
function OnInvisibleCallBack(err, data) { function OnInvisibleCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0900 OnInvisibleCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_0900 OnInvisibleCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
formIdInvisible = data.parameters.formId; formIdInvisible = data.parameters.formId;
commonEvent.unsubscribe(subscriberInvisible, unSubscribeOnInvisibleCallback); commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0900"));
if (formIdInvisible && formIdVisible && onSupplyCount == 2) { if (formIdInvisible && formIdVisible && onSupplyCount == 2) {
let commonEventPublishData = { let commonEventPublishData = {
data: formIdInvisible data: formIdInvisible
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyInvisibleForms_0900", done));
} }
} }
function unSubscribeOnVisibleCallback() { async function onVisibleCallBack(_, data) {
console.debug("====>FMS_notifyInvisibleForms_0900 unSubscribeOnVisibleCallback CallBack====>");
}
function unSubscribeOnInvisibleCallback() {
console.debug("====>FMS_notifyInvisibleForms_0900 unSubscribeOnInvisibleCallback CallBack====>");
}
async function onVisibleCallBack(err, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0900 onVisibleCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_0900 onVisibleCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberVisible, unSubscribeOnVisibleCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0900"));
formIdVisible = data.parameters.formId; formIdVisible = data.parameters.formId;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0900 onStateFormEvent Invisible Subscriber====>");
subscriberInvisible = data;
await commonEvent.subscribe(subscriberInvisible, OnInvisibleCallBack);
});
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
commonEvent.subscribe(subscriberOnState, OnInvisibleCallBack);
console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbility again start`); console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbility again start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -139,17 +121,9 @@ export default function test() { ...@@ -139,17 +121,9 @@ export default function test() {
}); });
console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbility again end`); console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbility again end`);
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onVisibleCallBack);
console.debug("====>FMS_notifyInvisibleForms_0900 onStateFormEvent Subscriber====>"); commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
subscriberVisible = data;
await commonEvent.subscribe(subscriberVisible, onVisibleCallBack);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0900 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbility start`); console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -183,25 +157,8 @@ export default function test() { ...@@ -183,25 +157,8 @@ export default function test() {
*/ */
it(`FMS_notifyInvisibleForms_1000`, 0, async (done) => { it(`FMS_notifyInvisibleForms_1000`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_1000 start`); console.log(`FMS_notifyInvisibleForms_1000 start`);
let subscriberOnVisible;
let subscriberOnSupply;
function delPublishCallBack(err, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1000 delPublishCallBack====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_notifyInvisibleForms_1000 delPublishCallBack end');
console.log(`FMS_notifyInvisibleForms_1000 end`);
done();
}, 1000);
}
function unSubscribeOnVisibleCallback() { function onVisibleCallBack(_, data) {
console.debug("====>FMS_notifyInvisibleForms_1000 unSubscribeOnVisibleCallback CallBack====>");
}
function unSubscribeSupplyCallback() {
console.debug("====>FMS_notifyInvisibleForms_1000 unSubscribeSupplyCallback CallBack====>");
}
function onVisibleCallBack(err, data) {
if (data.parameters.kind != "invisible") { if (data.parameters.kind != "invisible") {
return; return;
} }
...@@ -210,35 +167,27 @@ export default function test() { ...@@ -210,35 +167,27 @@ export default function test() {
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
setTimeout(function () { setTimeout(function () {
commonEvent.unsubscribe(subscriberOnVisible, unSubscribeOnVisibleCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_1000"));
commonEvent.unsubscribe(subscriberOnSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_1000"));
let commonEventPublishData = { let commonEventPublishData = {
data: data.parameters.formId data: data.parameters.formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyInvisibleForms_0900", done));
}, 2000); }, 2000);
} }
function onSupplyEventCallBack(err, data) { function onSupplyEventCallBack(_, data) {
if (data.parameters.kind != "onVisibilityChange") { if (data.parameters.kind != "onVisibilityChange") {
return; return;
} }
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
commonEvent.unsubscribe(subscriberOnSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_1000"));
console.debug("====>FMS_notifyInvisibleForms_1000 onSupplyEventCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyInvisibleForms_1000 onSupplyEventCallBack====>" + JSON.stringify(data));
console.log(`FMS_notifyInvisibleForms_1000 error`); console.log(`FMS_notifyInvisibleForms_1000 error`);
expect().assertFail(); expect().assertFail();
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onVisibleCallBack);
console.debug("====>FMS_notifyInvisibleForms_1000 onStateFormEvent Invisible Subscriber====>"); commonEvent.subscribe(subscriberSupply, onSupplyEventCallBack);
subscriberOnVisible = data;
await commonEvent.subscribe(subscriberOnVisible, onVisibleCallBack);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_1000 onSupplyEvent Invisible Subscriber====>");
subscriberOnSupply = data;
await commonEvent.subscribe(subscriberOnSupply, onSupplyEventCallBack);
});
console.log(`FMS_notifyInvisibleForms_1000 featureAbility.startAbility start`); console.log(`FMS_notifyInvisibleForms_1000 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -272,17 +221,14 @@ export default function test() { ...@@ -272,17 +221,14 @@ export default function test() {
*/ */
it(`FMS_notifyInvisibleForms_1100`, 0, async (done) => { it(`FMS_notifyInvisibleForms_1100`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_1100 start`); console.log(`FMS_notifyInvisibleForms_1100 start`);
let subscriberInvisible;
let subscriberVisible;
let subscriberSupply;
let supplyFlag = false; let supplyFlag = false;
let formIdInvisible; let formIdInvisible;
let formIdVisible; let formIdVisible;
function delPublishCallBack(err, data) { function delPublishCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1100 delPublishCallBack====>"); console.info("!!!====>FMS_notifyInvisibleForms_1100 delPublishCallBack====>");
setTimeout(function () { setTimeout(function () {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_1100"));
if (supplyFlag) { if (supplyFlag) {
expect().assertFail(); expect().assertFail();
} }
...@@ -292,17 +238,14 @@ export default function test() { ...@@ -292,17 +238,14 @@ export default function test() {
}, 1000); }, 1000);
} }
function unSubscribeSupplyCallback() { function onSupplyCallBack(_, data) {
console.debug("====>FMS_notifyInvisibleForms_1100 unSubscribeSupplyCallback====>");
}
function onSupplyCallBack(err, data) {
if (data.parameters.kind == "onVisibilityChange") { if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyInvisibleForms_1100 onSupplyCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyInvisibleForms_1100 onSupplyCallBack====>" + JSON.stringify(data));
supplyFlag = true; supplyFlag = true;
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_1100"));
if (formIdInvisible && formIdVisible) { if (formIdInvisible && formIdVisible) {
let commonEventPublishData = { let commonEventPublishData = {
data: formIdInvisible data: formIdInvisible
}; };
...@@ -311,12 +254,12 @@ export default function test() { ...@@ -311,12 +254,12 @@ export default function test() {
} }
} }
function OnInvisibleCallBack(err, data) { function OnInvisibleCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1100 OnInvisibleCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_1100 OnInvisibleCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
formIdInvisible = data.parameters.formId; formIdInvisible = data.parameters.formId;
commonEvent.unsubscribe(subscriberInvisible, unSubscribeOnInvisibleCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_1100"));
if (formIdInvisible && formIdVisible) { if (formIdInvisible && formIdVisible) {
let commonEventPublishData = { let commonEventPublishData = {
data: formIdInvisible data: formIdInvisible
...@@ -324,24 +267,15 @@ export default function test() { ...@@ -324,24 +267,15 @@ export default function test() {
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
} }
} }
function unSubscribeOnVisibleCallback() { async function onVisibleCallBack(_, data) {
console.debug("====>FMS_notifyInvisibleForms_1100 unSubscribeOnVisibleCallback CallBack====>");
}
function unSubscribeOnInvisibleCallback() {
console.debug("====>FMS_notifyInvisibleForms_1100 unSubscribeOnInvisibleCallback CallBack====>");
}
async function onVisibleCallBack(err, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1100 onVisibleCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_1100 onVisibleCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberVisible, unSubscribeOnVisibleCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_1100"));
formIdVisible = data.parameters.formId; formIdVisible = data.parameters.formId;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
console.debug("====>FMS_notifyInvisibleForms_1100 onStateFormEvent Invisible Subscriber====>"); commonEvent.subscribe(subscriberOnState, OnInvisibleCallBack);
subscriberInvisible = data;
await commonEvent.subscribe(subscriberInvisible, OnInvisibleCallBack);
});
console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbility again start`); console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbility again start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
...@@ -367,17 +301,9 @@ export default function test() { ...@@ -367,17 +301,9 @@ export default function test() {
}); });
console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbility again end`); console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbility again end`);
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onVisibleCallBack);
console.debug("====>FMS_notifyInvisibleForms_1100 onStateFormEvent Subscriber====>"); commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
subscriberVisible = data;
await commonEvent.subscribe(subscriberVisible, onVisibleCallBack);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_1100 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbility start`); console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -413,9 +339,6 @@ export default function test() { ...@@ -413,9 +339,6 @@ export default function test() {
*/ */
it(`FMS_notifyInvisibleForms_1200`, 0, async (done) => { it(`FMS_notifyInvisibleForms_1200`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_1200 start`); console.log(`FMS_notifyInvisibleForms_1200 start`);
let subscriberOnAcquired;
let subscriberOnState;
let subscriberSupply;
let formId1; let formId1;
let formId2; let formId2;
let delCount = 0; let delCount = 0;
...@@ -432,7 +355,7 @@ export default function test() { ...@@ -432,7 +355,7 @@ export default function test() {
}, 500); }, 500);
} }
} }
function onAcquiredCallBack_Normal1(err, data) { function onAcquiredCallBack_Normal1(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1200 onAcquiredCallBack_Normal1 data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_1200 onAcquiredCallBack_Normal1 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal1) commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal1)
...@@ -443,15 +366,11 @@ export default function test() { ...@@ -443,15 +366,11 @@ export default function test() {
function unSubscribeOnAcquiredCallBack_Normal1() { function unSubscribeOnAcquiredCallBack_Normal1() {
console.debug("====>FMS_notifyInvisibleForms_1200 unSubscribeOnAcquiredCallBack_Normal1 CallBack====>"); console.debug("====>FMS_notifyInvisibleForms_1200 unSubscribeOnAcquiredCallBack_Normal1 CallBack====>");
} }
async function FMS_notifyInvisibleForms_1200_normal1() { async function FMS_notifyInvisibleForms_1200_normal1() {
console.log(`FMS_notifyInvisibleForms_1200_normal1 start`); console.log(`FMS_notifyInvisibleForms_1200_normal1 start`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_1200_normal1 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1);
console.log(`FMS_notifyInvisibleForms_1200_normal1 featureAbility.startAbility start`); console.log(`FMS_notifyInvisibleForms_1200_normal1 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -477,11 +396,11 @@ export default function test() { ...@@ -477,11 +396,11 @@ export default function test() {
console.log(`FMS_notifyInvisibleForms_1200_normal1 end`); console.log(`FMS_notifyInvisibleForms_1200_normal1 end`);
} }
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1200 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_1200 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_1200"))
console.info("!!!====>FMS_notifyInvisibleForms_1200 onStateCallBack formId1:====>" + formId1); console.info("!!!====>FMS_notifyInvisibleForms_1200 onStateCallBack formId1:====>" + formId1);
console.info("!!!====>FMS_notifyInvisibleForms_1200 onStateCallBack formId2:====>" + formId2); console.info("!!!====>FMS_notifyInvisibleForms_1200 onStateCallBack formId2:====>" + formId2);
console.info("!!!====>FMS_notifyInvisibleForms_1200 onStateCallBack onSupplyCount:====>" + onSupplyCount); console.info("!!!====>FMS_notifyInvisibleForms_1200 onStateCallBack onSupplyCount:====>" + onSupplyCount);
...@@ -496,22 +415,14 @@ export default function test() { ...@@ -496,22 +415,14 @@ export default function test() {
commonEvent.publish(deleteForm_Event, commonEventPublishData2, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData2, delPublishCallBack);
} }
} }
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyInvisibleForms_1200 unSubscribeOnStateCallback CallBack====>");
}
async function onAcquiredCallBack_Normal2(err, data) { async function onAcquiredCallBack_Normal2(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1200 onAcquiredCallBack_Normal2 data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_1200 onAcquiredCallBack_Normal2 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal2); commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal2);
formId2 = data.data; formId2 = data.data;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.debug("====>FMS_notifyInvisibleForms_1200 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_notifyInvisibleForms_1200 featureAbility.startAbility start`); console.log(`FMS_notifyInvisibleForms_1200 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -540,12 +451,8 @@ export default function test() { ...@@ -540,12 +451,8 @@ export default function test() {
console.debug("====>FMS_notifyInvisibleForms_1200 unSubscribeOnAcquiredCallBack_Normal2====>"); console.debug("====>FMS_notifyInvisibleForms_1200 unSubscribeOnAcquiredCallBack_Normal2====>");
} }
async function FMS_notifyInvisibleForms_1200_normal2() { async function FMS_notifyInvisibleForms_1200_normal2() {
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
console.debug("====>FMS_notifyInvisibleForms_1200_normal2 Create OnAcquired Subscriber====>"); commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
});
console.log(`FMS_notifyInvisibleForms_1200_normal2 featureAbility.startAbility start`); console.log(`FMS_notifyInvisibleForms_1200_normal2 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -569,10 +476,7 @@ export default function test() { ...@@ -569,10 +476,7 @@ export default function test() {
console.log(`FMS_notifyInvisibleForms_1200_normal2 featureAbility.startAbility end`); console.log(`FMS_notifyInvisibleForms_1200_normal2 featureAbility.startAbility end`);
} }
function unSubscribeSupplyCallback() { function onSupplyCallBack(_, data) {
console.debug("====>FMS_notifyInvisibleForms_1200 unSubscribeSupplyCallback====>");
}
function onSupplyCallBack(err, data) {
if (data.parameters.kind == "onVisibilityChange") { if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyInvisibleForms_1200 onSupplyCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyInvisibleForms_1200 onSupplyCallBack====>" + JSON.stringify(data));
...@@ -586,9 +490,9 @@ export default function test() { ...@@ -586,9 +490,9 @@ export default function test() {
onSupplyCount++; onSupplyCount++;
if (onSupplyCount == 2) { if (onSupplyCount == 2) {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_1200"));
} }
if (formId1 && formId2) { if (formId1 && formId2) {
let commonEventPublishData = { let commonEventPublishData = {
data: formId1 data: formId1
}; };
...@@ -600,11 +504,8 @@ export default function test() { ...@@ -600,11 +504,8 @@ export default function test() {
} }
} }
} }
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_1200 onSupplyEvent Subscriber====>"); commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
FMS_notifyInvisibleForms_1200_normal1(); FMS_notifyInvisibleForms_1200_normal1();
}); });
/** /**
...@@ -616,13 +517,11 @@ export default function test() { ...@@ -616,13 +517,11 @@ export default function test() {
*/ */
it(`FMS_notifyInvisibleForms_1300`, 0, async (done) => { it(`FMS_notifyInvisibleForms_1300`, 0, async (done) => {
console.info(`FMS_notifyInvisibleForms_1300 start`); console.info(`FMS_notifyInvisibleForms_1300 start`);
let subscriberInvisible;
let subscriberSupply;
let hostFormId; let hostFormId;
let providerFormId; let providerFormId;
let counter = 0; let counter = 0;
const delPublishCallback = (err, data) => { const delPublishCallback = (_, data) => {
console.info("!!!====>FMS_notifyInvisibleForms_1300 delPublishCallback====>"); console.info("!!!====>FMS_notifyInvisibleForms_1300 delPublishCallback====>");
setTimeout(() => { setTimeout(() => {
expect(hostFormId).assertEqual(providerFormId); expect(hostFormId).assertEqual(providerFormId);
...@@ -632,7 +531,7 @@ export default function test() { ...@@ -632,7 +531,7 @@ export default function test() {
}, 1000); }, 1000);
} }
const onSupplyCallback = (err, data) => { const onSupplyCallback = (_, data) => {
if (data.parameters.kind != "onVisibilityChange") { if (data.parameters.kind != "onVisibilityChange") {
return; return;
} }
...@@ -652,7 +551,7 @@ export default function test() { ...@@ -652,7 +551,7 @@ export default function test() {
} }
} }
const onInvisibleCallback = (err, data) => { const onInvisibleCallback = (_, data) => {
if (data.parameters.kind != "invisible") { if (data.parameters.kind != "invisible") {
return; return;
} }
...@@ -660,7 +559,7 @@ export default function test() { ...@@ -660,7 +559,7 @@ export default function test() {
hostFormId = data.parameters.formId; hostFormId = data.parameters.formId;
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberInvisible, () => { commonEvent.unsubscribe(subscriberOnState, () => {
console.info("====>FMS_notifyInvisibleForms_1300 unSubscribeOnInvisibleCallback====>"); console.info("====>FMS_notifyInvisibleForms_1300 unSubscribeOnInvisibleCallback====>");
}); });
if (++counter == 2) { if (++counter == 2) {
...@@ -671,17 +570,8 @@ export default function test() { ...@@ -671,17 +570,8 @@ export default function test() {
} }
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onInvisibleCallback);
console.info("====>FMS_notifyInvisibleForms_1300 onStateFormEvent Invisible Subscriber====>"); commonEvent.subscribe(subscriberSupply, onSupplyCallback);
subscriberInvisible = data;
await commonEvent.subscribe(subscriberInvisible, onInvisibleCallback);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.info("====>FMS_notifyInvisibleForms_1300 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallback);
});
console.info(`FMS_notifyInvisibleForms_1300 featureAbility.startAbility start`); console.info(`FMS_notifyInvisibleForms_1300 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -714,25 +604,17 @@ export default function test() { ...@@ -714,25 +604,17 @@ export default function test() {
*/ */
it(`FMS_notifyInvisibleForms_1400`, 0, async (done) => { it(`FMS_notifyInvisibleForms_1400`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_1400 start`); console.log(`FMS_notifyInvisibleForms_1400 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formIds = new Array(); let formIds = new Array();
let retFormId;
let formId1;
let formId2;
let count = 0; let count = 0;
function unSubscribeSupplyCallback() { function delPublishCallBack1(_, data) {
console.debug("====>FMS_notifyInvisibleForms_1400 unSubscribeSupplyCallback====>");
}
function delPublishCallBack1(err, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1400 delPublishCallBack1====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_1400 delPublishCallBack1====>" + JSON.stringify(data));
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyInvisibleForms_1400 delPublishCallBack1 end'); console.info('FMS_notifyInvisibleForms_1400 delPublishCallBack1 end');
console.log(`FMS_notifyInvisibleForms_1400 end`); console.log(`FMS_notifyInvisibleForms_1400 end`);
}, 1000); }, 1000);
} }
function delPublishCallBack2(err, data) { function delPublishCallBack2(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1400 delPublishCallBack2====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_1400 delPublishCallBack2====>" + JSON.stringify(data));
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyInvisibleForms_1400 delPublishCallBack2 end'); console.info('FMS_notifyInvisibleForms_1400 delPublishCallBack2 end');
...@@ -741,7 +623,7 @@ export default function test() { ...@@ -741,7 +623,7 @@ export default function test() {
}, 1000); }, 1000);
} }
function onSupplyCallBack(err, data) { function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") { if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyInvisibleForms_1400 onSupplyCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyInvisibleForms_1400 onSupplyCallBack====>" + JSON.stringify(data));
...@@ -754,7 +636,7 @@ export default function test() { ...@@ -754,7 +636,7 @@ export default function test() {
++count; ++count;
if (count == 2) { if (count == 2) {
console.debug("====>FMS_notifyInvisibleForms_1400 OK====>"); console.debug("====>FMS_notifyInvisibleForms_1400 OK====>");
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_1400"));
let commonEventPublishData1 = { let commonEventPublishData1 = {
data: formIds[0] data: formIds[0]
...@@ -768,19 +650,15 @@ export default function test() { ...@@ -768,19 +650,15 @@ export default function test() {
} }
} }
async function onSecondAcquiredCallBack(err, data) { async function onSecondAcquiredCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_1400"));
console.debug("====>FMS_notifyInvisibleForms_1400 onSecondAcquiredCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyInvisibleForms_1400 onSecondAcquiredCallBack====>" + JSON.stringify(data));
formIds.push(data.data); formIds.push(data.data);
formIds.push("-1"); formIds.push("-1");
console.debug("====>FMS_notifyInvisibleForms_1400 formIds====>" + formIds); console.debug("====>FMS_notifyInvisibleForms_1400 formIds====>" + formIds);
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.debug("====>FMS_notifyInvisibleForms_1400 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility notifyInVisible start`); console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility notifyInVisible start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
...@@ -807,18 +685,14 @@ export default function test() { ...@@ -807,18 +685,14 @@ export default function test() {
console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility notifyInVisible end`); console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility notifyInVisible end`);
} }
async function onFirstAcquiredCallBack(err, data) { async function onFirstAcquiredCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_1400"));
console.debug("====>FMS_notifyInvisibleForms_1400 onFirstAcquiredCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyInvisibleForms_1400 onFirstAcquiredCallBack====>" + JSON.stringify(data));
formIds.push(data.data); formIds.push(data.data);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
console.debug("====>FMS_notifyInvisibleForms_1400 onAcquiredForm_Event Subscriber====>"); commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack);
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack);
});
console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility serviceb start`); console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility serviceb start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -842,11 +716,7 @@ export default function test() { ...@@ -842,11 +716,7 @@ export default function test() {
console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility serviceb end`); console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility serviceb end`);
} }
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack);
console.debug("====>FMS_notifyInvisibleForms_1400 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack);
});
console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility servicea start`); console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -876,30 +746,20 @@ export default function test() { ...@@ -876,30 +746,20 @@ export default function test() {
*/ */
it(`FMS_notifyInvisibleForms_1500`, 0, async (done) => { it(`FMS_notifyInvisibleForms_1500`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_1500 start`); console.log(`FMS_notifyInvisibleForms_1500 start`);
let subscriberOnState;
let formId;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1500 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyInvisibleForms_1500 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data != "0").assertEqual(true); expect(data.data != "0").assertEqual(true);
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_1500"))
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyInvisibleForms_1500 delPublishCallBack end'); console.info('FMS_notifyInvisibleForms_1500 delPublishCallBack end');
console.log(`FMS_notifyInvisibleForms_1500 end`); console.log(`FMS_notifyInvisibleForms_1500 end`);
done(); done();
}, 100) }, 100)
} }
function unSubscribeOnStateCallback() { commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.debug("====>FMS_notifyInvisibleForms_1500 unSubscribeOnStateCallback CallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_1500 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_notifyInvisibleForms_1500 featureAbility.startAbility start`); console.log(`FMS_notifyInvisibleForms_1500 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -930,3 +790,19 @@ export default function test() { ...@@ -930,3 +790,19 @@ export default function test() {
}); });
}); });
} }
const delPublishCallback = async (tcNumber, done) => {
console.info(`${tcNumber} delPublishCallBack start`);
setTimeout(function () {
console.info(`${tcNumber} delPublishCallBack end`);
done();
}, 1000);
}
const unsubscribeOnStateCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unsubscribeOnStateCallback====>`);
}
const unsubscribeSupplyCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unSubscribeSupplyCallback====>`);
}
/*
* 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 formManager from '@ohos.ability.formmanager';
import bundleManager from '@ohos.bundle';
export default class FormViewModel {
private static sFormViewModel: FormViewModel = null;
public static getInstance(): FormViewModel {
if (FormViewModel.sFormViewModel == null) {
FormViewModel.sFormViewModel = new FormViewModel();
}
return FormViewModel.sFormViewModel;
}
public async requestForm(formId: string) {
formManager.requestForm(formId)
.then((data) => {
console.info( '[FormComponent] requestForm result:' + data);
});
}
public async deleteCard(formId: string) {
formManager.deleteForm(formId)
.then((data) => {
console.info('[FormComponent] deleteForm result:' + data);
});
}
public async releaseCard(formId: string) {
formManager.releaseForm(formId)
.then((data) => {
console.info('[FormComponent] releaseForm result:' + data);
});
}
public async castTempToNormal(formId: string) {
formManager.castTempForm(formId)
.then((data) => {
console.info('[FormComponent] castTempToNormal result:' + data);
});
}
public async enableCard(formId: string) {
formManager.enableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] enableFormsUpdate result:' + data);
});
}
public async disableCard(formId: string) {
formManager.disableFormsUpdate([formId])
.then((data) => {
console.info('[FormComponent] disableCard result:' + data);
});
}
public async changeCardVisible(formId: string, isVisible: boolean) {
if (isVisible) {
formManager.notifyVisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
} else {
formManager.notifyInvisibleForms([formId])
.then((data) => {
console.info('[FormComponent] changeCardVisible result:' + data + ', isVisible:' + isVisible);
});
}
}
public async isFmsReady() {
formManager.isSystemReady()
.then((data) => {
console.info('[FormComponent] isFmsReady result:' + data);
});
}
public async getAllFormsInfo() {
console.info("[FormComponent] getAllFormsInfo start");
formManager.getAllFormsInfo()
.then((data) => {
console.info('[FormComponent] getAllFormsInfo result:' + JSON.stringify(data));
})
.catch((err) => {
console.info('[FormComponent] getAllFormsInfo error:' + JSON.stringify(err));
});
console.info("[FormComponent] getAllFormsInfo end");
}
public async getFormsInfoByApp(bundle: string) {
formManager.getFormsInfo(bundle)
.then((data) => {
console.info('[FormComponent] getFormsInfoByApp result:' + JSON.stringify(data));
});
}
public async getFormsInfoByModule(bundle: string, moduleName: string) {
formManager.getFormsInfo(bundle, moduleName)
.then((data) => {
console.info('[FormComponent] getFormsInfoByModule result:' + JSON.stringify(data));
});
}
public async clearFormUserCache() {
bundleManager.cleanBundleCacheFiles('com.ohos.myapplicationform')
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
public async clearFormProviderCache(bundle: string) {
bundleManager.cleanBundleCacheFiles(bundle)
.then((data) => {
console.info('[FormComponent] cleanBundleCacheFiles result:' + JSON.stringify(data));
});
}
}
\ No newline at end of file
...@@ -15,19 +15,12 @@ ...@@ -15,19 +15,12 @@
import featureAbility from "@ohos.ability.featureAbility"; import featureAbility from "@ohos.ability.featureAbility";
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import { beforeAll, describe, expect, it } from "deccjsunit/index.ets"; import { beforeAll, beforeEach, describe, expect, it } from "deccjsunit/index.ets";
var onErrorForm_Event = {
events: ["FMS_FormOnError_commonEvent"],
};
var onAcquiredForm_Event = { var onAcquiredForm_Event = {
events: ["FMS_FormOnAcquired_commonEvent"], events: ["FMS_FormOnAcquired_commonEvent"],
}; };
var onDeletedFormEvent = {
events: ["FMS_FormOnDeleted_commonEvent"],
};
var onStateFormEvent = { var onStateFormEvent = {
events: ["FMS_FormOnState_commonEvent"], events: ["FMS_FormOnState_commonEvent"],
}; };
...@@ -38,6 +31,10 @@ var onSupplyEvent = { ...@@ -38,6 +31,10 @@ var onSupplyEvent = {
var deleteForm_Event = "FMS_FormDelete_commonEvent"; var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnAcquired;
var subscriberOnState;
var subscriberSupply;
export default function test() { export default function test() {
describe(`FmsStateFormTest`, () => { describe(`FmsStateFormTest`, () => {
...@@ -45,6 +42,13 @@ export default function test() { ...@@ -45,6 +42,13 @@ export default function test() {
done(); done();
}) })
beforeEach(async () => {
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
subscriberSupply = await commonEvent.createSubscriber(onSupplyEvent);
})
/** /**
* @tc.number: FMS_notifyVisibleForms_0200 * @tc.number: FMS_notifyVisibleForms_0200
* @tc.name: The form user does not have permission. * @tc.name: The form user does not have permission.
...@@ -53,29 +57,20 @@ export default function test() { ...@@ -53,29 +57,20 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_0200`, 0, async (done) => { it(`FMS_notifyVisibleForms_0200`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_0200 start`); console.log(`FMS_notifyVisibleForms_0200 start`);
let subscriberOnState;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_0200 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_0200 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("2"); expect(data.data).assertEqual("2");
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallBack); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_0200"));
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyVisibleForms_0200 onStateCallBack end'); console.info('FMS_notifyVisibleForms_0200 onStateCallBack end');
console.log(`FMS_notifyVisibleForms_0200 end`); console.log(`FMS_notifyVisibleForms_0200 end`);
done(); done();
}, 1000) }, 1000)
} }
function unsubscribeOnStateCallBack() {
console.debug("====>FMS_notifyVisibleForms_0200 unsubscribeOnStateCallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_0200 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyVisibleForms_0200 featureAbility.startAbility again start`); console.log(`FMS_notifyVisibleForms_0200 featureAbility.startAbility again start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -108,30 +103,21 @@ export default function test() { ...@@ -108,30 +103,21 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_0300`, 0, async (done) => { it(`FMS_notifyVisibleForms_0300`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_0300 start`); console.log(`FMS_notifyVisibleForms_0300 start`);
let subscriberOnState;
let formId;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_0300 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_0300 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("7"); expect(data.data).assertEqual("7");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_0300"));
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyVisibleForms_0300 delPublishCallBack end'); console.info('FMS_notifyVisibleForms_0300 delPublishCallBack end');
console.log(`FMS_notifyVisibleForms_0300 end`); console.log(`FMS_notifyVisibleForms_0300 end`);
done(); done();
}, 100) }, 100)
} }
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyVisibleForms_0300 unSubscribeOnStateCallback CallBack====>"); commonEvent.subscribe(subscriberOnState, onStateCallBack);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_0300 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_notifyVisibleForms_0300 featureAbility.startAbility start`); console.log(`FMS_notifyVisibleForms_0300 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -164,29 +150,20 @@ export default function test() { ...@@ -164,29 +150,20 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_0400`, 0, async (done) => { it(`FMS_notifyVisibleForms_0400`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_0400 start`); console.log(`FMS_notifyVisibleForms_0400 start`);
let subscriberOnState; function onStateCallBack(_, data) {
let formId;
function onStateCallBack(err, data) {
console.info("!!!====>FMS_notifyVisibleForms_0400 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_0400 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_0400"))
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyVisibleForms_0400 delPublishCallBack end'); console.info('FMS_notifyVisibleForms_0400 delPublishCallBack end');
console.log(`FMS_notifyVisibleForms_0400 end`); console.log(`FMS_notifyVisibleForms_0400 end`);
done(); done();
}, 100) }, 100)
} }
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyVisibleForms_0400 unSubscribeOnStateCallback CallBack====>"); commonEvent.subscribe(subscriberOnState, onStateCallBack);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_0400 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_notifyVisibleForms_0400 featureAbility.startAbility start`); console.log(`FMS_notifyVisibleForms_0400 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -219,30 +196,21 @@ export default function test() { ...@@ -219,30 +196,21 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_0500`, 0, async (done) => { it(`FMS_notifyVisibleForms_0500`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_0500 start`); console.log(`FMS_notifyVisibleForms_0500 start`);
let subscriberOnState;
let formId;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_0500 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_0500 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_0500"))
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyVisibleForms_0500 delPublishCallBack end'); console.info('FMS_notifyVisibleForms_0500 delPublishCallBack end');
console.log(`FMS_notifyVisibleForms_0500 end`); console.log(`FMS_notifyVisibleForms_0500 end`);
done(); done();
}, 100); }, 100);
} }
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyVisibleForms_0500 unSubscribeOnStateCallback CallBack====>"); commonEvent.subscribe(subscriberOnState, onStateCallBack);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_0500 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_notifyVisibleForms_0500 featureAbility.startAbility start`); console.log(`FMS_notifyVisibleForms_0500 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -275,46 +243,24 @@ export default function test() { ...@@ -275,46 +243,24 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_0600`, 0, async (done) => { it(`FMS_notifyVisibleForms_0600`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_0600 start`); console.log(`FMS_notifyVisibleForms_0600 start`);
let subscriberOnState;
let subscriberOnAcquired;
let formId; let formId;
function delPublishCallBack() { function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_0600 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_notifyVisibleForms_0600 delPublishCallBack end');
console.log(`FMS_notifyVisibleForms_0600 end`);
done();
}, 1000);
}
function onStateCallBack(err, data) {
console.info("!!!====>FMS_notifyVisibleForms_0600 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_0600 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_0600"));
let commonEventPublishData = { let commonEventPublishData = {
data: formId data: formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyVisibleForms_0600", done));
}
function unsubscribeOnStateCallback() {
console.debug("====>FMS_notifyVisibleForms_0600 unsubscribeOnStateCallback====>");
}
function unSubscribeOnAcquiredCallback() {
console.debug("====>FMS_notifyVisibleForms_0600 OnAcquired UnSubscribe CallBack====>");
} }
async function onAcquiredCallBack(err, data) { async function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_0600 onAcquiredCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_0600 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback) commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_notifyVisibleForms_0600"))
formId = data.data; formId = data.data;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.debug("====>FMS_notifyVisibleForms_0600 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbility again start`); console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbility again start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -339,12 +285,8 @@ export default function test() { ...@@ -339,12 +285,8 @@ export default function test() {
}); });
console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbility again end`); console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbility again end`);
} }
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.debug("====>FMS_notifyVisibleForms_0600 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbility start`); console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -375,34 +317,21 @@ export default function test() { ...@@ -375,34 +317,21 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_0700`, 0, async (done) => { it(`FMS_notifyVisibleForms_0700`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_0700 start`); console.log(`FMS_notifyVisibleForms_0700 start`);
let subscriberOnState;
let formId;
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_0700 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_0700 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_0700"));
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyVisibleForms_0700 onStateCallBack end'); console.info('FMS_notifyVisibleForms_0700 onStateCallBack end');
console.log(`FMS_notifyVisibleForms_0700 end`); console.log(`FMS_notifyVisibleForms_0700 end`);
done(); done();
}, 100); }, 100);
}
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyVisibleForms_0700 unSubscribeOnStateCallback CallBack====>");
}
function unSubscribeDeletedCallback() {
console.debug("====>FMS_notifyVisibleForms_0700 unSubscribeDeletedCallback CallBack====>");
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.debug("====>FMS_notifyVisibleForms_0700 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_notifyVisibleForms_0700 featureAbility.startAbility again start`); console.log(`FMS_notifyVisibleForms_0700 featureAbility.startAbility again start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -436,74 +365,49 @@ export default function test() { ...@@ -436,74 +365,49 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_1000`, 0, async (done) => { it(`FMS_notifyVisibleForms_1000`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1000 start`); console.log(`FMS_notifyVisibleForms_1000 start`);
let subscriberInvisible;
let subscriberVisible;
let subscriberSupply;
let supplyFlag = false;
let formIdInvisible; let formIdInvisible;
let formIdVisible; let formIdVisible;
let onSupplyCount = 0; let onSupplyCount = 0;
function unSubscribeSupplyCallback() {
console.debug("====>FMS_notifyVisibleForms_1000 unSubscribeSupplyCallback====>");
}
function delPublishCallBack(err, data) {
console.info("!!!====>FMS_notifyVisibleForms_1000 delPublishCallBack====>");
setTimeout(function () {
console.info('FMS_notifyVisibleForms_1000 delPublishCallBack end');
console.log(`FMS_notifyVisibleForms_1000 end`);
done();
}, 1000);
}
function onSupplyCallBack(err, data) { function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") { if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyVisibleForms_1000 onSupplyCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyVisibleForms_1000 onSupplyCallBack====>" + JSON.stringify(data));
onSupplyCount++; onSupplyCount++;
if (onSupplyCount == 2) { if (onSupplyCount == 2) {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1000"));
} }
if (formIdInvisible && formIdVisible) { if (formIdInvisible && formIdVisible) {
let commonEventPublishData = { let commonEventPublishData = {
data: formIdInvisible data: formIdInvisible
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyVisibleForms_1000", done));
} }
} }
} }
function onVisibleCallBack(err, data) { function onVisibleCallBack(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_1000 onVisibleCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_1000 onVisibleCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
formIdVisible = data.parameters.formId; formIdVisible = data.parameters.formId;
commonEvent.unsubscribe(subscriberVisible, unSubscribeOnVisibleCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_1000"));
if (formIdInvisible && formIdVisible && onSupplyCount == 2) { if (formIdInvisible && formIdVisible && onSupplyCount == 2) {
let commonEventPublishData = { let commonEventPublishData = {
data: formIdInvisible data: formIdInvisible
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyVisibleForms_1000", done));
} }
} }
function unSubscribeOnVisibleCallback() { async function OnInvisibleCallBack(_, data) {
console.debug("====>FMS_notifyVisibleForms_1000 unSubscribeOnVisibleCallback CallBack====>");
}
function unSubscribeOnInvisibleCallback(){
console.debug("====>FMS_notifyVisibleForms_1000 unSubscribeOnInvisibleCallback CallBack====>");
}
async function OnInvisibleCallBack(err, data) {
console.info("!!!====>FMS_notifyVisibleForms_1000 OnInvisibleCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_1000 OnInvisibleCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberInvisible, unSubscribeOnInvisibleCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_1000"))
formIdInvisible = data.parameters.formId; formIdInvisible = data.parameters.formId;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1000 B onStateFormEvent Subscriber====>");
subscriberVisible = data;
await commonEvent.subscribe(subscriberVisible, onVisibleCallBack);
});
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
commonEvent.subscribe(subscriberOnState, onVisibleCallBack);
console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbility again start`); console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbility again start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -529,16 +433,8 @@ export default function test() { ...@@ -529,16 +433,8 @@ export default function test() {
console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbility again end`); console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbility again end`);
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, OnInvisibleCallBack);
console.debug("====>FMS_notifyVisibleForms_1300 onStateFormEvent Invisible Subscriber====>"); commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
subscriberInvisible = data;
await commonEvent.subscribe(subscriberInvisible, OnInvisibleCallBack);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1300 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbility start`); console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -571,25 +467,12 @@ export default function test() { ...@@ -571,25 +467,12 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_1100`, 0, async (done) => { it(`FMS_notifyVisibleForms_1100`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1100 start`); console.log(`FMS_notifyVisibleForms_1100 start`);
let subscriberSupply;
let subscriberOnVisible;
let assertFormId; let assertFormId;
function unSubscribeSupplyCallback() { function onSupplyCallBack(_, data) {
console.debug("====>FMS_notifyVisibleForms_1100 unSubscribeSupplyCallback====>");
}
function delPublishCallBack(err, data) {
console.info("!!!====>FMS_notifyVisibleForms_1100 delPublishCallBack====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_notifyVisibleForms_1100 delPublishCallBack end');
console.log(`FMS_notifyVisibleForms_1100 end`);
done();
}, 1000);
}
function onSupplyCallBack(err, data) {
if (data.parameters.kind == "onVisibilityChange") { if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1100"));
console.debug("====>FMS_notifyVisibleForms_1100 onSupplyCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyVisibleForms_1100 onSupplyCallBack====>" + JSON.stringify(data));
let formId = Object.keys(JSON.parse(data.parameters.parameters))[0]; let formId = Object.keys(JSON.parse(data.parameters.parameters))[0];
const visibilityStatus = JSON.parse(data.parameters.parameters)[formId]; const visibilityStatus = JSON.parse(data.parameters.parameters)[formId];
...@@ -599,15 +482,11 @@ export default function test() { ...@@ -599,15 +482,11 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: formId data: formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyVisibleForms_1000", done));
} }
} }
function unSubscribeOnVisibleCallback() { function onVisibleCallBack(_, data) {
console.debug("====>FMS_notifyVisibleForms_1100 unSubscribeOnVisibleCallback CallBack====>");
}
function onVisibleCallBack(err, data) {
if (data.parameters.kind != "visible") { if (data.parameters.kind != "visible") {
return; return;
} }
...@@ -616,18 +495,11 @@ export default function test() { ...@@ -616,18 +495,11 @@ export default function test() {
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
assertFormId = data.parameters.formId; assertFormId = data.parameters.formId;
commonEvent.unsubscribe(subscriberOnVisible, unSubscribeOnVisibleCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_1100"));
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1100 onStateFormEvent Visible Subscriber====>"); commonEvent.subscribe(subscriberOnState, onVisibleCallBack);
subscriberOnVisible = data; commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
await commonEvent.subscribe(subscriberOnVisible, onVisibleCallBack);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1100 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
console.log(`FMS_notifyVisibleForms_1100 featureAbility.startAbility start`); console.log(`FMS_notifyVisibleForms_1100 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -662,25 +534,8 @@ export default function test() { ...@@ -662,25 +534,8 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_1200`, 0, async (done) => { it(`FMS_notifyVisibleForms_1200`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1200 start`); console.log(`FMS_notifyVisibleForms_1200 start`);
let subscriberOnVisible;
let subscriberOnSupply;
function delPublishCallBack(err, data) {
console.info("!!!====>FMS_notifyVisibleForms_1200 delPublishCallBack====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_notifyVisibleForms_1200 delPublishCallBack end');
console.log(`FMS_notifyVisibleForms_1200 end`);
done();
}, 1000);
}
function unSubscribeOnVisibleCallback() { function onVisibleCallBack(_, data) {
console.debug("====>FMS_notifyVisibleForms_1200 unSubscribeOnVisibleCallback CallBack====>");
}
function unSubscribeSupplyCallback() {
console.debug("====>FMS_notifyVisibleForms_1200 unSubscribeSupplyCallback CallBack====>");
}
function onVisibleCallBack(err, data) {
if (data.parameters.kind != "visible") { if (data.parameters.kind != "visible") {
return; return;
} }
...@@ -689,35 +544,28 @@ export default function test() { ...@@ -689,35 +544,28 @@ export default function test() {
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
setTimeout(function () { setTimeout(function () {
commonEvent.unsubscribe(subscriberOnVisible, unSubscribeOnVisibleCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_1200"));
commonEvent.unsubscribe(subscriberOnSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1200"));
let commonEventPublishData = { let commonEventPublishData = {
data: data.parameters.formId data: data.parameters.formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyVisibleForms_1200", done));
}, 2000); }, 2000);
} }
function onSupplyEventCallBack(err, data) { function onSupplyEventCallBack(_, data) {
if (data.parameters.kind != "onVisibilityChange") { if (data.parameters.kind != "onVisibilityChange") {
return; return;
} }
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
commonEvent.unsubscribe(subscriberOnSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1200"));
console.debug("====>FMS_notifyVisibleForms_1200 onSupplyEventCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyVisibleForms_1200 onSupplyEventCallBack====>" + JSON.stringify(data));
console.log(`FMS_notifyVisibleForms_1200 error`); console.log(`FMS_notifyVisibleForms_1200 error`);
expect().assertFail(); expect().assertFail();
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1200 onStateFormEvent Visible Subscriber====>"); commonEvent.subscribe(subscriberOnState, onVisibleCallBack);
subscriberOnVisible = data; commonEvent.subscribe(subscriberSupply, onSupplyEventCallBack);
await commonEvent.subscribe(subscriberOnVisible, onVisibleCallBack);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1200 onSupplyEvent Visible Subscriber====>");
subscriberOnSupply = data;
await commonEvent.subscribe(subscriberOnSupply, onSupplyEventCallBack);
});
console.log(`FMS_notifyVisibleForms_1200 featureAbility.startAbility start`); console.log(`FMS_notifyVisibleForms_1200 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -751,21 +599,8 @@ export default function test() { ...@@ -751,21 +599,8 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_1300`, 0, async (done) => { it(`FMS_notifyVisibleForms_1300`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1300 start`); console.log(`FMS_notifyVisibleForms_1300 start`);
let subscriberOnVisible;
function delPublishCallBack(err, data) {
console.info("!!!====>FMS_notifyVisibleForms_1300 delPublishCallBack====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_notifyVisibleForms_1300 delPublishCallBack end');
console.log(`FMS_notifyVisibleForms_1300 end`);
done();
}, 1000);
}
function unSubscribeOnVisibleCallback() { function OnVisibleCallBack(_, data) {
console.debug("====>FMS_notifyVisibleForms_1300 unSubscribeOnVisibleCallback CallBack====>");
}
function OnVisibleCallBack(err, data) {
if (data.parameters.kind != "visible") { if (data.parameters.kind != "visible") {
return; return;
} }
...@@ -773,18 +608,15 @@ export default function test() { ...@@ -773,18 +608,15 @@ export default function test() {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnVisible, unSubscribeOnVisibleCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_1300"));
let commonEventPublishData = { let commonEventPublishData = {
data: data.parameters.formId data: data.parameters.formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyVisibleForms_1300", done));
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1300 onStateFormEvent Visible Subscriber====>"); commonEvent.subscribe(subscriberOnState, OnVisibleCallBack);
subscriberOnVisible = data;
await commonEvent.subscribe(subscriberOnVisible, OnVisibleCallBack);
});
console.log(`FMS_notifyVisibleForms_1300 featureAbility.startAbility start`); console.log(`FMS_notifyVisibleForms_1300 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -820,9 +652,6 @@ export default function test() { ...@@ -820,9 +652,6 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_1400`, 0, async (done) => { it(`FMS_notifyVisibleForms_1400`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1400 start`); console.log(`FMS_notifyVisibleForms_1400 start`);
let subscriberOnAcquired;
let subscriberOnState;
let subscriberSupply;
let supplyFlag = false; let supplyFlag = false;
let formId1; let formId1;
let formId2; let formId2;
...@@ -834,7 +663,7 @@ export default function test() { ...@@ -834,7 +663,7 @@ export default function test() {
delCount++; delCount++;
if (delCount == 2) { if (delCount == 2) {
setTimeout(function () { setTimeout(function () {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1400"));
if (supplyFlag) { if (supplyFlag) {
expect().assertFail(); expect().assertFail();
} }
...@@ -844,7 +673,7 @@ export default function test() { ...@@ -844,7 +673,7 @@ export default function test() {
}, 1000); }, 1000);
} }
} }
function onAcquiredCallBack_Normal1(err, data) { function onAcquiredCallBack_Normal1(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_1400 onAcquiredCallBack_Normal1 data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_1400 onAcquiredCallBack_Normal1 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal1) commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal1)
...@@ -853,17 +682,11 @@ export default function test() { ...@@ -853,17 +682,11 @@ export default function test() {
FMS_notifyVisibleForms_1400_normal2(); FMS_notifyVisibleForms_1400_normal2();
} }
function unSubscribeOnAcquiredCallBack_Normal1() { function unSubscribeOnAcquiredCallBack_Normal1() {
console.debug("====>FMS_notifyVisibleForms_1400 unSubscribeOnAcquiredCallBack_Normal1 CallBack====>"); console.debug("====>FMS_notifyVisibleForms_1400 unSubscribeOnAcquiredCallBack_Normal2====>");
} }
async function FMS_notifyVisibleForms_1400_normal1() { async function FMS_notifyVisibleForms_1400_normal1() {
console.log(`FMS_notifyVisibleForms_1400_normal1 start`); console.log(`FMS_notifyVisibleForms_1400_normal1 start`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1);
console.debug("====>FMS_notifyVisibleForms_1400_normal1 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1);
});
console.log(`FMS_notifyVisibleForms_1400_normal1 featureAbility.startAbility start`); console.log(`FMS_notifyVisibleForms_1400_normal1 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -889,11 +712,11 @@ export default function test() { ...@@ -889,11 +712,11 @@ export default function test() {
console.log(`FMS_notifyVisibleForms_1400_normal1 end`); console.log(`FMS_notifyVisibleForms_1400_normal1 end`);
} }
function onStateCallBack(err, data) { function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_1400 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_1400 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_1400"))
console.info("!!!====>FMS_notifyVisibleForms_1400 onStateCallBack formId1:====>" + formId1); console.info("!!!====>FMS_notifyVisibleForms_1400 onStateCallBack formId1:====>" + formId1);
console.info("!!!====>FMS_notifyVisibleForms_1400 onStateCallBack formId2:====>" + formId2); console.info("!!!====>FMS_notifyVisibleForms_1400 onStateCallBack formId2:====>" + formId2);
console.info("!!!====>FMS_notifyVisibleForms_1400 onStateCallBack onSupplyCount:====>" + onSupplyCount); console.info("!!!====>FMS_notifyVisibleForms_1400 onStateCallBack onSupplyCount:====>" + onSupplyCount);
...@@ -908,21 +731,15 @@ export default function test() { ...@@ -908,21 +731,15 @@ export default function test() {
commonEvent.publish(deleteForm_Event, commonEventPublishData2, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData2, delPublishCallBack);
} }
} }
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyVisibleForms_1400 unSubscribeOnStateCallback CallBack====>");
}
async function onAcquiredCallBack_Normal2(err, data) { async function onAcquiredCallBack_Normal2(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_1400 onAcquiredCallBack_Normal2 data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_1400 onAcquiredCallBack_Normal2 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal2); commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal2);
formId2 = data.data; formId2 = data.data;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1400 onStateFormEvent Subscriber====>"); commonEvent.subscribe(subscriberOnState, onStateCallBack);
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_notifyVisibleForms_1400 featureAbility.startAbility start`); console.log(`FMS_notifyVisibleForms_1400 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
...@@ -952,12 +769,8 @@ export default function test() { ...@@ -952,12 +769,8 @@ export default function test() {
console.debug("====>FMS_notifyVisibleForms_1400 unSubscribeOnAcquiredCallBack_Normal2====>"); console.debug("====>FMS_notifyVisibleForms_1400 unSubscribeOnAcquiredCallBack_Normal2====>");
} }
async function FMS_notifyVisibleForms_1400_normal2() { async function FMS_notifyVisibleForms_1400_normal2() {
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
console.debug("====>FMS_notifyVisibleForms_1400_normal2 Create OnAcquired Subscriber====>"); commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
});
console.log(`FMS_notifyVisibleForms_1400_normal2 featureAbility.startAbility start`); console.log(`FMS_notifyVisibleForms_1400_normal2 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -981,10 +794,7 @@ export default function test() { ...@@ -981,10 +794,7 @@ export default function test() {
console.log(`FMS_notifyVisibleForms_1400_normal2 featureAbility.startAbility end`); console.log(`FMS_notifyVisibleForms_1400_normal2 featureAbility.startAbility end`);
} }
function unSubscribeSupplyCallback() { function onSupplyCallBack(_, data) {
console.debug("====>FMS_notifyVisibleForms_1400 unSubscribeSupplyCallback====>");
}
function onSupplyCallBack(err, data) {
if (data.parameters.kind == "onVisibilityChange") { if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyVisibleForms_1400 onSupplyCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyVisibleForms_1400 onSupplyCallBack====>" + JSON.stringify(data));
...@@ -999,10 +809,10 @@ export default function test() { ...@@ -999,10 +809,10 @@ export default function test() {
onSupplyCount++; onSupplyCount++;
if (onSupplyCount == 2) { if (onSupplyCount == 2) {
supplyFlag = true; supplyFlag = true;
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1400"));
} }
if (formId1 && formId2) { if (formId1 && formId2) {
let commonEventPublishData = { let commonEventPublishData = {
data: formId1 data: formId1
}; };
...@@ -1014,11 +824,7 @@ export default function test() { ...@@ -1014,11 +824,7 @@ export default function test() {
} }
} }
} }
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.debug("====>FMS_notifyVisibleForms_1400 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
FMS_notifyVisibleForms_1400_normal1(); FMS_notifyVisibleForms_1400_normal1();
}); });
/** /**
...@@ -1029,23 +835,17 @@ export default function test() { ...@@ -1029,23 +835,17 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_1500`, 0, async (done) => { it(`FMS_notifyVisibleForms_1500`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1500 start`); console.log(`FMS_notifyVisibleForms_1500 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formIds = new Array(); let formIds = new Array();
let retFormId;
let count = 0; let count = 0;
function unSubscribeSupplyCallback() { function delPublishCallBack1(_, data) {
console.debug("====>FMS_notifyVisibleForms_1500 unSubscribeSupplyCallback====>");
}
function delPublishCallBack1(err, data) {
console.info("!!!====>FMS_notifyVisibleForms_1500 delPublishCallBack1====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_1500 delPublishCallBack1====>" + JSON.stringify(data));
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyVisibleForms_1500 delPublishCallBack1 end'); console.info('FMS_notifyVisibleForms_1500 delPublishCallBack1 end');
console.log(`FMS_notifyVisibleForms_1500 end`); console.log(`FMS_notifyVisibleForms_1500 end`);
}, 1000); }, 1000);
} }
function delPublishCallBack2(err, data) { function delPublishCallBack2(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_1500 delPublishCallBack2====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_1500 delPublishCallBack2====>" + JSON.stringify(data));
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyVisibleForms_1500 delPublishCallBack2 end'); console.info('FMS_notifyVisibleForms_1500 delPublishCallBack2 end');
...@@ -1054,7 +854,7 @@ export default function test() { ...@@ -1054,7 +854,7 @@ export default function test() {
}, 1000); }, 1000);
} }
function onInVisibleSupplyCallBack(err, data) { function onInVisibleSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") { if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyVisibleForms_1500 onInVisibleSupplyCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyVisibleForms_1500 onInVisibleSupplyCallBack====>" + JSON.stringify(data));
...@@ -1066,7 +866,7 @@ export default function test() { ...@@ -1066,7 +866,7 @@ export default function test() {
++count; ++count;
if (count == 12) { if (count == 12) {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1500"));
let commonEventPublishData1 = { let commonEventPublishData1 = {
data: formIds[0] data: formIds[0]
}; };
...@@ -1079,7 +879,7 @@ export default function test() { ...@@ -1079,7 +879,7 @@ export default function test() {
} }
} }
async function onVisibleSupplyCallBack(err, data) { async function onVisibleSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") { if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyVisibleForms_1500 onVisibleSupplyCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyVisibleForms_1500 onVisibleSupplyCallBack====>" + JSON.stringify(data));
...@@ -1091,12 +891,9 @@ export default function test() { ...@@ -1091,12 +891,9 @@ export default function test() {
++count; ++count;
if (count == 6) { if (count == 6) {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1500"));
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { subscriberSupply = await commonEvent.createSubscriber(onSupplyEvent);
console.debug("====>FMS_notifyVisibleForms_1500 onSupplyEvent Subscriber====>"); commonEvent.subscribe(subscriberSupply, onInVisibleSupplyCallBack);
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onInVisibleSupplyCallBack);
});
console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility notifyInvisible start`); console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility notifyInvisible start`);
for (var i = 0; i < 3; i++) { for (var i = 0; i < 3; i++) {
await featureAbility.startAbility({ await featureAbility.startAbility({
...@@ -1120,19 +917,15 @@ export default function test() { ...@@ -1120,19 +917,15 @@ export default function test() {
} }
} }
async function onAcquiredCallBack2(err, data) { async function onAcquiredCallBack2(_, data) {
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1500"));
console.debug("====>FMS_notifyVisibleForms_1500 onAcquiredCallBack2====>" + JSON.stringify(data)); console.debug("====>FMS_notifyVisibleForms_1500 onAcquiredCallBack2====>" + JSON.stringify(data));
formIds.push(data.data); formIds.push(data.data);
console.debug("====>FMS_notifyVisibleForms_1500 formIds====>" + formIds); console.debug("====>FMS_notifyVisibleForms_1500 formIds====>" + formIds);
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
console.debug("====>FMS_notifyVisibleForms_1500 onSupplyEvent Subscriber====>"); commonEvent.subscribe(subscriberSupply, onVisibleSupplyCallBack);
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onVisibleSupplyCallBack);
});
console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility notifyVisible start`); console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility notifyVisible start`);
for (var i = 0; i < 3; i++) { for (var i = 0; i < 3; i++) {
await featureAbility.startAbility({ await featureAbility.startAbility({
...@@ -1154,19 +947,15 @@ export default function test() { ...@@ -1154,19 +947,15 @@ export default function test() {
console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility notifyVisible end`); console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility notifyVisible end`);
} }
async function onAcquiredCallBack1(err, data) { async function onAcquiredCallBack1(_, data) {
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1500"));
console.debug("====>FMS_notifyVisibleForms_1500 onAcquiredCallBack1====>" + JSON.stringify(data)); console.debug("====>FMS_notifyVisibleForms_1500 onAcquiredCallBack1====>" + JSON.stringify(data));
formIds.push(data.data); formIds.push(data.data);
console.debug("====>FMS_notifyVisibleForms_1500 formIds====>" + JSON.stringify(formIds)); console.debug("====>FMS_notifyVisibleForms_1500 formIds====>" + JSON.stringify(formIds));
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
console.debug("====>FMS_notifyVisibleForms_1500 onAcquiredForm_Event Subscriber====>"); commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack2);
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack2);
});
console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility serviceb start`); console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility serviceb start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -1190,11 +979,7 @@ export default function test() { ...@@ -1190,11 +979,7 @@ export default function test() {
console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility serviceb end`); console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility serviceb end`);
} }
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack1);
console.debug("====>FMS_notifyVisibleForms_1500 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack1);
});
console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility servicea start`); console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -1226,23 +1011,17 @@ export default function test() { ...@@ -1226,23 +1011,17 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_1600`, 0, async (done) => { it(`FMS_notifyVisibleForms_1600`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1600 start`); console.log(`FMS_notifyVisibleForms_1600 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formIds = new Array(); let formIds = new Array();
let retFormId;
let count = 0; let count = 0;
function unSubscribeSupplyCallback() { function delPublishCallBack1(_, data) {
console.debug("====>FMS_notifyVisibleForms_1600 unSubscribeSupplyCallback====>");
}
function delPublishCallBack1(err, data) {
console.info("!!!====>FMS_notifyVisibleForms_1600 delPublishCallBack1====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_1600 delPublishCallBack1====>" + JSON.stringify(data));
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyVisibleForms_1600 delPublishCallBack1 end'); console.info('FMS_notifyVisibleForms_1600 delPublishCallBack1 end');
console.log(`FMS_notifyVisibleForms_1600 end`); console.log(`FMS_notifyVisibleForms_1600 end`);
}, 1000); }, 1000);
} }
function delPublishCallBack2(err, data) { function delPublishCallBack2(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_1600 delPublishCallBack2====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_1600 delPublishCallBack2====>" + JSON.stringify(data));
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyVisibleForms_1600 delPublishCallBack2 end'); console.info('FMS_notifyVisibleForms_1600 delPublishCallBack2 end');
...@@ -1251,7 +1030,7 @@ export default function test() { ...@@ -1251,7 +1030,7 @@ export default function test() {
}, 1000); }, 1000);
} }
function onSupplyCallBack(err, data) { function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") { if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyVisibleForms_1600 onSupplyCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyVisibleForms_1600 onSupplyCallBack====>" + JSON.stringify(data));
...@@ -1264,7 +1043,7 @@ export default function test() { ...@@ -1264,7 +1043,7 @@ export default function test() {
++count; ++count;
if (count == 2) { if (count == 2) {
console.debug("====>FMS_notifyVisibleForms_1600 OK====>"); console.debug("====>FMS_notifyVisibleForms_1600 OK====>");
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1500"));
let commonEventPublishData1 = { let commonEventPublishData1 = {
data: formIds[0] data: formIds[0]
...@@ -1278,20 +1057,15 @@ export default function test() { ...@@ -1278,20 +1057,15 @@ export default function test() {
} }
} }
async function onSecondAcquiredCallBack(err, data) { async function onSecondAcquiredCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_notifyVisibleForms_1500"));
console.debug("====>FMS_notifyVisibleForms_1600 onSecondAcquiredCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyVisibleForms_1600 onSecondAcquiredCallBack====>" + JSON.stringify(data));
formIds.push(data.data); formIds.push(data.data);
formIds.push("-1"); formIds.push("-1");
console.debug("====>FMS_notifyVisibleForms_1600 formIds====>" + formIds); console.debug("====>FMS_notifyVisibleForms_1600 formIds====>" + formIds);
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => { commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.debug("====>FMS_notifyVisibleForms_1600 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility notifyVisible start`); console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility notifyVisible start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -1317,18 +1091,14 @@ export default function test() { ...@@ -1317,18 +1091,14 @@ export default function test() {
console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility notifyVisible end`); console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility notifyVisible end`);
} }
async function onFirstAcquiredCallBack(err, data) { async function onFirstAcquiredCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent"); expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_notifyVisibleForms_1500"));
console.debug("====>FMS_notifyVisibleForms_1600 onFirstAcquiredCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyVisibleForms_1600 onFirstAcquiredCallBack====>" + JSON.stringify(data));
formIds.push(data.data); formIds.push(data.data);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
console.debug("====>FMS_notifyVisibleForms_1600 onAcquiredForm_Event Subscriber====>"); commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack);
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack);
});
console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility serviceb start`); console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility serviceb start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -1352,11 +1122,7 @@ export default function test() { ...@@ -1352,11 +1122,7 @@ export default function test() {
console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility serviceb end`); console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility serviceb end`);
} }
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => { commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack);
console.debug("====>FMS_notifyVisibleForms_1600 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack);
});
console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility servicea start`); console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -1388,25 +1154,10 @@ export default function test() { ...@@ -1388,25 +1154,10 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_1700`, 0, async (done) => { it(`FMS_notifyVisibleForms_1700`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1700 start`); console.log(`FMS_notifyVisibleForms_1700 start`);
let subscriberVisible;
let subscriberSupply;
function unSubscribeSupplyCallback() {
console.debug("====>FMS_notifyVisibleForms_1700 unSubscribeSupplyCallback====>");
}
function delPublishCallBack(err, data) {
console.info("!!!====>FMS_notifyVisibleForms_1700 delPublishCallBack====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_notifyVisibleForms_1700 delPublishCallBack end');
console.log(`FMS_notifyVisibleForms_1700 end`);
done();
}, 1000);
}
function onFormVisibleCallBack(err, data) { function onFormVisibleCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
commonEvent.unsubscribe(subscriberVisible, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberOnState, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1700"));
console.debug("====>FMS_notifyVisibleForms_1700 onFirstAcquiredCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyVisibleForms_1700 onFirstAcquiredCallBack====>" + JSON.stringify(data));
expect(data.parameters.kind).assertEqual("visible"); expect(data.parameters.kind).assertEqual("visible");
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
...@@ -1415,13 +1166,13 @@ export default function test() { ...@@ -1415,13 +1166,13 @@ export default function test() {
let commonEventPublishData = { let commonEventPublishData = {
data: data.parameters.formId data: data.parameters.formId
}; };
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack); commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyVisibleForms_1700", done));
}, 2000); }, 2000);
} }
function onFormSupplyCallBack(err, data) { function onFormSupplyCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent"); expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback); commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1700"));
console.debug("====>FMS_notifyVisibleForms_1700 onFormSupplyCallBack====>" + JSON.stringify(data)); console.debug("====>FMS_notifyVisibleForms_1700 onFormSupplyCallBack====>" + JSON.stringify(data));
if (data.parameters.kind == "onVisibilityChange") { if (data.parameters.kind == "onVisibilityChange") {
console.debug("====>FMS_notifyVisibleForms_1700 error"); console.debug("====>FMS_notifyVisibleForms_1700 error");
...@@ -1429,18 +1180,8 @@ export default function test() { ...@@ -1429,18 +1180,8 @@ export default function test() {
} }
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onFormVisibleCallBack);
console.debug("====>FMS_notifyVisibleForms_1700 onStateFormEvent Subscriber====>"); commonEvent.subscribe(subscriberSupply, onFormSupplyCallBack);
subscriberVisible = data;
await commonEvent.subscribe(subscriberVisible, onFormVisibleCallBack);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1700 onStateFormEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onFormSupplyCallBack);
});
console.log(`FMS_notifyVisibleForms_1700 featureAbility.startAbility servicea start`); console.log(`FMS_notifyVisibleForms_1700 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -1475,13 +1216,11 @@ export default function test() { ...@@ -1475,13 +1216,11 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_1800`, 0, async (done) => { it(`FMS_notifyVisibleForms_1800`, 0, async (done) => {
console.info(`FMS_notifyVisibleForms_1800 start`); console.info(`FMS_notifyVisibleForms_1800 start`);
let subscriberVisible;
let subscriberSupply;
let hostFormId; let hostFormId;
let providerFormId; let providerFormId;
let counter = 0; let counter = 0;
const delPublishCallback = (err, data) => { const delPublishCallback = (_, data) => {
console.info("!!!====>FMS_notifyVisibleForms_1800 delPublishCallback====>"); console.info("!!!====>FMS_notifyVisibleForms_1800 delPublishCallback====>");
setTimeout(() => { setTimeout(() => {
expect(hostFormId).assertEqual(providerFormId); expect(hostFormId).assertEqual(providerFormId);
...@@ -1491,7 +1230,7 @@ export default function test() { ...@@ -1491,7 +1230,7 @@ export default function test() {
}, 1000); }, 1000);
} }
const onSupplyCallback = (err, data) => { const onSupplyCallback = (_, data) => {
if (data.parameters.kind != "onVisibilityChange") { if (data.parameters.kind != "onVisibilityChange") {
return; return;
} }
...@@ -1511,7 +1250,7 @@ export default function test() { ...@@ -1511,7 +1250,7 @@ export default function test() {
} }
} }
const onVisibleCallback = (err, data) => { const onVisibleCallback = (_, data) => {
if (data.parameters.kind != "visible") { if (data.parameters.kind != "visible") {
return; return;
} }
...@@ -1519,7 +1258,7 @@ export default function test() { ...@@ -1519,7 +1258,7 @@ export default function test() {
hostFormId = data.parameters.formId; hostFormId = data.parameters.formId;
expect(data.data).assertEqual("0"); expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberVisible, () => { commonEvent.unsubscribe(subscriberOnState, () => {
console.info("====>FMS_notifyVisibleForms_1800 unSubscribeOnVisibleCallback====>"); console.info("====>FMS_notifyVisibleForms_1800 unSubscribeOnVisibleCallback====>");
}); });
if (++counter == 2) { if (++counter == 2) {
...@@ -1530,17 +1269,8 @@ export default function test() { ...@@ -1530,17 +1269,8 @@ export default function test() {
} }
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onVisibleCallback);
console.info("====>FMS_notifyVisibleForms_1800 onStateFormEvent Visible Subscriber====>"); commonEvent.subscribe(subscriberSupply, onSupplyCallback);
subscriberVisible = data;
await commonEvent.subscribe(subscriberVisible, onVisibleCallback);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.info("====>FMS_notifyVisibleForms_1800 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallback);
});
console.info(`FMS_notifyVisibleForms_1800 featureAbility.startAbility start`); console.info(`FMS_notifyVisibleForms_1800 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -1571,29 +1301,21 @@ export default function test() { ...@@ -1571,29 +1301,21 @@ export default function test() {
*/ */
it(`FMS_notifyVisibleForms_1900`, 0, async (done) => { it(`FMS_notifyVisibleForms_1900`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1900 start`); console.log(`FMS_notifyVisibleForms_1900 start`);
let subscriberOnState;
let formId; function onStateCallBack(_, data) {
function onStateCallBack(err, data) {
console.info("!!!====>FMS_notifyVisibleForms_1900 onStateCallBack data:====>" + JSON.stringify(data)); console.info("!!!====>FMS_notifyVisibleForms_1900 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent"); expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data != "0").assertEqual(true); expect(data.data != "0").assertEqual(true);
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback) commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_1900"))
setTimeout(function () { setTimeout(function () {
console.info('FMS_notifyVisibleForms_1900 delPublishCallBack end'); console.info('FMS_notifyVisibleForms_1900 delPublishCallBack end');
console.log(`FMS_notifyVisibleForms_1900 end`); console.log(`FMS_notifyVisibleForms_1900 end`);
done(); done();
}, 100); }, 100);
}
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyVisibleForms_1900 unSubscribeOnStateCallback CallBack====>");
} }
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => { commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.debug("====>FMS_notifyVisibleForms_1900 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
console.log(`FMS_notifyVisibleForms_1900 featureAbility.startAbility start`); console.log(`FMS_notifyVisibleForms_1900 featureAbility.startAbility start`);
await featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
...@@ -1624,3 +1346,23 @@ export default function test() { ...@@ -1624,3 +1346,23 @@ export default function test() {
}); });
}); });
} }
const delPublishCallback = async (tcNumber, done) => {
console.info(`${tcNumber} delPublishCallBack start`);
setTimeout(function () {
console.info(`${tcNumber} delPublishCallBack end`);
done();
}, 1000);
}
const unsubscribeOnStateCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unsubscribeOnStateCallback====>`);
}
const unsubscribeSupplyCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unSubscribeSupplyCallback====>`);
}
const unsubscribeOnAcquiredCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unsubscribeOnAcquiredCallback====>`);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册