From aa3f49c029f0ed250b4b732a9e117d1da4efe0d6 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Fri, 24 Mar 2023 17:53:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8B=95=E5=8C=96?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autotest.utils.js | 1 + env.js | 1 + jest.config.js | 11 + pages.json | 9 +- pages/autotest/uni-wifi/uni-wifi.test.js | 245 ++++++ pages/autotest/uni-wifi/uni-wifi.vue | 724 ++++++++++++++++++ .../uni-wifi/utssdk/app-android/index.uts | 36 +- uni_modules/uni-wifi/utssdk/interface.uts | 28 + uni_modules/uni-wifi/utssdk/uni.autotest.js | 35 + 9 files changed, 1072 insertions(+), 18 deletions(-) create mode 100644 autotest.utils.js create mode 100644 env.js create mode 100644 jest.config.js create mode 100644 pages/autotest/uni-wifi/uni-wifi.test.js create mode 100644 pages/autotest/uni-wifi/uni-wifi.vue create mode 100644 uni_modules/uni-wifi/utssdk/uni.autotest.js diff --git a/autotest.utils.js b/autotest.utils.js new file mode 100644 index 0000000..1622345 --- /dev/null +++ b/autotest.utils.js @@ -0,0 +1 @@ +"use strict";function t(t,r){const s=t.split("."),e=r.split("."),n=Math.max(s.length,e.length);for(let t=0;tn)return 1;if(r=":return t(r,s.substring(2))>=0;case"<=":return t(r,s.substring(2))<=0;case"!=":return 0!==t(r,s.substring(2))}switch(s.charAt(0)){case">":return t(r,s.substring(1))>0;case"<":return t(r,s.substring(1))<0;case"=":return 0===t(r,s.substring(1));case"^":return parseInt(r.split(".")[0])===parseInt(s.substring(1).split(".")[0])&&t(r,s.substring(1))>=0;case"~":return t(r,(s=s.substring(1).trim())+".0")>=0&&t(r,`${s[0]}.${parseInt(s[2])+1}`)<0;default:return-1!==t(r,s)}}exports.invokeApi=function(t,r,s,...e){if(r||function(t){return!("[object Object]"!==Object.prototype.toString.call(t)||!["success","fail"].find((r=>"function"==typeof t[r])))}(s)){const{success:r,fail:n,...i}=s;return new Promise(((s,u)=>{t({...i,success(t){r&&r(t),s(t)},fail(t){n&&n(t),u(t)}},...e)}))}return t(s,...e)},exports.platformMatch=function(t,s,e){let n=!0;e&&(n=r(s.uniRuntimeVersion,e));const i=t[s.uniPlatform];if(n&&i){if(i[s.osName]){const t=i[s.osName];return r(s[t.versionKey]||"*",t.version||"*")}return r(s[i.versionKey]||"*",i.version||"*")}return!1},exports.satisfies=r; diff --git a/env.js b/env.js new file mode 100644 index 0000000..206a664 --- /dev/null +++ b/env.js @@ -0,0 +1 @@ +module.exports = {"compile":true,"h5":{"options":{"headless":true},"executablePath":""},"mp-weixin":{"port":9420,"account":"","args":"","cwd":"","launch":true,"teardown":"disconnect","remote":false,"executablePath":""},"app-plus":{"android":{"id":"WDHVB20804034055","executablePath":"D:\\Do\\tools\\HX\\lastest_dev\\HBuilderX.3.7.7.20230315-alpha\\HBuilderX\\plugins\\launcher\\base\\android_base.apk"},"version":"D:\\Do\\tools\\HX\\lastest_dev\\HBuilderX.3.7.7.20230315-alpha\\HBuilderX\\plugins\\launcher\\base\\version.txt","ios":{"id":"","executablePath":""}}} \ No newline at end of file diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..a54d98a --- /dev/null +++ b/jest.config.js @@ -0,0 +1,11 @@ +module.exports = { + testTimeout: 10000, + reporters: [ + 'default' + ], + watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'], + moduleFileExtensions: ['js', 'json'], + rootDir: __dirname, + testMatch: ["/pages/**/*test.[jt]s?(x)"], + testPathIgnorePatterns: ['/node_modules/'] +} diff --git a/pages.json b/pages.json index 869105d..4070ea8 100644 --- a/pages.json +++ b/pages.json @@ -5,7 +5,14 @@ "style": { "navigationBarTitleText": "uni-app" } - } + }, + { + "path": "pages/autotest/uni-wifi/uni-wifi", + "style": { + "navigationBarTitleText": "uni-wifi", + "enablePullDownRefresh": false + } + } ], "globalStyle": { "navigationBarTextStyle": "black", diff --git a/pages/autotest/uni-wifi/uni-wifi.test.js b/pages/autotest/uni-wifi/uni-wifi.test.js new file mode 100644 index 0000000..afbda75 --- /dev/null +++ b/pages/autotest/uni-wifi/uni-wifi.test.js @@ -0,0 +1,245 @@ +describe('uni-wifi', () => { + let page; + beforeAll(async () => { + page = await program.reLaunch('/pages/autotest/uni-wifi/uni-wifi'); + await page.waitFor(3000); + }); + it('startWifi0', async () => { + const result0 = await page.callMethod('startWifi00'); + expect(result0.res).not.toHaveProperty('_errMsg'); + expect(result0.res.errCode).toEqual(expect.any(Number)); + expect(result0.res.errSubject).toEqual(expect.any(String)); + expect(result0.res.errMsg).toEqual(expect.any(String)); + const result1 = await page.callMethod('startWifi01'); + expect(result1.res).not.toHaveProperty('_errMsg'); + expect(result1.res.errCode).toEqual(expect.any(Number)); + expect(result1.res.errSubject).toEqual(expect.any(String)); + expect(result1.res.errMsg).toEqual(expect.any(String)); + const result2 = await page.callMethod('startWifi02'); + expect(result2.res).not.toHaveProperty('_errMsg'); + expect(result2.res.errCode).toEqual(expect.any(Number)); + expect(result2.res.errSubject).toEqual(expect.any(String)); + expect(result2.res.errMsg).toEqual(expect.any(String)); + const result3 = await page.callMethod('startWifi03'); + expect(result3.res).not.toHaveProperty('_errMsg'); + expect(result3.res.errCode).toEqual(expect.any(Number)); + expect(result3.res.errSubject).toEqual(expect.any(String)); + expect(result3.res.errMsg).toEqual(expect.any(String)); + const result4 = await page.callMethod('startWifi04'); + expect(result4.res).not.toHaveProperty('_errMsg'); + expect(result4.res.errCode).toEqual(expect.any(Number)); + expect(result4.res.errSubject).toEqual(expect.any(String)); + expect(result4.res.errMsg).toEqual(expect.any(String)); + const result5 = await page.callMethod('startWifi05'); + expect(result5.res).not.toHaveProperty('_errMsg'); + expect(result5.res.errCode).toEqual(expect.any(Number)); + expect(result5.res.errSubject).toEqual(expect.any(String)); + expect(result5.res.errMsg).toEqual(expect.any(String)); + const result6 = await page.callMethod('startWifi06'); + expect(result6.res).not.toHaveProperty('_errMsg'); + expect(result6.res.errCode).toEqual(expect.any(Number)); + expect(result6.res.errSubject).toEqual(expect.any(String)); + expect(result6.res.errMsg).toEqual(expect.any(String)); + const result7 = await page.callMethod('startWifi07'); + expect(result7.res).not.toHaveProperty('_errMsg'); + expect(result7.res.errCode).toEqual(expect.any(Number)); + expect(result7.res.errSubject).toEqual(expect.any(String)); + expect(result7.res.errMsg).toEqual(expect.any(String)); + const result8 = await page.callMethod('startWifi08'); + expect(result8.res).not.toHaveProperty('_errMsg'); + expect(result8.res.errCode).toEqual(expect.any(Number)); + expect(result8.res.errSubject).toEqual(expect.any(String)); + expect(result8.res.errMsg).toEqual(expect.any(String)); + const result9 = await page.callMethod('startWifi09'); + expect(result9.res).not.toHaveProperty('_errMsg'); + expect(result9.res.errCode).toEqual(expect.any(Number)); + expect(result9.res.errSubject).toEqual(expect.any(String)); + expect(result9.res.errMsg).toEqual(expect.any(String)); + const result10 = await page.callMethod('startWifi010'); + expect(result10.res).not.toHaveProperty('_errMsg'); + expect(result10.res.errCode).toEqual(expect.any(Number)); + expect(result10.res.errSubject).toEqual(expect.any(String)); + expect(result10.res.errMsg).toEqual(expect.any(String)); + const result11 = await page.callMethod('startWifi011'); + expect(result11.res).not.toHaveProperty('_errMsg'); + expect(result11.res.errCode).toEqual(expect.any(Number)); + expect(result11.res.errSubject).toEqual(expect.any(String)); + expect(result11.res.errMsg).toEqual(expect.any(String)); + const result12 = await page.callMethod('startWifi012'); + expect(result12.res).not.toHaveProperty('_errMsg'); + expect(result12.res.errCode).toEqual(expect.any(Number)); + expect(result12.res.errSubject).toEqual(expect.any(String)); + expect(result12.res.errMsg).toEqual(expect.any(String)); + const result13 = await page.callMethod('startWifi013'); + expect(result13.res).not.toHaveProperty('_errMsg'); + expect(result13.res.errCode).toEqual(expect.any(Number)); + expect(result13.res.errSubject).toEqual(expect.any(String)); + expect(result13.res.errMsg).toEqual(expect.any(String)); + const result14 = await page.callMethod('startWifi014'); + expect(result14.res).not.toHaveProperty('_errMsg'); + expect(result14.res.errCode).toEqual(expect.any(Number)); + expect(result14.res.errSubject).toEqual(expect.any(String)); + expect(result14.res.errMsg).toEqual(expect.any(String)); + const result15 = await page.callMethod('startWifi015'); + expect(result15.res).not.toHaveProperty('_errMsg'); + expect(result15.res.errCode).toEqual(expect.any(Number)); + expect(result15.res.errSubject).toEqual(expect.any(String)); + expect(result15.res.errMsg).toEqual(expect.any(String)); + const result16 = await page.callMethod('startWifi016'); + expect(result16.res).not.toHaveProperty('_errMsg'); + expect(result16.res.errCode).toEqual(expect.any(Number)); + expect(result16.res.errSubject).toEqual(expect.any(String)); + expect(result16.res.errMsg).toEqual(expect.any(String)); + const result17 = await page.callMethod('startWifi017'); + expect(result17.res).not.toHaveProperty('_errMsg'); + expect(result17.res.errCode).toEqual(expect.any(Number)); + expect(result17.res.errSubject).toEqual(expect.any(String)); + expect(result17.res.errMsg).toEqual(expect.any(String)); + const result18 = await page.callMethod('startWifi018'); + expect(result18.res).not.toHaveProperty('_errMsg'); + expect(result18.res.errCode).toEqual(expect.any(Number)); + expect(result18.res.errSubject).toEqual(expect.any(String)); + expect(result18.res.errMsg).toEqual(expect.any(String)); + const result19 = await page.callMethod('startWifi019'); + expect(result19.res).not.toHaveProperty('_errMsg'); + expect(result19.res.errCode).toEqual(expect.any(Number)); + expect(result19.res.errSubject).toEqual(expect.any(String)); + expect(result19.res.errMsg).toEqual(expect.any(String)); + const result20 = await page.callMethod('startWifi020'); + expect(result20.res).not.toHaveProperty('_errMsg'); + expect(result20.res.errCode).toEqual(expect.any(Number)); + expect(result20.res.errSubject).toEqual(expect.any(String)); + expect(result20.res.errMsg).toEqual(expect.any(String)); + const result21 = await page.callMethod('startWifi021'); + expect(result21.res).not.toHaveProperty('_errMsg'); + expect(result21.res.errCode).toEqual(expect.any(Number)); + expect(result21.res.errSubject).toEqual(expect.any(String)); + expect(result21.res.errMsg).toEqual(expect.any(String)); + }); + it('stopWifi1', async () => { + const result0 = await page.callMethod('stopWifi10'); + expect(result0.res).not.toHaveProperty('_errMsg'); + expect(result0.res.errCode).toEqual(expect.any(Number)); + expect(result0.res.errSubject).toEqual(expect.any(String)); + expect(result0.res.errMsg).toEqual(expect.any(String)); + const result1 = await page.callMethod('stopWifi11'); + expect(result1.res).not.toHaveProperty('_errMsg'); + expect(result1.res.errCode).toEqual(expect.any(Number)); + expect(result1.res.errSubject).toEqual(expect.any(String)); + expect(result1.res.errMsg).toEqual(expect.any(String)); + const result2 = await page.callMethod('stopWifi12'); + expect(result2.res).not.toHaveProperty('_errMsg'); + expect(result2.res.errCode).toEqual(expect.any(Number)); + expect(result2.res.errSubject).toEqual(expect.any(String)); + expect(result2.res.errMsg).toEqual(expect.any(String)); + const result3 = await page.callMethod('stopWifi13'); + expect(result3.res).not.toHaveProperty('_errMsg'); + expect(result3.res.errCode).toEqual(expect.any(Number)); + expect(result3.res.errSubject).toEqual(expect.any(String)); + expect(result3.res.errMsg).toEqual(expect.any(String)); + const result4 = await page.callMethod('stopWifi14'); + expect(result4.res).not.toHaveProperty('_errMsg'); + expect(result4.res.errCode).toEqual(expect.any(Number)); + expect(result4.res.errSubject).toEqual(expect.any(String)); + expect(result4.res.errMsg).toEqual(expect.any(String)); + const result5 = await page.callMethod('stopWifi15'); + expect(result5.res).not.toHaveProperty('_errMsg'); + expect(result5.res.errCode).toEqual(expect.any(Number)); + expect(result5.res.errSubject).toEqual(expect.any(String)); + expect(result5.res.errMsg).toEqual(expect.any(String)); + const result6 = await page.callMethod('stopWifi16'); + expect(result6.res).not.toHaveProperty('_errMsg'); + expect(result6.res.errCode).toEqual(expect.any(Number)); + expect(result6.res.errSubject).toEqual(expect.any(String)); + expect(result6.res.errMsg).toEqual(expect.any(String)); + const result7 = await page.callMethod('stopWifi17'); + expect(result7.res).not.toHaveProperty('_errMsg'); + expect(result7.res.errCode).toEqual(expect.any(Number)); + expect(result7.res.errSubject).toEqual(expect.any(String)); + expect(result7.res.errMsg).toEqual(expect.any(String)); + const result8 = await page.callMethod('stopWifi18'); + expect(result8.res).not.toHaveProperty('_errMsg'); + expect(result8.res.errCode).toEqual(expect.any(Number)); + expect(result8.res.errSubject).toEqual(expect.any(String)); + expect(result8.res.errMsg).toEqual(expect.any(String)); + const result9 = await page.callMethod('stopWifi19'); + expect(result9.res).not.toHaveProperty('_errMsg'); + expect(result9.res.errCode).toEqual(expect.any(Number)); + expect(result9.res.errSubject).toEqual(expect.any(String)); + expect(result9.res.errMsg).toEqual(expect.any(String)); + const result10 = await page.callMethod('stopWifi110'); + expect(result10.res).not.toHaveProperty('_errMsg'); + expect(result10.res.errCode).toEqual(expect.any(Number)); + expect(result10.res.errSubject).toEqual(expect.any(String)); + expect(result10.res.errMsg).toEqual(expect.any(String)); + const result11 = await page.callMethod('stopWifi111'); + expect(result11.res).not.toHaveProperty('_errMsg'); + expect(result11.res.errCode).toEqual(expect.any(Number)); + expect(result11.res.errSubject).toEqual(expect.any(String)); + expect(result11.res.errMsg).toEqual(expect.any(String)); + const result12 = await page.callMethod('stopWifi112'); + expect(result12.res).not.toHaveProperty('_errMsg'); + expect(result12.res.errCode).toEqual(expect.any(Number)); + expect(result12.res.errSubject).toEqual(expect.any(String)); + expect(result12.res.errMsg).toEqual(expect.any(String)); + const result13 = await page.callMethod('stopWifi113'); + expect(result13.res).not.toHaveProperty('_errMsg'); + expect(result13.res.errCode).toEqual(expect.any(Number)); + expect(result13.res.errSubject).toEqual(expect.any(String)); + expect(result13.res.errMsg).toEqual(expect.any(String)); + const result14 = await page.callMethod('stopWifi114'); + expect(result14.res).not.toHaveProperty('_errMsg'); + expect(result14.res.errCode).toEqual(expect.any(Number)); + expect(result14.res.errSubject).toEqual(expect.any(String)); + expect(result14.res.errMsg).toEqual(expect.any(String)); + const result15 = await page.callMethod('stopWifi115'); + expect(result15.res).not.toHaveProperty('_errMsg'); + expect(result15.res.errCode).toEqual(expect.any(Number)); + expect(result15.res.errSubject).toEqual(expect.any(String)); + expect(result15.res.errMsg).toEqual(expect.any(String)); + const result16 = await page.callMethod('stopWifi116'); + expect(result16.res).not.toHaveProperty('_errMsg'); + expect(result16.res.errCode).toEqual(expect.any(Number)); + expect(result16.res.errSubject).toEqual(expect.any(String)); + expect(result16.res.errMsg).toEqual(expect.any(String)); + const result17 = await page.callMethod('stopWifi117'); + expect(result17.res).not.toHaveProperty('_errMsg'); + expect(result17.res.errCode).toEqual(expect.any(Number)); + expect(result17.res.errSubject).toEqual(expect.any(String)); + expect(result17.res.errMsg).toEqual(expect.any(String)); + const result18 = await page.callMethod('stopWifi118'); + expect(result18.res).not.toHaveProperty('_errMsg'); + expect(result18.res.errCode).toEqual(expect.any(Number)); + expect(result18.res.errSubject).toEqual(expect.any(String)); + expect(result18.res.errMsg).toEqual(expect.any(String)); + const result19 = await page.callMethod('stopWifi119'); + expect(result19.res).not.toHaveProperty('_errMsg'); + expect(result19.res.errCode).toEqual(expect.any(Number)); + expect(result19.res.errSubject).toEqual(expect.any(String)); + expect(result19.res.errMsg).toEqual(expect.any(String)); + const result20 = await page.callMethod('stopWifi120'); + expect(result20.res).not.toHaveProperty('_errMsg'); + expect(result20.res.errCode).toEqual(expect.any(Number)); + expect(result20.res.errSubject).toEqual(expect.any(String)); + expect(result20.res.errMsg).toEqual(expect.any(String)); + const result21 = await page.callMethod('stopWifi121'); + expect(result21.res).not.toHaveProperty('_errMsg'); + expect(result21.res.errCode).toEqual(expect.any(Number)); + expect(result21.res.errSubject).toEqual(expect.any(String)); + expect(result21.res.errMsg).toEqual(expect.any(String)); + }); + it('connectWifi2', async () => { + const result_assert0 = await page.callMethod('connectWifi2_assert0'); + expect(result_assert0.res).not.toHaveProperty('_errMsg'); + expect(result_assert0.res.errCode).toEqual(expect.any(Number)); + expect(result_assert0.res.errSubject).toEqual(expect.any(String)); + expect(result_assert0.res.errMsg).toEqual(expect.any(String)); + }); + it('getWifiList3', async () => { + const result_assert0 = await page.callMethod('getWifiList3_assert0'); + expect(result_assert0.res).not.toHaveProperty('_errMsg'); + expect(result_assert0.res.errCode).toEqual(expect.any(Number)); + expect(result_assert0.res.errSubject).toEqual(expect.any(String)); + expect(result_assert0.res.errMsg).toEqual(expect.any(String)); + }); +}); \ No newline at end of file diff --git a/pages/autotest/uni-wifi/uni-wifi.vue b/pages/autotest/uni-wifi/uni-wifi.vue new file mode 100644 index 0000000..e4750bf --- /dev/null +++ b/pages/autotest/uni-wifi/uni-wifi.vue @@ -0,0 +1,724 @@ + + + \ No newline at end of file diff --git a/uni_modules/uni-wifi/utssdk/app-android/index.uts b/uni_modules/uni-wifi/utssdk/app-android/index.uts index 0a0e658..937459d 100644 --- a/uni_modules/uni-wifi/utssdk/app-android/index.uts +++ b/uni_modules/uni-wifi/utssdk/app-android/index.uts @@ -17,7 +17,7 @@ import AuthAlgorithm from 'android.net.wifi.WifiConfiguration.AuthAlgorithm'; import KeyMgmt from 'android.net.wifi.WifiConfiguration.KeyMgmt'; import TextUtils from 'android.text.TextUtils'; -import { UniWifiResult, GetConnectedWifiOptions, WifiConnectOption, WifiOption, UniWifiInfo,UniWifiPartialInfo, UniWifiCallback, StartWifi, StopWifi, GetWifiList, GetConnectedWifi, OnGetWifiList, OnWifiConnectedWithPartialInfo, OnOffWifiConnectedWithPartialInfo, OnWifiConnected, ConnectWifi, OffGetWifiList, OffWifiConnected, SetWifiList } from "../interface.uts" +import { UniWifiResult, GetConnectedWifiOptions, WifiConnectOption, WifiOption, UniWifiInfo, UniWifiPartialInfo, UniWifiCallback, StartWifi, StopWifi, GetWifiList, GetConnectedWifi, OnGetWifiList, OnWifiConnectedWithPartialInfo, OnOffWifiConnectedWithPartialInfo, OnWifiConnected, ConnectWifi, OffGetWifiList, OffWifiConnected, SetWifiList } from "../interface.uts" @@ -113,7 +113,7 @@ export type AndroidUniWifiInfo = { securityType : string; } -function wrapUniWifiInfoFromAndroid(androidInfo:AndroidUniWifiInfo): UniWifiInfo{ +function wrapUniWifiInfoFromAndroid(androidInfo : AndroidUniWifiInfo) : UniWifiInfo { let ret : UniWifiInfo = { SSID: androidInfo.SSID, BSSID: androidInfo.BSSID, @@ -131,7 +131,7 @@ function wrapUniWifiInfoFromScan(scanResult : ScanResult) : AndroidUniWifiInfo { secure: false, signalStrength: 0, frequency: 0, - securityType:"NONE" + securityType: "NONE" } if (scanResult != null) { // 如果是通过扫描列表得到的数据,进行封装 @@ -164,8 +164,8 @@ function wrapUniWifiInfoFromConnectInfo(connectInfo : WifiInfo) : UniWifiInfo { signalStrength: 0, frequency: 0, } - - + + if (connectInfo.getSSID() != null) { let s = connectInfo.getSSID(); // 微信不带,这里需要去掉引号 @@ -316,8 +316,8 @@ function getSecurityType(result : ScanResult) : string { } -function zeroCountNum(source? : string) : number { - if(source == null){ +function zeroCountNum(source ?: string) : number { + if (source == null) { return 0 } var splitted = source.split(":") @@ -329,6 +329,8 @@ function zeroCountNum(source? : string) : number { } return countNum } + + /** * 自定义wifi变化广播监听器 */ @@ -724,10 +726,10 @@ export function connectWifi(option : WifiConnectOption) { wifiManager.saveConfiguration() //scanWifiInfo 根据 partialInfo 填充给返回字段 if (option.partialInfo != null && option.partialInfo == true) { - let wifiPartialInfo:UniWifiInfo = { + let wifiPartialInfo : UniWifiInfo = { SSID: scanWifiInfo.SSID } - result.wifi =wifiPartialInfo + result.wifi = wifiPartialInfo } else { result.wifi = wrapUniWifiInfoFromAndroid(scanWifiInfo) } @@ -748,9 +750,9 @@ export function connectWifi(option : WifiConnectOption) { export function stopWifi(option : WifiOption) { // 需要先开启wifi,才能使用后续的功能 if (Global.mReceiver == null) { - var result:UniWifiResult = { + var result : UniWifiResult = { errCode: 12000, - errSubject:"uni-stopWifi", + errSubject: "uni-stopWifi", errMsg: "stopWifi:not init" } option.fail?.(result) @@ -765,9 +767,9 @@ export function stopWifi(option : WifiOption) { //TODO handle the exception } - var result:UniWifiResult = { + var result : UniWifiResult = { errCode: 0, - errSubject:"uni-stopWifi", + errSubject: "uni-stopWifi", errMsg: "stopWifi:ok" } option.success?.(result) @@ -781,11 +783,11 @@ export function stopWifi(option : WifiOption) { @Suppress("DEPRECATION") export function getConnectedWifi(option : GetConnectedWifiOptions) { - let wifiInfo:UniWifiInfo = { - SSID:"" + let wifiInfo : UniWifiInfo = { + SSID: "" } - var res:UniWifiResult = { + var res : UniWifiResult = { errCode: 12000, errMsg: "getConnectedWifi:fail:not invoke startWifi", errSubject: "uni-getConnectedWifi", @@ -823,7 +825,7 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) { wifiInfo = wrapUniWifiInfoFromConnectInfo(winfo); // 判断一下是否wifi 关闭了 if (option.partialInfo!) { - let ret:UniWifiInfo = { + let ret : UniWifiInfo = { SSID: wifiInfo.SSID } res.wifi = ret; diff --git a/uni_modules/uni-wifi/utssdk/interface.uts b/uni_modules/uni-wifi/utssdk/interface.uts index 6f4f63a..c900600 100644 --- a/uni_modules/uni-wifi/utssdk/interface.uts +++ b/uni_modules/uni-wifi/utssdk/interface.uts @@ -80,6 +80,34 @@ export type SetWifiList = (option: WifiOption) => void interface Uni { startWifi : StartWifi, stopWifi : StopWifi, + /** + * @autotest { + generated: false, + cases:[ + { + before: 'startWifi', + after: 'stopWifi', + input: [{ + maunal:false, + SSID:"Xiaomi_20D0", + password:"BBB111" + }] + } + ] + } + */ + connectWifi: ConnectWifi, + /** + * @autotest { + generated: false, + cases:[ + { + before: 'startWifi', + after: 'stopWifi' + } + ] + } + */ getWifiList : GetWifiList, onGetWifiList : OnGetWifiList, offGetWifiList : OffGetWifiList, diff --git a/uni_modules/uni-wifi/utssdk/uni.autotest.js b/uni_modules/uni-wifi/utssdk/uni.autotest.js new file mode 100644 index 0000000..93873d5 --- /dev/null +++ b/uni_modules/uni-wifi/utssdk/uni.autotest.js @@ -0,0 +1,35 @@ +function startWifi() { + return new Promise((resolve, reject) => { + uni.startWifi({ + success: () => { + console.log('startWifi success'); + resolve() + }, + fail: () => { + console.log('startWifi fail'); + reject() + } + }) + }) +} + +function stopWifi() { + return new Promise((resolve, reject) => { + uni.stopWifi({ + success: () => { + console.log('stopWifi success'); + resolve() + }, + fail: () => { + console.log('stopWifi success'); + fail() + } + }) + }) +} + + +module.exports = { + startWifi, + stopWifi +} -- GitLab