From 6814c0ebd8977ef458ee337c9c1625bfc95816de Mon Sep 17 00:00:00 2001 From: chengxingzhen Date: Mon, 16 Jan 2023 20:29:17 +0800 Subject: [PATCH] =?UTF-8?q?xts-=E7=B3=BB=E7=BB=9Fapi=E4=B8=8B=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengxingzhen --- .../main/ets/Application/MyAbilityStage.ts | 26 - .../src/main/ets/MainAbility/MainAbility.ts | 23 - .../ets/test/StageContextProperties.test.ets | 572 ------------------ .../ets/test/ActsStageContextTest.test.ets | 247 -------- 4 files changed, 868 deletions(-) diff --git a/ability/ability_runtime/context/actsstagecontext/actsstagecontextassisttwo/entry/src/main/ets/Application/MyAbilityStage.ts b/ability/ability_runtime/context/actsstagecontext/actsstagecontextassisttwo/entry/src/main/ets/Application/MyAbilityStage.ts index c006f8749..3f3434133 100644 --- a/ability/ability_runtime/context/actsstagecontext/actsstagecontextassisttwo/entry/src/main/ets/Application/MyAbilityStage.ts +++ b/ability/ability_runtime/context/actsstagecontext/actsstagecontextassisttwo/entry/src/main/ets/Application/MyAbilityStage.ts @@ -49,36 +49,10 @@ export default class MyAbilityStage extends AbilityStage { 'preferencesDir': stageAppContext.preferencesDir, 'bundleCodeDir': stageAppContext.bundleCodeDir }; - let bundleContext = globalThis.abilityStageContextB.createBundleContext("com.example.actsstagecontextassisttwo"); - - let result = await bundleContext.resourceManager.getString(16777219) - - let appBundleContext = stageAppContext.createBundleContext("com.example.actsstagecontextassisttwo"); - - let result1 = await appBundleContext.resourceManager.getString(16777219) - - console.log("ActsStageContextAssistTwo getLabel " + JSON.stringify(result1)) - - let stageBundleContextJson = { - 'cacheDir': bundleContext.cacheDir, 'tempDir': bundleContext.tempDir, 'filesDir': bundleContext.filesDir, - 'distributedFilesDir': bundleContext.distributedFilesDir, 'databaseDir': bundleContext.databaseDir, - 'preferencesDir': bundleContext.preferencesDir, 'bundleCodeDir': bundleContext.bundleCodeDir - }; - - let stageAppBundleContextJson = { - 'cacheDir': appBundleContext.cacheDir, 'tempDir': appBundleContext.tempDir, 'filesDir': appBundleContext.filesDir, - 'distributedFilesDir': appBundleContext.distributedFilesDir, 'databaseDir': appBundleContext.databaseDir, - 'preferencesDir': appBundleContext.preferencesDir, 'bundleCodeDir': appBundleContext.bundleCodeDir - }; - let commonEventData = { parameters: { abilityStageContextAssistOne: stageContextJson, abilityStageAppContextAssistOne: stageAppContextJson, - abilityStageLabel: result, - abilityStageAppLabel: result1, - abilityStageBundleContxtAssistOne: stageBundleContextJson, - abilityStageAppBundleContextAssistOne: stageAppBundleContextJson } } commonEvent.publish("AssistContextTwo_StageAbilityA_Start_CommonEvent", commonEventData, () => { diff --git a/ability/ability_runtime/context/actsstagecontext/actsstagecontextassisttwo/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/context/actsstagecontext/actsstagecontextassisttwo/entry/src/main/ets/MainAbility/MainAbility.ts index fec47b86b..23b514543 100644 --- a/ability/ability_runtime/context/actsstagecontext/actsstagecontextassisttwo/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/context/actsstagecontext/actsstagecontextassisttwo/entry/src/main/ets/MainAbility/MainAbility.ts @@ -15,8 +15,6 @@ import Ability from '@ohos.app.ability.UIAbility' import commonEvent from '@ohos.commonEvent' -import bundle from '@ohos.bundle'; -import dataAbility from '@ohos.data.dataAbility'; export default class MainAbility extends Ability { onCreate(want: any, launchParam: any) { @@ -52,24 +50,6 @@ export default class MainAbility extends Ability { 'preferencesDir': abilityAppContext.preferencesDir, 'bundleCodeDir': abilityAppContext.bundleCodeDir }; - let bundleContext = this.context.createBundleContext("com.example.actsstagecontextassisttwo") - - let bundleAppContext = abilityAppContext.createBundleContext("com.example.actsstagecontextassisttwo") - - let result = await bundleContext.resourceManager.getString(16777219) - - let bundleContextJson = { - 'cacheDir': bundleContext.cacheDir, 'tempDir': bundleContext.tempDir, 'filesDir': bundleContext.filesDir, - 'distributedFilesDir': bundleContext.distributedFilesDir, 'databaseDir': bundleContext.databaseDir, - 'preferencesDir': bundleContext.preferencesDir, 'bundleCodeDir': bundleContext.bundleCodeDir - }; - - let appBundleContextJson = { - 'cacheDir': bundleAppContext.cacheDir, 'tempDir': bundleAppContext.tempDir, 'filesDir': bundleAppContext.filesDir, - 'distributedFilesDir': bundleAppContext.distributedFilesDir, 'databaseDir': bundleAppContext.databaseDir, - 'preferencesDir': bundleAppContext.preferencesDir, 'bundleCodeDir': bundleAppContext.bundleCodeDir - }; - let errCode; try { @@ -83,9 +63,6 @@ export default class MainAbility extends Ability { parameters: { abilityContextAssistTwo: contextJson, abilityAppContextAssistTwo: appContextJson, - abilityLabel: result, - abilityBundleContextAssistTwo: bundleContextJson, - abilityAppBundleContextAssistTwo: appBundleContextJson, abilityBundleContextTest: errCode } } diff --git a/ability/ability_runtime/context/actsstagecontext/actsstagecontextpropertiestest/entry/src/main/ets/test/StageContextProperties.test.ets b/ability/ability_runtime/context/actsstagecontext/actsstagecontextpropertiestest/entry/src/main/ets/test/StageContextProperties.test.ets index 21c002b9c..7ff9200b7 100644 --- a/ability/ability_runtime/context/actsstagecontext/actsstagecontextpropertiestest/entry/src/main/ets/test/StageContextProperties.test.ets +++ b/ability/ability_runtime/context/actsstagecontext/actsstagecontextpropertiestest/entry/src/main/ets/test/StageContextProperties.test.ets @@ -496,558 +496,6 @@ export default function stageContextPropertiesTest(abilityContext) { } }); - /** - * @tc.number: SUB_AA_OpenHarmony_Context_1400 - * @tc.name: The resource obtained through getString is the same as config.json in the label resources are the same - * @tc.desc: Function test - * @tc.level 3 - */ - it('SUB_AA_OpenHarmony_Context_1400', 0, async function (done) { - TAG = "SUB_AA_OpenHarmony_Context_1400" - console.log(TAG + " --- start"); - let bundleContext = abilityContext.createBundleContext("com.example.stagecontextpropertiestest"); - let result = await bundleContext.resourceManager.getString(16777219); - console.log(TAG + " : result = " + JSON.stringify(result)); - expect(result).assertEqual("feature_MainAbility"); - done(); - }); - - /** - * @tc.number: SUB_AA_OpenHarmony_Context_1500 - * @tc.name: The resource obtained through getString is the same as config.json in the label resources are the same - * @tc.desc: Function test - * @tc.level 3 - */ - it('SUB_AA_OpenHarmony_Context_1500', 0, async function (done) { - TAG = "SUB_AA_OpenHarmony_Context_1500" - console.log(TAG + " --- start"); - - function SubscribeCallBack(err, data) { - console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data) - + "err: " + JSON.stringify(err)); - if (data.event == 'StartMainAbility4_CommonEvent_ContextOne') { - expect(data.parameters.abilityLabel).assertEqual("entry_MainAbility"); - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); - } - } - - await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => { - console.log(TAG + " Create Subscriber"); - Subscriber = data; - await commonEvent.subscribe(Subscriber, SubscribeCallBack); - }) - - function UnSubscribeCallback() { - console.log(TAG + " UnSubscribe CallBack"); - done(); - } - - await abilityContext.startAbility({ - bundleName: "com.example.actsstagecontextassisttwo", - abilityName: "MainAbility4", - parameters: { - startId: 4, - } - }).then((data) => { - console.log(TAG + ' - startAbility: ' + JSON.stringify(data)); - }).catch((err) => { - console.log(TAG + " - start failed" + JSON.stringify(err)); - expect.assertFail() - done() - }) - }); - - /** - * @tc.number: SUB_AA_OpenHarmony_Context_1600 - * @tc.name: The resource obtained through getString is the same as config.json in the label resources are the same - * @tc.desc: Function test - * @tc.level 3 - */ - it('SUB_AA_OpenHarmony_Context_1600', 0, async function (done) { - TAG = "SUB_AA_OpenHarmony_Context_1600" - console.log(TAG + " --- start"); - - function SubscribeCallBack(err, data) { - console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data) - + "err: " + JSON.stringify(err)); - if (data.event == 'AssistContextTwo_StageAbilityA_Start_CommonEvent') { - expect(data.parameters.abilityStageLabel).assertEqual("entry_MainAbility"); - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); - } - } - - await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => { - console.log(TAG + " Create Subscriber"); - Subscriber = data; - await commonEvent.subscribe(Subscriber, SubscribeCallBack); - }) - - function UnSubscribeCallback() { - console.log(TAG + " UnSubscribe CallBack"); - done(); - } - - await abilityContext.startAbility({ - bundleName: "com.example.actsstagecontextassisttwo", - abilityName: "MainAbility4", - parameters: { - startId: 5, - } - }).then((data) => { - console.log(TAG + ' - startAbility: ' + JSON.stringify(data)); - }).catch((err) => { - console.log(TAG + " - start failed" + JSON.stringify(err)); - expect.assertFail() - done() - }) - }); - - /** - * @tc.number: SUB_AA_OpenHarmony_Context_1700 - * @tc.name: The resource obtained through getString is the same as config.json in the label resources are the same - * @tc.desc: Function test - * @tc.level 3 - */ - it('SUB_AA_OpenHarmony_Context_1700', 0, async function (done) { - TAG = "SUB_AA_OpenHarmony_Context_1700" - console.log(TAG + " --- start"); - - function SubscribeCallBack(err, data) { - console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data) - + "err: " + JSON.stringify(err)); - if (data.event == 'AssistContextTwo_StageAbilityA_Start_CommonEvent') { - expect(data.parameters.abilityStageAppLabel).assertEqual("entry_MainAbility"); - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); - } - } - - await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => { - console.log(TAG + " Create Subscriber"); - Subscriber = data; - await commonEvent.subscribe(Subscriber, SubscribeCallBack); - }) - - function UnSubscribeCallback() { - console.log(TAG + " UnSubscribe CallBack"); - done(); - } - - await abilityContext.startAbility({ - bundleName: "com.example.actsstagecontextassisttwo", - abilityName: "MainAbility4", - parameters: { - startId: 6, - } - }).then((data) => { - console.log(TAG + ' - startAbility: ' + JSON.stringify(data)); - }).catch((err) => { - console.log(TAG + " - start failed" + JSON.stringify(err)); - expect.assertFail() - done() - }) - }); - - - /** - * @tc.number: SUB_AA_OpenHarmony_Context_1800 - * @tc.name: Check that context paths of different Ability in the same hap are the same. - * @tc.desc: Function test - * @tc.level 3 - */ - it('SUB_AA_OpenHarmony_Context_1800', 0, async function (done) { - TAG = "SUB_AA_OpenHarmony_Context_1800" - console.log(TAG + " --- start"); - let abilityBundleContext1 = abilityContext.createBundleContext("com.example.stagecontextpropertiestest"); - let abilityBundleContext2 = globalThis.abilityContext2 - .createBundleContext("com.example.stagecontextpropertiestest"); - checkBundleContextDir(abilityBundleContext1); - checkContextDirEqualA(abilityBundleContext1, abilityBundleContext2); - console.log(TAG + " --- end"); - done() - }); - - /** - * @tc.number: SUB_AA_OpenHarmony_Context_1900 - * @tc.name: Check that ApplicationContext paths of different Ability in the same hap are the same. - * @tc.desc: Function test - * @tc.level 3 - */ - it('SUB_AA_OpenHarmony_Context_1900', 0, async function (done) { - TAG = "SUB_AA_OpenHarmony_Context_1800" - console.log(TAG + " --- start"); - let abilityBundleContext1 = abilityContext.createBundleContext("com.example.stagecontextpropertiestest"); - let abilityBundleContext2 = globalThis.abilityContext2 - .createBundleContext("com.example.stagecontextpropertiestest"); - let abilityStageBundleContext2 = globalThis.abilityStageContext - .createBundleContext("com.example.stagecontextpropertiestest"); - checkBundleContextDir(abilityBundleContext1); - checkContextDirEqualA(abilityBundleContext1, abilityBundleContext2); - checkContextDirEqualA(abilityBundleContext1, abilityStageBundleContext2); - console.log(TAG + " --- end"); - done() - }); - - /** - * @tc.number: SUB_AA_OpenHarmony_Context_2000 - * @tc.name: Check that ApplicationContext paths of different Ability in the different hap are the same. - * @tc.desc: Function test - * @tc.level 3 - */ - it('SUB_AA_OpenHarmony_Context_2000', 0, async function (done) { - TAG = "SUB_AA_OpenHarmony_Context_2000" - console.log(TAG + " --- start"); - let abilityBundleContext1 = abilityContext.createBundleContext("com.example.stagecontextpropertiestest"); - - checkBundleContextDir(abilityBundleContext1); - - function SubscribeCallBack(err, data) { - console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data) - + "err: " + JSON.stringify(err)); - let abilityBundleContext2 = globalThis.abilityContextA.createBundleContext( - "com.example.stagecontextpropertiestest"); - checkContextDirEqualA(abilityBundleContext1, abilityBundleContext2); - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); - } - - await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => { - console.log(TAG + " Create Subscriber"); - Subscriber = data; - await commonEvent.subscribe(Subscriber, SubscribeCallBack); - }) - - function UnSubscribeCallback() { - console.log(TAG + " UnSubscribe CallBack"); - done(); - } - - await abilityContext.startAbility({ - bundleName: "com.example.stagecontextpropertiestest", - abilityName: "MainAbility3", - }).then((data) => { - console.log(TAG + ' - startAbility: ' + JSON.stringify(data)); - }).catch((err) => { - console.log(TAG + " - start failed" + JSON.stringify(err)); - expect.assertFail() - done() - }) - }); - - /** - * @tc.number: SUB_AA_OpenHarmony_Context_2100 - * @tc.name: Check that ApplicationContext paths of different Ability in the different hap are the same. - * @tc.desc: Function test - * @tc.level 3 - */ - it('SUB_AA_OpenHarmony_Context_2100', 0, async function (done) { - TAG = "SUB_AA_OpenHarmony_Context_2100" - console.log(TAG + " --- start"); - let abilityStageBundleContext1 = globalThis.abilityStageContext.createBundleContext( - "com.example.stagecontextpropertiestest"); - - checkBundleContextDir(abilityStageBundleContext1); - - function SubscribeCallBack(err, data) { - console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data) - + "err: " + JSON.stringify(err)); - let abilityBundleContext2 = globalThis.abilityStageContextA.createBundleContext( - "com.example.stagecontextpropertiestest"); - checkContextDirEqualA(abilityStageBundleContext1, abilityBundleContext2); - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); - } - - await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => { - console.log(TAG + " Create Subscriber"); - Subscriber = data; - await commonEvent.subscribe(Subscriber, SubscribeCallBack); - }) - - function UnSubscribeCallback() { - console.log(TAG + " UnSubscribe CallBack"); - done(); - } - - await abilityContext.startAbility({ - bundleName: "com.example.stagecontextpropertiestest", - abilityName: "MainAbility3", - }).then((data) => { - console.log(TAG + ' - startAbility: ' + JSON.stringify(data)); - }).catch((err) => { - console.log(TAG + " - start failed" + JSON.stringify(err)); - expect.assertFail() - done() - }) - }); - - /** - * @tc.number: SUB_AA_OpenHarmony_Context_2200 - * @tc.name: Check that ApplicationContext paths of different Ability in the different hap are the same. - * @tc.desc: Function test - * @tc.level 3 - */ - it('SUB_AA_OpenHarmony_Context_2200', 0, async function (done) { - TAG = "SUB_AA_OpenHarmony_Context_2200" - console.log(TAG + " --- start"); - let abilityBundleContext1 = abilityContext.getApplicationContext() - .createBundleContext("com.example.stagecontextpropertiestest") - let abilityStageBundleContext1 = globalThis.abilityStageContext.getApplicationContext() - .createBundleContext( - "com.example.stagecontextpropertiestest"); - - checkBundleContextDir(abilityBundleContext1); - - function SubscribeCallBack(err, data) { - console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data) - + "err: " + JSON.stringify(err)); - let abilityBundleContext2 = abilityContext.getApplicationContext() - .createBundleContext("com.example.stagecontextpropertiestest") - let abilityStageBundleContext2 = globalThis.abilityStageContext.getApplicationContext() - .createBundleContext( - "com.example.stagecontextpropertiestest"); - checkContextDirEqualA(abilityBundleContext1, abilityStageBundleContext1); - checkContextDirEqualA(abilityBundleContext2, abilityStageBundleContext2); - checkContextDirEqualA(abilityBundleContext1, abilityStageBundleContext2); - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); - } - - await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => { - console.log(TAG + " Create Subscriber"); - Subscriber = data; - await commonEvent.subscribe(Subscriber, SubscribeCallBack); - }) - - function UnSubscribeCallback() { - console.log(TAG + " UnSubscribe CallBack"); - done(); - } - - await abilityContext.startAbility({ - bundleName: "com.example.stagecontextpropertiestest", - abilityName: "MainAbility3", - }).then((data) => { - console.log(TAG + ' - startAbility: ' + JSON.stringify(data)); - }).catch((err) => { - console.log(TAG + " - start failed" + JSON.stringify(err)); - expect.assertFail() - done() - }) - }); - - /** - * @tc.number: SUB_AA_OpenHarmony_Context_2300 - * @tc.name: Check that Context paths of different Ability in the different hap are the same. - * @tc.desc: Function test - * @tc.level 3 - */ - it('SUB_AA_OpenHarmony_Context_2300', 0, async function (done) { - TAG = "SUB_AA_OpenHarmony_Context_2300" - console.log(TAG + " --- start"); - let abilityBundleContext1 = abilityContext.createBundleContext("com.example.stagecontextpropertiestest"); - - checkBundleContextDir(abilityBundleContext1); - - function SubscribeCallBack(err, data) { - console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data) - + "err: " + JSON.stringify(err)); - if (data.event == 'StartMainAbility4_CommonEvent_ContextOne') { - checkAssistHapBundleContextDir(data.parameters.abilityBundleContextAssistTwo) - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); - } - } - - await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => { - console.log(TAG + " Create Subscriber"); - Subscriber = data; - await commonEvent.subscribe(Subscriber, SubscribeCallBack); - }) - - function UnSubscribeCallback() { - console.log(TAG + " UnSubscribe CallBack"); - done(); - } - - await abilityContext.startAbility({ - bundleName: "com.example.actsstagecontextassisttwo", - abilityName: "MainAbility4", - parameters: { - startId: 7, - } - }).then((data) => { - console.log(TAG + ' - startAbility: ' + JSON.stringify(data)); - }).catch((err) => { - console.log(TAG + " - start failed" + JSON.stringify(err)); - expect.assertFail() - done() - }) - }); - - /** - * @tc.number: SUB_AA_OpenHarmony_Context_2400 - * @tc.name: Check that Context paths of different Ability in the different hap are the same. - * @tc.desc: Function test - * @tc.level 3 - */ - it('SUB_AA_OpenHarmony_Context_2400', 0, async function (done) { - TAG = "SUB_AA_OpenHarmony_Context_2400" - console.log(TAG + " --- start"); - let abilityStageBundleContext1 = globalThis.abilityStageContext - .createBundleContext("com.example.stagecontextpropertiestest"); - - checkBundleContextDir(abilityStageBundleContext1); - - function SubscribeCallBack(err, data) { - console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data) - + "err: " + JSON.stringify(err)); - if (data.event == 'AssistContextTwo_StageAbilityA_Start_CommonEvent') { - checkAssistHapBundleContextDir(data.parameters.abilityStageBundleContxtAssistOne) - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); - } - } - - await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => { - console.log(TAG + " Create Subscriber"); - Subscriber = data; - await commonEvent.subscribe(Subscriber, SubscribeCallBack); - }) - - function UnSubscribeCallback() { - console.log(TAG + " UnSubscribe CallBack"); - done(); - } - - await abilityContext.startAbility({ - bundleName: "com.example.actsstagecontextassisttwo", - abilityName: "MainAbility4", - parameters: { - startId: 8, - } - }).then((data) => { - console.log(TAG + ' - startAbility: ' + JSON.stringify(data)); - }).catch((err) => { - console.log(TAG + " - start failed" + JSON.stringify(err)); - expect.assertFail() - done() - }) - }); - - /** - * @tc.number: SUB_AA_OpenHarmony_Context_2500 - * @tc.name: Check that ApplicationContex paths of different Ability in the different hap are the same. - * @tc.desc: Function test - * @tc.level 3 - */ - it('SUB_AA_OpenHarmony_Context_2500', 0, async function (done) { - TAG = "SUB_AA_OpenHarmony_Context_2500" - console.log(TAG + " --- start"); - let num = 0; - let abilityStageAppBundleContext; - let abilityAppBundleContext; - let abilityAppBundleContext1 = globalThis.abilityStageContext.getApplicationContext() - .createBundleContext("com.example.stagecontextpropertiestest"); - let abilityStageAppBundleContext1 = globalThis.abilityStageContext.getApplicationContext() - .createBundleContext("com.example.stagecontextpropertiestest"); - - checkBundleContextDir(abilityAppBundleContext1); - checkContextDirEqualA(abilityAppBundleContext1, abilityStageAppBundleContext1) - - function SubscribeCallBack(err, data) { - console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data) - + "err: " + JSON.stringify(err)); - if (data.event == 'AssistContextTwo_StageAbilityA_Start_CommonEvent') { - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); - } - if (data.event == 'AssistContextTwo_StageAbilityA_Start_CommonEvent') { - console.log(TAG + " AssistContextTwo_StageAbilityA_Start_CommonEvent") - num++; - abilityStageAppBundleContext = data.parameters.abilityStageAppContextAssistOne - } - if (data.event == 'StartMainAbility4_CommonEvent_ContextOne') { - console.log(TAG + " StartMainAbility4_CommonEvent_ContextOne") - num++; - abilityAppBundleContext = data.parameters.abilityAppContextAssistTwo - } - if (num == 2) { - console.log(TAG + " start expect"); - checkAssistHapBundleContextDir(abilityAppBundleContext) - checkContextDirEqualA(abilityAppBundleContext, abilityStageAppBundleContext) - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); - } - } - - await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => { - console.log(TAG + " Create Subscriber"); - Subscriber = data; - await commonEvent.subscribe(Subscriber, SubscribeCallBack); - }) - - function UnSubscribeCallback() { - console.log(TAG + " UnSubscribe CallBack"); - done(); - } - - await abilityContext.startAbility({ - bundleName: "com.example.actsstagecontextassisttwo", - abilityName: "MainAbility4", - parameters: { - startId: 9, - } - }).then((data) => { - console.log(TAG + ' - startAbility: ' + JSON.stringify(data)); - }).catch((err) => { - console.log(TAG + " - start failed" + JSON.stringify(err)); - expect.assertFail() - done() - }) - }); - - /** - * @tc.number: SUB_AA_OpenHarmony_Context_2600 - * @tc.name: Check that Context paths of different Ability in the different hap are the same. - * @tc.desc: Function test - * @tc.level 3 - */ - it('SUB_AA_OpenHarmony_Context_2600', 0, async function (done) { - TAG = "SUB_AA_OpenHarmony_Context_2600" - console.log(TAG + " --- start"); - let abilityBundleContext1 = globalThis.abilityStageContext - .createBundleContext("com.example.stagecontextpropertiestest"); - - checkBundleContextDir(abilityBundleContext1); - - function SubscribeCallBack(err, data) { - console.log(TAG + " Subscribe CallBack data: " + JSON.stringify(data) - + "err: " + JSON.stringify(err)); - if (data.event == 'StartMainAbility4_CommonEvent_ContextOne') { - expect(data.parameters.abilityBundleContextTest).assertEqual(401) - commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); - } - } - - await commonEvent.createSubscriber(subscriberInfo_AbilityContext).then(async (data) => { - console.log(TAG + " Create Subscriber"); - Subscriber = data; - await commonEvent.subscribe(Subscriber, SubscribeCallBack); - }) - - function UnSubscribeCallback() { - console.log(TAG + " UnSubscribe CallBack"); - done(); - } - - await abilityContext.startAbility({ - bundleName: "com.example.actsstagecontextassisttwo", - abilityName: "MainAbility4", - parameters: { - startId: 10, - } - }).then((data) => { - console.log(TAG + ' - startAbility: ' + JSON.stringify(data)); - }).catch((err) => { - console.log(TAG + " - start failed" + JSON.stringify(err)); - expect.assertFail() - done() - }) - }); - function checkApplicationContextDir(applicationContext) { expect(applicationContext.cacheDir).assertEqual("/data/storage/el2/base/cache"); expect(applicationContext.tempDir).assertEqual("/data/storage/el2/base/temp"); @@ -1117,25 +565,5 @@ export default function stageContextPropertiesTest(abilityContext) { expect(globalThis.abilityStageContext.preferencesDir).assertEqual("/data/storage/el2/base/haps/entry_test/preferences"); expect(globalThis.abilityStageContext.bundleCodeDir).assertEqual("/data/storage/el1/bundle"); } - - function checkBundleContextDir(bundleContext) { - expect(bundleContext.bundleCodeDir).assertEqual("/data/bundles/com.example.stagecontextpropertiestest"); - expect(bundleContext.tempDir).assertEqual("/data/app/el2/100/base/com.example.stagecontextpropertiestest/temp"); - expect(bundleContext.filesDir).assertEqual("/data/app/el2/100/base/com.example.stagecontextpropertiestest/files"); - expect(bundleContext.cacheDir).assertEqual("/data/app/el2/100/base/com.example.stagecontextpropertiestest/cache"); - expect(bundleContext.databaseDir).assertEqual("/data/app/el2/100/database/com.example.stagecontextpropertiestest"); - expect(bundleContext.preferencesDir).assertEqual("/data/app/el2/100/base/com.example.stagecontextpropertiestest/preferences"); - expect(bundleContext.distributedFilesDir).assertEqual("/mnt/hmdfs/100/device_view/local/data/com.example.stagecontextpropertiestest"); - } - - function checkAssistHapBundleContextDir(bundleContext) { - expect(bundleContext.bundleCodeDir).assertEqual("/data/bundles/com.example.actsstagecontextassisttwo"); - expect(bundleContext.tempDir).assertEqual("/data/app/el2/100/base/com.example.actsstagecontextassisttwo/temp"); - expect(bundleContext.filesDir).assertEqual("/data/app/el2/100/base/com.example.actsstagecontextassisttwo/files"); - expect(bundleContext.cacheDir).assertEqual("/data/app/el2/100/base/com.example.actsstagecontextassisttwo/cache"); - expect(bundleContext.databaseDir).assertEqual("/data/app/el2/100/database/com.example.actsstagecontextassisttwo"); - expect(bundleContext.preferencesDir).assertEqual("/data/app/el2/100/base/com.example.actsstagecontextassisttwo/preferences"); - expect(bundleContext.distributedFilesDir).assertEqual("/mnt/hmdfs/100/device_view/local/data/com.example.actsstagecontextassisttwo"); - } }) } \ No newline at end of file diff --git a/ability/ability_runtime/context/actsstagecontexttest/entry/src/main/ets/test/ActsStageContextTest.test.ets b/ability/ability_runtime/context/actsstagecontexttest/entry/src/main/ets/test/ActsStageContextTest.test.ets index 4efc5cba8..2f859b612 100644 --- a/ability/ability_runtime/context/actsstagecontexttest/entry/src/main/ets/test/ActsStageContextTest.test.ets +++ b/ability/ability_runtime/context/actsstagecontexttest/entry/src/main/ets/test/ActsStageContextTest.test.ets @@ -150,139 +150,6 @@ export default function actsStageContextTest() { }) }) - /* - * @tc.number : ACTS_StageContext_0800 - * @tc.name : get resource by Resource in applicationInfo - * @tc.desc : get resource by Resource in applicationInfo - */ - it('ACTS_StageContext_0800',0, async function (done) { - await bundleManager.getApplicationInfo("com.example.stage_app", 0).then(appInfo => { - return globalThis.abilityContext.createModuleContext("module1").resourceManager.getString(appInfo.labelResource) - }).then(str => { - console.info("ACTS_StageContext_0800 labelId: " + str) - expect(str).assertEqual("stage_app") - done() - }).catch(e => { - console.info("ACTS_StageContext_0800 error: " + e) - expect().assertFail() - done() - }) - }) - - /* - * @tc.number : ACTS_StageContext_0900 - * @tc.name : get resource by labelId in applicationInfo from bundle context - * @tc.desc : get resource by labelId in applicationInfo from bundle context - */ - it('ACTS_StageContext_0900',0, async function (done) { - await bundleManager.getApplicationInfo("com.example.stage_app", 0).then(appInfo => { - return globalThis.abilityContext.createBundleContext("com.example.stage_app").resourceManager.getString(appInfo.labelId) - }).then(str => { - console.info("ACTS_StageContext_0900 labelId: " + str) - expect(str).assertEqual("stage_app") - done() - }).catch(e => { - console.info("ACTS_StageContext_0900 error: " + e) - expect().assertFail() - done() - }) - }) - - /* - * @tc.number : ACTS_StageContext_1000 - * @tc.name : get resource by labelId in applicationInfo from moduleContext - * @tc.desc : get resource by labelId in applicationInfo from moduleContext - */ - it('ACTS_StageContext_1000',0, async function (done) { - await bundleManager.getApplicationInfo("com.example.stage_app", 0).then(appInfo => { - return globalThis.abilityContext.createModuleContext("com.example.stage_app", "entry").resourceManager.getString(appInfo.labelId) - }).then(str => { - console.info("ACTS_StageContext_1000 labelId: " + str) - expect(str).assertEqual("stage_app") - done() - }).catch(e => { - console.info("ACTS_StageContext_1000 error: " + e) - expect().assertFail() - done() - }) - }) - - /* - * @tc.number : ACTS_StageContext_1100 - * @tc.name : get resource by labelId in abilityInfo from bundleContext - * @tc.desc : get resource by labelId in abilityInfo from bundleContext - */ - it('ACTS_StageContext_1100',0, async function (done) { - await bundle.getAbilityInfo("com.example.stage_app", "MainAbility").then(abilityInfo => { - return globalThis.abilityContext.createBundleContext("com.example.stage_app").resourceManager.getString(abilityInfo.labelId) - }).then(str => { - console.info("ACTS_StageContext_1100 labelId: " + str) - expect(str).assertEqual("module1_label") - done() - }).catch(e => { - console.info("ACTS_StageContext_1100 error: " + e) - expect().assertFail() - done() - }) - }) - - /* - * @tc.number : ACTS_StageContext_1200 - * @tc.name : get resource by labelId in abilityInfo from moduleContext - * @tc.desc : get resource by labelId in abilityInfo from moduleContext - */ - it('ACTS_StageContext_1200',0, async function (done) { - await bundle.getAbilityInfo("com.example.stage_app", "MainAbility").then(abilityInfo => { - return globalThis.abilityContext.createModuleContext("com.example.stage_app", "entry").resourceManager.getString(abilityInfo.labelId) - }).then(str => { - console.info("ACTS_StageContext_1200 labelId: " + str) - expect(str).assertEqual("stage_app") - done() - }).catch(e => { - console.info("ACTS_StageContext_1200 error: " + e) - expect().assertFail() - done() - }) - }) - - /* - * @tc.number : ACTS_StageContext_1300 - * @tc.name : get resource by Resource in applicationInfo from bundleContext - * @tc.desc : get resource by Resource in applicationInfo from bundleContext - */ - it('ACTS_StageContext_1300',0, async function (done) { - await bundleManager.getApplicationInfo("com.example.stage_app", 0).then(appInfo => { - return globalThis.abilityContext.createBundleContext("com.example.stage_app").resourceManager.getString(appInfo.labelResource) - }).then(str => { - console.info("ACTS_StageContext_1300 labelId: " + str) - expect(str).assertEqual("stage_app") - done() - }).catch(e => { - console.info("ACTS_StageContext_1300 error: " + e) - expect().assertFail() - done() - }) - }) - - /* - * @tc.number : ACTS_StageContext_1400 - * @tc.name : get resource by Resource in applicationInfo from moduleContext - * @tc.desc : get resource by Resource in applicationInfo from moduleContext - */ - it('ACTS_StageContext_1400',0, async function (done) { - await bundleManager.getApplicationInfo("com.example.stage_app", 0).then(appInfo => { - return globalThis.abilityContext.createModuleContext("com.example.stage_app", "entry").resourceManager.getString(appInfo.labelResource) - }).then(str => { - console.info("ACTS_StageContext_1400 labelId: " + str) - expect(str).assertEqual("stage_app") - done() - }).catch(e => { - console.info("ACTS_StageContext_1400 error: " + e) - expect().assertFail() - done() - }) - }) - /* * @tc.number : ACTS_StageContext_1500 * @tc.name : get resource by Resource in applicationInfo from context(API8) @@ -302,101 +169,6 @@ export default function actsStageContextTest() { }) }) - /* - * @tc.number : ACTS_StageContext_1600 - * @tc.name : get resource by labelId in applicationInfo from bundle context - * @tc.desc : get resource by labelId in applicationInfo from bundle context - */ - it('ACTS_StageContext_1600',0, async function (done) { - await bundleManager.getApplicationInfo("com.example.contextapp", 0).then(appInfo => { - return globalThis.abilityContext.createBundleContext("com.example.contextapp").resourceManager.getString(appInfo.labelId) - }).then(str => { - console.info("ACTS_StageContext_1600 labelId: " + str) - expect(str).assertEqual("ContextApp") - done() - }).catch(e => { - console.info("ACTS_StageContext_1600 error: " + e) - expect().assertFail() - done() - }) - }) - - /* - * @tc.number : ACTS_StageContext_1700 - * @tc.name : get resource by labelId in applicationInfo from moduleContext - * @tc.desc : get resource by labelId in applicationInfo from moduleContext - */ - it('ACTS_StageContext_1700',0, async function (done) { - await bundleManager.getApplicationInfo("com.example.contextapp", 0).then(appInfo => { - return globalThis.abilityContext.createModuleContext("com.example.contextapp", "entry").resourceManager.getString(appInfo.labelId) - }).then(str => { - console.info("ACTS_StageContext_1700 labelId: " + str) - expect(str).assertEqual("ContextApp") - done() - }).catch(e => { - console.info("ACTS_StageContext_1700 error: " + e) - expect().assertFail() - done() - }) - }) - - /* - * @tc.number : ACTS_StageContext_1900 - * @tc.name : get resource by labelId in abilityInfo from moduleContext - * @tc.desc : get resource by labelId in abilityInfo from moduleContext - */ - it('ACTS_StageContext_1900',0, async function (done) { - await bundle.getAbilityInfo("com.example.contextapp", "MainAbility").then(abilityInfo => { - return globalThis.abilityContext.createModuleContext("com.example.contextapp", "entry").resourceManager.getString(abilityInfo.labelId) - }).then(str => { - console.info("ACTS_StageContext_1900 labelId: " + str) - expect(str).assertEqual("context_app") - done() - }).catch(e => { - console.info("ACTS_StageContext_1900 error: " + e) - expect().assertFail() - done() - }) - }) - - /* - * @tc.number : ACTS_StageContext_2000 - * @tc.name : get resource by Resource in applicationInfo from bundleContext - * @tc.desc : get resource by Resource in applicationInfo from bundleContext - */ - it('ACTS_StageContext_2000',0, async function (done) { - await bundleManager.getApplicationInfo("com.example.contextapp", 0).then(appInfo => { - return globalThis.abilityContext.createBundleContext("com.example.contextapp").resourceManager.getString(appInfo.labelResource) - }).then(str => { - console.info("ACTS_StageContext_2000 labelId: " + str) - expect(str).assertEqual("ContextApp") - done() - }).catch(e => { - console.info("ACTS_StageContext_2000 error: " + e) - expect().assertFail() - done() - }) - }) - - /* - * @tc.number : ACTS_StageContext_2100 - * @tc.name : get resource by Resource in applicationInfo from moduleContext - * @tc.desc : get resource by Resource in applicationInfo from moduleContext - */ - it('ACTS_StageContext_2100',0, async function (done) { - await bundleManager.getApplicationInfo("com.example.contextapp", 0).then(appInfo => { - return globalThis.abilityContext.createModuleContext("com.example.contextapp", "entry").resourceManager.getString(appInfo.labelResource) - }).then(str => { - console.info("ACTS_StageContext_2100 labelId: " + str) - expect(str).assertEqual("ContextApp") - done() - }).catch(e => { - console.info("ACTS_StageContext_2100 error: " + e) - expect().assertFail() - done() - }) - }) - /* * @tc.number : ACTS_StageContext_2200 * @tc.name : get resource by Resource in applicationInfo from context @@ -415,24 +187,5 @@ export default function actsStageContextTest() { done() }) }) - - /* - * @tc.number : ACTS_StageContext_2300 - * @tc.name : get resource by Resource in applicationInfo from context(API8) - * @tc.desc : get resource by Resource in applicationInfo from context(API8) - */ - it('ACTS_StageContext_2300',0, async function (done) { - await bundle.getAbilityInfo("com.example.fa8_app", "com.example.entry.MainAbility").then(abilityInfo => { - return globalThis.abilityContext.createModuleContext("com.example.fa8_app", "entry").resourceManager.getString(abilityInfo.labelId) - }).then(str => { - console.info("ACTS_StageContext_2300 labelId: " + str) - expect(str).assertEqual("fa8_app") - done() - }).catch(e => { - console.info("ACTS_StageContext_2300 error: " + e) - expect().assertFail() - done() - }) - }) }) } \ No newline at end of file -- GitLab