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

!3415 fix codex

Merge pull request !3415 from chengxingzhen/master
/*
* 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 @@
import featureAbility from "@ohos.ability.featureAbility";
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 = {
events: ["FMS_FormOnError_commonEvent"],
......@@ -32,9 +32,22 @@ var onSupplyEvent = {
var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnError;
var subscriberOnAcquired;
var subscriberCast;
var subscriberSupply;
export default function test() {
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.name: The form host does not have permission to use the form
......@@ -42,23 +55,15 @@ export default function test() {
*/
it(`FMS_acquireForm_0200`, 0, async (done) => {
console.info(`FMS_acquireForm_0200 start`);
var subscriberOnError;
function onErrorCallBack(err, data) {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_0200 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
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`);
done();
}
function unSubscribeOnErrorCallback() {
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);
});
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info(`FMS_acquireForm_0200 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -88,23 +93,15 @@ export default function test() {
*/
it(`FMS_acquireForm_0300`, 0, async (done) => {
console.info(`FMS_acquireForm_0300 start`);
var subscriberOnError;
function onErrorCallBack(err, data) {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_0300 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
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`);
done();
}
function unSubscribeOnErrorCallback() {
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);
});
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info(`FMS_acquireForm_0300 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -134,23 +131,15 @@ export default function test() {
*/
it(`FMS_acquireForm_0400`, 0, async (done) => {
console.info(`FMS_acquireForm_0400 start`);
var subscriberOnError;
function onErrorCallBack(err, data) {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_0400 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
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`);
done();
}
function unSubscribeOnErrorCallback() {
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);
});
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info(`FMS_acquireForm_0400 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -180,23 +169,15 @@ export default function test() {
*/
it(`FMS_acquireForm_0500`, 0, async (done) => {
console.info(`FMS_acquireForm_0500 start`);
var subscriberOnError;
function onErrorCallBack(err, data) {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_0500 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
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`);
done();
}
function unSubscribeOnErrorCallback() {
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);
});
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info(`FMS_acquireForm_0500 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -226,23 +207,15 @@ export default function test() {
*/
it(`FMS_acquireForm_0600`, 0, async (done) => {
console.info(`FMS_acquireForm_0600 start`);
var subscriberOnError;
function onErrorCallBack(err, data) {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_0600 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
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`);
done();
}
function unSubscribeOnErrorCallback() {
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);
});
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info(`FMS_acquireForm_0600 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -272,23 +245,15 @@ export default function test() {
*/
it(`FMS_acquireForm_0700`, 0, async (done) => {
console.info(`FMS_acquireForm_0700 start`);
var subscriberOnError;
function onErrorCallBack(err, data) {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_0700 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
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`);
done();
}
function unSubscribeOnErrorCallback() {
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);
});
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info(`FMS_acquireForm_0700 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -318,23 +283,15 @@ export default function test() {
*/
it(`FMS_acquireForm_1000`, 0, async (done) => {
console.info(`FMS_acquireForm_1000 start`);
var subscriberOnError;
function onErrorCallBack(err, data) {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_1000 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
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`);
done();
}
function unSubscribeOnErrorCallback() {
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);
});
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info(`FMS_acquireForm_1000 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -366,23 +323,13 @@ export default function test() {
*/
it(`FMS_acquireForm_1100`, 0, async (done) => {
console.info(`FMS_acquireForm_1100 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formId1;
let formId2;
function delPublishCallBack() {
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) {
function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_1100 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback);
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_1100"));
formId1 = data.data;
if (formId1 && formId2) {
......@@ -390,21 +337,15 @@ export default function test() {
let commonEventPublishData = {
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.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) {
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onCreate") {
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 bundleName = retData.bundleName;
......@@ -427,18 +368,11 @@ export default function test() {
let commonEventPublishData = {
data: formId1
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_1100", done));
}
}
function unSubscribeSupplyCallback() {
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);
});
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.info(`FMS_acquireForm_1100 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -469,23 +403,13 @@ export default function test() {
*/
it(`FMS_acquireForm_1200`, 0, async (done) => {
console.info(`FMS_acquireForm_1200 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formId1;
let formId2;
function delPublishCallBack() {
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) {
function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_1200 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback)
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_1200"))
formId1 = data.data;
console.info("!!!====>FMS_acquireForm_1200 onAcquiredCallBack formId1:====>" + formId1);
if (formId1 && formId2) {
......@@ -493,22 +417,13 @@ export default function test() {
let commonEventPublishData = {
data: formId1
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_1200", done));
}
}
function unSubscribeOnAcquiredCallback() {
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) {
function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onCreate") {
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 bundleName = retData.bundleName;
......@@ -525,24 +440,18 @@ export default function test() {
expect(tempFormFlag).assertEqual(false);
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) {
expect(formId1).assertEqual(formId2);
let commonEventPublishData = {
data: formId1
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_1200", done));
}
}
function unSubscribeSupplyCallback() {
console.info("====>FMS_acquireForm_1200 unSubscribeSupplyCallback====>");
}
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.info("====>FMS_acquireForm_1200 onSupplyEvent Subscriber====>");
subscriberSupply = data;
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
console.info(`FMS_acquireForm_1200 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -572,44 +481,27 @@ export default function test() {
*/
it(`FMS_acquireForm_1400`, 0, async (done) => {
console.info(`FMS_acquireForm_1400 start`);
var subscriberOnAcquired;
var subscriberOnError;
var formId;
function delPublishCallBack() {
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) {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_1400 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
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 = {
data: formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
function unSubscribeOnErrorCallBackCache() {
console.info("====>FMS_acquireForm_1400 unSubscribeOnErrorCallBackCache CallBack====>");
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_1400", done));
}
function onAcquiredCallBack(err, data) {
async function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_1400 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback)
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_1400"))
formId = data.data;
// add cache form
commonEvent.createSubscriber(onErrorForm_Event).then(async (data1) => {
console.info("====>FMS_acquireForm_1400 onErrorForm_Event Subscriber====>");
subscriberOnError = data1;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info(`FMS_acquireForm_1400 featureAbility.startAbility again start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility",
......@@ -630,16 +522,8 @@ export default function test() {
});
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`);
await featureAbility.startAbility({
want: {
......@@ -669,23 +553,13 @@ export default function test() {
*/
it(`FMS_acquireForm_1500`, 0, async (done) => {
console.info(`FMS_acquireForm_1500 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formId1;
let formId2;
let onCreateCount = 0;
function delPublishCallBack() {
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) {
function onAcquiredCallBackCache(_, 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");
formId2 = data.data;
if (formId1 && formId2) {
......@@ -693,25 +567,19 @@ export default function test() {
let commonEventPublishData = {
data: formId1
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_1500", done));
}
function unSubscribeOnAcquiredCallBackCache() {
console.info("====>FMS_acquireForm_1500 OnAcquired Cache UnSubscribe CallBack====>");
}
function onAcquiredCallBack(err, data) {
async function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_1500 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback)
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_1500"))
formId1 = data.data;
// add cache form
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data1) => {
console.info("====>FMS_acquireForm_1500 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data1;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBackCache);
});
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBackCache);
console.info(`FMS_acquireForm_1500 featureAbility.startAbility again start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhostb",
abilityName: "com.ohos.st.formsystemhostb.MainAbility",
......@@ -732,40 +600,26 @@ export default function test() {
});
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) => {
console.info("====>FMS_acquireForm_1500 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
function onSupplyCallBack(err, data) {
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onCreate") {
console.info("====>FMS_acquireForm_1500 onSupplyCallBack====>" + JSON.stringify(data));
onCreateCount++;
if (onCreateCount == 2) {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback)
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_acquireForm_1500"))
}
if (formId1 && formId2) {
expect(formId1).assertEqual(formId2);
let commonEventPublishData = {
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) => {
console.info("====>FMS_acquireForm_1500 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.info(`FMS_acquireForm_1500 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -798,8 +652,6 @@ export default function test() {
it(`FMS_acquireForm_1600`, 0, async (done) => {
console.info(`FMS_acquireForm_1600 start`);
var subscriberOnAcquired;
function delPublishCallBack_Normal1() {
console.info("!!!====>FMS_acquireForm_1600 delPublishCallBack_Normal1====>");
setTimeout(function () {
......@@ -807,7 +659,7 @@ export default function test() {
FMS_acquireForm_1600_normal2();
}, 50);
}
function onAcquiredCallBack_Normal1(err, data) {
function onAcquiredCallBack_Normal1(_, data) {
console.info("!!!====>FMS_acquireForm_1600 onAcquiredCallBack_Normal1 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal1)
......@@ -821,16 +673,11 @@ export default function test() {
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`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_1600_normal1 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1);
console.info(`FMS_acquireForm_1600_normal1 featureAbility.startAbility start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility",
......@@ -861,7 +708,7 @@ export default function test() {
FMS_acquireForm_1600_Temp1();
}, 50);
}
function onAcquiredCallBack_Normal2(err, data) {
function onAcquiredCallBack_Normal2(_, data) {
console.info("!!!====>FMS_acquireForm_1600 onAcquiredCallBack_Normal2 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal2)
......@@ -874,16 +721,12 @@ export default function test() {
function 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`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_1600_normal2 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
});
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
console.info(`FMS_acquireForm_1600_normal2 featureAbility.startAbility start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility",
......@@ -914,7 +757,7 @@ export default function test() {
FMS_acquireForm_1600_Temp2();
}, 50);
}
function onAcquiredCallBack_Temp1(err, data) {
function onAcquiredCallBack_Temp1(_, data) {
console.info("!!!====>FMS_acquireForm_1600 onAcquiredCallBack_Temp1 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Temp1)
......@@ -928,16 +771,12 @@ export default function test() {
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`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_1600_Temp1 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp1);
});
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp1);
console.info(`FMS_acquireForm_1600_Temp1 featureAbility.startAbility start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility",
......@@ -970,7 +809,7 @@ export default function test() {
done();
}, 500);
}
function onAcquiredCallBack_Temp2(err, data) {
function onAcquiredCallBack_Temp2(_, data) {
console.info("!!!====>FMS_acquireForm_1600 onAcquiredCallBack_Temp2 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Temp2)
......@@ -984,16 +823,12 @@ export default function test() {
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`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_1600_Temp2 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp2);
});
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp2);
console.info(`FMS_acquireForm_1600_Temp2 featureAbility.startAbility start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility",
......@@ -1028,8 +863,6 @@ export default function test() {
it(`FMS_acquireForm_1800`, 0, async (done) => {
console.info(`FMS_acquireForm_1800 start`);
var subscriberOnAcquired;
function delPublishCallBack_Normal1() {
console.info("!!!====>FMS_acquireForm_1800 delPublishCallBack_Normal1====>");
setTimeout(function () {
......@@ -1037,7 +870,7 @@ export default function test() {
FMS_acquireForm_1800_normal2();
}, 50);
}
function onAcquiredCallBack_Normal1(err, data) {
function onAcquiredCallBack_Normal1(_, data) {
console.info("!!!====>FMS_acquireForm_1800 onAcquiredCallBack_Normal1 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal1)
......@@ -1051,16 +884,12 @@ export default function test() {
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`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_1800_normal1 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1);
console.info(`FMS_acquireForm_1800_normal1 featureAbility.startAbility start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility",
......@@ -1091,7 +920,7 @@ export default function test() {
FMS_acquireForm_1800_Temp1();
}, 50);
}
function onAcquiredCallBack_Normal2(err, data) {
function onAcquiredCallBack_Normal2(_, data) {
console.info("!!!====>FMS_acquireForm_1800 onAcquiredCallBack_Normal2 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal2)
......@@ -1104,16 +933,13 @@ export default function test() {
function 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`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_1800_normal2 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
});
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
console.info(`FMS_acquireForm_1800_normal2 featureAbility.startAbility start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhostb",
abilityName: "com.ohos.st.formsystemhostb.MainAbility",
......@@ -1144,7 +970,7 @@ export default function test() {
FMS_acquireForm_1800_Temp2();
}, 50);
}
function onAcquiredCallBack_Temp1(err, data) {
function onAcquiredCallBack_Temp1(_, data) {
console.info("!!!====>FMS_acquireForm_1800 onAcquiredCallBack_Temp1 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Temp1)
......@@ -1158,16 +984,12 @@ export default function test() {
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`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_1800_Temp1 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp1);
});
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp1);
console.info(`FMS_acquireForm_1800_Temp1 featureAbility.startAbility start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility",
......@@ -1199,7 +1021,7 @@ export default function test() {
done();
}, 500);
}
function onAcquiredCallBack_Temp2(err, data) {
function onAcquiredCallBack_Temp2(_, data) {
console.info("!!!====>FMS_acquireForm_1800 onAcquiredCallBack_Temp2 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Temp2)
......@@ -1213,16 +1035,13 @@ export default function test() {
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`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_1800_Temp2 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp2);
});
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Temp2);
console.info(`FMS_acquireForm_1800_Temp2 featureAbility.startAbility start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhostb",
abilityName: "com.ohos.st.formsystemhostb.MainAbility",
......@@ -1256,23 +1075,13 @@ export default function test() {
*/
it(`FMS_acquireForm_1900`, 0, async (done) => {
console.info(`FMS_acquireForm_1900 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formId1;
let formId2;
function delPublishCallBack() {
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) {
function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_1900 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack)
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_1900"))
formId1 = data.data;
if (formId1 && formId2) {
......@@ -1280,23 +1089,16 @@ export default function test() {
let commonEventPublishData = {
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) => {
console.info("====>FMS_acquireForm_1900 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
function onSupplyCallBack(err, data) {
function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onCreate") {
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 bundleName = retData.bundleName;
......@@ -1318,22 +1120,15 @@ export default function test() {
let commonEventPublishData = {
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) => {
console.info("====>FMS_acquireForm_1900 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.info(`FMS_acquireForm_1900 featureAbility.startAbility start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility",
......@@ -1362,44 +1157,27 @@ export default function test() {
*/
it(`FMS_acquireForm_2100`, 0, async (done) => {
console.info(`FMS_acquireForm_2100 start`);
var subscriberOnAcquired;
var subscriberOnError;
var formId;
function delPublishCallBack() {
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) {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_2100 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
expect(data.data).assertEqual("invalid params received on operating form.");
commonEvent.unsubscribe(subscriberOnError, unSubscribeOnErrorCallBackCache);
commonEvent.unsubscribe(subscriberOnError, () => unsubscribeOnErrorCallBackCache("FMS_acquireForm_2100"));
var commonEventPublishData = {
data: formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
function unSubscribeOnErrorCallBackCache() {
console.info("====>FMS_acquireForm_2100 unSubscribeOnErrorCallBackCache CallBack====>");
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_2100", done));
}
function onAcquiredCallBack(err, data) {
async function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_2100 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback)
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_2100"))
formId = data.data;
// add cache form
commonEvent.createSubscriber(onErrorForm_Event).then(async (data1) => {
console.info("====>FMS_acquireForm_2100 onErrorForm_Event Subscriber====>");
subscriberOnError = data1;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info(`FMS_acquireForm_2100 featureAbility.startAbility again start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility",
......@@ -1420,16 +1198,8 @@ export default function test() {
});
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`);
await featureAbility.startAbility({
want: {
......@@ -1459,39 +1229,19 @@ export default function test() {
*/
it(`FMS_acquireForm_2200`, 0, async (done) => {
console.info(`FMS_acquireForm_2200 start`);
var subscriberCast;
var subscriberOnError;
var formId;
function delPublishCallBack() {
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) {
function onCastCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_2200 onCastCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormCast_commonEvent");
expect(data.data != "0").assertEqual(true);
commonEvent.unsubscribe(subscriberCast, unSubscribeOnCastCallback)
commonEvent.unsubscribe(subscriberCast, () => unsubscribeOnCastCallback("FMS_acquireForm_2200"))
var commonEventPublishData = {
data: data.parameters.formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
function unSubscribeOnCastCallback() {
console.info("====>FMS_acquireForm_2200 unSubscribeOnCastCallback====>");
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_2200", done));
}
commonEvent.createSubscriber(subscriberFormCastEvent).then(async (data) => {
console.info("====>FMS_acquireForm_2200 subscriberFormCastEvent Subscriber====>");
subscriberCast = data;
await commonEvent.subscribe(subscriberCast, onCastCallBack);
});
commonEvent.subscribe(subscriberCast, onCastCallBack);
console.info(`FMS_acquireForm_2200 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -1523,38 +1273,18 @@ export default function test() {
*/
it(`FMS_acquireForm_2300`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormCast_commonEvent");
expect(data.data != "0").assertEqual(true);
commonEvent.unsubscribe(subscriberCast, unSubscribeOnCastCallback)
commonEvent.unsubscribe(subscriberCast, () => unsubscribeOnCastCallback("FMS_acquireForm_2300"))
var commonEventPublishData = {
data: data.parameters.formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
function unSubscribeOnCastCallback() {
console.info("====>FMS_acquireForm_2300 unSubscribeOnCastCallback====>");
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_2300", done));
}
commonEvent.createSubscriber(subscriberFormCastEvent).then(async (data) => {
console.info("====>FMS_acquireForm_2300 subscriberFormCastEvent Subscriber====>");
subscriberCast = data;
await commonEvent.subscribe(subscriberCast, onCastCallBack);
});
commonEvent.subscribe(subscriberCast, onCastCallBack);
console.info(`FMS_acquireForm_2300 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -1586,44 +1316,24 @@ export default function test() {
*/
it(`FMS_acquireForm_2400`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormCast_commonEvent");
expect(data.data != "0").assertEqual(true);
commonEvent.unsubscribe(subscriberCast, unSubscribeOnCastCallback)
commonEvent.unsubscribe(subscriberCast, () => unsubscribeOnCastCallback("FMS_acquireForm_2400"))
var commonEventPublishData = {
data: data.parameters.formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
function unSubscribeOnCastCallback() {
console.info("====>FMS_acquireForm_2400 unSubscribeOnCastCallback====>");
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_2400", done));
}
function onAcquiredCallBack(err, data) {
async function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_2400 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback)
commonEvent.createSubscriber(subscriberFormCastEvent).then(async (data) => {
console.info("====>FMS_acquireForm_2400 subscriberFormCastEvent Subscriber====>");
subscriberCast = data;
await commonEvent.subscribe(subscriberCast, onCastCallBack);
});
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_2400"))
commonEvent.subscribe(subscriberCast, onCastCallBack);
console.info(`FMS_acquireForm_2400 featureAbility.startAbility again start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhostb",
abilityName: "com.ohos.st.formsystemhostb.MainAbility",
......@@ -1646,16 +1356,8 @@ export default function test() {
});
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`);
await featureAbility.startAbility({
want: {
......@@ -1685,38 +1387,18 @@ export default function test() {
*/
it(`FMS_acquireForm_2500`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormCast_commonEvent");
expect(data.data != "0").assertEqual(true);
commonEvent.unsubscribe(subscriberCast, unSubscribeOnCastCallback)
commonEvent.unsubscribe(subscriberCast, () => unsubscribeOnCastCallback("FMS_acquireForm_2500"))
var commonEventPublishData = {
data: data.parameters.formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
function unSubscribeOnCastCallback() {
console.info("====>FMS_acquireForm_2500 unSubscribeOnCastCallback====>");
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_2500", done));
}
commonEvent.createSubscriber(subscriberFormCastEvent).then(async (data) => {
console.info("====>FMS_acquireForm_2500 subscriberFormCastEvent Subscriber====>");
subscriberCast = data;
await commonEvent.subscribe(subscriberCast, onCastCallBack);
});
commonEvent.subscribe(subscriberCast, onCastCallBack);
console.info(`FMS_acquireForm_2500 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -1749,46 +1431,31 @@ export default function test() {
*/
it(`FMS_acquireForm_2600`, 0, async (done) => {
console.info(`FMS_acquireForm_2600 start`);
let subscriberOnAcquired;
let subscriberCast;
let subscriberSupply;
let formId1;
let formId2;
function delPublishCallBack() {
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) {
function onCastCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_2600 onCastCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormCast_commonEvent");
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberCast, unSubscribeOnCastCallback)
commonEvent.unsubscribe(subscriberCast, () => unsubscribeOnCastCallback("FMS_acquireForm_2600"))
formId1 = data.parameters.formId;
if (formId1 && formId2) {
expect(formId1).assertEqual(formId2);
let commonEventPublishData = {
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));
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`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility",
......@@ -1811,14 +1478,11 @@ export default function test() {
});
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") {
console.info("====>FMS_acquireForm_2600 onSupplyCallBack====>" + JSON.stringify(data));
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_acquireForm_2600"));
formId2 = data.parameters.parameters;
if (formId1 && formId2) {
......@@ -1826,29 +1490,14 @@ export default function test() {
let commonEventPublishData = {
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) => {
console.info("====>FMS_acquireForm_2600 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
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);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
commonEvent.subscribe(subscriberCast, onCastCallBack);
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.info(`FMS_acquireForm_2600 featureAbility.startAbility start`);
await featureAbility.startAbility({
......@@ -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 @@
import featureAbility from "@ohos.ability.featureAbility";
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 = {
events: ["FMS_FormOnError_commonEvent"],
......@@ -32,9 +32,21 @@ var onSupplyEvent = {
var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnError;
var subscriberOnAcquired;
var subscriberCast;
var subscriberSupply;
export default function test() {
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.name: Failed to add form when parameter ability is wrong.
......@@ -42,23 +54,15 @@ export default function test() {
*/
it(`FMS_acquireForm_3800`, 0, async (done) => {
console.info(`FMS_acquireForm_3800 start`);
var subscriberOnError;
function onErrorCallBack(err, data) {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_3800 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
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`);
done();
}
function unSubscribeOnErrorCallback() {
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);
});
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info(`FMS_acquireForm_3800 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -88,23 +92,15 @@ export default function test() {
*/
it(`FMS_acquireForm_3900`, 0, async (done) => {
console.info(`FMS_acquireForm_3900 start`);
var subscriberOnError;
function onErrorCallBack(err, data) {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_3900 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
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`);
done();
}
function unSubscribeOnErrorCallback() {
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);
});
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info(`FMS_acquireForm_3900 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -135,44 +131,26 @@ export default function test() {
*/
it(`FMS_acquireForm_4000`, 0, async (done) => {
console.info(`FMS_acquireForm_4000 start`);
var subscriberOnAcquired;
var subscriberOnError;
var formId;
function delPublishCallBack() {
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) {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_4000 onErrorCallBack data:====>" + JSON.stringify(data));
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.");
console.info(`FMS_acquireForm_4000 end`);
var commonEventPublishData = {
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));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback)
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_4000"))
formId = data.data;
commonEvent.createSubscriber(onErrorForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_4000 onErrorForm_Event Subscriber====>");
subscriberOnError = data;
await commonEvent.subscribe(subscriberOnError, onErrorCallBack);
});
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info(`FMS_acquireForm_4000 featureAbility.startAbility again start`);
featureAbility.startAbility({
......@@ -201,12 +179,7 @@ export default function test() {
console.info("====>FMS_acquireForm_4000 OnAcquired UnSubscribe CallBack====>");
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.info("====>FMS_acquireForm_4000 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.info(`FMS_acquireForm_4000 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -238,23 +211,15 @@ export default function test() {
*/
it(`FMS_acquireForm_4100`, 0, async (done) => {
console.info(`FMS_acquireForm_4100 start`);
var subscriberOnError;
function onErrorCallBack(err, data) {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_4100 onErrorCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnError_commonEvent");
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`);
done();
}
function unSubscribeOnErrorCallback() {
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);
});
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info(`FMS_acquireForm_4100 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -286,23 +251,13 @@ export default function test() {
*/
it(`FMS_acquireForm_4200`, 0, async (done) => {
console.info(`FMS_acquireForm_4200 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formId1;
let formId2;
function delPublishCallBack() {
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) {
function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_4200 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack)
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_4200"))
formId1 = data.data;
if (formId1 && formId2) {
......@@ -310,23 +265,15 @@ export default function test() {
let commonEventPublishData = {
data: formId1
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_4200", done));
}
function unSubscribeOnAcquiredCallBack() {
console.info("====>FMS_acquireForm_4200 unSubscribeOnAcquiredCallBack====>");
}
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
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") {
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 formName = retData.parameters['ohos.extra.param.key.form_name'];
......@@ -338,22 +285,13 @@ export default function test() {
let commonEventPublishData = {
data: formId1
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_4200", done));
}
}
function unSubscribeSupplyCallback() {
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);
});
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.info(`FMS_acquireForm_4200 featureAbility.startAbility start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhost",
abilityName: "com.ohos.st.formsystemhost.MainAbility",
......@@ -383,23 +321,15 @@ export default function test() {
*/
it(`FMS_acquireForm_4300`, 0, async (done) => {
console.info(`FMS_acquireForm_4300 start`);
let subscriberOnAcquired;
function onAcquiredCallBack(err, data) {
function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_4300 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
expect(data.data != "0").assertEqual(true);
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack);
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_4300"));
console.info(`FMS_acquireForm_4300 end`);
done();
}
function unSubscribeOnAcquiredCallBack() {
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);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.info(`FMS_acquireForm_4300 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -430,24 +360,15 @@ export default function test() {
*/
it(`FMS_acquireForm_4400`, 0, async (done) => {
console.info(`FMS_acquireForm_4400 start`);
var subscriberOnError;
function onErrorCallBack(err, data) {
function onErrorCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_4400 onErrorCallBack data:====>" + JSON.stringify(data));
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.");
console.info(`FMS_acquireForm_4400 end`);
done();
}
function unSubscribeOnErrorCallback() {
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);
});
commonEvent.subscribe(subscriberOnError, onErrorCallBack);
console.info(`FMS_acquireForm_4400 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -479,41 +400,22 @@ export default function test() {
*/
it(`FMS_acquireForm_4900`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormCast_commonEvent");
expect(data.data).assertEqual("9");
commonEvent.unsubscribe(subscriberCast, unSubscribeOnCastCallback)
commonEvent.unsubscribe(subscriberCast, () => unsubscribeOnCastCallback("FMS_acquireForm_4900"))
var commonEventPublishData = {
data: data.parameters.formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
function unSubscribeOnCastCallback() {
console.info("====>FMS_acquireForm_4900 unSubscribeOnCastCallback====>");
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack("FMS_acquireForm_4900", done));
}
function onAcquiredCallBack(err, data) {
function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_acquireForm_4900 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback)
commonEvent.createSubscriber(subscriberFormCastEvent).then(async (data) => {
console.info("====>FMS_acquireForm_4900 subscriberFormCastEvent Subscriber====>");
subscriberCast = data;
await commonEvent.subscribe(subscriberCast, onCastCallBack);
});
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_acquireForm_4900"))
commonEvent.subscribe(subscriberCast, onCastCallBack);
console.info(`FMS_acquireForm_4900 featureAbility.startAbility again start`);
featureAbility.startAbility({
......@@ -539,16 +441,8 @@ export default function test() {
});
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`);
await featureAbility.startAbility({
want: {
......@@ -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() {
});
}
const delPublishCallBack = async (tcNumber, done) {
const delPublishCallBack = async (tcNumber, done) => {
console.info(`${tcNumber} delPublishCallBack start`);
setTimeout(function () {
console.info(`${tcNumber} delPublishCallBack end`);
......@@ -565,10 +565,10 @@ const delPublishCallBack = async (tcNumber, done) {
}, 1000);
}
const unsubscribeOnReleasedCallback = (tcNumber) {
const unsubscribeOnReleasedCallback = (tcNumber) => {
console.debug(`====>${tcNumber} unsubscribeOnReleasedCallback====>`);
}
const unsubscribeOnAcquiredCallback = (tcNumber) {
const unsubscribeOnAcquiredCallback = (tcNumber) => {
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 @@
import featureAbility from "@ohos.ability.featureAbility";
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 = {
events: ["FMS_FormOnAcquired_commonEvent"],
};
......@@ -38,6 +35,11 @@ var onSupplyEvent = {
var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnAcquired;
var subscriberDel;
var subscriberOnState;
var subscriberSupply;
export default function test() {
describe(`FmsStateFormTest`, () => {
......@@ -45,6 +47,14 @@ export default function test() {
done();
})
beforeEach(async () => {
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
subscriberDel = await commonEvent.createSubscriber(onDeletedFormEvent);
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
subscriberSupply = await commonEvent.createSubscriber(onSupplyEvent);
await sleep(1000);
})
/**
* @tc.number: FMS_disableFormsUpdate_0200
* @tc.name: The form user does not have permission.
......@@ -53,29 +63,19 @@ export default function test() {
*/
it(`FMS_disableFormsUpdate_0200`, 0, async (done) => {
console.log(`FMS_disableFormsUpdate_0200 start`);
let subscriberOnState;
function onStateCallBack(err, data) {
function onStateCallBack(_, data) {
console.info("!!!====>FMS_disableFormsUpdate_0200 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("2");
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallBack);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_disableFormsUpdate_0200"));
setTimeout(function () {
console.info('FMS_disableFormsUpdate_0200 onStateCallBack end');
console.log(`FMS_disableFormsUpdate_0200 end`);
done();
}, 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`);
featureAbility.startAbility({
want: {
......@@ -108,13 +108,12 @@ export default function test() {
*/
it(`FMS_disableFormsUpdate_0300`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("7");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback)
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_disableFormsUpdate_0300"))
setTimeout(function () {
console.info('FMS_disableFormsUpdate_0300 delPublishCallBack end');
......@@ -122,15 +121,8 @@ export default function test() {
done();
}, 100)
}
function unSubscribeOnStateCallback() {
console.debug("====>FMS_disableFormsUpdate_0300 unSubscribeOnStateCallback CallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_0300 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_disableFormsUpdate_0300 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -163,14 +155,12 @@ export default function test() {
*/
it(`FMS_disableFormsUpdate_0400`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback)
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_disableFormsUpdate_0400"))
setTimeout(function () {
console.info('FMS_disableFormsUpdate_0400 delPublishCallBack end');
......@@ -178,15 +168,7 @@ export default function test() {
done();
}, 100)
}
function unSubscribeOnStateCallback() {
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);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_disableFormsUpdate_0400 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -219,14 +201,12 @@ export default function test() {
*/
it(`FMS_disableFormsUpdate_0500`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback)
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_disableFormsUpdate_0500"))
setTimeout(function () {
console.info('FMS_disableFormsUpdate_0500 delPublishCallBack end');
......@@ -234,15 +214,7 @@ export default function test() {
done();
}, 100)
}
function unSubscribeOnStateCallback() {
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);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_disableFormsUpdate_0500 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -275,36 +247,24 @@ export default function test() {
*/
it(`FMS_disableFormsUpdate_0600`, 0, async (done) => {
console.info(`FMS_disableFormsUpdate_0600 start`);
let subscriberOnAcquired;
let subscriberDisable;
let hostFormId;
const delPublishCallback = (err, 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) => {
const onDisableCallback = (_, data) => {
if (data.parameters.kind != "disable") {
return;
}
console.debug("====>FMS_disableFormsUpdate_0600 onDisableCallback data:====>" + JSON.stringify(data));
expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberDisable, () => {
console.info("====>FMS_disableFormsUpdate_0600 unSubscribeOnDisableCallback====>");
});
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnDisableCallback("FMS_disableFormsUpdate_0600"));
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_disableFormsUpdate_0600"));
const commonEventPublishData = {
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));
hostFormId = data.data;
......@@ -329,22 +289,11 @@ export default function test() {
}).catch((err: any) => {
console.debug(`FMS_disableFormsUpdate_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`);
});
commonEvent.unsubscribe(subscriberOnAcquired, () => {
console.info("====>FMS_disableFormsUpdate_0600 unSubscribeOnAcquiredCallback====>");
});
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_disableFormsUpdate_0600"));
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_0600 onAcquiredFormEvent Subscriber====>");
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);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
commonEvent.subscribe(subscriberOnState, onDisableCallback);
console.info(`FMS_disableFormsUpdate_0600 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -374,24 +323,22 @@ export default function test() {
*/
it(`FMS_disableFormsUpdate_0700`, 0, async (done) => {
console.info(`FMS_disableFormsUpdate_0700 start`);
let subscriberDel;
let subscriberDisable;
let hostFormId;
const onDisableCallback = (err, data) => {
const onDisableCallback = (_, data) => {
if (data.parameters.kind != "disable") {
return;
}
console.debug("====>FMS_disableFormsUpdate_0700 onDisableCallback data:====>" + JSON.stringify(data));
expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberDisable, () => {
commonEvent.unsubscribe(subscriberOnState, () => {
console.info("====>FMS_disableFormsUpdate_0700 unSubscribeOnDisableCallback====>");
});
done();
}
const onDeleteCallback = async (err, data) => {
const onDeleteCallback = async (_, data) => {
console.debug("====>FMS_disableFormsUpdate_0700 onDeleteCallback data:====>" + JSON.stringify(data));
hostFormId = data.parameters.formId;
......@@ -422,17 +369,8 @@ export default function test() {
});
}
commonEvent.createSubscriber(onDeletedFormEvent).then(async (data) => {
console.info("====>FMS_disableFormsUpdate_0700 onDeletedFormEvent Invisible Subscriber====>");
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);
});
commonEvent.subscribe(subscriberDel, onDeleteCallback);
commonEvent.subscribe(subscriberOnState, onDisableCallback);
console.info(`FMS_disableFormsUpdate_0700 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -464,39 +402,21 @@ export default function test() {
*/
it(`FMS_disableFormsUpdate_0800`, 0, async (done) => {
console.log(`FMS_disableFormsUpdate_0800 start`);
let subscriberOnState;
let subscriberOnAcquired;
let formId;
function delPublishCallBack() {
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) {
function onStateCallBack(_, data) {
console.info("!!!====>FMS_disableFormsUpdate_0800 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
formId = data.parameters.formId;
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_disableFormsUpdate_0800"));
let commonEventPublishData = {
data: formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
function unsubscribeOnStateCallback() {
console.debug("====>FMS_disableFormsUpdate_0800 unsubscribeOnStateCallback====>");
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_disableFormsUpdate_0800", done));
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_0800 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_disableFormsUpdate_0800 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -530,48 +450,28 @@ export default function test() {
*/
it(`FMS_disableFormsUpdate_0900`, 0, async (done) => {
console.log(`FMS_disableFormsUpdate_0900 start`);
let subscriberDisable;
let subscriberEnable;
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() {
console.info("!!!====>FMS_disableFormsUpdate_0900 unSubscribeOnDisableCallback====>");
}
function OnDisableCallBack(err, data) {
function OnDisableCallBack(_, data) {
console.info("!!!====>FMS_disableFormsUpdate_0900 OnDisableCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberDisable, unSubscribeOnDisableCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnDisableCallback("FMS_disableFormsUpdate_0900"));
let commonEventPublishData = {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
commonEvent.unsubscribe(subscriberEnable, unSubscribeOnEnableCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnEnableCallback("FMS_disableFormsUpdate_0900"));
formId = data.parameters.formId;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_0900 onStateFormEvent Invisible Subscriber====>");
subscriberDisable = data;
await commonEvent.subscribe(subscriberDisable, OnDisableCallBack);
});
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
commonEvent.subscribe(subscriberOnState, OnDisableCallBack);
console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbility start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhostg",
abilityName: "com.ohos.st.formsystemhostg.MainAbility",
......@@ -595,11 +495,7 @@ export default function test() {
console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbility end`);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_0900 onStateFormEvent Invisible Subscriber====>");
subscriberEnable = data;
await commonEvent.subscribe(subscriberEnable, OnEnableCallBack);
});
commonEvent.subscribe(subscriberOnState, OnEnableCallBack);
console.log(`FMS_disableFormsUpdate_0900 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -633,10 +529,6 @@ export default function test() {
*/
it(`FMS_disableFormsUpdate_1000`, 0, async (done) => {
console.log(`FMS_disableFormsUpdate_1000 start`);
let subscriberOnAcquired;
let subscriberStatus;
let subscriberEnable;
let subscriberSupply;
let formId;
// timer speed up
......@@ -644,46 +536,30 @@ export default function test() {
console.log(`FMS_disableFormsUpdate_1000 time speed up`);
});
function unSubscribeSupplyCallback() {
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) {
function onSupplyEventCallBack(_, data) {
console.debug("====>FMS_disableFormsUpdate_1000 onSupplyEventCallBack====>" + JSON.stringify(data));
if ("onUpdate" == data.parameters.kind) {
console.debug("FMS_disableFormsUpdate_1000 error, onUpdate called.");
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_disableFormsUpdate_1000"));
expect().assertFail();
}
}
function onFormDisableCallBack(err, data) {
function onFormDisableCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
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.data).assertEqual("0");
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_1000 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyEventCallBack);
});
commonEvent.subscribe(subscriberSupply, onSupplyEventCallBack);
setTimeout(() => {
// timer reset
commonEvent.publish(`fms.time_speed`, { code: 1 }, () => {
console.log(`FMS_disableFormsUpdate_1000 time reset`);
});
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_disableFormsUpdate_1000"));
}, 9000);
setTimeout(() => {
......@@ -691,26 +567,22 @@ export default function test() {
let commonEventPublishData = {
data: formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_disableFormsUpdate_1000", done));
}, 10000);
}
function onAcquiredCallBack(err, data) {
async function onAcquiredCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeSupplyCallback("FMS_disableFormsUpdate_1000"));
console.debug("====>FMS_disableFormsUpdate_1000 onAcquiredCallBack====>" + JSON.stringify(data));
expect(data.parameters.kind).assertEqual("visible");
expect(data.data).assertEqual("0");
formId = data.parameters.formId;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_1000 onStateFormEvent Subscriber====>");
subscriberStatus = data;
await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack);
});
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
commonEvent.subscribe(subscriberOnState, onFormDisableCallBack);
console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbility notify disable start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhostg",
abilityName: "com.ohos.st.formsystemhostg.MainAbility",
......@@ -734,11 +606,7 @@ export default function test() {
console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbility notify disable end`);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_1000 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnState, onAcquiredCallBack);
console.log(`FMS_disableFormsUpdate_1000 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({
want: {
......@@ -773,10 +641,6 @@ export default function test() {
*/
it(`FMS_disableFormsUpdate_1100`, 0, async (done) => {
console.log(`FMS_disableFormsUpdate_1100 start`);
let subscriberOnAcquired;
let subscriberStatus;
let subscriberEnable;
let subscriberSupply;
let formId;
// timer speed up
......@@ -784,46 +648,30 @@ export default function test() {
console.log(`FMS_disableFormsUpdate_1100 time speed up`);
});
function unSubscribeSupplyCallback() {
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) {
function onSupplyEventCallBack(_, data) {
console.debug("====>FMS_disableFormsUpdate_1100 onSupplyEventCallBack====>" + JSON.stringify(data));
if ("onUpdate" == data.parameters.kind) {
console.debug("FMS_disableFormsUpdate_1100 error, onUpdate called.");
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_disableFormsUpdate_1100"));
expect().assertFail();
}
}
function onFormDisableCallBack(err, data) {
function onFormDisableCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
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.data).assertEqual("0");
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_1100 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyEventCallBack);
});
commonEvent.subscribe(subscriberSupply, onSupplyEventCallBack);
setTimeout(() => {
// timer reset
commonEvent.publish(`fms.time_speed`, { code: 1 }, () => {
console.log(`FMS_disableFormsUpdate_1100 time reset`);
});
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_disableFormsUpdate_1100"));
}, 9000);
setTimeout(() => {
......@@ -831,26 +679,22 @@ export default function test() {
let commonEventPublishData = {
data: formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_disableFormsUpdate_1100", done));
}, 10000);
}
function onAcquiredCallBack(err, data) {
async function onAcquiredCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeSupplyCallback("FMS_disableFormsUpdate_1100"));
console.debug("====>FMS_disableFormsUpdate_1100 onAcquiredCallBack====>" + JSON.stringify(data));
expect(data.parameters.kind).assertEqual("visible");
expect(data.data).assertEqual("0");
formId = data.parameters.formId;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_1100 onStateFormEvent Subscriber====>");
subscriberStatus = data;
await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack);
});
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
commonEvent.subscribe(subscriberOnState, onFormDisableCallBack);
console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbility notify disable start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhostg",
abilityName: "com.ohos.st.formsystemhostg.MainAbility",
......@@ -874,11 +718,7 @@ export default function test() {
console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbility notify disable end`);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_disableFormsUpdate_1100 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnState, onAcquiredCallBack);
console.log(`FMS_disableFormsUpdate_1100 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({
want: {
......@@ -905,3 +745,39 @@ 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 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 @@
import featureAbility from "@ohos.ability.featureAbility";
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 = {
events: ["FMS_FormOnAcquired_commonEvent"],
};
......@@ -38,6 +35,11 @@ var onSupplyEvent = {
var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnAcquired;
var subscriberDel;
var subscriberOnState;
var subscriberSupply;
export default function test() {
describe(`FmsStateFormTest`, () => {
......@@ -45,6 +47,14 @@ export default function test() {
done();
})
beforeEach(async () => {
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
subscriberDel = await commonEvent.createSubscriber(onDeletedFormEvent);
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
subscriberSupply = await commonEvent.createSubscriber(onSupplyEvent);
await sleep(1000);
})
/**
* @tc.number: FMS_enableFormsUpdate_0200
* @tc.name: The form user does not have permission.
......@@ -53,29 +63,20 @@ export default function test() {
*/
it(`FMS_enableFormsUpdate_0200`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("2");
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallBack);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_enableFormsUpdate_0200"));
setTimeout(function () {
console.info('FMS_enableFormsUpdate_0200 onStateCallBack end');
console.log(`FMS_enableFormsUpdate_0200 end`);
done();
}, 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`);
featureAbility.startAbility({
want: {
......@@ -108,14 +109,12 @@ export default function test() {
*/
it(`FMS_enableFormsUpdate_0300`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("7");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback)
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_enableFormsUpdate_0300"))
setTimeout(function () {
console.info('FMS_enableFormsUpdate_0300 delPublishCallBack end');
......@@ -123,15 +122,8 @@ export default function test() {
done();
}, 100)
}
function unSubscribeOnStateCallback() {
console.debug("====>FMS_enableFormsUpdate_0300 unSubscribeOnStateCallback CallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_0300 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_enableFormsUpdate_0300 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -164,14 +156,12 @@ export default function test() {
*/
it(`FMS_enableFormsUpdate_0400`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback)
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_enableFormsUpdate_0400"))
setTimeout(function () {
console.info('FMS_enableFormsUpdate_0400 delPublishCallBack end');
......@@ -179,15 +169,8 @@ export default function test() {
done();
}, 100)
}
function unSubscribeOnStateCallback() {
console.debug("====>FMS_enableFormsUpdate_0400 unSubscribeOnStateCallback CallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_0400 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_enableFormsUpdate_0400 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -220,14 +203,12 @@ export default function test() {
*/
it(`FMS_enableFormsUpdate_0500`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback)
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_enableFormsUpdate_0500"))
setTimeout(function () {
console.info('FMS_enableFormsUpdate_0500 delPublishCallBack end');
......@@ -235,15 +216,8 @@ export default function test() {
done();
}, 100)
}
function unSubscribeOnStateCallback() {
console.debug("====>FMS_enableFormsUpdate_0500 unSubscribeOnStateCallback CallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_0500 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_enableFormsUpdate_0500 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -276,36 +250,23 @@ export default function test() {
*/
it(`FMS_enableFormsUpdate_0600`, 0, async (done) => {
console.info(`FMS_enableFormsUpdate_0600 start`);
let subscriberOnAcquired;
let subscriberEnable;
let hostFormId;
const delPublishCallback = (err, 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) => {
const onEnableCallback = (_, data) => {
if (data.parameters.kind != "enable") {
return;
}
console.debug("====>FMS_enableFormsUpdate_0600 onEnableCallback data:====>" + JSON.stringify(data));
expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberEnable, () => {
console.info("====>FMS_enableFormsUpdate_0600 unSubscribeOnEnableCallback====>");
});
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_enableFormsUpdate_0600"));
const commonEventPublishData = {
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));
hostFormId = data.data;
......@@ -330,22 +291,11 @@ export default function test() {
}).catch((err: any) => {
console.debug(`FMS_enableFormsUpdate_0600 featureAbility.startAbilityhost error: ${JSON.stringify(err)}`);
});
commonEvent.unsubscribe(subscriberOnAcquired, () => {
console.info("====>FMS_enableFormsUpdate_0600 unSubscribeOnAcquiredCallback====>");
});
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_enableFormsUpdate_0600"));
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_0600 onAcquiredFormEvent Subscriber====>");
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);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
commonEvent.subscribe(subscriberOnState, onEnableCallback);
console.info(`FMS_enableFormsUpdate_0600 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -375,24 +325,22 @@ export default function test() {
*/
it(`FMS_enableFormsUpdate_0700`, 0, async (done) => {
console.info(`FMS_enableFormsUpdate_0700 start`);
let subscriberDel;
let subscriberEnable;
let hostFormId;
const onEnableCallback = (err, data) => {
const onEnableCallback = (_, data) => {
if (data.parameters.kind != "enable") {
return;
}
console.debug("====>FMS_enableFormsUpdate_0700 onEnableCallback data:====>" + JSON.stringify(data));
expect(data.data).assertEqual("13");
commonEvent.unsubscribe(subscriberEnable, () => {
commonEvent.unsubscribe(subscriberOnState, () => {
console.info("====>FMS_enableFormsUpdate_0700 unSubscribeOnEnableCallback====>");
});
done();
}
const onDeleteCallback = async (err, data) => {
const onDeleteCallback = async (_, data) => {
console.debug("====>FMS_enableFormsUpdate_0700 onDeleteCallback data:====>" + JSON.stringify(data));
hostFormId = data.parameters.formId;
......@@ -423,17 +371,8 @@ export default function test() {
});
}
commonEvent.createSubscriber(onDeletedFormEvent).then(async (data) => {
console.info("====>FMS_enableFormsUpdate_0700 onDeletedFormEvent Invisible Subscriber====>");
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);
});
commonEvent.subscribe(subscriberDel, onDeleteCallback);
commonEvent.subscribe(subscriberOnState, onEnableCallback);
console.info(`FMS_enableFormsUpdate_0700 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -466,10 +405,6 @@ export default function test() {
*/
it(`FMS_enableFormsUpdate_0900`, 0, async (done) => {
console.log(`FMS_enableFormsUpdate_0900 start`);
let subscriberOnAcquired;
let subscriberStatus;
let subscriberEnable;
let subscriberSupply;
let formIds = [];
// timer speed up
......@@ -477,25 +412,13 @@ export default function test() {
console.log(`FMS_enableFormsUpdate_0900 time speed up`);
});
function unSubscribeSupplyCallback() {
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) {
function onUpdateCallBack(_, data) {
if (data.parameters.kind == "onUpdate") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_enableFormsUpdate_0900 onUpdateCallBack====>" + JSON.stringify(data));
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 }, () => {
console.log(`FMS_enableFormsUpdate_0900 time reset`);
......@@ -505,41 +428,33 @@ export default function test() {
let commonEventPublishData = {
data: formIds[0]
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_enableFormsUpdate_0900", done));
}, 2000);
}
}
function onFormEnableCallBack(err, data) {
function onFormEnableCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
console.debug("====>FMS_enableFormsUpdate_0900 onFormEnableCallBack====>" + JSON.stringify(data));
expect(data.parameters.formId).assertEqual(formIds[0]);
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");
console.debug("====>FMS_enableFormsUpdate_0900 onFormDisableCallBack====>" + JSON.stringify(data));
expect(data.parameters.formId).assertEqual(formIds[0]);
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) => {
console.debug("====>FMS_enableFormsUpdate_0900 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onUpdateCallBack);
});
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
commonEvent.subscribe(subscriberOnState, onFormEnableCallBack);
commonEvent.subscribe(subscriberSupply, onUpdateCallBack);
setTimeout(() => {
setTimeout(async () => {
console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility notifyVisible start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhostg",
abilityName: "com.ohos.st.formsystemhostg.MainAbility",
......@@ -564,20 +479,15 @@ export default function test() {
}, 10000);
}
function onAcquiredCallBack(err, data) {
async function onAcquiredCallBack(_, data) {
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));
formIds.push(data.data);
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_0900 onStateFormEvent Subscriber====>");
subscriberStatus = data;
await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack);
});
commonEvent.subscribe(subscriberOnState, onFormDisableCallBack);
console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility notify disable start`);
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhostg",
abilityName: "com.ohos.st.formsystemhostg.MainAbility",
......@@ -601,11 +511,7 @@ export default function test() {
console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility notify disable end`);
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_0900 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.log(`FMS_enableFormsUpdate_0900 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({
want: {
......@@ -637,10 +543,6 @@ export default function test() {
*/
it(`FMS_enableFormsUpdate_1000`, 0, async (done) => {
console.log(`FMS_enableFormsUpdate_1000 start`);
let subscriberOnAcquired;
let subscriberStatus;
let subscriberEnable;
let subscriberSupply;
let formIds = [];
// timer speed up
......@@ -648,25 +550,13 @@ export default function test() {
console.log(`FMS_enableFormsUpdate_1000 time speed up`);
});
function unSubscribeSupplyCallback() {
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) {
function onUpdateCallBack(_, data) {
if (data.parameters.kind == "onUpdate") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_enableFormsUpdate_1000 onUpdateCallBack====>" + JSON.stringify(data));
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 }, () => {
console.log(`FMS_enableFormsUpdate_1000 time reset`);
......@@ -676,42 +566,34 @@ export default function test() {
let commonEventPublishData = {
data: formIds[0]
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_enableFormsUpdate_1000", done));
}, 2000);
}
}
function onFormEnableCallBack(err, data) {
function onFormEnableCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
console.debug("====>FMS_enableFormsUpdate_1000 onFormEnableCallBack====>" + JSON.stringify(data));
expect(data.parameters.formId).assertEqual(formIds[0]);
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");
console.debug("====>FMS_enableFormsUpdate_1000 onFormDisableCallBack====>" + JSON.stringify(data));
expect(data.parameters.formId).assertEqual(formIds[0]);
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);
});
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
commonEvent.subscribe(subscriberOnState, onFormEnableCallBack);
commonEvent.subscribe(subscriberSupply, onUpdateCallBack);
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_1000 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onUpdateCallBack);
});
setTimeout(() => {
setTimeout(async () => {
console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility notifyVisible start`);
formIds.push("0");
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhostg",
abilityName: "com.ohos.st.formsystemhostg.MainAbility",
......@@ -736,18 +618,12 @@ export default function test() {
}, 10000);
}
function onAcquiredCallBack(err, data) {
function onAcquiredCallBack(_, data) {
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));
formIds.push(data.data);
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_1000 onStateFormEvent Subscriber====>");
subscriberStatus = data;
await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack);
});
commonEvent.subscribe(subscriberOnState, onFormDisableCallBack);
console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility notify disable start`);
featureAbility.startAbility({
want: {
......@@ -773,11 +649,7 @@ export default function test() {
console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility notify disable end`);
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_1000 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.log(`FMS_enableFormsUpdate_1000 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({
want: {
......@@ -809,12 +681,7 @@ export default function test() {
*/
it(`FMS_enableFormsUpdate_1200`, 0, async (done) => {
console.log(`FMS_enableFormsUpdate_1200 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formIds = new Array();
let retFormId;
let subscriberStatus;
let subscriberEnable;
let count = 0;
// timer speed up
......@@ -822,26 +689,23 @@ export default function test() {
console.log(`FMS_enableFormsUpdate_1200 time speed up`);
});
function unSubscribeSupplyCallback() {
console.debug("====>FMS_enableFormsUpdate_1200 unSubscribeSupplyCallback====>");
}
function delPublishCallBack1(err, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1400 delPublishCallBack1====>" + JSON.stringify(data));
function delPublishCallBack1(_, data) {
console.info("!!!====>FMS_enableFormsUpdate_1200 delPublishCallBack1====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_notifyInvisibleForms_1400 delPublishCallBack1 end');
console.log(`FMS_notifyInvisibleForms_1400 end`);
console.info('FMS_enableFormsUpdate_1200 delPublishCallBack1 end');
console.log(`FMS_enableFormsUpdate_1200 end`);
}, 1000);
}
function delPublishCallBack2(err, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1400 delPublishCallBack2====>" + JSON.stringify(data));
function delPublishCallBack2(_, data) {
console.info("!!!====>FMS_enableFormsUpdate_1200 delPublishCallBack2====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_notifyInvisibleForms_1400 delPublishCallBack2 end');
console.log(`FMS_notifyInvisibleForms_1400 end`);
console.info('FMS_enableFormsUpdate_1200 delPublishCallBack2 end');
console.log(`FMS_enableFormsUpdate_1200 end`);
done();
}, 1000);
}
function onUpdateCallBack(err, data) {
function onUpdateCallBack(_, data) {
if (data.parameters.kind == "onUpdate") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_enableFormsUpdate_1200 onUpdateCallBack====>" + JSON.stringify(data));
......@@ -849,8 +713,8 @@ export default function test() {
++count;
if (count == 2) {
console.debug("====>FMS_notifyInvisibleForms_1400 OK====>");
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
console.debug("====>FMS_enableFormsUpdate_1200 OK====>");
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_1200"));
commonEvent.publish(`fms.time_speed`, { code: 1 }, () => {
console.log(`FMS_enableFormsUpdate_1200 time reset`);
......@@ -870,34 +734,25 @@ export default function test() {
}
}
function onFormEnableCallBack(err, data) {
function onFormEnableCallBack(_, data) {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
console.debug("====>FMS_enableFormsUpdate_1200 onFormEnableCallBack====>" + JSON.stringify(data));
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");
console.debug("====>FMS_enableFormsUpdate_1200 onFormDisableCallBack====>" + JSON.stringify(data));
commonEvent.unsubscribe(subscriberStatus, unSubscribeSupplyCallback);
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_1200 onStateFormEvent Subscriber====>");
subscriberEnable = data;
await commonEvent.subscribe(subscriberEnable, onFormEnableCallBack);
});
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_1200 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onUpdateCallBack);
});
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_1200"));
setTimeout(() => {
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
commonEvent.subscribe(subscriberOnState, onFormEnableCallBack);
commonEvent.subscribe(subscriberSupply, onUpdateCallBack);
setTimeout(async () => {
console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility notifyVisible start`);
formIds.push("0");
featureAbility.startAbility({
await featureAbility.startAbility({
want: {
bundleName: "com.ohos.st.formsystemhostg",
abilityName: "com.ohos.st.formsystemhostg.MainAbility",
......@@ -922,18 +777,14 @@ export default function test() {
}, 10000);
}
async function onSecondAcquiredCallBack(err, data) {
async function onSecondAcquiredCallBack(_, data) {
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));
formIds.push(data.data);
console.debug("====>FMS_enableFormsUpdate_1200 formIds====>" + formIds);
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_1200 onStateFormEvent Subscriber====>");
subscriberStatus = data;
await commonEvent.subscribe(subscriberStatus, onFormDisableCallBack);
});
commonEvent.subscribe(subscriberOnState, onFormDisableCallBack);
console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility notify disable start`);
await featureAbility.startAbility({
......@@ -960,17 +811,14 @@ export default function test() {
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");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeSupplyCallback("FMS_enableFormsUpdate_1200"));
console.debug("====>FMS_enableFormsUpdate_1200 onFirstAcquiredCallBack====>" + JSON.stringify(data));
formIds.push(data.data);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_1200 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack);
});
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack);
console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility serviceb start`);
await featureAbility.startAbility({
......@@ -995,11 +843,7 @@ export default function test() {
console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility serviceb end`);
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_enableFormsUpdate_1200 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack);
console.log(`FMS_enableFormsUpdate_1200 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({
want: {
......@@ -1024,3 +868,31 @@ 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 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 @@
import featureAbility from "@ohos.ability.featureAbility";
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 = {
events: ["FMS_FormOnAcquired_commonEvent"],
......@@ -35,9 +35,22 @@ var onSupplyEvent = {
var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnAcquired;
var subscriberDel;
var subscriberOnState;
var subscriberSupply;
export default function test() {
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);
await sleep(1000);
})
/**
* @tc.number: FMS_notifyInvisibleForms_0200
* @tc.name: The form user does not have permission.
......@@ -46,29 +59,20 @@ export default function test() {
*/
it(`FMS_notifyInvisibleForms_0200`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("2");
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallBack);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0200"));
setTimeout(function () {
console.info('FMS_notifyInvisibleForms_0200 onStateCallBack end');
console.log(`FMS_notifyInvisibleForms_0200 end`);
done();
}, 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`);
featureAbility.startAbility({
want: {
......@@ -101,13 +105,12 @@ export default function test() {
*/
it(`FMS_notifyInvisibleForms_0300`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("7");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback)
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0300"))
setTimeout(function () {
console.info('FMS_notifyInvisibleForms_0300 delPublishCallBack end');
......@@ -115,15 +118,8 @@ export default function test() {
done();
}, 100)
}
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyInvisibleForms_0300 unSubscribeOnStateCallback CallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0300 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyInvisibleForms_0300 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -156,13 +152,12 @@ export default function test() {
*/
it(`FMS_notifyInvisibleForms_0400`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_0400 start`);
let subscriberOnState;
function onStateCallBack(err, data) {
function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0400 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback)
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0400"))
setTimeout(function () {
console.info('FMS_notifyInvisibleForms_0400 delPublishCallBack end');
......@@ -170,15 +165,8 @@ export default function test() {
done();
}, 100)
}
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyInvisibleForms_0400 unSubscribeOnStateCallback CallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0400 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyInvisibleForms_0400 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -211,13 +199,12 @@ export default function test() {
*/
it(`FMS_notifyInvisibleForms_0500`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback)
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0500"))
setTimeout(function () {
console.info('FMS_notifyInvisibleForms_0500 delPublishCallBack end');
......@@ -225,15 +212,8 @@ export default function test() {
done();
}, 100)
}
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyInvisibleForms_0500 unSubscribeOnStateCallback CallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0500 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyInvisibleForms_0500 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -266,44 +246,25 @@ export default function test() {
*/
it(`FMS_notifyInvisibleForms_0600`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_0600 start`);
let subscriberOnState;
let subscriberOnAcquired;
let formId;
function delPublishCallBack() {
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) {
function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0600 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0600"));
let commonEventPublishData = {
data: formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
function unsubscribeOnStateCallback() {
console.debug("====>FMS_notifyInvisibleForms_0600 unsubscribeOnStateCallback====>");
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyInvisibleForms_0600", done));
}
async function onAcquiredCallBack(err, data) {
async function onAcquiredCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0600 onAcquiredCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback)
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_notifyInvisibleForms_0600"))
formId = data.data;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0600 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbility again start`);
await featureAbility.startAbility({
want: {
......@@ -328,15 +289,8 @@ export default function test() {
});
console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbility again end`);
}
function unSubscribeOnAcquiredCallback() {
console.debug("====>FMS_notifyInvisibleForms_0600 OnAcquired UnSubscribe CallBack====>");
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0600 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.log(`FMS_notifyInvisibleForms_0600 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -367,12 +321,9 @@ export default function test() {
*/
it(`FMS_notifyInvisibleForms_0700`, 0, async (done) => {
console.info(`FMS_notifyInvisibleForms_0700 start`);
let subscriberInvisible;
let subscriberDel;
let subscriberSupply;
let hostFormId;
const onSupplyCallback = (err, data) => {
const onSupplyCallback = (_, data) => {
if (data.parameters.kind != "onVisibilityChange") {
return;
}
......@@ -380,7 +331,7 @@ export default function test() {
expect().assertFail();
}
const onInvisibleCallback = (err, data) => {
const onInvisibleCallback = (_, data) => {
if (data.parameters.kind != "invisible") {
return;
}
......@@ -388,18 +339,14 @@ export default function test() {
expect(data.data).assertEqual("0");
expect(data.parameters.formId).assertEqual(hostFormId);
commonEvent.unsubscribe(subscriberInvisible, () => {
console.info("====>FMS_notifyInvisibleForms_0700 unSubscribeOnInvisibleCallback====>");
});
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0700"));
setTimeout(() => {
commonEvent.unsubscribe(subscriberSupply, () => {
console.info("====>FMS_notifyInvisibleForms_0700 unSubscribeSupplyCallback====>");
});
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_0700"));
done();
}, 2000);
}
const onDeleteCallback = async (err, data) => {
const onDeleteCallback = async (_, data) => {
console.debug("====>FMS_notifyInvisibleForms_0700 onDeleteCallback data:====>" + JSON.stringify(data));
hostFormId = data.parameters.formId;
......@@ -430,22 +377,9 @@ export default function test() {
});
}
commonEvent.createSubscriber(onDeletedFormEvent).then(async (data) => {
console.info("====>FMS_notifyInvisibleForms_0700 onDeletedFormEvent Invisible Subscriber====>");
subscriberDel = data;
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);
});
commonEvent.subscribe(subscriberDel, onDeleteCallback);
commonEvent.subscribe(subscriberOnState, onInvisibleCallback);
commonEvent.subscribe(subscriberSupply, onSupplyCallback);
console.info(`FMS_notifyInvisibleForms_0700 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -478,74 +412,49 @@ export default function test() {
*/
it(`FMS_notifyInvisibleForms_0800`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_0800 start`);
let subscriberInvisible;
let subscriberVisible;
let subscriberSupply;
let formIdInvisible;
let formIdVisible;
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") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyInvisibleForms_0800 onSupplyCallBack====>" + JSON.stringify(data));
onSupplyCount++;
if (onSupplyCount == 2) {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_0800"));
}
if (formIdInvisible && formIdVisible) {
let commonEventPublishData = {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
formIdInvisible = data.parameters.formId;
commonEvent.unsubscribe(subscriberInvisible, unSubscribeOnInvisibleCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0800"));
if (formIdInvisible && formIdVisible && onSupplyCount == 2) {
let commonEventPublishData = {
data: formIdInvisible
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyInvisibleForms_0800", done));
}
function unSubscribeOnVisibleCallback() {
console.debug("====>FMS_notifyInvisibleForms_0800 unSubscribeOnVisibleCallback CallBack====>");
}
function unSubscribeOnInvisibleCallback() {
console.debug("====>FMS_notifyInvisibleForms_0800 unSubscribeOnInvisibleCallback CallBack====>");
}
async function onVisibleCallBack(err, data) {
async function onVisibleCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0800 onVisibleCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberVisible, unSubscribeOnVisibleCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0800"));
formIdVisible = data.parameters.formId;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0800 onStateFormEvent Invisible Subscriber====>");
subscriberInvisible = data;
await commonEvent.subscribe(subscriberInvisible, OnInvisibleCallBack);
});
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
commonEvent.subscribe(subscriberOnState, OnInvisibleCallBack);
console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbility again start`);
await featureAbility.startAbility({
want: {
......@@ -571,16 +480,8 @@ export default function test() {
console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbility again end`);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0800 onStateFormEvent Subscriber====>");
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);
});
commonEvent.subscribe(subscriberOnState, onVisibleCallBack);
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.log(`FMS_notifyInvisibleForms_0800 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -607,3 +508,31 @@ 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 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 @@
import featureAbility from "@ohos.ability.featureAbility";
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 = {
events: ["FMS_FormOnAcquired_commonEvent"],
};
var onDeletedFormEvent = {
events: ["FMS_FormOnDeleted_commonEvent"],
};
var onStateFormEvent = {
events: ["FMS_FormOnState_commonEvent"],
};
......@@ -35,9 +31,21 @@ var onSupplyEvent = {
var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnAcquired;
var subscriberOnState;
var subscriberSupply;
export default function test() {
describe(`FmsStateFormTest`, () => {
beforeEach(async () => {
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
subscriberSupply = await commonEvent.createSubscriber(onSupplyEvent);
await sleep(1000);
})
/**
* @tc.number: FMS_notifyInvisibleForms_0900
* @tc.name: There are correct and wrong formId in the form ID parameter list
......@@ -47,74 +55,49 @@ export default function test() {
*/
it(`FMS_notifyInvisibleForms_0900`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_0900 start`);
let subscriberInvisible;
let subscriberVisible;
let subscriberSupply;
let formIdInvisible;
let formIdVisible;
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") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyInvisibleForms_0900 onSupplyCallBack====>" + JSON.stringify(data));
onSupplyCount++;
if (onSupplyCount == 2) {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_0900"));
}
if (formIdInvisible && formIdVisible) {
let commonEventPublishData = {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
formIdInvisible = data.parameters.formId;
commonEvent.unsubscribe(subscriberInvisible, unSubscribeOnInvisibleCallback);
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0900"));
if (formIdInvisible && formIdVisible && onSupplyCount == 2) {
let commonEventPublishData = {
data: formIdInvisible
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyInvisibleForms_0900", done));
}
function unSubscribeOnVisibleCallback() {
console.debug("====>FMS_notifyInvisibleForms_0900 unSubscribeOnVisibleCallback CallBack====>");
}
function unSubscribeOnInvisibleCallback() {
console.debug("====>FMS_notifyInvisibleForms_0900 unSubscribeOnInvisibleCallback CallBack====>");
}
async function onVisibleCallBack(err, data) {
async function onVisibleCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_0900 onVisibleCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberVisible, unSubscribeOnVisibleCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_0900"));
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`);
await featureAbility.startAbility({
want: {
......@@ -140,16 +123,8 @@ export default function test() {
console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbility again end`);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_0900 onStateFormEvent Subscriber====>");
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);
});
commonEvent.subscribe(subscriberOnState, onVisibleCallBack);
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.log(`FMS_notifyInvisibleForms_0900 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -183,25 +158,8 @@ export default function test() {
*/
it(`FMS_notifyInvisibleForms_1000`, 0, async (done) => {
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() {
console.debug("====>FMS_notifyInvisibleForms_1000 unSubscribeOnVisibleCallback CallBack====>");
}
function unSubscribeSupplyCallback() {
console.debug("====>FMS_notifyInvisibleForms_1000 unSubscribeSupplyCallback CallBack====>");
}
function onVisibleCallBack(err, data) {
function onVisibleCallBack(_, data) {
if (data.parameters.kind != "invisible") {
return;
}
......@@ -210,35 +168,27 @@ export default function test() {
expect(data.data).assertEqual("0");
setTimeout(function () {
commonEvent.unsubscribe(subscriberOnVisible, unSubscribeOnVisibleCallback);
commonEvent.unsubscribe(subscriberOnSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_1000"));
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_1000"));
let commonEventPublishData = {
data: data.parameters.formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyInvisibleForms_0900", done));
}, 2000);
}
function onSupplyEventCallBack(err, data) {
function onSupplyEventCallBack(_, data) {
if (data.parameters.kind != "onVisibilityChange") {
return;
}
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.log(`FMS_notifyInvisibleForms_1000 error`);
expect().assertFail();
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_1000 onStateFormEvent Invisible Subscriber====>");
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);
});
commonEvent.subscribe(subscriberOnState, onVisibleCallBack);
commonEvent.subscribe(subscriberSupply, onSupplyEventCallBack);
console.log(`FMS_notifyInvisibleForms_1000 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -272,17 +222,14 @@ export default function test() {
*/
it(`FMS_notifyInvisibleForms_1100`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_1100 start`);
let subscriberInvisible;
let subscriberVisible;
let subscriberSupply;
let supplyFlag = false;
let formIdInvisible;
let formIdVisible;
function delPublishCallBack(err, data) {
function delPublishCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1100 delPublishCallBack====>");
setTimeout(function () {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_1100"));
if (supplyFlag) {
expect().assertFail();
}
......@@ -292,15 +239,12 @@ export default function test() {
}, 1000);
}
function unSubscribeSupplyCallback() {
console.debug("====>FMS_notifyInvisibleForms_1100 unSubscribeSupplyCallback====>");
}
function onSupplyCallBack(err, data) {
function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyInvisibleForms_1100 onSupplyCallBack====>" + JSON.stringify(data));
supplyFlag = true;
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_1100"));
if (formIdInvisible && formIdVisible) {
let commonEventPublishData = {
......@@ -311,12 +255,12 @@ export default function test() {
}
}
function OnInvisibleCallBack(err, data) {
function OnInvisibleCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1100 OnInvisibleCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
formIdInvisible = data.parameters.formId;
commonEvent.unsubscribe(subscriberInvisible, unSubscribeOnInvisibleCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_1100"));
if (formIdInvisible && formIdVisible) {
let commonEventPublishData = {
data: formIdInvisible
......@@ -324,24 +268,15 @@ export default function test() {
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
}
function unSubscribeOnVisibleCallback() {
console.debug("====>FMS_notifyInvisibleForms_1100 unSubscribeOnVisibleCallback CallBack====>");
}
function unSubscribeOnInvisibleCallback() {
console.debug("====>FMS_notifyInvisibleForms_1100 unSubscribeOnInvisibleCallback CallBack====>");
}
async function onVisibleCallBack(err, data) {
async function onVisibleCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1100 onVisibleCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberVisible, unSubscribeOnVisibleCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_1100"));
formIdVisible = data.parameters.formId;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_1100 onStateFormEvent Invisible Subscriber====>");
subscriberInvisible = data;
await commonEvent.subscribe(subscriberInvisible, OnInvisibleCallBack);
});
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
commonEvent.subscribe(subscriberOnState, OnInvisibleCallBack);
console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbility again start`);
await featureAbility.startAbility({
......@@ -368,16 +303,8 @@ export default function test() {
console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbility again end`);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_1100 onStateFormEvent Subscriber====>");
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);
});
commonEvent.subscribe(subscriberOnState, onVisibleCallBack);
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.log(`FMS_notifyInvisibleForms_1100 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -413,9 +340,6 @@ export default function test() {
*/
it(`FMS_notifyInvisibleForms_1200`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_1200 start`);
let subscriberOnAcquired;
let subscriberOnState;
let subscriberSupply;
let formId1;
let formId2;
let delCount = 0;
......@@ -432,7 +356,7 @@ export default function test() {
}, 500);
}
}
function onAcquiredCallBack_Normal1(err, data) {
function onAcquiredCallBack_Normal1(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1200 onAcquiredCallBack_Normal1 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal1)
......@@ -446,12 +370,8 @@ export default function test() {
async function FMS_notifyInvisibleForms_1200_normal1() {
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`);
await featureAbility.startAbility({
want: {
......@@ -477,11 +397,11 @@ export default function test() {
console.log(`FMS_notifyInvisibleForms_1200_normal1 end`);
}
function onStateCallBack(err, data) {
function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1200 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
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 formId2:====>" + formId2);
console.info("!!!====>FMS_notifyInvisibleForms_1200 onStateCallBack onSupplyCount:====>" + onSupplyCount);
......@@ -496,22 +416,14 @@ export default function test() {
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));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal2);
formId2 = data.data;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_1200 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyInvisibleForms_1200 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -540,12 +452,8 @@ export default function test() {
console.debug("====>FMS_notifyInvisibleForms_1200 unSubscribeOnAcquiredCallBack_Normal2====>");
}
async function FMS_notifyInvisibleForms_1200_normal2() {
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_1200_normal2 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
});
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
console.log(`FMS_notifyInvisibleForms_1200_normal2 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -569,10 +477,7 @@ export default function test() {
console.log(`FMS_notifyInvisibleForms_1200_normal2 featureAbility.startAbility end`);
}
function unSubscribeSupplyCallback() {
console.debug("====>FMS_notifyInvisibleForms_1200 unSubscribeSupplyCallback====>");
}
function onSupplyCallBack(err, data) {
function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyInvisibleForms_1200 onSupplyCallBack====>" + JSON.stringify(data));
......@@ -586,7 +491,7 @@ export default function test() {
onSupplyCount++;
if (onSupplyCount == 2) {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_1200"));
}
if (formId1 && formId2) {
let commonEventPublishData = {
......@@ -600,11 +505,8 @@ export default function test() {
}
}
}
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_1200 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
FMS_notifyInvisibleForms_1200_normal1();
});
/**
......@@ -616,13 +518,11 @@ export default function test() {
*/
it(`FMS_notifyInvisibleForms_1300`, 0, async (done) => {
console.info(`FMS_notifyInvisibleForms_1300 start`);
let subscriberInvisible;
let subscriberSupply;
let hostFormId;
let providerFormId;
let counter = 0;
const delPublishCallback = (err, data) => {
const delPublishCallback = (_, data) => {
console.info("!!!====>FMS_notifyInvisibleForms_1300 delPublishCallback====>");
setTimeout(() => {
expect(hostFormId).assertEqual(providerFormId);
......@@ -632,7 +532,7 @@ export default function test() {
}, 1000);
}
const onSupplyCallback = (err, data) => {
const onSupplyCallback = (_, data) => {
if (data.parameters.kind != "onVisibilityChange") {
return;
}
......@@ -652,7 +552,7 @@ export default function test() {
}
}
const onInvisibleCallback = (err, data) => {
const onInvisibleCallback = (_, data) => {
if (data.parameters.kind != "invisible") {
return;
}
......@@ -660,7 +560,7 @@ export default function test() {
hostFormId = data.parameters.formId;
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberInvisible, () => {
commonEvent.unsubscribe(subscriberOnState, () => {
console.info("====>FMS_notifyInvisibleForms_1300 unSubscribeOnInvisibleCallback====>");
});
if (++counter == 2) {
......@@ -671,17 +571,8 @@ export default function test() {
}
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.info("====>FMS_notifyInvisibleForms_1300 onStateFormEvent Invisible Subscriber====>");
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);
});
commonEvent.subscribe(subscriberOnState, onInvisibleCallback);
commonEvent.subscribe(subscriberSupply, onSupplyCallback);
console.info(`FMS_notifyInvisibleForms_1300 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -714,25 +605,17 @@ export default function test() {
*/
it(`FMS_notifyInvisibleForms_1400`, 0, async (done) => {
console.log(`FMS_notifyInvisibleForms_1400 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formIds = new Array();
let retFormId;
let formId1;
let formId2;
let count = 0;
function unSubscribeSupplyCallback() {
console.debug("====>FMS_notifyInvisibleForms_1400 unSubscribeSupplyCallback====>");
}
function delPublishCallBack1(err, data) {
function delPublishCallBack1(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1400 delPublishCallBack1====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_notifyInvisibleForms_1400 delPublishCallBack1 end');
console.log(`FMS_notifyInvisibleForms_1400 end`);
}, 1000);
}
function delPublishCallBack2(err, data) {
function delPublishCallBack2(_, data) {
console.info("!!!====>FMS_notifyInvisibleForms_1400 delPublishCallBack2====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_notifyInvisibleForms_1400 delPublishCallBack2 end');
......@@ -741,7 +624,7 @@ export default function test() {
}, 1000);
}
function onSupplyCallBack(err, data) {
function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyInvisibleForms_1400 onSupplyCallBack====>" + JSON.stringify(data));
......@@ -754,7 +637,7 @@ export default function test() {
++count;
if (count == 2) {
console.debug("====>FMS_notifyInvisibleForms_1400 OK====>");
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_1400"));
let commonEventPublishData1 = {
data: formIds[0]
......@@ -768,19 +651,15 @@ export default function test() {
}
}
async function onSecondAcquiredCallBack(err, data) {
async function onSecondAcquiredCallBack(_, data) {
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));
formIds.push(data.data);
formIds.push("-1");
console.debug("====>FMS_notifyInvisibleForms_1400 formIds====>" + formIds);
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_1400 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility notifyInVisible start`);
await featureAbility.startAbility({
......@@ -807,18 +686,14 @@ export default function test() {
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");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeSupplyCallback("FMS_notifyInvisibleForms_1400"));
console.debug("====>FMS_notifyInvisibleForms_1400 onFirstAcquiredCallBack====>" + JSON.stringify(data));
formIds.push(data.data);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_1400 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack);
});
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack);
console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility serviceb start`);
await featureAbility.startAbility({
want: {
......@@ -842,11 +717,7 @@ export default function test() {
console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility serviceb end`);
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_notifyInvisibleForms_1400 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack);
console.log(`FMS_notifyInvisibleForms_1400 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({
want: {
......@@ -876,14 +747,12 @@ export default function test() {
*/
it(`FMS_notifyInvisibleForms_1500`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data != "0").assertEqual(true);
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback)
expect(data.data).assertEqual("7");
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyInvisibleForms_1500"))
setTimeout(function () {
console.info('FMS_notifyInvisibleForms_1500 delPublishCallBack end');
......@@ -891,15 +760,7 @@ export default function test() {
done();
}, 100)
}
function unSubscribeOnStateCallback() {
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);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyInvisibleForms_1500 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -930,3 +791,27 @@ 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 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 @@
import featureAbility from "@ohos.ability.featureAbility";
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 = {
events: ["FMS_FormOnAcquired_commonEvent"],
};
var onDeletedFormEvent = {
events: ["FMS_FormOnDeleted_commonEvent"],
};
var onStateFormEvent = {
events: ["FMS_FormOnState_commonEvent"],
};
......@@ -38,6 +31,10 @@ var onSupplyEvent = {
var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnAcquired;
var subscriberOnState;
var subscriberSupply;
export default function test() {
describe(`FmsStateFormTest`, () => {
......@@ -45,6 +42,14 @@ export default function test() {
done();
})
beforeEach(async () => {
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
subscriberOnState = await commonEvent.createSubscriber(onStateFormEvent);
subscriberSupply = await commonEvent.createSubscriber(onSupplyEvent);
await sleep(1000);
})
/**
* @tc.number: FMS_notifyVisibleForms_0200
* @tc.name: The form user does not have permission.
......@@ -53,29 +58,20 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_0200`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("2");
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallBack);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_0200"));
setTimeout(function () {
console.info('FMS_notifyVisibleForms_0200 onStateCallBack end');
console.log(`FMS_notifyVisibleForms_0200 end`);
done();
}, 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`);
await featureAbility.startAbility({
want: {
......@@ -108,14 +104,12 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_0300`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("7");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_0300"));
setTimeout(function () {
console.info('FMS_notifyVisibleForms_0300 delPublishCallBack end');
......@@ -123,15 +117,8 @@ export default function test() {
done();
}, 100)
}
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyVisibleForms_0300 unSubscribeOnStateCallback CallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_0300 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyVisibleForms_0300 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -164,13 +151,11 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_0400`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_0400 start`);
let subscriberOnState;
let formId;
function onStateCallBack(err, data) {
function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_0400 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback)
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_0400"))
setTimeout(function () {
console.info('FMS_notifyVisibleForms_0400 delPublishCallBack end');
......@@ -178,15 +163,8 @@ export default function test() {
done();
}, 100)
}
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyVisibleForms_0400 unSubscribeOnStateCallback CallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_0400 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyVisibleForms_0400 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -219,14 +197,12 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_0500`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback)
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_0500"))
setTimeout(function () {
console.info('FMS_notifyVisibleForms_0500 delPublishCallBack end');
......@@ -234,15 +210,8 @@ export default function test() {
done();
}, 100);
}
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyVisibleForms_0500 unSubscribeOnStateCallback CallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_0500 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyVisibleForms_0500 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -275,46 +244,24 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_0600`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_0600 start`);
let subscriberOnState;
let subscriberOnAcquired;
let formId;
function delPublishCallBack() {
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) {
function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_0600 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unsubscribeOnStateCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_0600"));
let commonEventPublishData = {
data: formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
function unsubscribeOnStateCallback() {
console.debug("====>FMS_notifyVisibleForms_0600 unsubscribeOnStateCallback====>");
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyVisibleForms_0600", done));
}
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));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallback)
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_notifyVisibleForms_0600"))
formId = data.data;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_0600 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbility again start`);
await featureAbility.startAbility({
want: {
......@@ -340,11 +287,7 @@ export default function test() {
console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbility again end`);
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_0600 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack);
console.log(`FMS_notifyVisibleForms_0600 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -375,14 +318,12 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_0700`, 0, async (done) => {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_0700"));
setTimeout(function () {
console.info('FMS_notifyVisibleForms_0700 onStateCallBack end');
......@@ -390,19 +331,8 @@ export default function test() {
done();
}, 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) => {
console.debug("====>FMS_notifyVisibleForms_0700 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyVisibleForms_0700 featureAbility.startAbility again start`);
await featureAbility.startAbility({
want: {
......@@ -436,74 +366,49 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_1000`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1000 start`);
let subscriberInvisible;
let subscriberVisible;
let subscriberSupply;
let supplyFlag = false;
let formIdInvisible;
let formIdVisible;
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") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyVisibleForms_1000 onSupplyCallBack====>" + JSON.stringify(data));
onSupplyCount++;
if (onSupplyCount == 2) {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1000"));
}
if (formIdInvisible && formIdVisible) {
let commonEventPublishData = {
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));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
formIdVisible = data.parameters.formId;
commonEvent.unsubscribe(subscriberVisible, unSubscribeOnVisibleCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_1000"));
if (formIdInvisible && formIdVisible && onSupplyCount == 2) {
let commonEventPublishData = {
data: formIdInvisible
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
}
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyVisibleForms_1000", done));
}
function unSubscribeOnVisibleCallback() {
console.debug("====>FMS_notifyVisibleForms_1000 unSubscribeOnVisibleCallback CallBack====>");
}
function unSubscribeOnInvisibleCallback(){
console.debug("====>FMS_notifyVisibleForms_1000 unSubscribeOnInvisibleCallback CallBack====>");
}
async function OnInvisibleCallBack(err, data) {
async function OnInvisibleCallBack(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_1000 OnInvisibleCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberInvisible, unSubscribeOnInvisibleCallback)
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_1000"))
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`);
await featureAbility.startAbility({
want: {
......@@ -529,16 +434,8 @@ export default function test() {
console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbility again end`);
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1300 onStateFormEvent Invisible Subscriber====>");
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);
});
commonEvent.subscribe(subscriberOnState, OnInvisibleCallBack);
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.log(`FMS_notifyVisibleForms_1000 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -571,25 +468,12 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_1100`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1100 start`);
let subscriberSupply;
let subscriberOnVisible;
let assertFormId;
function unSubscribeSupplyCallback() {
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) {
function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") {
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));
let formId = Object.keys(JSON.parse(data.parameters.parameters))[0];
const visibilityStatus = JSON.parse(data.parameters.parameters)[formId];
......@@ -599,15 +483,11 @@ export default function test() {
let commonEventPublishData = {
data: formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyVisibleForms_1000", done));
}
}
function unSubscribeOnVisibleCallback() {
console.debug("====>FMS_notifyVisibleForms_1100 unSubscribeOnVisibleCallback CallBack====>");
}
function onVisibleCallBack(err, data) {
function onVisibleCallBack(_, data) {
if (data.parameters.kind != "visible") {
return;
}
......@@ -616,18 +496,11 @@ export default function test() {
expect(data.data).assertEqual("0");
assertFormId = data.parameters.formId;
commonEvent.unsubscribe(subscriberOnVisible, unSubscribeOnVisibleCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_1100"));
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1100 onStateFormEvent Visible Subscriber====>");
subscriberOnVisible = data;
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);
});
commonEvent.subscribe(subscriberOnState, onVisibleCallBack);
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.log(`FMS_notifyVisibleForms_1100 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -662,25 +535,8 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_1200`, 0, async (done) => {
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() {
console.debug("====>FMS_notifyVisibleForms_1200 unSubscribeOnVisibleCallback CallBack====>");
}
function unSubscribeSupplyCallback() {
console.debug("====>FMS_notifyVisibleForms_1200 unSubscribeSupplyCallback CallBack====>");
}
function onVisibleCallBack(err, data) {
function onVisibleCallBack(_, data) {
if (data.parameters.kind != "visible") {
return;
}
......@@ -689,35 +545,28 @@ export default function test() {
expect(data.data).assertEqual("0");
setTimeout(function () {
commonEvent.unsubscribe(subscriberOnVisible, unSubscribeOnVisibleCallback);
commonEvent.unsubscribe(subscriberOnSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_1200"));
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1200"));
let commonEventPublishData = {
data: data.parameters.formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyVisibleForms_1200", done));
}, 2000);
}
function onSupplyEventCallBack(err, data) {
function onSupplyEventCallBack(_, data) {
if (data.parameters.kind != "onVisibilityChange") {
return;
}
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.log(`FMS_notifyVisibleForms_1200 error`);
expect().assertFail();
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1200 onStateFormEvent Visible Subscriber====>");
subscriberOnVisible = data;
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);
});
commonEvent.subscribe(subscriberOnState, onVisibleCallBack);
commonEvent.subscribe(subscriberSupply, onSupplyEventCallBack);
console.log(`FMS_notifyVisibleForms_1200 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -751,21 +600,8 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_1300`, 0, async (done) => {
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() {
console.debug("====>FMS_notifyVisibleForms_1300 unSubscribeOnVisibleCallback CallBack====>");
}
function OnVisibleCallBack(err, data) {
function OnVisibleCallBack(_, data) {
if (data.parameters.kind != "visible") {
return;
}
......@@ -773,18 +609,15 @@ export default function test() {
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberOnVisible, unSubscribeOnVisibleCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_1300"));
let commonEventPublishData = {
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====>");
subscriberOnVisible = data;
await commonEvent.subscribe(subscriberOnVisible, OnVisibleCallBack);
});
commonEvent.subscribe(subscriberOnState, OnVisibleCallBack);
console.log(`FMS_notifyVisibleForms_1300 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -820,9 +653,6 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_1400`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1400 start`);
let subscriberOnAcquired;
let subscriberOnState;
let subscriberSupply;
let supplyFlag = false;
let formId1;
let formId2;
......@@ -834,7 +664,7 @@ export default function test() {
delCount++;
if (delCount == 2) {
setTimeout(function () {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1400"));
if (supplyFlag) {
expect().assertFail();
}
......@@ -844,7 +674,7 @@ export default function test() {
}, 1000);
}
}
function onAcquiredCallBack_Normal1(err, data) {
function onAcquiredCallBack_Normal1(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_1400 onAcquiredCallBack_Normal1 data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal1)
......@@ -853,17 +683,11 @@ export default function test() {
FMS_notifyVisibleForms_1400_normal2();
}
function unSubscribeOnAcquiredCallBack_Normal1() {
console.debug("====>FMS_notifyVisibleForms_1400 unSubscribeOnAcquiredCallBack_Normal1 CallBack====>");
console.debug("====>FMS_notifyVisibleForms_1400 unSubscribeOnAcquiredCallBack_Normal2====>");
}
async function FMS_notifyVisibleForms_1400_normal1() {
console.log(`FMS_notifyVisibleForms_1400_normal1 start`);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1400_normal1 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal1);
console.log(`FMS_notifyVisibleForms_1400_normal1 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -889,11 +713,11 @@ export default function test() {
console.log(`FMS_notifyVisibleForms_1400_normal1 end`);
}
function onStateCallBack(err, data) {
function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_1400 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
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 formId2:====>" + formId2);
console.info("!!!====>FMS_notifyVisibleForms_1400 onStateCallBack onSupplyCount:====>" + onSupplyCount);
......@@ -908,21 +732,15 @@ export default function test() {
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));
expect(data.event).assertEqual("FMS_FormOnAcquired_commonEvent");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeOnAcquiredCallBack_Normal2);
formId2 = data.data;
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1400 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyVisibleForms_1400 featureAbility.startAbility start`);
await featureAbility.startAbility({
......@@ -952,12 +770,8 @@ export default function test() {
console.debug("====>FMS_notifyVisibleForms_1400 unSubscribeOnAcquiredCallBack_Normal2====>");
}
async function FMS_notifyVisibleForms_1400_normal2() {
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1400_normal2 Create OnAcquired Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
});
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack_Normal2);
console.log(`FMS_notifyVisibleForms_1400_normal2 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -981,10 +795,7 @@ export default function test() {
console.log(`FMS_notifyVisibleForms_1400_normal2 featureAbility.startAbility end`);
}
function unSubscribeSupplyCallback() {
console.debug("====>FMS_notifyVisibleForms_1400 unSubscribeSupplyCallback====>");
}
function onSupplyCallBack(err, data) {
function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyVisibleForms_1400 onSupplyCallBack====>" + JSON.stringify(data));
......@@ -999,7 +810,7 @@ export default function test() {
onSupplyCount++;
if (onSupplyCount == 2) {
supplyFlag = true;
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1400"));
}
if (formId1 && formId2) {
......@@ -1014,11 +825,7 @@ export default function test() {
}
}
}
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1400 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
FMS_notifyVisibleForms_1400_normal1();
});
/**
......@@ -1029,23 +836,17 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_1500`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1500 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formIds = new Array();
let retFormId;
let count = 0;
function unSubscribeSupplyCallback() {
console.debug("====>FMS_notifyVisibleForms_1500 unSubscribeSupplyCallback====>");
}
function delPublishCallBack1(err, data) {
function delPublishCallBack1(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_1500 delPublishCallBack1====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_notifyVisibleForms_1500 delPublishCallBack1 end');
console.log(`FMS_notifyVisibleForms_1500 end`);
}, 1000);
}
function delPublishCallBack2(err, data) {
function delPublishCallBack2(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_1500 delPublishCallBack2====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_notifyVisibleForms_1500 delPublishCallBack2 end');
......@@ -1054,7 +855,7 @@ export default function test() {
}, 1000);
}
function onInVisibleSupplyCallBack(err, data) {
function onInVisibleSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyVisibleForms_1500 onInVisibleSupplyCallBack====>" + JSON.stringify(data));
......@@ -1066,7 +867,7 @@ export default function test() {
++count;
if (count == 12) {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1500"));
let commonEventPublishData1 = {
data: formIds[0]
};
......@@ -1079,7 +880,7 @@ export default function test() {
}
}
async function onVisibleSupplyCallBack(err, data) {
async function onVisibleSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyVisibleForms_1500 onVisibleSupplyCallBack====>" + JSON.stringify(data));
......@@ -1091,12 +892,9 @@ export default function test() {
++count;
if (count == 6) {
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1500 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onInVisibleSupplyCallBack);
});
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1500"));
subscriberSupply = await commonEvent.createSubscriber(onSupplyEvent);
commonEvent.subscribe(subscriberSupply, onInVisibleSupplyCallBack);
console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility notifyInvisible start`);
for (var i = 0; i < 3; i++) {
await featureAbility.startAbility({
......@@ -1120,19 +918,14 @@ export default function test() {
}
}
async function onAcquiredCallBack2(err, data) {
async function onAcquiredCallBack2(_, data) {
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));
formIds.push(data.data);
console.debug("====>FMS_notifyVisibleForms_1500 formIds====>" + formIds);
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1500 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onVisibleSupplyCallBack);
});
commonEvent.subscribe(subscriberSupply, onVisibleSupplyCallBack);
console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility notifyVisible start`);
for (var i = 0; i < 3; i++) {
await featureAbility.startAbility({
......@@ -1154,19 +947,15 @@ export default function test() {
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");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1500"));
console.debug("====>FMS_notifyVisibleForms_1500 onAcquiredCallBack1====>" + JSON.stringify(data));
formIds.push(data.data);
console.debug("====>FMS_notifyVisibleForms_1500 formIds====>" + JSON.stringify(formIds));
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1500 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack2);
});
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack2);
console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility serviceb start`);
await featureAbility.startAbility({
want: {
......@@ -1190,11 +979,7 @@ export default function test() {
console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility serviceb end`);
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1500 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack1);
});
commonEvent.subscribe(subscriberOnAcquired, onAcquiredCallBack1);
console.log(`FMS_notifyVisibleForms_1500 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({
want: {
......@@ -1226,23 +1011,17 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_1600`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1600 start`);
let subscriberOnAcquired;
let subscriberSupply;
let formIds = new Array();
let retFormId;
let count = 0;
function unSubscribeSupplyCallback() {
console.debug("====>FMS_notifyVisibleForms_1600 unSubscribeSupplyCallback====>");
}
function delPublishCallBack1(err, data) {
function delPublishCallBack1(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_1600 delPublishCallBack1====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_notifyVisibleForms_1600 delPublishCallBack1 end');
console.log(`FMS_notifyVisibleForms_1600 end`);
}, 1000);
}
function delPublishCallBack2(err, data) {
function delPublishCallBack2(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_1600 delPublishCallBack2====>" + JSON.stringify(data));
setTimeout(function () {
console.info('FMS_notifyVisibleForms_1600 delPublishCallBack2 end');
......@@ -1251,7 +1030,7 @@ export default function test() {
}, 1000);
}
function onSupplyCallBack(err, data) {
function onSupplyCallBack(_, data) {
if (data.parameters.kind == "onVisibilityChange") {
expect(data.event).assertEqual("FMS_FormSupply_commonEvent");
console.debug("====>FMS_notifyVisibleForms_1600 onSupplyCallBack====>" + JSON.stringify(data));
......@@ -1264,7 +1043,7 @@ export default function test() {
++count;
if (count == 2) {
console.debug("====>FMS_notifyVisibleForms_1600 OK====>");
commonEvent.unsubscribe(subscriberSupply, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberSupply, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1500"));
let commonEventPublishData1 = {
data: formIds[0]
......@@ -1278,20 +1057,15 @@ export default function test() {
}
}
async function onSecondAcquiredCallBack(err, data) {
async function onSecondAcquiredCallBack(_, data) {
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));
formIds.push(data.data);
formIds.push("-1");
console.debug("====>FMS_notifyVisibleForms_1600 formIds====>" + formIds);
commonEvent.createSubscriber(onSupplyEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1600 onSupplyEvent Subscriber====>");
subscriberSupply = data;
await commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
});
commonEvent.subscribe(subscriberSupply, onSupplyCallBack);
console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility notifyVisible start`);
await featureAbility.startAbility({
want: {
......@@ -1317,18 +1091,14 @@ export default function test() {
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");
commonEvent.unsubscribe(subscriberOnAcquired, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberOnAcquired, () => unsubscribeOnAcquiredCallback("FMS_notifyVisibleForms_1500"));
console.debug("====>FMS_notifyVisibleForms_1600 onFirstAcquiredCallBack====>" + JSON.stringify(data));
formIds.push(data.data);
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1600 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack);
});
subscriberOnAcquired = await commonEvent.createSubscriber(onAcquiredForm_Event);
commonEvent.subscribe(subscriberOnAcquired, onSecondAcquiredCallBack);
console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility serviceb start`);
await featureAbility.startAbility({
want: {
......@@ -1352,11 +1122,7 @@ export default function test() {
console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility serviceb end`);
}
commonEvent.createSubscriber(onAcquiredForm_Event).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1600 onAcquiredForm_Event Subscriber====>");
subscriberOnAcquired = data;
await commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack);
});
commonEvent.subscribe(subscriberOnAcquired, onFirstAcquiredCallBack);
console.log(`FMS_notifyVisibleForms_1600 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({
want: {
......@@ -1388,25 +1154,10 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_1700`, 0, async (done) => {
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");
commonEvent.unsubscribe(subscriberVisible, unSubscribeSupplyCallback);
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeSupplyCallback("FMS_notifyVisibleForms_1700"));
console.debug("====>FMS_notifyVisibleForms_1700 onFirstAcquiredCallBack====>" + JSON.stringify(data));
expect(data.parameters.kind).assertEqual("visible");
expect(data.data).assertEqual("0");
......@@ -1415,13 +1166,13 @@ export default function test() {
let commonEventPublishData = {
data: data.parameters.formId
};
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallBack);
commonEvent.publish(deleteForm_Event, commonEventPublishData, delPublishCallback("FMS_notifyVisibleForms_1700", done));
}, 2000);
}
function onFormSupplyCallBack(err, data) {
function onFormSupplyCallBack(_, data) {
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));
if (data.parameters.kind == "onVisibilityChange") {
console.debug("====>FMS_notifyVisibleForms_1700 error");
......@@ -1429,18 +1180,8 @@ export default function test() {
}
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1700 onStateFormEvent Subscriber====>");
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);
});
commonEvent.subscribe(subscriberOnState, onFormVisibleCallBack);
commonEvent.subscribe(subscriberSupply, onFormSupplyCallBack);
console.log(`FMS_notifyVisibleForms_1700 featureAbility.startAbility servicea start`);
await featureAbility.startAbility({
want: {
......@@ -1475,13 +1216,11 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_1800`, 0, async (done) => {
console.info(`FMS_notifyVisibleForms_1800 start`);
let subscriberVisible;
let subscriberSupply;
let hostFormId;
let providerFormId;
let counter = 0;
const delPublishCallback = (err, data) => {
const delPublishCallback = (_, data) => {
console.info("!!!====>FMS_notifyVisibleForms_1800 delPublishCallback====>");
setTimeout(() => {
expect(hostFormId).assertEqual(providerFormId);
......@@ -1491,7 +1230,7 @@ export default function test() {
}, 1000);
}
const onSupplyCallback = (err, data) => {
const onSupplyCallback = (_, data) => {
if (data.parameters.kind != "onVisibilityChange") {
return;
}
......@@ -1511,7 +1250,7 @@ export default function test() {
}
}
const onVisibleCallback = (err, data) => {
const onVisibleCallback = (_, data) => {
if (data.parameters.kind != "visible") {
return;
}
......@@ -1519,7 +1258,7 @@ export default function test() {
hostFormId = data.parameters.formId;
expect(data.data).assertEqual("0");
commonEvent.unsubscribe(subscriberVisible, () => {
commonEvent.unsubscribe(subscriberOnState, () => {
console.info("====>FMS_notifyVisibleForms_1800 unSubscribeOnVisibleCallback====>");
});
if (++counter == 2) {
......@@ -1530,17 +1269,8 @@ export default function test() {
}
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.info("====>FMS_notifyVisibleForms_1800 onStateFormEvent Visible Subscriber====>");
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);
});
commonEvent.subscribe(subscriberOnState, onVisibleCallback);
commonEvent.subscribe(subscriberSupply, onSupplyCallback);
console.info(`FMS_notifyVisibleForms_1800 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -1571,13 +1301,12 @@ export default function test() {
*/
it(`FMS_notifyVisibleForms_1900`, 0, async (done) => {
console.log(`FMS_notifyVisibleForms_1900 start`);
let subscriberOnState;
let formId;
function onStateCallBack(err, data) {
function onStateCallBack(_, data) {
console.info("!!!====>FMS_notifyVisibleForms_1900 onStateCallBack data:====>" + JSON.stringify(data));
expect(data.event).assertEqual("FMS_FormOnState_commonEvent");
expect(data.data != "0").assertEqual(true);
commonEvent.unsubscribe(subscriberOnState, unSubscribeOnStateCallback)
commonEvent.unsubscribe(subscriberOnState, () => unsubscribeOnStateCallback("FMS_notifyVisibleForms_1900"))
setTimeout(function () {
console.info('FMS_notifyVisibleForms_1900 delPublishCallBack end');
......@@ -1585,15 +1314,8 @@ export default function test() {
done();
}, 100);
}
function unSubscribeOnStateCallback() {
console.debug("====>FMS_notifyVisibleForms_1900 unSubscribeOnStateCallback CallBack====>");
}
commonEvent.createSubscriber(onStateFormEvent).then(async (data) => {
console.debug("====>FMS_notifyVisibleForms_1900 onStateFormEvent Subscriber====>");
subscriberOnState = data;
await commonEvent.subscribe(subscriberOnState, onStateCallBack);
});
commonEvent.subscribe(subscriberOnState, onStateCallBack);
console.log(`FMS_notifyVisibleForms_1900 featureAbility.startAbility start`);
await featureAbility.startAbility({
want: {
......@@ -1624,3 +1346,31 @@ 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 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.
先完成此消息的编辑!
想要评论请 注册