diff --git a/entry/src/ohosTest/ets/test/Ability.test.ets b/entry/src/ohosTest/ets/test/Ability.test.ets index bcf232a5df65fb679fcf60d1f1c396cb83447046..4df96fc51010ce5f26121105d5f3e714b4856aa7 100644 --- a/entry/src/ohosTest/ets/test/Ability.test.ets +++ b/entry/src/ohosTest/ets/test/Ability.test.ets @@ -31,6 +31,7 @@ import { TransPort, Util } from '@ohos/mail'; +const HTTP_COUNT: number = 2; const BASE_COUNT: number = 2000; @@ -117,8 +118,20 @@ export default function abilityTest() { expect(true).assertEqual(success) }); let startTime = new Date().getTime(); - transport.connect(properties, (success:boolean, err:Error) => { }); - endTime(startTime, 'connectSmtp'); + let configUrlTest: (index: number) => void = async (index) => { + transport.connect(properties, (success:boolean, err:Error) => { + transport.close((err:Error) => { + if(index < HTTP_COUNT){ + configUrlTest(index + 1) + }else{ + let endTime = new Date().getTime() + let averageTime = (endTime - startTime) * 1000/ HTTP_COUNT + console.log("connectSmtp averageTime: " + averageTime + ' μs') + } + }) + }) + } + configUrlTest(0) transport.noop((err:Error) => {}); MailLogger.info('ohos_mail-- login smtp fail : ---------') }) @@ -189,7 +202,20 @@ export default function abilityTest() { } }) }) - + let configUrlTest: (index: number) => void = async (index) => { + transport.sendMessage(mimeMessage, (err:Error) => { + transport.close((err:Error) => { + if(index < HTTP_COUNT){ + configUrlTest(index + 1) + }else{ + let endTime = new Date().getTime() + let averageTime = (endTime - startTime) * 1000/ HTTP_COUNT + console.log("sendMail averageTime: " + averageTime + ' μs') + } + }) + }) + } + configUrlTest(0) } else { MailLogger.error('ohos_mail-- login smtp fail:' + err); expect().assertFalse()