提交 2571a676 编写于 作者: C chengxingzhen

xts签名文件整改

Signed-off-by: Nchengxingzhen <chengxingzhen@huawei.com>
上级 e469f5f4
......@@ -26,8 +26,6 @@ group("ability_runtime") {
"actsabilitymanageretstest:ActsAbilityManagerEtsTest",
"actsabilityusertest:ActsAbilityuserTest",
"actscalldataabilitytest:ActsCallDataAbilityTest",
"actscalldataabilitytest:ActsCallDataAbilityTest",
"actscalltest:actscalltest",
"actsdataabilityaccessdatasharetest:dataabilityaccessdatashare",
"actsfwkdataaccessortest:dataability",
"actsqueryfunctiontest:actsqueryfunctiontest",
......
# 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")
group("actscalltest") {
testonly = true
if (is_standard_system) {
deps = [
"systemcallentrytest:ActsCallTestEntryTest",
]
}
}
{
"app":{
"bundleName":"com.example.systemcalltest",
"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":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsCallTestEntryTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemcallentrytest_js_assets",
":systemcallentrytest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsCallTestEntryTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemcallentrytest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemcallentrytest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemcallentrytest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemcallentrytest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"bundle-name": "com.example.systemcalltest",
"module-name": "com.example.systemcalltest",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
"test-file-name": [
"ActsCallTestEntryTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount"
]
}
]
}
\ 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 AbilityStage from "@ohos.application.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest MyAbilityStage onCreate")
}
}
\ 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'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
export default class MainAbility extends Ability {
test2100(data) {
console.log("SystemCallTest MainAbility test2100 begin");
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
return new MySequenceable(recvData.num + 1, recvData.str + "Main", recvData.result);
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemCallTest MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.callee = this.callee;
this.callee.on('test2100', this.test2100);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemCallTest MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemCallTest MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemCallTest MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemCallTest MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("SystemCallTest MainAbility onBackground")
}
};
/*
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
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')
.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.
*/
@Entry
@Component
struct Index {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('SystemCallTest SecondAbility)')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.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 Ability from '@ohos.application.Ability'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
}
onDestroy() {
console.log('TestAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
windowStage.setUIContent(this.context, 'TestAbility/pages/index', null)
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility 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 router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
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
/*
* 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'
var abilityDelegator = undefined
var 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'
])
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()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.example.systemcalltest.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
/*
* 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 } from "@ohos/hypium"
const ERROR_CODE_INVALID_PARAM = 401;
const ERROR_CODE_FUNC_REGISTERED = 16200004;
const ERROR_CODE_FUNC_NOT_EXIST = 16200005;
export default function abilityTest() {
describe('ActsAbilityTest', function () {
/**
* @tc.number: ACTS_CommonComponent_Call_3100
* @tc.name: The parameter method of the Callee.on function is an empty string.
* @tc.desc: Verify that the parameter method of the Callee.on function is an empty string.
*/
it('ACTS_CommonComponent_Call_3100', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_3100 begin');
function onTest(data) {
console.log('ACTS_CommonComponent_Call_3100 onTest');
}
let finishFlag = 0;
try {
globalThis.callee.on('', onTest);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3100 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/**
* @tc.number: ACTS_CommonComponent_Call_3200
* @tc.name: The parameter method of the Callee.on function is null.
* @tc.desc: Verify that the parameter method of the Callee.on function is null.
*/
it('ACTS_CommonComponent_Call_3200', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_3200 begin');
function onTest(data) {
console.log('ACTS_CommonComponent_Call_3200 onTest');
}
let finishFlag = 0;
try {
globalThis.callee.on(null, onTest);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3200 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/**
* @tc.number: ACTS_CommonComponent_Call_3300
* @tc.name: The parameter method of the Caller.callWithResult function is undefined.
* @tc.desc: Verify that the parameter method of the Caller.callWithResult function is undefined.
*/
it('ACTS_CommonComponent_Call_3300', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_3300 begin');
function onTest(data) {
console.log('ACTS_CommonComponent_Call_3300 onTest');
}
let finishFlag = 0;
try {
globalThis.callee.on(undefined, onTest);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3300 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/**
* @tc.number: ACTS_CommonComponent_Call_3400
* @tc.name: The parameter "method" of the Callee.off function is an empty string.
* @tc.desc: Verify that the parameter "method" of the Callee.off function is an empty string.
*/
it('ACTS_CommonComponent_Call_3400', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_3400 begin');
let finishFlag = 0;
try {
globalThis.callee.off('');
} catch (err) {
console.log('ACTS_CommonComponent_Call_3400 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/**
* @tc.number: ACTS_CommonComponent_Call_3500
* @tc.name: The parameter "method" of the Callee.off function is null.
* @tc.desc: Verify that the parameter "method" of the Callee.off function is null.
*/
it('ACTS_CommonComponent_Call_3500', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_3500 begin');
let finishFlag = 0;
try {
globalThis.callee.off(null);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3500 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/**
* @tc.number: ACTS_CommonComponent_Call_3600
* @tc.name: The parameter “method” of the Callee.off function is undefined.
* @tc.desc: Verify that the parameter “method” of the Callee.off function is undefined.
*/
it('ACTS_CommonComponent_Call_3600', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_3600 begin');
let finishFlag = 0;
try {
globalThis.callee.off(undefined);
} catch (err) {
console.log('ACTS_CommonComponent_Call_3600 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/*
* @tc.number: ACTS_CommonComponent_Call_4300
* @tc.name: Connects a service ability, which is used to start a cloned page ability.
* @tc.desc: Check the event data of executor page ability publishes
*/
it('ACTS_CommonComponent_Call_4300', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_4300 begin');
let finishFlag = 0;
try {
globalThis.callee.on('testCall', "");
} catch (err) {
console.log('ACTS_CommonComponent_Call_4300 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/*
* @tc.number: ACTS_CommonComponent_Call_4400
* @tc.name: Connects a service ability, which is used to start a cloned page ability.
* @tc.desc: Check the event data of executor page ability publishes
*/
it('ACTS_CommonComponent_Call_4400', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_4400 begin');
let finishFlag = 0;
try {
globalThis.callee.on('testCall', null);
} catch (err) {
console.log('ACTS_CommonComponent_Call_4400 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/*
* @tc.number: ACTS_CommonComponent_Call_4500
* @tc.name: Connects a service ability, which is used to start a cloned page ability.
* @tc.desc: Check the event data of executor page ability publishes
*/
it('ACTS_CommonComponent_Call_4500', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_4500 begin');
let finishFlag = 0;
try {
globalThis.callee.on('testCall', undefined);
} catch (err) {
console.log('ACTS_CommonComponent_Call_4500 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_INVALID_PARAM);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
done();
})
/*
* @tc.number: ACTS_CommonComponent_Call_5000
* @tc.name: Connects a service ability, which is used to start a cloned page ability.
* @tc.desc: Check the event data of executor page ability publishes
*/
it('ACTS_CommonComponent_Call_5000', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5000 begin');
let finishFlag = 0;
function testCallback_5100() {
console.log('ACTS_CommonComponent_Call_5000 testCallback');
}
try {
globalThis.callee.on('ACTS_CommonComponent_Call_5000', testCallback_5100);
} catch (err) {
console.log('ACTS_CommonComponent_Call_5000 call err' + err);
expect().assertFail();
globalThis.callee.off('ACTS_CommonComponent_Call_5000');
done();
}
try {
globalThis.callee.on('ACTS_CommonComponent_Call_5000', testCallback_5100);
} catch (err) {
console.log('ACTS_CommonComponent_Call_5000 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_FUNC_REGISTERED);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
globalThis.callee.off('ACTS_CommonComponent_Call_5000');
console.log('ACTS_CommonComponent_Call_5000 finished');
done();
})
/*
* @tc.number: ACTS_CommonComponent_Call_5100
* @tc.name: Connects a service ability, which is used to start a cloned page ability.
* @tc.desc: Check the event data of executor page ability publishes
*/
it('ACTS_CommonComponent_Call_5100', 0, async function (done) {
console.log('ACTS_CommonComponent_Call_5100 begin');
let finishFlag = 0;
function testCallback_5100() {
console.log('ACTS_CommonComponent_Call_5100 testCallback');
}
try {
globalThis.callee.on('ACTS_CommonComponent_Call_5100', testCallback_5100);
globalThis.callee.off('ACTS_CommonComponent_Call_5100');
} catch (err) {
console.log('ACTS_CommonComponent_Call_5100 first step err' + err);
expect().assertFail();
globalThis.callee.off('ACTS_CommonComponent_Call_5100');
done();
}
try {
globalThis.callee.off('ACTS_CommonComponent_Call_5100');
} catch (err) {
console.log('ACTS_CommonComponent_Call_5100 call err.code: ' + JSON.stringify(err.code) +
' err.msg: ' + JSON.stringify(err.message));
expect(err.code).assertEqual(ERROR_CODE_FUNC_NOT_EXIST);
finishFlag = 1;
}
expect(finishFlag).assertEqual(1);
console.log('ACTS_CommonComponent_Call_5100 finished');
done();
})
})
}
\ 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 abilityTest from './Ability.test.ets'
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
{
"module": {
"name": "com.example.systemcalltest",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.systemcalltest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ 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 ServiceExtension from '@ohos.application.ServiceExtensionAbility'
import commonEvent from "@ohos.commonEvent";
import Want from '@ohos.application.Want';
import rpc from '@ohos.rpc';
export default class ServiceAbility extends ServiceExtension {
onCreate(want:Want) {
globalThis.abilityWant = want;
globalThis.serviceContext = this.context
let direction = this.context.config.direction
let pointerDervice = this.context.config.hasPointerDevice
let AbilityInfo = this.context.extensionAbilityInfo.bundleName
console.log('ServiceAbility onCreate, want: ' + want.abilityName);
var CommonEventPublishData = {
parameters: {
"config": direction,
"poniterDevices": pointerDervice,
"AbilityInfo":AbilityInfo
}
}
commonEvent.publish("ExtensionConext_StartAbility", CommonEventPublishData, (err) => {
console.info("ExtensionConext_StartAbility onCreate");
});
}
onRequest(want, startId) {
console.log('ServiceAbility onRequest, want: ' + want.abilityName + ', startId: ' + startId);
console.log('ServiceAbility registerApplicationStateObserver begin');
setTimeout(()=>{
this.context.terminateSelf().then((data) => {
console.info("terminateSelf data = " + JSON.stringify(data));
}).catch((err) => {
console.info("terminateSelf err = " + JSON.stringify(err));
});
}, 3000)
}
onConnect(want) {
console.log('ServiceAbility onConnect, want:' + want.abilityName);
return null;
}
onDisconnect(want) {
console.log('ServiceAbility onDisconnect, want:' + want.abilityName);
}
onDestroy() {
console.log('ServiceAbility onDestroy');
}
}
\ No newline at end of file
......@@ -679,57 +679,6 @@ export default function ApiCoverTest() {
})
})
/*
* @tc.number SUB_AA_FMS_AbilityStage_0200
* @tc.name Start Service and get config.
* @tc.desc Function test
* @tc.level 3
*/
it('SUB_AA_FMS_AbilityStage_0200', 0, async function (done) {
let subscriber = null
let subscribeInfo = {
events: ["ExtensionConext_StartAbility"]
}
function UnSubscribeInfoCallback(err, data) {
console.info("SUB_AA_FMS_AbilityStage_0200===UnSubscribeInfoCallback===")
}
async function SubscribeInfoCallback(err, data) {
console.info("SUB_AA_FMS_AbilityStage_0200===SubscribeInfoCallback===" + JSON.stringify(data))
console.info("SUB_AA_FMS_AbilityStage_0200===serviceContext===" + JSON.stringify(globalThis.serviceContext))
console.info("SUB_AA_FMS_AbilityStage_0200===config===" + JSON.stringify(globalThis.serviceContext.config))
expect(data.parameters["config"]).assertLess(2)
expect(data.parameters["poniterDevices"]).assertFalse()
expect(data.parameters["AbilityInfo"]).assertEqual("com.example.apicoverhaptest")
let direction = globalThis.serviceContext.config.direction
let pointerDervice = globalThis.serviceContext.config.hasPointerDevice
let AbilityInfo = globalThis.serviceContext.extensionAbilityInfo.bundleName
expect(direction).assertLess(2)
expect(pointerDervice).assertFalse()
expect(AbilityInfo).assertEqual("com.example.apicoverhaptest")
commonEvent.unsubscribe(subscriber, UnSubscribeInfoCallback)
await sleep(4000)
done()
}
commonEvent.createSubscriber(subscribeInfo, (err, data) => {
console.info("SUB_AA_FMS_AbilityStage_0200===CreateSubscriberCallback===")
subscriber = data
commonEvent.subscribe(subscriber, SubscribeInfoCallback)
})
let formWant ={
deviceId:"",
bundleName:"com.example.apicoverhaptest",
abilityName:"ServiceAbility",
}
globalThis.abilityContext.startAbility(formWant, (err, data)=>{
if(err.code == 0){
console.info("SUB_AA_FMS_AbilityStage_0200===abilityContext startAbility success===")
}else{
expect().assertFail()
done()
}
})
})
/*
* @tc.number SUB_AA_FMS_AcquireForm_0100
* @tc.name Test startAbility in FormExtensionContext.
......
......@@ -82,14 +82,6 @@
"resource": "$profile:form_config"
}
]
},
{
"name": "ServiceAbility",
"srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts",
"label": "$string:MainAbility_label",
"description": "$string:MainAbility_desc",
"type": "service",
"visible": true
}
],
"requestPermissions":[
......
......@@ -31,11 +31,12 @@ export default class MainAbility3 extends Ability {
}
onDestroy() {
console.info(printLog3 + "onDestroy")
commonEvent.publish(listPush3 + "onDestroy", (err) => {
console.info(printLog3 + listPush3 + "onDestroy");
});
setTimeout(()=>{
console.info(printLog3 + "onDestroy")
}, 1000)
}
onWindowStageCreate(windowStage) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册