Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-api
提交
98ad8603
U
uni-api
项目概览
DCloud
/
uni-api
通知
671
Star
23
Fork
12
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-api
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
98ad8603
编写于
3月 28, 2023
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复wifi 插件部分问题
上级
9876fce9
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
190 addition
and
1163 deletion
+190
-1163
autotest.utils.js
autotest.utils.js
+0
-1
env.js
env.js
+0
-1
pages/autotest/uni-wifi/uni-wifi.test.js
pages/autotest/uni-wifi/uni-wifi.test.js
+0
-245
pages/autotest/uni-wifi/uni-wifi.vue
pages/autotest/uni-wifi/uni-wifi.vue
+0
-724
pages/index/index.vue
pages/index/index.vue
+30
-8
uni_modules/uni-wifi/utssdk/app-android/index.uts
uni_modules/uni-wifi/utssdk/app-android/index.uts
+153
-182
uni_modules/uni-wifi/utssdk/interface.uts
uni_modules/uni-wifi/utssdk/interface.uts
+7
-2
未找到文件。
autotest.utils.js
已删除
100644 → 0
浏览文件 @
9876fce9
"
use strict
"
;
function
t
(
t
,
r
){
const
s
=
t
.
split
(
"
.
"
),
e
=
r
.
split
(
"
.
"
),
n
=
Math
.
max
(
s
.
length
,
e
.
length
);
for
(
let
t
=
0
;
t
<
n
;
t
++
){
const
r
=
parseInt
(
s
[
t
]
||
"
0
"
),
n
=
parseInt
(
e
[
t
]
||
"
0
"
);
if
(
r
>
n
)
return
1
;
if
(
r
<
n
)
return
-
1
}
return
0
}
function
r
(
r
,
s
){
if
(
"
*
"
===
s
||
s
===
r
)
return
!
0
;
switch
(
s
.
slice
(
0
,
2
)){
case
"
>=
"
:
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
;
env.js
已删除
100644 → 0
浏览文件 @
9876fce9
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
pages/autotest/uni-wifi/uni-wifi.test.js
已删除
100644 → 0
浏览文件 @
9876fce9
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
pages/autotest/uni-wifi/uni-wifi.vue
已删除
100644 → 0
浏览文件 @
9876fce9
<
template
>
<view>
</view>
</
template
>
<
script
>
import
{
startWifi
,
stopWifi
}
from
"
@/uni_modules/uni-wifi/utssdk/uni.autotest.js
"
;
import
{
invokeApi
}
from
"
D:/source/uni-api/autotest.utils.js
"
;
export
default
{
methods
:
{
startWifi00
:
async
function
startWifi00
()
{
const
inputs
=
[
function
()
{
""
;
}];
let
startWifi00_res
;
try
{
startWifi00_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi00_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi00_res
};
},
startWifi01
:
async
function
startWifi01
()
{
const
inputs
=
[[]];
let
startWifi01_res
;
try
{
startWifi01_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi01_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi01_res
};
},
startWifi02
:
async
function
startWifi02
()
{
const
inputs
=
[
new
Uint8Array
([
0
,
1
]).
buffer
];
let
startWifi02_res
;
try
{
startWifi02_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi02_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi02_res
};
},
startWifi03
:
async
function
startWifi03
()
{
const
inputs
=
[
"
abc
"
];
let
startWifi03_res
;
try
{
startWifi03_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi03_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi03_res
};
},
startWifi04
:
async
function
startWifi04
()
{
const
inputs
=
[
"
0
"
];
let
startWifi04_res
;
try
{
startWifi04_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi04_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi04_res
};
},
startWifi05
:
async
function
startWifi05
()
{
const
inputs
=
[
"
false
"
];
let
startWifi05_res
;
try
{
startWifi05_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi05_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi05_res
};
},
startWifi06
:
async
function
startWifi06
()
{
const
inputs
=
[
"
\
u6587
"
];
let
startWifi06_res
;
try
{
startWifi06_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi06_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi06_res
};
},
startWifi07
:
async
function
startWifi07
()
{
const
inputs
=
[
"
/
"
];
let
startWifi07_res
;
try
{
startWifi07_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi07_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi07_res
};
},
startWifi08
:
async
function
startWifi08
()
{
const
inputs
=
[
"
\"
"
];
let
startWifi08_res
;
try
{
startWifi08_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi08_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi08_res
};
},
startWifi09
:
async
function
startWifi09
()
{
const
inputs
=
[
"
%
"
];
let
startWifi09_res
;
try
{
startWifi09_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi09_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi09_res
};
},
startWifi010
:
async
function
startWifi010
()
{
const
inputs
=
[
"
;
"
];
let
startWifi010_res
;
try
{
startWifi010_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi010_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi010_res
};
},
startWifi011
:
async
function
startWifi011
()
{
const
inputs
=
[
-
1.1
];
let
startWifi011_res
;
try
{
startWifi011_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi011_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi011_res
};
},
startWifi012
:
async
function
startWifi012
()
{
const
inputs
=
[
-
1
];
let
startWifi012_res
;
try
{
startWifi012_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi012_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi012_res
};
},
startWifi013
:
async
function
startWifi013
()
{
const
inputs
=
[
-
0.1
];
let
startWifi013_res
;
try
{
startWifi013_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi013_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi013_res
};
},
startWifi014
:
async
function
startWifi014
()
{
const
inputs
=
[
0
];
let
startWifi014_res
;
try
{
startWifi014_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi014_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi014_res
};
},
startWifi015
:
async
function
startWifi015
()
{
const
inputs
=
[
0.1
];
let
startWifi015_res
;
try
{
startWifi015_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi015_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi015_res
};
},
startWifi016
:
async
function
startWifi016
()
{
const
inputs
=
[
1
];
let
startWifi016_res
;
try
{
startWifi016_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi016_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi016_res
};
},
startWifi017
:
async
function
startWifi017
()
{
const
inputs
=
[
1.1
];
let
startWifi017_res
;
try
{
startWifi017_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi017_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi017_res
};
},
startWifi018
:
async
function
startWifi018
()
{
const
inputs
=
[
-
9007199254740991
];
let
startWifi018_res
;
try
{
startWifi018_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi018_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi018_res
};
},
startWifi019
:
async
function
startWifi019
()
{
const
inputs
=
[
9007199254740991
];
let
startWifi019_res
;
try
{
startWifi019_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi019_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi019_res
};
},
startWifi020
:
async
function
startWifi020
()
{
const
inputs
=
[
true
];
let
startWifi020_res
;
try
{
startWifi020_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi020_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi020_res
};
},
startWifi021
:
async
function
startWifi021
()
{
const
inputs
=
[
false
];
let
startWifi021_res
;
try
{
startWifi021_res
=
await
invokeApi
(
uni
.
startWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
startWifi021_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
startWifi021_res
};
},
stopWifi10
:
async
function
stopWifi10
()
{
const
inputs
=
[
function
()
{
""
;
}];
let
stopWifi10_res
;
try
{
stopWifi10_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi10_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi10_res
};
},
stopWifi11
:
async
function
stopWifi11
()
{
const
inputs
=
[[]];
let
stopWifi11_res
;
try
{
stopWifi11_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi11_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi11_res
};
},
stopWifi12
:
async
function
stopWifi12
()
{
const
inputs
=
[
new
Uint8Array
([
0
,
1
]).
buffer
];
let
stopWifi12_res
;
try
{
stopWifi12_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi12_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi12_res
};
},
stopWifi13
:
async
function
stopWifi13
()
{
const
inputs
=
[
"
abc
"
];
let
stopWifi13_res
;
try
{
stopWifi13_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi13_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi13_res
};
},
stopWifi14
:
async
function
stopWifi14
()
{
const
inputs
=
[
"
0
"
];
let
stopWifi14_res
;
try
{
stopWifi14_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi14_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi14_res
};
},
stopWifi15
:
async
function
stopWifi15
()
{
const
inputs
=
[
"
false
"
];
let
stopWifi15_res
;
try
{
stopWifi15_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi15_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi15_res
};
},
stopWifi16
:
async
function
stopWifi16
()
{
const
inputs
=
[
"
\
u6587
"
];
let
stopWifi16_res
;
try
{
stopWifi16_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi16_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi16_res
};
},
stopWifi17
:
async
function
stopWifi17
()
{
const
inputs
=
[
"
/
"
];
let
stopWifi17_res
;
try
{
stopWifi17_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi17_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi17_res
};
},
stopWifi18
:
async
function
stopWifi18
()
{
const
inputs
=
[
"
\"
"
];
let
stopWifi18_res
;
try
{
stopWifi18_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi18_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi18_res
};
},
stopWifi19
:
async
function
stopWifi19
()
{
const
inputs
=
[
"
%
"
];
let
stopWifi19_res
;
try
{
stopWifi19_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi19_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi19_res
};
},
stopWifi110
:
async
function
stopWifi110
()
{
const
inputs
=
[
"
;
"
];
let
stopWifi110_res
;
try
{
stopWifi110_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi110_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi110_res
};
},
stopWifi111
:
async
function
stopWifi111
()
{
const
inputs
=
[
-
1.1
];
let
stopWifi111_res
;
try
{
stopWifi111_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi111_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi111_res
};
},
stopWifi112
:
async
function
stopWifi112
()
{
const
inputs
=
[
-
1
];
let
stopWifi112_res
;
try
{
stopWifi112_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi112_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi112_res
};
},
stopWifi113
:
async
function
stopWifi113
()
{
const
inputs
=
[
-
0.1
];
let
stopWifi113_res
;
try
{
stopWifi113_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi113_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi113_res
};
},
stopWifi114
:
async
function
stopWifi114
()
{
const
inputs
=
[
0
];
let
stopWifi114_res
;
try
{
stopWifi114_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi114_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi114_res
};
},
stopWifi115
:
async
function
stopWifi115
()
{
const
inputs
=
[
0.1
];
let
stopWifi115_res
;
try
{
stopWifi115_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi115_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi115_res
};
},
stopWifi116
:
async
function
stopWifi116
()
{
const
inputs
=
[
1
];
let
stopWifi116_res
;
try
{
stopWifi116_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi116_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi116_res
};
},
stopWifi117
:
async
function
stopWifi117
()
{
const
inputs
=
[
1.1
];
let
stopWifi117_res
;
try
{
stopWifi117_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi117_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi117_res
};
},
stopWifi118
:
async
function
stopWifi118
()
{
const
inputs
=
[
-
9007199254740991
];
let
stopWifi118_res
;
try
{
stopWifi118_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi118_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi118_res
};
},
stopWifi119
:
async
function
stopWifi119
()
{
const
inputs
=
[
9007199254740991
];
let
stopWifi119_res
;
try
{
stopWifi119_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi119_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi119_res
};
},
stopWifi120
:
async
function
stopWifi120
()
{
const
inputs
=
[
true
];
let
stopWifi120_res
;
try
{
stopWifi120_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi120_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi120_res
};
},
stopWifi121
:
async
function
stopWifi121
()
{
const
inputs
=
[
false
];
let
stopWifi121_res
;
try
{
stopWifi121_res
=
await
invokeApi
(
uni
.
stopWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
stopWifi121_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
return
{
res
:
stopWifi121_res
};
},
connectWifi2_assert0
:
async
function
connectWifi2_assert0
()
{
const
inputs
=
[{
maunal
:
false
,
SSID
:
"
Xiaomi_20D0
"
,
password
:
"
BBB111
"
}];
const
uniAutoTest
=
{
isRandom
:
false
,
inputs
};
await
startWifi
(
uniAutoTest
);
let
connectWifi2_assert0_res
;
try
{
connectWifi2_assert0_res
=
await
invokeApi
(
uni
.
connectWifi
,
true
,
...
inputs
);
}
catch
(
e
)
{
connectWifi2_assert0_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
await
stopWifi
(
uniAutoTest
);
return
{
res
:
connectWifi2_assert0_res
};
},
getWifiList3_assert0
:
async
function
getWifiList3_assert0
()
{
const
inputs
=
[];
const
uniAutoTest
=
{
isRandom
:
false
,
inputs
};
await
startWifi
(
uniAutoTest
);
let
getWifiList3_assert0_res
;
try
{
getWifiList3_assert0_res
=
await
invokeApi
(
uni
.
getWifiList
,
true
,
...
inputs
);
}
catch
(
e
)
{
getWifiList3_assert0_res
=
{
_expectError
:
true
,
_errMsg
:
getErrMsg
(
e
)
};
}
await
stopWifi
(
uniAutoTest
);
return
{
res
:
getWifiList3_assert0_res
};
}
}
};
function
getErrMsg
(
e
){
return
e
?
e
.
message
||
e
:
'
There is no error information
'
}
</
script
>
\ No newline at end of file
pages/index/index.vue
浏览文件 @
98ad8603
...
...
@@ -14,6 +14,7 @@
<button
@
tap=
"testStartWifi"
>
初始化wifi模块
</button>
<button
@
tap=
"testGetWifiList"
>
获取当前wifi列表
</button>
<button
@
tap=
"testOffGetWifiList"
>
移除wifi列表监听
</button>
<button
@
tap=
"testGetConnnectWifi"
>
获取当前连接的wifi
</button>
<button
@
tap=
"testConnnectWifi"
>
链接wifi
</button>
<button
@
tap=
"testStopWifi"
>
关闭wifi模块
</button>
...
...
@@ -39,15 +40,26 @@
console
.
log
(
res
);
},
testConnnectWifi
(){
uni
.
connectWifi
({
maunal
:
true
,
SSID
:
"
Xiaomi_20D0
"
,
password
:
"
BBB111
"
,
complete
:(
res
)
=>
{
console
.
log
(
res
);
uni
.
startWifi
({
success
:(
res
)
=>
{
console
.
log
(
"
success:
"
+
JSON
.
stringify
(
res
));
uni
.
connectWifi
({
maunal
:
false
,
SSID
:
"
Xiaomi_20D0
"
,
password
:
"
BBB111
"
,
complete
:(
res
)
=>
{
console
.
log
(
res
);
}
});
},
fail
:(
res
)
=>
{
console
.
log
(
"
fail:
"
+
JSON
.
stringify
(
res
));
},
complete
:(
res
)
=>
{
console
.
log
(
"
complete:
"
+
JSON
.
stringify
(
res
));
}
});
})
},
testGetConnnectWifi
(){
...
...
@@ -96,6 +108,9 @@
})
},
testStopWifi
()
{
uni
.
offWifiConnected
()
uni
.
offWifiConnectedWithPartialInfo
()
uni
.
stopWifi
({
success
:(
res
)
=>
{
console
.
log
(
"
success:
"
+
JSON
.
stringify
(
res
));
...
...
@@ -119,6 +134,13 @@
})
},
testOffGetWifiList
(){
uni
.
offGetWifiList
()
},
testonMemoryWarning
()
{
uni
.
onMemoryWarning
(
this
.
onMemoryWarning
)
uni
.
showToast
({
...
...
uni_modules/uni-wifi/utssdk/app-android/index.uts
浏览文件 @
98ad8603
...
...
@@ -16,45 +16,9 @@ import WifiConfiguration from 'android.net.wifi.WifiConfiguration';
import AuthAlgorithm from 'android.net.wifi.WifiConfiguration.AuthAlgorithm';
import KeyMgmt from 'android.net.wifi.WifiConfiguration.KeyMgmt';
import TextUtils from 'android.text.TextUtils';
import Build from 'android.os.Build';
import { UniWifiResult, GetConnectedWifiOptions, WifiConnectOption, WifiOption, UniWifiInfo, UniWifiPartialInfo, UniWifiCallback, StartWifi, StopWifi, GetWifiList, GetConnectedWifi, OnGetWifiList, OnWifiConnectedWithPartialInfo, OnOffWifiConnectedWithPartialInfo, OnWifiConnected, ConnectWifi, OffGetWifiList, OffWifiConnected, SetWifiList } from "../interface.uts"
// /**
// * Wifi 函数通用入参封装
// */
// type WifiOption = {
// success?: (res: object) => void;
// fail?: (res: object) => void;
// complete?: (res: object) => void;
// };
// /**
// * 获取当前链接的wifi信息
// */
// type GetConnectedWifiOptions = {
// partialInfo?: boolean
// success?: (res: UTSJSONObject) => void
// fail?: (res: UTSJSONObject) => void
// complete?: (res: UTSJSONObject) => void
// }
// /**
// * Wifi 链接参数封装
// */
// type WifiConnectOption = {
// SSID:string;
// BSSID?:string;
// password:string;
// maunal:boolean;
// // 只返回ssid
// partialInfo:boolean;
// success?: (res: object) => void;
// fail?: (res: object) => void;
// complete?: (res: object) => void;
// }
import { UniWifiResult, GetConnectedWifiOptions, WifiConnectOption, WifiOption, UniWifiInfo } from "../interface.uts"
...
...
@@ -103,7 +67,9 @@ function isHexWepKey(wepKey : string) : boolean {
return isHex(wepKey);
}
/**
* android 平台特有的Wifi信息对象,主要是加了加密信息这个字段
*/
export type AndroidUniWifiInfo = {
SSID : string;
BSSID ?: string;
...
...
@@ -123,7 +89,9 @@ function wrapUniWifiInfoFromAndroid(androidInfo : AndroidUniWifiInfo) : UniWifiI
}
return ret
}
/**
* 从扫描结果中提取统一的wifi数据结构
*/
function wrapUniWifiInfoFromScan(scanResult : ScanResult) : AndroidUniWifiInfo {
let ret : AndroidUniWifiInfo = {
...
...
@@ -156,7 +124,9 @@ function wrapUniWifiInfoFromScan(scanResult : ScanResult) : AndroidUniWifiInfo {
return ret
}
/**
* 从链接信息中提取统一的wifi数据结构
*/
function wrapUniWifiInfoFromConnectInfo(connectInfo : WifiInfo) : UniWifiInfo {
let ret : UniWifiInfo = {
SSID: "",
...
...
@@ -185,73 +155,9 @@ function wrapUniWifiInfoFromConnectInfo(connectInfo : WifiInfo) : UniWifiInfo {
}
// /**
// * Wifi信息统一数据结构
// */
// class UniWifiInfo {
// SSID: string = "";
// BSSID: string = "";
// secure: boolean = false;
// signalStrength: Number = 0;
// frequency: Number = 0;
// /*下面的字段属于扩展字段*/
// securityType:string = ""
// constructor(scanResult: ScanResult|null = null) {
// if (scanResult != null) {
// // 如果是通过扫描列表得到的数据,进行封装
// this.BSSID = scanResult.BSSID;
// this.SSID = scanResult.SSID;
// this.signalStrength = scanResult.level;
// this.frequency = scanResult.frequency;
// // 是否安全,微信的标准是是否需要密码。 来源:https://developers.weixin.qq.com/community/develop/doc/00064cf1790458db19cddf9925ac00?highLine=WifiInfo
// this.secure = false;
// let capabilities = scanResult.capabilities.trim();
// if ((capabilities.equals(Global.WIFI_AUTH_OPEN) || capabilities.equals(Global.WIFI_AUTH_ROAM))) {
// this.secure = false;
// } else {
// this.secure = true;
// }
// /*扩展字段*/
// this.securityType = getSecurityType(scanResult);
// }
// }
// /**
// * 根据connectInfo 链接信息对wifi数据结构进行初始化
// */
// wrapConnectInfo(connectInfo: WifiInfo): void {
// if (connectInfo.getBSSID() == null) {
// return
// }
// if (connectInfo.getSSID() != null) {
// let s = connectInfo.getSSID();
// // 微信不带,这里需要去掉引号
// if (s.length > 2 && s.charAt(0) == '"' && s.charAt(s.length - 1) == '"') {
// s = s.substring(1, s.length - 1);
// }
// this.SSID = s;
// }
// this.BSSID = connectInfo.getBSSID();
// //Android返回的值是-100~0,而微信API规范是0~100,值越大信号越好,需要+100拉齐
// this.signalStrength = connectInfo.getRssi() + 100;
// this.frequency = connectInfo.getFrequency();
// }
// }
/**
* 连接wifi时使用,根据用户输入内容包装为系统需要的wifi配置对象
*/
* 连接wifi时使用,根据用户输入内容包装为系统需要的wifi配置对象
*
*/
@Suppress("DEPRECATION")
function wrapWifiConfiguration(SSID : string, password ?: string, passwordType : string) : WifiConfiguration {
...
...
@@ -396,6 +302,7 @@ class CustomBroadcastReceiver extends BroadcastReceiver {
if (intent.action == WifiManager.SCAN_RESULTS_AVAILABLE_ACTION) {
startWifiScaning = false;
// wifi 扫描结果回调
let results = this.mWifiManager!.scanResults;
...
...
@@ -427,10 +334,14 @@ class CustomBroadcastReceiver extends BroadcastReceiver {
/************************* 下面是对外提供的函数 *************************/
/**
* start wifi是否正在扫描
*/
var startWifiScaning = false
/**
* 开启wifi
*/
* 开启wifi
*/
@Suppress("DEPRECATION")
export function startWifi(option : WifiOption) {
...
...
@@ -452,7 +363,7 @@ export function startWifi(option : WifiOption) {
return;
}
// 具备了权限,继续前进
let wifiManager : WifiManager =
UTSAndroid.getAppContext()!.getSystemService(Context.WIFI_SERVICE) as WifiManager
...
...
@@ -496,6 +407,7 @@ export function startWifi(option : WifiOption) {
}
});
startWifiScaning = true
// 开始扫描
wifiManager.startScan()
...
...
@@ -558,18 +470,33 @@ export function onWifiConnectedWithPartialInfo(callback : UTSCallback) {
/**
* wifi 链接成功的回调取消注册
*/
export function offWifiConnected(callback : UTSCallback) {
* wifi 链接成功的回调取消注册
*/
export function offWifiConnected(callback? : UTSCallback) {
if(callback == null){
Global.onWifiConnectCallbackList = []
return
}
let callbackIndex = Global.onWifiConnectCallbackList.indexOf(callback)
if (callbackIndex > 0) {
if (callbackIndex >
=
0) {
Global.onWifiConnectCallbackList.splice(callbackIndex, 1);
}
}
export function offWifiConnectedWithPartialInfo(callback : UTSCallback) {
/**
* 不具备详细信息的wifi 反注册
*/
export function offWifiConnectedWithPartialInfo(callback? : UTSCallback) {
if(callback == null){
Global.onWifiConnectWithPartialInfoCallbackList = []
return
}
let callbackIndex = Global.onWifiConnectWithPartialInfoCallbackList.indexOf(callback)
if (callbackIndex > 0) {
if (callbackIndex >
=
0) {
Global.onWifiConnectWithPartialInfoCallbackList.splice(callbackIndex, 1);
}
}
...
...
@@ -580,53 +507,34 @@ export function offWifiConnectedWithPartialInfo(callback : UTSCallback) {
export function onGetWifiList(callback : UTSCallback) {
Global.getWifiListCallbackList.push(callback)
}
/**
* 取消注册Wifi列表的监听事件
*/
export function offGetWifiList(callback : UTSCallback) {
* 取消注册Wifi列表的监听事件
*/
export function offGetWifiList(callback? : UTSCallback) {
if(callback == null){
Global.getWifiListCallbackList = []
return
}
let callbackIndex = Global.getWifiListCallbackList.indexOf(callback)
if (callbackIndex > 0) {
if (callbackIndex >
=
0) {
Global.getWifiListCallbackList.splice(callbackIndex, 1);
}
}
/**
* 链接指定wifi
*/
@Suppress("UNUSED_PARAMETER", "DEPRECATION")
export function connectWifi(option : WifiConnectOption) {
if (option.maunal == true) {
// 指定了手动模式
let manunalIntent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
UTSAndroid.getUniActivity()!.startActivity(manunalIntent);
result.errCode = 0
result.errMsg = "connectWifi:ok"
option.success?.(result)
option.complete?.(result)
return
}
var result : UniWifiResult = {
errCode: 12000,
errMsg: "connectWifi:fail:not invoke startWifi",
errSubject: "uni-connectWifi",
}
* 真正执行wifi链接逻辑
*/
function realWifiConnect(option : WifiConnectOption,result : UniWifiResult){
if (Global.mReceiver == null || Global.scanList.length < 1) {
// 还没调用startWifi 提示报错
option.fail?.(result)
option.complete?.(result)
return
}
// 执行后续的逻辑
let scanWifiInfo : AndroidUniWifiInfo | null = null
for (let scanResult in Global.scanList) {
...
...
@@ -634,19 +542,19 @@ export function connectWifi(option : WifiConnectOption) {
scanWifiInfo = scanResult
}
}
if (scanWifiInfo == null) {
// 不在扫描列表中返回错误
option.fail?.(result)
option.complete?.(result)
return
}
let wifiConfigration = wrapWifiConfiguration(scanWifiInfo.SSID, option.password, scanWifiInfo.securityType);
wifiConfigration.BSSID = scanWifiInfo.BSSID
let wifiManager : WifiManager =
UTSAndroid.getAppContext()!.getSystemService(Context.WIFI_SERVICE) as WifiManager
// 如果已经存在了指定wifi 配置,移除之
let targetExistConfig : WifiConfiguration | null = null
let existingConfigs = wifiManager.getConfiguredNetworks();
...
...
@@ -658,20 +566,28 @@ export function connectWifi(option : WifiConnectOption) {
// 如果wifi已经保存了当前ssid的配置,可能是别的应用添加的。android系统要求,需要删除掉重新添加
if (targetExistConfig != null) {
let removeRet = wifiManager.removeNetwork(targetExistConfig.networkId);
if (!removeRet) {
// 移除之前的配置失败了,返回错误,需要用户手动取消保存一下
result.errCode = 12013
result.errMsg = "connectWifi:wifi config may be expired"
// add since 2023-03-28,如果当前系统大于等于android10, 则明确当前系统不支持
if(Build.VERSION.SDK_INT > 28){
// 系统大于android 9
result.errCode = 12001
result.errMsg = "connectWifi:system not support"
}else{
// 移除之前的配置失败了,返回错误,需要用户手动取消保存一下
result.errCode = 12013
result.errMsg = "connectWifi:wifi config may be expired"
}
option.fail?.(result)
option.complete?.(result)
return
}
}
let currentConnect = wifiManager.getConnectionInfo()
if (currentConnect.networkId >= 0) {
wifiManager.disableNetwork(currentConnect.networkId)
...
...
@@ -679,52 +595,52 @@ export function connectWifi(option : WifiConnectOption) {
wifiManager.removeNetwork(currentConnect.networkId)
}
wifiManager.disconnect()
let connected = false;
try {
let netID = wifiManager.addNetwork(wifiConfigration);
// 如果-1 说明没添加上,报错即可
if (netID < 0) {
result.errCode = 12002
result.errMsg = "connectWifi:password error Wi-Fi"
option.fail?.(result)
option.complete?.(result)
return
}
let enabled = wifiManager.enableNetwork(netID, true);
if (!enabled) {
result.errCode = 12007
result.errMsg = "connectWifi:user denied"
option.fail?.(result)
option.complete?.(result)
return
}
connected = wifiManager.reconnect();
} catch (e) {
connected = false;
console.log(e);
}
if (!connected) {
// 出错了,返回错误
// 兜底的报错
result.errCode = 12010
result.errMsg = "connectWifi:fail:unknown error"
option.fail?.(result)
option.complete?.(result)
return
}
wifiManager.saveConfiguration()
//scanWifiInfo 根据 partialInfo 填充给返回字段
if (option.partialInfo != null && option.partialInfo == true) {
...
...
@@ -735,13 +651,65 @@ export function connectWifi(option : WifiConnectOption) {
} else {
result.wifi = wrapUniWifiInfoFromAndroid(scanWifiInfo)
}
// result.wifi = scanWifiInfo.toUTSJSON(option.partialInfo)
result.errCode = 0
result.errMsg = "connectWifi:ok"
option.success?.(result)
option.complete?.(result)
}
/**
* 链接指定wifi
*/
@Suppress("UNUSED_PARAMETER", "DEPRECATION")
export function connectWifi(option : WifiConnectOption) {
var result : UniWifiResult = {
errCode: 12000,
errMsg: "connectWifi:fail:not invoke startWifi",
errSubject: "uni-connectWifi",
}
if (option.maunal == true) {
// 指定了手动模式
let manunalIntent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
UTSAndroid.getUniActivity()!.startActivity(manunalIntent);
result.errCode = 0
result.errMsg = "connectWifi:ok"
option.success?.(result)
option.complete?.(result)
return
}
// add since 2022-03-28 ,增加逻辑,如果正在扫描中,则可以等待5s
if(startWifiScaning){
let taskCount = 0
let taskId:number = 0
taskId = setInterval(function(){
taskCount += 1;
if(taskCount >= 5 || startWifiScaning == false){
// 超过10s了。或者扫描过程结束了
clearInterval(taskId)
realWifiConnect(option,result)
}
},2000)
UTSAndroid.onAppActivityDestroy(function () {
clearInterval(taskId)
});
}else{
realWifiConnect(option,result)
}
}
...
...
@@ -768,8 +736,12 @@ export function stopWifi(option : WifiOption) {
// 多次调用
//TODO handle the exception
}
Global.getWifiListCallbackList = []
Global.onWifiConnectWithPartialInfoCallbackList = []
Global.onWifiConnectCallbackList = []
var
result : UniWifiResult = {
let
result : UniWifiResult = {
errCode: 0,
errSubject: "uni-stopWifi",
errMsg: "stopWifi:ok"
...
...
@@ -780,8 +752,8 @@ export function stopWifi(option : WifiOption) {
}
/**
* 获取当前连接中的wifi信息
*/
* 获取当前连接中的wifi信息
*/
@Suppress("DEPRECATION")
export function getConnectedWifi(option : GetConnectedWifiOptions) {
...
...
@@ -803,6 +775,7 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
return
}
// 需要先校验权限,没有位置权限无法获取wifi
if (ActivityCompat.checkSelfPermission(UTSAndroid.getUniActivity()!, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// 尚不具备权限,返回错误
res.errCode = 12001
...
...
@@ -813,8 +786,6 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
return;
}
// TODO 应该try catch一下,把系统的错误码给返回来,然后和微信的错误码拉齐
// 需要先校验权限,没有位置权限无法获取wifi
const context = UTSAndroid.getAppContext();
if (context != null) {
const wm = context.getSystemService(
...
...
@@ -826,7 +797,7 @@ export function getConnectedWifi(option : GetConnectedWifiOptions) {
wifiInfo = wrapUniWifiInfoFromConnectInfo(winfo);
// 判断一下是否wifi 关闭了
if (option.partialInfo!) {
if (option.partialInfo!
= null
) {
let ret : UniWifiInfo = {
SSID: wifiInfo.SSID
}
...
...
uni_modules/uni-wifi/utssdk/interface.uts
浏览文件 @
98ad8603
...
...
@@ -83,6 +83,7 @@ interface Uni {
/**
* @autotest {
generated: false,
pollution: false,
cases:[
{
before: 'startWifi',
...
...
@@ -90,8 +91,12 @@ interface Uni {
input: [{
maunal:false,
SSID:"Xiaomi_20D0",
password:"BBB111"
}]
password:"streamApp!2016",
}],
output:{
callbackType: 'success',
value: { errCode: 12013 ,errMsg: "connectWifi:wifi config may be expired",errSubject: "uni-connectWifi"}
}
}
]
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录