提交 21f964f7 编写于 作者: Z zhaoyuan17

Add session notification test case

Signed-off-by: Nzhaoyuan17 <zhaoyuan17@huawei.com>
上级 6aec3310
......@@ -17,6 +17,7 @@ group("publish_test") {
if (is_standard_system) {
deps = [
"actsanspublishcontroltest:ActsAnsPublishControlTest",
"actsanspublishconversation:ActsAnsConversationTest",
"badgedisplayed:badgedisplayed",
"enablenotification:enablenotification",
"getactive:getactive",
......
......@@ -25,11 +25,26 @@ describe('ActsAnsPublishInput', function () {
console.info("=========Ans_PublishInput_0100 onConsume start==============>");
console.info("=========Ans_PublishInput_0100 onConsume data:==============>" + JSON.stringify(data));
var inputKey = data.request.actionButtons[0].userInput.inputKey
var tag = data.request.actionButtons[0].userInput.tag
var options = data.request.actionButtons[0].userInput.options
var permitMimeTypes = data.request.actionButtons[0].userInput.permitMimeTypes
var editType = data.request.actionButtons[0].userInput.editType
var additionalData = data.request.actionButtons[0].userInput.additionalData
console.info("=========Ans_PublishInput_0100 onConsume inputKey================>"+inputKey);
console.info("=========Ans_PublishInput_0100 onConsume tag================>"+tag);
console.info("=========Ans_PublishInput_0100 onConsume options================>"+options);
console.info("=========Ans_PublishInput_0100 onConsume permitMimeTypes================>"+permitMimeTypes);
console.info("=========Ans_PublishInput_0100 onConsume editType================>"+editType);
expect(inputKey).assertEqual("inputKey_0100");
expect(tag).assertEqual("tag_0100");
expect(options).assertEqual("options_0100");
expect(permitMimeTypes).assertEqual("permitMimeTypes_0100");
expect(editType).assertEqual(1);
expect(additionalData.key0100).assertEqual("0100");
console.info("=========Ans_PublishInput_0100 onConsume end================>");
}
/*
* @tc.number: Ans_PublishInput_0100
* @tc.name: publish(request: NotificationRequest): Promise<void>;
......@@ -89,6 +104,11 @@ describe('ActsAnsPublishInput', function () {
wantAgent:wantAgentData,
userInput : {
inputKey: "inputKey_0100",
tag: "tag_0100",
options: ["options_0100"],
permitMimeTypes:["permitMimeTypes_0100"],
editType:1,
additionalData:{"key0100":"0100"}
}
}]
}
......@@ -103,87 +123,4 @@ describe('ActsAnsPublishInput', function () {
done();
}),timeout);
})
function onConsumeTwo(data) {
console.info("=========Ans_PublishInput_0200 onConsume start==============>");
console.info("=========Ans_PublishInput_0200 onConsume data:==============>" + JSON.stringify(data));
var inputKey = data.request.actionButtons[0].userInput.inputKey
console.info("=========Ans_PublishInput_0200 onConsume inputKey================>"+inputKey);
expect(inputKey).assertEqual(" ");
console.info("=========Ans_PublishInput_0200 onConsume end================>");
}
/*
* @tc.number: Ans_PublishInput_0200
* @tc.name: publish(request: NotificationRequest): Promise<void>;
* @tc.desc: Verify that the inputKey information can be received in the received notification.(inputKey = " ")
*/
it('Ans_PublishInput_0200', 0, async function (done) {
console.info("==================Ans_PublishInput_0200 start==================>");
var subscriber = {
onConsume:onConsumeTwo,
}
var agentInfo = {
wants: [
{
deviceId: "deviceId",
bundleName: "com.example.actsanspublishinput",
abilityName: "com.example.actsanspublishinput.MainAbility",
action: "action1",
entities: ["entity1"],
type: "MIMETYPE",
uri: "key={true,true,false}",
parameters:
{
mykey0: 2222,
mykey1: [1, 2, 3],
mykey2: "[1, 2, 3]",
mykey3: "ssssssssssssssssssssssssss",
mykey4: [false, true, false],
mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"],
mykey6: true,
}
}
],
operationType: OperationType.START_ABILITY,
requestCode: 0,
wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG]
};
var wantAgentData = await wantagent.getWantAgent(agentInfo);
console.info("===========Ans_PublishInput_0200 getWantAgent promise======>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_LONG_TEXT,
longText : {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText",
longText: "long_text",
briefText: "long_briefText",
expandedTitle: "long_expandedTitle"
},
},
id: 2,
slotType : notify.SlotType.SERVICE_INFORMATION,
wantAgent: wantAgentData,
actionButtons: [
{
title:"button2",
wantAgent:wantAgentData,
userInput : {
inputKey: " ",
}
}]
}
await notify.subscribe(subscriber);
console.info("===========Ans_PublishInput_0200 subscribe promise======>");
await notify.publish(notificationRequest);
console.info("===========Ans_PublishInput_0200 publish promise========>");
setTimeout((async function(){
console.info("======Ans_PublishInput_0200 setTimeout==============>");
notify.unsubscribe(subscriber);
console.info("======Ans_PublishInput_0200 setTimeout unsubscribe==>");
done();
}),timeout);
})
})
\ No newline at end of file
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAnsConversationTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsConversationTest"
}
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.actsansconversationtest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAnsConversationTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsansconversationtest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsansconversationtest",
"name": ".actsansconversationtest",
"deviceType": [
"phone"
],
"reqPermissions": [{
"name": "ohos.permission.NOTIFICATION_CONTROLLER",
"reason": "install bundle",
"usedScene": {
"ability": [
"KitFramework"
],
"when": "always"
}
}],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsansconversationtest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"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">
publishConversation
</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 app from '@system.app'
import device from '@system.device'
import router from '@system.router'
import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index'
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'
})
const reportExtend = new ReportExtend(file)
core.addService('expect', expectExtend)
core.addService('report', reportExtend)
core.init()
const configService = core.getDefaultService('config')
configService.setConfig(this)
require('../../../test/List.test')
core.execute()
}
}
{
"string": [
{
"name": "app_name",
"value": "conversation"
},
{
"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.
*/
import notify from '@ohos.notification';
import image from '@ohos.multimedia.image'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var timeout = 500;
describe('ActsAnsConversationTest', function () {
console.info("===========ActsAnsConversationTest start====================>");
function onConsumeOne(data) {
console.info("=========Ans_Conversation_0100 onConsume start==============>");
console.info("=========Ans_Conversation_0100 onConsume data:==============>" + JSON.stringify(data));
expect(data.request.content.contentType).assertEqual(notify.ContentType.NOTIFICATION_CONTENT_CONVERSATION);
expect(data.request.content.conversation.title).assertEqual("test_title");
expect(data.request.content.conversation.text).assertEqual("test_text");
expect(data.request.content.conversation.additionalText).assertEqual("test_additionalText");
expect(data.request.content.conversation.conversationTitle).assertEqual("conversationTitle_0100");
expect(data.request.content.conversation.conversationGroup).assertEqual(true);
expect(data.request.content.conversation.messages[0].text).assertEqual("conversation_text_1");
expect(data.request.content.conversation.messages[0].timestamp).assertEqual(1);
expect(data.request.content.conversation.messages[0].sender.name).assertEqual("sender_name_1");
expect(data.request.content.conversation.messages[0].sender.key).assertEqual("sender_key_1");
expect(data.request.content.conversation.messages[0].sender.uri).assertEqual("sender_uri_1");
expect(data.request.content.conversation.messages[0].sender.isMachine).assertEqual(true);
expect(data.request.content.conversation.messages[0].sender.isUserImportant).assertEqual(true);
expect(data.request.content.conversation.messages[0].mimeType).assertEqual("conversation_mimeType_1");
expect(data.request.content.conversation.messages[0].uri).assertEqual("conversation_uri_1");
expect(data.request.content.conversation.messages[1].text).assertEqual("conversation_text_2");
expect(data.request.content.conversation.messages[1].timestamp).assertEqual(1);
expect(data.request.content.conversation.messages[1].sender.name).assertEqual("sender_name_2");
expect(data.request.content.conversation.messages[1].sender.key).assertEqual("sender_key_2");
expect(data.request.content.conversation.messages[1].sender.uri).assertEqual("sender_uri_2");
expect(data.request.content.conversation.messages[1].sender.isMachine).assertEqual(true);
expect(data.request.content.conversation.messages[1].sender.isUserImportant).assertEqual(true);
expect(data.request.content.conversation.messages[1].mimeType).assertEqual("conversation_mimeType_2");
expect(data.request.content.conversation.messages[1].uri).assertEqual("conversation_uri_2");
console.info("=========Ans_Conversation_0100 onConsume end================>");
}
/*
* @tc.number: Ans_Conversation_0100
* @tc.name: publish(request: NotificationRequest): Promise<void>;
* @tc.desc: Verify that the conversation information can be received in the received notification.
*/
it('Ans_Conversation_0100', 0, async function (done) {
console.info("==================Ans_Conversation_0100 start==================>");
var bufferA = new ArrayBuffer(4*2*25);
var optionA = {alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: {height: 25, width: 2}}
var conversationIconA = await image.createPixelMap(bufferA, optionA);
console.info("===========Ans_Conversation_0100 createPixelMap A promise======>");
var bufferB = new ArrayBuffer(4*2*24);
var optionB = {alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: {height: 24, width: 2}}
var conversationIconB = await image.createPixelMap(bufferB, optionB);
console.info("===========Ans_Conversation_0100 createPixelMap B promise======>");
var bufferC = new ArrayBuffer(4*2*23);
var optionC = {alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: {height: 23, width: 2}}
var conversationIconC = await image.createPixelMap(bufferC, optionC);
console.info("===========Ans_Conversation_0100 createPixelMap C promise======>");
var subscriber = {
onConsume:onConsumeOne,
}
await notify.subscribe(subscriber);
console.info("==================Ans_Conversation_0100 subscribe promise==================>");
var notificationRequest = {
content:{
contentType: notify.ContentType.NOTIFICATION_CONTENT_CONVERSATION,
conversation: {
title: "test_title",
text: "test_text",
additionalText: "test_additionalText",
user:{
name:"user_name",
key: "user_key",
uri: "user_uri",
isMachine:true,
isUserImportant:true,
icon:conversationIconA
},
messages:[
{
text:"conversation_text_1",
timestamp:1,
sender:{
name:"sender_name_1",
key: "sender_key_1",
uri: "sender_uri_1",
isMachine:true,
isUserImportant:true,
icon:conversationIconB
},
mimeType:"conversation_mimeType_1",
uri:"conversation_uri_1",
},
{
text:"conversation_text_2",
timestamp:1,
sender:{
name:"sender_name_2",
key: "sender_key_2",
uri: "sender_uri_2",
isMachine:true,
isUserImportant:true,
icon:conversationIconC
},
mimeType:"conversation_mimeType_2",
uri:"conversation_uri_2",
},],
conversationGroup:true,
conversationTitle:"conversationTitle_0100",
},
},
}
await notify.publish(notificationRequest);
console.info("===========Ans_Conversation_0100 publish promise========>");
setTimeout((async function(){
console.info("======Ans_Conversation_0100 setTimeout==============>");
notify.unsubscribe(subscriber);
console.info("======Ans_Conversation_0100 setTimeout unsubscribe==>");
done();
}),timeout);
})
})
\ 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('./ActsAnsPublishConversation.js')
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册