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

!7251 xts-系统api下库

Merge pull request !7251 from chengxingzhen/master
......@@ -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, () => {
......
......@@ -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
}
}
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册