提交 e8d6173d 编写于 作者: S songjindian

修复context测试用例获取string值错误

Signed-off-by: Nsongjindian <songjindian1@huawei.com>
上级 626fd54d
...@@ -19,5 +19,6 @@ export default class MyAbilityStage extends AbilityStage { ...@@ -19,5 +19,6 @@ export default class MyAbilityStage extends AbilityStage {
onCreate() { onCreate() {
console.info("MyAbilityStageMonitor onCreate") console.info("MyAbilityStageMonitor onCreate")
globalThis.abilityStageContext = this.context globalThis.abilityStageContext = this.context
globalThis.abilityStageContextRes = this.context.createModuleContext('entry_test')
} }
} }
\ No newline at end of file
...@@ -23,6 +23,7 @@ export default class MainAbility extends Ability { ...@@ -23,6 +23,7 @@ export default class MainAbility extends Ability {
console.log("ActsStageContextPropertiesTest MainAbility onCreate") console.log("ActsStageContextPropertiesTest MainAbility onCreate")
globalThis.abilityWant = want; globalThis.abilityWant = want;
globalThis.abilityContext = this.context globalThis.abilityContext = this.context
globalThis.abilityContextRes = this.context.createModuleContext('entry_test')
let abilityDelegator: any let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any let abilityDelegatorArguments: any
......
...@@ -398,7 +398,7 @@ export default function stageContextPropertiesTest(abilityContext) { ...@@ -398,7 +398,7 @@ export default function stageContextPropertiesTest(abilityContext) {
it('SUB_AA_OpenHarmony_Context_0900', 0, async function (done) { it('SUB_AA_OpenHarmony_Context_0900', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_0900" TAG = "SUB_AA_OpenHarmony_Context_0900"
console.log(TAG + " --- start"); console.log(TAG + " --- start");
let result = await abilityContext.resourceManager.getString(16777219); let result = await globalThis.abilityContextRes.resourceManager.getString(16777219);
console.log(TAG + " : result = " + JSON.stringify(result)); console.log(TAG + " : result = " + JSON.stringify(result));
expect(result).assertEqual("entry_MainAbility"); expect(result).assertEqual("entry_MainAbility");
done(); done();
...@@ -413,7 +413,7 @@ export default function stageContextPropertiesTest(abilityContext) { ...@@ -413,7 +413,7 @@ export default function stageContextPropertiesTest(abilityContext) {
it('SUB_AA_OpenHarmony_Context_1000', 0, async function (done) { it('SUB_AA_OpenHarmony_Context_1000', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_1000" TAG = "SUB_AA_OpenHarmony_Context_1000"
console.log(TAG + " --- start"); console.log(TAG + " --- start");
let result = await globalThis.abilityStageContext.resourceManager.getString(16777219); let result = await globalThis.abilityStageContextRes.resourceManager.getString(16777219);
console.log(TAG + " : result = " + JSON.stringify(result)); console.log(TAG + " : result = " + JSON.stringify(result));
expect(result).assertEqual("entry_MainAbility"); expect(result).assertEqual("entry_MainAbility");
done(); done();
...@@ -428,10 +428,10 @@ export default function stageContextPropertiesTest(abilityContext) { ...@@ -428,10 +428,10 @@ export default function stageContextPropertiesTest(abilityContext) {
it('SUB_AA_OpenHarmony_Context_1100', 0, async function (done) { it('SUB_AA_OpenHarmony_Context_1100', 0, async function (done) {
TAG = "SUB_AA_OpenHarmony_Context_1100" TAG = "SUB_AA_OpenHarmony_Context_1100"
console.log(TAG + " --- start"); console.log(TAG + " --- start");
let result = await globalThis.abilityStageContext.getApplicationContext() let result = await globalThis.abilityStageContextRes.getApplicationContext()
.resourceManager.getString(16777219); .resourceManager.getString(16777219);
console.log(TAG + " : result = " + JSON.stringify(result)); console.log(TAG + " : result = " + JSON.stringify(result));
expect(result).assertEqual("entry_MainAbility"); expect(result).assertEqual("feature_MainAbility");
done(); done();
}); });
...@@ -448,9 +448,11 @@ export default function stageContextPropertiesTest(abilityContext) { ...@@ -448,9 +448,11 @@ export default function stageContextPropertiesTest(abilityContext) {
async function SubscribeCallBack(err, data) { async function SubscribeCallBack(err, data) {
console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data) console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data)
+ "err: " + JSON.stringify(err)); + "err: " + JSON.stringify(err));
let result = await globalThis.abilityContextA.resourceManager.getString(16777219); console.log(TAG, JSON.stringify(globalThis.abilityContextA))
console.log(TAG + " : result = " + JSON.stringify(result)); console.log(TAG, JSON.stringify(globalThis.abilityContextA.resourceManager))
expect(result).assertEqual("entry_MainAbility"); let result = globalThis.abilityContextA.resourceManager.getStringSync(16777219);
console.log(TAG + " : results = " + JSON.stringify(result));
expect(result).assertEqual("feature_MainAbility");
checkContextDirEqualB(abilityContext, globalThis.abilityContextA) checkContextDirEqualB(abilityContext, globalThis.abilityContextA)
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册