提交 c5051da0 编写于 作者: O openharmony_ci 提交者: Gitee

!835 update test code

Merge pull request !835 from blackleon/master_0930
......@@ -19,7 +19,8 @@ group("publish_test") {
#"actsanspublishcontroltest:ActsAnsPublishControlTest",
#"badgedisplayed:badgedisplayed",
#"badgedisplayedset:badgedisplayedset",
#"enablenotification:enablenotification",
"enablenotification:enablenotification",
#"enablenotificationset:enablenotificationset",
"getactive:getactive",
"getwantagentinfo:getwantagentinfo",
......@@ -27,6 +28,9 @@ group("publish_test") {
#"publishcontentype:ActsAnsNotificationTest",
#"subscribe:subscribe",
#"unsubscribe:ActsAnsUnSubscriberTest",
#"activeButton:ActsAnsActionButtonTest",
#"publishicontest:ActsAnsIconTest",
#"publishimage:ActsAnsPublishImageTest",
"wantagent:wantagent",
]
}
......
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
/entry/.preview
.cxx
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="1.8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="D:\HUAWEI\DevEco Studio 2.1.0.301\tools\gradle" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/entry" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven2" />
<option name="name" value="maven2" />
<option name="url" value="https://developer.huawei.com/repo/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://repo.huaweicloud.com/repository/maven/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
</project>
\ 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("ActsAnsActionButtonTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsActionButtonTest"
}
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.actsansactionbuttontest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAnsActionButtonTest"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsansactionbuttontest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 5,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsansactionbuttontest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsansactionbuttontest.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">
activeButton
</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": "ActiveBtn"
},
{
"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 wantagent from '@ohos.wantAgent'
import image from '@ohos.multimedia.image'
import { OperationType, Flags } from '@ohos.wantagent'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var largeBuffer
var smallBuffer
var opts
var subInfo
var largeIcon
var smallIcon
var time = 1000
describe('ActsAnsActionButtonTest', function () {
console.info("===========ActsDoNotSubscriberTest start====================>");
//consume
function consumeCallback(err,data) {
console.debug("==========================>consumeDoNotCallbackOne data : =======================>" +err+ JSON.stringify(data));
expect(typeof(data.request.actionButtons)).assertEqual('object')
for(let i=0; i<data.request.actionButtons; i++)
{
console.debug("======consumeCallback====data.actionButtons.title:====>" + data.request.actionButtons[i].title);
console.debug("======consumeCallback====sortings.hashCode:====>" + data.request.actionButtons[i].wantAgent);
console.debug("======consumeCallback====sortings.hashCode:====>" + data.request.actionButtons[i].icon);
}
}
//consume
function consumeCallbackTwo(err,data) {
console.debug("==========================>consumeDoNotCallbackTwo data : =======================>" +err+ JSON.stringify(data));
expect(typeof(data.request.actionButtons)).assertEqual('object')
for(let i=0; i<data.request.actionButtons; i++)
{
console.debug("======consumeDoNotCallbackTwo====sortings.hashCode:====>" + data.request.actionButtons[i].title);
console.debug("======consumeDoNotCallbackTwo====sortings.hashCode:====>" + data.request.actionButtons[i].wantAgent);
console.debug("======consumeCallback====sortings.hashCode:====>" + data.request.actionButtons[i].icon);
}
}
//subscribe
function subscribeCallback(err) {
console.debug("==========================>subscribeDoNotCallback=======================>");
}
function publishCallback200(){
console.debug("==========================>publishCallback200=======================>");
}
/*
* @tc.number: ActsDoNotSubscriber_test_0100
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsActiveButton_test_0100', 0, async function (done) {
console.debug("===============ActsActiveButton_test_0100======begin====================>");
var subInfo ={
onConsume:consumeCallback
}
try{
await notify.subscribe(subInfo,subscribeCallback);
}catch(err) {
console.error('=ActsActiveButton_test_0100 订阅 activeButton err:'+err);
}
console.debug("===============ActsActiveButton_test_0100=======end3===================>");
var agentInfo = {
wants: [
{
deviceId: "deviceId",
bundleName: "com.example.test",
abilityName: "com.example.test.TriggerAbility",
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:[Flags.UPDATE_PRESENT_FLAG]
};
var wantAgentData = await wantagent.getWantAgent(agentInfo);
largeBuffer = new ArrayBuffer(64);
smallBuffer = new ArrayBuffer(32);
opts = {alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: {height: 2, width: 3}}
const promise_Large = image.createPixelMap(largeBuffer, opts);
promise_Large.then((data) => {
console.debug("==========================createPixelMap_promise_Large=======================>");
largeIcon = data;
console.debug("==========================createPixelMap_promise_Large largeIcon=======================>"+largeIcon);
const promise_Small = image.createPixelMap(smallBuffer, opts);
promise_Small.then((data) => {
console.debug("==========================createPixelMap_promise_Small=======================>");
smallIcon = data;
console.debug("==========================createPixelMap_promise_Small smallIcon=======================>"+smallIcon);
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: 1,
slotType : notify.SlotType.SERVICE_INFORMATION,
actionButtons: [{title:"button", wantAgent:wantAgentData,icon:largeIcon},{title:"button", wantAgent:wantAgentData,icon:smallIcon}]
}
notify.publish(notificationRequest, publishCallback200);
console.info("===============ActsActiveButton_test_0100==========================>");
done();
setTimeout(function(){
console.debug("====>time out ActsActiveButton_test_0100====>");
}, 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.
*/
require('./ActiveButton.js')
......@@ -10,20 +10,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap("ActsAnsLocalCanDisplayTest") {
ohos_js_hap_suite("ActsAnsLocalCanDisplayTest") {
hap_profile = "./entry/src/main/config.json"
hap_name = "ActsAnsLocalCanDisplayTest"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsLocalCanDisplayTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
......
<div class="container">
<text class="title">
通知许可设定--参数传空0928
通知许可设定--参数传空1111
</text>
</div>
......@@ -42,10 +42,11 @@ describe('ActsAnsEnableNotificationFiveTest', function () {
* @tc.desc: verify the function of enableNotification
*/
it('ActsEnableNotification_test_1000', 0, async function (done) {
await notify.enableNotification(
var promise = notify.enableNotification(
{
bundle:"com.example.actsanslocalnotificationtest",
},"").then(console.log("====>ActsEnableNotification_test_1000 success====>"))
},"")
expect(promise).assertEqual(undefined)
done();
setTimeout(function(){
console.debug("====>time out ActsEnableNotification_test_1000====>");
......
......@@ -42,10 +42,11 @@ describe('ActsAnsEnableNotificationFourTest', function () {
* @tc.desc: verify the function of enableNotification
*/
it('ActsEnableNotification_test_0800', 0, async function (done) {
await notify.enableNotification(
var promise = notify.enableNotification(
{
bundle:"com.example.actsanslocalnotificationtest",
},100).then(console.log("====>ActsEnableNotification_test_0800 success====>"))
},100)
expect(promise).assertEqual(undefined)
done();
setTimeout(function(){
console.debug("====>time out ActsEnableNotification_test_0800====>");
......
......@@ -42,10 +42,11 @@ describe('ActsAnsEnableNotificationSetFiveTest', function () {
* @tc.desc: verify the function of enableNotification
*/
it('ActsEnableNotificationSet_test_1000', 0, async function (done) {
await notify.enableNotification(
var promise = notify.enableNotification(
{
bundle:"com.example.actsanslocalnotificationtest",
},"").then(console.log("====>ActsEnableNotificationSet_test_1000 success====>"))
},"")
expect(promise).assertEqual(undefined)
done();
setTimeout(function(){
console.debug("====>time out ActsEnableNotificationSet_test_1000====>");
......
......@@ -42,10 +42,11 @@ describe('ActsAnsEnableNotificationSetFourTest', function () {
* @tc.desc: verify the function of enableNotification
*/
it('ActsEnableNotificationSet_test_0800', 0, async function (done) {
await notify.enableNotification(
var promise = notify.enableNotification(
{
bundle:"com.example.actsanslocalnotificationtest",
},100).then(console.log("====>ActsEnableNotificationSet_test_0800 success====>"))
},100)
expect(promise).assertEqual(undefined)
done();
setTimeout(function(){
console.debug("====>time out ActsEnableNotificationSet_test_0800====>");
......
......@@ -2,9 +2,9 @@
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"test-timeout": "21600000",
"package": "com.example.actsansactivesubscribertest",
"shell-timeout": "60000"
"shell-timeout": "21600000"
},
"kits": [
{
......
......@@ -2,9 +2,9 @@
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"test-timeout": "21600000",
"package": "com.example.actsansgetcancelactivenumtest",
"shell-timeout": "60000"
"shell-timeout": "21600000"
},
"kits": [
{
......
......@@ -147,17 +147,17 @@ describe('ActsAnsGetWantAgentInfoOneProTest', function () {
console.info(data);
expect(typeof(data)).assertEqual("object");
wantAgent.equal(WantAgent1,WantAgent2).then(
(error,data) => {
(data) => {
console.info('----equalPromise1 success!----')
console.info(data);
expect(typeof(data)).assertEqual("boolean");
expect(data).assertEqual(false);
}
)
wantAgent.equal(WantAgent1,WantAgent1).then(
(error,data) => {
(data) => {
console.info('----equalPromise2 success!----')
console.info(data);
expect(typeof(data)).assertEqual("boolean");
expect(data).assertEqual(true);
}
)
}
......
......@@ -71,10 +71,10 @@ describe('ActsAnsGetWantAgentInfoTwoProTest', function () {
expect(typeof(data)).assertEqual("object");
}
done();
}),
setTimeout(function(){
console.debug("====>time out ACTS_SetWantInfo_0700====>");
}, time)
}),
console.info('----getWantAgent1 after----');
})
......@@ -121,17 +121,17 @@ describe('ActsAnsGetWantAgentInfoTwoProTest', function () {
console.info(data);
expect(typeof(data)).assertEqual("object");
wantAgent.equal(WantAgent1,WantAgent2).then(
(error,data) => {
(data) => {
console.info('----equalPromise1 success!----')
console.info(data);
expect(typeof(data)).assertEqual("boolean");
expect(data).assertEqual(false);
}
)
wantAgent.equal(WantAgent1,WantAgent1).then(
(error,data) => {
(data) => {
console.info('----equalPromise2 success!----')
console.info(data);
expect(typeof(data)).assertEqual("boolean");
expect(data).assertEqual(true);
}
)
}
......@@ -141,10 +141,11 @@ describe('ActsAnsGetWantAgentInfoTwoProTest', function () {
expect(typeof(data)).assertEqual("object");
}
done();
});
setTimeout(function(){
console.debug("====>time out ACTS_SetWantInfo_0800====>");
}, time)
});
console.info('----getWantAgent2 after----');
})
})
......
# 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("ActsAnsIconTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsIconTest"
}
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": "120000",
"package": "com.example.actsansicontest",
"shell-timeout": "120000"
},
"kits": [
{
"test-file-name": [
"ActsAnsIconTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsansicontest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 5,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsansicontest",
"name": ".actsansicontest",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsansicontest.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"isVisible": "true",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container">
<text class="title">
icon_pixcelMap
</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.
*/
import notify from '@ohos.notification'
import image from '@ohos.multimedia.image'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
var largeBuffer
var smallBuffer
var opts
var subInfo
var largeIcon
var smallIcon
var time = 1000
describe('ActsAnsIconTest', function () {
console.info("===========ActsAnsIconTest start====================>");
//consume
function consumeCallback(err,data) {
console.debug("==========================consumeCallback data : =======================>" +err+ JSON.stringify(data));
console.log("==========================consumeCallback smallIcon : =======================>"+JSON.stringify(data.request.smallIcon))
console.log("==========================consumeCallback largeIcon : =======================>"+JSON.stringify(data.request.largeIcon))
}
function subscribeCallback(err) {
console.info("==========================subscribeCallback start=======================>");
console.info("================subscribeCallback err : =======================>" + JSON.stringify(err));
console.info("==========================subscribeCallback end=======================>");
}
function publishCallback(err){
console.info("==========================publishCallback start=======================>");
console.info("================publishCallback err : =======================>" + JSON.stringify(err));
console.info("==========================publishCallback end=======================>");
}
/*
* @tc.number: ActsAnsIconTest_0100
* @tc.name: createPixelMap()
* @tc.desc: verify the function of subscribe
*/
it('ActsAnsIconTest_0100', 0, async function (done) {
console.debug("===============ActsAnsIconTest_0100 start====================>");
subInfo ={
onConsume:consumeCallback,
}
await notify.subscribe(subInfo,subscribeCallback);
largeBuffer = new ArrayBuffer(64);
smallBuffer = new ArrayBuffer(32);
opts = {alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: {height: 2, width: 3}}
const promise_Large = image.createPixelMap(largeBuffer, opts);
promise_Large.then((data) => {
console.debug("==========================createPixelMap_promise_Large=======================>");
largeIcon = data;
console.debug("==========================createPixelMap_promise_Large largeIcon=======================>"+largeIcon);
const promise_Small = image.createPixelMap(smallBuffer, opts);
promise_Small.then((data) => {
console.debug("==========================createPixelMap_promise_Small=======================>");
smallIcon = data;
console.debug("==========================createPixelMap_promise_Small smallIcon=======================>"+smallIcon);
notify.publish({
id: 1,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "test1_title",
text: "test1_text",
additionalText: "test1_additionalText"
},
},
slotType:notify.SlotType.SOCIAL_COMMUNICATION,
classification:"classification1",
sortingKey:"sortingKey1",
smallIcon:smallIcon,
largeIcon:largeIcon,
},publishCallback);
done();
setTimeout(function(){
console.debug("====>time out ActsAnsIconTest_0100====>");
}, 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.
*/
require('./Icon.js')
\ No newline at end of file
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
/entry/.preview
.cxx
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="1.8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="D:\HUAWEI\DevEco Studio 2.1.0.301\tools\gradle" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/entry" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
<option name="useQualifiedModuleNames" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven2" />
<option name="name" value="maven2" />
<option name="url" value="https://developer.huawei.com/repo/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://repo.huaweicloud.com/repository/maven/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
</project>
\ 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("ActsAnsPublishImageTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsPublishImageTest"
}
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.actsanspublishimagetest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsAnsPublishImageTest"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.actsanspublishimagetest",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 5,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {},
"module": {
"package": "com.example.actsanspublishimagetest",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.actsanspublishimagetest.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": "Pubimage"
},
{
"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('./publishImage.js')
/*
* 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 imageBuffer
var opts
var pubimage
var time = 1000
describe('ActsAnsPublishImageTest', function () {
console.info("===========ActsDoNotSubscriberTest start====================>");
//consume
function consumeCallbackOne(err,data) {
console.debug("==========================>consumeDoNotCallback1 data : =======================>" +err+ JSON.stringify(data));
checkConsumeData(data)
}
function consumeCallbackTwo(err,data) {
console.debug("==========================>consumeDoNotCallback2 data : =======================>" +err+ JSON.stringify(data));
checkConsumeData(data)
}
function checkConsumeData(data){
expect(typeof(data)).assertEqual("object");
expect(data.id).assertEqual(1);
expect(data.content.contentType).assertEqual(notify.ContentType.NOTIFICATION_CONTENT_PICTURE);
expect(data.content.picture.title).assertEqual("image_title");
expect(data.content.picture.text).assertEqual("image_text");
expect(data.content.picture.additionalText).assertEqual("image_additionalText");
expect(data.content.picture.briefText).assertEqual("image_briefText");
expect(data.content.picture.expandedTitle).assertEqual("expandedTitle");
// expect(typeof(data.content.picture.picture)).assertEqual();
expect(data.slotType).assertEqual(notify.SlotType.SOCIAL_COMMUNICATION);
expect(data.classification).assertEqual("classification1");
expect(data.sortingKey).assertEqual("sortingKey1");
}
//subscribeOn
function subscribeOnCallback(err) {
console.debug("==========================>subscribeDoNotOnCallback=======================>");
}
//subscribe
function subscribeCallback(err) {
console.debug("==========================>subscribeDoNotCallback=======================>");
}
function publishCallback001(){
console.log('ActsAnsPublishImageTest ACTS_Publish_0100 asyncCallback')
}
/*
* @tc.number: ActsPublishImage_test_0100
* @tc.name: subscribe()
* @tc.desc: verify the function of subscribe
*/
it('ActsPublishImage_test_0100', 0, async function (done) {
console.debug("===============ActsDoNotSubscriber_test_0100======begin====================>");
var subInfo ={
onConsume:consumeCallbackOne,
onConnecte:subscribeOnCallback,
}
try {
await notify.subscribe(subInfo, subscribeCallback);
}
catch(err) {
console.error('=ActsDoNotSubscriber_test_0100 订阅 subscribeDoNotCallback err:'+err);
}
console.debug("===============ActsSubscriber_test_0100=======end3===================>");
done();
setTimeout(function(){
console.debug("====>time out ActsPublishImage_test_0100====>");
}, time);
})
/*
* @tc.number: ACTS_publishTest_0100
* @tc.name: publish()
* @tc.desc: verify the function of publish
*/
it('ActsPublishImage_test_0200', 0,async function (done) {
imageBuffer = new ArrayBuffer(32);
opts = {alphaType: 0, editable: true, pixelFormat: 4, scaleMode: 1, size: {height: 2, width: 3}}
const promise_Large = image.createPixelMap(imageBuffer, opts);
promise_Large.then((data) => {
console.debug("==========================createPixelMap_promise_Large=======================>");
pubimage = data;
console.debug("==========================createPixelMap_promise_Large largeIcon=======================>"+pubimage);
notify.publish({
id: 1,
content: {
contentType: notify.ContentType.NOTIFICATION_CONTENT_PICTURE,
picture: {
title: "image_title",
text: "image_text",
additionalText: "image_additionalText",
briefText:"image_brief",
expandedTitle:"expandedTitle",
picture:pubimage
},
},
slotType:notify.SlotType.SOCIAL_COMMUNICATION,
classification:"classification1",
sortingKey:"sortingKey1",
},publishCallback001);
done()
setTimeout(function(){
console.debug("====>time out ACTS_publishTest_0100====>");
}, time);
})
})
})
......@@ -10,20 +10,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap("ActsAnsPublishOneTest") {
ohos_js_hap_suite("ActsAnsPublishOneTest") {
hap_profile = "./entry/src/main/config.json"
hap_name = "ActsAnsPublishOneTest"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsPublishOneTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
......
......@@ -10,20 +10,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap("ActsAnsPublishTwoTest") {
ohos_js_hap_suite("ActsAnsPublishTwoTest") {
hap_profile = "./entry/src/main/config.json"
hap_name = "ActsAnsPublishTwoTest"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAnsPublishTwoTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
......
......@@ -9,21 +9,18 @@
# 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.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap("test1") {
ohos_js_hap_suite("test1") {
hap_profile = "./entry/src/main/config.json"
hap_name = "test1"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "test1"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
......
......@@ -9,21 +9,18 @@
# 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.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_hap("test2") {
ohos_js_hap_suite("test2") {
hap_profile = "./entry/src/main/config.json"
hap_name = "test2"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "test2"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册