提交 aad466e2 编写于 作者: J jiyong

featureability and rpc testcase

Signed-off-by: Njiyong <jiyong@huawei.com>
上级 1205a042
......@@ -16,6 +16,7 @@ import featureAbility from '@ohos.ability.featureAbility'
import wantconstant from '@ohos.ability.wantConstant'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import commonEvent from '@ohos.commonevent'
import wantConstant from '@ohos.ability.wantConstant'
const START_ABILITY_TIMEOUT = 4000;
const TERMINATE_ABILITY_TIMEOUT = 1000;
......@@ -38,6 +39,12 @@ var subscriberInfo_ACTS_StartAbility_0500 = {
var subscriberInfo_ACTS_StartAbility_0600 = {
events: ["ACTS_StartAbility_0600_CommonEvent"],
};
var subscriberInfoStartAbilityTen = {
events: ["ACTS_StartAbility_1000_CommonEvent"],
};
var subscriberInfoStartAbilityThirteen = {
events: ["ACTS_StartAbility_1300_CommonEvent"],
};
var subscriberInfo_ACTS_StartAbilityForResult_0100 = {
events: ["ACTS_StartAbilityForResult_0100_CommonEvent"],
};
......@@ -53,14 +60,14 @@ var subscriberInfo_ACTS_StartAbilityForResult_0400 = {
var subscriberInfo_ACTS_StartAbilityForResult_0500 = {
events: ["ACTS_StartAbilityForResult_0500_CommonEvent"],
};
var subscriberInfo_ACTS_StartAbilityForResult_0600 = {
var subscriberInfoStartAbilityForResultSix = {
events: ["ACTS_StartAbilityForResult_0600_CommonEvent"],
};
var subscriberInfo_ACTS_TerminateAbility_0100 = {
events: ["ACTS_TerminateAbility_0100_CommonEvent",
"ACTS_TerminateAbility_0100_Return"],
};
var subscriberInfo_ACTS_TerminateAbility_0200 = {
var subscriberInfoTerminateAbilityTwo = {
events: ["ACTS_TerminateAbility_0200_CommonEvent",
"ACTS_TerminateAbility_0200_Return"],
};
......@@ -2087,4 +2094,355 @@ describe('ActsFeatureAbilityTest', function () {
console.info('====> ACTS_GetOrCreateLocalDir_0200 =====>')
}, TIMEOUT)
})
/*
* @tc.number ACTS_StartAbility_0700
* @tc.name Configures the wrong abilityname validation
* @tc.desc Function test
* @tc.level 0
*/
it("ACTS_StartAbility_0700",0, async function(done){
console.info("------------------logMessage ACTS_StartAbility_0700-------------------");
try{
let Want = {
deviceId: '',
bundleName: "com.example.startability",
abilityName: "com.example.startability.MainAbilityXXXXX",
}
var StartAbilityParameter = {
want:Want
}
featureAbility.startAbility(StartAbilityParameter,(err,data)=>{
console.log('ACTS_StartAbility_0700 asyncCallback errCode : ' + JSON.stringify(err)
+ " data: " + JSON.stringify(data));
expect(err.code == 2097152).assertTrue();
done();
});
}catch(error){
console.log("ACTS_StartAbility_0700 : error = " + error);
}
});
/*
* @tc.number ACTS_StartAbility_0800
* @tc.name Misconfigured bundlename validation
* @tc.desc Function test
* @tc.level 0
*/
it("ACTS_StartAbility_0800",0, async function(done){
console.info("------------------logMessage startAbilityTest_0300-------------------");
try{
let Want = {
deviceId: '',
bundleName: "com.example.startabilityxxxxx",
abilityName: "com.example.startability.MainAbility",
}
var StartAbilityParameter = {
want:Want
}
featureAbility.startAbility(StartAbilityParameter,(err,data)=>{
console.log('ACTS_StartAbility_0800 asyncCallback errCode : ' + JSON.stringify(err)
+ " data: " + JSON.stringify(data));
expect(err.code == 2097152).assertTrue();
done();
});
}catch(error){
console.log("ACTS_StartAbility_0800 : error = " + error);
}
});
/*
* @tc.number ACTS_StartAbility_0900
* @tc.name Misconfigured deviceid validation
* @tc.desc Function test
* @tc.level 0
*/
it("ACTS_StartAbility_0900",0, async function(done){
console.info("------------------logMessage ACTS_StartAbility_0900-------------------");
try{
let Want = {
deviceId: "43026cb4ca40ce10101834d72731dc8509be1906d30e8d42e86886d2791e82xx",
bundleName: "com.example.startability",
abilityName: "com.example.startability.MainAbility",
}
var StartAbilityParameter = {
want:Want
}
featureAbility.startAbility(StartAbilityParameter,(err,data)=>{
console.log('ACTS_StartAbility_0900 asyncCallback errCode : ' + JSON.stringify(err)
+ " data: " + JSON.stringify(data));
expect(err.code == 2097152).assertTrue();
done();
});
}catch(error){
console.log("ACTS_StartAbility_0900 : error = " + error);
}
});
/*
* @tc.number ACTS_StartAbility_1000
* @tc.name The configured URI is started and the page is not configured
* @tc.desc Function test
* @tc.level 0
*/
it("ACTS_StartAbility_1000",0, async function(done){
console.info("------------------logMessage ACTS_StartAbility_1000-------------------");
try{
var Subscriber;
let id;
function SubscribeCallBack(err, data) {
clearTimeout(id);
expect(data.event).assertEqual("ACTS_StartAbility_1000");
console.debug("====>Subscribe CallBack data:====>" + JSON.stringify(data));
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
done();
}
commonEvent.createSubscriber(subscriberInfoStartAbilityTen).then(async (data) => {
console.debug("====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.debug("====>UnSubscribe CallBack====>");
done();
}
function timeout() {
expect().assertFail();
console.debug('ACTS_StartAbility_1000=====timeout======');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
done();
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
let Want = {
bundleName: "com.example.startability",
abilityName: "com.example.startability.MainAbility",
uri: "xxxxx",
}
var StartAbilityParameter = {
want:Want
}
featureAbility.startAbility(StartAbilityParameter,(err,data)=>{
console.log('ACTS_StartAbility_1000 asyncCallback errCode : ' + JSON.stringify(err)
+ " data: " + JSON.stringify(data));
expect(err.code == 0).assertTrue();
done();
});
}catch(error){
console.log("ACTS_StartAbility_1000 : error = " + error);
}
})
/*
* @tc.number ACTS_StartAbility_1100
* @tc.name Verify the ability of implicitly starting through action without configuring action
* @tc.desc Function test
* @tc.level 0
*/
it("ACTS_StartAbility_1100",0, async function(done){
console.info("------------------logMessage ACTS_StartAbility_1100-------------------");
try{
let Want = {
action: "action.sysxxxtem.homexxxx"
}
var StartAbilityParameter = {
want:Want
}
featureAbility.startAbility(StartAbilityParameter,(err,data)=>{
console.log('ACTS_StartAbility_1100 asyncCallback errCode : ' + JSON.stringify(err)
+ " data: " + JSON.stringify(data));
expect(err.code == 2097152).assertTrue();
done();
});
}catch(error){
console.log("ACTS_StartAbility_1100 : error = " + error);
}
});
/*
* @tc.number ACTS_StartAbility_1200
* @tc.name Verify that the ability without configured entities is started through action and entities
* @tc.desc Function test
* @tc.level 0
*/
it("ACTS_StartAbility_1200",0, async function(done){
console.info("------------------logMessage ACTS_StartAbility_1200-------------------");
try{
let Want = {
action: "action.system.home",
entities: ["entity.system.homexxxxxxxxx"]
}
var StartAbilityParameter = {
want:Want
}
featureAbility.startAbility(StartAbilityParameter,(err,data)=>{
console.log('ACTS_StartAbility_1200 asyncCallback errCode : ' + JSON.stringify(err)
+ " data: " + JSON.stringify(data));
expect(err.code == 2097152).assertTrue();
done();
});
}catch(error){
console.log("ACTS_StartAbility_1200 : error = " + error);
}
});
/*
* @tc.number ACTS_StartAbility_1300
* @tc.name Start ability through action and entities. Entities is configured as an empty array
* @tc.desc Function test
* @tc.level 0
*/
it("ACTS_StartAbility_1300",0, async function(done){
console.info("------------------logMessage ACTS_StartAbility_1300-------------------");
try{
var Subscriber;
let id;
function SubscribeCallBack(err, data) {
clearTimeout(id);
expect(data.event).assertEqual("ACTS_StartAbility_1300_CommonEvent");
console.debug("====>Subscribe CallBack data:====>" + JSON.stringify(data));
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
done();
}
commonEvent.createSubscriber(subscriberInfoStartAbilityThirteen).then(async (data) => {
console.debug("====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.debug("====>UnSubscribe CallBack====>");
done();
}
function timeout() {
expect().assertFail();
console.debug('ACTS_StartAbility_1300=====timeout======');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
done();
}
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
let Want = {
action: "action.system.home",
entities: []
}
var StartAbilityParameter = {
want:Want
}
featureAbility.startAbility(StartAbilityParameter,(err,data)=>{
console.log('ACTS_StartAbility_1300 asyncCallback errCode : ' + JSON.stringify(err)
+ " data: " + JSON.stringify(data));
expect(err.code == 0).assertTrue();
done();
});
}catch(error){
console.log("ACTS_StartAbility_1300 : error = " + error);
}
});
/*
* @tc.number ACTS_StartAbility_1400
* @tc.name Start ability through action and entities, which are configured as strings
* @tc.desc Function test
* @tc.level 0
*/
it("ACTS_StartAbility_1400",0, async function(done){
console.info("------------------logMessage ACTS_StartAbility_1400-------------------");
try{
let Want = {
action: "action.system.home",
entities: 'asdfghj'
}
var StartAbilityParameter = {
want:Want
}
featureAbility.startAbility(StartAbilityParameter,(err,data)=>{
console.log('ACTS_StartAbility_1400 asyncCallback errCode : ' + JSON.stringify(err)
+ " data: " + JSON.stringify(data));
expect(err.code == 2097152).assertTrue();
done();
});
}catch(error){
console.log("ACTS_StartAbility_1400 : error = " + error);
}
});
/*
* @tc.number ACTS_StartAbility_1600
* @tc.name Startability input parameter want is {}
* @tc.desc Function test
* @tc.level 0
*/
it("ACTS_StartAbility_1600",0, async function(done){
console.info("------------------logMessage ACTS_StartAbility_1600-------------------");
try{
let Want = {}
var StartAbilityParameter = {
want:Want
}
featureAbility.startAbility(StartAbilityParameter).then((err,data) => {
console.log('ACTS_StartAbility_1600 asyncCallback errCode : ' + JSON.stringify(err)
+ " data: " + JSON.stringify(data));
expect(data == undefined).assertTrue();
done();
});
}catch(error){
console.log("ACTS_StartAbility_1600 : error = " + error);
}
});
/*
* @tc.number ACTS_StartAbility_1700
* @tc.name The startability input parameter is not configured with want
* @tc.desc Function test
* @tc.level 0
*/
it("ACTS_StartAbility_1700",0, async function(){
console.info("------------------logMessage ACTS_StartAbility_1700-------------------");
try{
var StartAbilityParameter = {}
var promise = await featureAbility.startAbility(StartAbilityParameter);
console.log('ACTS_StartAbility_1700 promise is : ' + JSON.stringify(promise));
}catch(error){
console.log("ACTS_StartAbility_1700 : error = " + error);
}
});
/*
* @tc.number ACTS_StartAbility_1800
* @tc.name The startability input parameter is undefined
* @tc.desc Function test
* @tc.level 0
*/
it("ACTS_StartAbility_1800",0, async function(done){
console.info("------------------logMessage ACTS_StartAbility_1800-------------------");
try{
featureAbility.startAbility(undefined).then((err,data) => {
console.log('ACTS_StartAbility_1800 asyncCallback errCode : ' + JSON.stringify(err)
+ " data: " + JSON.stringify(data));
expect(data == undefined).assertTrue();
done();
});
}catch(error){
console.log("ACTS_StartAbility_1800 : error = " + error);
}
});
})
......@@ -35,6 +35,12 @@ function PublishCallBackFive() {
function PublishCallBackSix() {
console.debug("====>Publish CallBack ACTS_StartAbility_0600_CommonEvent====>");
}
function PublishCallBackTen() {
console.debug("====>Publish CallBack ACTS_StartAbility_1000_CommonEvent====>");
}
function PublishCallBackThirteen() {
console.debug("====>Publish CallBack ACTS_StartAbility_1300_CommonEvent====>");
}
export default {
data: {
......@@ -50,6 +56,8 @@ export default {
commonEvent.publish("ACTS_StartAbility_0400_CommonEvent", PublishCallBackFour);
commonEvent.publish("ACTS_StartAbility_0500_CommonEvent", PublishCallBackFive);
commonEvent.publish("ACTS_StartAbility_0600_CommonEvent", PublishCallBackSix);
commonEvent.publish("ACTS_StartAbility_1000_CommonEvent", PublishCallBackTen);
commonEvent.publish("ACTS_StartAbility_1300_CommonEvent", PublishCallBackThirteen);
},
onReady() {
},
......
......@@ -983,4 +983,70 @@ describe('ActsGetWantTest', function () {
done();
})
})
/*
* @tc.number ACTS_GetWant_2000
* @tc.name Misconfigured bundlename validation
* @tc.desc Function test
* @tc.level 0
*/
it("ACTS_GetWant_2000",0, async function(done){
console.info("------------------start ACTS_GetWant_2000-------------------");
try{
featureAbility.startAbilityForResult({
want:
{
deviceId: "",
bundleName: "com.example.actsgetwantalltesthap",
abilityName: "com.example.actsgetwantalltesthap.MainAbility",
action: "action2",
entities: ["entity1", "entity2"],
type: "MIMETYPE",
uri: "key={true,true,false}",
flags: wantConstant.Flags.FLAG_ABILITY_FORWARD_RESULT,
parameters:
{
mykey0: 0.1,
mykey1: [0.1, 0.2, 0.3],
mykey2: "[1, 2, 3]",
mykey3: "str",
mykey4: [false, true, false],
mykey5: ["str", "!@#$%", "helloopenharmony"],
},
},
},
(err, data) => {
checkOnAbilityResult(data);
done();
})
}catch(error){
console.log("ACTS_GetWant_2000 : error = " + error);
}
console.log('ACTS_GetWant_2000 end');
});
function checkOnAbilityResult(data) {
console.info('====> ACTS_StartAbilityForResult_2000 start ability=====>' + JSON.stringify(data))
expect(data.want.deviceId).assertEqual("");
expect(data.want.bundleName).assertEqual("com.example.actsgetwantalltesthap");
expect(data.want.abilityName).assertEqual("com.example.actsgetwantalltesthap.MainAbility");
expect(data.want.action).assertEqual("action2");
expect(data.want.entities[0]).assertEqual("entity1");
expect(data.want.type).assertEqual("MIMETYPE");
expect(data.want.uri).assertEqual("key={true,true,false}");
expect(data.want.flags).assertEqual(wantConstant.Flags.FLAG_ABILITY_FORWARD_RESULT );
expect(data.want.parameters.mykey0).assertEqual(0.1);
expect(data.want.parameters.mykey1[0]).assertEqual(0.1);
expect(data.want.parameters.mykey1[1]).assertEqual(0.2);
expect(data.want.parameters.mykey1[2]).assertEqual(0.3);
expect(data.want.parameters.mykey2).assertEqual("[1, 2, 3]");
expect(data.want.parameters.mykey3).assertEqual("str");
expect(data.want.parameters.mykey4[0]).assertEqual(false);
expect(data.want.parameters.mykey4[1]).assertEqual(true);
expect(data.want.parameters.mykey4[2]).assertEqual(false);
expect(data.want.parameters.mykey5[0]).assertEqual("str");
expect(data.want.parameters.mykey5[1]).assertEqual("!@#$%");
expect(data.want.parameters.mykey5[2]).assertEqual("helloopenharmony");
console.info('====> before done=====>')
}
})
# 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("//build/ohos_var.gni")
group("dsoftbus") {
testonly = true
if (is_standard_system) {
deps = [ "rpc:ActsRpcJsTest" ]
}
}
# 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")
ohos_js_hap_suite("ActsRpcJsTest") {
hap_profile = "./src/main/config.json"
deps = [
":rpc_js_assets",
":rpc_js_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsRpcHapTest"
}
ohos_js_assets("rpc_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("rpc_js_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for rpc Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "com.ohos.rpctest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsRpcHapTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.ohos.rpctest",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "com.ohos.rpctest",
"name": "com.ohos.rpc.MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.ohos.rpc.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"visible":true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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 app from '@system.app'
import {Core} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ''
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../test/List.test')
core.execute()
},
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.
*/
require('./RpcJsunit.test.js')
\ No newline at end of file
此差异已折叠。
{
"string": [
{
"name": "app_name",
"value": "rpctest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Rpc"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册