提交 3e231235 编写于 作者: C chengxingzhen

XTS元能力问题用例适配

Signed-off-by: Nchengxingzhen <chengxingzhen@huawei.com>
上级 ec3b85fc
...@@ -19,6 +19,7 @@ export default class MainAbility extends Ability { ...@@ -19,6 +19,7 @@ export default class MainAbility extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate") console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want; globalThis.abilityWant = want;
globalThis.applicationContext = this.context.getApplicationContext();
} }
onDestroy() { onDestroy() {
......
...@@ -392,9 +392,9 @@ function checkFormInfoModule1(formInfo){ ...@@ -392,9 +392,9 @@ function checkFormInfoModule1(formInfo){
expect("This is a service widget.").assertEqual(formInfo.description) expect("This is a service widget.").assertEqual(formInfo.description)
expect(FormInfo.FormType.JS).assertEqual(formInfo.type) expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect(FormInfo.ColorMode.MODE_DARK).assertEqual(formInfo.colorMode) expect(FormInfo.ColorMode.MODE_DARK).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault) expect(formInfo.isDefault).assertTrue()
expect(1).assertEqual(formInfo.updateEnabled) expect(formInfo.updateEnabled).assertTrue()
expect(0).assertEqual(formInfo.formVisibleNotify) expect(formInfo.formVisibleNotify).assertFalse()
expect(undefined).assertEqual(formInfo.relatedBundleName) expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("ability://xxxxx").assertEqual(formInfo.formConfigAbility) expect("ability://xxxxx").assertEqual(formInfo.formConfigAbility)
expect(1).assertEqual(formInfo.updateDuration) expect(1).assertEqual(formInfo.updateDuration)
...@@ -410,9 +410,9 @@ function checkFormInfo(formInfo){ ...@@ -410,9 +410,9 @@ function checkFormInfo(formInfo){
expect("This is a service widget.").assertEqual(formInfo.description) expect("This is a service widget.").assertEqual(formInfo.description)
expect(FormInfo.FormType.JS).assertEqual(formInfo.type) expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect(FormInfo.ColorMode.MODE_AUTO).assertEqual(formInfo.colorMode) expect(FormInfo.ColorMode.MODE_AUTO).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault) expect(formInfo.isDefault).assertTrue()
expect(1).assertEqual(formInfo.updateEnabled) expect(formInfo.updateEnabled).assertTrue()
expect(0).assertEqual(formInfo.formVisibleNotify) expect(formInfo.formVisibleNotify).assertFalse()
expect(undefined).assertEqual(formInfo.relatedBundleName) expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("ability://xxxxx").assertEqual(formInfo.formConfigAbility) expect("ability://xxxxx").assertEqual(formInfo.formConfigAbility)
expect(1).assertEqual(formInfo.updateDuration) expect(1).assertEqual(formInfo.updateDuration)
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
var TAG: string = ''
export default function ContextEnvironmentTest(applicationContext) {
describe('ContextEnvironmentTest', function () {
var isUpdated = false;
var update_language = "";
var callbackid_NA = 100
var callbackid_errorNum = -1
var callbackid_errorType = "test"
var callNum = 0;
let envCallback = {
onConfigurationUpdated(config) {
console.info(TAG, `envCallback onConfigurationUpdated success: ${JSON.stringify(config)}`)
update_language = config.language;
isUpdated = true;
}
}
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
let gSetTimeout = 1000
beforeEach(async (done) => {
isUpdated = false;
setTimeout(function () {
done();
}, gSetTimeout);
})
afterEach(async (done) => {
isUpdated = false;
setTimeout(function () {
done();
}, gSetTimeout);
})
/*
* @tc.number SUB_AA_AMS_Context_EnvironmentTest_0400
* @tc.name Multiple registrations and deregistration.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AMS_Context_EnvironmentTest_0400', 0, async function (done) {
TAG = 'SUB_AA_AMS_Context_EnvironmentTest_0400 ==== '
console.info(TAG, `begin`)
for (let i = 0;i < 5;i++) {
// registerEnvironmentCallback
var callbackId = applicationContext.registerEnvironmentCallback(envCallback);
var code = undefined
console.info(TAG + "callbackId = " + callbackId + " callNum = " + callNum)
await sleep(1000)
// unregisterEnvironmentCallback
applicationContext.unregisterEnvironmentCallback(callbackId, (error, data) => {
console.info(TAG + "unregisterEnvironmentCallback first err is : " + JSON.stringify(error) + ", data is : " + JSON.stringify(data))
code = error.code
})
await sleep(1000)
expect(callbackId).assertEqual(callNum)
expect(code).assertEqual(0)
callNum++;
}
done()
console.info(TAG, `end`)
})
/*
* @tc.number SUB_AA_AMS_Context_EnvironmentTest_0500
* @tc.name unregisterEnvironmentCallback interface input parameter is a nonexistent ID.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AMS_Context_EnvironmentTest_0500', 0, async function (done) {
TAG = 'SUB_AA_AMS_Context_EnvironmentTest_0500 ==== '
console.info(TAG, `begin`)
applicationContext.unregisterEnvironmentCallback(callbackid_NA, (error, data) => {
console.info(TAG + "unregisterEnvironmentCallback err is : " + JSON.stringify(error) + ", data is : " + JSON.stringify(data))
expect(error.code).assertEqual(1)
console.info(TAG, `end`)
done();
})
})
/*
* @tc.number SUB_AA_AMS_Context_EnvironmentTest_0600
* @tc.name unregisterEnvironmentCallback interface input parameter is negative.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AMS_Context_EnvironmentTest_0600', 0, async function (done) {
TAG = 'SUB_AA_AMS_Context_EnvironmentTest_0600 ==== '
console.info(TAG, `begin`)
applicationContext.unregisterEnvironmentCallback(callbackid_errorNum, (error, data) => {
console.info(TAG + "unregisterEnvironmentCallback err is : " + JSON.stringify(error) + ", data is : " + JSON.stringify(data))
expect(error.code).assertEqual(1)
console.info(TAG, `end`)
done();
})
})
/*
* @tc.number SUB_AA_AMS_Context_EnvironmentTest_0700
* @tc.name unregisterEnvironmentCallback interface input parameter is of wrong type.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AMS_Context_EnvironmentTest_0700', 0, async function (done) {
TAG = 'SUB_AA_AMS_Context_EnvironmentTest_0700 ==== '
console.info(TAG, `begin`)
applicationContext.unregisterEnvironmentCallback(callbackid_errorType, (error, data) => {
console.info(TAG + "unregisterEnvironmentCallback err is : " + JSON.stringify(error) + ", data is : " + JSON.stringify(data))
expect(error.code).assertEqual(1)
console.info(TAG, `end`)
done();
})
})
/*
* @tc.number SUB_AA_AMS_Context_EnvironmentTest_0800
* @tc.name unregisterEnvironmentCallback interface input parameter is undefined.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_AMS_Context_EnvironmentTest_0800', 0, async function (done) {
TAG = 'SUB_AA_AMS_Context_EnvironmentTest_0800 ==== '
console.info(TAG, `begin`)
await applicationContext.unregisterEnvironmentCallback(undefined).then((data) => {
console.info(TAG + "unregisterEnvironmentCallback data is : " + JSON.stringify(data))
expect().assertFail();
}).catch((error) => {
console.info(TAG + "unregisterEnvironmentCallback err is : " + JSON.stringify(error))
expect(error.code).assertEqual(1)
});
console.info(TAG, `end`)
done();
})
})
}
\ No newline at end of file
...@@ -16,10 +16,12 @@ ...@@ -16,10 +16,12 @@
import apiCoverAbility from './ApiCoverAbility.test' import apiCoverAbility from './ApiCoverAbility.test'
import verificationTest from './VerificationTest' import verificationTest from './VerificationTest'
import wantAgentCover from './WantAgentCover.test' import wantAgentCover from './WantAgentCover.test'
import contextEnvironmentTest from './ContextEnvironmentTest.test';
export default function List(context) { export default function List(context) {
apiCoverAbility(context) apiCoverAbility(context)
verificationTest(context) verificationTest(context)
wantAgentCover(context) wantAgentCover(context)
contextEnvironmentTest(globalThis.applicationContext)
} }
\ No newline at end of file
...@@ -366,89 +366,6 @@ export default function verificationTest(abilityContext){ ...@@ -366,89 +366,6 @@ export default function verificationTest(abilityContext){
} }
}) })
/*
* @tc.number SUB_AA_OpenHarmony_StartAbilityFlags_0100
* @tc.name Validate the input parameter flags of startAbility.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_StartAbilityFlags_0100', 0, async function(done) {
TAG = 'SUB_AA_OpenHarmony_StartAbilityFlags_0100 ==>';
try {
let number1 = undefined
let number2 = 536870912
let code1 = undefined
let code2 = undefined
let subscriber = null
let subscribeInfo = {
events: ["Stage_MainAbility7_onCreate", "Stage_MainAbility7_onDestroy"]
}
function SubscribeInfoCallback(err, data) {
console.info(TAG + "===SubscribeInfoCallback===" + JSON.stringify(data))
if (data.event == "Stage_MainAbility7_onCreate") {
number1 = data.parameters.flags
}
if (data.event == "Stage_MainAbility7_onDestroy") {
expect(code1).assertEqual(22);
expect(code2).assertEqual(14);
expect(number1).assertEqual(number2);
commonEvent.unsubscribe(subscriber, UnSubscribeInfoCallback)
}
}
function UnSubscribeInfoCallback(err, data) {
console.info(TAG + "===UnSubscribeInfoCallback===")
done()
}
commonEvent.createSubscriber(subscribeInfo, (err, data) => {
console.info(TAG + "===CreateSubscriberCallback===")
subscriber = data
commonEvent.subscribe(subscriber, SubscribeInfoCallback)
})
let wantNum1 = {
bundleName: 'ohos.acts.aafwk.test.stagesupplement',
abilityName: 'MainAbility6',
flags: wantConstant.Flags.FLAG_ABILITY_CONTINUATION
}
abilityContext.startAbility(wantNum1).then((data) => {
console.info(TAG + "startAbility data = " + JSON.stringify(data));
}).catch((err) => {
code1 = err.code
console.info(TAG + "startAbility err = " + JSON.stringify(err));
});
let wantNum2 = {
bundleName: 'ohos.acts.aafwk.test.stagesupplement',
abilityName: 'MainAbility7',
flags: wantConstant.Flags.FLAG_ABILITY_MISSION_TOP
}
abilityContext.startAbility(wantNum2).then((data) => {
console.info(TAG + "startAbility data = " + JSON.stringify(data));
}).catch((err) => {
console.info(TAG + "startAbility err = " + JSON.stringify(err));
expect().assertFail();
done();
});
let wantNum3 = {
bundleName: 'ohos.acts.aafwk.test.stagesupplement',
abilityName: 'MainAbility8',
flags: wantConstant.Flags.FLAG_INSTALL_ON_DEMAND
}
abilityContext.startAbility(wantNum3).then((data) => {
console.info(TAG + "startAbility data = " + JSON.stringify(data));
}).catch((err) => {
code2 = err.code
console.info(TAG + "startAbility err = " + JSON.stringify(err));
});
} catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err));
expect().assertFail();
done();
}
})
/* /*
* @tc.number SUB_AA_OpenHarmony_StartAbilityLife_0100 * @tc.number SUB_AA_OpenHarmony_StartAbilityLife_0100
* @tc.name Ability startup and termination will not trigger the migration lifecycle. * @tc.name Ability startup and termination will not trigger the migration lifecycle.
......
import ServiceExtensionAbility from "@ohos.application.ServiceExtensionAbility";
import rpc from "@ohos.rpc";
import commonEvent from '@ohos.commonEvent';
class StubTest1 extends rpc.RemoteObject {
constructor(des) {
if (typeof des === 'string') {
super(des);
}
else {
return null;
}
}
queryLocalInterface(descriptor) {
return null;
}
getInterfaceDescriptor() {
return "";
}
sendRequest(code, data, reply, options) {
return null;
}
getCallingPid() {
return 0;
}
getCallingUid() {
return 0;
}
attachLocalInterface(localInterface, descriptor) { }
onRemoteRequest(code, data, reply, options) {
console.log(printLogS1 + "onRemoteRequest");
if (code == 1) {
console.log(printLogS1 + "onRemoteRequest code 1");
let op1 = data.readInt();
let op2 = data.readInt();
console.log(printLogS1 + "onRemoteRequest op1 = " + op1 + ", op2 = " + op2);
reply.writeInt(op1 + op2);
}
else {
console.log(printLogS1 + "onRemoteRequest code = " + code);
}
return true;
}
}
var printLogS1 = "Stage:ServiceAbility:";
var listPushS1 = "Stage_ServiceAbility_";
class ExtensionAbility extends ServiceExtensionAbility {
onCreate(want) {
console.log(printLogS1 + 'onCreate');
commonEvent.publish(listPushS1 + "onCreate", (err) => {
console.info(printLogS1 + listPushS1 + "onCreate");
});
}
onDestroy() {
console.log(printLogS1 + 'onDestroy');
commonEvent.publish(listPushS1 + "onDestroy", (err) => {
console.info(printLogS1 + listPushS1 + "onDestroy");
});
}
onRequest(want, startId) {
console.log(printLogS1 + 'onRequest');
}
onConnect(want) {
console.log(printLogS1 + 'onConnect');
return new StubTest1("Test1");
}
onDisconnect(want) {
console.log(printLogS1 + 'onDisconnect');
this.context
}
dump(param) {
console.info(printLogS1 + "dump = " + JSON.stringify(param))
var CommonEventPublishData = {
parameters: {
dumpParam: param
}
}
commonEvent.publish(listPushS1 + "Dump", CommonEventPublishData, (err) => {
console.info(printLogS1 + listPushS1 + "Dump");
});
return ["ExtensionAbility"]
}
};
export default ExtensionAbility
\ No newline at end of file
import ServiceExtensionAbility from "@ohos.application.ServiceExtensionAbility";
import rpc from "@ohos.rpc";
import commonEvent from '@ohos.commonEvent';
class StubTest2 extends rpc.RemoteObject {
constructor(des) {
if (typeof des === 'string') {
super(des);
}
else {
return null;
}
}
queryLocalInterface(descriptor) {
return null;
}
getInterfaceDescriptor() {
return "";
}
sendRequest(code, data, reply, options) {
return null;
}
getCallingPid() {
return 0;
}
getCallingUid() {
return 0;
}
attachLocalInterface(localInterface, descriptor) { }
onRemoteRequest(code, data, reply, options) {
console.log(printLogS2 + "onRemoteRequest");
if (code == 1) {
console.log(printLogS2 + "onRemoteRequest code 1");
let op1 = data.readInt();
let op2 = data.readInt();
console.log(printLogS2 + "onRemoteRequest op1 = " + op1 + ", op2 = " + op2);
reply.writeInt(op1 + op2);
}
else {
console.log(printLogS2 + "onRemoteRequest code = " + code);
}
return true;
}
}
var printLogS2 = "Stage:ServiceAbility2:";
var listPushS2 = "Stage_ServiceAbility2_";
class ExtensionAbility2 extends ServiceExtensionAbility {
onCreate(want) {
console.log(printLogS2 + 'onCreate');
commonEvent.publish(listPushS2 + "onCreate", (err) => {
console.info(printLogS2 + listPushS2 + "onCreate");
});
}
onDestroy() {
console.log(printLogS2 + 'onDestroy');
commonEvent.publish(listPushS2 + "onDestroy", (err) => {
console.info(printLogS2 + listPushS2 + "onDestroy");
});
}
onRequest(want, startId) {
console.log(printLogS2 + 'onRequest');
}
onConnect(want) {
console.log(printLogS2 + 'onConnect');
return new StubTest2("Test1");
}
onDisconnect(want) {
console.log(printLogS2 + 'onDisconnect');
}
};
export default ExtensionAbility2
\ No newline at end of file
import Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent';
import AbilityConstant from '@ohos.application.AbilityConstant';
import distributedObject from '@ohos.data.distributedDataObject';
import accessControl from '@ohos.abilityAccessCtrl';
import bundle from '@ohos.bundle';
var BUNDLE_NAME = 'ohos.acts.aafwk.test.stagesupplement'
var PERMISSION_REJECT = -1
var printLog2 = "Stage:MainAbility2:";
var listPush2 = "Stage_MainAbility2_";
class ContentStorage {
}
var g_object = distributedObject.createDistributedObject({name:undefined});
export default class MainAbility2 extends Ability {
contentStorage : ContentStorage
sessionId : string;
statusCallback(sessionId, networkid, status) {
// @ts-ignore
console.info(printLog2 + `continuation object status change, sessionId: ${sessionId}, status: ${status}, g_object.name: ${g_object.name}`)
}
onCreate(want, launchParam) {
console.info(printLog2 + "onCreate = " + launchParam.launchReason)
if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) {
let input = want.parameters.input // get user data from want params
// @ts-ignore
AppStorage.SetOrCreate<string>('ContinueInput', input)
console.info(printLog2 + `onCreate for continuation sessionId: ${this.sessionId}`)
this.contentStorage = new ContentStorage();
this.context.restoreWindowStage(this.contentStorage);
}
}
onDestroy() {
console.info(printLog2 + "onDestroy")
commonEvent.publish(listPush2 + "onDestroy", (err) => {
console.info(printLog2 + listPush2 + "onDestroy");
});
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.info(printLog2 + "onWindowStageCreate")
// this.requestPermissions()
windowStage.setUIContent(this.context, "pages/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.info(printLog2 + "onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.info(printLog2 + "onForeground")
}
onBackground() {
// Ability has back to background
console.info(printLog2 + "onBackground")
}
onContinue(wantParam : {[key: string]: any}) {
console.info(printLog2 + "onContinue")
// set user input data into want params
// @ts-ignore
wantParam["input"] = AppStorage.Get<string>('ContinueInput');
console.info(printLog2 + `onContinue input = ${wantParam["input"]}`);
return AbilityConstant.OnContinueResult.AGREE
}
// @ts-ignore
onNewWant(want, launchParam) {
console.info(printLog2 + "onNewWant = " + launchParam.launchReason)
if (launchParam.launchReason == AbilityConstant.LaunchReason.CONTINUATION) {
// get distributed data object session id from want params
this.sessionId = want.parameters.session
// @ts-ignore
g_object.name = undefined;
// @ts-ignore
g_object.on("status", this.statusCallback);
// set session id, so it will sync data from remote device
g_object.setSessionId(this.sessionId);
this.contentStorage = new ContentStorage();
this.context.restoreWindowStage(this.contentStorage);
}
}
onWindowStageRestore(windowStage) {
console.info(printLog2 + "onWindowStageCreate")
// this.requestPermissions()
commonEvent.publish(listPush2 + "onWindowStageRestore", (err) => {
console.info(printLog2 + listPush2 + "onWindowStageRestore");
});
setTimeout(()=>{
this.context.terminateSelf().then((data) => {
console.info(printLog2 + "terminateSelf data = " + JSON.stringify(data));
}).catch((err) => {
console.info(printLog2 + "terminateSelf err = " + JSON.stringify(err));
});
}, 3000)
}
requestPermissions = async () => {
let permissions: Array<string> = [
"ohos.permission.DISTRIBUTED_DATASYNC"
];
let needGrantPermission = false
let accessManger = accessControl.createAtManager()
console.info(printLog2 + "app permission get bundle info")
let bundleInfo = await bundle.getApplicationInfo(BUNDLE_NAME, 0, 100)
console.info(printLog2 + `app permission query permission ${bundleInfo.accessTokenId.toString()}`)
for (const permission of permissions) {
console.info(printLog2 + `app permission query grant status ${permission}`)
try {
let grantStatus = await accessManger.verifyAccessToken(bundleInfo.accessTokenId, permission)
if (grantStatus === PERMISSION_REJECT) {
needGrantPermission = true
break;
}
} catch (err) {
console.info(printLog2 + `app permission query grant status error ${permission} ${JSON.stringify(err)}`)
needGrantPermission = true
break;
}
}
if (needGrantPermission) {
console.info(printLog2 + "app permission needGrantPermission")
try {
await this.context.requestPermissionsFromUser(permissions)
} catch (err) {
console.info(printLog2 + `app permission ${JSON.stringify(err)}`)
}
} else {
console.info(printLog2 + "app permission already granted")
}
}
};
import Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent';
var printLog6 = "Stage:MainAbility6:";
var listPush6 = "Stage_MainAbility6_";
export default class MainAbility6 extends Ability {
onCreate(want, launchParam) {
console.info(printLog6 + "onCreate = " + want.flags)
var flags = {
parameters: {
flags: want.flags
}
}
commonEvent.publish(listPush6 + "onCreate", flags, (err) => {
console.info(printLog6 + listPush6 + "onCreate");
});
setTimeout(()=>{
this.context.terminateSelf().then((data) => {
console.info(printLog6 + "terminateSelf data = " + JSON.stringify(data));
}).catch((err) => {
console.info(printLog6 + "terminateSelf err = " + JSON.stringify(err));
});
}, 3000)
}
onDestroy() {
console.info(printLog6 + "onDestroy")
commonEvent.publish(listPush6 + "onDestroy", (err) => {
console.info(printLog6 + listPush6 + "onDestroy");
});
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.info(printLog6 + "onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.info(printLog6 + "onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.info(printLog6 + "onForeground")
}
onBackground() {
// Ability has back to background
console.info(printLog6 + "onBackground")
}
};
import Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent';
var printLog7 = "Stage:MainAbility7:";
var listPush7 = "Stage_MainAbility7_";
export default class MainAbility7 extends Ability {
onCreate(want, launchParam) {
console.info(printLog7 + "onCreate = " + want.flags)
var flags = {
parameters: {
flags: want.flags
}
}
commonEvent.publish(listPush7 + "onCreate", flags, (err) => {
console.info(printLog7 + listPush7 + "onCreate");
});
setTimeout(()=>{
this.context.terminateSelf().then((data) => {
console.info(printLog7 + "terminateSelf data = " + JSON.stringify(data));
}).catch((err) => {
console.info(printLog7 + "terminateSelf err = " + JSON.stringify(err));
});
}, 3000)
}
onDestroy() {
console.info(printLog7 + "onDestroy")
commonEvent.publish(listPush7 + "onDestroy", (err) => {
console.info(printLog7 + listPush7 + "onDestroy");
});
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.info(printLog7 + "onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.info(printLog7 + "onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.info(printLog7 + "onForeground")
}
onBackground() {
// Ability has back to background
console.info(printLog7 + "onBackground")
}
};
import Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent';
var printLog8 = "Stage:MainAbility8:";
var listPush8 = "Stage_MainAbility8_";
export default class MainAbility8 extends Ability {
onCreate(want, launchParam) {
console.info(printLog8 + "onCreate = " + want.flags)
var flags = {
parameters: {
flags: want.flags
}
}
commonEvent.publish(listPush8 + "onCreate", flags, (err) => {
console.info(printLog8 + listPush8 + "onCreate");
});
setTimeout(()=>{
this.context.terminateSelf().then((data) => {
console.info(printLog8 + "terminateSelf data = " + JSON.stringify(data));
}).catch((err) => {
console.info(printLog8 + "terminateSelf err = " + JSON.stringify(err));
});
}, 3000)
}
onDestroy() {
console.info(printLog8 + "onDestroy")
commonEvent.publish(listPush8 + "onDestroy", (err) => {
console.info(printLog8 + listPush8 + "onDestroy");
});
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.info(printLog8 + "onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.info(printLog8 + "onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.info(printLog8 + "onForeground")
}
onBackground() {
// Ability has back to background
console.info(printLog8 + "onBackground")
}
};
...@@ -34,18 +34,6 @@ ...@@ -34,18 +34,6 @@
} }
] ]
}, },
{
"name": "MainAbility2",
"srcEntrance": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:MainAbility2_desc",
"icon": "$media:icon",
"label": "$string:MainAbility2_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"visible": true,
"launchType": "singleton",
"continuable": true
},
{ {
"name": "MainAbility3", "name": "MainAbility3",
"srcEntrance": "./ets/MainAbility3/MainAbility3.ts", "srcEntrance": "./ets/MainAbility3/MainAbility3.ts",
...@@ -79,39 +67,6 @@ ...@@ -79,39 +67,6 @@
"visible": true, "visible": true,
"launchType": "singleton" "launchType": "singleton"
}, },
{
"name": "MainAbility6",
"srcEntrance": "./ets/MainAbility6/MainAbility6.ts",
"description": "$string:MainAbility6_desc",
"icon": "$media:icon",
"label": "$string:MainAbility6_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"visible": true,
"launchType": "singleton"
},
{
"name": "MainAbility7",
"srcEntrance": "./ets/MainAbility7/MainAbility7.ts",
"description": "$string:MainAbility7_desc",
"icon": "$media:icon",
"label": "$string:MainAbility7_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"visible": true,
"launchType": "singleton"
},
{
"name": "MainAbility8",
"srcEntrance": "./ets/MainAbility8/MainAbility8.ts",
"description": "$string:MainAbility8_desc",
"icon": "$media:icon",
"label": "$string:MainAbility8_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:white",
"visible": true,
"launchType": "singleton"
},
{ {
"name": "MainAbility9", "name": "MainAbility9",
"srcEntrance": "./ets/MainAbility9/MainAbility9.ts", "srcEntrance": "./ets/MainAbility9/MainAbility9.ts",
...@@ -135,25 +90,6 @@ ...@@ -135,25 +90,6 @@
"launchType": "singleton" "launchType": "singleton"
} }
], ],
"extensionAbilities": [
{
"srcEntrance": "./ets/ExtensionAbility/ExtensionAbility.ts",
"name": "ExtensionAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"type": "service",
"visible": true
},
{
"srcEntrance": "./ets/ExtensionAbility2/ExtensionAbility2.ts",
"name": "ExtensionAbility2",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"type": "fileShare",
"uri": "fileshare://com.samples.filesharetest.FileShare",
"visible": true
}
],
"requestPermissions": [ "requestPermissions": [
{ {
"name": "ohos.permission.DISTRIBUTED_DATASYNC" "name": "ohos.permission.DISTRIBUTED_DATASYNC"
......
...@@ -12,14 +12,6 @@ ...@@ -12,14 +12,6 @@
"name": "MainAbility_label", "name": "MainAbility_label",
"value": "StageSupplement" "value": "StageSupplement"
}, },
{
"name": "MainAbility2_desc",
"value": "description"
},
{
"name": "MainAbility2_label",
"value": "label"
},
{ {
"name": "MainAbility3_desc", "name": "MainAbility3_desc",
"value": "description" "value": "description"
...@@ -44,30 +36,6 @@ ...@@ -44,30 +36,6 @@
"name": "MainAbility5_label", "name": "MainAbility5_label",
"value": "label" "value": "label"
}, },
{
"name": "MainAbility6_desc",
"value": "description"
},
{
"name": "MainAbility6_label",
"value": "label"
},
{
"name": "MainAbility7_desc",
"value": "description"
},
{
"name": "MainAbility7_label",
"value": "label"
},
{
"name": "MainAbility8_desc",
"value": "description"
},
{
"name": "MainAbility8_label",
"value": "label"
},
{ {
"name": "MainAbility9_desc", "name": "MainAbility9_desc",
"value": "description" "value": "description"
...@@ -83,14 +51,6 @@ ...@@ -83,14 +51,6 @@
{ {
"name": "MainAbility10_label", "name": "MainAbility10_label",
"value": "label" "value": "label"
},
{
"name": "MainAbility11_desc",
"value": "description"
},
{
"name": "MainAbility11_label",
"value": "label"
} }
] ]
} }
\ No newline at end of file
...@@ -27,7 +27,7 @@ var getCallingBundleType = { ...@@ -27,7 +27,7 @@ var getCallingBundleType = {
} }
describe('ApplicationInfoTest', function () { describe('ApplicationInfoTest', function () {
var TAG = '';- var TAG = '';
/* /*
* @tc.number SUB_AA_OpenHarmony_FormBase_1000 * @tc.number SUB_AA_OpenHarmony_FormBase_1000
...@@ -44,11 +44,26 @@ describe('ApplicationInfoTest', function () { ...@@ -44,11 +44,26 @@ describe('ApplicationInfoTest', function () {
"test":11, "test":11,
"test3":true "test3":true
} }
var result = formBindingData.createFormBindingData(dataObj) var formData = formBindingData.createFormBindingData(dataObj)
console.log(TAG + " result is : " + JSON.stringify(result)) console.info(TAG + " result is : " + JSON.stringify(formData))
expect(JSON.stringify(result)).
assertEqual(JSON.stringify({"data":"{\"temperature\":\"11c\",\"time\":\"11:00\",\"test\":11,\"test3\":true}"})); let formDataStr = JSON.stringify(formData.data);
let formDataStrToObj = JSON.parse(formDataStr);
if (typeof(formDataStrToObj) == "string" ) {
console.info(TAG + " formDataStrToObj1 is : " + typeof formDataStrToObj)
let formDataStrToObj2 = JSON.parse(formDataStrToObj)
console.info(TAG + " formDataStrToObj2 is : " + typeof formDataStrToObj2)
expect(formDataStrToObj2.test).assertEqual(11)
expect(formDataStrToObj2.test3).assertTrue()
expect(formDataStrToObj2.time).assertEqual("11:00")
done();
} else {
console.info(TAG + " formDataStrToObj is : " + typeof formDataStrToObj)
expect(formDataStrToObj.test).assertEqual(11)
expect(formDataStrToObj.test3).assertTrue()
expect(formDataStrToObj.time).assertEqual("11:00")
done(); done();
}
console.info('------------end SUB_AA_OpenHarmony_FormBase_1000-------------'); console.info('------------end SUB_AA_OpenHarmony_FormBase_1000-------------');
}); });
......
...@@ -40,7 +40,7 @@ struct Index { ...@@ -40,7 +40,7 @@ struct Index {
core.init(); core.init();
core.subscribeEvent('task', reportExtend); core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config'); const configService = core.getDefaultService('config');
want.parameters['timeout'] = 10000; want.parameters['timeout'] = 20000;
console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters)); console.info('[FormComponent] parameters---->' + JSON.stringify(want.parameters));
configService.setConfig(want.parameters); configService.setConfig(want.parameters);
testsuite(); testsuite();
......
...@@ -599,7 +599,6 @@ export default function test() { ...@@ -599,7 +599,6 @@ export default function test() {
async function delPublishCallbackB() { async function delPublishCallbackB() {
console.info(`${tcNumber} delPublishCallbackB`); console.info(`${tcNumber} delPublishCallbackB`);
await sleep(1000);
console.info(`${tcNumber} delPublishCallbackB end`); console.info(`${tcNumber} delPublishCallbackB end`);
console.info(`${tcNumber} end`); console.info(`${tcNumber} end`);
done(); done();
......
...@@ -81,6 +81,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -81,6 +81,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
console.log(`${callbackName} exception caught: ${JSON.stringify(error)})`); console.log(`${callbackName} exception caught: ${JSON.stringify(error)})`);
console.log(`${callbackName} should not reach here`); console.log(`${callbackName} should not reach here`);
expect().assertFail(); expect().assertFail();
done();
} }
}); });
...@@ -97,6 +98,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -97,6 +98,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
console.log(`${promiseName} getFormsInfo data: ${JSON.stringify(data)}`); console.log(`${promiseName} getFormsInfo data: ${JSON.stringify(data)}`);
console.log(`${promiseName} should not reach here`); console.log(`${promiseName} should not reach here`);
expect().assertFail(); expect().assertFail();
done();
} catch (error) { } catch (error) {
console.log(`${promiseName} exception caught: ${JSON.stringify(error)})`); console.log(`${promiseName} exception caught: ${JSON.stringify(error)})`);
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE); expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
...@@ -177,7 +179,6 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -177,7 +179,6 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
tempDataB = dataB[0] tempDataB = dataB[0]
expect(error.code).assertEqual(ERR_OK_CODE); expect(error.code).assertEqual(ERR_OK_CODE);
expect(error.message).assertEqual(ERR_OK); expect(error.message).assertEqual(ERR_OK);
done();
console.log(`==========${callbackName2} ${describeName} end==========`); console.log(`==========${callbackName2} ${describeName} end==========`);
}); });
await sleep(2000) await sleep(2000)
...@@ -232,9 +233,9 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -232,9 +233,9 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
expect(FormInfo.FormType.JS).assertEqual(formInfo.type) expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect('card_b').assertEqual(formInfo.jsComponentName) expect('card_b').assertEqual(formInfo.jsComponentName)
expect(FormInfo.ColorMode.MODE_AUTO).assertEqual(formInfo.colorMode) expect(FormInfo.ColorMode.MODE_AUTO).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault) expect(formInfo.isDefault).assertTrue()
expect(1).assertEqual(formInfo.updateEnabled) expect(formInfo.updateEnabled).assertTrue()
expect(1).assertEqual(formInfo.formVisibleNotify) expect(formInfo.formVisibleNotify).assertTrue()
expect(undefined).assertEqual(formInfo.relatedBundleName) expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("abilityb").assertEqual(formInfo.formConfigAbility) expect("abilityb").assertEqual(formInfo.formConfigAbility)
expect(3).assertEqual(formInfo.updateDuration) expect(3).assertEqual(formInfo.updateDuration)
...@@ -242,8 +243,8 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -242,8 +243,8 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
expect('10:30').assertEqual(formInfo.scheduledUpdateTime) expect('10:30').assertEqual(formInfo.scheduledUpdateTime)
expect(1).assertEqual(formInfo.supportDimensions[0]) expect(1).assertEqual(formInfo.supportDimensions[0])
expect(2).assertEqual(formInfo.supportDimensions[1]) expect(2).assertEqual(formInfo.supportDimensions[1])
expect('originWidgetNameB').assertEqual(formInfo.metaData.customizeData[0].name) expect('originWidgetNameB').assertEqual(formInfo.customizeData[0].name)
expect('valueB').assertEqual(formInfo.metaData.customizeData[0].value) expect('valueB').assertEqual(formInfo.customizeData[0].value)
} }
/** /**
...@@ -283,6 +284,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -283,6 +284,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
console.log(`${promiseName3} getFormsInfo data: ${JSON.stringify(data)}`); console.log(`${promiseName3} getFormsInfo data: ${JSON.stringify(data)}`);
console.log(`${promiseName3} should not reach here`); console.log(`${promiseName3} should not reach here`);
expect().assertFail(); expect().assertFail();
done();
} catch (error) { } catch (error) {
console.log(`${promiseName3} exception caught: ${JSON.stringify(error)})`); console.log(`${promiseName3} exception caught: ${JSON.stringify(error)})`);
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE); expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
...@@ -312,6 +314,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -312,6 +314,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
console.log(`${callbackName4} exception caught: ${JSON.stringify(error)})`); console.log(`${callbackName4} exception caught: ${JSON.stringify(error)})`);
console.log(`${callbackName4} should not reach here`); console.log(`${callbackName4} should not reach here`);
expect().assertFail(); expect().assertFail();
done();
} }
}); });
...@@ -328,6 +331,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -328,6 +331,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
console.log(`${promiseName4} getFormsInfo data: ${JSON.stringify(data)}`); console.log(`${promiseName4} getFormsInfo data: ${JSON.stringify(data)}`);
console.log(`${promiseName4} should not reach here`); console.log(`${promiseName4} should not reach here`);
expect().assertFail(); expect().assertFail();
done();
} catch (error) { } catch (error) {
console.log(`${promiseName4} exception caught: ${JSON.stringify(error)})`); console.log(`${promiseName4} exception caught: ${JSON.stringify(error)})`);
expect(error.code).assertEqual(ERR_GET_BUNDLE_FAILED_CODE); expect(error.code).assertEqual(ERR_GET_BUNDLE_FAILED_CODE);
...@@ -357,6 +361,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -357,6 +361,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
console.log(`${callbackName5} exception caught: ${JSON.stringify(error)})`); console.log(`${callbackName5} exception caught: ${JSON.stringify(error)})`);
console.log(`${callbackName5} should not reach here`); console.log(`${callbackName5} should not reach here`);
expect().assertFail(); expect().assertFail();
done();
} }
}); });
...@@ -373,6 +378,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -373,6 +378,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
console.log(`${promiseName5} getFormsInfo data: ${JSON.stringify(data)}`); console.log(`${promiseName5} getFormsInfo data: ${JSON.stringify(data)}`);
console.log(`${promiseName5} should not reach here`); console.log(`${promiseName5} should not reach here`);
expect().assertFail(); expect().assertFail();
done();
} catch (error) { } catch (error) {
console.log(`${promiseName5} exception caught: ${JSON.stringify(error)})`); console.log(`${promiseName5} exception caught: ${JSON.stringify(error)})`);
expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE); expect(error.code).assertEqual(ERR_ADD_INVALID_PARAM_CODE);
...@@ -403,6 +409,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -403,6 +409,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
console.log(`${callbackName6} exception caught: ${JSON.stringify(error)})`); console.log(`${callbackName6} exception caught: ${JSON.stringify(error)})`);
console.log(`${callbackName6} should not reach here`); console.log(`${callbackName6} should not reach here`);
expect().assertFail(); expect().assertFail();
done();
} }
}); });
...@@ -424,6 +431,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -424,6 +431,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
console.log(`${promiseName6} exception caught: ${JSON.stringify(error)})`); console.log(`${promiseName6} exception caught: ${JSON.stringify(error)})`);
console.log(`${promiseName6} should not reach here`); console.log(`${promiseName6} should not reach here`);
expect().assertFail(); expect().assertFail();
done();
} }
}); });
...@@ -460,6 +468,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -460,6 +468,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
console.log(`${callbackName7} exception caught: ${JSON.stringify(error)})`); console.log(`${callbackName7} exception caught: ${JSON.stringify(error)})`);
console.log(`${callbackName7} should not reach here`); console.log(`${callbackName7} should not reach here`);
expect().assertFail(); expect().assertFail();
done();
} }
}); });
...@@ -492,6 +501,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -492,6 +501,7 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
console.log(`${promiseName7} exception caught: ${JSON.stringify(error)})`); console.log(`${promiseName7} exception caught: ${JSON.stringify(error)})`);
console.log(`${promiseName7} should not reach here`); console.log(`${promiseName7} should not reach here`);
expect().assertFail(); expect().assertFail();
done();
} }
}); });
...@@ -504,17 +514,17 @@ export const getFormsInfoTest = (describeName, filterParameter) => { ...@@ -504,17 +514,17 @@ export const getFormsInfoTest = (describeName, filterParameter) => {
expect(FormInfo.FormType.JS).assertEqual(formInfo.type) expect(FormInfo.FormType.JS).assertEqual(formInfo.type)
expect('card_c').assertEqual(formInfo.jsComponentName) expect('card_c').assertEqual(formInfo.jsComponentName)
expect(FormInfo.ColorMode.MODE_LIGHT).assertEqual(formInfo.colorMode) expect(FormInfo.ColorMode.MODE_LIGHT).assertEqual(formInfo.colorMode)
expect(1).assertEqual(formInfo.isDefault) expect(formInfo.isDefault).assertTrue()
expect(1).assertEqual(formInfo.updateEnabled) expect(formInfo.updateEnabled).assertTrue()
expect(1).assertEqual(formInfo.formVisibleNotify) expect(formInfo.formVisibleNotify).assertTrue()
expect(undefined).assertEqual(formInfo.relatedBundleName) expect(undefined).assertEqual(formInfo.relatedBundleName)
expect("abilityc").assertEqual(formInfo.formConfigAbility) expect("abilityc").assertEqual(formInfo.formConfigAbility)
expect(4).assertEqual(formInfo.updateDuration) expect(4).assertEqual(formInfo.updateDuration)
expect(3).assertEqual(formInfo.defaultDimension) expect(3).assertEqual(formInfo.defaultDimension)
expect(3).assertEqual(formInfo.supportDimensions[0]) expect(3).assertEqual(formInfo.supportDimensions[0])
expect(4).assertEqual(formInfo.supportDimensions[1]) expect(4).assertEqual(formInfo.supportDimensions[1])
expect('originWidgetNameC').assertEqual(formInfo.metaData.customizeData[0].name) expect('originWidgetNameC').assertEqual(formInfo.customizeData[0].name)
expect('valueC').assertEqual(formInfo.metaData.customizeData[0].value) expect('valueC').assertEqual(formInfo.customizeData[0].value)
} }
}); });
}; };
...@@ -31,7 +31,9 @@ var deleteForm_Event = "FMS_FormDelete_commonEvent"; ...@@ -31,7 +31,9 @@ var deleteForm_Event = "FMS_FormDelete_commonEvent";
var subscriberOnAcquired; var subscriberOnAcquired;
var subscriberOnDeleted; var subscriberOnDeleted;
var subscriberOnReleased; var subscriberOnReleased;
function sleep(time) {
return new Promise((resolve)=>setTimeout(resolve,time));
}
export default function test() { export default function test() {
describe(`FmsReleaseFormTest`, () => { describe(`FmsReleaseFormTest`, () => {
...@@ -437,12 +439,12 @@ export default function test() { ...@@ -437,12 +439,12 @@ export default function test() {
} }
} }
} }
function releaseForms() { async function releaseForms() {
console.debug("====>FMS_releaseForm_1300 releaseForms====>"); console.debug("====>FMS_releaseForm_1300 releaseForms====>");
commonEvent.subscribe(subscriberOnReleased, onReleasedCallBack); commonEvent.subscribe(subscriberOnReleased, onReleasedCallBack);
for(var iIndex = 0; iIndex < formIdList.length; iIndex++) { for(var iIndex = 0; iIndex < formIdList.length; iIndex++) {
console.log(`FMS_releaseForm_1300 featureAbility.startAbility start`); console.log(`FMS_releaseForm_1300 featureAbility.startAbility start`);
featureAbility.startAbility({ await featureAbility.startAbility({
want: { want: {
bundleName: "com.ohos.st.formsystemhostc", bundleName: "com.ohos.st.formsystemhostc",
abilityName: "com.ohos.st.formsystemhostc.MainAbility", abilityName: "com.ohos.st.formsystemhostc.MainAbility",
...@@ -465,6 +467,7 @@ export default function test() { ...@@ -465,6 +467,7 @@ export default function test() {
expect().assertFail(); expect().assertFail();
done(); done();
}); });
await sleep(1000)
console.log(`FMS_releaseForm_1300 featureAbility.startAbility end`); console.log(`FMS_releaseForm_1300 featureAbility.startAbility end`);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册