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

!2621 【XTS】【事件通知子系统】remove,分布式,AsUser,新增ans自动化

Merge pull request !2621 from fujiarui/OpenHarmony-3.1-Release
......@@ -982,14 +982,13 @@ describe('ActsAnsNotificationRemove', function () {
function onCancelRemoveIsUnremovable(data) {
console.info("==========ANS_Remove_1300 onCancel start================>");
console.info("==========ANS_Remove_1300 onCancel data:================>" + JSON.stringify(data));
expect().assertFail();
console.info("==========ANS_Remove_1300 onCancel end================>");
}
function removeIsUnremovableCallBack(err) {
console.info("==========ANS_Remove_1300 removeCallBack start===================>");
console.info("==========ANS_Remove_1300 removeCallBack err=====================>" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
expect(err.code).assertEqual(0);
console.info("==========ANS_Remove_1300 removeCallBack end=====================>");
}
......@@ -1055,7 +1054,7 @@ describe('ActsAnsNotificationRemove', function () {
console.info("=======ANS_Remove_1400 onConsume remove data:=======>" + JSON.stringify(data));
}).catch((err)=>{
console.info("=======ANS_Remove_1400 onConsume remove err:========>" + JSON.stringify(err));
expect(err.code != 0).assertEqual(true);
expect(err.code).assertEqual(0);
console.info("=======ANS_Remove_1400 onConsume end================>");
});
}
......@@ -1063,7 +1062,6 @@ describe('ActsAnsNotificationRemove', function () {
function OnCancelRemoveIsUnremovablePromise(data) {
console.info("==============ANS_Remove_1400 onCancel start==============>");
console.info("==============ANS_Remove_1400 onCancel data:==============>" + JSON.stringify(data));
expect().assertFail();
console.info("==============ANS_Remove_1400 onCancel end================>");
}
......
......@@ -26,11 +26,15 @@ group("publish_test") {
#"publishcontentype:publishcontentype",
#"subscribe:subscribe",
"activebtn:activebtn",
"actsansdistributedtest:ActsAnsDistributeTest",
"actsansgetallactive:ActsAnsGetAllActiveTestXts",
"ansactscancelgroup:ActsAnsCancelGroupTest",
"ansactsremovegroup:ActsAnsRemoveGroupTest",
"donotdisturbmode:ActsAnsDoNotDisturbTest",
"publish:ActsAnsNotificationPublishXts",
"publishsound:ActsAnsPublishSoundTest",
"publishvibra:ActsAnsPublishVibraTest",
"sub:ActsAnsSubTestXts",
"unsubscribe:ActsAnsUnSubscriberTest",
"wantagent:wantagent",
]
......
# 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("ActsAnsDistributeTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsDistributeTest"
}
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"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "com.example.actsansdistributetest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAnsDistributeTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsansdistributetest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 5,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsansdistributetest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"reqPermissions": [
{
"name": "ohos.permission.NOTIFICATION_CONTROLLER"
}
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsansdistributetest.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
}
}
]
}
}
\ 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">
分布式自动化
</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": "distribute"
},
{
"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('./actsansdistributedtest.js')
\ 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 notify from '@ohos.notification'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var timeout = 1800;
describe('ActsAnsDistributeTest', function () {
/*
* @tc.number: ActsDistribute_test_0100
* @tc.name: enableDistributed()
* @tc.desc: verify the function of enableDistributed,isDistributedEnabled
*/
it('ActsDistribute_test_0100', 0, async function (done) {
await notify.enableDistributed(false,async() => {
await notify.isDistributedEnabled((err,data) => {
console.log("===>ActsDistribute_test_0100 success===>"+err+data)
expect(data).assertEqual(false)
done();
})
})
})
/*
* @tc.number: ActsDistribute_test_0200
* @tc.name: enableDistributedByBundle()
* @tc.desc: verify the function of enableDistributedByBundle,isDistributedEnableByBundle
*/
it('ActsDistribute_test_0200', 0, async function (done) {
await notify.enableDistributedByBundle({
bundle:"com.example.actsansdistributetest"
},true,async() => {
await notify.isDistributedEnableByBundle({
bundle:"com.example.actsansdistributetest",
},(err,data) => {
console.log("===>ActsDistribute_test_0200 success===>"+err+data)
expect(data).assertEqual(true)
done();
})
})
})
/*
* @tc.number: ActsDistribute_test_0300
* @tc.name: getDeviceRemindType()
* @tc.desc: verify the function of getDeviceRemindType
*/
it('ActsDistribute_test_0300', 0, async function (done) {
await notify.getDeviceRemindType((err,data) => {
console.debug("===>ActsDistribute_test_0300===>"+ JSON.stringify(data))
expect(data != notify.DeviceRemindType.IDLE_DONOT_REMIND ).assertEqual(true);
expect(data != notify.DeviceRemindType.IDLE_REMIND).assertEqual(true);
expect(data != notify.DeviceRemindType.ACTIVE_DONOT_REMIND).assertEqual(true);
expect(data).assertEqual(notify.DeviceRemindType.ACTIVE_REMIND);
done();
});
})
/*
* @tc.number: ActsDistribute_test_0400
* @tc.name: publish()
* @tc.desc: verify the function of publish
*/
it('ActsDistribute_test_0400', 0, async function (done) {
function onConsume0100(data) {
console.info("========ActsDistribute_test_0400 onConsume data:=======>" + JSON.stringify(data));
expect(data.request.distributedOption.remindType).assertEqual(3);
expect(data.request.deviceId).assertEqual("");
console.info("========ActsDistribute_test_0400 onConsume data:=======>" + JSON.stringify(data.request.notificationFlags));
expect(JSON.stringify(data.request.notificationFlags)).assertEqual(undefined);
}
await notify.enableDistributed(true);
await notify.enableDistributedSelf(true);
console.info("==================ActsDistribute_test_0400 start==================>");
var subscriber ={
onConsume:onConsume0100,
}
await notify.subscribe(subscriber);
var notificationRequest = {
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test13_title",
text: "test13_text",
additionalText: "test13_additionalText"
}
},
id: 4,
label: "ANS_PublishBasicText_0100",
slotType : notify.SlotType.CONTENT_INFORMATION,
distributedOption:{isDistributed: true, supportDisplayDevices: ["0"], supportOperateDevices: ["0"]}
}
await notify.publish(notificationRequest);
console.info("===========ActsDistribute_test_0400 publish promise========>");
setTimeout((async function(){
console.info("======ActsDistribute_test_0400 setTimeout==============>");
await notify.unsubscribe(subscriber);
console.info("======ActsDistribute_test_0400 setTimeout unsubscribe==>");
done();
}),timeout);
})
/*
* @tc.number: ActsDistribute_test_0500
* @tc.name: onEnabledNotificationChanged()
* @tc.desc: verify the function of onEnabledNotificationChanged
*/
it('ActsDistribute_test_0500', 0, async function (done) {
function onEnabledNotificationChanged001(data){
console.log("===>onEnabledNotificationChanged001 success===>"+JSON.stringify(data))
console.log("===>onEnabledNotificationChanged001 bundle===>"+JSON.stringify(data.bundle))
console.log("===>onEnabledNotificationChanged001 uid===>"+JSON.stringify(data.uid))
console.log("===>onEnabledNotificationChanged001 enable===>"+JSON.stringify(data.enable))
expect(JSON.stringify(data.bundle)).assertEqual("com.example.actsansdistributetest");
expect(JSON.stringify(data.uid)).assertEqual("454231");
expect(JSON.stringify(data.enable)).assertEqual(true);
}
function connectCallbacka() {
console.debug("==>connectCallbacka code==>");
}
var subscriber ={
onConnect:connectCallbacka,
onEnabledNotificationChanged:onEnabledNotificationChanged001,
}
await notify.subscribe(subscriber,async(err)=>{
console.debug("==>subscribeCallback code==>" +err.code);
expect(err.code).assertEqual(0);
await notify.requestEnableNotification((err) => {
console.log("===>ActsDistribute_test_0500 success===>"+err.code)
})
});
setTimeout((async function(){
console.info("======ActsDistribute_test_0500 setTimeout==============>");
await notify.unsubscribe(subscriber);
console.info("======ActsDistribute_test_0500 setTimeout unsubscribe==>");
done();
}),timeout);
})
})
# 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("ActsAnsGetAllActiveTestXts") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsGetAllActiveTestXts"
}
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"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.example.actsansgetallactivetest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAnsGetAllActiveTestXts.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsansgetallactivetest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 5,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsansgetallactivetest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"reqPermissions": [{
"name": "ohos.permission.NOTIFICATION_CONTROLLER"
}],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsansgetallactivetest.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">
currentApp
</text>
<text class="title">
ForGetAllActive
</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": "getAllActive"
},
{
"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('./getAllActive.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 notify from '@ohos.notification'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var time = 500
describe('ActsAnsGetAllActiveTestXts', function () {
console.info("===========ActsAnsGetAllActiveTest start====================>");
function getAllCallback(err, data){
console.log("Ans_GetAllActive_0100 getAllCallback ============>");
var i;
console.log("Ans_GetAllActive_0100 getAllCallback data.length============>"+data.length);
expect(data.length).assertEqual(2);
console.log("Ans_GetAllActive_0100 getAllCallback data============>"+JSON.stringify(data));
for (i = 0; i < data.length; i++) {
if (i == 0){
expect(data[i].content.normal.title).assertEqual("test_title_otherApp");
console.log("=======Ans_GetAllActive_0100 getCallback title=====>"+data[i].content.normal.title)
expect(data[i].content.normal.text).assertEqual("test_text_otherApp");
console.log("=======Ans_GetAllActive_0100 getCallback text========>"+data[i].content.normal.text)
expect(data[i].content.normal.additionalText).assertEqual("test_additionalText_otherApp");
console.log("===Ans_GetAllActive_0100 getCallback text====>"+data[i].content.normal.additionalText)
expect(data[i].id).assertEqual(2);
console.log("============Ans_GetAllActive_0100 getCallback id============>"+data[i].id)
expect(data[i].label).assertEqual("otherApp");
console.log("============Ans_GetAllActive_0100 getCallback label=====>"+data[i].label)
}else if(i == 1){
expect(data[i].content.normal.title).assertEqual("test_title_currentApp");
console.log("======Ans_GetAllActive_0100 getCallback title=========>"+data[i].content.normal.title)
expect(data[i].content.normal.text).assertEqual("test_text_currentApp");
console.log("==========Ans_GetAllActive_0100 getCallback text=======>"+data[i].content.normal.text)
expect(data[i].content.normal.additionalText).assertEqual("test_additionalText_currentApp");
console.log("===Ans_GetAllActive_0100 getCallback text=====>"+data[i].content.normal.additionalText)
expect(data[i].id).assertEqual(1);
console.log("============Ans_GetAllActive_0100 getCallback id============>"+data[i].id)
expect(data[i].label).assertEqual("currentApp_0100");
console.log("============Ans_GetAllActive_0100 getCallback label=====>"+data[i].label)
}
}
}
/*
* @tc.number: Ans_GetAllActive_xts_0100
* @tc.name: getAllActiveNotifications(callback: AsyncCallback<Array<NotificationRequest>>): void;
* @tc.desc: Verify: After the current app and other apps publish two notifications,
get all active notifications in the system(callback)
*/
it('Ans_GetAllActive_xts_0100', 0, async function (done) {
console.debug("===============Ans_GetAllActive_0100 start==================>");
await notify.cancelAll();
var notificationRequestOfOtherApp = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title_otherApp",
text: "test_text_otherApp",
additionalText: "test_additionalText_otherApp"
},
},
id: 2,
label: "otherApp",
}
await notify.publish(notificationRequestOfOtherApp);
console.debug("===============Ans_GetAllActive_0100 publish OtherApp notify end==================>");
var notificationRequestOfCurrentApp = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title_currentApp",
text: "test_text_currentApp",
additionalText: "test_additionalText_currentApp"
},
},
id: 1,
label: "currentApp_0100",
}
await notify.publish(notificationRequestOfCurrentApp);
console.debug("===============Ans_GetAllActive_0100 publish CurrentApp notify end==================>");
notify.getAllActiveNotifications(getAllCallback);
console.debug("===============Ans_GetAllActive_0100 getAllActiveNotifications end==================>");
setTimeout(function(){
console.debug("===============Ans_GetAllActive_0100 setTimeout==================>");
done();
}, time);
})
/*
* @tc.number: Ans_GetAllActive_xts_0200
* @tc.name: getAllActiveNotifications(): Promise<Array<NotificationRequest>>
* @tc.desc: Verify: After the current app and other apps publish two notifications,
get all active notifications in the system(promise)
*/
it('Ans_GetAllActive_xts_0200', 0, async function (done) {
console.debug("===============Ans_GetAllActive_0200 start==================>");
await notify.cancelAll();
var notificationRequestOfOtherApp = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title_otherApp",
text: "test_text_otherApp",
additionalText: "test_additionalText_otherApp"
},
},
id: 2,
label: "otherApp",
}
await notify.publish(notificationRequestOfOtherApp);
console.debug("===============Ans_GetAllActive_0200 publish OtherApp notify end==================>");
var notificationRequestOfCurrentApp = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title_currentApp",
text: "test_text_currentApp",
additionalText: "test_additionalText_currentApp"
},
},
id: 1,
label: "currentApp_0200",
}
await notify.publish(notificationRequestOfCurrentApp);
console.debug("===============Ans_GetAllActive_0200 publish CurrentApp notify end==================>");
var promiseData = await notify.getAllActiveNotifications();
console.debug("===============Ans_GetAllActive_0200 getActiveNotifications end==================>");
expect(promiseData.length).assertEqual(2);
var i;
for (i = 0; i < promiseData.length; i++) {
if (i == 0){
expect(promiseData[i].content.normal.title).assertEqual("test_title_otherApp");
console.log("=======Ans_GetAllActive_0200 title=====>"+promiseData[i].content.normal.title)
expect(promiseData[i].content.normal.text).assertEqual("test_text_otherApp");
console.log("=======Ans_GetAllActive_0200 text========>"+promiseData[i].content.normal.text)
expect(promiseData[i].content.normal.additionalText).assertEqual("test_additionalText_otherApp");
console.log("===Ans_GetAllActive_0200 text====>"+promiseData[i].content.normal.additionalText)
expect(promiseData[i].id).assertEqual(2);
console.log("============Ans_GetAllActive_0200 id============>"+promiseData[i].id)
expect(promiseData[i].label).assertEqual("otherApp");
console.log("============Ans_GetAllActive_0200 label=====>"+promiseData[i].label)
}else if(i == 1){
expect(promiseData[i].content.normal.title).assertEqual("test_title_currentApp");
console.log("====Ans_GetAllActive_0200 title=====>"+promiseData[i].content.normal.title)
expect(promiseData[i].content.normal.text).assertEqual("test_text_currentApp");
console.log("======Ans_GetAllActive_0200 text=====>"+promiseData[i].content.normal.text)
expect(promiseData[i].content.normal.additionalText).assertEqual("test_additionalText_currentApp");
console.log("Ans_GetAllActive_0200 text===>"+promiseData[i].content.normal.additionalText)
expect(promiseData[i].id).assertEqual(1);
console.log("============Ans_GetAllActive_0200 id============>"+promiseData[i].id)
expect(promiseData[i].label).assertEqual("currentApp_0200");
console.log("============Ans_GetAllActive_0200 label=====>"+promiseData[i].label)
}
}
setTimeout(function(){
console.debug("===============Ans_GetAllActive_0200 setTimeout==================>");
done();
}, time);
})
function getAllCallbackThree(err, data){
console.log("Ans_GetAllActive_0300 getAllCallbackThree ============>");
console.log("Ans_GetAllActive_0300 getAllCallbackThree data.length============>"+data.length);
console.log("Ans_GetAllActive_0300 getAllCallbackThree data============>"+JSON.stringify(data));
expect(data.length).assertEqual(1);
var i;
for (i = 0; i < data.length; i++) {
expect(data[i].content.normal.title).assertEqual("test_title_otherApp");
console.log("==========Ans_GetAllActive_0300 getCallback title=========>"+data[i].content.normal.title)
expect(data[i].content.normal.text).assertEqual("test_text_otherApp");
console.log("==========Ans_GetAllActive_0300 getCallback text============>"+data[i].content.normal.text)
expect(data[i].content.normal.additionalText).assertEqual("test_additionalText_otherApp");
console.log("======Ans_GetAllActive_0300 getCallback text=======>"+data[i].content.normal.additionalText)
expect(data[i].id).assertEqual(2);
console.log("============Ans_GetAllActive_0300 getCallback id============>"+data[i].id)
expect(data[i].label).assertEqual("otherApp");
console.log("============Ans_GetAllActive_0300 getCallback label=====>"+data[i].label)
}
}
/*
* @tc.number: Ans_GetAllActive_xts_0300
* @tc.name: getAllActiveNotifications(callback: AsyncCallback<Array<NotificationRequest>>): void;
* @tc.desc: Verify: After the current app and other apps publish two notifications, cancel the notifications
of the current app, get all active notifications in the system(callback)
*/
it('Ans_GetAllActive_xts_0300', 0, async function (done) {
console.debug("===============Ans_GetAllActive_0300 start==================>");
await notify.cancelAll();
var notificationRequestOfOtherApp = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title_otherApp",
text: "test_text_otherApp",
additionalText: "test_additionalText_otherApp"
},
},
id: 2,
label: "otherApp",
}
await notify.publish(notificationRequestOfOtherApp);
console.debug("===============Ans_GetAllActive_0300 publish OtherApp notify end==================>");
var notificationRequestOfCurrentApp = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title_currentApp",
text: "test_text_currentApp",
additionalText: "test_additionalText_currentApp"
},
},
id: 1,
label: "currentApp_0300",
}
await notify.publish(notificationRequestOfCurrentApp);
console.debug("===============Ans_GetAllActive_0300 publish CurrentApp notify end==================>");
await notify.cancel(1, "currentApp_0300");
notify.getAllActiveNotifications(getAllCallbackThree);
console.debug("===============Ans_GetAllActive_0300 getAllActiveNotifications end==================>");
setTimeout(function(){
console.debug("===============Ans_GetAllActive_0300 setTimeout==================>");
done();
}, time);
})
/*
* @tc.number: Ans_GetAllActive_xts_0400
* @tc.name: getAllActiveNotifications(): Promise<Array<NotificationRequest>>;
* @tc.desc: Verify: after publishing two notifications,
cancel one of the notifications, get all active notifications info(promise)
*/
it('Ans_GetAllActive_xts_0400', 0, async function (done) {
console.debug("===============Ans_GetAllActive_0400 start==================>");
await notify.cancelAll();
var notificationRequestOfOtherApp = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title_otherApp",
text: "test_text_otherApp",
additionalText: "test_additionalText_otherApp"
},
},
id: 2,
label: "otherApp",
}
await notify.publish(notificationRequestOfOtherApp);
console.debug("===============Ans_GetAllActive_0400 publish OtherApp notify end==================>");
var notificationRequestOfCurrentApp = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title_currentApp",
text: "test_text_currentApp",
additionalText: "test_additionalText_currentApp"
},
},
id: 1,
label: "currentApp_0400",
}
await notify.publish(notificationRequestOfCurrentApp);
console.debug("===============Ans_GetAllActive_0400 publish CurrentApp notify end==================>");
await notify.cancel(1, "currentApp_0400");
console.debug("===============Ans_GetAllActive_0400 cancel end==================>");
var promiseData = await notify.getAllActiveNotifications();
var i;
for (i = 0; i < promiseData.length; i++) {
expect(promiseData[i].content.normal.title).assertEqual("test_title_otherApp");
console.log("=======Ans_GetAllActive_0400 title=====>"+promiseData[i].content.normal.title)
expect(promiseData[i].content.normal.text).assertEqual("test_text_otherApp");
console.log("=======Ans_GetAllActive_0400 text========>"+promiseData[i].content.normal.text)
expect(promiseData[i].content.normal.additionalText).assertEqual("test_additionalText_otherApp");
console.log("===Ans_GetAllActive_0400 text====>"+promiseData[i].content.normal.additionalText)
expect(promiseData[i].id).assertEqual(2);
console.log("============Ans_GetAllActive_0400 id============>"+promiseData[i].id)
expect(promiseData[i].label).assertEqual("otherApp");
console.log("============Ans_GetAllActive_0400 label=====>"+promiseData[i].label)
}
console.debug("===============Ans_GetAllActive_0400 getAllActiveNotifications end==================>");
setTimeout(function(){
console.debug("===============Ans_GetAllActive_0400 setTimeout==================>");
done();
}, time);
})
function getAllCallbackFive(err, data){
console.log("Ans_GetAllActive_0500 getAllCallbackFive data.length============>"+data.length);
console.log("Ans_GetAllActive_0500 getAllCallbackFive data============>"+JSON.stringify(data));
expect(data.length).assertEqual(0);
}
/*
* @tc.number: Ans_GetAllActive_xts_0500
* @tc.name: getAllActiveNotifications(callback: AsyncCallback<Array<NotificationRequest>>): void;
* @tc.desc: Verify: After the current app and other apps publish two notifications, remove all the notifications
of the system, get all active notifications in the system(callback)
*/
it('Ans_GetAllActive_xts_0500', 0, async function (done) {
console.debug("===============Ans_GetAllActive_0500 start==================>");
await notify.cancelAll();
var notificationRequestOfOtherApp = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title_otherApp",
text: "test_text_otherApp",
additionalText: "test_additionalText_otherApp"
},
},
id: 2,
label: "otherApp",
}
await notify.publish(notificationRequestOfOtherApp);
console.debug("===============Ans_GetAllActive_0500 publish OtherApp notify end==================>");
var notificationRequestOfCurrentApp = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title_currentApp",
text: "test_text_currentApp",
additionalText: "test_additionalText_currentApp"
},
},
id: 1,
label: "currentApp_0500",
}
await notify.publish(notificationRequestOfCurrentApp);
console.debug("===============Ans_GetAllActive_0500 publish CurrentApp notify end==================>");
await notify.removeAll();
notify.getAllActiveNotifications(getAllCallbackFive);
console.debug("===============Ans_GetAllActive_0500 getAllActiveNotifications end==================>");
setTimeout(function(){
console.debug("===============Ans_GetAllActive_0500 setTimeout==================>");
done();
}, time);
})
/*
* @tc.number: Ans_GetAllActive_xts_0600
* @tc.name: getAllActiveNotifications(): Promise<Array<NotificationRequest>>;
* @tc.desc: Verify: After the current app and other apps publish two notifications, remove all the notifications
of the system, get all active notifications in the system(promise)
*/
it('Ans_GetAllActive_xts_0600', 0, async function (done) {
console.debug("===============Ans_GetAllActive_0600 start==================>");
await notify.cancelAll();
var notificationRequestOfOtherApp = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title_otherApp",
text: "test_text_otherApp",
additionalText: "test_additionalText_otherApp"
},
},
id: 2,
label: "otherApp",
}
await notify.publish(notificationRequestOfOtherApp);
console.debug("===============Ans_GetAllActive_0600 publish OtherApp notify end==================>");
var notificationRequestOfCurrentApp = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title_currentApp",
text: "test_text_currentApp",
additionalText: "test_additionalText_currentApp"
},
},
id: 1,
label: "currentApp_0600",
}
await notify.publish(notificationRequestOfCurrentApp);
console.debug("==========Ans_GetAllActive_0600 publish CurrentApp notify end==================>");
await notify.removeAll();
var promiseData = await notify.getAllActiveNotifications();
expect(promiseData.length).assertEqual(0);
console.debug("=======Ans_GetAllActive_0600 promiseData.length==========>"+promiseData.length);
console.debug("=======Ans_GetAllActive_0600 promiseData==========>"+JSON.stringify(promiseData));
setTimeout(function(){
console.debug("===============Ans_GetAllActive_0600 setTimeout==================>");
done();
}, time);
})
function getAllCallbackSeven(err, data){
console.log("Ans_GetAllActive_0700 getAllCallbackSeven data.length============>"+data.length);
console.log("Ans_GetAllActive_0700 getAllCallbackSeven data============>"+JSON.stringify(data));
expect(data.length).assertEqual(0);
}
/*
* @tc.number: Ans_GetAllActive_xts_0700
* @tc.name: getAllActiveNotifications(callback: AsyncCallback<Array<NotificationRequest>>): void;
* @tc.desc: Verify:No active notifications in the system, get all active notifications in the system(callback)
*/
it('Ans_GetAllActive_xts_0700', 0, async function (done) {
console.debug("===============Ans_GetAllActive_0700 start==================>");
await notify.removeAll();
notify.getAllActiveNotifications(getAllCallbackSeven);
console.debug("===============Ans_GetAllActive_0700 getAllActiveNotifications end==================>");
setTimeout(function(){
console.debug("===============Ans_GetAllActive_0700 setTimeout==================>");
done();
}, time);
})
/*
* @tc.number: Ans_GetAllActive_xts_0800
* @tc.name: getAllActiveNotifications(): Promise<Array<NotificationRequest>>;
* @tc.desc: Verify: No active notifications in the system, get all active notifications in the system(promise)
*/
it('Ans_GetAllActive_xts_0800', 0, async function (done) {
console.debug("==========Ans_GetAllActive_0800 start==================>");
await notify.removeAll();
var promiseData = await notify.getAllActiveNotifications();
console.debug("=========Ans_GetAllActive_0800 promiseData.length=============>"+promiseData.length);
expect(promiseData.length).assertEqual(0);
setTimeout(function(){
console.debug("===============Ans_GetAllActive_0800 setTimeout==================>");
done();
}, time);
})
})
# 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("ActsAnsNotificationPublishXts") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsNotificationPublishXts"
}
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"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.example.actsanspublishtest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAnsNotificationPublishXts.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsanspublishtest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 5,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsanspublishtest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsanspublishtest.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">
发布Icon通知
</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": "pubIcon"
},
{
"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('./publish.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 notify from '@ohos.notification'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var timeout = 1000;
describe('ActsAnsNotificationPublishXts', function () {
console.info("===========ActsAnsNotificationPublish start====================>");
function onConsumeA(data) {
console.info("===ACTS_PublishMULTILINEContent_0100 onConsume start===>");
console.info("===ACTS_PublishMULTILINEContent_0100 onConsume data:===>" + JSON.stringify(data));
expect(data.request.label).assertEqual("ACTS_PublishMULTILINEContent_0100");
expect(data.request.creatorUserId).assertEqual(100);
console.info("===ACTS_PublishMULTILINEContent_0100 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishMULTILINEContent_xts_0100
* @tc.name: function publish(request: NotificationRequest, callback: AsyncCallback<void>): void;
* @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_MULTILINE)
*/
it('ACTS_PublishMULTILINEContent_xts_0100', 0, async function (done) {
console.info("===ACTS_PublishMULTILINEContent_0100 start===>");
var subscriber ={
onConsume:onConsumeA
}
await notify.subscribe(subscriber);
console.info("===========ACTS_PublishMULTILINEContent_0100 subscribe promise=======>");
var notificationRequest = {
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_MULTILINE,
multiLine: {
title: "test1_title",
text: "test1_text",
additionalText: "test1_additionalText",
briefText: "briefText1",
longTitle: "longTitle1",
lines: ["thrive", "democracy", "civilization", "harmonious"]
},
},
id: 1,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishMULTILINEContent_0100",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest,(err)=>{
console.info("===ACTS_PublishMULTILINEContent_0100 err===>"+err.code);
});
setTimeout((async function(){
console.info("===ACTS_PublishMULTILINEContent_0100 setTimeout===>");
await notify.unsubscribe(subscriber);
console.info("===ACTS_PublishMULTILINEContent_0100 setTimeout unsubscribe===>");
done();
}),timeout);
})
function onConsumeB(data) {
console.info("===ACTS_PublishMULTILINEContent_0200 onConsume start===>");
console.info("===ACTS_PublishMULTILINEContent_0200 onConsume data:===>" + JSON.stringify(data));
console.info("===ACTS_PublishMULTILINEContent_0200 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishMULTILINEContent_xts_0200
* @tc.name: function publish(request: NotificationRequest, callback: AsyncCallback<void>): void;
* @tc.desc: verify the function of publish()
*/
it('ACTS_PublishMULTILINEContent_xts_0200', 0, async function (done) {
console.info("===ACTS_PublishMULTILINEContent_0200 start===>");
var subscriber ={
onConsume:onConsumeB
}
await notify.subscribe(subscriber);
console.info("===ACTS_PublishMULTILINEContent_0200 subscribe promise===>");
var notificationRequest = {
content:{
// contentType: notify.ContentType.NOTIFICATION_CONTENT_MULTILINE,
multiLine: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText",
briefText: "briefText",
longTitle: "longTitle",
lines: ["thrive", "democracy", "civilization", "harmonious"]
},
},
id: 2,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishMULTILINEContent_0200",
badgeIconStyle: 1,
showDeliveryTime: true,
}
try {
await notify.publish(notificationRequest, (err) => {
console.info("===ACTS_PublishMULTILINEContent_0200 err===>" + err.code);
});
}catch(err){
console.info("===ACTS_PublishMULTILINEContent_0200 err===>" + err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("===ACTS_PublishMULTILINEContent_0200 setTimeout unsubscribe end===>");
done();
}),timeout);
})
function onConsumeC(data) {
console.info("===ANS_Publish_0300 onConsume start===>");
console.info("===ANS_Publish_0300 onConsume data:===>" + JSON.stringify(data));
console.info("===ANS_Publish_0300 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishMULTILINEContent_xts_0300
* @tc.name: function publish(request: NotificationRequest, callback: AsyncCallback<void>): void;
* @tc.desc: verify the function of publish()
*/
it('ACTS_PublishMULTILINEContent_xts_0300', 0, async function (done) {
console.info("===============ACTS_PublishMULTILINEContent_0300 start==========================>");
var subscriber ={
onConsume:onConsumeC
}
await notify.subscribe(subscriber);
console.info("===============ACTS_PublishMULTILINEContent_0300 subscribe promise===============>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_PICTURE,
multiLine: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText",
briefText: "briefText",
longTitle: "longTitle",
lines: ["thrive", "democracy", "civilization", "harmonious"]
},
},
id: 3,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishMULTILINEContent_0300",
badgeIconStyle: 1,
showDeliveryTime: true,
}
try {
await notify.publish(notificationRequest, (err) => {
console.info("==========ACTS_PublishMULTILINEContent_0300 err==================>" + err.code);
});
}catch(err){
console.info("==========ACTS_PublishMULTILINEContent_0300 err==================>" + err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishMULTILINEContent_0300 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeD(data) {
console.info("===ACTS_PublishMULTILINEContent_0400 onConsume===>");
console.info("===ACTS_PublishMULTILINEContent_0400 onConsume data:===>" + JSON.stringify(data));
expect(data.request.label).assertEqual("ACTS_PublishMULTILINEContent_0400");
console.info("===ACTS_PublishMULTILINEContent_0400 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishMULTILINEContent_xts_0400
* @tc.name: function publish(request: NotificationRequest): Promise<void>;
* @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_MULTILINE) promise
*/
it('ACTS_PublishMULTILINEContent_xts_0400', 0, async function (done) {
console.info("===============ACTS_PublishMULTILINEContent_0400 start==========================>");
var subscriber ={
onConsume:onConsumeD
}
await notify.subscribe(subscriber);
console.info("================ACTS_PublishMULTILINEContent_0400 subscribe promise=============>");
var notificationRequest = {
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_MULTILINE,
multiLine: {
title: "test4_title",
text: "test4_text",
additionalText: "test4_additionalText",
briefText: "briefText4",
longTitle: "longTitle4",
lines: ["thrive", "democracy", "civilization", "harmonious"]
},
},
id: 4,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishMULTILINEContent_0400",
badgeIconStyle: 1,
showDeliveryTime: true,
}
notify.publish(notificationRequest).then(console.info("======ACTS_PublishMULTILINEContent_0400 promise==================>"));
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishMULTILINEContent_0400 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeE(data) {
console.info("===ACTS_PublishMULTILINEContent_0500 onConsume start===>");
console.info("===ACTS_PublishMULTILINEContent_0500 onConsume data:===>" + JSON.stringify(data));
console.info("===ACTS_PublishMULTILINEContent_0500 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishMULTILINEContent_xts_0500
* @tc.name: function publish(request: NotificationRequest): Promise<void>;
* @tc.desc: function publish(request: NotificationRequest): Promise<void>;
*/
it('ACTS_PublishMULTILINEContent_xts_0500', 0, async function (done) {
console.info("============ACTS_PublishMULTILINEContent_0500 start==================>");
var subscriber ={
onConsume:onConsumeE
}
await notify.subscribe(subscriber);
console.info("============ACTS_PublishMULTILINEContent_0500 subscribe promise======>");
var notificationRequest = {
content: {
// contentType: notify.ContentType.NOTIFICATION_CONTENT_MULTILINE,
multiLine: {
title: "test5_title",
text: "test5_text",
additionalText: "test5_additionalText",
briefText: "briefText5",
longTitle: "longTitle5",
lines: ["thrive", "democracy", "civilization", "harmonious"]
},
},
id: 5,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishMULTILINEContent_0500",
badgeIconStyle: 1,
showDeliveryTime: true,
}
try{
await notify.publish(notificationRequest)
}catch(err){
console.info("======ACTS_PublishMULTILINEContent_0500 err==================>"+err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishMULTILINEContent_0500 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeF(data) {
console.info("===ACTS_PublishMULTILINEContent_0600 onConsume start===>");
console.info("===ACTS_PublishMULTILINEContent_0600 onConsume data===>" + JSON.stringify(data));
console.info("===ACTS_PublishMULTILINEContent_0600 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishMULTILINEContent_xts_0600
* @tc.name: cancelAll(): Promise<void>;
* @tc.desc: Verify that all notifications are cancelled successfully by calling the
cancelAll(): Promise<void> interface, and then cancel the notification again
*/
it('ACTS_PublishMULTILINEContent_xts_0600', 0, async function (done) {
console.info("===============ACTS_PublishMULTILINEContent_0600 start==========================>");
var subscriber ={
onConsume:onConsumeF
}
await notify.subscribe(subscriber);
console.info("==================ACTS_PublishMULTILINEContent_0600 subscribe promise==================>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_PICTURE,
multiLine: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText",
briefText: "briefText",
longTitle: "longTitle",
lines: ["thrive", "democracy", "civilization", "harmonious"]
},
},
id: 6,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishMULTILINEContent_0600",
badgeIconStyle: 1,
showDeliveryTime: true,
}
try {
await notify.publish(notificationRequest);
}catch(err){
console.info("==================ACTS_PublishMULTILINEContent_0600 err==================>"+err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishMULTILINEContent_0600 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeG(data) {
console.info("===ACTS_PublishLONGContent_0100 onConsume start===>");
console.info("===ACTS_PublishLONGContent_0100 onConsume data: ===>" + JSON.stringify(data));
expect(data.request.label).assertEqual("ACTS_PublishLONGContent_0100");
console.info("===ACTS_PublishLONGContent_0100 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishLONGContent_xts_0100
* @tc.name: function publish(request: NotificationRequest, callback: AsyncCallback<void>): void;
* @tc.desc: function publish(request: NotificationRequest, callback: AsyncCallback<void>): void;
*/
it('ACTS_PublishLONGContent_xts_0100', 0, async function (done) {
console.info("===============ACTS_PublishLONGContent_0100 start==========================>");
var subscriber ={
onConsume:onConsumeG
}
await notify.subscribe(subscriber);
console.info("========ACTS_PublishLONGContent_0100 subscribe promise==================>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_LONG_TEXT,
longText: {
title: "test7_title",
text: "test7_text",
additionalText: "test7_additionalText",
longText:"longText7",
briefText:"briefText7",
expandedTitle:"expandedTitle7"
},
},
id: 7,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : true,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishLONGContent_0100",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest,(err)=>{
console.info("===========ACTS_PublishLONGContent_0100 err==================>"+err.code);
});
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishLONGContent_0100 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeH(data) {
console.info("===ACTS_PublishLONGContent_0200 onConsume start===>");
console.info("===ACTS_PublishLONGContent_0200 onConsume data:===>" + JSON.stringify(data));
console.info("===ACTS_PublishLONGContent_0200 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishLONGContent_xts_0200
* @tc.name: function publish(request: NotificationRequest, callback: AsyncCallback<void>): void;
* @tc.desc: function publish(request: NotificationRequest, callback: AsyncCallback<void>): void;
*/
it('ACTS_PublishLONGContent_xts_0200', 0, async function (done) {
console.info("===============ACTS_PublishLONGContent_0200 start==========================>");
var subscriber ={
onConsume:onConsumeH
}
await notify.subscribe(subscriber);
console.info("==================ACTS_PublishLONGContent_0200 subscribe promise==================>");
var notificationRequest = {
content:{
// contentType: notify.ContentType.NOTIFICATION_CONTENT_LONG_TEXT,
longText: {
title: "test8_title",
text: "test8_text",
additionalText: "test8_additionalText",
longText:"longText8",
briefText:"briefText8",
expandedTitle:"expandedTitle8"
},
},
id: 8,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : true,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishLONGContent_0200",
badgeIconStyle: 1,
showDeliveryTime: true,
}
try{
await notify.publish(notificationRequest,(err)=>{
console.info("=========ACTS_PublishLONGContent_0200 err==================>"+err.code);
});
}catch(err){
console.info("=========ACTS_PublishLONGContent_0200 err==================>"+err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishLONGContent_0200 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeI(data) {
console.info("===ACTS_PublishLONGContent_0300 onConsume start===>");
console.info("===ACTS_PublishLONGContent_0300 onConsume data:===>" + JSON.stringify(data));
console.info("===ACTS_PublishLONGContent_0300 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishLONGContent_xts_0300
* @tc.name: function publish(request: NotificationRequest, callback: AsyncCallback<void>): void;
* @tc.desc: function publish(request: NotificationRequest, callback: AsyncCallback<void>): void;
*/
it('ACTS_PublishLONGContent_xts_0300', 0, async function (done) {
console.info("===============ACTS_PublishLONGContent_0300 start==========================>");
var subscriber ={
onConsume:onConsumeI
}
await notify.subscribe(subscriber);
console.info("==================ACTS_PublishLONGContent_0300 subscribe promise==================>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_MEDIA,
longText: {
title: "test9_title",
text: "test9_text",
additionalText: "test9_additionalText",
longText:"longText9",
briefText:"briefText9",
expandedTitle:"expandedTitle9"
},
},
id: 9,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : true,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishLONGContent_0300",
badgeIconStyle: 1,
showDeliveryTime: true,
}
try {
await notify.publish(notificationRequest,(err)=>{
console.info("==================ACTS_PublishLONGContent_0300 err==================>"+err.code);
});
}catch(err){
console.info("==================ACTS_PublishLONGContent_0300 err==================>"+err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishLONGContent_0300 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeJ(data) {
console.info("===ACTS_PublishLONGContent_0400 onConsume start===>");
console.info("===ACTS_PublishLONGContent_0400 onConsume data:===>" + JSON.stringify(data));
expect(data.request.label).assertEqual("ACTS_PublishLONGContent_0400");
console.info("===ACTS_PublishLONGContent_0400 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishLONGContent_xts_0400
* @tc.name: cancel(id: number, callback: AsyncCallback<void>): void;
* @tc.desc: Verify that when the cancel(id: number, callback: AsyncCallback<void>): void
interface is called, when the id is wrong, no notification information is cancelled at this time
*/
it('ACTS_PublishLONGContent_xts_0400', 0, async function (done) {
console.info("===============ACTS_PublishLONGContent_0400 start==========================>");
var subscriber ={
onConsume:onConsumeJ
}
await notify.subscribe(subscriber);
console.info("================ACTS_PublishLONGContent_0400 subscribe promise==================>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_LONG_TEXT,
longText: {
title: "test10_title",
text: "test10_text",
additionalText: "test10_additionalText",
longText:"longText10",
briefText:"briefText10",
expandedTitle:"expandedTitle10"
},
},
id: 10,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : true,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishLONGContent_0400",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest);
console.info("===========ACTS_PublishLONGContent_0400 publish promise==================>");
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishLONGContent_0400 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeK(data) {
console.info("===ACTS_PublishLONGContent_0500 onConsume start===>");
console.info("===ACTS_PublishLONGContent_0500 onConsume data:===>" + JSON.stringify(data));
console.info("===ACTS_PublishLONGContent_0500 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishLONGContent_xts_0500
* @tc.name: cancel(id: number, callback: AsyncCallback<void>): void;
* @tc.desc: Verify the success of canceling the notification with the notification attribute isUnremovable
being true by calling the cancel(id: number, callback: AsyncCallback<void>): void interface
*/
it('ACTS_PublishLONGContent_xts_0500', 0, async function (done) {
console.info("===============ACTS_PublishLONGContent_0500 start==========================>");
var subscriber ={
onConsume:onConsumeK
}
await notify.subscribe(subscriber);
console.info("===============ACTS_PublishLONGContent_0500 subscribe promise=============>");
var notificationRequest = {
content:{
// contentType: notify.ContentType.NOTIFICATION_CONTENT_LONG_TEXT,
longText: {
title: "test11_title",
text: "test11_text",
additionalText: "test11_additionalText",
longText:"longText11",
briefText:"briefText11",
expandedTitle:"expandedTitle11"
},
},
id: 11,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : true,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishLONGContent_0500",
badgeIconStyle: 1,
showDeliveryTime: true,
}
try {
await notify.publish(notificationRequest);
}catch(err){
console.info("============ACTS_PublishLONGContent_0500 err===========>"+err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishLONGContent_0500 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeL(data) {
console.info("===ACTS_PublishLONGContent_0600 onConsume start===>");
console.info("===ACTS_PublishLONGContent_0600 onConsume data:===>" + JSON.stringify(data));
console.info("===ACTS_PublishLONGContent_0600 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishLONGContent_xts_0600
* @tc.name: cancel(id: number, callback: AsyncCallback<void>): void;
* @tc.desc: Verify that the cancel(id: number, callback: AsyncCallback<void>): void
interface is called twice in a row to cancel the notification
*/
it('ACTS_PublishLONGContent_xts_0600', 0, async function (done) {
console.info("=============ACTS_PublishLONGContent_0600 start==========================>");
var subscriber ={
onConsume:onConsumeL
}
await notify.subscribe(subscriber);
console.info("=============ACTS_PublishLONGContent_0600 subscribe promise==================>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_MEDIA,
longText: {
title: "test12_title",
text: "test12_text",
additionalText: "test12_additionalText",
longText:"longText12",
briefText:"briefText12",
expandedTitle:"expandedTitle12"
},
},
id: 12,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : true,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishLONGContent_0600",
badgeIconStyle: 1,
showDeliveryTime: true,
}
try {
await notify.publish(notificationRequest);
}catch(err){
console.info("========ACTS_PublishLONGContent_0600 err=================>"+err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishLONGContent_0600 setTimeout unsubscribe end==================>");
done();
}),1500);
})
function onConsumeM(data) {
console.info("===ANS_Cancel_1300 onConsume start===>");
console.info("===ANS_Cancel_1300 onConsume data:===>" + JSON.stringify(data));
expect(data.request.label).assertEqual("ACTS_Publish_SlotTypeContent_0100");
console.info("===ANS_Cancel_1300 onConsume end===>");
}
/*
* @tc.number: ACTS_Publish_SlotTypeContent_xts_0100
* @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void;
* @tc.desc: Verify that the cancel notification is successful by calling the
cancel(id: number, label: string, callback: AsyncCallback<void>): void; interface
*/
it('ACTS_Publish_SlotTypeContent_xts_0100', 0, async function (done) {
console.info("===ACTS_Publish_SlotTypeContent_0100 start===>");
var subscriber ={
onConsume:onConsumeM
}
await notify.subscribe(subscriber);
console.info("===ACTS_Publish_SlotTypeContent_0100 subscribe promise===>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 13,
slotType : notify.SlotType.CONTENT_INFORMATION,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_Publish_SlotTypeContent_0100",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest,(err)=>{
console.info("===ACTS_Publish_SlotTypeContent_0100 err===>"+err.code);
});
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("===ACTS_Publish_SlotTypeContent_0100 setTimeout unsubscribe end===>");
done();
}),timeout);
})
function onConsumeN(data) {
console.info("===ACTS_Publish_SlotTypeContent_0200 onConsume start===>");
console.info("===ACTS_Publish_SlotTypeContent_0200 onConsume data:===>" + JSON.stringify(data));
console.info("===ACTS_Publish_SlotTypeContent_0200 onConsume end===>");
}
/*
* @tc.number: ACTS_Publish_SlotTypeContent_xts_0200
* @tc.name: cancel(id: number, label?: string): Promise<void>
* @tc.desc: Verify that the cancel notification is successful by calling the
cancel(id: number, label?: string): Promise<void> interface
*/
it('ACTS_Publish_SlotTypeContent_xts_0200', 0, async function (done) {
console.info("===============ACTS_Publish_SlotTypeContent_0200 start==========================>");
var subscriber ={
onConsume:onConsumeN
}
await notify.subscribe(subscriber);
console.info("==========ACTS_Publish_SlotTypeContent_0200 subscribe promise==================>");
var notificationRequest = {
content:{
// contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 14,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_Publish_SlotTypeContent_0200",
badgeIconStyle: 1,
showDeliveryTime: true,
}
try {
await notify.publish(notificationRequest,(err)=>{
console.info("===============ACTS_Publish_SlotTypeContent_0200 err==============>"+err.code);
});
}catch(err){
console.info("===============ACTS_Publish_SlotTypeContent_0200 err==============>"+err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_Publish_SlotTypeContent_0200 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeO(data) {
console.info("===ACTS_Publish_SlotTypeContent_0300 onConsume start===>");
console.info("===ACTS_Publish_SlotTypeContent_0300 onConsume data:===>" + JSON.stringify(data));
console.info("===ACTS_Publish_SlotTypeContent_0300 onConsume end===>");
}
/*
* @tc.number: ACTS_Publish_SlotTypeContent_xts_0300
* @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void
* @tc.desc: Verify that the notification whose notification property isUnremovable is true is canceled
successfully by calling the cancel(id: number, label: string, callback: AsyncCallback<void>): void interface
*/
it('ACTS_Publish_SlotTypeContent_xts_0300', 0, async function (done) {
console.info("===============ACTS_Publish_SlotTypeContent_0300 start==========================>");
var subscriber ={
onConsume:onConsumeO
}
await notify.subscribe(subscriber);
console.info("=======ACTS_Publish_SlotTypeContent_0300 subscribe promise==================>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 15,
isOngoing : true,
isUnremovable : true,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_Publish_SlotTypeContent_0300",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest,(err)=>{
console.info("===========ACTS_Publish_SlotTypeContent_0300 publish promise=============>"+err.code);
});
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_Publish_SlotTypeContent_0300 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeP(data) {
console.info("===ACTS_Publish_SlotTypeContent_0400 onConsume start===>");
console.info("===ACTS_Publish_SlotTypeContent_0400 onConsume data:===>" + JSON.stringify(data));
expect(data.request.label).assertEqual("ACTS_Publish_SlotTypeContent_0400");
console.info("===ACTS_Publish_SlotTypeContent_0400 onConsume end===>");
}
/*
* @tc.number: ACTS_Publish_SlotTypeContent_xts_0400
* @tc.name: cancel(id: number, label?: string): Promise<void>
* @tc.desc: Verify that the notification whose notification property isUnremovable is true
is canceled successfully by calling the cancel(id: number, label?: string): Promise<void> interface
*/
it('ACTS_Publish_SlotTypeContent_xts_0400', 0, async function (done) {
console.info("===ACTS_Publish_SlotTypeContent_0400 start===>");
var subscriber ={
onConsume:onConsumeP
}
await notify.subscribe(subscriber);
console.info("===ACTS_Publish_SlotTypeContent_0400 subscribe promise===>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 16,
slotType : notify.SlotType.SERVICE_INFORMATION,
isOngoing : true,
isUnremovable : true,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_Publish_SlotTypeContent_0400",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest,(err)=>{
console.info("===ACTS_Publish_SlotTypeContent_0400 err===>"+err.code);
});
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("===ACTS_Publish_SlotTypeContent_0400 setTimeout unsubscribe end===>");
done();
}),timeout);
})
function onConsumeQ(data) {
console.info("===ACTS_Publish_SlotTypeContent_0500 onConsume start===>");
console.info("===ACTS_Publish_SlotTypeContent_0500 onConsume data:===>" + JSON.stringify(data));
expect(data.request.label).assertEqual("ACTS_Publish_SlotTypeContent_0500");
console.info("===ACTS_Publish_SlotTypeContent_0500 onConsume end===>");
}
/*
* @tc.number: ACTS_Publish_SlotTypeContent_xts_0500
* @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void;
* @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback<void>): void
interface is called, the label is wrong and the ID is correct.
*/
it('ACTS_Publish_SlotTypeContent_xts_0500', 0, async function (done) {
console.info("===============ACTS_Publish_SlotTypeContent_0500 start==========================>");
var subscriber ={
onConsume:onConsumeQ
}
await notify.subscribe(subscriber);
console.info("==============ACTS_Publish_SlotTypeContent_0500 subscribe promise==================>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 17,
slotType : notify.SlotType.CONTENT_INFORMATION,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_Publish_SlotTypeContent_0500",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest);
console.info("==============ACTS_Publish_SlotTypeContent_0500 publish promise==================>");
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_Publish_SlotTypeContent_0500 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeR(data) {
console.info("===ACTS_Publish_SlotTypeContent_0600 onConsume start===>");
console.info("===ACTS_Publish_SlotTypeContent_0600 onConsume data:===>" + JSON.stringify(data));
console.info("===ACTS_Publish_SlotTypeContent_0600 onConsume end===>");
}
/*
* @tc.number: ACTS_Publish_SlotTypeContent_xts_0600
* @tc.name: cancel(id: number, label?: string): Promise<void>
* @tc.desc: Verify that the cancel(id: number, label?: string): Promise<void> interface is called,
the label is wrong and the ID is correct.
*/
it('ACTS_Publish_SlotTypeContent_xts_0600', 0, async function (done) {
console.info("===============ACTS_Publish_SlotTypeContent_0600 start==========================>");
var subscriber ={
onConsume:onConsumeR
}
await notify.subscribe(subscriber);
console.info("==============ACTS_Publish_SlotTypeContent_0600 subscribe promise==================>");
var notificationRequest = {
content:{
// contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 18,
slotType : notify.SlotType.CONTENT_INFORMATION,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_Publish_SlotTypeContent_0600",
badgeIconStyle: 1,
showDeliveryTime: true,
}
try {
await notify.publish(notificationRequest);
}catch(err){
console.info("===ACTS_Publish_SlotTypeContent_0600 publish promise===>"+err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_Publish_SlotTypeContent_0600 setTimeout unsubscribe end===>");
done();
}),timeout);
})
function onConsumeS(data) {
console.info("===ACTS_Publish_SlotTypeContent_0700 onConsume start===>");
console.info("===ACTS_Publish_SlotTypeContent_0700 onConsume data:===>" + JSON.stringify(data));
expect(data.request.label).assertEqual("ACTS_Publish_SlotTypeContent_0700");
console.info("===ACTS_Publish_SlotTypeContent_0700 onConsume end===>");
}
/*
* @tc.number: ACTS_Publish_SlotTypeContent_xts_0700
* @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void;
* @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback<void>): void
interface is called, and the label uses empty characters
*/
it('ACTS_Publish_SlotTypeContent_xts_0700', 0, async function (done) {
console.info("===============ACTS_Publish_SlotTypeContent_0700 start==========================>");
var subscriber ={
onConsume:onConsumeS
}
await notify.subscribe(subscriber);
console.info("=============ACTS_Publish_SlotTypeContent_0700 subscribe promise==================>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 19,
// slotType : notify.SlotType.CONTENT_INFORMATION,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_Publish_SlotTypeContent_0700",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest);
console.info("==========ACTS_Publish_SlotTypeContent_0700 publish promise==============>");
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_Publish_SlotTypeContent_0700 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeT(data) {
console.info("===ACTS_Publish_SlotTypeContent_0800 onConsume start===>");
console.info("===ACTS_Publish_SlotTypeContent_0800 onConsume data:===>" + JSON.stringify(data));
expect(data.request.label).assertEqual("ACTS_Publish_SlotTypeContent_0800");
console.info("===ACTS_Publish_SlotTypeContent_0800 onConsume end===>");
}
/*
* @tc.number: ACTS_Publish_SlotTypeContent_xts_0800
* @tc.name: cancel(id: number, label?: string): Promise<void>;
* @tc.desc: Verify that the cancel(id: number, label?: string): Promise<void> interface is called,
and the label uses empty characters
*/
it('ACTS_Publish_SlotTypeContent_xts_0800', 0, async function (done) {
console.info("===============ACTS_Publish_SlotTypeContent_0800 start==========================>");
var subscriber ={
onConsume:onConsumeT
}
await notify.subscribe(subscriber);
console.info("=========ACTS_Publish_SlotTypeContent_0800 subscribe promise==================>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 20,
slotType : notify.SlotType.SERVICE_INFORMATION,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_Publish_SlotTypeContent_0800",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest);
console.info("============ACTS_Publish_SlotTypeContent_0800 publish promise===============>");
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_Publish_SlotTypeContent_0800 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeU(data) {
console.info("===ACTS_PublishSlotTypeOther_0100 onConsume start===>");
console.info("===ACTS_PublishSlotTypeOther_0100 onConsume data:===>" + JSON.stringify(data));
expect(data.request.label).assertEqual("ACTS_PublishSlotTypeOther_0100");
console.info("===ACTS_PublishSlotTypeOther_0100 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishSlotTypeOther_xts_0100
* @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void;
* @tc.desc: Verify that the cancel notification is successful by calling the
cancel(id: number, label: string, callback: AsyncCallback<void>): void; interface
*/
it('ACTS_PublishSlotTypeOther_xts_0100', 0, async function (done) {
console.info("===ACTS_PublishSlotTypeOther_0100 start===>");
var subscriber ={
onConsume:onConsumeU
}
await notify.subscribe(subscriber);
console.info("===ACTS_PublishSlotTypeOther_0100 subscribe promise===>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 13,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishSlotTypeOther_0100",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest,(err)=>{
console.info("===ACTS_PublishSlotTypeOther_0100 err===>"+err.code);
});
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("===ACTS_PublishSlotTypeOther_0100 setTimeout unsubscribe end===>");
done();
}),timeout);
})
function onConsumeV(data) {
console.info("===ACTS_PublishSlotTypeOther_0200 onConsume start===>");
console.info("===ACTS_PublishSlotTypeOther_0200 onConsume data:===>" + JSON.stringify(data));
console.info("===ACTS_PublishSlotTypeOther_0200 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishSlotTypeOther_xts_0200
* @tc.name: cancel(id: number, label?: string): Promise<void>
* @tc.desc: Verify that the cancel notification is successful by calling the
cancel(id: number, label?: string): Promise<void> interface
*/
it('ACTS_PublishSlotTypeOther_xts_0200', 0, async function (done) {
console.info("===============ACTS_PublishSlotTypeOther_0200 start==========================>");
var subscriber ={
onConsume:onConsumeV
}
await notify.subscribe(subscriber);
console.info("==========ACTS_PublishSlotTypeOther_0200 subscribe promise==================>");
var notificationRequest = {
content:{
// contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 14,
slotType : notify.SlotType.OTHER_TYPES,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishSlotTypeOther_0200",
badgeIconStyle: 1,
showDeliveryTime: true,
}
try {
await notify.publish(notificationRequest,(err)=>{
console.info("===============ACTS_PublishSlotTypeOther_0200 err==============>"+err.code);
});
}catch(err){
console.info("===============ACTS_PublishSlotTypeOther_0200 err==============>"+err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeOther_0200 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeW(data) {
console.info("===ACTS_PublishSlotTypeOther_0300 onConsume start===>");
console.info("===ACTS_PublishSlotTypeOther_0300 onConsume data:===>" + JSON.stringify(data));
console.info("===ACTS_PublishSlotTypeOther_0300 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishSlotTypeOther_xts_0300
* @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void
* @tc.desc: Verify that the notification whose notification property isUnremovable is true is canceled
successfully by calling the cancel(id: number, label: string, callback: AsyncCallback<void>): void interface
*/
it('ACTS_PublishSlotTypeOther_xts_0300', 0, async function (done) {
console.info("===============ACTS_PublishSlotTypeOther_0300 start==========================>");
var subscriber ={
onConsume:onConsumeW
}
await notify.subscribe(subscriber);
console.info("=======ACTS_PublishSlotTypeOther_0300 subscribe promise==================>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 15,
isOngoing : true,
isUnremovable : true,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishSlotTypeOther_0300",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest,(err)=>{
console.info("===========ACTS_PublishSlotTypeOther_0300 err=============>"+err.code);
});
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeOther_0300 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeX(data) {
console.info("===ACTS_PublishSlotTypeOther_0400 onConsume start===>");
console.info("===ACTS_PublishSlotTypeOther_0400 onConsume data:===>" + JSON.stringify(data));
expect(data.request.label).assertEqual("ACTS_PublishSlotTypeOther_0400");
console.info("===ACTS_PublishSlotTypeOther_0400 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishSlotTypeOther_xts_0400
* @tc.name: cancel(id: number, label?: string): Promise<void>
* @tc.desc: Verify that the notification whose notification property isUnremovable is true
is canceled successfully by calling the cancel(id: number, label?: string): Promise<void> interface
*/
it('ACTS_PublishSlotTypeOther_xts_0400', 0, async function (done) {
console.info("===ACTS_PublishSlotTypeOther_0400 start===>");
var subscriber ={
onConsume:onConsumeX
}
await notify.subscribe(subscriber);
console.info("===ACTS_PublishSlotTypeOther_0400 subscribe promise===>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 16,
slotType : notify.SlotType.SERVICE_INFORMATION,
isOngoing : true,
isUnremovable : true,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishSlotTypeOther_0400",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest,(err)=>{
console.info("===ACTS_PublishSlotTypeOther_0400 err===>"+err.code);
});
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("===ACTS_PublishSlotTypeOther_0400 setTimeout unsubscribe end===>");
done();
}),timeout);
})
function onConsumeY(data) {
console.info("===ACTS_PublishSlotTypeOther_0500 onConsume start===>");
console.info("===ACTS_PublishSlotTypeOther_0500 onConsume data:===>" + JSON.stringify(data));
expect(data.request.label).assertEqual("ACTS_PublishSlotTypeOther_0500");
console.info("===ACTS_PublishSlotTypeOther_0500 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishSlotTypeOther_xts_0500
* @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void;
* @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback<void>): void
interface is called, the label is wrong and the ID is correct.
*/
it('ACTS_PublishSlotTypeOther_xts_0500', 0, async function (done) {
console.info("===============ACTS_PublishSlotTypeOther_0500 start==========================>");
var subscriber ={
onConsume:onConsumeY
}
await notify.subscribe(subscriber);
console.info("==============ACTS_PublishSlotTypeOther_0500 subscribe promise==================>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 17,
slotType : notify.SlotType.CONTENT_INFORMATION,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishSlotTypeOther_0500",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest);
console.info("==============ACTS_PublishSlotTypeOther_0500 publish promise==================>");
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeOther_0500 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeZ(data) {
console.info("===ACTS_PublishSlotTypeOther_0600 onConsume start===>");
console.info("===ACTS_PublishSlotTypeOther_0600 onConsume data:===>" + JSON.stringify(data));
console.info("===ACTS_PublishSlotTypeOther_0600 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishSlotTypeOther_xts_0600
* @tc.name: cancel(id: number, label?: string): Promise<void>
* @tc.desc: Verify that the cancel(id: number, label?: string): Promise<void> interface is called,
the label is wrong and the ID is correct.
*/
it('ACTS_PublishSlotTypeOther_xts_0600', 0, async function (done) {
console.info("===============ACTS_PublishSlotTypeOther_0600 start==========================>");
var subscriber ={
onConsume:onConsumeZ
}
await notify.subscribe(subscriber);
console.info("==============ACTS_PublishSlotTypeOther_0600 subscribe promise==================>");
var notificationRequest = {
content:{
// contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 18,
slotType : notify.SlotType.CONTENT_INFORMATION,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishSlotTypeOther_0600",
badgeIconStyle: 1,
showDeliveryTime: true,
}
try {
await notify.publish(notificationRequest);
}catch(err){
console.info("===ACTS_PublishSlotTypeOther_0600 publish promise===>"+err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeOther_0600 setTimeout unsubscribe end===>");
done();
}),timeout);
})
function onConsumea(data) {
console.info("===ACTS_PublishSlotTypeOther_0700 onConsume start===>");
console.info("===ACTS_PublishSlotTypeOther_0700 onConsume data:===>" + JSON.stringify(data));
expect(data.request.label).assertEqual("ACTS_PublishSlotTypeOther_0700");
console.info("===ACTS_PublishSlotTypeOther_0700 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishSlotTypeOther_xts_0700
* @tc.name: cancel(id: number, label: string, callback: AsyncCallback<void>): void;
* @tc.desc: Verify that the cancel(id: number, label: string, callback: AsyncCallback<void>): void
interface is called, and the label uses empty characters
*/
it('ACTS_PublishSlotTypeOther_xts_0700', 0, async function (done) {
console.info("===============ACTS_PublishSlotTypeOther_0700 start==========================>");
var subscriber ={
onConsume:onConsumea
}
await notify.subscribe(subscriber);
console.info("=============ACTS_PublishSlotTypeOther_0700 subscribe promise==================>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 19,
// slotType : notify.SlotType.CONTENT_INFORMATION,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishSlotTypeOther_0700",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest);
console.info("==========ACTS_PublishSlotTypeOther_0700 publish promise==============>");
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeOther_0700 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function onConsumeb(data) {
console.info("===ACTS_PublishSlotTypeOther_0800 onConsume start===>");
console.info("===ACTS_PublishSlotTypeOther_0800 onConsume data:===>" + JSON.stringify(data));
expect(data.request.label).assertEqual("ACTS_PublishSlotTypeOther_0800");
console.info("===ACTS_PublishSlotTypeOther_0800 onConsume end===>");
}
/*
* @tc.number: ACTS_PublishSlotTypeOther_xts_0800
* @tc.name: cancel(id: number, label?: string): Promise<void>;
* @tc.desc: Verify that the cancel(id: number, label?: string): Promise<void> interface is called,
and the label uses empty characters
*/
it('ACTS_PublishSlotTypeOther_xts_0800', 0, async function (done) {
console.info("===============ACTS_PublishSlotTypeOther_0800 start==========================>");
var subscriber ={
onConsume:onConsumeb
}
await notify.subscribe(subscriber);
console.info("=========ACTS_PublishSlotTypeOther_0800 subscribe promise==================>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
id: 20,
slotType : notify.SlotType.SERVICE_INFORMATION,
isOngoing : true,
isUnremovable : false,
deliveryTime : 1624950453,
tapDismissed : true,
autoDeletedTime: 1625036817,
color: 2,
colorEnabled: true,
isAlertOnce: true,
isStopwatch: true,
isCountDown: true,
progressValue: 12,
progressMaxValue: 100,
isIndeterminate: true,
statusBarText: "statusBarText",
isFloatingIcon : true,
label: "ACTS_PublishSlotTypeOther_0800",
badgeIconStyle: 1,
showDeliveryTime: true,
}
await notify.publish(notificationRequest);
console.info("============ACTS_PublishSlotTypeOther_0800 publish promise===============>");
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeOther_0800 setTimeout unsubscribe end==================>");
done();
}),timeout);
})
function publishSlotSocialCallback001(error){
console.log('=========ACTS_PublishSlotTypeSocial_0100 publish callback==========>'+JSON.stringify(error.code));
}
function onConsume0100(data){
console.info("===========ACTS_PublishSlotTypeSocial_0100 onConsume start===========>");
console.info("===========ACTS_PublishSlotTypeSocial_0100 onConsume data:===========>" + JSON.stringify(data));
expect(data.request.content.normal.title).assertEqual("test37_title");
console.info("===========ACTS_PublishSlotTypeSocial_0100 onConsume end=============>");
}
/*
* @tc.number: ACTS_PublishSlotTypeSocial_xts_0100
* @tc.name: publish()
* @tc.desc: verify publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:SOCIAL_COMMUNICATION)
*/
it('ACTS_PublishSlotTypeSocial_xts_0100', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeSocial_0100================>");
var subscriber ={
onConsume:onConsume0100
}
await notify.subscribe(subscriber);
console.info("===============ACTS_PublishSlotTypeSocial_0100 subscribe======>");
await notify.publish({
id: 37,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test37_title",
text: "test37_text",
additionalText: "test37_additionalText"
},
slotType:notify.SlotType.SOCIAL_COMMUNICATION
}
},publishSlotSocialCallback001);
console.info("==========ACTS_PublishSlotTypeSocial_0100 publish======>");
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeSocial_0100 setTimeout unsubscribe===>");
done();
}),timeout);
});
function publishSlotSocialCallback002(error){
console.log('=========ACTS_PublishSlotTypeSocial_0200 publish callback==========>'+JSON.stringify(error.code));
}
function onConsume0200(data){
console.info("===========ACTS_PublishSlotTypeSocial_0200 onConsume start===========>");
console.info("===========ACTS_PublishSlotTypeSocial_0200 onConsume data:===========>" + JSON.stringify(data));
expect().assertFail();
console.info("===========ACTS_PublishSlotTypeSocial_0200 onConsume end=============>");
}
/*
* @tc.number: ACTS_PublishSlotTypeSocial_xts_0200
* @tc.name: publish()
* @tc.desc: verify the function of publish(slotType:SOCIAL_COMMUNICATION)
*/
it('ACTS_PublishSlotTypeSocial_xts_0200', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeSocial_0200================>");
var subscriber ={
onConsume:onConsume0200
}
await notify.subscribe(subscriber);
try {
await notify.publish({
id: 38,
content: {
// contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
slotType: notify.SlotType.SOCIAL_COMMUNICATION
}
}, publishSlotSocialCallback002);
}catch(err){
console.info("==========ACTS_PublishSlotTypeSocial_0200 publish======>"+err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeSocial_0200 setTimeout unsubscribe===>");
done();
}),timeout);
});
function publishSlotSocialCallback003(error){
console.log('=========ACTS_PublishSlotTypeSocial_0300 publish callback==========>'+JSON.stringify(error.code));
}
function onConsume0300(data){
console.info("===========ACTS_PublishSlotTypeSocial_0300 onConsume start===========>");
console.info("===========ACTS_PublishSlotTypeSocial_0300 onConsume data:===========>" + JSON.stringify(data));
expect(data.request.content.normal.title).assertEqual("test39_title");
console.info("===========ACTS_PublishSlotTypeSocial_0300 onConsume end=============>");
}
/*
* @tc.number: ACTS_PublishSlotTypeSocial_xts_0300
* @tc.name: publish()
* @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT)
*/
it('ACTS_PublishSlotTypeSocial_xts_0300', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeSocial_0300================>");
var subscriber ={
onConsume:onConsume0300
}
await notify.subscribe(subscriber);
await notify.publish({
id: 39,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test39_title",
text: "test39_text",
additionalText: "test39_additionalText"
},
// slotType:notification.SlotType.SOCIAL_COMMUNICATION
}
},publishSlotSocialCallback003);
console.info("==========ACTS_PublishSlotTypeSocial_0300 publish======>");
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeSocial_0300 setTimeout unsubscribe===>");
done();
}),timeout);
});
function publishSlotSocialCallback004(error){
console.log('=========ACTS_PublishSlotTypeSocial_0400 publish callback==========>'+JSON.stringify(error.code));
}
function onConsume0400(data){
console.info("===========ACTS_PublishSlotTypeSocial_0400 onConsume start===========>");
console.info("===========ACTS_PublishSlotTypeSocial_0400 onConsume data:===========>" + JSON.stringify(data));
expect(data.request.content.normal.title).assertEqual("test40_title");
console.info("===========ACTS_PublishSlotTypeSocial_0400 onConsume end=============>");
}
/*
* @tc.number: ACTS_PublishSlotTypeSocial_xts_0400
* @tc.name: publish()
* @tc.desc: verify the publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:CONTENT_INFORMATION)
*/
it('ACTS_PublishSlotTypeSocial_xts_0400', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeSocial_0400================>");
var subscriber ={
onConsume:onConsume0400
}
await notify.subscribe(subscriber);
await notify.publish({
id: 40,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test40_title",
text: "test40_text",
additionalText: "test40_additionalText"
},
slotType:notify.SlotType.CONTENT_INFORMATION
}
},publishSlotSocialCallback004);
console.info("==========ACTS_PublishSlotTypeSocial_0400 publish======>");
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeSocial_0400 setTimeout unsubscribe===>");
done();
}),timeout);
});
function onConsume0500(data){
console.info("===========ACTS_PublishSlotTypeSocial_0500 onConsume start===========>");
console.info("===========ACTS_PublishSlotTypeSocial_0500 onConsume data:===========>" + JSON.stringify(data));
expect(data.request.content.normal.title).assertEqual("test41_title");
console.info("===========ACTS_PublishSlotTypeSocial_0500 onConsume end=============>");
}
/*
* @tc.number: ACTS_PublishSlotTypeSocial_xts_0500
* @tc.name: publish()
* @tc.desc: verify publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:SOCIAL_COMMUNICATION) promise
*/
it('ACTS_PublishSlotTypeSocial_xts_0500', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeSocial_0500================>");
var subscriber ={
onConsume:onConsume0500
}
await notify.subscribe(subscriber);
notify.publish({
id: 41,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test41_title",
text: "test41_text",
additionalText: "test41_additionalText"
},
slotType:notify.SlotType.SOCIAL_COMMUNICATION
}
}).then(console.info("==========ACTS_PublishSlotTypeSocial_0500 publish then======>"));
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeSocial_0500 setTimeout unsubscribe===>");
done();
}),timeout);
});
function onConsume0600(data){
console.info("===========ACTS_PublishSlotTypeSocial_0600 onConsume start===========>");
console.info("===========ACTS_PublishSlotTypeSocial_0600 onConsume data:===========>" + JSON.stringify(data));
expect().assertFail();
console.info("===========ACTS_PublishSlotTypeSocial_0600 onConsume end=============>");
}
/*
* @tc.number: ACTS_PublishSlotTypeSocial_xts_0600
* @tc.name: publish()
* @tc.desc: verify the function of publish(slotType:SOCIAL_COMMUNICATION) promise
*/
it('ACTS_PublishSlotTypeSocial_xts_0600', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeSocial_0600================>");
var subscriber ={
onConsume:onConsume0600
}
await notify.subscribe(subscriber);
try {
var promise = notify.publish({
id: 42,
content: {
// contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
slotType: notify.SlotType.SOCIAL_COMMUNICATION
}
})
}catch(err){
console.info("======ACTS_PublishSlotTypeSocial_0600 err===>"+err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeSocial_0600 setTimeout unsubscribe===>");
done();
}),timeout);
});
function onConsume0700(data){
console.info("===========ACTS_PublishSlotTypeSocial_0700 onConsume start===========>");
console.info("===========ACTS_PublishSlotTypeSocial_0700 onConsume data:===========>" + JSON.stringify(data));
expect(data.request.content.normal.title).assertEqual("test43_title");
console.info("===========ACTS_PublishSlotTypeSocial_0700 onConsume end=============>");
}
/*
* @tc.number: ACTS_PublishSlotTypeSocial_xts_0700
* @tc.name: publish()
* @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT) promise
*/
it('ACTS_PublishSlotTypeSocial_xts_0700', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeSocial_0700================>");
var subscriber ={
onConsume:onConsume0700
}
await notify.subscribe(subscriber);
var notificationRequest = {
id: 43,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test43_title",
text: "test43_text",
additionalText: "test43_additionalText"
},
//slotType:notification.SlotType.SOCIAL_COMMUNICATION
}
}
await notify.publish(notificationRequest);
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeSocial_0700 setTimeout unsubscribe===>");
done();
}),timeout)
});
function onConsume0800(data){
console.info("===========ACTS_PublishSlotTypeSocial_0800 onConsume start===========>");
console.info("===========ACTS_PublishSlotTypeSocial_0800 onConsume data:===========>" + JSON.stringify(data));
expect(data.request.content.normal.title).assertEqual("test44_title");
console.info("===========ACTS_PublishSlotTypeSocial_0800 onConsume end=============>");
}
/*
* @tc.number: ACTS_PublishSlotTypeSocial_xts_0800
* @tc.name: publish()
* @tc.desc: verify the publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:CONTENT_INFORMATION) promise
*/
it('ACTS_PublishSlotTypeSocial_xts_0800', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeSocial_0800================>");
var subscriber ={
onConsume:onConsume0800
}
await notify.subscribe(subscriber);
await notify.publish({
id: 44,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test44_title",
text: "test44_text",
additionalText: "test44_additionalText"
},
slotType:notify.SlotType.CONTENT_INFORMATION
}
})
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("===============ACTS_PublishSlotTypeSocial_0800 setTimeout unsubscribe================>");
done();
}),timeout)
});
function publishSlotServiceCallback001(error){
console.log('=========ACTS_PublishSlotTypeSocial_0100 publish callback==========>'+JSON.stringify(error.code));
}
function onConsume0900(data){
console.info("===========ACTS_PublishSlotTypeSocial_0100 onConsume start===========>");
console.info("===========ACTS_PublishSlotTypeSocial_0100 onConsume data:===========>" + JSON.stringify(data));
expect(data.request.content.normal.title).assertEqual("test29_title");
console.info("===========ACTS_PublishSlotTypeSocial_0100 onConsume end=============>");
}
/*
* @tc.number: ACTS_PublishSlotTypeService_xts_0100
* @tc.name: publish()
* @tc.desc: verify the publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:SERVICE_INFORMATION)
*/
it('ACTS_PublishSlotTypeService_xts_0100', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeService_0100================>");
var subscriber ={
onConsume:onConsume0900
}
await notify.subscribe(subscriber);
console.info("===============ACTS_PublishSlotTypeService_0100 subscribe======>");
await notify.publish({
id:29,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test29_title",
text: "test29_text",
additionalText: "test29_additionalText"
},
},
slotType:notify.SlotType.SERVICE_INFORMATION
},publishSlotServiceCallback001);
console.info("==========ACTS_PublishSlotTypeService_0100 publish======>");
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeService_0100 setTimeout unsubscribe===>");
done();
}),timeout);
});
function publishSlotServiceCallback002(error){
console.log('========ACTS_PublishSlotTypeService_0200 publish callback========>'+JSON.stringify(error.code));
}
function onConsume1000(data){
console.info("=======ACTS_PublishSlotTypeService_0200 onConsume start=========>");
console.info("===========ACTS_PublishSlotTypeService_0200 onConsume data:=========>" + JSON.stringify(data));
expect().assertFail();
console.info("===========ACTS_PublishSlotTypeService_0200 onConsume end===========>");
}
/*
* @tc.number: ACTS_PublishSlotTypeService_xts_0200
* @tc.name: publish()
* @tc.desc: verify the function of publish(slotType:SERVICE_INFORMATION)
*/
it('ACTS_PublishSlotTypeService_xts_0200', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeService_0200================>");
var subscriber ={
onConsume:onConsume1000
}
await notify.subscribe(subscriber);
console.info("===============ACTS_PublishSlotTypeService_0200 subscribe======>");
try {
await notify.publish({
id: 30,
content: {
// contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
slotType: notify.SlotType.SERVICE_INFORMATION
}, publishSlotServiceCallback002);
}catch(err){
console.info("==========ACTS_PublishSlotTypeService_0200 err======>"+err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeService_0200 setTimeout unsubscribe===>");
done();
}),timeout);
});
function publishSlotServiceCallback003(error){
console.log('========ACTS_PublishSlotTypeService_0300 publish callback========>'+JSON.stringify(error.code));
}
function onConsume1100(data){
console.info("=======ACTS_PublishSlotTypeService_0300 onConsume start=========>");
console.info("=======ACTS_PublishSlotTypeService_0300 onConsume data:=========>" + JSON.stringify(data));
expect(data.request.content.normal.title).assertEqual("test31_title");
console.info("=======ACTS_PublishSlotTypeService_0300 onConsume end===========>");
}
/*
* @tc.number: ACTS_PublishSlotTypeService_xts_0300
* @tc.name: publish()
* @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT)
*/
it('ACTS_PublishSlotTypeService_xts_0300', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeService_0300================>");
var subscriber ={
onConsume:onConsume1100
}
await notify.subscribe(subscriber);
console.info("===============ACTS_PublishSlotTypeService_0300 subscribe======>");
await notify.publish({
id: 31,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test31_title",
text: "test31_text",
additionalText: "test31_additionalText"
},
},
// slotType:notification.SlotType.SERVICE_INFORMATION
},publishSlotServiceCallback003);
console.info("==========ACTS_PublishSlotTypeService_0300 publish======>");
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeService_0300 setTimeout unsubscribe===>");
done();
}),timeout);
});
function publishSlotServiceCallback004(error){
console.log('========ACTS_PublishSlotTypeService_0400 publish callback========>'+JSON.stringify(error.code));
}
function onConsume1200(data){
console.info("=======ACTS_PublishSlotTypeService_0400 onConsume start=========>");
console.info("=======ACTS_PublishSlotTypeService_0400 onConsume data:=========>" + JSON.stringify(data));
expect(data.request.content.normal.title).assertEqual("test32_title");
console.info("=======ACTS_PublishSlotTypeService_0400 onConsume end===========>");
}
/*
* @tc.number: ACTS_PublishSlotTypeService_xts_0400
* @tc.name: publish()
* @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:UNKNOWN_TYPE)
*/
it('ACTS_PublishSlotTypeService_xts_0400', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeService_0400================>");
var subscriber ={
onConsume:onConsume1200
}
await notify.subscribe(subscriber);
console.info("===============ACTS_PublishSlotTypeService_0400 subscribe======>");
await notify.publish({
id: 32,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test32_title",
text: "test32_text",
additionalText: "test32_additionalText"
},
},
slotType:notify.SlotType.UNKNOWN_TYPE
},publishSlotServiceCallback004);
console.info("==========ACTS_PublishSlotTypeService_0400 publish======>");
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeService_0400 setTimeout unsubscribe===>");
done();
}),timeout);
});
function onConsume1300(data){
console.info("=======ACTS_PublishSlotTypeService_0500 onConsume start=========>");
console.info("=======ACTS_PublishSlotTypeService_0500 onConsume data:=========>" + JSON.stringify(data));
expect(data.request.content.normal.title).assertEqual("test33_title");
console.info("=======ACTS_PublishSlotTypeService_0500 onConsume end===========>");
}
/*
* @tc.number: ACTS_PublishSlotTypeService_xts_0500
* @tc.name: publish()
* @tc.desc: verify the publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:SERVICE_INFORMATION) promise
*/
it('ACTS_PublishSlotTypeService_xts_0500', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeService_0500================>");
var subscriber ={
onConsume:onConsume1300
}
await notify.subscribe(subscriber);
console.info("===============ACTS_PublishSlotTypeService_0500 subscribe======>");
notify.publish({
id: 33,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test33_title",
text: "test33_text",
additionalText: "test33_additionalText"
},
},
slotType:notify.SlotType.SERVICE_INFORMATION
}).then(console.log("==========ACTS_PublishSlotTypeService_0500 publish then======>"))
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeService_0500 setTimeout unsubscribe===>");
done();
}),timeout);
});
function onConsume1400(data){
console.info("=======ACTS_PublishSlotTypeService_0600 onConsume start=========>");
console.info("=======ACTS_PublishSlotTypeService_0600 onConsume data:=========>" + JSON.stringify(data));
expect().assertFail();
console.info("=======ACTS_PublishSlotTypeService_0600 onConsume end===========>");
}
/*
* @tc.number: ACTS_PublishSlotTypeService_xts_0600
* @tc.name: publish()
* @tc.desc: verify the function of publish(slotType:SERVICE_INFORMATION) promise
*/
it('ACTS_PublishSlotTypeService_xts_0600', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeService_0600================>");
var subscriber ={
onConsume:onConsume1400
}
await notify.subscribe(subscriber);
console.info("===============ACTS_PublishSlotTypeService_0600 subscribe======>");
try {
var promise = notify.publish({
id: 34,
content: {
// contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText"
},
},
slotType: notify.SlotType.SERVICE_INFORMATION
})
}catch(err){
console.info("======ACTS_PublishSlotTypeService_0600 err===>"+err.code);
}
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeService_0600 setTimeout unsubscribe===>");
done();
}),timeout);
});
function onConsume1500(data){
console.info("=======ACTS_PublishSlotTypeService_0700 onConsume start=========>");
console.info("=======ACTS_PublishSlotTypeService_0700 onConsume data:=========>" + JSON.stringify(data));
expect(data.request.content.normal.title).assertEqual("test35_title");
console.info("=======ACTS_PublishSlotTypeService_0700 onConsume end===========>");
}
/*
* @tc.number: ACTS_PublishSlotTypeService_xts_0700
* @tc.name: publish()
* @tc.desc: verify the function of publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT) promise
*/
it('ACTS_PublishSlotTypeService_xts_0700', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeService_0700================>");
var subscriber ={
onConsume:onConsume1500
}
await notify.subscribe(subscriber);
console.info("===============ACTS_PublishSlotTypeService_0700 subscribe======>");
notify.publish({
id: 35,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test35_title",
text: "test35_text",
additionalText: "test35_additionalText"
},
},
// slotType:notification.SlotType.SERVICE_INFORMATION
}).then(console.log("===ACTS_PublishSlotTypeService_0700 finished==="));
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeService_0700 setTimeout unsubscribe===>");
done();
}),timeout);
});
function onConsume1600(data){
console.info("=======ACTS_PublishSlotTypeService_0800 onConsume start=========>");
console.info("=======ACTS_PublishSlotTypeService_0800 onConsume data:=========>" + JSON.stringify(data));
expect(data.request.content.normal.title).assertEqual("test36_title");
console.info("=======ACTS_PublishSlotTypeService_0800 onConsume end===========>");
}
/*
* @tc.number: ACTS_PublishSlotTypeService_xts_0800
* @tc.name: publish()
* @tc.desc: verify publish(contentType:NOTIFICATION_CONTENT_BASIC_TEXT,slotType:UNKNOWN_TYPE) promise
*/
it('ACTS_PublishSlotTypeService_xts_0800', 0,async function (done) {
console.info("===============ACTS_PublishSlotTypeService_0800================>");
var subscriber ={
onConsume:onConsume1600
}
await notify.subscribe(subscriber);
console.info("===============ACTS_PublishSlotTypeService_0800 subscribe======>");
notify.publish({
id: 36,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test36_title",
text: "test36_text",
additionalText: "test36_additionalText"
},
},
slotType:notify.SlotType.UNKNOWN_TYPE
}).then(console.log("===ACTS_PublishSlotTypeService_0800 finished==="))
setTimeout((async function(){
await notify.unsubscribe(subscriber);
console.info("======ACTS_PublishSlotTypeService_0800 setTimeout unsubscribe===>");
done();
}),timeout);
});
})
# 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("ActsAnsSubTestXts") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsSubTestXts"
}
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"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.example.actsanssubtest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAnsSubTestXts.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsanssubtest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 5,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsanssubtest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsanssubtest.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": "Subscriber"
},
{
"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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
import notify from '@ohos.notification';
var timeout = 1000;
describe('ActsAnsSubTestXts', function () {
console.info("==ActsAnsSubscriberTest start==>");
//ActsSubscriber_test_0100
var subInfoa ={
onConnect:connectCallbacka,
onDisconnect:disconnectCallbacka,
}
function connectCallbacka() {
console.debug("==>connectCallbacka code==>");
}
function subscribeCallbacka(err) {
console.debug("==>subscribeCallbacka code==>" +err.code);
expect(err.code).assertEqual(0);
}
function unSubscribeCallbacka(err){
console.debug("==>unSubscribeCallbacka code==>" +err.code);
expect(err.code).assertEqual(0);
}
function disconnectCallbacka(){
console.debug("==>disconnectCallbacka code==>");
}
//ActsSubscriber_test_0200
function connectCallbackb() {
console.debug("==>connectCallbackb code==>");
}
function subscribeCallbackb(err) {
console.debug("==>subscribeCallbackb code==>" +err.code);
expect(err.code).assertEqual(0);
}
function subscribeCallbackc(err) {
console.debug("==>subscribeCallbackc code==>" +err.code);
expect(err.code).assertEqual(0);
}
function unSubscribeCallbackb(err){
console.debug("==>unSubscribeCallbackb code==>" +err.code);
expect(err.code).assertEqual(0);
}
function disconnectCallbackb(){
console.debug("==>disconnectCallbackb code==>");
}
//ActsSubscriber_test_0300
function connectCallbackc() {
console.debug("==>connectCallbackc code==>");
}
function connectCallbackd() {
console.debug("==>connectCallbackd code==>");
}
function subscribeCallbackd(err) {
console.debug("==>subscribeCallbackd code==>" +err.code);
expect(err.code).assertEqual(0);
}
function subscribeCallbacke(err) {
console.debug("==>subscribeCallbacke code==>" +err.code);
expect(err.code).assertEqual(0);
}
function unSubscribeCallbackc(err){
console.debug("==>unSubscribeCallbackc code==>" +err.code);
expect(err.code).assertEqual(0);
}
function unSubscribeCallbackd(err){
console.debug("==>unSubscribeCallbackd code==>" +err.code);
expect(err.code).assertEqual(0);
}
function disconnectCallbackc(){
console.debug("==>disconnectCallbackc code==>");
}
function disconnectCallbackd(){
console.debug("==>disconnectCallbackd code==>");
}
//ActsSubscriber_test_0400
function connectCallbackf() {
console.debug("==>connectCallbackf code==>");
}
function connectCallbackg() {
console.debug("==>connectCallbackg code==>");
}
function subscribeCallbackg(err) {
console.debug("==>subscribeCallbackg code==>" +err.code);
expect(err.code).assertEqual(0);
}
function subscribeCallbackh(err) {
console.debug("==>subscribeCallbackh code==>" +err.code);
expect(err.code).assertEqual(0);
}
function subscribeCallbacki(err) {
console.debug("==>subscribeCallbacki code==>" +err.code);
expect(err.code).assertEqual(0);
}
function unSubscribeCallbackf(err){
console.debug("==>unSubscribeCallbackf code==>" +err.code);
expect(err.code).assertEqual(0);
}
function unSubscribeCallbackg(err){
console.debug("==>unSubscribeCallbackg code==>" +err.code);
expect(err.code).assertEqual(0);
}
function disconnectCallbackf(){
console.debug("==>disconnectCallbackf code==>");
}
function disconnectCallbackg(){
console.debug("==>disconnectCallbackg code==>");
}
//ActsSubscriber_test_0500
var subInfob = {
onConnect:connectCallbacki,
onDisconnect:disconnectCallbacki,
}
function connectCallbacki() {
console.debug("==>connectCallbacki code==>");
}
function subscribeCallbackl(err) {
console.debug("==>subscribeCallbackl code==>" +err.code);
expect(err.code).assertEqual(0);
}
function unSubscribeCallbacki(err){
console.debug("==>unSubscribeCallbacki code==>" +err.code);
expect(err.code).assertEqual(0);
}
function disconnectCallbacki(){
console.debug("==>disconnectCallbacki code==>");
}
//ActsSubscriber_test_0600
var subInfoc ={
onConnecte:connectCallbackj,
onDisconnect:disconnectCallbackj,
}
function connectCallbackj() {
console.debug("==>connectCallbackj code==>");
}
function unSubscribeCallbackj(err){
console.debug("==>unSubscribeCallbackj code==>" +err.code);
expect(err.code).assertEqual(0);
}
function disconnectCallbackj(){
console.debug("==>disconnectCallbackj code==>");
}
//ActsSubscriber_test_0700
var subInfod ={
onConnect:connectCallbackm,
onDisconnect:disconnectCallbackl,
}
function connectCallbackm() {
console.debug("==>connectCallbackm code==>");
}
function subscribeCallbackn(err) {
console.debug("==>subscribeCallbackn code==>" +err.code);
expect(err.code).assertEqual(0);
}
function unSubscribeCallbackl(err){
console.debug("==>unSubscribeCallbackl code==>" +err.code);
expect(err.code).assertEqual(0);
}
function disconnectCallbackl(){
console.debug("==>disconnectCallbackl code==>");
}
//ActsSubscriber_test_0800
var subInfoe ={
onConnect:connectCallbackn,
onDisconnect:disconnectCallbackm,
}
function connectCallbackn() {
console.debug("==>connectCallbackn code==>");
}
function unSubscribeCallbackm(err){
console.debug("==>unSubscribeCallbackm code==>" +err.code);
expect(err.code).assertEqual(0);
}
function disconnectCallbackm(){
console.debug("==>disconnectCallbackm code==>");
}
//ActsSubscriber_test_1300
function connectCallbackl(){
console.debug("==>connectCallbackl code==>");
}
function subscribeCallbacko(err){
console.debug("==>subscribeCallbacko code==>" +err.code);
expect(err.code).assertEqual(0);
}
function unSubscribeCallbackn(err){
console.debug("==>unSubscribeCallbackn code==>" +err.code);
expect(err.code).assertEqual(0);
}
function disconnectCallbackn(){
console.debug("==>disconnectCallbackn code==>");
}
//ActsSubscriber_test_1400
function connectCallbacko(){
console.debug("==>connectCallbacko code==>");
}
function subscribeCallbackp(err){
console.debug("==>subscribeCallbackp code==>" +err.code);
expect(err.code).assertEqual(0);
}
function unSubscribeCallbacko(err){
console.debug("==>unSubscribeCallbacko code==>" +err.code);
expect(err.code).assertEqual(0);
}
function disconnectCallbacko(){
console.debug("==>disconnectCallbacko code==>");
}
/*
* @tc.number: ActsSubscriber_test_xts_0100
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsSubscriber_test_xts_0100', 0, async function (done) {
console.debug("==ActsSubscriber_test_0100==begin==>");
await notify.subscribe(subInfoa, subscribeCallbacka);
await notify.unsubscribe(subInfoa, unSubscribeCallbacka);
console.debug("==ActsSubscriber_test_0100==end==>");
done();
})
/*
* @tc.number: ActsSubscriber_test_xts_0200
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsSubscriber_test_xts_0200', 0, async function (done) {
console.debug("==ActsSubscriber_test_0200==begin==>");
var subInfo ={
onConnect:connectCallbackb,
onDisconnect:disconnectCallbackb,
}
await notify.subscribe(subInfo,subscribeCallbackb);
await notify.subscribe(subInfo,subscribeCallbackc);
await notify.unsubscribe(subInfo, unSubscribeCallbackb);
console.debug("==ActsSubscriber_test_0200==end==>");
done();
})
/*
* @tc.number: ActsSubscriber_test_xts_0300
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsSubscriber_test_xts_0300', 0, async function (done) {
console.debug("==ActsSubscriber_test_0300==begin==>");
var subInfo ={
onConnect:connectCallbackc,
onDisconnect:disconnectCallbackc,
}
var subInfo2 ={
onConnect:connectCallbackd,
onDisconnect:disconnectCallbackd,
}
await notify.subscribe(subInfo,subscribeCallbackd);
await notify.subscribe(subInfo2,subscribeCallbacke);
await notify.unsubscribe(subInfo, unSubscribeCallbackc);
await notify.unsubscribe(subInfo2, unSubscribeCallbackd);
console.debug("==ActsSubscriber_test_0300==end==>");
done();
})
/*
* @tc.number: ActsSubscriber_test_xts_0400
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsSubscriber_test_xts_0400', 0, async function (done) {
console.debug("==ActsSubscriber_test_0500==begin==>");
var subInfo ={
onConnect:connectCallbackf,
onDisconnect:disconnectCallbackf,
}
var subInfo2 ={
onConnect:connectCallbackg,
onDisconnect:disconnectCallbackg,
}
await notify.subscribe(subInfo,subscribeCallbackg);
await notify.subscribe(subInfo,subscribeCallbackh);
await notify.subscribe(subInfo2,subscribeCallbacki);
await notify.unsubscribe(subInfo, unSubscribeCallbackf);
await notify.unsubscribe(subInfo2, unSubscribeCallbackg);
console.debug("==ActsSubscriber_test_0500==end==>");
done();
})
/*
* @tc.number: ActsSubscriber_test_xts_0500
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsSubscriber_test_xts_0500', 0, async function (done) {
console.debug("==ActsSubscriber_test_0500==begin==>");
await notify.subscribe(subInfob, {bundleNames:["com.example.actsanspublishtest"]},subscribeCallbackl);
await notify.unsubscribe(subInfob, unSubscribeCallbacki);
console.debug("==ActsSubscriber_test_0500==end3==>");
done();
})
/*
* @tc.number: ActsSubscriber_test_xts_0600
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsSubscriber_test_xts_0600', 0, async function (done) {
console.debug("==ActsSubscriber_test_0600==begin==>");
await notify.subscribe(subInfoc, {bundleNames:["com.example.actsanspublishtest"]}).then(async()=> {
console.log("ActsSubscriber_test_0600=======promise")
await notify.unsubscribe(subInfoc, unSubscribeCallbackj)
});
console.debug("==ActsSubscriber_test_0600==end==>");
done();
})
/*
* @tc.number: ActsSubscriber_test_xts_0700
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsSubscriber_test_xts_0700', 0, async function (done) {
console.debug("==ActsSubscriber_test_0700==begin==>");
await notify.subscribe(subInfod, {bundleNames:["com.example.actsanspublishtest","com.example.actsanspublishtest"]},subscribeCallbackn);
console.debug("==ActsSubscriber_test_0700==end==>");
await notify.unsubscribe(subInfod, unSubscribeCallbackl);
done();
})
/*
* @tc.number: ActsSubscriber_test_xts_0800
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsSubscriber_test_xts_0800', 0, async function (done) {
console.debug("==ActsSubscriber_test_0900==begin==>");
await notify.subscribe(subInfoe, {bundleNames:["com.example.actsanspublishtest","com.example.actsanspublishtest"]}).then(async()=> {
console.log("ActsSubscriber_test_0900=======promise")
await notify.unsubscribe(subInfoe, unSubscribeCallbackm)
});
console.debug("==ActsSubscriber_test_0900==end==>");
done();
})
/*
* @tc.number: ActsSubscriber_test_xts_0900
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsSubscriber_test_xts_0900', 0, async function (done) {
console.debug("==ActsSubscriber_test_1000==begin==>");
var promise = notify.subscribe(100,{bundleNames:["com.example.actsanspublishtest"]});
expect(promise).assertEqual(undefined);
console.debug("==ActsSubscriber_test_1000==end==>");
done();
})
/*
* @tc.number: ActsSubscriber_test_xts_1000
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsSubscriber_test_xts_1000', 0, async function (done) {
console.debug("==ActsSubscriber_test_1000==begin==>");
var subInfo = null
var promise = await notify.subscribe(subInfo,{bundleNames:["com.example.actsanspublishtest"]});
expect(promise).assertEqual(undefined);
console.debug("==ActsSubscriber_test_1000==end==>");
done();
})
/*
* @tc.number: ActsSubscriber_test_xts_1100
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsSubscriber_test_xts_1100', 0, async function (done) {
console.debug("==ActsSubscriber_test_1200==begin==>");
var subInfo = "#$#%$%$^&%^%"
var promise = notify.subscribe(subInfo,{bundleNames:["com.example.actsanspublishtest"]});
expect(promise).assertEqual(undefined);
console.debug("==ActsSubscriber_test_1200==end==>");
done();
})
/*
* @tc.number: ActsSubscriber_test_xts_1200
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsSubscriber_test_xts_1200', 0, async function (done) {
console.debug("==ActsSubscriber_test_1200==begin==>");
var subInfo = ""
var promise = await notify.subscribe(subInfo,{bundleNames:["com.example.actsanspublishtest"]});
expect(promise).assertEqual(undefined);
console.debug("==ActsSubscriber_test_1200==end==>");
done();
})
/*
* @tc.number: ActsSubscriber_test_xts_1300
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsSubscriber_test_xts_1300', 0, async function (done) {
console.debug("==ActsSubscriber_test_1300==begin==>");
var subInfo ={
onConnect:connectCallbackl,
onDisconnect:disconnectCallbackn,
}
await notify.subscribe(subInfo,{bundleNames:["wrongBudleName"]},subscribeCallbacko);
await notify.unsubscribe(subInfo, unSubscribeCallbackn);
console.debug("==ActsSubscriber_test_1300==end==>");
done();
})
/*
* @tc.number: ActsSubscriber_test_xts_1400
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsSubscriber_test_xts_1400', 0, async function (done) {
console.debug("==ActsSubscriber_test_1400==begin==>");
var subInfo ={
onConnect:connectCallbacko,
onDisconnect:disconnectCallbacko,
}
try{
await notify.subscribe(subInfo, {bundleNames: []}, subscribeCallbackp);
}catch(err){
console.debug("==ActsSubscriber_test_1400==err==>"+err);
}
console.debug("==ActsSubscriber_test_1400==end==>");
done();
})
})
......@@ -17,6 +17,7 @@ group("SubscribeAndPublish") {
testonly = true
if (is_standard_system) {
deps = [
"actspublish:ActsPublish",
"actssubscriberorderedtest:ActsSubscriberOrderTest",
"actssubscriberunordersystemtest:ActsSubscriberTestUnorderSystemTest",
"actssubscriberunordertest:ActsSubscriberUnorderTest",
......
# 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("ActsPublish") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsPublish"
}
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"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.example.actspublish",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"actsPublish.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actspublish",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 5,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actspublish",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"defPermissions": [
{
"availableScope": [],
"grantMode": "system_grant",
"name": "publish_event0800_permission"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "publish_event0900_subscriberPermissions"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "publish_event0900_publisherPermission"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "publish_event1000_permission"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "permission.COMMONEVENT_STICKY"
}
],
"reqPermissions": [
{
"name": "publish_event0800_permission",
"reason": "ceshi"
},
{
"name": "publish_event0900_subscriberPermissions",
"reason": "ceshi"
},
{
"name": "publish_event0900_publisherPermission",
"reason": "ceshi"
},
{
"name": "publish_event1000_permission",
"reason": "ceshi"
},
{
"name": "permission.COMMONEVENT_STICKY",
"reason": "ceshi"
}
],
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": "com.example.actspublish.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"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">
您好,地球1111
{{ $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 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() {
},
}
{
"string": [
{
"name": "app_name",
"value": "JsHelloWorld"
},
{
"name": "mainability_description",
"value": "hap sample empty page"
}
]
}
\ 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 CommonEvent from '@ohos.commonevent'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('Actspublish_0100', function () {
console.info("===========ActspublishAsUser start====================>");
it('Actspublishr_0100', 0, async function (done) {
function PublishCallBack(err) {
if (err.code) {
console.error("publish failed " + JSON.stringify(err));
} else {
console.info("publish success");
expect(event).assertEqual("event_test");
}
}
var event = "event_test"
CommonEvent.publishAsUser(event, 100, PublishCallBack);
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.
*/
require('./ActsPublish.js')
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册