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

!9274 add xts for setmissionlabel

Merge pull request !9274 from savior-xzh/xts
......@@ -20,6 +20,11 @@ import wantConstant from '@ohos.ability.wantConstant';
var INVALID_PARAM = 401
var TAG
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
export default function verificationTest(){
describe('VerificationTestTest', function() {
......@@ -319,6 +324,113 @@ export default function verificationTest(){
done();
})
/*
* @tc.number SUB_AA_OpenHarmony_SetMissionLabel_0200
* @tc.name Verify setMissionLabel that the input parameter is number.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_SetMissionLabel_0200', 0, async function(done) {
TAG = 'SUB_AA_OpenHarmony_SetMissionLabel_0200 ==>';
let label = 0;
try {
await globalThis.abilityContext.setMissionLabel(label).then((data) => {
console.info(TAG + "setMissionLabel data = " + JSON.stringify(data));
}).catch((err) => {
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
});
expect().assertFail();
} catch (err) {
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
expect(err.code).assertEqual(INVALID_PARAM);
}
try {
await globalThis.abilityContext.setMissionLabel(label, (err, data) => {
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
console.info(TAG + "setMissionLabel data = " + JSON.stringify(data));
})
expect().assertFail();
} catch (err) {
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
expect(err.code).assertEqual(INVALID_PARAM);
}
done();
})
/*
* @tc.number SUB_AA_OpenHarmony_SetMissionLabel_0300
* @tc.name Verify setMissionLabel that the input parameter is string.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_SetMissionLabel_0300', 0, async function(done) {
TAG = 'SUB_AA_OpenHarmony_SetMissionLabel_0300 ==>';
let label = "testlabel";
let missionLabelUpdatedFlag = false;
await globalThis.abilityContext.setMissionLabel(label).then((data) => {
console.info(TAG + "setMissionLabel data = " + JSON.stringify(data));
missionLabelUpdatedFlag = true;
}).catch((err) => {
console.info(TAG + "setMissionLabel err = " + JSON.stringify(err));
});
await sleep(1000);
expect(missionLabelUpdatedFlag).assertTrue();
done();
})
/*
* @tc.number SUB_AA_OpenHarmony_SetMissionLabel_0400
* @tc.name Verify multiple setMissionLabel that the input parameter is string.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_SetMissionLabel_0400', 0, async function(done) {
TAG = 'SUB_AA_OpenHarmony_SetMissionLabel_0400 ==>';
let label1 = "testlabel1";
let label2 = "testlabel2";
let missionLabelUpdatedCount = 0;
await globalThis.abilityContext.setMissionLabel(label1).then((data) => {
console.info(TAG + "setMissionLabel1 data = " + JSON.stringify(data));
missionLabelUpdatedCount++;
}).catch((err) => {
console.info(TAG + "setMissionLabel1 err = " + JSON.stringify(err));
});
await globalThis.abilityContext.setMissionLabel(label2).then((data) => {
console.info(TAG + "setMissionLabel2 data = " + JSON.stringify(data));
missionLabelUpdatedCount++;
}).catch((err) => {
console.info(TAG + "setMissionLabel2 err = " + JSON.stringify(err));
});
await sleep(1000);
expect(missionLabelUpdatedCount).assertEqual(2);
missionLabelUpdatedCount = 0;
await globalThis.abilityContext.setMissionLabel(label1, (err, data) => {
console.info(TAG + "setMissionLabel1 err = " + JSON.stringify(err));
console.info(TAG + "setMissionLabel1 data = " + JSON.stringify(data));
if (err.code == 0) {
missionLabelUpdatedCount++;
}
})
await globalThis.abilityContext.setMissionLabel(label2, (err, data) => {
console.info(TAG + "setMissionLabel2 err = " + JSON.stringify(err));
console.info(TAG + "setMissionLabel2 data = " + JSON.stringify(data));
if (err.code == 0) {
missionLabelUpdatedCount++;
}
})
await sleep(1000);
expect(missionLabelUpdatedCount).assertEqual(2);
done();
})
/*
* @tc.number SUB_AA_OpenHarmony_StartAbilityLife_0100
* @tc.name Ability startup and termination will not trigger the migration lifecycle.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册