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

!9781 补充common下uiextensioncontext

Merge pull request !9781 from kirl75/master
......@@ -242,5 +242,122 @@ export default function appManagerTest() {
done();
})
})
/**
* @tc.number: System_API_Test_App_Manager_1100
* @tc.name: callback form GetProcessMemoryByPid system interface interception test
* @tc.desc: Test the third-party application call GetProcessMemoryByPid will be blocked
* @tc.level 3
*/
it('System_API_Test_App_Manager_1100',0, function (done) {
let TAG = 'System_API_Test_App_Manager_1100';
let pid = 0;
appManager.getProcessMemoryByPid(pid, (err) => {
console.log(TAG + " err.code: " + err.code);
expect(err.code).assertEqual(ERROR_CODE);
done();
});
})
/**
* @tc.number: System_API_Test_App_Manager_1200
* @tc.name: promise form GetProcessMemoryByPid system interface interception test
* @tc.desc: Test the third-party application call GetProcessMemoryByPid will be blocked
* @tc.level 3
*/
it('System_API_Test_App_Manager_1200',0, function (done) {
let TAG = 'System_API_Test_App_Manager_1200';
let pid = 0;
appManager.getProcessMemoryByPid(pid)
.then(err => {
console.log(TAG + ` err->${JSON.stringify(err)}`);
expect().assertFail();
done();
})
.catch(err => {
console.log(TAG + " err.code: " + err.code);
expect(err.code).assertEqual(ERROR_CODE);
done();
})
})
/**
* @tc.number: System_API_Test_App_Manager_1300
* @tc.name: callback form getRunningProcessInfoByBundleName system interface interception test
* @tc.desc: Test the third-party application call getRunningProcessInfoByBundleName will be blocked
* @tc.level 3
*/
it('System_API_Test_App_Manager_1300',0, function (done) {
let TAG = 'System_API_Test_App_Manager_1300';
let bundleName = "com.ohos.application";
appManager.getRunningProcessInfoByBundleName(bundleName, (err) => {
console.log(TAG + " err.code: " + err.code);
expect(err.code).assertEqual(ERROR_CODE);
done();
});
})
/**
* @tc.number: System_API_Test_App_Manager_1400
* @tc.name: promise form getRunningProcessInfoByBundleName system interface interception test
* @tc.desc: Test the third-party application call getRunningProcessInfoByBundleName will be blocked
* @tc.level 3
*/
it('System_API_Test_App_Manager_1400',0, function (done) {
let TAG = 'System_API_Test_App_Manager_1400';
let bundleName = "com.ohos.application";
appManager.getRunningProcessInfoByBundleName(bundleName)
.then(err => {
console.log(TAG + ` err->${JSON.stringify(err)}`);
expect().assertFail();
done();
})
.catch(err => {
console.log(TAG + " err.code: " + err.code);
expect(err.code).assertEqual(ERROR_CODE);
done();
})
})
/**
* @tc.number: System_API_Test_App_Manager_1500
* @tc.name: callback form getRunningProcessInfoByBundleName system interface interception test
* @tc.desc: Test the third-party application call getRunningProcessInfoByBundleName will be blocked
* @tc.level 3
*/
it('System_API_Test_App_Manager_1500',0, function (done) {
let TAG = 'System_API_Test_App_Manager_1500';
let bundleName = "com.ohos.application";
let userId = 100;
appManager.getRunningProcessInfoByBundleName(bundleName, userId, (err) => {
console.log(TAG + " err.code: " + err.code);
expect(err.code).assertEqual(ERROR_CODE);
done();
});
})
/**
* @tc.number: System_API_Test_App_Manager_1600
* @tc.name: promise form getRunningProcessInfoByBundleName system interface interception test
* @tc.desc: Test the third-party application call getRunningProcessInfoByBundleName will be blocked
* @tc.level 3
*/
it('System_API_Test_App_Manager_1600',0, function (done) {
let TAG = 'System_API_Test_App_Manager_1600';
let bundleName = "com.ohos.application";
let userId = 100;
appManager.getRunningProcessInfoByBundleName(bundleName, userId)
.then(err => {
console.log(TAG + ` err->${JSON.stringify(err)}`);
expect().assertFail();
done();
})
.catch(err => {
console.log(TAG + " err.code: " + err.code);
expect(err.code).assertEqual(ERROR_CODE);
done();
})
})
})
}
\ No newline at end of file
......@@ -15,12 +15,13 @@
import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility'
import Logger from '../model/Logger'
import common from '@ohos.app.ability.common';
const TAG: string = '[UIExtAbility]'
export default class UIExtAbility extends UIExtensionAbility {
onCreate() {
Logger.log(TAG, `UIExtAbility onCreate`)
let UiExtensionContext:common.UIExtensionContext = this.context;
}
onForeground() {
......
......@@ -16,7 +16,8 @@
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'
import commonEventManager from '@ohos.commonEventManager'
import Logger from '../model/Logger'
import common from '@ohos.app.ability.common';
let context= getContext(this) as common.UIExtensionContext;
const TAG: string = '[UIExtAbility]'
const sleepTimeOne = 1000;
......@@ -29,6 +30,23 @@ struct Index {
private session: UIExtensionContentSession = storage.get<UIExtensionContentSession>('session');
aboutToAppear() {
let options = {
parameters: {
cacheDir: context.cacheDir,
tempDir: context.tempDir,
filesDir: context.filesDir,
databaseDir: context.databaseDir,
preferencesDir: context.preferencesDir,
bundleCodeDir: context.bundleCodeDir,
distributedFilesDir: context.distributedFilesDir,
stageMode: context.stageMode,
area: context.area,
eventHub: context.eventHub
}
}
commonEventManager.publish('0100_UIExtensionAbilityContext', options, (err) => {
console.log('SUB_AA_Extension_UIServiceExtensionAbility_Context_0100 commonEventManager 0100_UIExtensionAbilityContext');
})
let appearEvent = 'ACTS_UIExtension_AboutToAppear';
let terminateSelfWithResultEvent = 'ACTS_UIExtension_TerminateSelfWithResult';
let sendDataEvent = 'ACTS_UIExtension_SendData';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册