未验证 提交 846da039 编写于 作者: O openharmony_ci 提交者: Gitee

!4709 XTS元能力用例优化

Merge pull request !4709 from chengxingzhen/master
......@@ -89,11 +89,6 @@ export default class MainAbility extends Ability {
console.log("ACTS_NewWant Publish CallBack onNewWantMain_To_Test_CommonEvent")
});
switch (want.action) {
case 'restartHapB':
commonEvent.publish("onNewWantMain1_To_Test_CommonEvent", publishData, () => {
console.log("ACTS_NewWant Publish CallBack onNewWantMain1_To_Test_CommonEvent")
});
break;
case 'restartHapC':
commonEvent.publish("onNewWantMain2_To_Test_CommonEvent", publishData, () => {
console.log("ACTS_NewWant Publish CallBack onNewWantMain2_To_Test_CommonEvent")
......
......@@ -88,5 +88,12 @@ export default class MainAbility extends Ability {
commonEvent.publish("onNewWantMain_To_Test_CommonEvent", publishData, () => {
console.log("ACTS_NewWant Publish CallBack onNewWantMain_To_Test_CommonEvent")
});
switch (want.action) {
case 'restartHapB':
commonEvent.publish("onNewWantMain1_To_Test_CommonEvent", publishData, () => {
console.log("ACTS_NewWant Publish CallBack onNewWantMain1_To_Test_CommonEvent")
});
break;
}
}
};
......@@ -80,6 +80,16 @@ export default class MainAbility extends Ability {
+ JSON.stringify(error) + ", " + JSON.stringify(data))
})
}
if (globalThis.abilityWant.action == 'startMainAbility0800') {
globalThis.abilityContext.startAbility({
bundleName: "com.example.newwanthap",
abilityName: "com.example.newwanthapa.SecondAbility",
action: "startSecondAbility0800"
}, (error, data) => {
console.log('ACTS_NewWant MainAbility onForeground - startAbility startServiceAbility: '
+ JSON.stringify(error) + ", " + JSON.stringify(data))
})
}
commonEvent.publish("onForegroundMain_To_Test_CommonEvent", () => {
console.log("ACTS_NewWant MainAbility Publish CallBack onForegroundMain_To_Test_CommonEvent")
});
......@@ -102,9 +112,23 @@ export default class MainAbility extends Ability {
console.log("ACTS_NewWant MainAbility onNewWant type :" + want.type)
console.log("ACTS_NewWant MainAbility onNewWant flags :" + want.flags)
console.log("ACTS_NewWant MainAbility onNewWant action :" + want.action)
var publishData = {
data: want.action
}
commonEvent.publish("onNewWantMain_To_Test_CommonEvent", () => {
console.log("ACTS_NewWant MainAbility Publish CallBack onNewWantMain_To_Test_CommonEvent")
});
switch (want.action) {
case 'restartHapB':
commonEvent.publish("onNewWantSecond1_To_Test_CommonEvent", publishData,() => {
console.log("ACTS_NewWant SecondAbility Publish CallBack onNewWantSecond1_To_Test_CommonEvent")
});
break;
case 'restartSecondAbility0700':
commonEvent.publish("onNewWantSecond2_To_Test_CommonEvent", publishData,() => {
console.log("ACTS_NewWant SecondAbility Publish CallBack onNewWantSecond2_To_Test_CommonEvent")
});
break;
}
}
};
......@@ -16,7 +16,7 @@
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index"
import commonEvent from '@ohos.commonEvent'
var subscriberInfo = {
let subscriberInfo = {
events: ['onCreateMain_To_Test_CommonEvent',
'onWindowStageCreateMain_To_Test_CommonEvent',
'onForegroundMain_To_Test_CommonEvent',
......@@ -33,6 +33,8 @@ var subscriberInfo = {
],
};
let flagNewWant = false;
export default function abilityTest(abilityContext) {
describe('ActsNewWantTest', function () {
......@@ -43,13 +45,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0100', 0, async function (done) {
console.log("ACTS_NewWant_Test_0100 --- start")
var Subscriber;
var flagOnCreate = 0;
var flagOnWindowStageCreate = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
let Subscriber;
let flagOnCreate = 0;
let flagOnWindowStageCreate = 0;
let flagOnForeground = 0;
let flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0100====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
......@@ -94,17 +96,14 @@ export default function abilityTest(abilityContext) {
+ flagOnNewWant)
if (flagOnCreate == 1 && flagOnWindowStageCreate == 1
&& flagOnForeground == 1 && flagOnNewWant == 0) {
expect(flagOnCreate).assertEqual(1);
expect(flagOnWindowStageCreate).assertEqual(1);
expect(flagOnForeground).assertEqual(1);
expect(flagOnNewWant).assertEqual(0);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
done()
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0100====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
......@@ -116,13 +115,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0200', 0, async function (done) {
console.log("ACTS_NewWant_Test_0200 --- start")
var Subscriber;
var flagOnCreate = 0;
var flagOnWindowStageCreate = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
let Subscriber;
let flagOnCreate = 0;
let flagOnWindowStageCreate = 0;
let flagOnForeground = 0;
let flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0200====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
......@@ -166,17 +165,14 @@ export default function abilityTest(abilityContext) {
+ flagOnNewWant)
if (flagOnCreate == 1 && flagOnWindowStageCreate == 1
&& flagOnForeground == 1 && flagOnNewWant == 0) {
expect(flagOnCreate).assertEqual(1);
expect(flagOnWindowStageCreate).assertEqual(1);
expect(flagOnForeground).assertEqual(1);
expect(flagOnNewWant).assertEqual(0);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
done()
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0200====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
......@@ -188,13 +184,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0300', 0, async function (done) {
console.log("ACTS_NewWant_Test_0300 --- start")
var Subscriber;
var flagOnCreate = 0;
var flagOnWindowStageCreate = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
let Subscriber;
let flagOnCreate = 0;
let flagOnWindowStageCreate = 0;
let flagOnForeground = 0;
let flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0300====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
......@@ -240,15 +236,13 @@ export default function abilityTest(abilityContext) {
if (flagOnCreate == 2 && flagOnWindowStageCreate == 2
&& flagOnForeground == 2 && flagOnNewWant == 0) {
expect(flagOnCreate).assertEqual(2);
expect(flagOnWindowStageCreate).assertEqual(2);
expect(flagOnForeground).assertEqual(2);
expect(flagOnNewWant).assertEqual(0);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0300====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
......@@ -260,13 +254,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0400', 0, async function (done) {
console.log("ACTS_NewWant_Test_0400 --- start")
var Subscriber;
var flagOnCreate = 0;
var flagOnWindowStageCreate = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
let Subscriber;
let flagOnCreate = 0;
let flagOnWindowStageCreate = 0;
let flagOnForeground = 0;
let flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0400====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
......@@ -311,19 +305,16 @@ export default function abilityTest(abilityContext) {
console.debug("ACTS_NewWant_Test_0400====>flagOnNewWant:====>"
+ flagOnNewWant)
if (flagOnCreate == 1 && flagOnWindowStageCreate == 1
if (flagOnCreate == 0 && flagOnWindowStageCreate == 0
&& flagOnForeground == 2 && flagOnNewWant == 1) {
expect(flagOnCreate).assertEqual(1);
expect(flagOnWindowStageCreate).assertEqual(1);
expect(flagOnForeground).assertEqual(2);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
done()
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0400====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
......@@ -335,13 +326,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0500', 0, async function (done) {
console.log("ACTS_NewWant_Test_0500 --- start")
var Subscriber;
var flagOnCreate = 0;
var flagOnWindowStageCreate = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
let Subscriber;
let flagOnCreate = 0;
let flagOnWindowStageCreate = 0;
let flagOnForeground = 0;
let flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0500====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
......@@ -388,17 +379,14 @@ export default function abilityTest(abilityContext) {
if (flagOnCreate == 1 && flagOnWindowStageCreate == 1
&& flagOnForeground == 2 && flagOnNewWant == 1) {
expect(flagOnCreate).assertEqual(1);
expect(flagOnWindowStageCreate).assertEqual(1);
expect(flagOnForeground).assertEqual(2);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
done()
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0500====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
......@@ -410,13 +398,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0600', 0, async function (done) {
console.log("ACTS_NewWant_Test_0600 --- start")
var Subscriber;
var flagOnCreate = 0;
var flagOnWindowStageCreate = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
let Subscriber;
let flagOnCreate = 0;
let flagOnWindowStageCreate = 0;
let flagOnForeground = 0;
let flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0600====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
......@@ -463,17 +451,14 @@ export default function abilityTest(abilityContext) {
if (flagOnCreate == 1 && flagOnWindowStageCreate == 1
&& flagOnForeground == 2 && flagOnNewWant == 1) {
expect(flagOnCreate).assertEqual(1);
expect(flagOnWindowStageCreate).assertEqual(1);
expect(flagOnForeground).assertEqual(2);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
done()
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0600====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
......@@ -485,13 +470,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0700', 0, async function (done) {
console.log("ACTS_NewWant_Test_0700 --- start")
var Subscriber;
var flagOnCreate = 0;
var flagOnWindowStageCreate = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
let Subscriber;
let flagOnCreate = 0;
let flagOnWindowStageCreate = 0;
let flagOnForeground = 0;
let flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0700====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
......@@ -536,18 +521,15 @@ export default function abilityTest(abilityContext) {
console.debug("ACTS_NewWant_Test_0700====>flagOnNewWant:====>"
+ flagOnNewWant)
if (flagOnCreate == 1 && flagOnWindowStageCreate == 1
if (flagOnCreate == 0 && flagOnWindowStageCreate == 0
&& flagOnForeground == 2 && flagOnNewWant == 1) {
expect(flagOnCreate).assertEqual(1);
expect(flagOnWindowStageCreate).assertEqual(1);
expect(flagOnForeground).assertEqual(2);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
done()
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0700====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
......@@ -559,13 +541,13 @@ export default function abilityTest(abilityContext) {
*/
it('ACTS_NewWant_Test_0800', 0, async function (done) {
console.log("ACTS_NewWant_Test_0800 --- start")
var Subscriber;
var flagOnCreate = 0;
var flagOnWindowStageCreate = 0;
var flagOnForeground = 0;
var flagOnNewWant = 0;
let Subscriber;
let flagOnCreate = 0;
let flagOnWindowStageCreate = 0;
let flagOnForeground = 0;
let flagOnNewWant = 0;
commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
await commonEvent.createSubscriber(subscriberInfo).then(async (data) => {
console.debug("ACTS_NewWant_Test_0800====>Create Subscriber====>");
Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBack);
......@@ -573,8 +555,8 @@ export default function abilityTest(abilityContext) {
abilityContext.startAbility({
bundleName: "com.example.newwanthap",
abilityName: "com.example.newwanthapa.SecondAbility",
action: "startSecondAbility0800"
abilityName: "com.example.newwanthapa.MainAbility",
action: "startMainAbility0800"
}, (error, data) => {
console.log('ACTS_NewWant_Test_0800 - startAbility start SecondAbility: '
+ JSON.stringify(error) + ", " + JSON.stringify(data))
......@@ -611,18 +593,15 @@ export default function abilityTest(abilityContext) {
console.debug("ACTS_NewWant_Test_0800====>flagOnNewWant:====>"
+ flagOnNewWant)
if (flagOnCreate == 1 && flagOnWindowStageCreate == 1
if (flagOnCreate == 0 && flagOnWindowStageCreate == 0
&& flagOnForeground == 2 && flagOnNewWant == 1) {
expect(flagOnCreate).assertEqual(1);
expect(flagOnWindowStageCreate).assertEqual(1);
expect(flagOnForeground).assertEqual(2);
expect(flagOnNewWant).assertEqual(1);
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
flagNewWant = true;
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback);
}
done()
}
function UnSubscribeCallback() {
console.debug("ACTS_NewWant_Test_0800====>UnSubscribe CallBack====>");
expect(flagNewWant).assertTrue();
done();
}
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册