提交 2ff62d5f 编写于 作者: H HuangXW

fixed a5da8324 from https://gitee.com/H-xinwei/xts_acts/pulls/5927

错误码整改适配

Change-Id: Ia75b1cbeca2c2a49512f2bcb4e111dd1397d0399
Signed-off-by: NHuangXW <huangxinwei4@huawei.com>
上级 1832dbdb
...@@ -47,6 +47,14 @@ var subscriberInfo = { ...@@ -47,6 +47,14 @@ var subscriberInfo = {
var caseDepBundles = []; var caseDepBundles = [];
var subscriber = null; var subscriber = null;
const ERROR_CODE_INVALID_PARAM = 401;
const ERROR_CODE_CALLER_RELEASED = 16200001;
const ERROR_CODE_CLAAEE_INVALID = 16200002;
const ERROR_CODE_FUNC_REGISTERED = 16200004;
const ERROR_CODE_FUNC_NOT_EXIST = 16200005;
const ERROR_CODE_INNER_ERROR = 16000050;
const ERROR_CODE_TYPE_ERROR = 16000002;
class MySequenceable { class MySequenceable {
num: number = 0; num: number = 0;
str: String = "default"; str: String = "default";
...@@ -588,19 +596,21 @@ export default function abilityTest() { ...@@ -588,19 +596,21 @@ export default function abilityTest() {
*/ */
it('ACTS_CommonComponent_Call_1700', 0, async function (done) { it('ACTS_CommonComponent_Call_1700', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_1700 begin'); console.log('ACTS_CommonComponent_Call_1700 begin');
var caller;
var exceptionFlag = false; var exceptionFlag = false;
try { await globalThis.globalThis.abilityContext.startAbilityByCall({
caller = await globalThis.globalThis.abilityContext.startAbilityByCall({ bundleName: systemAppCalleeABundleName,
bundleName: systemAppCalleeABundleName, abilityName: systemAppCalleeAThirdAbilityName,
abilityName: systemAppCalleeAThirdAbilityName, }).then(data => {
}); expect().assertFail();
} catch(err) { done();
console.log('ACTS_CommonComponent_Call_1700 exception' + err); }).catch(err => {
console.log('ACTS_CommonComponent_Call_1700 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_TYPE_ERROR);
exceptionFlag = true; exceptionFlag = true;
expect(err.message).assertEqual("function request remote error"); });
}
expect(exceptionFlag).assertEqual(true); expect(exceptionFlag).assertEqual(true);
done(); done();
}) })
...@@ -655,8 +665,9 @@ export default function abilityTest() { ...@@ -655,8 +665,9 @@ export default function abilityTest() {
try { try {
globalThis.callee.on('', onTest); globalThis.callee.on('', onTest);
} catch (err) { } catch (err) {
console.log('ACTS_CommonComponent_Call_3100 callee.on err' + err); console.log('ACTS_CommonComponent_Call_3100 call err.code: ' + JSON.stringify(err.code) +
expect(err.message).assertEqual("function input parameter error"); ' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1; finishFlag = 1;
} }
...@@ -680,8 +691,9 @@ export default function abilityTest() { ...@@ -680,8 +691,9 @@ export default function abilityTest() {
try { try {
globalThis.callee.on(null, onTest); globalThis.callee.on(null, onTest);
} catch (err) { } catch (err) {
console.log('ACTS_CommonComponent_Call_3200 callee.on err' + err); console.log('ACTS_CommonComponent_Call_3200 call err.code: ' + JSON.stringify(err.code) +
expect(err.message).assertEqual("function input parameter error"); ' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1; finishFlag = 1;
} }
...@@ -705,8 +717,9 @@ export default function abilityTest() { ...@@ -705,8 +717,9 @@ export default function abilityTest() {
try { try {
globalThis.callee.on(undefined, onTest); globalThis.callee.on(undefined, onTest);
} catch (err) { } catch (err) {
console.log('ACTS_CommonComponent_Call_3300 callee.on err' + err); console.log('ACTS_CommonComponent_Call_3300 call err.code: ' + JSON.stringify(err.code) +
expect(err.message).assertEqual("function input parameter error"); ' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1; finishFlag = 1;
} }
...@@ -726,8 +739,9 @@ export default function abilityTest() { ...@@ -726,8 +739,9 @@ export default function abilityTest() {
try { try {
globalThis.callee.off(''); globalThis.callee.off('');
} catch (err) { } catch (err) {
console.log('ACTS_CommonComponent_Call_3400 callee.off err' + err); console.log('ACTS_CommonComponent_Call_3400 call err.code: ' + JSON.stringify(err.code) +
expect(err.message).assertEqual("function input parameter error"); ' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1; finishFlag = 1;
} }
...@@ -747,8 +761,9 @@ export default function abilityTest() { ...@@ -747,8 +761,9 @@ export default function abilityTest() {
try { try {
globalThis.callee.off(null); globalThis.callee.off(null);
} catch (err) { } catch (err) {
console.log('ACTS_CommonComponent_Call_3500 callee.off err' + err); console.log('ACTS_CommonComponent_Call_3500 call err.code: ' + JSON.stringify(err.code) +
expect(err.message).assertEqual("function input parameter error"); ' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1; finishFlag = 1;
} }
...@@ -768,8 +783,9 @@ export default function abilityTest() { ...@@ -768,8 +783,9 @@ export default function abilityTest() {
try { try {
globalThis.callee.off(undefined); globalThis.callee.off(undefined);
} catch (err) { } catch (err) {
console.log('ACTS_CommonComponent_Call_3600 callee.off err' + err); console.log('ACTS_CommonComponent_Call_3600 call err.code: ' + JSON.stringify(err.code) +
expect(err.message).assertEqual("function input parameter error"); ' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1; finishFlag = 1;
} }
...@@ -788,8 +804,9 @@ export default function abilityTest() { ...@@ -788,8 +804,9 @@ export default function abilityTest() {
try { try {
globalThis.callee.on('testCall', ""); globalThis.callee.on('testCall', "");
} catch (err) { } catch (err) {
console.log('ACTS_CommonComponent_Call_4300 call err' + err); console.log('ACTS_CommonComponent_Call_4300 call err.code: ' + JSON.stringify(err.code) +
expect(err.message).assertEqual("function input parameter error"); ' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1; finishFlag = 1;
} }
...@@ -808,8 +825,9 @@ export default function abilityTest() { ...@@ -808,8 +825,9 @@ export default function abilityTest() {
try { try {
globalThis.callee.on('testCall', null); globalThis.callee.on('testCall', null);
} catch (err) { } catch (err) {
console.log('ACTS_CommonComponent_Call_4400 call err' + err); console.log('ACTS_CommonComponent_Call_4400 call err.code: ' + JSON.stringify(err.code) +
expect(err.message).assertEqual("function input parameter error"); ' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1; finishFlag = 1;
} }
...@@ -828,8 +846,9 @@ export default function abilityTest() { ...@@ -828,8 +846,9 @@ export default function abilityTest() {
try { try {
globalThis.callee.on('testCall', undefined); globalThis.callee.on('testCall', undefined);
} catch (err) { } catch (err) {
console.log('ACTS_CommonComponent_Call_4500 call err' + err); console.log('ACTS_CommonComponent_Call_4500 call err.code: ' + JSON.stringify(err.code) +
expect(err.message).assertEqual("function input parameter error"); ' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1; finishFlag = 1;
} }
...@@ -861,8 +880,9 @@ export default function abilityTest() { ...@@ -861,8 +880,9 @@ export default function abilityTest() {
try { try {
globalThis.callee.on('ACTS_CommonComponent_Call_5000', testCallback_5100); globalThis.callee.on('ACTS_CommonComponent_Call_5000', testCallback_5100);
} catch (err) { } catch (err) {
console.log('ACTS_CommonComponent_Call_5000 call err' + err); console.log('ACTS_CommonComponent_Call_5000 call err.code: ' + JSON.stringify(err.code) +
expect(err.message).assertEqual("function is registered"); ' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_FUNC_REGISTERED);
finishFlag = 1; finishFlag = 1;
} }
...@@ -897,8 +917,9 @@ export default function abilityTest() { ...@@ -897,8 +917,9 @@ export default function abilityTest() {
try { try {
globalThis.callee.off('ACTS_CommonComponent_Call_5100'); globalThis.callee.off('ACTS_CommonComponent_Call_5100');
} catch (err) { } catch (err) {
console.log('ACTS_CommonComponent_Call_5100 call err' + err); console.log('ACTS_CommonComponent_Call_5100 call err.code: ' + JSON.stringify(err.code) +
expect(err.message).assertEqual("function not registered"); ' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_FUNC_NOT_EXIST);
finishFlag = 1; finishFlag = 1;
} }
...@@ -914,17 +935,19 @@ export default function abilityTest() { ...@@ -914,17 +935,19 @@ export default function abilityTest() {
*/ */
it('ACTS_CommonComponent_Call_5200', 0, async function (done) { it('ACTS_CommonComponent_Call_5200', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5200 begin'); console.log('ACTS_CommonComponent_Call_5200 begin');
let caller;
let exceptionFlag = false; let exceptionFlag = false;
try {
caller = await globalThis.globalThis.abilityContext.startAbilityByCall(null); await globalThis.globalThis.abilityContext.startAbilityByCall(null)
console.log('ACTS_CommonComponent_Call_5200 startAbilityByCall' + JSON.stringify(caller)) .then(data => {
} catch(err) { expect().assertFail();
console.log('ACTS_CommonComponent_Call_5200 exception' + err); done();
exceptionFlag = true; }).catch(err => {
expect(err.message).assertEqual("function input parameter error"); console.log('ACTS_CommonComponent_Call_5200 call err.code: ' + JSON.stringify(err.code) +
} ' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
exceptionFlag = true;
});
expect(exceptionFlag).assertEqual(true); expect(exceptionFlag).assertEqual(true);
done(); done();
...@@ -937,20 +960,20 @@ export default function abilityTest() { ...@@ -937,20 +960,20 @@ export default function abilityTest() {
*/ */
it('ACTS_CommonComponent_Call_5300', 0, async function (done) { it('ACTS_CommonComponent_Call_5300', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5300 begin'); console.log('ACTS_CommonComponent_Call_5300 begin');
let caller;
let exceptionFlag = false; let exceptionFlag = false;
try { await globalThis.globalThis.abilityContext.startAbilityByCall({
caller = await globalThis.globalThis.abilityContext.startAbilityByCall({ bundleName: "",
bundleName: "", abilityName: "",
abilityName: "", }).then(data => {
}); expect().assertFail();
console.log('ACTS_CommonComponent_Call_5300 startAbilityByCall' + JSON.stringify(caller)) done();
} catch(err) { }).catch(err => {
console.log('ACTS_CommonComponent_Call_5300 exception' + err); console.log('ACTS_CommonComponent_Call_5300 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INNER_ERROR);
exceptionFlag = true; exceptionFlag = true;
expect(err.message).assertEqual("function request remote error"); });
}
expect(exceptionFlag).assertEqual(true); expect(exceptionFlag).assertEqual(true);
done(); done();
...@@ -963,17 +986,18 @@ export default function abilityTest() { ...@@ -963,17 +986,18 @@ export default function abilityTest() {
*/ */
it('ACTS_CommonComponent_Call_5400', 0, async function (done) { it('ACTS_CommonComponent_Call_5400', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5400 begin'); console.log('ACTS_CommonComponent_Call_5400 begin');
let caller;
let exceptionFlag = false; let exceptionFlag = false;
try { await globalThis.globalThis.abilityContext.startAbilityByCall(undefined)
caller = await globalThis.globalThis.abilityContext.startAbilityByCall(undefined); .then(data => {
console.log('ACTS_CommonComponent_Call_5400 startAbilityByCall' + JSON.stringify(caller)) expect().assertFail();
} catch(err) { done();
console.log('ACTS_CommonComponent_Call_5400 exception' + err); }).catch(err => {
console.log('ACTS_CommonComponent_Call_5400 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
exceptionFlag = true; exceptionFlag = true;
expect(err.message).assertEqual("function input parameter error"); });
}
expect(exceptionFlag).assertEqual(true); expect(exceptionFlag).assertEqual(true);
done(); done();
......
...@@ -24,9 +24,9 @@ import appManager from '@ohos.application.appManager' ...@@ -24,9 +24,9 @@ import appManager from '@ohos.application.appManager'
import applicationContext from '@ohos.application.context' import applicationContext from '@ohos.application.context'
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import ability from '@ohos.ability.ability' import ability from '@ohos.ability.ability'
FormDimension
var EXTENSION_INFO_ERR = 2097152 var EXTENSION_INFO_ERR = 16000001
var USERID_ERR = 2097177 var CROSS_USER_DENY = 201
var trueInfo; var trueInfo;
var array = new Array(); var array = new Array();
function sleep(time) { function sleep(time) {
...@@ -102,7 +102,7 @@ export default function ApiCoverTest() { ...@@ -102,7 +102,7 @@ export default function ApiCoverTest() {
expect("case execute failed").assertEqual("data"); expect("case execute failed").assertEqual("data");
}).catch((error) => { }).catch((error) => {
console.error(`Ability: startServiceExtensionAbilityWithAccount failed: ${JSON.stringify(error)}`); console.error(`Ability: startServiceExtensionAbilityWithAccount failed: ${JSON.stringify(error)}`);
expect(USERID_ERR).assertEqual(error.code); expect(CROSS_USER_DENY).assertEqual(error.code);
}) })
done() done()
}) })
...@@ -124,7 +124,7 @@ export default function ApiCoverTest() { ...@@ -124,7 +124,7 @@ export default function ApiCoverTest() {
expect("case execute failed").assertEqual(data); expect("case execute failed").assertEqual(data);
}).catch((error) => { }).catch((error) => {
console.error(`Ability: stopServiceExtensionAbilityWithAccount failed: ${JSON.stringify(error)}`); console.error(`Ability: stopServiceExtensionAbilityWithAccount failed: ${JSON.stringify(error)}`);
expect(USERID_ERR).assertEqual(error.code); expect(CROSS_USER_DENY).assertEqual(error.code);
}) })
done() done()
}) })
...@@ -193,7 +193,7 @@ export default function ApiCoverTest() { ...@@ -193,7 +193,7 @@ export default function ApiCoverTest() {
await globalThis.abilityContext.startServiceExtensionAbilityWithAccount(want, 999, (err, data) => { await globalThis.abilityContext.startServiceExtensionAbilityWithAccount(want, 999, (err, data) => {
if (err.code) { if (err.code) {
console.error(`Ability: startServiceExtensionAbilityWithAccount failed: ${JSON.stringify(err)}`); console.error(`Ability: startServiceExtensionAbilityWithAccount failed: ${JSON.stringify(err)}`);
expect(USERID_ERR).assertEqual(err.code); expect(CROSS_USER_DENY).assertEqual(err.code);
} else { } else {
console.log(`Ability: startServiceExtensionAbilityWithAccount success: ${JSON.stringify(data)}`); console.log(`Ability: startServiceExtensionAbilityWithAccount success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data); expect("case execute failed").assertEqual(data);
...@@ -217,7 +217,7 @@ export default function ApiCoverTest() { ...@@ -217,7 +217,7 @@ export default function ApiCoverTest() {
globalThis.abilityContext.stopServiceExtensionAbilityWithAccount(want, 999, (err, data) => { globalThis.abilityContext.stopServiceExtensionAbilityWithAccount(want, 999, (err, data) => {
if (err.code) { if (err.code) {
console.error(`Ability: stopServiceExtensionAbilityWithAccount failed: ${JSON.stringify(err)}`); console.error(`Ability: stopServiceExtensionAbilityWithAccount failed: ${JSON.stringify(err)}`);
expect(USERID_ERR).assertEqual(err.code); expect(CROSS_USER_DENY).assertEqual(err.code);
} else { } else {
console.log(`Ability: stopServiceExtensionAbilityWithAccount success: ${JSON.stringify(data)}`); console.log(`Ability: stopServiceExtensionAbilityWithAccount success: ${JSON.stringify(data)}`);
expect("case execute failed").assertEqual(data); expect("case execute failed").assertEqual(data);
......
...@@ -18,6 +18,7 @@ import AbilityConstant from "@ohos.application.AbilityConstant"; ...@@ -18,6 +18,7 @@ import AbilityConstant from "@ohos.application.AbilityConstant";
import appManager from "@ohos.application.appManager"; import appManager from "@ohos.application.appManager";
import wantConstant from '@ohos.ability.wantConstant'; import wantConstant from '@ohos.ability.wantConstant';
var INVALID_PARAM = 401
var TAG var TAG
export default function verificationTest(){ export default function verificationTest(){
...@@ -280,34 +281,34 @@ export default function verificationTest(){ ...@@ -280,34 +281,34 @@ export default function verificationTest(){
*/ */
it('SUB_AA_OpenHarmony_SetMissionLabel_0100', 0, async function(done) { it('SUB_AA_OpenHarmony_SetMissionLabel_0100', 0, async function(done) {
TAG = 'SUB_AA_OpenHarmony_SetMissionLabel_0100 ==>'; TAG = 'SUB_AA_OpenHarmony_SetMissionLabel_0100 ==>';
let label = undefined;
let code1 = 0;
let code2 = 0;
try { try {
let label = undefined await globalThis.abilityContext.setMissionLabel(label).then((data) => {
let code1 = 0
let code2 = 0
globalThis.abilityContext.setMissionLabel(label).then((data) => {
console.info(TAG + "setMissionLabel data = " + JSON.stringify(data)); console.info(TAG + "setMissionLabel data = " + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
code1 = err.code code1 = err.code
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err)); console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
}); });
} catch (err) {
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
expect(err.code).assertEqual(INVALID_PARAM);
}
globalThis.abilityContext.setMissionLabel(label, (err, data) => { try {
await globalThis.abilityContext.setMissionLabel(label, (err, data) => {
code2 = err.code code2 = err.code
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err)); console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
console.info(TAG + "setMissionLabel data = " + JSON.stringify(data)); console.info(TAG + "setMissionLabel data = " + JSON.stringify(data));
}) })
setTimeout(()=>{
expect(code1).assertEqual(-1);
expect(code2).assertEqual(-1);
done()
}, 3000)
} catch (err) { } catch (err) {
console.info(TAG + "catch err = " + JSON.stringify(err)); console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
expect().assertFail(); expect(err.code).assertEqual(INVALID_PARAM);
done();
} }
done();
}) })
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册