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

!2036 【XTS】【事件通知子系统】ActsAnsCommonSubscriberTest用例修复

Merge pull request !2036 from zhijianwen/master
......@@ -17,7 +17,6 @@ group("wantagent") {
testonly = true
if (is_standard_system) {
deps = [
"sub:ActsAnsCommonSubscriberTest",
"test1:test1",
"test2:test2",
"wantagent1:ActsAnsWantAgentOneTest",
......
# 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_hap("ActsAnsCommonSubscriberTest") {
hap_profile = "./entry/src/main/config.json"
hap_name = "ActsAnsCommonSubscriberTest"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"app": {
"bundleName": "com.example.actsanscommonsubscribertest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 5,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsanscommonsubscribertest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsanscommonsubscribertest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"isVisible": "true",
"launchType": "standard",
"visible": true
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": 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.
*/
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">
发布公共事件
</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 file from '@system.file'
import {Core, ExpectExtend} 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()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
},
onReady() {
console.info('onReady');
},
}
{
"string": [
{
"name": "app_name",
"value": "Sub1"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ 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.
*/
require('./Subscriber.js')
\ 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 Subscriber from '@ohos.commonevent'
import wantAgent from '@ohos.wantAgent';
import { OperationType, Flags } from '@ohos.wantagent';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var commonEventSubscribeInfo;
var commonEventSubscriber;
var WantAgent;
var time = 1000
describe('ActsAnsCommonSubscriberTest', function () {
console.info("===========ActsSubscriberTest start====================>");
//consume
async function getSubscribeInfoCallBack(err, data) {
console.log("============data=========="+JSON.stringify(data))
// expect(data.events[0]).assertEqual("action1");
await Subscriber.subscribe(commonEventSubscriber, subscriberCallBack001);
}
function subscriberCallBack001(err, data) {
console.info("==========================>subscriberCallBack001");
expect(data.event).assertEqual("action1");
expect(data.bundleName).assertEqual("");
expect(data.code).assertEqual(0);
expect(data.data).assertEqual("");
}
//subscribe
function subscribeCallback(err) {
console.debug("==========================>subscribeCallback=======================>");
}
/*
* @tc.number : ActsSubscriberTestUnorder_0100
* @tc.name : verify subscribe and publish : Check subscribe and publish common event data
* @tc.desc : Check the subscriber can receive event "publish_event0100" type of the interface (by Promise)
*/
it('ActsSubscriberTestUnorder_0100', 0, async function (done) {
console.info("===============ActsSubscriberTestUnorder_0100=============================>");
commonEventSubscribeInfo = {
events: ["action1"],
};
await Subscriber.createSubscriber(
commonEventSubscribeInfo
).then(async (data) =>{
console.info("===============ActsSubscriberTestUnorder_0100=========createSubscriber promise"+JSON.stringify(data));
commonEventSubscriber = data;
await data.getSubscribeInfo().then(async (data)=>{
console.info("===============ActsSubscriberTestUnorder_0100=========getSubscribeInfo promise");
await getSubscribeInfoCallBack(data);
});
})
console.info("===============ActsSubscriberTestUnorder_0100==============================>");
done();
setTimeout(function(){
console.debug("====>time out ActsSubscriberTestUnorder_0100====>");
}, time)
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册