From 5b9356c01cd2e82ef0fda1502b29541b3c2a5643 Mon Sep 17 00:00:00 2001 From: xinking129 Date: Tue, 18 Jul 2023 11:05:35 +0800 Subject: [PATCH] change code Signed-off-by: xinking129 --- .../entry/src/main/ets/test/Ability.test.ets | 119 +++++++----------- .../signature/openharmony_sx.p7b | Bin 3538 -> 3651 bytes 2 files changed, 45 insertions(+), 74 deletions(-) diff --git a/ability/ability_runtime/actsnfcselecttypes/ActsNFCSelectTypesTest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsnfcselecttypes/ActsNFCSelectTypesTest/entry/src/main/ets/test/Ability.test.ets index fcf21912e..6b57babe6 100644 --- a/ability/ability_runtime/actsnfcselecttypes/ActsNFCSelectTypesTest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/actsnfcselecttypes/ActsNFCSelectTypesTest/entry/src/main/ets/test/Ability.test.ets @@ -514,47 +514,30 @@ export default function abilityTest() { ] } }; - globalThis.abilitycontext.startAbility( - want, (err) => { - if (err.code) { - console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`); - expect(true).assertFalse(); - return; - } - console.info('startAbility succeed'); - expect(true).assertTrue() - }); - await sleep(1000); - setTimeout(()=> { - abilityDelegator.executeShellCommand('pkill -f com.example.mytest5').then(data => { - console.log('pkill -f successful ' + JSON.stringify(data)) - }).catch(err => { - console.log('pkill -f err is ' + JSON.stringify(err)) - }); - },1000) - await sleep(1000); - setTimeout(()=> { - globalThis.abilitycontext.startAbility( - want, (err) => { - if (err.code) { - console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`); + globalThis.abilitycontext.startAbility(want).then(() => { + console.info('startAbility first succeed'); + setTimeout(() => { + globalThis.abilitycontext.startAbility(want).then(() => { + console.info('startAbility second succeed'); + setTimeout(()=> { + abilityDelegator.executeShellCommand('pkill -f com.example.mytest5').then((data) => { + console.log('pkill -f successful ' + JSON.stringify(data)) + }).catch((err) => { + console.log('pkill -f err is ' + JSON.stringify(err)) + }); + done(); + }, 1000) + }).catch((err) => { + console.error(`startAbility second failed, error is ${JSON.stringify(err)}`); expect(true).assertFalse(); done(); - return; - } - console.info('startAbility succeed'); - expect(true).assertTrue(); - setTimeout(()=> { - abilityDelegator.executeShellCommand('pkill -f com.example.mytest5').then(data => { - console.log('pkill -f successful ' + JSON.stringify(data)) - }).catch(err => { - console.log('pkill -f err is ' + JSON.stringify(err)) - }); - done(); - },1000) - }); - },1000) - + }); + }, 1000); + }).catch((err) => { + console.error(`startAbility first failed, error is ${JSON.stringify(err)}`); + expect(true).assertFalse(); + done(); + }); }) /* @@ -564,7 +547,7 @@ export default function abilityTest() { * @tc.level:1 */ it('ACTS_NFC_SelectTypes_1300',0, async function (done) { - hilog.info(DOMAIN, TAG, '%{public}s', 'ACTS_NFC_SelectTypes_1300 begin'); + hilog.info(DOMAIN, TAG, '%{public}s', 'ACTS_NFC_SelectTypes_1200 begin'); let want = { action: "ohos.nfc.tag.action.TAG_FOUND", type: '', @@ -574,41 +557,29 @@ export default function abilityTest() { ] } }; - globalThis.abilitycontext.startAbility( - want, (err) => { - if (err.code) { - console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`); - expect(true).assertFalse(); - return; - } - console.info('startAbility succeed'); - expect(true).assertTrue() - }); - setTimeout(()=> { - abilityDelegator.executeShellCommand('pkill -f com.example.mytest4').then(data => { - console.log('pkill -f successful ' + JSON.stringify(data)) - }).catch(err => { - console.log('pkill -f err is ' + JSON.stringify(err)) - }); - },1000) - globalThis.abilitycontext.startAbility( - want, (err) => { - if (err.code) { - console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`); - expect(true).assertFalse(); - done(); - return; - } - console.info('startAbility succeed'); - expect(true).assertTrue(); - setTimeout(()=> { - abilityDelegator.executeShellCommand('pkill -f com.example.mytest5').then(data => { - console.log('pkill -f successful ' + JSON.stringify(data)) - }).catch(err => { - console.log('pkill -f err is ' + JSON.stringify(err)) + globalThis.abilitycontext.startAbility(want).then(() => { + console.info('startAbility first succeed'); + setTimeout(() => { + globalThis.abilitycontext.startAbility(want).then(() => { + console.info('startAbility second succeed'); + setTimeout(()=> { + abilityDelegator.executeShellCommand('pkill -f com.example.mytest4').then((data) => { + console.log('pkill -f successful ' + JSON.stringify(data)) + }).catch((err) => { + console.log('pkill -f err is ' + JSON.stringify(err)) + }); + done(); + }, 1000) + }).catch((err) => { + console.error(`startAbility second failed, error is ${JSON.stringify(err)}`); + expect(true).assertFalse(); + done(); }); - done(); - },1000) + }, 1000); + }).catch((err) => { + console.error(`startAbility first failed, error is ${JSON.stringify(err)}`); + expect(true).assertFalse(); + done(); }); }) }) diff --git a/ability/ability_runtime/actsnfcselecttypes/ActsNFCSelectTypesTest/signature/openharmony_sx.p7b b/ability/ability_runtime/actsnfcselecttypes/ActsNFCSelectTypesTest/signature/openharmony_sx.p7b index 1dc131a566d75f35b7f6eac286081805bec7fcba..3a43acd9de9b627e0d31cab06a2c86c9b0c57fad 100644 GIT binary patch delta 368 zcmca4eOSi9po!0(jZ>@5qwPB{BRkWACO!k8kPZ_gqam*WHydX{n+IbmGYb==K@;l( zghIvzO{^DLnpn?nbm(DW%gZmyP0X2moyE#fDL*5>Sg#A9G~d_5azo9d8ePJzZb?`B=s^qv&{soxvV*&Pf?+yemD C7J^Iw delta 253 zcmX>sb4l94po#Y!8>d#AN85K^Ms}tJO}zVoLc5t584Y<2xY;-p+B_IjnOT?^4VqZ< z5egX>G_fYIG_l5Pbm(E>F0L#tNzIK<&M!)xe2K+svMsC5c4Qx+UHFjL*_Hi*{apF!6P&Z1(H4?FLJ@(`L?G z{@j3zjRWYubG9tZOf2pOu1pF+iB{SdOyv#Q+tBc;|Jh1}+&wu=J{BAowyX$Ambq*r