From 97e2fb5d8c7c77d5725abf8d55dcfae9b79f8237 Mon Sep 17 00:00:00 2001 From: zhaoyuan17 Date: Wed, 10 Nov 2021 15:40:42 +0800 Subject: [PATCH] Update xts code Signed-off-by: zhaoyuan17 --- .../actsparticleabilitytest/Test.json | 3 +- .../js/test/ActsParticleAbilityTest.test.js | 576 ++++++++++++------ .../src/main/js/default/pages/index/index.js | 21 +- .../src/main/js/default/pages/index/index.js | 38 +- .../stserviceabilityserver/BUILD.gn | 9 +- .../src/main/js/test/ExampleJsunit.test.js | 5 - .../src/main/js/test/ExampleJsunit.test.js | 5 - .../src/main/js/test/ExampleJsunit.test.js | 2 - .../src/main/js/test/ExampleJsunit.test.js | 12 +- 9 files changed, 444 insertions(+), 227 deletions(-) diff --git a/appexecfwk/ams_standard/serviceability/actsparticleabilitytest/Test.json b/appexecfwk/ams_standard/serviceability/actsparticleabilitytest/Test.json index d02dd2093..100abeae4 100755 --- a/appexecfwk/ams_standard/serviceability/actsparticleabilitytest/Test.json +++ b/appexecfwk/ams_standard/serviceability/actsparticleabilitytest/Test.json @@ -10,7 +10,8 @@ { "test-file-name": [ "ActsParticleAbilityTest.hap", - "ParticleStartAbility.hap" + "ParticleStartAbility.hap", + "amsStDataAbility.hap" ], "type": "AppInstallKit", "cleanup-apps": true diff --git a/appexecfwk/ams_standard/serviceability/actsparticleabilitytest/entry/src/main/js/test/ActsParticleAbilityTest.test.js b/appexecfwk/ams_standard/serviceability/actsparticleabilitytest/entry/src/main/js/test/ActsParticleAbilityTest.test.js index 00e47bb9c..9741f6a5f 100644 --- a/appexecfwk/ams_standard/serviceability/actsparticleabilitytest/entry/src/main/js/test/ActsParticleAbilityTest.test.js +++ b/appexecfwk/ams_standard/serviceability/actsparticleabilitytest/entry/src/main/js/test/ActsParticleAbilityTest.test.js @@ -1,185 +1,393 @@ -/* - * 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 rpc from "@ohos.rpc" -import featureAbility from '@ohos.ability.featureAbility' -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' - -const TIMEOUT = 9000; -const START_ABILITY_TIMEOUT = 5000; - -var subscriberInfoStartAbility_0100 = { - events: ["ACTS_Particle_StartAbility_0100_CommonEvent"], -}; -var subscriberInfoStartAbility_0200 = { - events: ["ACTS_Particle_StartAbility_0200_CommonEvent"], -}; - -describe('ActsParticleAbilityTest', function () { - let bundleName = "com.example.particletestserver"; - let abilityName = "com.example.particletestserver.MainAbility"; - var mRemote; - function onConnectCallback(element, remote) { - console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.deviceId : ' + element.deviceId) - console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.bundleName : ' + element.bundleName) - console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.abilityName : ' + element.abilityName) - console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.uri : ' + element.uri) - console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.shortName : ' + element.shortName) - console.log('ACTS_featureAbilityTest ConnectAbility onConnect remote : ' + remote); - mRemote = remote; - console.log('ACTS_featureAbilityTest ConnectAbility onConnect remote 是否为proxy:' + (remote instanceof rpc.RemoteProxy)); - } - - function onDisconnectCallback(element) { - console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) - console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.bundleName : ' + element.bundleName) - console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.abilityName : ' + element.abilityName) - console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.uri : ' + element.uri) - console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.shortName : ' + element.shortName) - } - - function onFailedCallback(code) { - console.log('ACTS_featureAbilityTest ConnectAbility onFailed errCode : ' + code) - } - - /* - * @tc.number: ACTS_ParticleAbility_startAbility_0100 - * @tc.name: ConnectAbility : Connects an ability to a Service ability and use service to test startAbiltiy. - * @tc.desc: Check the event of the interface startAbiltiy (by promise) - */ - it('ACTS_ParticleAbility_startAbility_0100', 0, async function (done) { - console.log('ACTS_ParticleAbility_startAbility_0100====Subscribe CallBack data:====>" + JSON.stringify(data)); - var result = featureAbility.disconnectAbility( - connId, - (error, data) => { - console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) - }, - ); - console.log('DisconnectNative ConnectAbility result : ' + result); - commonEvent.unsubscribe(subscriber, unSubscribeCallback) - done(); - } - - commonEvent.createSubscriber(subscriberInfoStartAbility_0100).then(async (data) => { - console.debug("====>Create Subscriber====>"); - subscriber = data; - await commonEvent.subscribe(subscriber, subscribeCallBack); - }) - - function unSubscribeCallback() { - console.debug("====>UnSubscribe CallBack====>"); - done(); - } - - function timeout() { - expect().assertFail(); - console.debug('ACTS_ParticleAbility_startAbility_0100 timeout'); - commonEvent.unsubscribe(subscriber, unSubscribeCallback) - done(); - } - - id = setTimeout(timeout, START_ABILITY_TIMEOUT); - connId = await featureAbility.connectAbility( - { - bundleName: bundleName, - abilityName: abilityName, - action: "StartAbilityPromise" - }, - { - onConnect: onConnectCallback, - onDisconnect: onDisconnectCallback, - onFailed: onFailedCallback, - }, - ); - console.log('StartConnectNative ConnectAbility connId : ' + connId); - setTimeout(function () { - console.log('StartConnectNative ConnectAbility timeout') - }, TIMEOUT); - }) - - /* - * @tc.number: ACTS_ParticleAbility_startAbility_0200 - * @tc.name: ConnectAbility : Connects an ability to a Service ability and use service to test startAbiltiy. - * @tc.desc: Check the event of the interface startAbiltiy (by callback) - */ - it('ACTS_ParticleAbility_startAbility_0200', 0, async function (done) { - console.log('ACTS_ParticleAbility_startAbility_0200====Subscribe CallBack data:====>" + JSON.stringify(data)); - var result = featureAbility.disconnectAbility( - connId, - (error, data) => { - console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) - }, - ); - console.log('DisconnectNative ConnectAbility result : ' + result); - commonEvent.unsubscribe(subscriber, unSubscribeCallback) - done(); - } - - commonEvent.createSubscriber(subscriberInfoStartAbility_0200).then(async (data) => { - console.debug("====>Create Subscriber====>"); - subscriber = data; - await commonEvent.subscribe(subscriber, subscribeCallBack); - }) - - function unSubscribeCallback() { - console.debug("====>UnSubscribe CallBack====>"); - done(); - } - - function timeout() { - expect().assertFail(); - console.debug('ACTS_ParticleAbility_startAbility_0200 timeout'); - commonEvent.unsubscribe(subscriber, unSubscribeCallback) - done(); - } - - id = setTimeout(timeout, START_ABILITY_TIMEOUT); - connId = await featureAbility.connectAbility( - { - bundleName: bundleName, - abilityName: abilityName, - action: "StartAbilityCallback" - }, - { - onConnect: onConnectCallback, - onDisconnect: onDisconnectCallback, - onFailed: onFailedCallback, - }, - ); - console.log('StartConnectNative ConnectAbility connId : ' + connId); - setTimeout(function () { - console.log('StartConnectNative ConnectAbility timeout') - }, 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 commonEvent from "@ohos.commonevent" +import rpc from "@ohos.rpc" +import featureAbility from '@ohos.ability.featureAbility' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + +const START_ABILITY_TIMEOUT = 4000; +var subscriberInfoStartAbility_0100 = { + events: ["ACTS_Particle_StartAbility_0100_CommonEvent", "DISCONNECT_0100"], +}; +var subscriberInfoStartAbility_0200 = { + events: ["ACTS_Particle_StartAbility_0200_CommonEvent", "DISCONNECT_0200"], +}; + +var subscriberInfoAcquireDataHelper_0100 = { + events: ["ACTS_AcquireDataHelper_01001", "DISCONNECT_0300"], +}; + +var subscriberInfoAcquireDataHelper_0200 = { + events: ["ACTS_AcquireDataHelper_02000", "DISCONNECT_0400"], +}; + +describe('ActsParticleAbilityTest', function () { + let bundleName = "com.example.particletestserver"; + let abilityName = "com.example.particletestserver.MainAbility"; + var mRemote; + function onConnectCallback(element, remote) { + console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.deviceId : ' + element.deviceId) + console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.bundleName : ' + element.bundleName) + console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.abilityName : ' + element.abilityName) + console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.uri : ' + element.uri) + console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.shortName : ' + element.shortName) + console.log('ACTS_featureAbilityTest ConnectAbility onConnect remote : ' + remote); + mRemote = remote; + console.log('ACTS_featureAbilityTest ConnectAbility onConnect remote 是否为proxy:' + (remote instanceof rpc.RemoteProxy)); + } + + function onDisconnectCallback1(element) { + commonEvent.publish("DISCONNECT_0100", ()=>{console.log('disconnect finish1')}); + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.bundleName : ' + element.bundleName) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.abilityName : ' + element.abilityName) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.uri : ' + element.uri) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.shortName : ' + element.shortName) + } + function onDisconnectCallback2(element) { + commonEvent.publish("DISCONNECT_0200", ()=>{console.log('disconnect finish2')}); + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.bundleName : ' + element.bundleName) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.abilityName : ' + element.abilityName) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.uri : ' + element.uri) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.shortName : ' + element.shortName) + } + function onDisconnectCallback3(element) { + commonEvent.publish("DISCONNECT_0300", ()=>{console.log('disconnect finish3')}); + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.bundleName : ' + element.bundleName) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.abilityName : ' + element.abilityName) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.uri : ' + element.uri) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.shortName : ' + element.shortName) + } + function onDisconnectCallback4(element) { + commonEvent.publish("DISCONNECT_0400", ()=>{console.log('disconnect finish4')}); + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.bundleName : ' + element.bundleName) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.abilityName : ' + element.abilityName) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.uri : ' + element.uri) + console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.shortName : ' + element.shortName) + } + + + function onFailedCallback(code) { + console.log('ACTS_featureAbilityTest ConnectAbility onFailed errCode : ' + code) + } + + /* + * @tc.number: ACTS_ParticleAbility_startAbility_0100 + * @tc.name: ConnectAbility : Connects an ability to a Service ability and use service to test startAbiltiy. + * @tc.desc: Check the event of the interface startAbiltiy (by promise) + */ + it('ACTS_ParticleAbility_startAbility_0100', 0, async function (done) { + console.log('ACTS_ParticleAbility_startAbility_0100====Subscribe CallBack data:====>" + JSON.stringify(data)); + events.set(data.event, 0); + if(events.size == 1){ + if(data.event != "DISCONNECT_0100"){ + clearTimeout(id); + expect(data.event).assertEqual("ACTS_Particle_StartAbility_0100_CommonEvent"); + featureAbility.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }, + ); + } else { + expect(data.event).assertEqual("DISCONNECT_0100"); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + done(); + } + } else { + expect(data.event).assertEqual("DISCONNECT_0100"); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + done(); + } + + } + + commonEvent.createSubscriber(subscriberInfoStartAbility_0100).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ParticleAbility_startAbility_0100 timeout'); + featureAbility.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }, + ); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + connId = await featureAbility.connectAbility( + { + bundleName: bundleName, + abilityName: abilityName, + action: "StartAbilityPromise" + }, + { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback1, + onFailed: onFailedCallback, + }, + ); + console.log('StartConnectNative ConnectAbility connId : ' + connId); + }) + + /* + * @tc.number: ACTS_ParticleAbility_startAbility_0200 + * @tc.name: ConnectAbility : Connects an ability to a Service ability and use service to test startAbiltiy. + * @tc.desc: Check the event of the interface startAbiltiy (by callback) + */ + it('ACTS_ParticleAbility_startAbility_0200', 0, async function (done) { + console.log('ACTS_ParticleAbility_startAbility_0200====Subscribe CallBack data:====>" + JSON.stringify(data)); + events.set(data.event, 0); + if(events.size == 1){ + if(data.event != "DISCONNECT_0200"){ + clearTimeout(id); + expect(data.event).assertEqual("ACTS_Particle_StartAbility_0200_CommonEvent"); + featureAbility.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }, + ); + } else { + expect(data.event).assertEqual("DISCONNECT_0200"); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + done(); + } + } else { + expect(data.event).assertEqual("DISCONNECT_0200"); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + done(); + } + } + + commonEvent.createSubscriber(subscriberInfoStartAbility_0200).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ParticleAbility_startAbility_0200 timeout'); + featureAbility.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }, + ); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + connId = await featureAbility.connectAbility( + { + bundleName: bundleName, + abilityName: abilityName, + action: "StartAbilityCallback" + }, + { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback2, + onFailed: onFailedCallback, + }, + ); + console.log('StartConnectNative ConnectAbility connId : ' + connId); + }) + + + /* + * @tc.number: ACTS_ParticleAbility_acquireDataAbilityHelper_0100 + * @tc.name: ConnectAbility : Connects an ability to a Service ability and + * use service to test acquireDataAbilityHelper. + * @tc.desc: Check the event of the interface + */ + it('ACTS_ParticleAbility_acquireDataAbilityHelper_0100', 0, async function (done) { + console.log('ACTS_ParticleAbility_acquireDataAbilityHelper_0100====Subscribe CallBack data:====>" + JSON.stringify(data)); + events.set(data.event, 0); + if(events.size == 1){ + if(data.event != "DISCONNECT_0300"){ + clearTimeout(id); + expect(data.event).assertEqual("ACTS_AcquireDataHelper_01001"); + featureAbility.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }, + ); + } else { + expect(data.event).assertEqual("DISCONNECT_0300"); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + done(); + } + } else { + expect(data.event).assertEqual("DISCONNECT_0300"); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + done(); + } + + } + + commonEvent.createSubscriber(subscriberInfoAcquireDataHelper_0100).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ParticleAbility_acquireDataAbilityHelper_0100 timeout'); + featureAbility.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }, + ); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + connId = await featureAbility.connectAbility( + { + bundleName: bundleName, + abilityName: abilityName, + action: "AcquireDataHelper" + }, + { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback3, + onFailed: onFailedCallback, + }, + ); + console.log('StartConnectNative ConnectAbility connId : ' + connId); + }) + + /* + * @tc.number: ACTS_ParticleAbility_acquireDataAbilityHelper_0200 + * @tc.name: ConnectAbility : Connects an ability to a Service ability and + * use service to test acquireDataAbilityHelper. + * @tc.desc: Check the event of the interface + */ + it('ACTS_ParticleAbility_acquireDataAbilityHelper_0200', 0, async function (done) { + console.log('ACTS_ParticleAbility_acquireDataAbilityHelper_0200====Subscribe CallBack data:====>" + JSON.stringify(data)); + events.set(data.event, 0); + if(events.size == 1){ + if(data.event != "DISCONNECT_0400"){ + clearTimeout(id); + expect(data.event).assertEqual("ACTS_AcquireDataHelper_02000"); + featureAbility.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }, + ); + } else { + expect(data.event).assertEqual("DISCONNECT_0400"); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + done(); + } + } else { + expect(data.event).assertEqual("DISCONNECT_0400"); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + done(); + } + } + + commonEvent.createSubscriber(subscriberInfoAcquireDataHelper_0200).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ParticleAbility_acquireDataAbilityHelper_0200 timeout'); + featureAbility.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }, + ); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + connId = await featureAbility.connectAbility( + { + bundleName: bundleName, + abilityName: abilityName, + action: "AcquireDataHelper_no" + }, + { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback4, + onFailed: onFailedCallback, + }, + ); + console.log('StartConnectNative ConnectAbility connId : ' + connId); + }) }) \ No newline at end of file diff --git a/appexecfwk/ams_standard/serviceability/sceneProject/particlestartability/src/main/js/default/pages/index/index.js b/appexecfwk/ams_standard/serviceability/sceneProject/particlestartability/src/main/js/default/pages/index/index.js index 8555bfc25..9c7b84527 100644 --- a/appexecfwk/ams_standard/serviceability/sceneProject/particlestartability/src/main/js/default/pages/index/index.js +++ b/appexecfwk/ams_standard/serviceability/sceneProject/particlestartability/src/main/js/default/pages/index/index.js @@ -23,33 +23,20 @@ function publishCallBackOne() { function publishCallBackTwo() { console.debug("====>Publish CallBack ACTS_Particle_StartAbility_0200_CommonEvent====>"); } -function publishCallBackThree() { - console.debug("====>Publish CallBack ACTS_Particle_StartAbility_0300_CommonEvent====>"); -} -function publishCallBackFour() { - console.debug("====>Publish CallBack ACTS_Particle_StartAbility_0400_CommonEvent====>"); -} -function publishCallBackFive() { - console.debug("====>Publish CallBack ACTS_Particle_StartAbility_0500_CommonEvent====>"); -} -function publishCallBackSix() { - console.debug("====>Publish CallBack ACTS_Particle_StartAbility_0600_CommonEvent====>"); -} + export default { data: { title: "ParticleStartAbility" }, onInit() { - this.title = this.data.title; + this.title = "ParticleStartAbility"; }, onShow() { commonEvent.publish("ACTS_Particle_StartAbility_0100_CommonEvent", publishCallBackOne); commonEvent.publish("ACTS_Particle_StartAbility_0200_CommonEvent", publishCallBackTwo); - commonEvent.publish("ACTS_Particle_StartAbility_0300_CommonEvent", publishCallBackThree); - commonEvent.publish("ACTS_Particle_StartAbility_0400_CommonEvent", publishCallBackFour); - commonEvent.publish("ACTS_Particle_StartAbility_0500_CommonEvent", publishCallBackFive); - commonEvent.publish("ACTS_Particle_StartAbility_0600_CommonEvent", publishCallBackSix); + + }, onReady() { }, diff --git a/appexecfwk/ams_standard/serviceability/sceneProject/particletestserver/src/main/js/default/pages/index/index.js b/appexecfwk/ams_standard/serviceability/sceneProject/particletestserver/src/main/js/default/pages/index/index.js index 23497bb4d..f39ff85f7 100644 --- a/appexecfwk/ams_standard/serviceability/sceneProject/particletestserver/src/main/js/default/pages/index/index.js +++ b/appexecfwk/ams_standard/serviceability/sceneProject/particletestserver/src/main/js/default/pages/index/index.js @@ -14,6 +14,7 @@ */ import rpc from "@ohos.rpc" import particleAbility from '@ohos.ability.particleability' +import commonEvent from '@ohos.commonevent' let mMyStub; let mMyProxy; @@ -100,6 +101,42 @@ export default { } ); } + if (want.action == "AcquireDataHelper") { + console.log('stub SerivceAbilityServer OnConnect start 3') + let dataAbilityUri = "dataability:///com.ix.VerifyActDataAbility"; + const valueBucket = { + "name": "ACTS_AcquireDataHelper", + "age": 221, + "salary": 20.5, + "blobType": "u8", + } + let DAHelper = particleAbility.acquireDataAbilityHelper(dataAbilityUri); + console.log('stub SerivceAbilityServer OnConnect ' + DAHelper + JSON.stringify(DAHelper) + typeof DAHelper) + if (JSON.stringify(DAHelper) != 'null') { + var asyncCallback = DAHelper.insert(dataAbilityUri, valueBucket, + (err, data) => { + console.log("json err【" + JSON.stringify(err) + " 】json data【" + JSON.stringify(data) + " 】;"); + commonEvent.publish("ACTS_AcquireDataHelper_0100" + data, err => { + console.log('Publish ACTS_AcquireDataHelper_0100 result: ' + err.code); + }); + } + ); + } + console.log('stub SerivceAbilityServer OnConnect is null'); + } + if (want.action == "AcquireDataHelper_no") { + console.log('stub SerivceAbilityServer OnConnect start 4') + let dataAbilityUri = ""; + var DAHelper = particleAbility.acquireDataAbilityHelper(dataAbilityUri); + console.log('stub SerivceAbilityServer OnConnect ' + DAHelper + JSON.stringify(DAHelper) + typeof DAHelper); + if (JSON.stringify(DAHelper) == 'null') { + console.log('stub SerivceAbilityServer OnConnect DAHelper is null') + commonEvent.publish("ACTS_AcquireDataHelper_02000", err => { + console.log('Publish ACTS_AcquireDataHelper_0200 result: ' + err.code) + }); + } + console.log('stub SerivceAbilityServer OnConnect end') + } return mMyStub; }, onReconnect(want) { @@ -112,4 +149,3 @@ export default { console.log('SerivceAbilityServer onCommand'); }, } - diff --git a/appexecfwk/ams_standard/serviceability/stserviceabilityserver/BUILD.gn b/appexecfwk/ams_standard/serviceability/stserviceabilityserver/BUILD.gn index 27ecff427..021295f29 100644 --- a/appexecfwk/ams_standard/serviceability/stserviceabilityserver/BUILD.gn +++ b/appexecfwk/ams_standard/serviceability/stserviceabilityserver/BUILD.gn @@ -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("amsStServiceAilityServer") { +ohos_js_hap_suite("amsStServiceAilityServer") { hap_profile = "./entry/src/main/config.json" - hap_name = "amsStServiceAilityServer" - 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 = "amsStServiceAilityServer" } ohos_js_assets("hjs_demo_js_assets") { source_dir = "./entry/src/main/js/default" diff --git a/notification/ans_standard/actsansslottest/actsansgetslottestcallback/entry/src/main/js/test/ExampleJsunit.test.js b/notification/ans_standard/actsansslottest/actsansgetslottestcallback/entry/src/main/js/test/ExampleJsunit.test.js index 8c20183a7..93462fd82 100755 --- a/notification/ans_standard/actsansslottest/actsansgetslottestcallback/entry/src/main/js/test/ExampleJsunit.test.js +++ b/notification/ans_standard/actsansslottest/actsansgetslottestcallback/entry/src/main/js/test/ExampleJsunit.test.js @@ -43,7 +43,6 @@ describe('ActsAnsGetSlotTestCallback', function () { expect(data.bypassDnd).assertEqual(false); expect(data.lockscreenVisibility).assertEqual(2); expect(data.vibrationEnabled).assertEqual(true); - expect(data.sound).assertEqual(""); expect(data.lightEnabled).assertEqual(false); expect(data.lightColor).assertEqual(0); console.debug("====>getSlot ActsAnsGetSlotTestCallback_0100 finish====>"); @@ -78,7 +77,6 @@ describe('ActsAnsGetSlotTestCallback', function () { expect(data.bypassDnd).assertEqual(false); expect(data.lockscreenVisibility).assertEqual(2); expect(data.vibrationEnabled).assertEqual(true); - expect(data.sound).assertEqual(""); expect(data.lightEnabled).assertEqual(false); expect(data.lightColor).assertEqual(0); console.debug("====>getSlot ActsAnsGetSlotTestCallback_0200 finish====>"); @@ -120,7 +118,6 @@ describe('ActsAnsGetSlotTestCallback', function () { expect(data.bypassDnd).assertEqual(false); expect(data.lockscreenVisibility).assertEqual(3); expect(data.vibrationEnabled).assertEqual(false); - expect(data.sound).assertEqual(""); expect(data.lightEnabled).assertEqual(false); expect(data.lightColor).assertEqual(0); console.debug("====>getSlot ActsAnsGetSlotTestCallback_0300 finish====>"); @@ -162,7 +159,6 @@ describe('ActsAnsGetSlotTestCallback', function () { expect(data.bypassDnd).assertEqual(false); expect(data.lockscreenVisibility).assertEqual(3); expect(data.vibrationEnabled).assertEqual(false); - expect(data.sound).assertEqual(""); expect(data.lightEnabled).assertEqual(false); expect(data.lightColor).assertEqual(0); console.debug("====>getSlotActsAnsGetSlotTestCallback_0400 finish====>"); @@ -204,7 +200,6 @@ describe('ActsAnsGetSlotTestCallback', function () { expect(data.bypassDnd).assertEqual(false); expect(data.lockscreenVisibility).assertEqual(3); expect(data.vibrationEnabled).assertEqual(false); - expect(data.sound).assertEqual(""); expect(data.lightEnabled).assertEqual(false); expect(data.lightColor).assertEqual(0); console.debug("====>getSlot ActsAnsGetSlotTestCallback_0500 finish====>"); diff --git a/notification/ans_standard/actsansslottest/actsansgetslottestpromise/entry/src/main/js/test/ExampleJsunit.test.js b/notification/ans_standard/actsansslottest/actsansgetslottestpromise/entry/src/main/js/test/ExampleJsunit.test.js index 8a5ed6b5c..5c30fc35a 100755 --- a/notification/ans_standard/actsansslottest/actsansgetslottestpromise/entry/src/main/js/test/ExampleJsunit.test.js +++ b/notification/ans_standard/actsansslottest/actsansgetslottestpromise/entry/src/main/js/test/ExampleJsunit.test.js @@ -45,7 +45,6 @@ describe('ActsAnsGetSlotTestPromise', function () { expect(data.bypassDnd).assertEqual(false); expect(data.lockscreenVisibility).assertEqual(2); expect(data.vibrationEnabled).assertEqual(true); - expect(data.sound).assertEqual(""); expect(data.lightEnabled).assertEqual(false); expect(data.lightColor).assertEqual(0); console.debug("====>getSlot ActsAnsGetSlotTestPromise_0100 finish====>"); @@ -88,7 +87,6 @@ describe('ActsAnsGetSlotTestPromise', function () { expect(data.bypassDnd).assertEqual(false); expect(data.lockscreenVisibility).assertEqual(2); expect(data.vibrationEnabled).assertEqual(true); - expect(data.sound).assertEqual(""); expect(data.lightEnabled).assertEqual(false); expect(data.lightColor).assertEqual(0); console.debug("====>getSlot Promise SERVICE_INFORMATION ActsAnsGetSlotTestPromise_0200 finish====>"); @@ -131,7 +129,6 @@ describe('ActsAnsGetSlotTestPromise', function () { expect(data.bypassDnd).assertEqual(false); expect(data.lockscreenVisibility).assertEqual(3); expect(data.vibrationEnabled).assertEqual(false); - expect(data.sound).assertEqual(""); expect(data.lightEnabled).assertEqual(false); expect(data.lightColor).assertEqual(0); console.debug("====>getSlot Promise CONTENT_INFORMATION ActsAnsGetSlotTestPromise_0300 finish====>"); @@ -174,7 +171,6 @@ describe('ActsAnsGetSlotTestPromise', function () { expect(data.bypassDnd).assertEqual(false); expect(data.lockscreenVisibility).assertEqual(3); expect(data.vibrationEnabled).assertEqual(false); - expect(data.sound).assertEqual(""); expect(data.lightEnabled).assertEqual(false); expect(data.lightColor).assertEqual(0); console.debug("====>getSlot Promise OTHER_TYPES ActsAnsGetSlotTestPromise_0400 finish====>"); @@ -217,7 +213,6 @@ describe('ActsAnsGetSlotTestPromise', function () { expect(data.bypassDnd).assertEqual(false); expect(data.lockscreenVisibility).assertEqual(3); expect(data.vibrationEnabled).assertEqual(false); - expect(data.sound).assertEqual(""); expect(data.lightEnabled).assertEqual(false); expect(data.lightColor).assertEqual(0); console.debug("====>getSlotPromise UNKNOWN_TYPE ActsAnsGetSlotTestPromise_0500 finish====>"); diff --git a/notification/ans_standard/actsansslottest/actsansremoveslottest/entry/src/main/js/test/ExampleJsunit.test.js b/notification/ans_standard/actsansslottest/actsansremoveslottest/entry/src/main/js/test/ExampleJsunit.test.js index c6bc09398..bcea4e5ea 100755 --- a/notification/ans_standard/actsansslottest/actsansremoveslottest/entry/src/main/js/test/ExampleJsunit.test.js +++ b/notification/ans_standard/actsansslottest/actsansremoveslottest/entry/src/main/js/test/ExampleJsunit.test.js @@ -38,7 +38,6 @@ describe('ActsAnsRemoveSlotTest', function () { expect(data.bypassDnd).assertEqual(false); expect(data.lockscreenVisibility).assertEqual(2); expect(data.vibrationEnabled).assertEqual(true); - expect(data.sound).assertEqual(""); expect(data.lightEnabled).assertEqual(false); expect(data.lightColor).assertEqual(0); console.debug("====>getSlot ActsAnsRemoveSlotTest_0100 finish====>"); @@ -83,7 +82,6 @@ describe('ActsAnsRemoveSlotTest', function () { expect(data.bypassDnd).assertEqual(false); expect(data.lockscreenVisibility).assertEqual(2); expect(data.vibrationEnabled).assertEqual(true); - expect(data.sound).assertEqual(""); expect(data.lightEnabled).assertEqual(false); expect(data.lightColor).assertEqual(0); console.debug("====>getSlot ActsAnsRemoveSlotTest_0200 finish====>"); diff --git a/notification/ans_standard/publish_test/actsanspublishcontroltest/entry/src/main/js/test/ExampleJsunit.test.js b/notification/ans_standard/publish_test/actsanspublishcontroltest/entry/src/main/js/test/ExampleJsunit.test.js index 26275df1e..f1b7c6de6 100755 --- a/notification/ans_standard/publish_test/actsanspublishcontroltest/entry/src/main/js/test/ExampleJsunit.test.js +++ b/notification/ans_standard/publish_test/actsanspublishcontroltest/entry/src/main/js/test/ExampleJsunit.test.js @@ -28,8 +28,8 @@ var idRecord = new Array(20).fill(0); const publishFrequence = 10; const TIMEOUT = 3000; -function consumeCallback(err,data) { - console.debug("====>consumeCallback err: ====>" + JSON.stringify(err)); +function consumeCallback(data) { + console.debug("====>consumeCallback data: ====>" + JSON.stringify(data)); console.debug("====>consumeCallback id: ====>" + data.request.id); switch(data.request.id){ case 1: @@ -120,9 +120,8 @@ function consumeCallback(err,data) { } } -function subscribeOnCallback(err) { - console.debug("====>subscribeOnCallback err: ====>" + JSON.stringify(err)); - expect(err.code).assertEqual(0); +function subscribeOnCallback() { + console.debug("====>subscribeOnCallback enter====>"); } function subscribeCallback(err) { @@ -193,7 +192,8 @@ describe('ActsAnsPublishControlTest', function () { /* * @tc.number : ActsAnsPublishControlTest_0100 * @tc.name : Verify rejection of publishing notifications that exceed the threshold - * @tc.desc : Twenty notifications are published continuously within one second, and the first ten notifications can be received, the last ten notifications cannot be received + * @tc.desc : Twenty notifications are published continuously within one second, and the first + * ten notifications can be received, the last ten notifications cannot be received */ it('ActsAnsPublishControlTest_0100', 0, async function (done) { console.debug("====>ActsAnsPublishControlTest_0100 start====>"); -- GitLab