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

!7226 新增用例SUB_AA_UpdateConfiguration_0200

Merge pull request !7226 from yangliang36/yl0114
......@@ -47,4 +47,28 @@ export default class MainAbility extends Ability {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
onConfigurationUpdate(config) {
console.log('[Demo] MainAbility onConfigurationUpdate: ' + this.context.config.language)
console.log('[Demo] MainAbility onConfigurationUpdate: ' + config.language)
if (globalThis.UpdateConfiguration_0200_prepare_resolve) {
globalThis.UpdateConfiguration_0200_prepare_resolve();
}
if (!globalThis.UpdateConfiguration_0200_resolve) {
console.log("[Demo] MainAbility invalid resolve")
return;
}
if (!globalThis.UpdateConfiguration_0200_reject) {
console.log("[Demo] MainAbility invalid reject")
return;
}
if (this.context.config.language == "English" && config.language == "zh-Hans") {
globalThis.UpdateConfiguration_0200_resolve();
} else {
globalThis.UpdateConfiguration_0200_reject();
}
}
};
......@@ -131,5 +131,65 @@ export default function ApiCoverTest() {
done();
}
});
/*
* @tc.number SUB_AA_UpdateConfiguration_0200
* @tc.name Test updateConfiguration.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_UpdateConfiguration_0200', 0, async function (done) {
let enLanguage = {
language: 'English'
}
let zhLanguage = {
language: 'zh-Hans'
}
// set language to english
await new Promise((resolve, reject) => {
globalThis.UpdateConfiguration_0200_prepare_resolve = resolve;
console.info("SUB_AA_UpdateConfiguration_0200 ----> before set language to english.");
abilityManager.updateConfiguration(enLanguage).then(() => {
console.info("SUB_AA_UpdateConfiguration_0200 ----> set language to english succeed.");
}).catch(err => {
console.info("SUB_AA_UpdateConfiguration_0200 ----> failed to set language to english: " + err);
globalThis.UpdateConfiguration_0200_prepare_resolve();
});
}).then(() => {
console.info("SUB_AA_UpdateConfiguration_0200 ----> succees to set language.");
}).catch(err => {
console.info("SUB_AA_UpdateConfiguration_0200 ----> failed to set language: " + err);
}).finally(() => {
globalThis.UpdateConfiguration_0200_prepare_resolve = null;
globalThis.UpdateConfiguration_0200_resolve = null;
globalThis.UpdateConfiguration_0200_reject = null;
console.info("SUB_AA_UpdateConfiguration_0200 ----> set promise to null after all");
});
// set language to chinese
await new Promise((resolve, reject) => {
globalThis.UpdateConfiguration_0200_resolve = resolve;
globalThis.UpdateConfiguration_0200_reject = reject;
console.info("SUB_AA_UpdateConfiguration_0200 ----> before set language to chinese.");
abilityManager.updateConfiguration(zhLanguage).then(() => {
console.info("SUB_AA_UpdateConfiguration_0200 ----> set language to chinese succeed.");
}).catch(err => {
console.info("SUB_AA_UpdateConfiguration_0200 ----> failed to set language to chinese: " + err);
});
}).then(() => {
console.info("SUB_AA_UpdateConfiguration_0200 ----> succees to set language.");
expect(true).assertTrue();
}).catch(err => {
console.info("SUB_AA_UpdateConfiguration_0200 ----> failed to set language: " + err);
expect(false).assertTrue();
}).finally(() => {
globalThis.UpdateConfiguration_0200_resolve = null;
globalThis.UpdateConfiguration_0200_reject = null;
console.info("SUB_AA_UpdateConfiguration_0200 ----> set promise to null after all");
done();
});
});
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册