From 3576325ff187d7d6d05c37459715a73f51460a42 Mon Sep 17 00:00:00 2001 From: cuijiaojiao1 Date: Fri, 1 Sep 2023 15:19:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9POP3=E5=92=8CSMTP=20XTS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entry/src/ohosTest/ets/test/List.test.ets | 3 +- .../src/ohosTest/ets/test/POP3Press.test.ets | 27 +- .../ets/test/POP3PressDeplayTime.test.ets | 251 ++++++++++++++++++ .../entry/src/ohosTest/ets/test/List.test.ets | 3 +- .../src/ohosTest/ets/test/SMTPPress.test.ets | 29 +- .../ets/test/SMTPPressDeplayTime.test.ets | 72 +++++ 6 files changed, 339 insertions(+), 46 deletions(-) create mode 100644 POP3Client/entry/src/ohosTest/ets/test/POP3PressDeplayTime.test.ets create mode 100644 SMTPClient/entry/src/ohosTest/ets/test/SMTPPressDeplayTime.test.ets diff --git a/POP3Client/entry/src/ohosTest/ets/test/List.test.ets b/POP3Client/entry/src/ohosTest/ets/test/List.test.ets index 3c2a8ef..271e758 100644 --- a/POP3Client/entry/src/ohosTest/ets/test/List.test.ets +++ b/POP3Client/entry/src/ohosTest/ets/test/List.test.ets @@ -14,7 +14,8 @@ */ // import POP3Test from './POP3.test' -import POP3PressTest from './POP3Press.test' +// import POP3PressTest from './POP3Press.test' +import POP3PressTest from './POP3PressDeplayTime.test' export default function testsuite() { // POP3Test() diff --git a/POP3Client/entry/src/ohosTest/ets/test/POP3Press.test.ets b/POP3Client/entry/src/ohosTest/ets/test/POP3Press.test.ets index dc5655b..d355107 100644 --- a/POP3Client/entry/src/ohosTest/ets/test/POP3Press.test.ets +++ b/POP3Client/entry/src/ohosTest/ets/test/POP3Press.test.ets @@ -35,13 +35,9 @@ export default function POP3PressTest() { let client: Pop3Command = undefined let selectMsgNum: number = -1 let isListShow: boolean = false - const BASE_COUNT = 1000 - let count = 1; - let id = undefined; + const BASE_COUNT = 10000 describe('POP3PressTest', function () { - - function allApiInterface() { - + for (let i = 1;i <= BASE_COUNT; i++) { it('LIST', 0, function () { let option = { host: 'pop.qq.com', @@ -190,7 +186,7 @@ export default function POP3PressTest() { } client = new Pop3Command(option); let result = client.TOP("1") - + }) it('command', 0, function (done) { @@ -206,23 +202,8 @@ export default function POP3PressTest() { } client = new Pop3Command(option); let result = client.command("NOOP") - if (id) { - clearInterval(id) - id = undefined; - } - if (count <= BASE_COUNT) { - count += 1; - console.log(`POP3---count -1 --->${count}`); - id = setTimeout(function () { - allApiInterface() - done() - }, 1000) - } else { - console.log(`POP3---count -2--->${count}`); - done() - } + console.log("command count:"+i) }) } - allApiInterface() }) } \ No newline at end of file diff --git a/POP3Client/entry/src/ohosTest/ets/test/POP3PressDeplayTime.test.ets b/POP3Client/entry/src/ohosTest/ets/test/POP3PressDeplayTime.test.ets new file mode 100644 index 0000000..10f0b81 --- /dev/null +++ b/POP3Client/entry/src/ohosTest/ets/test/POP3PressDeplayTime.test.ets @@ -0,0 +1,251 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium' +import promptAction from '@ohos.promptAction' +import router from '@ohos.router' +import socket from '@ohos.net.socket' +import Pop3Command from '@ohos/node_pop3' +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import MsgBean from '../../../../../entry/src/main/ets/MsgBean' + +export default function POP3PressTest() { + + let message = 'Hello World' + let account = '479868299' + let password = 'prcryvqwfbspbhhi' + let mailType = '@qq.com' + let textValue = '' + let inputValue = 'click me' + let secure = false + let listData: Array = [] + let client: Pop3Command = undefined + let selectMsgNum: number = -1 + let isListShow: boolean = false + //总的次数 + const BASE_COUNT = 10000 + //每个用例延迟时间执行毫秒单位 + const deplayTime=500 + + describe('POP3PressTest', function () { + for (let i = 1;i <= BASE_COUNT; i++) { + it('LIST', 0, function (done) { + setTimeout(()=>{ + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); + let result = client.LIST(); + done() + },deplayTime) + }) + + it('STAT', 0, function (done) { + setTimeout(()=>{ + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); + let result = client.STAT() + done() + },deplayTime) + }) + + it('NOOP', 0, function (done) { + setTimeout(()=>{ + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); + let result = client.NOOP() + done() + },deplayTime) + + }) + + it('UIDL', 0, function (done) { + setTimeout(()=>{ + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); + let result = client.UIDL("1") + done() + },deplayTime) + }) + + it('RSET', 0, function (done) { + setTimeout(()=>{ + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); + let result = client.RSET() + done() + },deplayTime) + + }) + + it('RETR', 0, function (done) { + setTimeout(()=>{ + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); + let result = client.RETR("1") + done() + },deplayTime) + + }) + + it('DELE', 0, function (done) { + setTimeout(()=>{ + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); + let result = client.DELE("1") + done() + },deplayTime) + }) + + it('QUIT', 0, function (done) { + setTimeout(()=>{ + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); + let result = client.QUIT() + done() + },deplayTime) + + }) + + it('connect', 0, function (done) { + setTimeout(()=>{ + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); + let result = client.connect() + done() + },deplayTime) + + }) + + it('TOP', 0, function (done) { + setTimeout(()=>{ + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); + let result = client.TOP("1") + done() + },deplayTime) + }) + + it('command', 0, function (done) { + setTimeout(()=>{ + let option = { + host: 'pop.qq.com', + port: 110, + user: account + mailType, + password: password, + timeout: 30000, + servername: 'pop.qq.com', + tls: false, + tlsOptions: undefined + } + client = new Pop3Command(option); + let result = client.command("NOOP") + console.log("command count:"+i) + done() + },deplayTime) + + }) + } + }) +} \ No newline at end of file diff --git a/SMTPClient/entry/src/ohosTest/ets/test/List.test.ets b/SMTPClient/entry/src/ohosTest/ets/test/List.test.ets index 1c22bdf..c54269a 100644 --- a/SMTPClient/entry/src/ohosTest/ets/test/List.test.ets +++ b/SMTPClient/entry/src/ohosTest/ets/test/List.test.ets @@ -17,7 +17,8 @@ // import connectionTest from './Connection.test' // import dateTest from './Date.test' // import mimeTest from './Mime.test' -import SMTPPressTest from './SMTPPress.test' +// import SMTPPressTest from './SMTPPress.test' +import SMTPPressTest from './SMTPPressDeplayTime.test' export default function testsuite() { // addressTest() diff --git a/SMTPClient/entry/src/ohosTest/ets/test/SMTPPress.test.ets b/SMTPClient/entry/src/ohosTest/ets/test/SMTPPress.test.ets index 1b76921..e314086 100644 --- a/SMTPClient/entry/src/ohosTest/ets/test/SMTPPress.test.ets +++ b/SMTPClient/entry/src/ohosTest/ets/test/SMTPPress.test.ets @@ -16,11 +16,12 @@ export default function SMTPPressTest() { let bcc: string = '2' let subject: string = 'test' let content: string = 'test' - const BASE_COUNT = 1000 - let count = 1; - let id = undefined; + //总的次数 + const BASE_COUNT = 10000 + describe('SMTPPressTest', function () { - function allApiInterface() { + + for(let i=1;i<=BASE_COUNT;i++){ it('new_SMTPClient', 0, function () { let client = new SMTPClient({ user: '479868299@qq.com', @@ -32,9 +33,10 @@ export default function SMTPPressTest() { ssl: false, tls: undefined }); + console.log("new_SMTPClient count:"+i) }) - it('sendAsync', 0, function (done) { + it('sendAsync', 0, function () { let client = new SMTPClient({ user: '479868299@qq.com', password: 'bfxeualuaxambged', @@ -56,23 +58,8 @@ export default function SMTPPressTest() { attachment: null } client.sendAsync(msg) - if (id) { - clearInterval(id) - id = undefined; - } - if (count <= BASE_COUNT) { - count += 1; - console.log(`SMTP---count -1 --->${count}`); - id = setTimeout(function () { - allApiInterface() - done() - }, 1000) - } else { - console.log(`SMTP---count -2--->${count}`); - done() - } + console.log("sendAsync count:"+i) }) } - allApiInterface() }) } \ No newline at end of file diff --git a/SMTPClient/entry/src/ohosTest/ets/test/SMTPPressDeplayTime.test.ets b/SMTPClient/entry/src/ohosTest/ets/test/SMTPPressDeplayTime.test.ets new file mode 100644 index 0000000..3660569 --- /dev/null +++ b/SMTPClient/entry/src/ohosTest/ets/test/SMTPPressDeplayTime.test.ets @@ -0,0 +1,72 @@ +import hilog from '@ohos.hilog'; +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium' +import { AUTH_METHODS, Message, MessageAttachment, MessageHeaders, SMTPClient } from '@ohos/emailjs' +import promptAction from '@ohos.promptAction' +import router from '@ohos.router' +import socket from '@ohos.net.socket' +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import fs from '@ohos.file.fs'; + +export default function SMTPPressTest() { + + let from: string = '479868299@qq.com' + let accountName: string = '479868299' + let to: string = '12345689@qq.com' + let cc: string = '1' + let bcc: string = '2' + let subject: string = 'test' + let content: string = 'test' + //总的次数 + const BASE_COUNT = 10000 + //每个用例延迟时间执行毫秒单位 + const deplayTime=500 + describe('SMTPPressTest', function () { + + for(let i=1;i<=BASE_COUNT;i++){ + it('new_SMTPClient', 0, function (done) { + setTimeout(()=>{ + let client = new SMTPClient({ + user: '479868299@qq.com', + password: 'bfxeualuaxambged', + host: 'smtp.qq.com', + port: 25, + timeout: 30000, + authentication: [AUTH_METHODS.LOGIN], + ssl: false, + tls: undefined + }); + console.log("new_SMTPClient count:"+i) + done() + },deplayTime) + }) + + it('sendAsync', 0, function (done) { + setTimeout(()=>{ + let client = new SMTPClient({ + user: '479868299@qq.com', + password: 'bfxeualuaxambged', + host: 'smtp.qq.com', + port: 25, + timeout: 30000, + authentication: [AUTH_METHODS.LOGIN], + ssl: false, + tls: undefined + }); + + let msg: Message | MessageHeaders = { + text: content, + from: `${accountName} <${from}>`, + to: to, + cc: cc, + bcc: cc, + subject: subject, + attachment: null + } + client.sendAsync(msg) + console.log("sendAsync count:"+i) + done() + },deplayTime) + }) + } + }) +} \ No newline at end of file -- Gitee