提交 509c4202 编写于 作者: Y yangzk

IssueNo: #I5XGT5

Description: SDK元能力接口覆盖
Sig: SIG_ApplicationFramework
Feature or Bugfix: Feature
Binary Source: No
Signed-off-by: Nyangzk <yangzhongkai@huawei.com>
Change-Id: I2aa61ac37f6e27cd6fcbc2e07f794f56bcba9092
上级 bbacf6b9
......@@ -16,6 +16,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import formProvider from '@ohos.application.formProvider';
import FormInfo from '@ohos.application.formInfo';
import formInfoNew from '@ohos.app.form.formInfo';
import formError from '@ohos.application.formError';
import formHost from '@ohos.application.formHost';
import errorManager from '@ohos.application.errorManager';
......@@ -23,10 +24,13 @@ import abilityConstant from '@ohos.application.AbilityConstant'
import appManager from '@ohos.application.appManager'
import applicationContext from '@ohos.application.context'
import commonEvent from '@ohos.commonEvent';
import ability from '@ohos.ability.ability'
import ability from '@ohos.ability.ability';
import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
var EXTENSION_INFO_ERR = 16000001
var INNER_ERROR = 16000050
var CROSS_USER_DENY = 201
var INVALID_PARAM = 401
var trueInfo;
var array = new Array();
function sleep(time) {
......@@ -226,6 +230,120 @@ export default function ApiCoverTest() {
})
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_009
* @tc.name connectServiceExtensionAbility with invalid want.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_009', 0, async function (done) {
console.log(`SUB_AA_ABILITY_Extension_API_009 start`);
let want = {
bundleName: "com.example.extensionapitest1",
abilityName: "FirstExtension"
};
let options = {
onConnect: function (elementName, proxy) {
console.log("onConnect");
},
onDisconnect: function () {
console.log("onDisconnect");
},
onFailed: function () {
console.log("onFailed");
}
}
try {
let id = globalThis.abilityContext.connectServiceExtensionAbility(want, options);
console.log(`connectServiceExtensionAbility id: ${id}`);
} catch (err) {
console.log(`connectServiceExtensionAbility catch code: ${err.code}, message: ${err.message}`);
expect().assertFail();
}
done();
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_010
* @tc.name disconnectServiceExtensionAbility with invalid connectionId.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_010', 0, async function (done) {
console.log(`SUB_AA_ABILITY_Extension_API_010 start`);
try {
globalThis.abilityContext.disconnectServiceExtensionAbility(undefined, (err, data) => {
console.log(`disconnectServiceExtensionAbility, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`);
expect(err.code).assertEqual(INNER_ERROR);
done();
})
} catch (err) {
console.log(`disconnectServiceExtensionAbility catch code: ${err.code}, message: ${err.message}`);
expect().assertFail();
done();
}
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_011
* @tc.name disconnectServiceExtensionAbility with invalid connectionId.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_011', 0, async function (done) {
console.log(`SUB_AA_ABILITY_Extension_API_011 start`);
try {
globalThis.abilityContext.disconnectServiceExtensionAbility(undefined).then((err, data) => {
console.log(`disconnectServiceExtensionAbility, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`);
expect(err.code).assertEqual(INNER_ERROR);
});
} catch (err) {
console.log(`disconnectServiceExtensionAbility catch code: ${err.code}, message: ${err.message}`);
expect().assertFail();
}
done();
})
/*
* @tc.number SUB_AA_ABILITY_Extension_API_012
* @tc.name killProcessesBySelf with invalid param.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_ABILITY_Extension_API_012', 0, async function (done) {
try {
globalThis.abilityContext.getApplicationContext().killProcessesBySelf();
globalThis.abilityContext.getApplicationContext().killProcessesBySelf((err, data) => {
console.log(`killProcessesBySelf, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`);
})
let abilityDelegator: abilityDelegatorRegistry.AbilityDelegator;
abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
let abilityDelegatorArgs: abilityDelegatorRegistry.AbilityDelegatorArgs;
abilityDelegatorArgs = abilityDelegatorRegistry.getArguments();
let abilityMonitor: abilityDelegatorRegistry.AbilityMonitor = {
abilityName: "FirstExtension"
}
abilityDelegator.addAbilityMonitor(abilityMonitor, (err, data) => {
console.log(`printMsg, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`);
})
abilityDelegator.printMsg(undefined);
abilityDelegator.printMsg(undefined, (err, data) => {
console.log(`printMsg, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`);
});
let shellCmdResult: abilityDelegatorRegistry.ShellCmdResult;
shellCmdResult = await abilityDelegator.executeShellCmd(undefined);
abilityDelegator.executeShellCmd(undefined, 0, (err, data) => {
console.log(`executeShellCmd, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`);
});
abilityDelegator.executeShellCmd(undefined, (err, data) => {
console.log(`executeShellCmd, err: ${JSON.stringify(err)}, data: ${JSON.stringify(data)}`);
});
} catch (err) {
console.log(`catch code: ${err.code}, message: ${err.message}`);
}
done();
})
/*
* @tc.number SUB_AA_AMS_Context_0100
* @tc.name Get the resource and path of the context.
......@@ -345,6 +463,52 @@ export default function ApiCoverTest() {
expect(3).assertEqual(FormInfo.FormDimension.Dimension_2_4)
expect(4).assertEqual(FormInfo.FormDimension.Dimension_4_4)
expect(5).assertEqual(FormInfo.FormDimension.Dimension_2_1)
expect(1).assertEqual(FormInfo.FormType.JS);
expect(2).assertEqual(FormInfo.FormType.eTS);
expect(1).assertEqual(FormInfo.VisibilityType.FORM_VISIBLE);
expect(2).assertEqual(FormInfo.VisibilityType.FORM_INVISIBLE);
done();
});
/*
* @tc.number SUB_AA_Form_provider_TestFormInfo_0200
* @tc.name Get all FormInfo types
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_Form_provider_TestFormInfo_0200', 0, async function (done) {
console.info("SUB_AA_Form_provider_TestFormInfo_0200");
expect("ohos.extra.param.key.form_dimension").assertEqual(formInfoNew.FormParam.DIMENSION_KEY)
expect("ohos.extra.param.key.form_height").assertEqual(formInfoNew.FormParam.HEIGHT_KEY)
expect("ohos.extra.param.key.module_name").assertEqual(formInfoNew.FormParam.MODULE_NAME_KEY)
expect("ohos.extra.param.key.form_width").assertEqual(formInfoNew.FormParam.WIDTH_KEY)
expect("ohos.extra.param.key.form_name").assertEqual(formInfoNew.FormParam.NAME_KEY)
expect("ohos.extra.param.key.form_temporary").assertEqual(formInfoNew.FormParam.TEMPORARY_KEY)
expect("ohos.extra.param.key.form_identity").assertEqual(formInfoNew.FormParam.IDENTITY_KEY)
expect("ohos.extra.param.key.bundle_name").assertEqual(formInfoNew.FormParam.BUNDLE_NAME_KEY)
expect("ohos.extra.param.key.ability_name").assertEqual(formInfoNew.FormParam.ABILITY_NAME_KEY)
expect(0).assertEqual(formInfoNew.FormState.DEFAULT)
expect(1).assertEqual(formInfoNew.FormState.READY)
expect(-1).assertEqual(formInfoNew.FormState.UNKNOWN)
expect(0).assertEqual(formInfoNew.ColorMode.MODE_DARK)
expect(1).assertEqual(formInfoNew.ColorMode.MODE_LIGHT)
console.info("SUB_AA_Form_provider_TestFormInfo_0200:" + formInfoNew.FormDimension.Dimension_2_1);
expect(1).assertEqual(formInfoNew.FormDimension.Dimension_1_2)
expect(2).assertEqual(formInfoNew.FormDimension.Dimension_2_2)
expect(3).assertEqual(formInfoNew.FormDimension.Dimension_2_4)
expect(4).assertEqual(formInfoNew.FormDimension.Dimension_4_4)
expect(5).assertEqual(formInfoNew.FormDimension.Dimension_2_1)
expect(1).assertEqual(formInfoNew.FormType.JS);
expect(2).assertEqual(formInfoNew.FormType.eTS);
expect(1).assertEqual(formInfoNew.VisibilityType.FORM_VISIBLE);
expect(2).assertEqual(formInfoNew.VisibilityType.FORM_INVISIBLE);
let formStateInfo: formInfoNew.FormStateInfo = {
formState: formInfoNew.FormState.READY,
want: {
bundleName: "com.example.extensionapitest",
abilityName: "FirstExtension"
}
}
done();
});
......
import AbilityStage from "@ohos.application.AbilityStage"
import AbilityStage from "@ohos.app.ability.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageContext = this.context;
}
onAcceptWant(want) {
console.log("[Demo] MyAbilityStage onAcceptWant called want:" + JSON.stringify(want));
let abilityId = want.parameters.startId.toString();
return abilityId;
}
onConfigurationUpdate(configuration) {
console.log('[Demo] MyAbilityStage onConfigurationUpdate:' + JSON.stringify(configuration));
}
}
\ No newline at end of file
import FormExtension from '@ohos.application.FormExtension';
import formBindingData from '@ohos.application.formBindingData';
import formInfo from '@ohos.application.formInfo';
import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility';
import formBindingData from '@ohos.app.form.formBindingData';
import formInfo from '@ohos.app.form.formInfo';
export default class FormModuleAbility extends FormExtension {
onCreate(want) {
export default class FormModuleAbility extends FormExtensionAbility {
onAddForm(want) {
// Called to return a FormBindingData object.
console.info("FormAbility onCreate")
console.info("FormAbility onAddForm")
globalThis.abilityContext = this.context;
let formData = {
};
return formBindingData.createFormBindingData(formData);
}
onCastToNormal(formId) {
onCastToNormalForm(formId) {
// Called when the form provider is notified that a temporary form is successfully
// converted to a normal form.
}
onUpdate(formId) {
onUpdateForm(formId) {
// Called to notify the form provider to update a specified form.
}
onVisibilityChange(newStatus) {
onChangeFormVisibility(newStatus) {
// Called when the form provider receives form events from the system.
}
onEvent(formId, message) {
onFormEvent(formId, message) {
// Called when a specified message event defined by the form provider is triggered.
}
onDestroy(formId) {
onRemoveForm(formId) {
// Called to notify the form provider that a specified form has been destroyed.
}
onConfigurationUpdate(configuration) {
console.log('FormAbility onConfigurationUpdate:' + JSON.stringify(configuration));
}
onAcquireFormState(want) {
// Called to return a {@link FormState} object.
return formInfo.FormState.READY;
}
onShareForm(formId) {
console.log('FormAbility onShareForm:' + JSON.stringify(formId));
return {};
}
};
\ No newline at end of file
import Ability from '@ohos.application.Ability'
import Ability from '@ohos.app.ability.Ability'
import AbilityConstant
from "../../../../../../../../../../../../interface/sdk-js/api/@ohos.app.ability.AbilityConstant";
export default class ModuleAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
globalThis.abilityCallee = this.callee;
}
onDestroy() {
......@@ -22,6 +26,10 @@ export default class ModuleAbility extends Ability {
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onWindowStageRestore(windowStage) {
console.log("[Demo] MainAbility onWindowStageRestore")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
......@@ -31,4 +39,19 @@ export default class ModuleAbility extends Ability {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
onContinue(wantParam) {
console.log("[Demo] MainAbility onContinue")
return AbilityConstant.OnContinueResult.AGREE;
}
onConfigurationUpdate(configuration) {
console.log('[Demo] MainAbility onConfigurationUpdate: ' + JSON.stringify(configuration));
}
onDump(param) {
console.log("[Demo] MainAbility onDump: " + JSON.stringify(param))
return ["MainAbility"]
}
};
......@@ -14,6 +14,7 @@
*/
import featureAbility from '@ohos.ability.featureAbility'
import wantconstant from '@ohos.ability.wantConstant'
import wantConstantNew from '@ohos.app.ability.wantConstant'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import commonEvent from '@ohos.commonEvent'
import particleAbility from '@ohos.ability.particleAbility'
......@@ -152,6 +153,48 @@ describe('ActsFeatureAbilityTest', function () {
done();
})
/**
* @tc.number: ACTS_wantConstant_0200
* @tc.name: wantConstant : Check specific enum
* @tc.desc: Check the return type of the interface (by Promise)
*/
it('ACTS_wantConstant_0200', 0, async function (done) {
expect(wantConstantNew.Action.ACTION_HOME).assertEqual("ohos.want.action.home");
expect(wantConstantNew.Action.ACTION_DIAL).assertEqual("ohos.want.action.dial");
expect(wantConstantNew.Action.ACTION_SEARCH).assertEqual("ohos.want.action.search");
expect(wantConstantNew.Action.ACTION_WIRELESS_SETTINGS).assertEqual("ohos.settings.wireless");
expect(wantConstantNew.Action.ACTION_MANAGE_APPLICATIONS_SETTINGS)
.assertEqual("ohos.settings.manage.applications");
expect(wantConstantNew.Action.ACTION_APPLICATION_DETAILS_SETTINGS)
.assertEqual("ohos.settings.application.details");
expect(wantConstantNew.Action.ACTION_SET_ALARM).assertEqual("ohos.want.action.setAlarm");
expect(wantConstantNew.Action.ACTION_SHOW_ALARMS).assertEqual("ohos.want.action.showAlarms");
expect(wantConstantNew.Action.ACTION_SNOOZE_ALARM).assertEqual("ohos.want.action.snoozeAlarm");
expect(wantConstantNew.Action.ACTION_DISMISS_ALARM).assertEqual("ohos.want.action.dismissAlarm");
expect(wantConstantNew.Action.ACTION_DISMISS_TIMER).assertEqual("ohos.want.action.dismissTimer");
expect(wantConstantNew.Action.ACTION_SEND_SMS).assertEqual("ohos.want.action.sendSms");
expect(wantConstantNew.Action.ACTION_CHOOSE).assertEqual("ohos.want.action.choose");
expect(wantConstantNew.Action.ACTION_SELECT).assertEqual("ohos.want.action.select");
expect(wantConstantNew.Action.ACTION_SEND_DATA).assertEqual("ohos.want.action.sendData");
expect(wantConstantNew.Action.ACTION_SEND_MULTIPLE_DATA).assertEqual("ohos.want.action.sendMultipleData");
expect(wantConstantNew.Action.ACTION_SCAN_MEDIA_FILE).assertEqual("ohos.want.action.scanMediaFile");
expect(wantConstantNew.Action.ACTION_VIEW_DATA).assertEqual("ohos.want.action.viewData");
expect(wantConstantNew.Action.ACTION_EDIT_DATA).assertEqual("ohos.want.action.editData");
expect(wantConstantNew.Action.INTENT_PARAMS_INTENT).assertEqual("ability.want.params.INTENT");
expect(wantConstantNew.Action.INTENT_PARAMS_TITLE).assertEqual("ability.want.params.TITLE");
expect(wantConstantNew.Action.ACTION_FILE_SELECT).assertEqual("ohos.action.fileSelect");
expect(wantConstantNew.Action.PARAMS_STREAM).assertEqual("ability.params.stream");
expect(wantConstantNew.Action.ACTION_APP_ACCOUNT_AUTH).assertEqual("account.appAccount.action.auth");
expect(wantConstantNew.Entity.ENTITY_HOME).assertEqual("entity.system.home");
expect(wantConstantNew.Entity.ENTITY_DEFAULT).assertEqual("entity.system.default");
expect(wantConstantNew.Entity.ENTITY_VOICE).assertEqual("entity.system.voice");
expect(wantConstantNew.Entity.ENTITY_BROWSABLE).assertEqual("entity.system.browsable");
expect(wantConstantNew.Entity.ENTITY_VIDEO).assertEqual("entity.system.video");
done();
})
/**
* @tc.number: ACTS_GetContext_0100
* @tc.name: GetContext : Obtains the Context object
......
......@@ -13,6 +13,8 @@
* limitations under the License.
*/
import ActsNotificationWantAgentTest from './ActsNotificationWantAgentTest.js'
import ActsNotificationWantAgentNewTest from './ActsNotificationWantAgentNewTest.js'
export default function testsuite() {
ActsNotificationWantAgentTest()
ActsNotificationWantAgentNewTest()
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册