提交 b5e954d2 编写于 作者: L lichenchen 提交者: Gitee

Merge branch 'master' of gitee.com:openharmony/xts_acts into master

Signed-off-by: Nlichenchen <lichenchen15@huawei.com>
......@@ -60,7 +60,7 @@
"launchType": "singleton"
}
],
"reqPermissions": [
"requestPermissions": [
{
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
......
......@@ -6,7 +6,8 @@
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default"
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
......
......@@ -6,7 +6,8 @@
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default"
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
......
......@@ -6,7 +6,8 @@
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default"
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
......
......@@ -6,7 +6,8 @@
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default"
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
......
......@@ -21,7 +21,8 @@
"package": "com.example.amsabilitymultiinstanceappe",
"name": ".MyApplication",
"deviceType": [
"default"
"default",
"tablet"
],
"distro": {
"deliveryWithInstall": true,
......
......@@ -37,14 +37,6 @@ export default function actsStServiceAbilityTest() {
done();
}, gSetTimeout);
})
afterAll((done) => {
console.debug('= ACTS_AAAfterAll ====<begin');
setTimeout(function () {
console.debug('= ACTS_AAAfterAll ====<end');
featureAbility.terminateSelf();
done();
}, gSetTimeout);
})
/**
* @tc.number: ACTS_AExecuteShellCommand_0100
......
......@@ -63,14 +63,6 @@ describe('ActsStServiceAbilityTest', function () {
done();
}, gSetTimeout);
})
afterAll((done) => {
console.debug('= ACTS_AafterAll ====<begin');
setTimeout(function () {
console.debug('= ACTS_AafterAll ====<end');
featureAbility.terminateSelf();
done();
}, gSetTimeout);
})
/*
* @tc.number ACTS_AAbilityStartSetting_0100
......
......@@ -21,6 +21,8 @@ group("context") {
"actscreatemodulecontextassist:ActsCreateModuleContextAssist",
"actscreatemodulecontextassistone:ActsCreateModuleContextAssistOne",
"actscreatemodulecontexttest:ActsCreateModuleContextTest",
"actsstageappcontext:actsstageappcontext",
"actsstagecontext:actsstagecontext",
"scene/defpermission:DefPermission",
]
}
......
# Copyright (C) 2022 Huawei Device Co., Ltd.
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
......@@ -11,21 +11,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/ohos_var.gni")
import("//test/xts/tools/build/suite.gni")
group("edm_test_grop") {
group("actsstageappcontext") {
testonly = true
if (is_standard_system) {
deps = [
"TestExtensionAbility_001:ExtensionZeroTest",
"edm_xts_stage:ActsEdmTest",
#"actsstagecontextassistone:ActsStageContextAssistOne",
#"actsstagecontextassisttwo:ActsStageContextAssistTwo",
"actsstageappcontexttest:ActsStageAppContextTest",
]
}
}
group("customization") {
testonly = true
if (is_standard_system) {
deps = [ ":edm_test_grop" ]
}
}
{
"app": {
"bundleName": "com.example.stageappcontexttest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon" : "$media:icon",
"label" : "$string:app_name",
"description" : "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
......@@ -2,7 +2,7 @@
"string": [
{
"name": "app_name",
"value": "ohosProject"
"value": "AbilityStageMonitor"
}
]
}
......@@ -13,31 +13,31 @@
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ExtensionZeroTest") {
ohos_js_hap_suite("ActsStageAppContextTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":extensionZeroTest_js_assets",
":extensionZeroTest_resources",
":stageappcontext_js_assets",
":stageappcontext_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ExtensionZeroTest"
subsystem_name = "customization"
part_name = "enterprise_device_management"
hap_name = "ActsStageAppContextTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("extensionZeroTest_app_profile") {
ohos_app_scope("stageappcontext_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("extensionZeroTest_js_assets") {
ohos_js_assets("stageappcontext_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("extensionZeroTest_resources") {
ohos_resources("stageappcontext_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":extensionZeroTest_app_profile" ]
deps = [ ":stageappcontext_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.stageappcontexttest",
"module-name": "entry_test",
"shell-timeout": "600000",
"testcase-timeout": "15000"
},
"kits": [
{
"test-file-name": [
"ActsStageAppContextTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.info("MyAbilityStageAppContext onCreate")
globalThis.abilityStageContext = this.context
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("ActsStageAppContextTest MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("ActsStageAppContextTest MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("ActsStageAppContextTest MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
console.log("ActsStageAppContextTest MainAbility onWindowStageCreate finish")
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("ActsStageAppContextTest MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("ActsStageAppContextTest MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("ActsStageAppContextTest MainAbility onBackground")
}
};
\ No newline at end of file
......@@ -12,42 +12,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import rpc from '@ohos.rpc';
import ServiceExtension from '@ohos.application.ServiceExtensionAbility'
import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager'
export default class ServiceAbility extends ServiceExtension {
onCreate(want) {
console.log('ActsStageAppContextTest ServiceAbility onCreate, want: ' + want.abilityName);
globalThis.serviceExtenxionAbilityContext = this.context
}
const WANT1 = {
bundleName: "com.example.extensionzerotest",
abilityName: "com.example.extensionzerotest.EnterpriseAdminAbility"
};
const ENTINFO1 = {
name: "company",
description: "edm demo"
};
onRequest(want, startId) {
console.log('ServiceAbility onRequest, want: ' + want.abilityName + ', startId: ' + startId);
}
const SELFWANT = {
bundleName: "com.example.myapplication",
abilityName: "com.example.myapplication.EnterpriseAdminAbility"
};
const SELFHAPNAME = "com.example.myapplication"
const COMPANYNAME2 = "company2"
const DESCRIPTION2 = "edm demo2"
onConnect(want) {
console.log('ActsStageAppContextTest ServiceAbility onConnect, want:' + want.abilityName);
if (want.action == 'StartAbilityPromise') {
console.log('stub SerivceAbilityServer OnConnect start 1');
console.log('=======startAbilityPromise=======');
return new rpc.RemoteObject('ServiceAbility');
}
}
const ENTINFO2 = {
name: "company2",
description: "edm demo2"
};
onDisconnect(want) {
console.log('ActsStageAppContextTest ServiceAbility onDisconnect, want:' + want.abilityName);
}
const DEFAULT_USER_ID = 100;
const TEST_USER_ID = 101;
const ERR_USER_ID = 102;
const SUBSCRIBE_EVENTS: Array<enterpriseDeviceManager.ManagedEvent> = [
enterpriseDeviceManager.ManagedEvent.MANAGED_EVENT_BUNDLE_ADDED,
enterpriseDeviceManager.ManagedEvent.MANAGED_EVENT_BUNDLE_REMOVED
];
const SUBSCRIBE_INVALID_EVENTS: Array<number> = [20,21];
export {
WANT1, ENTINFO1, SELFWANT, SELFHAPNAME, COMPANYNAME2, DESCRIPTION2, ENTINFO2,
DEFAULT_USER_ID, TEST_USER_ID, ERR_USER_ID, SUBSCRIBE_EVENTS, SUBSCRIBE_INVALID_EVENTS
onDestroy() {
console.log('ActsStageAppContextTest ServiceAbility onDestroy');
}
}
\ No newline at end of file
......@@ -12,16 +12,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
let abilityDelegator = undefined
let abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout'
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
......@@ -52,13 +54,14 @@ export default class OpenHarmonyTestRunner implements TestRunner {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var MainAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
globalThis.abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: MainAbilityName,
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
let cmd = 'aa start -d 0 -a MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
......
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -12,26 +12,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from "../../test/List.test.ets"
@Entry
@Component
struct Index {
aboutToAppear(){
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
Text('MainAbility Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
......
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -17,7 +17,7 @@ import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
private content: string = "SecondMainAbility Page"
build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import stageAppContextTest from './StageAppContext.test'
export default function testsuite() {
stageAppContextTest(globalThis.abilityContext)
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, it, expect, beforeAll } from '@ohos/hypium'
let TAG;
export default function stageAppContextTest(abilityContext) {
describe('ActsStageAppContextTest', function () {
beforeAll(async (done) => {
console.log("ActsStageContextPropertiesTest afterAll called");
await abilityContext.startAbility({
bundleName: "com.example.stageappcontexttest",
abilityName: "ServiceAbility",
}).then((data) => {
console.log('ActsStageContextPropertiesTest - ServiceAbility: ' + JSON.stringify(data));
}).catch((err) => {
console.log("ActsStageContextPropertiesTest - ServiceAbility failed: "
+ JSON.stringify(err));
done()
})
setTimeout(function () {
console.log("ActsStageContextPropertiesTest afterAll end");
done();
}, 1000);
})
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0100
* @tc.name: Validating the context obtained by the AbilityContext call
* getApplicationContext can be obtained using createBundleContext
* @tc.desc: Function test
* @tc.level 0
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0100', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0100";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let result = context.createBundleContext('com.example.stageappcontexttest')
let getCacheDir = result.cacheDir
console.log(TAG + 'getCacheDir::' + JSON.stringify(getCacheDir));
expect(getCacheDir).assertEqual('/data/app/el2/100/base/com.example.stageappcontexttest/cache')
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0200
* @tc.name: Validating the context obtained by the AbilityContext call
* getApplicationContext can be obtained using getApplicationContext
* @tc.desc: Function test
* @tc.level 0
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0200', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0200";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let result = context.getApplicationContext()
let getCacheDir = result.cacheDir
console.log(TAG + 'getCacheDir::' + JSON.stringify(getCacheDir));
expect(getCacheDir).assertEqual('/data/storage/el2/base/cache')
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0300
* @tc.name: Verify that the AbilityContext call getApplicationContext
* gets the context using resourceManger
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0300', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0300";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let result = await context.resourceManager.getString(16777219);
console.log(TAG + " result = " + JSON.stringify(result));
expect(result).assertEqual("entry_MainAbility");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0400
* @tc.name: Verify that the AbilityContext call getApplicationContext
* gets the context using applicationInfo
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0400', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0400";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let result = context.applicationInfo.name;
console.log(TAG + " result = " + JSON.stringify(result));
expect(result).assertEqual("com.example.stageappcontexttest");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0500
* @tc.name: Validating the context obtained by the AbilityStageContext call
* getApplicationContext can be obtained using getApplicationContext
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0500', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0500";
console.log(TAG + " --- start");
let context = globalThis.abilityStageContext.getApplicationContext();
let result = context.getApplicationContext()
let getCacheDir = result.cacheDir
console.log(TAG + 'getCacheDir::' + JSON.stringify(getCacheDir));
expect(getCacheDir).assertEqual('/data/storage/el2/base/cache')
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0600
* @tc.name: Verify that the AbilityStageContext call getApplicationContext
* gets the context using applicationInfo
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0600', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0600";
console.log(TAG + " --- start");
let context = globalThis.abilityStageContext.getApplicationContext();
let result = context.applicationInfo.name;
console.log(TAG + " result = " + JSON.stringify(result));
expect(result).assertEqual("com.example.stageappcontexttest");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0700
* @tc.name: Validating the context obtained by the ExtensionContext call
* getApplicationContext can be obtained using createBundleContext
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0700', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0700";
console.log(TAG + " --- start");
let context = globalThis.serviceExtenxionAbilityContext.getApplicationContext();
let result = context.createBundleContext('com.example.stageappcontexttest')
let getCacheDir = result.cacheDir
console.log(TAG + 'getCacheDir::' + JSON.stringify(getCacheDir));
expect(getCacheDir).assertEqual('/data/app/el2/100/base/com.example.stageappcontexttest/cache')
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0800
* @tc.name: Validating the context obtained by the ExtensionContext call
* getApplicationContext can be obtained using getApplicationContext
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0800', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0800";
console.log(TAG + " --- start");
let serviceContext = globalThis.serviceExtenxionAbilityContext.getApplicationContext()
console.log(TAG + "servicecontext" + serviceContext)
let result = serviceContext.getApplicationContext();
console.log(TAG + " result = " + result);
let dir = serviceContext.cacheDir
console.log(TAG + " dir = " + dir);
expect(dir).assertEqual("/data/storage/el2/base/cache");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_0900
* @tc.name: Verify that the ExtensionContext call getApplicationContext
* gets the context using resourceManger
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_0900', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_0900";
console.log(TAG + " --- start");
let serviceContext = globalThis.serviceExtenxionAbilityContext.getApplicationContext();
let result = await serviceContext.resourceManager.getString(16777219);
console.log(TAG + " result = " + result);
expect(result).assertEqual("entry_MainAbility");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_1000
* @tc.name: Verify that the ExtensionContext call getApplicationContext
* gets the context using applicationInfo
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_1000', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_1000";
console.log(TAG + " --- start");
let serviceContext = globalThis.serviceExtenxionAbilityContext.getApplicationContext();
let result = serviceContext.applicationInfo.name;
console.log(TAG + " result = " + result);
expect(result).assertEqual("com.example.stageappcontexttest");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_1100
* @tc.name: Verify that the application-level context call interface
* getApplicationContext gets the context using createBundleContext
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_1100', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_1100";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let context2 = context.getApplicationContext();
let result = context2.createBundleContext("com.example.stageappcontexttest");
let dir = result.cacheDir;
console.log(TAG + " dir = " + dir);
expect(dir).assertEqual("/data/app/el2/100/base/com.example.stageappcontexttest/cache");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_1200
* @tc.name: Verify that the app-level context calls the interface
* getApplicationContext to get the context using getApplicationContext
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_1200', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_1200";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let context2 = context.getApplicationContext();
let result = context2.getApplicationContext();
let dir = result.cacheDir;
console.log(TAG + " dir = " + dir);
expect(dir).assertEqual("/data/storage/el2/base/cache");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_1300
* @tc.name: Verify that the context obtained by the application-level
* context calling interface getApplicationContext can use resourceManger
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_1300', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_1300";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let context2 = context.getApplicationContext();
let result = await context2.resourceManager.getString(16777219);
console.log(TAG + " result = " + result);
expect(result).assertEqual("entry_MainAbility");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_1400
* @tc.name: Verify that the application-level context calling interface
* getApplicationContext gets the context using applicationInfo
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_1400', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_1400";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let context2 = context.getApplicationContext();
let result = context2.applicationInfo.name;
console.log(TAG + " result = " + result);
expect(result).assertEqual("com.example.stageappcontexttest");
done();
});
/**
* @tc.number: SUB_AA_OpenHarmony_ApplicationContext_1500
* @tc.name: Verify that the context obtained by the app-level context
* calling interface getApplicationContext can be obtained using getApplicationContext
* @tc.desc: Function test
* @tc.level 3
*/
it('SUB_AA_OpenHarmony_ApplicationContext_1500', 0, async function (done) {
let TAG = "SUB_AA_OpenHarmony_ApplicationContext_1500";
console.log(TAG + " --- start");
let context = abilityContext.getApplicationContext();
let context2 = context.getApplicationContext();
let result = context2.getApplicationContext();
console.log(TAG + " result = " + JSON.stringify(result));
expect(result.tempDir).assertEqual("/data/storage/el2/base/temp");
expect(result.filesDir).assertEqual("/data/storage/el2/base/files");
expect(result.distributedFilesDir).assertEqual("/data/storage/el2/distributedfiles");
expect(result.databaseDir).assertEqual("/data/storage/el2/database");
expect(result.preferencesDir).assertEqual("/data/storage/el2/base/preferences");
expect(result.bundleCodeDir).assertEqual("/data/storage/el1/bundle");
done();
});
})
}
\ No newline at end of file
{
"module": {
"name": "entry_test",
"type": "entry",
"srcEntrance": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_test_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"name": "ServiceAbility",
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
"label": "$string:form_ServiceAbility_label",
"description": "$string:form_ServiceAbility_desc",
"type": "service"
}
],
"requestPermissions": [
{
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_test_desc",
"value": "description"
},
{
"name": "app_name",
"value": "ActsStageContextPropertiesTest"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "entry_MainAbility"
},
{
"name": "form_ServiceAbility_desc",
"value": "form_description"
},
{
"name": "form_ServiceAbility_label",
"value": "form_label"
}
]
}
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
group("actsstagecontext") {
testonly = true
if (is_standard_system) {
deps = [
"actsstagecontextassistone:ActsStageContextAssistOne",
"actsstagecontextassisttwo:ActsStageContextAssistTwo",
"actsstagecontextpropertiestest:ActsStageContextPropertiesTest",
]
}
}
{
"app": {
"bundleName": "com.example.stagecontextpropertiestest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon" : "$media:icon",
"label" : "$string:app_name",
"description" : "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "ActsStageContextAssistOne"
}
]
}
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsStageContextAssistOne") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":stagecontextassistone_js_assets",
":stagecontextassistone_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsStageContextAssistOne"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("stagecontextassistone_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("stagecontextassistone_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("stagecontextassistone_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":stagecontextassistone_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.info("ActsStageContextAssistOne StageAbility onCreate")
globalThis.abilityStageContextA = this.context;
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.info('ActsStageContextAssistOne MainAbility3 onCreate')
}
onDestroy() {
console.info('ActsStageContextAssistOne MainAbility3 onDestroy')
}
onWindowStageCreate(windowStage) {
console.info('ActsStageContextAssistOne MainAbility3 onWindowStageCreate')
windowStage.setUIContent(this.context, 'pages/index', null)
}
onWindowStageDestroy() {
console.info('ActsStageContextAssistOne MainAbility3 onWindowStageDestroy')
}
onForeground() {
console.info('ActsStageContextAssistOne MainAbility3 onForeground')
globalThis.abilityContextA = this.context
commonEvent.publish("StartMainAbility3_CommonEvent_ContextOne", () => {
console.log("Publish StartMainAbility3_CommonEvent_ContextOne callback")
})
}
onBackground() {
console.info('ActsStageContextAssistOne MainAbility3 onBackground')
}
};
\ No newline at end of file
......@@ -12,32 +12,38 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
struct Index {
aboutToAppear() {
console.info('MainAbility index aboutToAppear')
console.info('start run testcase!!!')
}
@State message: string = 'MainAbility3 Hello'
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(() => {
})
}
.width('100%')
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "feature_assistone",
"type": "feature",
"srcEntrance": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_test_desc",
"mainElement": "MainAbility3",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility3",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"launchType": "specified",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_test_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "feature_MainAbility"
},
{
"name": "app_name",
"value": "ActsStageContextAssistOne"
},
{
"name": "description_application",
"value": "demo for test"
}
]
}
\ No newline at end of file
{
"src": [
"pages/index"
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.actsstagecontextassisttwo",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon" : "$media:icon",
"label" : "$string:app_name",
"description" : "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
{
"string": [
{
"name": "app_name",
"value": "AbilityStageMonitor"
}
]
}
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap_assist_suite("ActsStageContextAssistTwo") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":stagecontextassisttwo_js_assets",
":stagecontextassisttwo_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsStageContextAssistTwo"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("stagecontextassisttwo_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("stagecontextassisttwo_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("stagecontextassisttwo_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":stagecontextassisttwo_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
import commonEvent from '@ohos.commonEvent'
function sleep(delay) {
let start = new Date().getTime();
while (true) {
if (new Date().getTime() - start > delay) {
break;
}
}
}
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.info("ActsStageContextAssistTwo AbilityStage onCreate")
globalThis.abilityStageContextB = this.context
}
onAcceptWant(want) {
console.log("ActsStageContextAssistTwo onAcceptWant called want:" + JSON.stringify(want));
async function publishContext() {
let stageContextJson = {
'cacheDir': globalThis.abilityStageContextB.cacheDir, 'tempDir': globalThis.abilityStageContextB.tempDir,
'filesDir': globalThis.abilityStageContextB.filesDir, 'distributedFilesDir': globalThis.abilityStageContextB.distributedFilesDir,
'databaseDir': globalThis.abilityStageContextB.databaseDir, 'preferencesDir': globalThis.abilityStageContextB.preferencesDir,
'bundleCodeDir': globalThis.abilityStageContextB.bundleCodeDir
};
let stageAppContext = globalThis.abilityStageContextB.getApplicationContext()
let stageAppContextJson = {
'cacheDir': stageAppContext.cacheDir, 'tempDir': stageAppContext.tempDir, 'filesDir': stageAppContext.filesDir,
'distributedFilesDir': stageAppContext.distributedFilesDir, 'databaseDir': stageAppContext.databaseDir,
'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, () => {
console.log("Publish AssistContextTwo_StageAbilityA_Start_CommonEvent callback")
})
}
publishContext()
sleep(500)
let abilityId = want.parameters.startId.toString();
return abilityId;
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
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) {
console.info('ActsStageContextAssistTwo MainAbility4 onCreate')
}
onDestroy() {
console.info('MainAbilityMonitor onDestroy')
}
onWindowStageCreate(windowStage) {
console.info('ActsStageContextAssistTwo MainAbility4 onWindowStageCreate')
windowStage.setUIContent(this.context, 'MainAbility/pages/index', null)
}
onWindowStageDestroy() {
console.info('ActsStageContextAssistTwo MainAbility4 onWindowStageDestroy')
}
async onForeground() {
console.info('ActsStageContextAssistTwo MainAbility4 onForeground')
let contextJson = {
'cacheDir': this.context.cacheDir, 'tempDir': this.context.tempDir, 'filesDir': this.context.filesDir,
'distributedFilesDir': this.context.distributedFilesDir, 'databaseDir': this.context.databaseDir,
'preferencesDir': this.context.preferencesDir, 'bundleCodeDir': this.context.bundleCodeDir
};
let abilityAppContext = this.context.getApplicationContext()
let appContextJson = {
'cacheDir': abilityAppContext.cacheDir, 'tempDir': abilityAppContext.tempDir, 'filesDir': abilityAppContext.filesDir,
'distributedFilesDir': abilityAppContext.distributedFilesDir, 'databaseDir': abilityAppContext.databaseDir,
'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 {
this.context.createBundleContext("com.example.stagecontextpropertiestest")
} catch (error) {
console.log("ActsStageContextAssistTwo createBundleContext is error:" + JSON.stringify(error))
errCode = error.code
}
let commonEventData = {
parameters: {
abilityContextAssistTwo: contextJson,
abilityAppContextAssistTwo: appContextJson,
abilityLabel: result,
abilityBundleContextAssistTwo: bundleContextJson,
abilityAppBundleContextAssistTwo: appBundleContextJson,
abilityBundleContextTest: errCode
}
}
commonEvent.publish("StartMainAbility4_CommonEvent_ContextOne", commonEventData, () => {
console.log("Publish StartMainAbility4_CommonEvent_ContextOne callback")
})
}
onBackground() {
console.info('ActsStageContextAssistTwo MainAbility4 onBackground')
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('MainAbility index aboutToAppear')
console.info('start run testcase!!!')
}
@State message: string = 'MainAbility4 Hello'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(() => {
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "entry_assisttow",
"type": "entry",
"srcEntrance": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_test_desc",
"mainElement": "MainAbility4",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility4",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"launchType": "specified",
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_test_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "entry_MainAbility"
},
{
"name": "app_name",
"value": "ActsStageContextAssistTwo"
},
{
"name": "description_application",
"value": "demo for test"
}
]
}
\ No newline at end of file
{
"src": [
"MainAbility/pages/index"
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.stagecontextpropertiestest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon" : "$media:icon",
"label" : "$string:app_name",
"description" : "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
{
"string": [
{
"name": "app_name",
"value": "AbilityStageMonitor"
}
]
}
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsStageContextPropertiesTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":stagecontextproperties_js_assets",
":stagecontextproperties_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsStageContextPropertiesTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("stagecontextproperties_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("stagecontextproperties_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("stagecontextproperties_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":stagecontextproperties_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.example.stagecontextpropertiestest",
"module-name": "entry_test",
"shell-timeout": "600000",
"testcase-timeout": "15000"
},
"kits": [
{
"test-file-name": [
"ActsStageContextPropertiesTest.hap",
"ActsStageContextAssistOne.hap",
"ActsStageContextAssistTwo.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.info("MyAbilityStageMonitor onCreate")
globalThis.abilityStageContext = this.context
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("ActsStageContextPropertiesTest MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("ActsStageContextPropertiesTest MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("ActsStageContextPropertiesTest MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
console.log("ActsStageContextPropertiesTest MainAbility onWindowStageCreate finish")
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("ActsStageContextPropertiesTest MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("ActsStageContextPropertiesTest MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("ActsStageContextPropertiesTest MainAbility onBackground")
}
};
\ No newline at end of file
......@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
......@@ -13,38 +13,41 @@
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
import commonEvent from '@ohos.commonEvent'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
export default class MainAbility2 extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate");
console.log("ActsStageContextPropertiesTest MainAbility2 onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context
globalThis.abilityContext2 = this.context
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility onDestroy");
console.log("ActsStageContextPropertiesTest MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate");
windowStage.setUIContent(this.context, "pages/index/index", null);
console.log("ActsStageContextPropertiesTest MainAbility2 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/secone/second ", null)
console.log("ActsStageContextPropertiesTest MainAbility2 onWindowStageCreate finish")
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy");
console.log("ActsStageContextPropertiesTest MainAbility2 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground");
console.log("ActsStageContextPropertiesTest MainAbility2 onForeground")
}
onBackground() {
// Ability has back to background
console.log("MainAbility onBackground");
console.log("ActsStageContextPropertiesTest MainAbility2 onBackground")
}
};
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
let abilityDelegator = undefined
let abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
globalThis.abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
let cmd = 'aa start -d 0 -a MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
......@@ -4,7 +4,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
......@@ -13,14 +13,32 @@
* limitations under the License.
*/
import EnterpriseAdminExtensionAbility from '@ohos.EnterpriseAdminExtensionAbility'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
onAdminEnabled() {
console.log('EnterpriseAdminExtensionAbility onAdminEnabled');
@Entry
@Component
struct Index {
aboutToAppear(){
}
onAdminDisabled(){
console.log('EnterpriseAdminExtensionAbility onAdminDisabled');
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('MainAbility Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "SecondMainAbility Page"
build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import stageContextPropertiesTest from './StageContextProperties.test'
export default function testsuite() {
stageContextPropertiesTest(globalThis.abilityContext)
}
\ No newline at end of file
{
"module": {
"name": "entry_test",
"type": "entry",
"srcEntrance": "./ets/Application/MyAbilityStage.ts",
"description": "$string:entry_test_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"uiSyntax": "ets",
"abilities": [
{
"name": "MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
},
{
"name": "MainAbility2",
"srcEntrance": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"requestPermissions": [
{
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "entry_test_desc",
"value": "description"
},
{
"name": "app_name",
"value": "ActsStageContextPropertiesTest"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "entry_MainAbility"
}
]
}
\ No newline at end of file
......@@ -29,7 +29,8 @@
}
],
"deviceType": [
"default"
"default",
"tablet"
],
"distro": {
"deliveryWithInstall": true,
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import { describe, beforeAll, afterEach, it, expect } from "@ohos/hypium"
import rpc from '@ohos.rpc';
import featureAbility from '@ohos.ability.featureAbility';
import wantConstant from '@ohos.ability.wantConstant'
......@@ -22,9 +22,9 @@ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry
export default function ConnectAbilityTest1() {
var TAG = "";
var Tempassert = "";
var abilityDelegator = undefined
let TAG = "";
let Tempassert = "";
let abilityDelegator = undefined
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
......@@ -34,17 +34,19 @@ export default function ConnectAbilityTest1() {
beforeAll(async function (done) {
console.info("FreeInstall_FA_ConnectAbility before all called");
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var cmd = "bm install -p data/test/MockService.hap";
let cmd = "bm install -p data/test/MockService.hap";
console.info("cmd : " + cmd)
console.info(TAG + " abilityDelegator : " + JSON.stringify(abilityDelegator));
abilityDelegator.executeShellCommand(cmd, (err: any, d: any) => {
console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
await sleep(500);
let cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry";
abilityDelegator.executeShellCommand(cmd1, (err: any, d: any) => {
console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
await sleep(500);
let cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files";
abilityDelegator.executeShellCommand(cmd2, (err: any, d: any) => {
console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
done();
......@@ -54,11 +56,12 @@ export default function ConnectAbilityTest1() {
afterEach(async function (done) {
console.info("FreeInstall_FA_ConnectAbility after each called");
Tempassert = ""
if ("FreeInstall_FA_ConnectAbility_1600" === TAG) {
var cmd14 = "bm uninstall -n com.ohos.hag.famanager";
if ("FreeInstall_FA_ConnectAbility_2000" === TAG) {
let cmd14 = "bm uninstall -n com.ohos.hag.famanager";
abilityDelegator.executeShellCommand(cmd14, (err: any, d: any) => {
console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(2000)
}
done();
});
......@@ -113,8 +116,6 @@ export default function ConnectAbilityTest1() {
console.info(msg + "END");
}
/*
* @tc.number FreeInstall_FA_ConnectAbility_1500
* @tc.name The application is not in the foreground,
......@@ -125,11 +126,12 @@ export default function ConnectAbilityTest1() {
it("FreeInstall_FA_ConnectAbility_1500", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1500-------------");
TAG = "FreeInstall_FA_ConnectAbility_1500";
var cmddif = "bm install -p data/test/ConnectDifferentApplication.hap";
let cmddif = "bm install -p data/test/ConnectDifferentApplication.hap";
abilityDelegator.executeShellCommand(cmddif, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
var str = {
await sleep(2000)
let str = {
"want": {
"bundleName": "com.example.different.hmservice",
"abilityName": "MainAbility",
......@@ -141,20 +143,18 @@ export default function ConnectAbilityTest1() {
}).catch((error) => {
console.error(TAG + " startother failed. Cause: " + JSON.stringify(error));
})
setTimeout(async () => {
var request15 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication5.ServiceAbility5",
"moduleName": "myapplication5",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request15);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
}, 500)
let request15 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication5.ServiceAbility5",
"moduleName": "myapplication5",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request15);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_1500-------------");
done();
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1500-------------");
done();
});
/*
......@@ -167,11 +167,12 @@ export default function ConnectAbilityTest1() {
it("FreeInstall_FA_ConnectAbility_1600", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1600-------------");
TAG = "FreeInstall_FA_ConnectAbility_1600";
var cmdmyapp4 = "bm install -p data/test/ConnectFaMyApplication4.hap";
let cmdmyapp4 = "bm install -p data/test/ConnectFaMyApplication4.hap";
abilityDelegator.executeShellCommand(cmdmyapp4, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
var str = {
await sleep(2000)
let str = {
"want": {
"bundleName": "com.example.different.hmservice",
"abilityName": "MainAbility",
......@@ -184,20 +185,18 @@ export default function ConnectAbilityTest1() {
console.error(TAG + " startother failed. Cause: " + JSON.stringify(error));
})
setTimeout(function () {
var request16 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication4.ServiceAbility4",
"moduleName": "myapplication4",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request16);
setTimeout(() => {
expect(Tempassert).assertEqual("onConnect");
}, 500)
let request16 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication4.ServiceAbility4",
"moduleName": "myapplication4",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request16);
setTimeout(() => {
expect(Tempassert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_1600-------------");
done();
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1600-------------");
done();
});
/*
......@@ -209,7 +208,7 @@ export default function ConnectAbilityTest1() {
it("FreeInstall_FA_ConnectAbility_1400", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1400-------------");
TAG = "FreeInstall_FA_ConnectAbility_1400";
var str = {
let str = {
"want": {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication2.MainAbility",
......@@ -222,20 +221,18 @@ export default function ConnectAbilityTest1() {
}).catch((error) => {
console.error(TAG + " startmyapp2 failed. Cause: " + JSON.stringify(error));
})
let request14 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication3",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request14);
setTimeout(() => {
var request14 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication3",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request14);
setTimeout(async () => {
expect(Tempassert).assertEqual("onFailed");
}, 500);
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_1400-------------");
done()
}, 2000)
done();
console.log("------------end FreeInstall_FA_ConnectAbility_1400-------------");
});
/*
......@@ -247,23 +244,22 @@ export default function ConnectAbilityTest1() {
it("FreeInstall_FA_ConnectAbility_1700", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1700-------------");
TAG = "FreeInstall_FA_ConnectAbility_1700";
var cmddif = "bm install -p data/test/ConnectDifferentApplication.hap";
let cmddif = "bm install -p data/test/ConnectDifferentApplication.hap";
await abilityDelegator.executeShellCommand(cmddif, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(2000)
let request17 = {
"bundleName": "com.example.different.hmservice",
"abilityName": "com.example.different.ServiceAbility",
"moduleName": "entry",
}
connectabillity(TAG, request17);
setTimeout(() => {
var request17 = {
"bundleName": "com.example.different.hmservice",
"abilityName": "com.example.different.ServiceAbility",
"moduleName": "entry",
}
connectabillity(TAG, request17);
setTimeout(() => {
expect(Tempassert).assertEqual("onConnect");
}, 500);
expect(Tempassert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_1700-------------");
done();
}, 2000)
console.log("------------end FreeInstall_FA_ConnectAbility_1700-------------");
done();
});
/*
......@@ -275,21 +271,18 @@ export default function ConnectAbilityTest1() {
it("FreeInstall_FA_ConnectAbility_1800", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1800-------------");
TAG = "FreeInstall_FA_ConnectAbility_1800";
setTimeout(async () => {
var request18 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "xxxxx",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request18);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
}, 500)
let request18 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "xxxxx",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request18);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_1800-------------");
done();
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1800-------------");
done();
});
/*
......@@ -301,25 +294,23 @@ export default function ConnectAbilityTest1() {
it("FreeInstall_FA_ConnectAbility_1900", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_1900-------------");
TAG = "FreeInstall_FA_ConnectAbility_1900";
var cmdmyapp5 = "cp data/test/ConnectFaMyApplication5.hap /data/app/el2/100/base/com.ohos.hag.famanager/" +
let cmdmyapp5 = "cp data/test/ConnectFaMyApplication5.hap /data/app/el2/100/base/com.ohos.hag.famanager/" +
"haps/entry/files";
await abilityDelegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
setTimeout(async () => {
var request19 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication3",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request19);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
}, 500)
let request19 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication1.ServiceAbility_feature",
"moduleName": "myapplication3",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
}
connectabillity(TAG, request19);
setTimeout(() => {
expect(Tempassert).assertEqual("onFailed");
console.log("------------end FreeInstall_FA_ConnectAbility_1900-------------");
done();
}, 2000);
console.log("------------end FreeInstall_FA_ConnectAbility_1900-------------");
done();
});
/*
......@@ -331,28 +322,27 @@ export default function ConnectAbilityTest1() {
it("FreeInstall_FA_ConnectAbility_2000", 0, async function (done) {
console.log("------------start FreeInstall_FA_ConnectAbility_2000-------------");
TAG = "FreeInstall_FA_ConnectAbility_2000";
var cmdmyapp5 = "cp data/test/ConnectFaMyApplication5.hap /data/app/el2/100/base/com.ohos.hag.famanager/" +
let cmdmyapp5 = "cp data/test/ConnectFaMyApplication5.hap /data/app/el2/100/base/com.ohos.hag.famanager/" +
"haps/entry/files";
abilityDelegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => {
console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
setTimeout(async () => {
var request20 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication5.ServiceAbility5",
"moduleName": "myapplication5",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
"parameters": {
"name": 1111, "key1": "value1", "site": "nice to meet you!"
},
}
connectabillity(TAG, request20);
setTimeout(() => {
expect(Tempassert).assertEqual("onConnect");
}, 500)
await sleep(1000)
let request20 = {
"bundleName": "com.example.myapplication.hmservice",
"abilityName": "com.example.myapplication5.ServiceAbility5",
"moduleName": "myapplication5",
"flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND,
"parameters": {
"name": 1111, "key1": "value1", "site": "nice to meet you!"
},
}
connectabillity(TAG, request20);
setTimeout(() => {
expect(Tempassert).assertEqual("onConnect");
console.log("------------end FreeInstall_FA_ConnectAbility_2000-------------");
done()
}, 4000)
done();
console.log("------------end FreeInstall_FA_ConnectAbility_2000-------------");
});
}
)
......
......@@ -146,8 +146,8 @@
abilityDelegator.executeShellCommand(cmd14, (err: any, d: any) => {
console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d));
})
await sleep(2000)
}
await sleep(1500);
done();
});
......
......@@ -6,7 +6,8 @@
"description": "$string:hap4_desc",
"mainElement": "Hap4MainAbility1",
"deviceTypes": [
"default"
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
......
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility'
export default {
data: {
title: ''
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('============Start Ability onShow finish');
featureAbility.getWant(
(err, data) => {
data = data;
console.debug("==========data=" + JSON.stringify(data));
if (data.parameters.mykey5[1] == 'test123'){
featureAbility.getWant().then((data) =>{
data = data
setTimeout(function(){
console.debug("==========data2 bundleName is==========="
+ JSON.stringify(data.bundleName));
featureAbility.terminateSelfWithResult(
{
resultCode: 1,
want: data
}
);
},1000);
})
}else{
setTimeout(function(){
console.debug("==========data1 bundleName is==========="
+ JSON.stringify(data.bundleName));
featureAbility.terminateSelfWithResult(
{
resultCode: 1,
want: data
}
);
},1000);
}
}
)
},
onReady() {
console.info('onReady');
},
}
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility'
export default {
data: {
title: ''
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('============Start Ability onShow finish');
featureAbility.getWant(
(err, data) => {
data = data;
console.debug("==========data=" + JSON.stringify(data));
if (data.parameters.mykey5[1] == 'test123'){
featureAbility.getWant().then((data) =>{
data = data
setTimeout(function(){
console.debug("==========data2 bundleName is==========="
+ JSON.stringify(data.bundleName));
featureAbility.terminateSelfWithResult(
{
resultCode: 1,
want: data
}
);
},1000);
})
}else{
setTimeout(function(){
featureAbility.terminateSelfWithResult(
{
resultCode: 1,
want: data
}
);
},800);
}
}
)
},
onReady() {
console.info('onReady');
},
}
......@@ -6,7 +6,8 @@
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default"
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
......
......@@ -6,7 +6,8 @@
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default"
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
......
......@@ -17,8 +17,8 @@
"package": "com.example.actsaccountoperatetest",
"name": ".MyApplication",
"deviceType": [
"tablet",
"default"
"default",
"tablet"
],
"distro": {
"deliveryWithInstall": true,
......@@ -112,4 +112,4 @@
"srcPath": "TestRunner"
}
}
}
\ No newline at end of file
}
......@@ -19,7 +19,8 @@
"mainAbility": ".MainAbility",
"srcPath":"",
"deviceType": [
"phone"
"default",
"tablet"
],
"distro": {
"deliveryWithInstall": true,
......@@ -124,4 +125,4 @@
"srcPath": "TestRunner"
}
}
}
\ No newline at end of file
}
......@@ -19,7 +19,8 @@
"mainAbility": ".MainAbility",
"srcPath":"",
"deviceType": [
"phone"
"default",
"tablet"
],
"distro": {
"deliveryWithInstall": true,
......@@ -128,4 +129,4 @@
"srcPath": "TestRunner"
}
}
}
\ No newline at end of file
}
......@@ -20,7 +20,7 @@ ohos_js_hap_suite("ActsGetAllAccountsNoParameter") {
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsGetAllAccountsNoParameter"
hap_name = "ActsGetAllAccountsNoParameterTest"
subsystem_name = "account"
part_name = "os_account"
}
......
......@@ -10,7 +10,7 @@
"kits": [
{
"test-file-name": [
"ActsGetAllAccountsNoParameter.hap",
"ActsGetAllAccountsNoParameterTest.hap",
"ActsAccountSceneAccessible.hap"
],
"type": "AppInstallKit",
......
......@@ -19,7 +19,8 @@
"mainAbility": ".MainAbility",
"srcPath":"",
"deviceType": [
"phone"
"default",
"tablet"
],
"distro": {
"deliveryWithInstall": true,
......@@ -124,4 +125,4 @@
"srcPath": "TestRunner"
}
}
}
\ No newline at end of file
}
......@@ -19,7 +19,8 @@
"mainAbility": ".MainAbility",
"srcPath":"",
"deviceType": [
"phone"
"default",
"tablet"
],
"distro": {
"deliveryWithInstall": true,
......@@ -124,4 +125,4 @@
"srcPath": "TestRunner"
}
}
}
\ No newline at end of file
}
......@@ -15,12 +15,13 @@ import("//test/xts/tools/lite/build/suite_lite.gni")
lite_component("test_plugin_manager_so") {
target_type = "shared_library"
features =
[ "//foundation/ai/engine/services/server/plugin_manager:plugin_manager" ]
features = [
"//foundation/ai/ai_engine/services/server/plugin_manager:plugin_manager",
]
deps = [
"//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
"//foundation/ai/engine/services/common/platform/dl_operation:dlOperation",
"//foundation/ai/engine/services/common/platform/lock:lock",
"//foundation/ai/engine/services/common/protocol/data_channel:data_channel",
"//foundation/ai/ai_engine/services/common/platform/dl_operation:dlOperation",
"//foundation/ai/ai_engine/services/common/platform/lock:lock",
"//foundation/ai/ai_engine/services/common/protocol/data_channel:data_channel",
]
}
......@@ -37,12 +37,12 @@ hcpptest_suite("ActsAiEngineTest") {
include_dirs = [
"src",
"//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog",
"//foundation/ai/engine/interfaces",
"//foundation/ai/engine/services/common",
"//foundation/ai/engine/services/client",
"//foundation/ai/engine/services/server",
"//foundation/ai/engine/services/algorithmsdk",
"//foundation/ai/engine/services/server/plugin",
"//foundation/ai/ai_engine/interfaces",
"//foundation/ai/ai_engine/services/common",
"//foundation/ai/ai_engine/services/client",
"//foundation/ai/ai_engine/services/server",
"//foundation/ai/ai_engine/services/algorithmsdk",
"//foundation/ai/ai_engine/services/server/plugin",
"//third_party/bounds_checking_function/include",
"//commonlibrary/utils_lite/include",
"//kernel/liteos-a/kernel/include",
......@@ -54,9 +54,9 @@ hcpptest_suite("ActsAiEngineTest") {
]
deps = [
"//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
"//foundation/ai/engine/services/client:client",
"//foundation/ai/engine/services/common/platform/dl_operation:dlOperation",
"//foundation/ai/engine/services/server/plugin_manager:plugin_manager",
"//foundation/ai/ai_engine/services/client:client",
"//foundation/ai/ai_engine/services/common/platform/dl_operation:dlOperation",
"//foundation/ai/ai_engine/services/server/plugin_manager:plugin_manager",
"//foundation/systemabilitymgr/samgr_lite/samgr:samgr",
"//test/xts/acts/ai_lite/ai_engine_posix/base/src/sample:sample_plugin_1_sync",
"//test/xts/acts/ai_lite/ai_engine_posix/base/src/sample:sample_plugin_2_async",
......
......@@ -21,9 +21,9 @@ source_set("syncDemoPluginCode") {
include_dirs = [
"//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog",
"//foundation/ai/engine/services/common",
"//foundation/ai/engine/services/server",
"//foundation/ai/engine/test",
"//foundation/ai/ai_engine/services/common",
"//foundation/ai/ai_engine/services/server",
"//foundation/ai/ai_engine/test",
"//third_party/bounds_checking_function/include",
]
}
......@@ -33,9 +33,7 @@ lite_component("sample_plugin_1_sync") {
cflags = [ "-fPIC" ]
cflags_cc = cflags
features = [ ":syncDemoPluginCode" ]
deps = [
"//foundation/ai/engine/services/common/protocol/data_channel:data_channel",
]
deps = [ "//foundation/ai/ai_engine/services/common/protocol/data_channel:data_channel" ]
}
source_set("asyncDemoPluginCode") {
......@@ -46,9 +44,9 @@ source_set("asyncDemoPluginCode") {
include_dirs = [
"//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog",
"//foundation/ai/engine/services/common",
"//foundation/ai/engine/services/server",
"//foundation/ai/engine/test",
"//foundation/ai/ai_engine/services/common",
"//foundation/ai/ai_engine/services/server",
"//foundation/ai/ai_engine/test",
"//third_party/bounds_checking_function/include",
]
}
......@@ -58,7 +56,5 @@ lite_component("sample_plugin_2_async") {
cflags = [ "-fPIC" ]
cflags_cc = cflags
features = [ ":asyncDemoPluginCode" ]
deps = [
"//foundation/ai/engine/services/common/protocol/data_channel:data_channel",
]
deps = [ "//foundation/ai/ai_engine/services/common/protocol/data_channel:data_channel" ]
}
......@@ -27,11 +27,13 @@ group("arkui") {
"ace_ets_test:ActsAceEtsTest",
"ace_ets_third_test:ActsAceEtsThirdTest",
"ace_ets_web_dev:ActsAceWebDevTest",
"ace_ets_web_dev_three:ActsAceWebDevThreeTest",
"ace_ets_web_dev_two:ActsAceWebDevTwoTest",
"ace_ets_xcomponent:ActsAceXComponentEtsTest",
"ace_js_attribute_api:ActsAceJsApiTest",
"ace_napi_test:ActsAceNapiEtsTest",
"ace_standard:ActsAceStandardTest",
"ace_standard_video:ActsAceStandardVideoTest",
"libuv:libuvTest",
]
}
......@@ -20,7 +20,6 @@ const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct AlphabetIndexerOnSelect {
private value: string[] = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N']
private content: string = "AlphabetIndexer Page"
......
......@@ -21,7 +21,6 @@ const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct CheckBoxGroupSelectAll {
@State isSelect: boolean = true;
......
......@@ -18,7 +18,6 @@ const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct CircleNe {
@State w: string = "100px";
@State h: string = "100px";
......
......@@ -19,7 +19,7 @@ const TAG = 'ets_apiLack_add';
@Entry
@Component
export default struct CommonBackgroundBlurStyle {
struct CommonBackgroundBlurStyle {
@State value: string = ''
aboutToAppear() {
......
......@@ -24,7 +24,7 @@ const TAG = 'ets_apiLack_add';
@Entry
@Component
export default struct Common_ts_ets_apiStaticClear {
struct Common_ts_ets_apiStaticClear {
@StorageLink('varA') varA: number = 2
private label: string = 'count'
@StorageLink('highScore') highScore: number = 0
......
......@@ -19,7 +19,7 @@ const TAG = 'ets_apiLack_add';
@Entry
@Component
export default struct CommonBackgroundBlurStyle {
struct CommonBackgroundBlurStyle {
@State value: string = ''
isEnv:boolean = Environment.EnvProp('accessibilityEnabled', 'default')
......
......@@ -19,7 +19,7 @@ const TAG = 'ets_apiLack_add';
@Entry
@Component
export default struct PanelBackgroundMask {
struct PanelBackgroundMask {
@State mode: PanelMode = PanelMode.Full
@State navBarPosition:PanelMode = PanelMode.Full
aboutToAppear() {
......
......@@ -18,7 +18,6 @@ const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct StackAlignContent {
aboutToAppear() {
......
......@@ -18,7 +18,6 @@ const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct TabsBarPosition {
private controller: TabsController = new TabsController()
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部