提交 97e2fb5d 编写于 作者: Z zhaoyuan17

Update xts code

Signed-off-by: Nzhaoyuan17 <zhaoyuan17@huawei.com>
上级 669a7672
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
{ {
"test-file-name": [ "test-file-name": [
"ActsParticleAbilityTest.hap", "ActsParticleAbilityTest.hap",
"ParticleStartAbility.hap" "ParticleStartAbility.hap",
"amsStDataAbility.hap"
], ],
"type": "AppInstallKit", "type": "AppInstallKit",
"cleanup-apps": true "cleanup-apps": true
......
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import commonEvent from "@ohos.commonevent" import commonEvent from "@ohos.commonevent"
import rpc from "@ohos.rpc" import rpc from "@ohos.rpc"
import featureAbility from '@ohos.ability.featureAbility' import featureAbility from '@ohos.ability.featureAbility'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
const TIMEOUT = 9000; const START_ABILITY_TIMEOUT = 4000;
const START_ABILITY_TIMEOUT = 5000; var subscriberInfoStartAbility_0100 = {
events: ["ACTS_Particle_StartAbility_0100_CommonEvent", "DISCONNECT_0100"],
var subscriberInfoStartAbility_0100 = { };
events: ["ACTS_Particle_StartAbility_0100_CommonEvent"], var subscriberInfoStartAbility_0200 = {
}; events: ["ACTS_Particle_StartAbility_0200_CommonEvent", "DISCONNECT_0200"],
var subscriberInfoStartAbility_0200 = { };
events: ["ACTS_Particle_StartAbility_0200_CommonEvent"],
}; var subscriberInfoAcquireDataHelper_0100 = {
events: ["ACTS_AcquireDataHelper_01001", "DISCONNECT_0300"],
describe('ActsParticleAbilityTest', function () { };
let bundleName = "com.example.particletestserver";
let abilityName = "com.example.particletestserver.MainAbility"; var subscriberInfoAcquireDataHelper_0200 = {
var mRemote; events: ["ACTS_AcquireDataHelper_02000", "DISCONNECT_0400"],
function onConnectCallback(element, remote) { };
console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.deviceId : ' + element.deviceId)
console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.bundleName : ' + element.bundleName) describe('ActsParticleAbilityTest', function () {
console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.abilityName : ' + element.abilityName) let bundleName = "com.example.particletestserver";
console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.uri : ' + element.uri) let abilityName = "com.example.particletestserver.MainAbility";
console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.shortName : ' + element.shortName) var mRemote;
console.log('ACTS_featureAbilityTest ConnectAbility onConnect remote : ' + remote); function onConnectCallback(element, remote) {
mRemote = remote; console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.deviceId : ' + element.deviceId)
console.log('ACTS_featureAbilityTest ConnectAbility onConnect remote 是否为proxy:' + (remote instanceof rpc.RemoteProxy)); 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)
function onDisconnectCallback(element) { console.log('ACTS_featureAbilityTest ConnectAbility onConnect element.shortName : ' + element.shortName)
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.deviceId : ' + element.deviceId) console.log('ACTS_featureAbilityTest ConnectAbility onConnect remote : ' + remote);
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.bundleName : ' + element.bundleName) mRemote = remote;
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.abilityName : ' + element.abilityName) console.log('ACTS_featureAbilityTest ConnectAbility onConnect remote 是否为proxy:' + (remote instanceof rpc.RemoteProxy));
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.uri : ' + element.uri) }
console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.shortName : ' + element.shortName)
} function onDisconnectCallback1(element) {
commonEvent.publish("DISCONNECT_0100", ()=>{console.log('disconnect finish1')});
function onFailedCallback(code) { console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
console.log('ACTS_featureAbilityTest ConnectAbility onFailed errCode : ' + code) 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)
* @tc.number: ACTS_ParticleAbility_startAbility_0100 }
* @tc.name: ConnectAbility : Connects an ability to a Service ability and use service to test startAbiltiy. function onDisconnectCallback2(element) {
* @tc.desc: Check the event of the interface startAbiltiy (by promise) commonEvent.publish("DISCONNECT_0200", ()=>{console.log('disconnect finish2')});
*/ console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
it('ACTS_ParticleAbility_startAbility_0100', 0, async function (done) { console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.bundleName : ' + element.bundleName)
console.log('ACTS_ParticleAbility_startAbility_0100====<begin'); console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.abilityName : ' + element.abilityName)
console.log('========StartConnect called'); console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.uri : ' + element.uri)
var subscriber; console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.shortName : ' + element.shortName)
let id; }
let connId; function onDisconnectCallback3(element) {
commonEvent.publish("DISCONNECT_0300", ()=>{console.log('disconnect finish3')});
function subscribeCallBack(err, data) { console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.deviceId : ' + element.deviceId)
clearTimeout(id); console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.bundleName : ' + element.bundleName)
expect(data.event).assertEqual("ACTS_Particle_StartAbility_0100_CommonEvent"); console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.abilityName : ' + element.abilityName)
console.debug("====>Subscribe CallBack data:====>" + JSON.stringify(data)); console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.uri : ' + element.uri)
var result = featureAbility.disconnectAbility( console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.shortName : ' + element.shortName)
connId, }
(error, data) => { function onDisconnectCallback4(element) {
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) 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('DisconnectNative ConnectAbility result : ' + result); console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.abilityName : ' + element.abilityName)
commonEvent.unsubscribe(subscriber, unSubscribeCallback) console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.uri : ' + element.uri)
done(); console.log('ACTS_featureAbilityTest ConnectAbility onDisconnect element.shortName : ' + element.shortName)
} }
commonEvent.createSubscriber(subscriberInfoStartAbility_0100).then(async (data) => {
console.debug("====>Create Subscriber====>"); function onFailedCallback(code) {
subscriber = data; console.log('ACTS_featureAbilityTest ConnectAbility onFailed errCode : ' + code)
await commonEvent.subscribe(subscriber, subscribeCallBack); }
})
/*
function unSubscribeCallback() { * @tc.number: ACTS_ParticleAbility_startAbility_0100
console.debug("====>UnSubscribe CallBack====>"); * @tc.name: ConnectAbility : Connects an ability to a Service ability and use service to test startAbiltiy.
done(); * @tc.desc: Check the event of the interface startAbiltiy (by promise)
} */
it('ACTS_ParticleAbility_startAbility_0100', 0, async function (done) {
function timeout() { console.log('ACTS_ParticleAbility_startAbility_0100====<begin');
expect().assertFail(); console.log('========StartConnect called');
console.debug('ACTS_ParticleAbility_startAbility_0100 timeout'); var subscriber;
commonEvent.unsubscribe(subscriber, unSubscribeCallback) let id;
done(); let connId;
} let events = new Map();
id = setTimeout(timeout, START_ABILITY_TIMEOUT); function subscribeCallBack(err, data) {
connId = await featureAbility.connectAbility( console.debug("====>Subscribe CallBack data:====>" + JSON.stringify(data));
{ events.set(data.event, 0);
bundleName: bundleName, if(events.size == 1){
abilityName: abilityName, if(data.event != "DISCONNECT_0100"){
action: "StartAbilityPromise" clearTimeout(id);
}, expect(data.event).assertEqual("ACTS_Particle_StartAbility_0100_CommonEvent");
{ featureAbility.disconnectAbility(
onConnect: onConnectCallback, connId,
onDisconnect: onDisconnectCallback, (error, data) => {
onFailed: onFailedCallback, console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
}, },
); );
console.log('StartConnectNative ConnectAbility connId : ' + connId); } else {
setTimeout(function () { expect(data.event).assertEqual("DISCONNECT_0100");
console.log('StartConnectNative ConnectAbility timeout') commonEvent.unsubscribe(subscriber, unSubscribeCallback)
}, TIMEOUT); done();
}) }
} else {
/* expect(data.event).assertEqual("DISCONNECT_0100");
* @tc.number: ACTS_ParticleAbility_startAbility_0200 commonEvent.unsubscribe(subscriber, unSubscribeCallback)
* @tc.name: ConnectAbility : Connects an ability to a Service ability and use service to test startAbiltiy. done();
* @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====<begin');
console.log('========StartConnect called'); commonEvent.createSubscriber(subscriberInfoStartAbility_0100).then(async (data) => {
var subscriber; console.debug("====>Create Subscriber====>");
let id; subscriber = data;
let connId; await commonEvent.subscribe(subscriber, subscribeCallBack);
})
function subscribeCallBack(err, data) {
clearTimeout(id); function unSubscribeCallback() {
expect(data.event).assertEqual("ACTS_Particle_StartAbility_0200_CommonEvent"); console.debug("====>UnSubscribe CallBack====>");
console.debug("====>Subscribe CallBack data:====>" + JSON.stringify(data)); }
var result = featureAbility.disconnectAbility(
connId, function timeout() {
(error, data) => { expect().assertFail();
console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) console.debug('ACTS_ParticleAbility_startAbility_0100 timeout');
}, featureAbility.disconnectAbility(
); connId,
console.log('DisconnectNative ConnectAbility result : ' + result); (error, data) => {
commonEvent.unsubscribe(subscriber, unSubscribeCallback) console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data)
done(); },
} );
}
commonEvent.createSubscriber(subscriberInfoStartAbility_0200).then(async (data) => {
console.debug("====>Create Subscriber====>"); id = setTimeout(timeout, START_ABILITY_TIMEOUT);
subscriber = data; connId = await featureAbility.connectAbility(
await commonEvent.subscribe(subscriber, subscribeCallBack); {
}) bundleName: bundleName,
abilityName: abilityName,
function unSubscribeCallback() { action: "StartAbilityPromise"
console.debug("====>UnSubscribe CallBack====>"); },
done(); {
} onConnect: onConnectCallback,
onDisconnect: onDisconnectCallback1,
function timeout() { onFailed: onFailedCallback,
expect().assertFail(); },
console.debug('ACTS_ParticleAbility_startAbility_0200 timeout'); );
commonEvent.unsubscribe(subscriber, unSubscribeCallback) console.log('StartConnectNative ConnectAbility connId : ' + connId);
done(); })
}
/*
id = setTimeout(timeout, START_ABILITY_TIMEOUT); * @tc.number: ACTS_ParticleAbility_startAbility_0200
connId = await featureAbility.connectAbility( * @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)
bundleName: bundleName, */
abilityName: abilityName, it('ACTS_ParticleAbility_startAbility_0200', 0, async function (done) {
action: "StartAbilityCallback" console.log('ACTS_ParticleAbility_startAbility_0200====<begin');
}, console.log('========StartConnect called');
{ var subscriber;
onConnect: onConnectCallback, let id;
onDisconnect: onDisconnectCallback, let connId;
onFailed: onFailedCallback, let events = new Map();
},
); function subscribeCallBack(err, data) {
console.log('StartConnectNative ConnectAbility connId : ' + connId); console.debug("====>Subscribe CallBack data:====>" + JSON.stringify(data));
setTimeout(function () { events.set(data.event, 0);
console.log('StartConnectNative ConnectAbility timeout') if(events.size == 1){
}, TIMEOUT); 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====<begin');
console.log('========StartConnect called');
var subscriber;
let id;
let connId;
let events = new Map();
function subscribeCallBack(err, data) {
console.debug("====>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====<begin');
console.log('========StartConnect called');
var subscriber;
let id;
let connId;
let events = new Map();
function subscribeCallBack(err, data) {
console.debug("====>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
...@@ -23,33 +23,20 @@ function publishCallBackOne() { ...@@ -23,33 +23,20 @@ function publishCallBackOne() {
function publishCallBackTwo() { function publishCallBackTwo() {
console.debug("====>Publish CallBack ACTS_Particle_StartAbility_0200_CommonEvent====>"); 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 { export default {
data: { data: {
title: "ParticleStartAbility" title: "ParticleStartAbility"
}, },
onInit() { onInit() {
this.title = this.data.title; this.title = "ParticleStartAbility";
}, },
onShow() { onShow() {
commonEvent.publish("ACTS_Particle_StartAbility_0100_CommonEvent", publishCallBackOne); commonEvent.publish("ACTS_Particle_StartAbility_0100_CommonEvent", publishCallBackOne);
commonEvent.publish("ACTS_Particle_StartAbility_0200_CommonEvent", publishCallBackTwo); 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() { onReady() {
}, },
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
*/ */
import rpc from "@ohos.rpc" import rpc from "@ohos.rpc"
import particleAbility from '@ohos.ability.particleability' import particleAbility from '@ohos.ability.particleability'
import commonEvent from '@ohos.commonevent'
let mMyStub; let mMyStub;
let mMyProxy; let mMyProxy;
...@@ -100,6 +101,42 @@ export default { ...@@ -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; return mMyStub;
}, },
onReconnect(want) { onReconnect(want) {
...@@ -112,4 +149,3 @@ export default { ...@@ -112,4 +149,3 @@ export default {
console.log('SerivceAbilityServer onCommand'); console.log('SerivceAbilityServer onCommand');
}, },
} }
...@@ -10,20 +10,17 @@ ...@@ -10,20 +10,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # 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") import("//test/xts/tools/build/suite.gni")
ohos_hap("amsStServiceAilityServer") { ohos_js_hap_suite("amsStServiceAilityServer") {
hap_profile = "./entry/src/main/config.json" 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 = [ deps = [
":hjs_demo_js_assets", ":hjs_demo_js_assets",
":hjs_demo_resources", ":hjs_demo_resources",
] ]
certificate_profile = "./signature/openharmony_sx.p7b" certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "amsStServiceAilityServer"
} }
ohos_js_assets("hjs_demo_js_assets") { ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default" source_dir = "./entry/src/main/js/default"
......
...@@ -43,7 +43,6 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -43,7 +43,6 @@ describe('ActsAnsGetSlotTestCallback', function () {
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
expect(data.lockscreenVisibility).assertEqual(2); expect(data.lockscreenVisibility).assertEqual(2);
expect(data.vibrationEnabled).assertEqual(true); expect(data.vibrationEnabled).assertEqual(true);
expect(data.sound).assertEqual("");
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlot ActsAnsGetSlotTestCallback_0100 finish====>"); console.debug("====>getSlot ActsAnsGetSlotTestCallback_0100 finish====>");
...@@ -78,7 +77,6 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -78,7 +77,6 @@ describe('ActsAnsGetSlotTestCallback', function () {
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
expect(data.lockscreenVisibility).assertEqual(2); expect(data.lockscreenVisibility).assertEqual(2);
expect(data.vibrationEnabled).assertEqual(true); expect(data.vibrationEnabled).assertEqual(true);
expect(data.sound).assertEqual("");
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlot ActsAnsGetSlotTestCallback_0200 finish====>"); console.debug("====>getSlot ActsAnsGetSlotTestCallback_0200 finish====>");
...@@ -120,7 +118,6 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -120,7 +118,6 @@ describe('ActsAnsGetSlotTestCallback', function () {
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
expect(data.lockscreenVisibility).assertEqual(3); expect(data.lockscreenVisibility).assertEqual(3);
expect(data.vibrationEnabled).assertEqual(false); expect(data.vibrationEnabled).assertEqual(false);
expect(data.sound).assertEqual("");
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlot ActsAnsGetSlotTestCallback_0300 finish====>"); console.debug("====>getSlot ActsAnsGetSlotTestCallback_0300 finish====>");
...@@ -162,7 +159,6 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -162,7 +159,6 @@ describe('ActsAnsGetSlotTestCallback', function () {
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
expect(data.lockscreenVisibility).assertEqual(3); expect(data.lockscreenVisibility).assertEqual(3);
expect(data.vibrationEnabled).assertEqual(false); expect(data.vibrationEnabled).assertEqual(false);
expect(data.sound).assertEqual("");
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlotActsAnsGetSlotTestCallback_0400 finish====>"); console.debug("====>getSlotActsAnsGetSlotTestCallback_0400 finish====>");
...@@ -204,7 +200,6 @@ describe('ActsAnsGetSlotTestCallback', function () { ...@@ -204,7 +200,6 @@ describe('ActsAnsGetSlotTestCallback', function () {
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
expect(data.lockscreenVisibility).assertEqual(3); expect(data.lockscreenVisibility).assertEqual(3);
expect(data.vibrationEnabled).assertEqual(false); expect(data.vibrationEnabled).assertEqual(false);
expect(data.sound).assertEqual("");
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlot ActsAnsGetSlotTestCallback_0500 finish====>"); console.debug("====>getSlot ActsAnsGetSlotTestCallback_0500 finish====>");
......
...@@ -45,7 +45,6 @@ describe('ActsAnsGetSlotTestPromise', function () { ...@@ -45,7 +45,6 @@ describe('ActsAnsGetSlotTestPromise', function () {
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
expect(data.lockscreenVisibility).assertEqual(2); expect(data.lockscreenVisibility).assertEqual(2);
expect(data.vibrationEnabled).assertEqual(true); expect(data.vibrationEnabled).assertEqual(true);
expect(data.sound).assertEqual("");
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlot ActsAnsGetSlotTestPromise_0100 finish====>"); console.debug("====>getSlot ActsAnsGetSlotTestPromise_0100 finish====>");
...@@ -88,7 +87,6 @@ describe('ActsAnsGetSlotTestPromise', function () { ...@@ -88,7 +87,6 @@ describe('ActsAnsGetSlotTestPromise', function () {
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
expect(data.lockscreenVisibility).assertEqual(2); expect(data.lockscreenVisibility).assertEqual(2);
expect(data.vibrationEnabled).assertEqual(true); expect(data.vibrationEnabled).assertEqual(true);
expect(data.sound).assertEqual("");
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlot Promise SERVICE_INFORMATION ActsAnsGetSlotTestPromise_0200 finish====>"); console.debug("====>getSlot Promise SERVICE_INFORMATION ActsAnsGetSlotTestPromise_0200 finish====>");
...@@ -131,7 +129,6 @@ describe('ActsAnsGetSlotTestPromise', function () { ...@@ -131,7 +129,6 @@ describe('ActsAnsGetSlotTestPromise', function () {
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
expect(data.lockscreenVisibility).assertEqual(3); expect(data.lockscreenVisibility).assertEqual(3);
expect(data.vibrationEnabled).assertEqual(false); expect(data.vibrationEnabled).assertEqual(false);
expect(data.sound).assertEqual("");
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlot Promise CONTENT_INFORMATION ActsAnsGetSlotTestPromise_0300 finish====>"); console.debug("====>getSlot Promise CONTENT_INFORMATION ActsAnsGetSlotTestPromise_0300 finish====>");
...@@ -174,7 +171,6 @@ describe('ActsAnsGetSlotTestPromise', function () { ...@@ -174,7 +171,6 @@ describe('ActsAnsGetSlotTestPromise', function () {
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
expect(data.lockscreenVisibility).assertEqual(3); expect(data.lockscreenVisibility).assertEqual(3);
expect(data.vibrationEnabled).assertEqual(false); expect(data.vibrationEnabled).assertEqual(false);
expect(data.sound).assertEqual("");
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlot Promise OTHER_TYPES ActsAnsGetSlotTestPromise_0400 finish====>"); console.debug("====>getSlot Promise OTHER_TYPES ActsAnsGetSlotTestPromise_0400 finish====>");
...@@ -217,7 +213,6 @@ describe('ActsAnsGetSlotTestPromise', function () { ...@@ -217,7 +213,6 @@ describe('ActsAnsGetSlotTestPromise', function () {
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
expect(data.lockscreenVisibility).assertEqual(3); expect(data.lockscreenVisibility).assertEqual(3);
expect(data.vibrationEnabled).assertEqual(false); expect(data.vibrationEnabled).assertEqual(false);
expect(data.sound).assertEqual("");
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlotPromise UNKNOWN_TYPE ActsAnsGetSlotTestPromise_0500 finish====>"); console.debug("====>getSlotPromise UNKNOWN_TYPE ActsAnsGetSlotTestPromise_0500 finish====>");
......
...@@ -38,7 +38,6 @@ describe('ActsAnsRemoveSlotTest', function () { ...@@ -38,7 +38,6 @@ describe('ActsAnsRemoveSlotTest', function () {
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
expect(data.lockscreenVisibility).assertEqual(2); expect(data.lockscreenVisibility).assertEqual(2);
expect(data.vibrationEnabled).assertEqual(true); expect(data.vibrationEnabled).assertEqual(true);
expect(data.sound).assertEqual("");
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlot ActsAnsRemoveSlotTest_0100 finish====>"); console.debug("====>getSlot ActsAnsRemoveSlotTest_0100 finish====>");
...@@ -83,7 +82,6 @@ describe('ActsAnsRemoveSlotTest', function () { ...@@ -83,7 +82,6 @@ describe('ActsAnsRemoveSlotTest', function () {
expect(data.bypassDnd).assertEqual(false); expect(data.bypassDnd).assertEqual(false);
expect(data.lockscreenVisibility).assertEqual(2); expect(data.lockscreenVisibility).assertEqual(2);
expect(data.vibrationEnabled).assertEqual(true); expect(data.vibrationEnabled).assertEqual(true);
expect(data.sound).assertEqual("");
expect(data.lightEnabled).assertEqual(false); expect(data.lightEnabled).assertEqual(false);
expect(data.lightColor).assertEqual(0); expect(data.lightColor).assertEqual(0);
console.debug("====>getSlot ActsAnsRemoveSlotTest_0200 finish====>"); console.debug("====>getSlot ActsAnsRemoveSlotTest_0200 finish====>");
......
...@@ -28,8 +28,8 @@ var idRecord = new Array(20).fill(0); ...@@ -28,8 +28,8 @@ var idRecord = new Array(20).fill(0);
const publishFrequence = 10; const publishFrequence = 10;
const TIMEOUT = 3000; const TIMEOUT = 3000;
function consumeCallback(err,data) { function consumeCallback(data) {
console.debug("====>consumeCallback err: ====>" + JSON.stringify(err)); console.debug("====>consumeCallback data: ====>" + JSON.stringify(data));
console.debug("====>consumeCallback id: ====>" + data.request.id); console.debug("====>consumeCallback id: ====>" + data.request.id);
switch(data.request.id){ switch(data.request.id){
case 1: case 1:
...@@ -120,9 +120,8 @@ function consumeCallback(err,data) { ...@@ -120,9 +120,8 @@ function consumeCallback(err,data) {
} }
} }
function subscribeOnCallback(err) { function subscribeOnCallback() {
console.debug("====>subscribeOnCallback err: ====>" + JSON.stringify(err)); console.debug("====>subscribeOnCallback enter====>");
expect(err.code).assertEqual(0);
} }
function subscribeCallback(err) { function subscribeCallback(err) {
...@@ -193,7 +192,8 @@ describe('ActsAnsPublishControlTest', function () { ...@@ -193,7 +192,8 @@ describe('ActsAnsPublishControlTest', function () {
/* /*
* @tc.number : ActsAnsPublishControlTest_0100 * @tc.number : ActsAnsPublishControlTest_0100
* @tc.name : Verify rejection of publishing notifications that exceed the threshold * @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) { it('ActsAnsPublishControlTest_0100', 0, async function (done) {
console.debug("====>ActsAnsPublishControlTest_0100 start====>"); console.debug("====>ActsAnsPublishControlTest_0100 start====>");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册