未验证 提交 480bc732 编写于 作者: O openharmony_ci 提交者: Gitee

!5582 solve XTS ActsAmsUsersSystemTest fail problem

Merge pull request !5582 from zhoujun62/OpenHarmony-3.2-Beta3
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
* limitations under the License. * limitations under the License.
*/ */
import commonEvent from "@ohos.commonEvent" import commonEvent from "@ohos.commonEvent"
import featureAbility from '@ohos.ability.featureAbility' import particleAbility from '@ohos.ability.particleAbility'
export default { export default {
onStart() { onStart() {
console.info('ServiceAbility onStart'); console.info('ServiceAbility onStart');
commonEvent.publish("ACTS_InterfaceMultiUsers_0100_Start_CommonEvent", () => { commonEvent.publish("ACTS_InterfaceMultiUsers_0100_Start_CommonEvent", () => {
console.log(" Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback") console.log(" Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback")
featureAbility.terminateSelf().then(() => { particleAbility.terminateSelf().then(() => {
console.log('terminateSelf promise'); console.log('terminateSelf promise');
commonEvent.publish("ACTS_TerminateSelf_CommonEvent", () => { commonEvent.publish("ACTS_TerminateSelf_CommonEvent", () => {
console.log(" Publish ACTS_TerminateSelf_CommonEvent callback") console.log(" Publish ACTS_TerminateSelf_CommonEvent callback")
......
...@@ -65,6 +65,13 @@ export default function abilityTest() { ...@@ -65,6 +65,13 @@ export default function abilityTest() {
}, 1000); }, 1000);
}) })
afterEach(async (done) => {
console.error("ACTS_InterfaceMultiUsers afterEach called");
setTimeout(function() {
done();
}, 500);
})
console.debug("====>in ACTS_InterfaceMultiUsers====>"); console.debug("====>in ACTS_InterfaceMultiUsers====>");
/* /*
* @tc.number : ACTS_startAbility_0100 * @tc.number : ACTS_startAbility_0100
...@@ -72,24 +79,25 @@ export default function abilityTest() { ...@@ -72,24 +79,25 @@ export default function abilityTest() {
* @tc.desc : Start an ability with the parameter startability with options succeeded.(promise) * @tc.desc : Start an ability with the parameter startability with options succeeded.(promise)
*/ */
it('ACTS_StartAbility_0100', 0, async function (done) { it('ACTS_StartAbility_0100', 0, async function (done) {
let TAG = 'ACTS_StartAbility_0100'
let Subscriber let Subscriber
var flag = true var flag = true
var startresult = false var startresult = false
function SubscribeCallBack (err, data) { function SubscribeCallBack (err, data) {
expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue();
console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); console.debug(TAG + "====>0100 Subscribe CallBack data:====>" + JSON.stringify(data));
if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){
startresult = true startresult = true
} }
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
} }
commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => {
console.debug("====>Create Subscriber====>"); console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{ data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data; Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack); commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>"); console.debug(TAG + "====>start startAbility====>");
await globalThis.abilityContext.startAbility( await globalThis.abilityContext.startAbility(
{ {
bundleName: 'com.acts.actsinterfacemultiuserstest', bundleName: 'com.acts.actsinterfacemultiuserstest',
...@@ -97,14 +105,14 @@ export default function abilityTest() { ...@@ -97,14 +105,14 @@ export default function abilityTest() {
}, { }, {
windowMode:0 windowMode:0
}).then((data)=>{ }).then((data)=>{
console.debug("====>startAbility end====>"); console.debug(TAG + "====>startAbility end====>");
console.debug("====>data is====>" + JSON.stringify(data)); console.debug(TAG + "====>data is====>" + JSON.stringify(data));
}) })
}) })
}) })
function UnSubscribeCallback() { function UnSubscribeCallback() {
console.debug("====>UnSubscribeCallback====>"); console.debug(TAG + "====>UnSubscribeCallback====>");
flag = false flag = false
expect(startresult).assertEqual(true); expect(startresult).assertEqual(true);
done(); done();
...@@ -113,7 +121,7 @@ export default function abilityTest() { ...@@ -113,7 +121,7 @@ export default function abilityTest() {
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('ACTS_startAbility_0100 - timeout'); console.debug(TAG + 'ACTS_startAbility_0100 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
} }
} }
...@@ -127,20 +135,21 @@ export default function abilityTest() { ...@@ -127,20 +135,21 @@ export default function abilityTest() {
* @tc.desc : Start an ability with the parameter startability with options failed.(promise) * @tc.desc : Start an ability with the parameter startability with options failed.(promise)
*/ */
it('ACTS_StartAbility_0200', 0, async function (done) { it('ACTS_StartAbility_0200', 0, async function (done) {
let TAG = 'ACTS_StartAbility_0200'
let Subscriber let Subscriber
function SubscribeCallBack (err, data) { function SubscribeCallBack (err, data) {
expect().assertFail(); expect().assertFail();
console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); console.debug(TAG + "====>0200 Subscribe CallBack data:====>" + JSON.stringify(data));
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
} }
commonEvent.createSubscriber(subscriberInfo_MainAbility).then((data) => { commonEvent.createSubscriber(subscriberInfo_MainAbility).then((data) => {
console.debug("====>Create Subscriber====>"); console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{ data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data; Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack); commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>"); console.debug(TAG + "====>start startAbility====>");
await globalThis.abilityContext.startAbility( await globalThis.abilityContext.startAbility(
{ {
bundleName: 'com.acts.error', bundleName: 'com.acts.error',
...@@ -148,18 +157,18 @@ export default function abilityTest() { ...@@ -148,18 +157,18 @@ export default function abilityTest() {
}, { }, {
windowMode:0 windowMode:0
}).then(()=>{ }).then(()=>{
console.debug("====>startAbility end====>"); console.debug(TAG + "====>startAbility end====>");
}) })
}) })
}) })
function UnSubscribeCallback() { function UnSubscribeCallback() {
console.debug("====>UnSubscribeCallback====>"); console.debug(TAG + "====>UnSubscribeCallback====>");
done(); done();
} }
function timeout() { function timeout() {
console.debug('ACTS_startAbility_0200 - timeout'); console.debug(TAG + 'ACTS_startAbility_0200 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
} }
...@@ -172,12 +181,13 @@ export default function abilityTest() { ...@@ -172,12 +181,13 @@ export default function abilityTest() {
* @tc.desc : Start an ability with the parameter startability with options succeeded.(callback) * @tc.desc : Start an ability with the parameter startability with options succeeded.(callback)
*/ */
it('ACTS_StartAbility_0300', 0, async function (done) { it('ACTS_StartAbility_0300', 0, async function (done) {
let TAG = 'ACTS_StartAbility_0300'
let Subscriber let Subscriber
var flag = true var flag = true
var startresult = false var startresult = false
function SubscribeCallBack (err, data) { function SubscribeCallBack (err, data) {
expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue();
console.debug("====>0300 Subscribe CallBack data:====>" + JSON.stringify(data)); console.debug(TAG + "====>0300 Subscribe CallBack data:====>" + JSON.stringify(data));
if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){
startresult = true startresult = true
} }
...@@ -185,12 +195,12 @@ export default function abilityTest() { ...@@ -185,12 +195,12 @@ export default function abilityTest() {
} }
commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => {
console.debug("====>Create Subscriber====>"); console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{ data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data; Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack); commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>"); console.debug(TAG + "====>start startAbility====>");
globalThis.abilityContext.startAbility( globalThis.abilityContext.startAbility(
{ {
bundleName: 'com.acts.actsinterfacemultiuserstest', bundleName: 'com.acts.actsinterfacemultiuserstest',
...@@ -198,14 +208,14 @@ export default function abilityTest() { ...@@ -198,14 +208,14 @@ export default function abilityTest() {
}, { }, {
windowMode:0 windowMode:0
},() => { },() => {
console.debug("====>startAbility end====>" ); console.debug(TAG + "====>startAbility end====>" );
}) })
}) })
}) })
function UnSubscribeCallback() { function UnSubscribeCallback() {
flag = false flag = false
console.debug("====>UnSubscribeCallback====>"); console.debug(TAG + "====>UnSubscribeCallback====>");
expect(startresult).assertEqual(true); expect(startresult).assertEqual(true);
done(); done();
} }
...@@ -213,7 +223,7 @@ export default function abilityTest() { ...@@ -213,7 +223,7 @@ export default function abilityTest() {
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('ACTS_startAbility_0300 - timeout'); console.debug(TAG + 'ACTS_startAbility_0300 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
} }
} }
...@@ -228,21 +238,22 @@ export default function abilityTest() { ...@@ -228,21 +238,22 @@ export default function abilityTest() {
* @tc.desc : Start an ability with the parameter startability with options failed.(callback) * @tc.desc : Start an ability with the parameter startability with options failed.(callback)
*/ */
it('ACTS_StartAbility_0400', 0, async function (done) { it('ACTS_StartAbility_0400', 0, async function (done) {
let TAG = 'ACTS_StartAbility_0400'
let Subscriber let Subscriber
function SubscribeCallBack (err, data) { function SubscribeCallBack (err, data) {
expect().assertFail(); expect().assertFail();
console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); console.debug(TAG + "====>0200 Subscribe CallBack data:====>" + JSON.stringify(data));
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
} }
commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => {
console.debug("====>Create Subscriber====>"); console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{ data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data; Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack); commonEvent.subscribe(Subscriber, SubscribeCallBack);
}) })
console.debug("====>start startAbility====>"); console.debug(TAG + "====>start startAbility====>");
await globalThis.abilityContext.startAbility( await globalThis.abilityContext.startAbility(
{ {
bundleName: 'com.acts.error', bundleName: 'com.acts.error',
...@@ -250,17 +261,17 @@ export default function abilityTest() { ...@@ -250,17 +261,17 @@ export default function abilityTest() {
}, { }, {
windowMode:0 windowMode:0
},() => { },() => {
console.debug("====>startAbility end====>" ); console.debug(TAG + "====>startAbility end====>" );
}) })
}) })
function UnSubscribeCallback() { function UnSubscribeCallback() {
console.debug("====>UnSubscribeCallback====>"); console.debug(TAG + "====>UnSubscribeCallback====>");
done(); done();
} }
function timeout() { function timeout() {
console.debug('ACTS_startAbility_0400 - timeout'); console.debug(TAG + 'ACTS_startAbility_0400 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
} }
...@@ -274,37 +285,38 @@ export default function abilityTest() { ...@@ -274,37 +285,38 @@ export default function abilityTest() {
* @tc.desc : Starting mainability2 with startability succeeded.(promise) * @tc.desc : Starting mainability2 with startability succeeded.(promise)
*/ */
it('ACTS_StartAbility_0500', 0, async function (done) { it('ACTS_StartAbility_0500', 0, async function (done) {
let TAG = 'ACTS_StartAbility_0500'
let Subscriber let Subscriber
var flag = true var flag = true
var startresult = false var startresult = false
function SubscribeCallBack (err, data) { function SubscribeCallBack (err, data) {
expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue();
console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); console.debug(TAG + "====>0100 Subscribe CallBack data:====>" + JSON.stringify(data));
if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){
startresult = true startresult = true
} }
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
} }
commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => {
console.debug("====>Create Subscriber====>"); console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{ data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data; Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack); commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>"); console.debug(TAG + "====>start startAbility====>");
await globalThis.abilityContext.startAbility( await globalThis.abilityContext.startAbility(
{ {
bundleName: 'com.acts.actsinterfacemultiuserstest', bundleName: 'com.acts.actsinterfacemultiuserstest',
abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility2' abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility2'
}).then((data)=>{ }).then((data)=>{
console.debug("====>startAbility end====>"); console.debug(TAG + "====>startAbility end====>");
console.debug("====>data is====>" + JSON.stringify(data)); console.debug(TAG + "====>data is====>" + JSON.stringify(data));
}) })
}) })
}) })
function UnSubscribeCallback() { function UnSubscribeCallback() {
console.debug("====>UnSubscribeCallback====>"); console.debug(TAG + "====>UnSubscribeCallback====>");
flag = false flag = false
expect(startresult).assertEqual(true); expect(startresult).assertEqual(true);
done(); done();
...@@ -313,7 +325,7 @@ export default function abilityTest() { ...@@ -313,7 +325,7 @@ export default function abilityTest() {
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('ACTS_startAbility_0100 - timeout'); console.debug(TAG + 'ACTS_startAbility_0100 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
} }
} }
...@@ -327,12 +339,13 @@ export default function abilityTest() { ...@@ -327,12 +339,13 @@ export default function abilityTest() {
* @tc.desc : Starting mainability2 with startability succeeded.(callback) * @tc.desc : Starting mainability2 with startability succeeded.(callback)
*/ */
it('ACTS_StartAbility_0700', 0, async function (done) { it('ACTS_StartAbility_0700', 0, async function (done) {
let TAG = 'ACTS_StartAbility_0700'
let Subscriber let Subscriber
var flag = true var flag = true
var startresult = false var startresult = false
function SubscribeCallBack (err, data) { function SubscribeCallBack (err, data) {
expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue();
console.debug("====>0300 Subscribe CallBack data:====>" + JSON.stringify(data)); console.debug(TAG + "====>0300 Subscribe CallBack data:====>" + JSON.stringify(data));
if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){
startresult = true startresult = true
} }
...@@ -340,25 +353,25 @@ export default function abilityTest() { ...@@ -340,25 +353,25 @@ export default function abilityTest() {
} }
commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => {
console.debug("====>Create Subscriber====>"); console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{ data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data; Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack); commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>"); console.debug(TAG + "====>start startAbility====>");
globalThis.abilityContext.startAbility( globalThis.abilityContext.startAbility(
{ {
bundleName: 'com.acts.actsinterfacemultiuserstest', bundleName: 'com.acts.actsinterfacemultiuserstest',
abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility2' abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility2'
},() => { },() => {
console.debug("====>startAbility end====>" ); console.debug(TAG + "====>startAbility end====>" );
}) })
}) })
}) })
function UnSubscribeCallback() { function UnSubscribeCallback() {
flag = false flag = false
console.debug("====>UnSubscribeCallback====>"); console.debug(TAG + "====>UnSubscribeCallback====>");
expect(startresult).assertEqual(true); expect(startresult).assertEqual(true);
done(); done();
} }
...@@ -366,7 +379,7 @@ export default function abilityTest() { ...@@ -366,7 +379,7 @@ export default function abilityTest() {
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('ACTS_startAbility_0300 - timeout'); console.debug(TAG + 'ACTS_startAbility_0300 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
} }
} }
...@@ -381,36 +394,37 @@ export default function abilityTest() { ...@@ -381,36 +394,37 @@ export default function abilityTest() {
* @tc.desc : Start an ability with the parameter startability with options succeeded.(promise) * @tc.desc : Start an ability with the parameter startability with options succeeded.(promise)
*/ */
it('ACTS_StartAbility_0900', 0, async function (done) { it('ACTS_StartAbility_0900', 0, async function (done) {
let TAG = 'ACTS_StartAbility_0900'
let Subscriber let Subscriber
var flag = true var flag = true
var startresult = false var startresult = false
function SubscribeCallBack (err, data) { function SubscribeCallBack (err, data) {
expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue();
console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); console.debug(TAG + "====>0100 Subscribe CallBack data:====>" + JSON.stringify(data));
if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){
startresult = true startresult = true
} }
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
} }
commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => {
console.debug("====>Create Subscriber====>"); console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{ data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data; Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack); commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>"); console.debug(TAG + "====>start startAbility====>");
await globalThis.abilityContext.startAbility( await globalThis.abilityContext.startAbility(
{ {
bundleName: 'com.example.userservicesystemapi7', bundleName: 'com.example.userservicesystemapi7',
abilityName: 'com.example.userservicesystemapi7.ServiceAbility' abilityName: 'com.example.userservicesystemapi7.ServiceAbility'
}).then(()=>{ }).then(()=>{
console.debug("====>startAbility end====>"); console.debug(TAG + "====>startAbility end====>");
}) })
}) })
}) })
function UnSubscribeCallback() { function UnSubscribeCallback() {
console.debug("====>UnSubscribeCallback====>"); console.debug(TAG + "====>UnSubscribeCallback====>");
flag = false flag = false
expect(startresult).assertEqual(true); expect(startresult).assertEqual(true);
done(); done();
...@@ -419,7 +433,7 @@ export default function abilityTest() { ...@@ -419,7 +433,7 @@ export default function abilityTest() {
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('ACTS_startAbility_0900 - timeout'); console.debug(TAG + 'ACTS_startAbility_0900 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
} }
} }
...@@ -432,36 +446,37 @@ export default function abilityTest() { ...@@ -432,36 +446,37 @@ export default function abilityTest() {
* @tc.desc : Start an ability with the parameter startability with options succeeded.(promise) * @tc.desc : Start an ability with the parameter startability with options succeeded.(promise)
*/ */
it('ACTS_startAbility_1000', 0, async function (done) { it('ACTS_startAbility_1000', 0, async function (done) {
let TAG = 'ACTS_startAbility_1000'
let Subscriber let Subscriber
var flag = true var flag = true
var startresult = false var startresult = false
function SubscribeCallBack (err, data) { function SubscribeCallBack (err, data) {
expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue();
console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); console.debug(TAG + "====>0100 Subscribe CallBack data:====>" + JSON.stringify(data));
if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){
startresult = true startresult = true
} }
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
} }
commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => {
console.debug("====>Create Subscriber====>"); console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{ data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data; Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack); commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>"); console.debug(TAG + "====>start startAbility====>");
await globalThis.abilityContext.startAbility( await globalThis.abilityContext.startAbility(
{ {
bundleName: 'com.example.userservicesystemapi7', bundleName: 'com.example.userservicesystemapi7',
abilityName: 'com.example.userservicesystemapi7.ServiceAbility' abilityName: 'com.example.userservicesystemapi7.ServiceAbility'
},()=>{ },()=>{
console.debug("====>startAbility end====>"); console.debug(TAG + "====>startAbility end====>");
}) })
}) })
}) })
function UnSubscribeCallback() { function UnSubscribeCallback() {
console.debug("====>UnSubscribeCallback====>"); console.debug(TAG + "====>UnSubscribeCallback====>");
flag = false flag = false
expect(startresult).assertEqual(true); expect(startresult).assertEqual(true);
done(); done();
...@@ -470,7 +485,7 @@ export default function abilityTest() { ...@@ -470,7 +485,7 @@ export default function abilityTest() {
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('ACTS_startAbility_1000 - timeout'); console.debug(TAG + 'ACTS_startAbility_1000 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
} }
} }
...@@ -484,16 +499,17 @@ export default function abilityTest() { ...@@ -484,16 +499,17 @@ export default function abilityTest() {
* @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(promise) * @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(promise)
*/ */
it('ACTS_StartAbilityForResult_0100', 0, async function (done) { it('ACTS_StartAbilityForResult_0100', 0, async function (done) {
let TAG = 'ACTS_StartAbilityForResult_0100'
var flag = true var flag = true
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('AMS_startAbilityForResult_0100 - timeout'); console.debug(TAG + 'AMS_startAbilityForResult_0100 - timeout');
done(); done();
} }
} }
setTimeout(timeout, START_ABILITY_TIMEOUT); setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>"); console.debug(TAG + "====>start startAbilityForResult====>");
await globalThis.abilityContext.startAbilityForResult( await globalThis.abilityContext.startAbilityForResult(
{ {
bundleName: 'com.acts.actsinterfacemultiuserstest', bundleName: 'com.acts.actsinterfacemultiuserstest',
...@@ -501,9 +517,9 @@ export default function abilityTest() { ...@@ -501,9 +517,9 @@ export default function abilityTest() {
}, { }, {
windowMode:0 windowMode:0
}).then((data)=>{ }).then((data)=>{
console.debug("====>startAbilityForResult end====>"); console.debug(TAG + "====>startAbilityForResult end====>");
flag = false flag = false
console.debug("====>data.resultCode is====>"+JSON); console.debug(TAG + "====>data.resultCode is====>"+JSON);
expect(data.resultCode).assertEqual(1) expect(data.resultCode).assertEqual(1)
expect(data.want.action).assertEqual('ACTION') expect(data.want.action).assertEqual('ACTION')
done(); done();
...@@ -516,12 +532,13 @@ export default function abilityTest() { ...@@ -516,12 +532,13 @@ export default function abilityTest() {
* @tc.desc : Starting mainability3 with startAbilityForResult failed.(promise) * @tc.desc : Starting mainability3 with startAbilityForResult failed.(promise)
*/ */
it('ACTS_StartAbilityForResult_0200', 0, async function (done) { it('ACTS_StartAbilityForResult_0200', 0, async function (done) {
let TAG = 'ACTS_StartAbilityForResult_0200'
function timeout() { function timeout() {
console.debug('ACTS_startAbilityForResult_0200 - timeout'); console.debug(TAG + 'ACTS_startAbilityForResult_0200 - timeout');
done(); done();
} }
setTimeout(timeout, START_ABILITY_TIMEOUT); setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>"); console.debug(TAG + "====>start startAbilityForResult====>");
await globalThis.abilityContext.startAbilityForResult( await globalThis.abilityContext.startAbilityForResult(
{ {
bundleName: 'com.acts.error', bundleName: 'com.acts.error',
...@@ -529,7 +546,7 @@ export default function abilityTest() { ...@@ -529,7 +546,7 @@ export default function abilityTest() {
}, { }, {
windowMode:0 windowMode:0
}).then((data)=>{ }).then((data)=>{
console.debug("====>startAbilityForResult end====>"); console.debug(TAG + "====>startAbilityForResult end====>");
expect().assertFail(); expect().assertFail();
expect(data.resultCode).assertEqual(1) expect(data.resultCode).assertEqual(1)
expect(data.want.action).assertEqual('ACTION') expect(data.want.action).assertEqual('ACTION')
...@@ -543,16 +560,17 @@ export default function abilityTest() { ...@@ -543,16 +560,17 @@ export default function abilityTest() {
* @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(callback) * @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(callback)
*/ */
it('ACTS_StartAbilityForResult_0300', 0, async function (done) { it('ACTS_StartAbilityForResult_0300', 0, async function (done) {
let TAG = 'ACTS_StartAbilityForResult_0300'
var flag = true var flag = true
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('ACTS_startAbilityForResult_0300 - timeout'); console.debug(TAG + 'ACTS_startAbilityForResult_0300 - timeout');
done(); done();
} }
} }
setTimeout(timeout, START_ABILITY_TIMEOUT); setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>"); console.debug(TAG + "====>start startAbilityForResult====>");
await globalThis.abilityContext.startAbilityForResult( await globalThis.abilityContext.startAbilityForResult(
{ {
bundleName: 'com.acts.actsinterfacemultiuserstest', bundleName: 'com.acts.actsinterfacemultiuserstest',
...@@ -560,7 +578,7 @@ export default function abilityTest() { ...@@ -560,7 +578,7 @@ export default function abilityTest() {
},{ },{
windowMode : 0 windowMode : 0
},(err,data)=>{ },(err,data)=>{
console.debug("====>startAbilityForResult end====>"); console.debug(TAG + "====>startAbilityForResult end====>");
flag = false flag = false
expect(data.resultCode).assertEqual(1) expect(data.resultCode).assertEqual(1)
expect(data.want.action).assertEqual('ACTION') expect(data.want.action).assertEqual('ACTION')
...@@ -574,12 +592,13 @@ export default function abilityTest() { ...@@ -574,12 +592,13 @@ export default function abilityTest() {
* @tc.desc : Starting mainability3 with startAbilityForResult failed.(callback) * @tc.desc : Starting mainability3 with startAbilityForResult failed.(callback)
*/ */
it('ACTS_StartAbilityForResult_0400', 0, async function (done) { it('ACTS_StartAbilityForResult_0400', 0, async function (done) {
let TAG = 'ACTS_StartAbilityForResult_0400'
function timeout() { function timeout() {
console.debug('ACTS_startAbilityForResult_0400 - timeout'); console.debug(TAG + 'ACTS_startAbilityForResult_0400 - timeout');
done(); done();
} }
setTimeout(timeout, START_ABILITY_TIMEOUT); setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>"); console.debug(TAG + "====>start startAbilityForResult====>");
await globalThis.abilityContext.startAbilityForResult( await globalThis.abilityContext.startAbilityForResult(
{ {
bundleName: 'com.acts.error', bundleName: 'com.acts.error',
...@@ -588,7 +607,7 @@ export default function abilityTest() { ...@@ -588,7 +607,7 @@ export default function abilityTest() {
windowMode:0 windowMode:0
},(err,data)=>{ },(err,data)=>{
expect().assertFail(); expect().assertFail();
console.debug("====>startAbilityForResult end====>"); console.debug(TAG + "====>startAbilityForResult end====>");
expect(data.resultCode).assertEqual(1) expect(data.resultCode).assertEqual(1)
expect(data.want.action).assertEqual('ACTION') expect(data.want.action).assertEqual('ACTION')
done(); done();
...@@ -601,24 +620,25 @@ export default function abilityTest() { ...@@ -601,24 +620,25 @@ export default function abilityTest() {
* @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(promise) * @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(promise)
*/ */
it('ACTS_StartAbilityForResult_0500', 0, async function (done) { it('ACTS_StartAbilityForResult_0500', 0, async function (done) {
let TAG = 'ACTS_StartAbilityForResult_0500'
var flag = true var flag = true
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('AMS_startAbilityForResult_0500 - timeout'); console.debug(TAG + 'AMS_startAbilityForResult_0500 - timeout');
done(); done();
} }
} }
setTimeout(timeout, START_ABILITY_TIMEOUT); setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>"); console.debug(TAG + "====>start startAbilityForResult====>");
await globalThis.abilityContext.startAbilityForResult( await globalThis.abilityContext.startAbilityForResult(
{ {
bundleName: 'com.acts.actsinterfacemultiuserstest', bundleName: 'com.acts.actsinterfacemultiuserstest',
abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3',
}).then((data)=>{ }).then((data)=>{
console.debug("====>startAbilityForResult end====>"); console.debug(TAG + "====>startAbilityForResult end====>");
flag = false flag = false
console.debug("====>data.resultCode is====>"+JSON); console.debug(TAG + "====>data.resultCode is====>"+JSON);
expect(data.resultCode).assertEqual(1) expect(data.resultCode).assertEqual(1)
expect(data.want.action).assertEqual('ACTION') expect(data.want.action).assertEqual('ACTION')
done(); done();
...@@ -631,22 +651,23 @@ export default function abilityTest() { ...@@ -631,22 +651,23 @@ export default function abilityTest() {
* @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(callback) * @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(callback)
*/ */
it('ACTS_StartAbilityForResult_0700', 0, async function (done) { it('ACTS_StartAbilityForResult_0700', 0, async function (done) {
let TAG = 'ACTS_StartAbilityForResult_0700'
var flag = true var flag = true
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('ACTS_startAbilityForResult_0700 - timeout'); console.debug(TAG + 'ACTS_startAbilityForResult_0700 - timeout');
done(); done();
} }
} }
setTimeout(timeout, START_ABILITY_TIMEOUT); setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>"); console.debug(TAG + "====>start startAbilityForResult====>");
await globalThis.abilityContext.startAbilityForResult( await globalThis.abilityContext.startAbilityForResult(
{ {
bundleName: 'com.acts.actsinterfacemultiuserstest', bundleName: 'com.acts.actsinterfacemultiuserstest',
abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3',
},(err,data)=>{ },(err,data)=>{
console.debug("====>startAbilityForResult end====>"); console.debug(TAG + "====>startAbilityForResult end====>");
flag = false flag = false
expect(data.resultCode).assertEqual(1) expect(data.resultCode).assertEqual(1)
expect(data.want.action).assertEqual('ACTION') expect(data.want.action).assertEqual('ACTION')
...@@ -660,38 +681,39 @@ export default function abilityTest() { ...@@ -660,38 +681,39 @@ export default function abilityTest() {
* @tc.desc : Starting mainability2 with startAbility then terminateself ability succeeded.(promise) * @tc.desc : Starting mainability2 with startAbility then terminateself ability succeeded.(promise)
*/ */
it('ACTS_TerminateSelf_0100', 0, async function (done) { it('ACTS_TerminateSelf_0100', 0, async function (done) {
let TAG = 'ACTS_TerminateSelf_0100'
let Subscriber let Subscriber
var flag = true var flag = true
var terminateresult = false var terminateresult = false
function SubscribeCallBack (err, data) { function SubscribeCallBack (err, data) {
expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue();
console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); console.debug(TAG + "====>0100 Subscribe CallBack data:====>" + JSON.stringify(data));
if(data.event == "ACTS_TerminateSelf_CommonEvent"){ if(data.event == "ACTS_TerminateSelf_CommonEvent"){
terminateresult = true terminateresult = true
console.debug("====>terminateresult is:====>" + JSON.stringify(terminateresult)); console.debug(TAG + "====>terminateresult is:====>" + JSON.stringify(terminateresult));
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
} }
} }
commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => {
console.debug("====>Create Subscriber====>"); console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{ data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data; Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack); commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>"); console.debug(TAG + "====>start startAbility====>");
await globalThis.abilityContext.startAbility( await globalThis.abilityContext.startAbility(
{ {
bundleName: 'com.acts.actsinterfacemultiuserstest', bundleName: 'com.acts.actsinterfacemultiuserstest',
abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility2' abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility2'
}).then(()=>{ }).then(()=>{
console.debug("====>startAbility end====>"); console.debug(TAG + "====>startAbility end====>");
}) })
}) })
}) })
function UnSubscribeCallback() { function UnSubscribeCallback() {
console.debug("====>UnSubscribeCallback====>"); console.debug(TAG + "====>UnSubscribeCallback====>");
flag = false flag = false
expect(terminateresult).assertEqual(true); expect(terminateresult).assertEqual(true);
done(); done();
...@@ -700,7 +722,7 @@ export default function abilityTest() { ...@@ -700,7 +722,7 @@ export default function abilityTest() {
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('ACTS_TerminateSelf_0100 - timeout'); console.debug(TAG + 'ACTS_TerminateSelf_0100 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
} }
} }
...@@ -715,12 +737,13 @@ export default function abilityTest() { ...@@ -715,12 +737,13 @@ export default function abilityTest() {
* @tc.desc : Starting mainability2 with startAbility then terminateself ability succeeded.(callback) * @tc.desc : Starting mainability2 with startAbility then terminateself ability succeeded.(callback)
*/ */
it('ACTS_TerminateSelf_0300', 0, async function (done) { it('ACTS_TerminateSelf_0300', 0, async function (done) {
let TAG = 'ACTS_TerminateSelf_0300'
let Subscriber let Subscriber
var flag = true var flag = true
var terminateresult = false var terminateresult = false
function SubscribeCallBack (err, data) { function SubscribeCallBack (err, data) {
expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue();
console.debug("====>0300 Subscribe CallBack data:====>" + JSON.stringify(data)); console.debug(TAG + "====>0300 Subscribe CallBack data:====>" + JSON.stringify(data));
if(data.event == "ACTS_TerminateSelf_CommonEvent"){ if(data.event == "ACTS_TerminateSelf_CommonEvent"){
terminateresult = true terminateresult = true
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
...@@ -729,25 +752,25 @@ export default function abilityTest() { ...@@ -729,25 +752,25 @@ export default function abilityTest() {
} }
commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => {
console.debug("====>Create Subscriber====>"); console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async(SubscribeInfo)=>{ data.getSubscribeInfo().then(async(SubscribeInfo)=>{
console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data; Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack); commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>"); console.debug(TAG + "====>start startAbility====>");
globalThis.abilityContext.startAbility( globalThis.abilityContext.startAbility(
{ {
bundleName: 'com.acts.actsinterfacemultiuserstest', bundleName: 'com.acts.actsinterfacemultiuserstest',
abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility2' abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility2'
},() => { },() => {
console.debug("====>startAbility end====>" ); console.debug(TAG + "====>startAbility end====>" );
}) })
}) })
}) })
function UnSubscribeCallback() { function UnSubscribeCallback() {
flag = false flag = false
console.debug("====>UnSubscribeCallback====>"); console.debug(TAG + "====>UnSubscribeCallback====>");
expect(terminateresult).assertEqual(true); expect(terminateresult).assertEqual(true);
done(); done();
} }
...@@ -755,7 +778,7 @@ export default function abilityTest() { ...@@ -755,7 +778,7 @@ export default function abilityTest() {
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('ACTS_TerminateSelf_0300 - timeout'); console.debug(TAG + 'ACTS_TerminateSelf_0300 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
} }
} }
...@@ -771,24 +794,25 @@ export default function abilityTest() { ...@@ -771,24 +794,25 @@ export default function abilityTest() {
* then terminateself ability and return result succeeded.(promise) * then terminateself ability and return result succeeded.(promise)
*/ */
it('ACTS_TerminateSelfWithResult_0100', 0, async function (done) { it('ACTS_TerminateSelfWithResult_0100', 0, async function (done) {
let TAG = 'ACTS_TerminateSelfWithResult_0100'
var flag = true var flag = true
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('ACTS_TerminateSelfWithResult_0100 - timeout'); console.debug(TAG + 'ACTS_TerminateSelfWithResult_0100 - timeout');
done(); done();
} }
} }
setTimeout(timeout, START_ABILITY_TIMEOUT); setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>"); console.debug(TAG + "====>start startAbilityForResult====>");
await globalThis.abilityContext.startAbilityForResult( await globalThis.abilityContext.startAbilityForResult(
{ {
bundleName: 'com.acts.actsinterfacemultiuserstest', bundleName: 'com.acts.actsinterfacemultiuserstest',
abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3',
}).then((data)=>{ }).then((data)=>{
console.debug("====>startAbilityForResult end====>"); console.debug(TAG + "====>startAbilityForResult end====>");
flag = false flag = false
console.debug("====>data.resultCode is====>"+JSON); console.debug(TAG + "====>data.resultCode is====>"+JSON);
expect(data.resultCode).assertEqual(1) expect(data.resultCode).assertEqual(1)
expect(data.want.action).assertEqual('ACTION') expect(data.want.action).assertEqual('ACTION')
done(); done();
...@@ -802,23 +826,24 @@ export default function abilityTest() { ...@@ -802,23 +826,24 @@ export default function abilityTest() {
* then terminateself ability and return result succeeded.(callback) * then terminateself ability and return result succeeded.(callback)
*/ */
it('ACTS_TerminateSelfWithResult_0300', 0, async function (done) { it('ACTS_TerminateSelfWithResult_0300', 0, async function (done) {
let TAG = 'ACTS_TerminateSelfWithResult_0300'
var flag = true var flag = true
function timeout() { function timeout() {
if (flag == true) { if (flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('ACTS_TerminateSelfWithResult_0300 - timeout'); console.debug(TAG + 'ACTS_TerminateSelfWithResult_0300 - timeout');
done(); done();
} }
} }
setTimeout(timeout, START_ABILITY_TIMEOUT); setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug("====>start startAbilityForResult====>"); console.debug(TAG + "====>start startAbilityForResult====>");
await globalThis.abilityContext.startAbilityForResult( await globalThis.abilityContext.startAbilityForResult(
{ {
bundleName: 'com.acts.actsinterfacemultiuserstest', bundleName: 'com.acts.actsinterfacemultiuserstest',
abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3',
},(err,data)=>{ },(err,data)=>{
flag = false flag = false
console.debug("====>startAbilityForResult end====>"); console.debug(TAG + "====>startAbilityForResult end====>");
expect(data.resultCode).assertEqual(1) expect(data.resultCode).assertEqual(1)
expect(data.want.action).assertEqual('ACTION') expect(data.want.action).assertEqual('ACTION')
done(); done();
...@@ -832,28 +857,29 @@ export default function abilityTest() { ...@@ -832,28 +857,29 @@ export default function abilityTest() {
* then terminateself ability and return result failed.(promise) * then terminateself ability and return result failed.(promise)
*/ */
it('ACTS_KillProcess_0100', 0, async function (done) { it('ACTS_KillProcess_0100', 0, async function (done) {
let TAG = 'ACTS_KillProcess_0100'
var Subscriber var Subscriber
var flag = true var flag = true
function SubscribeCallBack (err, data) { function SubscribeCallBack (err, data) {
expect(data.event == "ACTS_KillProcess").assertTrue(); expect(data.event == "ACTS_KillProcess").assertTrue();
console.debug("====>ACTS_KillProcess_0100 Subscribe CallBack data:====>" + JSON.stringify(data)); console.debug(TAG + "====>ACTS_KillProcess_0100 Subscribe CallBack data:====>" + JSON.stringify(data));
appManager.getProcessRunningInfos().then((data)=> { appManager.getProcessRunningInfos().then((data)=> {
console.info('====>ACTS_KillProcess_0100 getProcessRunningInfos=====>' + JSON.stringify(data)) console.info(TAG + '====>ACTS_KillProcess_0100 getProcessRunningInfos=====>' + JSON.stringify(data))
for(var i = 0; i<data.length ;i++){ for(var i = 0; i<data.length ;i++){
if (data[i].processName=='com.acts.killprocesshap'){ if (data[i].processName=='com.acts.killprocesshap'){
console.info('====>has com.acts.killprocesshap=====>') console.info(TAG + '====>has com.acts.killprocesshap=====>')
break break
} }
} }
console.log('====>i is:====>' + JSON.stringify(i)) console.log(TAG + '====>i is:====>' + JSON.stringify(i))
if(i==data.length && data[i].processName!='com.acts.killprocesshap'){ if(i==data.length && data[i].processName!='com.acts.killprocesshap'){
expect().assertFail() expect().assertFail()
} }
appManager.killProcessesByBundleName('com.acts.killprocesshap').then((data)=>{ appManager.killProcessesByBundleName('com.acts.killprocesshap').then((data)=>{
console.info('====>ACTS_KillProcess_0100 killProcessesByBundleName=====>' + JSON.stringify(data)) console.info(TAG + '====>ACTS_KillProcess_0100 killProcessesByBundleName=====>' + JSON.stringify(data))
setTimeout(()=>{ setTimeout(()=>{
appManager.getProcessRunningInfos().then((data)=> { appManager.getProcessRunningInfos().then((data)=> {
console.info('====>ACTS_KillProcess_0100 getProcessRunningInfos2=====>' + JSON.stringify(data)) console.info(TAG + '====>ACTS_KillProcess_0100 getProcessRunningInfos2=====>' + JSON.stringify(data))
for(var i = 0; i<data.length ;i++){ for(var i = 0; i<data.length ;i++){
if (data[i].processName=='com.acts.killprocesshap'){ if (data[i].processName=='com.acts.killprocesshap'){
expect().assertFail() expect().assertFail()
...@@ -867,24 +893,24 @@ export default function abilityTest() { ...@@ -867,24 +893,24 @@ export default function abilityTest() {
}) })
} }
commonEvent.createSubscriber(subscriberInfo_killprocess).then(async (data) => { commonEvent.createSubscriber(subscriberInfo_killprocess).then(async (data) => {
console.debug("====>Create Subscriber====>"); console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{ data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data; Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack); commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>"); console.debug(TAG + "====>start startAbility====>");
await globalThis.abilityContext.startAbility( await globalThis.abilityContext.startAbility(
{ {
bundleName: 'com.acts.killprocesshap', bundleName: 'com.acts.killprocesshap',
abilityName: 'com.acts.killprocesshap.MainAbility' abilityName: 'com.acts.killprocesshap.MainAbility'
}).then((data)=>{ }).then((data)=>{
console.debug("====>startAbility end====>"); console.debug(TAG + "====>startAbility end====>");
console.debug("====>data is====>" + JSON.stringify(data)); console.debug(TAG + "====>data is====>" + JSON.stringify(data));
}) })
}) })
}) })
function UnSubscribeCallback() { function UnSubscribeCallback() {
console.debug("====>UnSubscribeCallback====>"); console.debug(TAG + "====>UnSubscribeCallback====>");
flag = false flag = false
done(); done();
} }
...@@ -892,7 +918,7 @@ export default function abilityTest() { ...@@ -892,7 +918,7 @@ export default function abilityTest() {
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('ACTS_KillProcess_0100 - timeout'); console.debug(TAG + 'ACTS_KillProcess_0100 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
} }
} }
...@@ -907,28 +933,29 @@ export default function abilityTest() { ...@@ -907,28 +933,29 @@ export default function abilityTest() {
* then terminateself ability and return result failed.(callback) * then terminateself ability and return result failed.(callback)
*/ */
it('ACTS_KillProcess_0200', 0, async function (done) { it('ACTS_KillProcess_0200', 0, async function (done) {
let TAG = 'ACTS_KillProcess_0200'
var Subscriber var Subscriber
var flag = true var flag = true
function SubscribeCallBack (err, data) { function SubscribeCallBack (err, data) {
expect(data.event == "ACTS_KillProcess").assertTrue(); expect(data.event == "ACTS_KillProcess").assertTrue();
console.debug("====>ACTS_KillProcess_0200 Subscribe CallBack data:====>" + JSON.stringify(data)); console.debug(TAG + "====>ACTS_KillProcess_0200 Subscribe CallBack data:====>" + JSON.stringify(data));
appManager.getProcessRunningInfos().then((data)=> { appManager.getProcessRunningInfos().then((data)=> {
console.info('====>ACTS_KillProcess_0200 getProcessRunningInfos=====>' + JSON.stringify(data)) console.info(TAG + '====>ACTS_KillProcess_0200 getProcessRunningInfos=====>' + JSON.stringify(data))
for(var i = 0; i<data.length ;i++){ for(var i = 0; i<data.length ;i++){
if (data[i].processName=='com.acts.killprocesshap'){ if (data[i].processName=='com.acts.killprocesshap'){
console.info('====>has com.acts.killprocesshap=====>') console.info(TAG + '====>has com.acts.killprocesshap=====>')
break break
} }
} }
console.log('====>i is:====>' + JSON.stringify(i)) console.log(TAG + '====>i is:====>' + JSON.stringify(i))
if(i==data.length && data[i].processName!='com.acts.killprocesshap'){ if(i==data.length && data[i].processName!='com.acts.killprocesshap'){
expect().assertFail() expect().assertFail()
} }
appManager.killProcessesByBundleName('com.acts.killprocesshap',(data)=>{ appManager.killProcessesByBundleName('com.acts.killprocesshap',(data)=>{
console.info('====>ACTS_KillProcess_0200 killProcessesByBundleName=====>' + JSON.stringify(data)) console.info(TAG + '====>ACTS_KillProcess_0200 killProcessesByBundleName=====>' + JSON.stringify(data))
setTimeout(()=> { setTimeout(()=> {
appManager.getProcessRunningInfos().then((data) => { appManager.getProcessRunningInfos().then((data) => {
console.info('====>ACTS_KillProcess_0200 getProcessRunningInfos2=====>' + JSON.stringify(data)) console.info(TAG + '====>ACTS_KillProcess_0200 getProcessRunningInfos2=====>' + JSON.stringify(data))
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
if (data[i].processName == 'com.acts.killprocesshap') { if (data[i].processName == 'com.acts.killprocesshap') {
expect().assertFail() expect().assertFail()
...@@ -942,24 +969,24 @@ export default function abilityTest() { ...@@ -942,24 +969,24 @@ export default function abilityTest() {
}) })
} }
commonEvent.createSubscriber(subscriberInfo_killprocess).then(async (data) => { commonEvent.createSubscriber(subscriberInfo_killprocess).then(async (data) => {
console.debug("====>Create Subscriber====>"); console.debug(TAG + "====>Create Subscriber====>");
data.getSubscribeInfo().then(async (SubscribeInfo)=>{ data.getSubscribeInfo().then(async (SubscribeInfo)=>{
console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); console.debug(TAG + "====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo));
Subscriber = data; Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack); commonEvent.subscribe(Subscriber, SubscribeCallBack);
console.debug("====>start startAbility====>"); console.debug(TAG + "====>start startAbility====>");
await globalThis.abilityContext.startAbility( await globalThis.abilityContext.startAbility(
{ {
bundleName: 'com.acts.killprocesshap', bundleName: 'com.acts.killprocesshap',
abilityName: 'com.acts.killprocesshap.MainAbility' abilityName: 'com.acts.killprocesshap.MainAbility'
}).then((data)=>{ }).then((data)=>{
console.debug("====>startAbility end====>"); console.debug(TAG + "====>startAbility end====>");
console.debug("====>data is====>" + JSON.stringify(data)); console.debug(TAG + "====>data is====>" + JSON.stringify(data));
}) })
}) })
}) })
function UnSubscribeCallback() { function UnSubscribeCallback() {
console.debug("====>UnSubscribeCallback====>"); console.debug(TAG + "====>UnSubscribeCallback====>");
flag = false flag = false
done(); done();
} }
...@@ -967,7 +994,7 @@ export default function abilityTest() { ...@@ -967,7 +994,7 @@ export default function abilityTest() {
function timeout() { function timeout() {
if(flag == true) { if(flag == true) {
expect().assertFail(); expect().assertFail();
console.debug('ACTS_KillProcess_0200 - timeout'); console.debug(TAG + 'ACTS_KillProcess_0200 - timeout');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
} }
} }
...@@ -982,24 +1009,25 @@ export default function abilityTest() { ...@@ -982,24 +1009,25 @@ export default function abilityTest() {
* then terminateself ability and return result failed.(promise) * then terminateself ability and return result failed.(promise)
*/ */
it('ACTS_ThirdPartyKillProcess_0100', 0, async function (done) { it('ACTS_ThirdPartyKillProcess_0100', 0, async function (done) {
console.debug("====>start startAbility====>"); let TAG = 'ACTS_ThirdPartyKillProcess_0100'
console.debug(TAG + "====>start startAbility====>");
await globalThis.abilityContext.startAbility( await globalThis.abilityContext.startAbility(
{ {
bundleName: 'com.acts.killprocessthirdhap', bundleName: 'com.acts.killprocessthirdhap',
abilityName: 'com.acts.killprocessthirdhap.MainAbility' abilityName: 'com.acts.killprocessthirdhap.MainAbility'
}).then(()=>{ }).then(()=>{
console.debug("====>startAbility end====>"); console.debug(TAG + "====>startAbility end====>");
}) })
setTimeout(()=>{ setTimeout(()=>{
appManager.getProcessRunningInfos().then((data)=> { appManager.getProcessRunningInfos().then((data)=> {
console.info('====>ACTS_KillProcess_0100 getProcessRunningInfos=====>' + JSON.stringify(data)) console.info(TAG + '====>ACTS_KillProcess_0100 getProcessRunningInfos=====>' + JSON.stringify(data))
for(var i = 0; i<data.length ;i++){ for(var i = 0; i<data.length ;i++){
if (data[i].processName=='com.acts.killprocessthirdhap'){ if (data[i].processName=='com.acts.killprocessthirdhap'){
console.info('====>has com.acts.killprocessthirdhap=====>') console.info(TAG + '====>has com.acts.killprocessthirdhap=====>')
break break
} }
} }
console.log('====>i is:====>' + JSON.stringify(i)) console.log(TAG + '====>i is:====>' + JSON.stringify(i))
if(i==data.length && data[i].processName!='com.acts.killprocessthirdhap'){ if(i==data.length && data[i].processName!='com.acts.killprocessthirdhap'){
expect().assertFail() expect().assertFail()
} }
...@@ -1007,13 +1035,13 @@ export default function abilityTest() { ...@@ -1007,13 +1035,13 @@ export default function abilityTest() {
},1000) },1000)
setTimeout(()=> { setTimeout(()=> {
appManager.getProcessRunningInfos().then((data) => { appManager.getProcessRunningInfos().then((data) => {
console.info('====>ACTS_KillProcess_0100 getProcessRunningInfos2=====>' + JSON.stringify(data)) console.info(TAG + '====>ACTS_KillProcess_0100 getProcessRunningInfos2=====>' + JSON.stringify(data))
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
if (data[i].processName == 'com.acts.killprocessthirdhap') { if (data[i].processName == 'com.acts.killprocessthirdhap') {
break break
} }
} }
console.log('====>i2 is:====>' + JSON.stringify(i)) console.log(TAG + '====>i2 is:====>' + JSON.stringify(i))
if(i==data.length && data[i].processName!='com.acts.killprocessthirdhap'){ if(i==data.length && data[i].processName!='com.acts.killprocessthirdhap'){
expect().assertFail() expect().assertFail()
} }
...@@ -1029,24 +1057,25 @@ export default function abilityTest() { ...@@ -1029,24 +1057,25 @@ export default function abilityTest() {
* then terminateself ability and return result failed.(callback) * then terminateself ability and return result failed.(callback)
*/ */
it('ACTS_ThirdPartyKillProcess_0200', 0, async function (done) { it('ACTS_ThirdPartyKillProcess_0200', 0, async function (done) {
console.debug("====>start startAbility====>"); let TAG = 'ACTS_ThirdPartyKillProcess_0200'
console.debug(TAG + "====>start startAbility====>");
await globalThis.abilityContext.startAbility( await globalThis.abilityContext.startAbility(
{ {
bundleName: 'com.acts.killprocessthirdhap2', bundleName: 'com.acts.killprocessthirdhap2',
abilityName: 'com.acts.killprocessthirdhap2.MainAbility' abilityName: 'com.acts.killprocessthirdhap2.MainAbility'
}).then(() => { }).then(() => {
console.debug("====>startAbility end====>"); console.debug(TAG + "====>startAbility end====>");
}) })
setTimeout(() => { setTimeout(() => {
appManager.getProcessRunningInfos().then((data) => { appManager.getProcessRunningInfos().then((data) => {
console.info('====>ACTS_KillProcess_0100 getProcessRunningInfos=====>' + JSON.stringify(data)) console.info(TAG + '====>ACTS_KillProcess_0100 getProcessRunningInfos=====>' + JSON.stringify(data))
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
if (data[i].processName == 'com.acts.killprocessthirdhap2') { if (data[i].processName == 'com.acts.killprocessthirdhap2') {
console.info('====>has com.acts.killprocessthirdhap2=====>') console.info('====>has com.acts.killprocessthirdhap2=====>')
break break
} }
} }
console.log('====>i is:====>' + JSON.stringify(i)) console.log(TAG + '====>i is:====>' + JSON.stringify(i))
if (i == data.length && data[i].processName != 'com.acts.killprocessthirdhap2') { if (i == data.length && data[i].processName != 'com.acts.killprocessthirdhap2') {
expect().assertFail() expect().assertFail()
} }
...@@ -1054,13 +1083,13 @@ export default function abilityTest() { ...@@ -1054,13 +1083,13 @@ export default function abilityTest() {
},1000) },1000)
setTimeout(() => { setTimeout(() => {
appManager.getProcessRunningInfos().then((data) => { appManager.getProcessRunningInfos().then((data) => {
console.info('====>ACTS_KillProcess_0100 getProcessRunningInfos2=====>' + JSON.stringify(data)) console.info(TAG + '====>ACTS_KillProcess_0100 getProcessRunningInfos2=====>' + JSON.stringify(data))
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
if (data[i].processName == 'com.acts.killprocessthirdhap2') { if (data[i].processName == 'com.acts.killprocessthirdhap2') {
break break
} }
} }
console.log('====>i2 is:====>' + JSON.stringify(i)) console.log(TAG + '====>i2 is:====>' + JSON.stringify(i))
if(i==data.length && data[i].processName!='com.acts.killprocessthirdhap'){ if(i==data.length && data[i].processName!='com.acts.killprocessthirdhap'){
expect().assertFail() expect().assertFail()
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册