From 0fb649caa89b21b082d2e8facd1fbfa208ad9738 Mon Sep 17 00:00:00 2001 From: chengxingzhen Date: Mon, 11 Jul 2022 20:26:10 +0800 Subject: [PATCH] =?UTF-8?q?fixed=207c39b98=20from=20https://gitee.com/chen?= =?UTF-8?q?gxingzhen/xts=5Facts=5Fmaster/pulls/4257=20XTS=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=94=A8=E4=BE=8B=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengxingzhen --- .../entry/src/main/ets/test/Ability.test.ets | 197 ++++++++---------- ...ActsStServiceAbilityClientCaseTest.test.js | 12 +- .../main/js/test/FeatureAbilityJsunit.test.js | 3 +- 3 files changed, 96 insertions(+), 116 deletions(-) diff --git a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets index 1a5447405..5ed4b80e9 100644 --- a/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets @@ -14,24 +14,11 @@ */ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" import commonEvent from '@ohos.commonEvent' -import bundle from '@ohos.bundle' -import missionManager from '@ohos.application.missionManager' -import appManager from '@ohos.application.appManager' -var subscriberInfoMultiInstance = { +let subscriberInfoMultiInstance = { events: ["MultiInstanceStartNext", "MultiInstanceStartFinish"] }; -const BUNDLE_PATHS = [['/data/ActsAmsAbilityMultiinstanceHapARelyHap.hap'], -['/data/ActsAmsAbilityMultiinstanceHapBRelyHap.hap'], -['/data/ActsAmsAbilityMultiinstanceHapCRelyHap.hap'], -['/data/ActsAmsAbilityMultiinstanceHapDRelyHap.hap'], -['/data/ActsAmsAbilityMultiinstanceHapERelyHap.hap']]; -const BUNDLE_NAMES = ['com.example.amsabilitymultiinstanceappa', 'com.example.amsabilitymultiinstanceappb', -'com.example.amsabilitymultiinstanceappc', 'com.example.amsabilitymultiinstanceappd', -'com.example.amsabilitymultiinstanceappe']; -const BUNDLE_COUNT = 5; const START_ABILITY_TIMEOUT = 9000; -const MAX_MISSION_NUM = 1024; const ONACCEPTWANT_KEY_NOTSET_ID = -1; const ONACCEPTWANT_KEY_UNDEFINED_ID = -2; const UNSUBSCRIBE_TIMEOUT = 5000; @@ -48,6 +35,9 @@ async function startAbilityProcess(abilityContext, parameters) { case "StartA2": parameters.startId = 2; break; + case "StartA3": + parameters.startId = 3; + break; case "StartANS": parameters.startId = ONACCEPTWANT_KEY_NOTSET_ID; break; @@ -101,17 +91,6 @@ async function startAbilityProcess(abilityContext, parameters) { export default function abilityTest(abilityContext) { describe('ActsAbilityTest', function () { - beforeEach(async (done) => { - console.log('======>beforeEach ininin<======='); - done(); - }) - - afterEach(async (done) => { - let installer = await bundle.getBundleInstaller(); - var count = 0; - done(); - }) - /* * @tc.number: ACTS_AbilityMultiInstance_Multi_0100 * @tc.name: Connects a service ability, which is used to start a cloned page ability. @@ -119,16 +98,15 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_0100', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_0100====Subscribe CallBack data:====>" + JSON.stringify(data)); - if (data.event == "MultiInstanceStartFinish") { clearTimeout(id); console.log('ACTS_AbilityMultiInstance_Single_0100 finish callBackSeq = ' + data.data); @@ -136,7 +114,7 @@ export default function abilityTest(abilityContext) { expect(checkIndex).assertEqual(3); commonEvent.unsubscribe(subscriber, unSubscribeCallback) } else if (data.event == "MultiInstanceStartNext") { - console.log('ACTS_AbilityMultiInstance_Single_0100 callBackSeq = ' + data.data); + console.log('ACTS_AbilityMultiInstance_Single_010022 callBackSeq = ' + data.data); expect(data.data).assertEqual(checkEventResults[checkIndex++]); } } @@ -178,19 +156,18 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_0200', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_0200====Subscribe CallBack data:====>" + JSON.stringify(data)); if (data.event == "MultiInstanceStartFinish") { clearTimeout(id); - console.log('ACTS_AbilityMultiInstance_Single_0200 finish callBackSeq = ' + data.data); + console.log('ACTS_AbilityMultiInstance_Single_0200234 finish callBackSeq = ' + data.data); expect(data.data).assertEqual(checkEventResults[checkIndex++]); expect(checkIndex).assertEqual(3); commonEvent.unsubscribe(subscriber, unSubscribeCallback); @@ -227,7 +204,7 @@ export default function abilityTest(abilityContext) { startId: 0, stepNum: 3, nextStep: 0, - step: ["StartA1", "StartB", "StartA2"] + step: ["StartA3", "StartB", "StartA2"] }); }) @@ -238,12 +215,12 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_0300', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_0300====Subscribe CallBack data:====>" + JSON.stringify(data)); @@ -298,12 +275,12 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_0400', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_0400====Subscribe CallBack data:====>" + JSON.stringify(data)); @@ -312,7 +289,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); console.log('ACTS_AbilityMultiInstance_Single_0400 finish callBackSeq = ' + data.data); expect(data.data).assertEqual(checkEventResults[checkIndex++]); - expect(checkIndex).assertEqual(3); + expect(checkIndex).assertEqual(2); commonEvent.unsubscribe(subscriber, unSubscribeCallback); console.log('ACTS_AbilityMultiInstance_Single_0400 finish'); } else if (data.event == "MultiInstanceStartNext") { @@ -347,7 +324,7 @@ export default function abilityTest(abilityContext) { startId: 0, stepNum: 3, nextStep: 0, - step: ["StartA1", "StartC", "StartA2"] + step: ["StartA3", "StartC", "StartA2"] }); }) @@ -358,12 +335,12 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_0600', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_0600====Subscribe CallBack data:====>" + JSON.stringify(data)); @@ -418,12 +395,12 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_0700', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_0700====Subscribe CallBack data:====>" + JSON.stringify(data)); @@ -432,7 +409,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); console.log('ACTS_AbilityMultiInstance_Single_0700 finish callBackSeq = ' + data.data); expect(data.data).assertEqual(checkEventResults[checkIndex++]); - expect(checkIndex).assertEqual(4); + expect(checkIndex).assertEqual(3); commonEvent.unsubscribe(subscriber, unSubscribeCallback); console.log('ACTS_AbilityMultiInstance_Single_0700 finish'); } else if (data.event == "MultiInstanceStartNext") { @@ -478,12 +455,12 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_0800', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_0800====Subscribe CallBack data:====>" + JSON.stringify(data)); @@ -492,7 +469,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); console.log('ACTS_AbilityMultiInstance_Single_0800 finish callBackSeq = ' + data.data); expect(data.data).assertEqual(checkEventResults[checkIndex++]); - expect(checkIndex).assertEqual(4); + expect(checkIndex).assertEqual(3); commonEvent.unsubscribe(subscriber, unSubscribeCallback); console.log('ACTS_AbilityMultiInstance_Single_0800 finish'); } else if (data.event == "MultiInstanceStartNext") { @@ -527,7 +504,7 @@ export default function abilityTest(abilityContext) { startId: 0, stepNum: 4, nextStep: 0, - step: ["StartA1", "StartB", "StartC", "StartA2"] + step: ["StartA3", "StartB", "StartC", "StartA2"] }); }) @@ -538,12 +515,12 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_0900', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_0900====Subscribe CallBack data:====>" + JSON.stringify(data)); @@ -552,7 +529,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); console.log('ACTS_AbilityMultiInstance_Single_0900 finish callBackSeq = ' + data.data); expect(data.data).assertEqual(checkEventResults[checkIndex++]); - expect(checkIndex).assertEqual(4); + expect(checkIndex).assertEqual(3); commonEvent.unsubscribe(subscriber, unSubscribeCallback); console.log('ACTS_AbilityMultiInstance_Single_0900 finish'); } else if (data.event == "MultiInstanceStartNext") { @@ -598,12 +575,12 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_1000', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_1000====Subscribe CallBack data:====>" + JSON.stringify(data)); @@ -612,7 +589,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); console.log('ACTS_AbilityMultiInstance_Single_1000 finish callBackSeq = ' + data.data); expect(data.data).assertEqual(checkEventResults[checkIndex++]); - expect(checkIndex).assertEqual(4); + expect(checkIndex).assertEqual(3); commonEvent.unsubscribe(subscriber, unSubscribeCallback); console.log('ACTS_AbilityMultiInstance_Single_1000 finish'); } else if (data.event == "MultiInstanceStartNext") { @@ -658,12 +635,12 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_1100', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_1100====Subscribe CallBack data:====>" + JSON.stringify(data)); @@ -718,12 +695,12 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_1200', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_1200====Subscribe CallBack data:====>" + JSON.stringify(data)); @@ -767,7 +744,7 @@ export default function abilityTest(abilityContext) { startId: 0, stepNum: 4, nextStep: 0, - step: ["StartDMain1", "StartDSec", "StartDThd", "StartDMain2"] + step: ["StartDMain2", "StartDSec", "StartDThd", "StartDMain1"] }); }) @@ -778,11 +755,11 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_1300', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_1300====Subscribe CallBack data:====>" + JSON.stringify(data)); @@ -837,11 +814,11 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_1400', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_1400====Subscribe CallBack data:====>" + JSON.stringify(data)); @@ -896,11 +873,11 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_1500', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_1500====Subscribe CallBack data:====>" + JSON.stringify(data)); @@ -944,7 +921,7 @@ export default function abilityTest(abilityContext) { startId: 0, stepNum: 2, nextStep: 0, - step: ["StartA1", "StartE"] + step: ["StartA2", "StartE"] }); }) @@ -955,11 +932,11 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_1600', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_1600====Subscribe CallBack data:====>" + JSON.stringify(data)); @@ -1013,11 +990,11 @@ export default function abilityTest(abilityContext) { */ it('ACTS_AbilityMultiInstance_Single_1700', 0, async function (done) { console.log('ACTS_AbilityMultiInstance_Single_1700====Subscribe CallBack data:====>" + JSON.stringify(data)); diff --git a/ability/ability_runtime/actsstserviceabilityclientcase/entry/src/main/js/test/ActsStServiceAbilityClientCaseTest.test.js b/ability/ability_runtime/actsstserviceabilityclientcase/entry/src/main/js/test/ActsStServiceAbilityClientCaseTest.test.js index da3ae9e59..ad64aff76 100644 --- a/ability/ability_runtime/actsstserviceabilityclientcase/entry/src/main/js/test/ActsStServiceAbilityClientCaseTest.test.js +++ b/ability/ability_runtime/actsstserviceabilityclientcase/entry/src/main/js/test/ActsStServiceAbilityClientCaseTest.test.js @@ -16,6 +16,8 @@ import featureAbility from '@ohos.ability.featureAbility' import commonEvent from '@ohos.commonEvent' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' +const errCode = 1; + describe('ActsStServiceAbilityTest', function () { let bundleName = "com.amsst.stserviceabilityserver"; let abilityName = "com.amsst.stserviceabilityserver.ServiceAbility"; @@ -98,7 +100,7 @@ describe('ActsStServiceAbilityTest', function () { featureAbility.startAbility(StartAbilityParameter,(err,data)=>{ console.log('ACTS_AAbilityStartSetting_0100 asyncCallback errCode : ' + JSON.stringify(err) + " data: " + JSON.stringify(data)); - expect(2097152).assertEqual(err.code); + expect(errCode).assertEqual(err.code); done(); }); }catch(error){ @@ -136,7 +138,7 @@ describe('ActsStServiceAbilityTest', function () { featureAbility.startAbility(StartAbilityParameter,(err,data)=>{ console.log('ACTS_AAbilityStartSettingNew_0200 asyncCallback errCode : ' + JSON.stringify(err) + " data: " + JSON.stringify(data)); - expect(2097152).assertEqual(err.code); + expect(errCode).assertEqual(err.code); done(); }); }catch(error){ @@ -174,7 +176,7 @@ it("ACTS_AAbilityStartSettingNew_0300",0, async function(done){ featureAbility.startAbility(StartAbilityParameter,(err,data)=>{ console.log('ACTS_AAbilityStartSettingNew_0300 asyncCallback errCode : ' + JSON.stringify(err) + " data: " + JSON.stringify(data)); - expect(2097152).assertEqual(err.code); + expect(errCode).assertEqual(err.code); done(); }); }catch(error){ @@ -212,7 +214,7 @@ it("ACTS_AAbilityStartSettingNew_0400",0, async function(done){ featureAbility.startAbility(StartAbilityParameter,(err,data)=>{ console.log('ACTS_AAbilityStartSettingNew_0400 asyncCallback errCode : ' + JSON.stringify(err) + " data: " + JSON.stringify(data)); - expect(2097152).assertEqual(err.code); + expect(errCode).assertEqual(err.code); done(); }); }catch(error){ @@ -250,7 +252,7 @@ it("ACTS_AAbilityStartSettingNew_0500",0, async function(done){ featureAbility.startAbility(StartAbilityParameter,(err,data)=>{ console.log('ACTS_AAbilityStartSettingNew_0500 asyncCallback errCode : ' + JSON.stringify(err) + " data: " + JSON.stringify(data)); - expect(2097152).assertEqual(err.code); + expect(errCode).assertEqual(err.code); done(); }); }catch(error){ diff --git a/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/FeatureAbilityJsunit.test.js b/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/FeatureAbilityJsunit.test.js index 6a799876d..ab3ae014c 100644 --- a/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/FeatureAbilityJsunit.test.js +++ b/ability/ability_runtime/featureability/actsfeatureabilitytest/entry/src/main/js/test/FeatureAbilityJsunit.test.js @@ -25,6 +25,7 @@ const CREATELOCALDIR = "/data/storage/el2/base/haps/entry"; const START_ABILITY_TIMEOUT = 4000; const TERMINATE_ABILITY_TIMEOUT = 1000; const TIMEOUT = 1000; +const errCode = 1; var subscriberInfoActsStartAbility0100 = { events: ["ACTS_StartAbility_0100_CommonEvent"], }; @@ -1845,7 +1846,7 @@ describe('ActsFeatureAbilityTest', function () { featureAbility.startAbility(StartAbilityParameter,(err,data)=>{ console.log('ACTS_StartAbility_0700 asyncCallback errCode : ' + JSON.stringify(err) + " data: " + JSON.stringify(data)); - expect(err.code == 2097152).assertTrue(); + expect(errCode).assertEqual(error.code); done(); }); }catch(error){ -- GitLab