Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
4d9bb4fd
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
4d9bb4fd
编写于
10月 26, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
!6122 feat: Add the js api error code and the removeRight interface use case
Merge pull request !6122 from 李晓枫/usb1018
上级
fa090844
3a8028d1
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
590 addition
and
44 deletion
+590
-44
usb/usb_standard/src/main/js/test/UsbCoreJsunit.test.js
usb/usb_standard/src/main/js/test/UsbCoreJsunit.test.js
+64
-6
usb/usb_standard/src/main/js/test/UsbCoreJsunitEx.test.js
usb/usb_standard/src/main/js/test/UsbCoreJsunitEx.test.js
+203
-0
usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js
...usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js
+63
-36
usb/usb_standard/src/main/js/test/UsbDevicePipeJsunitEx.test.js
...b_standard/src/main/js/test/UsbDevicePipeJsunitEx.test.js
+150
-0
usb/usb_standard/src/main/js/test/UsbFunctionsJsunit.test.js
usb/usb_standard/src/main/js/test/UsbFunctionsJsunit.test.js
+2
-1
usb/usb_standard/src/main/js/test/UsbFunctionsJsunitEx.test.js
...sb_standard/src/main/js/test/UsbFunctionsJsunitEx.test.js
+37
-0
usb/usb_standard/src/main/js/test/UsbPortAndFunctionJsunit.test.js
...tandard/src/main/js/test/UsbPortAndFunctionJsunit.test.js
+0
-1
usb/usb_standard/src/main/js/test/UsbPortJsunitEx.test.js
usb/usb_standard/src/main/js/test/UsbPortJsunitEx.test.js
+71
-0
未找到文件。
usb/usb_standard/src/main/js/test/UsbCoreJsunit.test.js
浏览文件 @
4d9bb4fd
...
@@ -67,13 +67,13 @@ describe('UsbCoreJsFunctionsTest', function () {
...
@@ -67,13 +67,13 @@ describe('UsbCoreJsFunctionsTest', function () {
* @tc.desc : 获取设备列表
* @tc.desc : 获取设备列表
*/
*/
it
(
'
SUB_USB_JS_0480
'
,
0
,
function
()
{
it
(
'
SUB_USB_JS_0480
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_0480 begin
'
);
console
.
info
(
'
*****SUB_USB_JS_0480 portcurrentMode**** ret :
'
+
portCurrentMode
)
console
.
info
(
'
*****SUB_USB_JS_0480 portcurrentMode**** ret :
'
+
portCurrentMode
)
if
(
portCurrentMode
==
1
)
{
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
expect
(
false
).
assertFalse
();
return
return
}
}
console
.
info
(
'
usb SUB_USB_JS_0480 begin
'
);
gDeviceList
=
usb
.
getDevices
();
gDeviceList
=
usb
.
getDevices
();
if
(
gDeviceList
.
length
==
0
)
{
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb case get_devices list is null
'
)
console
.
info
(
'
usb case get_devices list is null
'
)
...
@@ -85,10 +85,9 @@ describe('UsbCoreJsFunctionsTest', function () {
...
@@ -85,10 +85,9 @@ describe('UsbCoreJsFunctionsTest', function () {
console
.
info
(
'
usb SUB_USB_JS_0480: PASS
'
);
console
.
info
(
'
usb SUB_USB_JS_0480: PASS
'
);
})
})
/**
/**
* @tc.number : SUB_USB_JS_0710
* @tc.number : SUB_USB_JS_0710
* @tc.name : hasRigt
* @tc.name : hasRig
h
t
* @tc.desc : 权限查询 连接设备 关闭设备
* @tc.desc : 权限查询 连接设备 关闭设备
*/
*/
it
(
'
SUB_USB_JS_0710
'
,
0
,
function
()
{
it
(
'
SUB_USB_JS_0710
'
,
0
,
function
()
{
...
@@ -113,7 +112,6 @@ describe('UsbCoreJsFunctionsTest', function () {
...
@@ -113,7 +112,6 @@ describe('UsbCoreJsFunctionsTest', function () {
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
})
})
/**
/**
* @tc.number : SUB_USB_JS_0680
* @tc.number : SUB_USB_JS_0680
* @tc.name : requestRight
* @tc.name : requestRight
...
@@ -145,6 +143,38 @@ describe('UsbCoreJsFunctionsTest', function () {
...
@@ -145,6 +143,38 @@ describe('UsbCoreJsFunctionsTest', function () {
}
}
})
})
/**
* @tc.number : SUB_USB_JS_1080
* @tc.name : removeRight
* @tc.desc : 移除权限
*/
it
(
'
SUB_USB_JS_1080
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1080 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb case get_device_list is null
'
)
expect
(
false
).
assertTrue
();
return
}
var
isRight
=
usb
.
hasRight
(
gDeviceList
[
0
].
name
);
if
(
!
isRight
)
{
usb
.
requestRight
(
gDeviceList
[
0
].
name
).
then
(
hasRight
=>
{
console
.
info
(
'
usb 1080 requestRight hasRight:
'
+
hasRight
);
}).
catch
(
error
=>
{
console
.
info
(
'
usb 1080 requestRight error:
'
+
error
);
});
CheckEmptyUtils
.
sleep
(
5000
);
}
var
remRight
=
usb
.
removeRight
(
gDeviceList
[
0
].
name
);
console
.
info
(
'
usb remove_right ret :
'
+
remRight
);
expect
(
remRight
).
assertTrue
();
console
.
info
(
'
usb SUB_USB_JS_1080 : PASS
'
);
})
/**
/**
* @tc.number : SUB_USB_JS_0090
* @tc.number : SUB_USB_JS_0090
* @tc.name : connectDevice
* @tc.name : connectDevice
...
@@ -165,9 +195,9 @@ describe('UsbCoreJsFunctionsTest', function () {
...
@@ -165,9 +195,9 @@ describe('UsbCoreJsFunctionsTest', function () {
var
isRight
=
usb
.
hasRight
(
gDeviceList
[
0
].
name
);
var
isRight
=
usb
.
hasRight
(
gDeviceList
[
0
].
name
);
if
(
!
isRight
)
{
if
(
!
isRight
)
{
usb
.
requestRight
(
gDeviceList
[
0
].
name
).
then
(
hasRight
=>
{
usb
.
requestRight
(
gDeviceList
[
0
].
name
).
then
(
hasRight
=>
{
console
.
info
(
'
usb 0090 requestRight hasRight:
'
+
hasRight
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
info
(
'
usb 0
1
requestRight error:
'
+
error
);
console
.
info
(
'
usb 0
090
requestRight error:
'
+
error
);
});
});
CheckEmptyUtils
.
sleep
(
5000
)
CheckEmptyUtils
.
sleep
(
5000
)
}
}
...
@@ -426,5 +456,33 @@ describe('UsbCoreJsFunctionsTest', function () {
...
@@ -426,5 +456,33 @@ describe('UsbCoreJsFunctionsTest', function () {
console
.
info
(
'
usb SUB_USB_JS_0520 : PASS
'
);
console
.
info
(
'
usb SUB_USB_JS_0520 : PASS
'
);
})
})
/**
* @tc.number : SUB_USB_JS_1070
* @tc.name : getFileDescriptor
* @tc.desc : 反向测试 关闭设备 传入错误参数
*/
it
(
'
SUB_USB_JS_1070
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1070 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb case get_device_list is null
'
)
expect
(
false
).
assertTrue
();
return
}
gPipe
=
usb
.
connectDevice
(
gDeviceList
[
0
])
try
{
var
maskCode
=
usb
.
getFileDescriptor
(
"
invalid
"
);
console
.
info
(
'
usb case getFileDescriptor return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1070 : PASS
'
);
}
})
})
})
}
}
usb/usb_standard/src/main/js/test/UsbCoreJsunitEx.test.js
浏览文件 @
4d9bb4fd
...
@@ -24,6 +24,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
...
@@ -24,6 +24,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
var
gDeviceList
var
gDeviceList
var
portCurrentMode
var
portCurrentMode
var
invalidCode
=
0
;
beforeAll
(
function
()
{
beforeAll
(
function
()
{
console
.
log
(
'
*************Usb Unit UsbCoreJsFunctionsTestEx Begin*************
'
);
console
.
log
(
'
*************Usb Unit UsbCoreJsFunctionsTestEx Begin*************
'
);
...
@@ -574,6 +575,43 @@ describe('UsbCoreJsFunctionsTestEx', function () {
...
@@ -574,6 +575,43 @@ describe('UsbCoreJsFunctionsTestEx', function () {
console
.
info
(
'
usb SUB_USB_JS_0210 : PASS
'
);
console
.
info
(
'
usb SUB_USB_JS_0210 : PASS
'
);
})
})
/**
* @tc.number : SUB_USB_JS_1040
* @tc.name : connectDevice
* @tc.desc : 反向测试 请求权限 参数类型错误
*/
it
(
'
SUB_USB_JS_1040
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1040 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb case get_device_list is null
'
)
expect
(
false
).
assertTrue
();
return
}
var
isRight
=
usb
.
hasRight
(
gDeviceList
[
0
].
name
);
if
(
!
isRight
)
{
usb
.
requestRight
(
gDeviceList
[
0
].
name
).
then
(
hasRight
=>
{
console
.
info
(
'
usb 1040 requestRight hasRight:
'
+
hasRight
);
}).
catch
(
error
=>
{
console
.
info
(
'
usb 1040 requestRight error:
'
+
error
);
});
CheckEmptyUtils
.
sleep
(
5000
)
}
try
{
var
maskCode
=
usb
.
connectDevice
(
"
invalid
"
);
console
.
info
(
'
usb case connectDevice return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1040 : PASS
'
);
}
})
/**
/**
* @tc.number : SUB_USB_JS_0720
* @tc.number : SUB_USB_JS_0720
* @tc.name : hasRight
* @tc.name : hasRight
...
@@ -634,6 +672,34 @@ describe('UsbCoreJsFunctionsTestEx', function () {
...
@@ -634,6 +672,34 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
})
})
/**
* @tc.number : SUB_USB_JS_1020
* @tc.name : hasRight
* @tc.desc : 反向测试 权限查询 参数类型错误
*/
it
(
'
SUB_USB_JS_1020
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1020 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb case get_device_list is null
'
)
expect
(
false
).
assertTrue
();
return
}
try
{
var
maskCode
=
usb
.
hasRight
(
invalidCode
);
console
.
info
(
'
usb case hasRight return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1020 : PASS
'
);
}
})
/**
/**
* @tc.number : SUB_USB_JS_0690
* @tc.number : SUB_USB_JS_0690
* @tc.name : requestRight
* @tc.name : requestRight
...
@@ -699,5 +765,142 @@ describe('UsbCoreJsFunctionsTestEx', function () {
...
@@ -699,5 +765,142 @@ describe('UsbCoreJsFunctionsTestEx', function () {
CheckEmptyUtils
.
sleep
(
5000
);
CheckEmptyUtils
.
sleep
(
5000
);
}
}
})
})
/**
* @tc.number : SUB_USB_JS_1030
* @tc.name : requestRight
* @tc.desc : 反向测试 请求权限 参数类型错误
*/
it
(
'
SUB_USB_JS_1030
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1030 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb case get_device_list is null
'
)
expect
(
false
).
assertTrue
();
return
}
try
{
var
maskCode
=
usb
.
requestRight
(
invalidCode
);
console
.
info
(
'
usb case requestRight return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1030 : PASS
'
);
}
CheckEmptyUtils
.
sleep
(
5000
);
})
/**
* @tc.number : SUB_USB_JS_1010
* @tc.name : getDevices
* @tc.desc : 反向测试 获取设备列表 参数类型错误
*/
it
(
'
SUB_USB_JS_1010
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1010 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
try
{
var
maskCode
=
usb
.
getDevices
(
"
invalid
"
);
console
.
info
(
'
usb case getDevices return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1010 : PASS
'
);
}
})
/**
* @tc.number : SUB_USB_JS_1050
* @tc.name : closePipe
* @tc.desc : 反向测试 关闭设备 参数类型错误
*/
it
(
'
SUB_USB_JS_1050
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1050 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb case get_device_list is null
'
)
expect
(
false
).
assertTrue
();
return
}
try
{
var
maskCode
=
usb
.
closePipe
(
"
invalid
"
);
console
.
info
(
'
usb case closePipe return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1050 : PASS
'
);
}
})
/**
* @tc.number : SUB_USB_JS_1060
* @tc.name : getRawDescriptor
* @tc.desc : 反向测试 关闭设备 参数类型错误
*/
it
(
'
SUB_USB_JS_1060
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1060 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb case get_device_list is null
'
)
expect
(
false
).
assertTrue
();
return
}
try
{
var
maskCode
=
usb
.
getRawDescriptor
(
"
invalid
"
);
console
.
info
(
'
usb case getRawDescriptor return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1060 : PASS
'
);
}
})
/**
* @tc.number : SUB_USB_JS_1090
* @tc.name : removeRight
* @tc.desc : 反向测试 移除权限 参数类型错误
*/
it
(
'
SUB_USB_JS_1090
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1090 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb case get_device_list is null
'
)
expect
(
false
).
assertTrue
();
return
}
try
{
var
maskCode
=
usb
.
removeRight
(
invalidCode
);
console
.
info
(
'
usb case removeRight return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1090 : PASS
'
);
}
CheckEmptyUtils
.
sleep
(
5000
);
})
})
})
}
}
usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js
浏览文件 @
4d9bb4fd
...
@@ -230,13 +230,13 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
...
@@ -230,13 +230,13 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
return
return
}
}
if
(
gDeviceList
.
length
==
0
)
{
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb 0
1
case get_device_list is null
'
)
console
.
info
(
'
usb 0
420
case get_device_list is null
'
)
expect
(
gDeviceList
.
length
).
assertEqual
(
-
1
);
expect
(
gDeviceList
.
length
).
assertEqual
(
-
1
);
return
return
}
}
if
(
gDeviceList
[
0
].
configs
.
length
==
0
)
{
if
(
gDeviceList
[
0
].
configs
.
length
==
0
)
{
console
.
info
(
'
usb 0
1
case current device.configs.length = 0
'
);
console
.
info
(
'
usb 0
420
case current device.configs.length = 0
'
);
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
return
return
}
}
...
@@ -591,48 +591,75 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
...
@@ -591,48 +591,75 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
* @tc.name : controlTransfer
* @tc.name : controlTransfer
* @tc.desc : 控制传输 ClearFeature: cmd 255 target 3 reqType 67 value 512 index 0
* @tc.desc : 控制传输 ClearFeature: cmd 255 target 3 reqType 67 value 512 index 0
*/
*/
it
(
'
SUB_USB_JS_0610
'
,
0
,
function
()
{
it
(
'
SUB_USB_JS_0610
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_0610 begin
'
);
console
.
info
(
'
usb SUB_USB_JS_0610 begin
'
);
if
(
portCurrentMode
==
1
)
{
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
expect
(
false
).
assertFalse
();
return
return
}
}
var
testParam
=
getTransferTestParam
()
var
testParam
=
getTransferTestParam
()
if
(
testParam
.
inEndpoint
==
null
||
testParam
.
interface
==
null
||
testParam
.
outEndpoint
==
null
)
{
if
(
testParam
.
inEndpoint
==
null
||
testParam
.
interface
==
null
||
testParam
.
outEndpoint
==
null
)
{
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
return
return
}
}
var
timeout
=
5000
;
var
timeout
=
5000
;
var
controlParam
=
getTransferParam
(
255
,
usb
.
USB_REQUEST_TARGET_OTHER
,
(
usb
.
USB_REQUEST_DIR_TO_DEVICE
<<
7
)
var
controlParam
=
getTransferParam
(
255
,
usb
.
USB_REQUEST_TARGET_OTHER
,
(
usb
.
USB_REQUEST_DIR_TO_DEVICE
<<
7
)
|
(
usb
.
USB_REQUEST_TYPE_VENDOR
<<
5
)
|
(
usb
.
USB_REQUEST_TARGET_OTHER
&
0x1f
),
(
2
<<
8
),
0
)
|
(
usb
.
USB_REQUEST_TYPE_VENDOR
<<
5
)
|
(
usb
.
USB_REQUEST_TARGET_OTHER
&
0x1f
),
(
2
<<
8
),
0
)
callControlTransfer
(
testParam
.
pip
,
controlParam
,
timeout
,
'
SUB_USB_JS_0610 ClearFeature
'
)
callControlTransfer
(
testParam
.
pip
,
controlParam
,
timeout
,
'
SUB_USB_JS_0610 ClearFeature
'
)
})
})
/**
/**
* @tc.number : SUB_USB_JS_0620
* @tc.number : SUB_USB_JS_0620
* @tc.name : controlTransfer
* @tc.name : controlTransfer
* @tc.desc : 控制传输 ClearFeature: cmd 255 target 3 reqType 35 value 0 index 0
* @tc.desc : 控制传输 ClearFeature: cmd 255 target 3 reqType 35 value 0 index 0
*/
*/
it
(
'
SUB_USB_JS_0620
'
,
0
,
function
()
{
it
(
'
SUB_USB_JS_0620
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_0620 begin
'
);
console
.
info
(
'
usb SUB_USB_JS_0620 begin
'
);
if
(
portCurrentMode
==
1
)
{
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
expect
(
false
).
assertFalse
();
return
return
}
}
var
testParam
=
getTransferTestParam
()
var
testParam
=
getTransferTestParam
()
if
(
testParam
.
inEndpoint
==
null
||
testParam
.
interface
==
null
||
testParam
.
outEndpoint
==
null
)
{
if
(
testParam
.
inEndpoint
==
null
||
testParam
.
interface
==
null
||
testParam
.
outEndpoint
==
null
)
{
expect
(
false
).
assertTrue
();
expect
(
false
).
assertTrue
();
return
return
}
}
var
timeout
=
5000
;
var
timeout
=
5000
;
var
controlParam
=
getTransferParam
(
255
,
usb
.
USB_REQUEST_TARGET_OTHER
,
(
usb
.
USB_REQUEST_DIR_TO_DEVICE
<<
7
)
var
controlParam
=
getTransferParam
(
255
,
usb
.
USB_REQUEST_TARGET_OTHER
,
(
usb
.
USB_REQUEST_DIR_TO_DEVICE
<<
7
)
|
(
usb
.
USB_REQUEST_TYPE_CLASS
<<
5
)
|
(
usb
.
USB_REQUEST_TARGET_OTHER
&
0x1f
),
0
,
0
)
|
(
usb
.
USB_REQUEST_TYPE_CLASS
<<
5
)
|
(
usb
.
USB_REQUEST_TARGET_OTHER
&
0x1f
),
0
,
0
)
callControlTransfer
(
testParam
.
pip
,
controlParam
,
timeout
,
'
SUB_USB_JS_0620 ClearFeature
'
)
callControlTransfer
(
testParam
.
pip
,
controlParam
,
timeout
,
'
SUB_USB_JS_0620 ClearFeature
'
)
})
})
/**
* @tc.number : SUB_USB_JS_1140
* @tc.name : controlTransfer
* @tc.desc : 反向测试 控制传输 参数类型错误
*/
it
(
'
SUB_USB_JS_1140
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1140 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
var
testParam
=
getTransferTestParam
()
if
(
testParam
.
inEndpoint
==
null
||
testParam
.
interface
==
null
||
testParam
.
outEndpoint
==
null
)
{
expect
(
false
).
assertTrue
();
return
}
try
{
var
maskCode
=
usb
.
controlTransfer
(
"
invalid
"
);
console
.
info
(
'
usb case controlTransfer return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1140 : PASS
'
);
}
})
})
})
}
}
usb/usb_standard/src/main/js/test/UsbDevicePipeJsunitEx.test.js
浏览文件 @
4d9bb4fd
...
@@ -251,6 +251,34 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
...
@@ -251,6 +251,34 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
CheckEmptyUtils
.
sleep
(
3000
);
CheckEmptyUtils
.
sleep
(
3000
);
})
})
/**
* @tc.number : SUB_USB_JS_1100
* @tc.name : bulkTransfer
* @tc.desc : 反向测试 批量传输 参数类型错误
*/
it
(
'
SUB_USB_JS_1100
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1100 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb case get_device_list is null
'
)
expect
(
false
).
assertTrue
();
return
}
try
{
var
maskCode
=
usb
.
bulkTransfer
(
"
invalid
"
);
console
.
info
(
'
usb case bulkTransfer return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1100 : PASS
'
);
}
})
/**
/**
* @tc.number : SUB_USB_JS_0430
* @tc.number : SUB_USB_JS_0430
* @tc.name : claimInterface
* @tc.name : claimInterface
...
@@ -456,6 +484,39 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
...
@@ -456,6 +484,39 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
})
})
/**
* @tc.number : SUB_USB_JS_1110
* @tc.name : claimInterface
* @tc.desc : 反向测试 获取接口 参数类型错误
*/
it
(
'
SUB_USB_JS_1110
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1110 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb case get_device_list is null
'
)
expect
(
false
).
assertTrue
();
return
}
if
(
gDeviceList
[
0
].
configs
.
length
==
0
)
{
console
.
info
(
'
usb 1110 case current device.configs.length = 0
'
);
expect
(
false
).
assertTrue
();
return
}
try
{
var
maskCode
=
usb
.
claimInterface
(
"
invalid
"
);
console
.
info
(
'
usb case claimInterface return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1110 : PASS
'
);
}
})
/**
/**
* @tc.number : SUB_USB_JS_0280
* @tc.number : SUB_USB_JS_0280
* @tc.name : releaseInterface
* @tc.name : releaseInterface
...
@@ -661,6 +722,40 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
...
@@ -661,6 +722,40 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
})
})
/**
* @tc.number : SUB_USB_JS_1150
* @tc.name : releaseInterface
* @tc.desc : 反向测试 释放接口 参数类型错误
*/
it
(
'
SUB_USB_JS_1150
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1150 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb case get_device_list is null
'
)
expect
(
false
).
assertTrue
();
return
}
if
(
gDeviceList
[
0
].
configs
.
length
==
0
)
{
console
.
info
(
'
usb 1110 case current device.configs.length = 0
'
);
expect
(
false
).
assertTrue
();
return
}
gPipe
=
usb
.
connectDevice
(
gDeviceList
[
0
])
try
{
var
maskCode
=
usb
.
releaseInterface
(
"
invalid
"
);
console
.
info
(
'
usb case releaseInterface return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1150 : PASS
'
);
}
})
/**
/**
* @tc.number : SUB_USB_JS_0820
* @tc.number : SUB_USB_JS_0820
* @tc.name : setInterface
* @tc.name : setInterface
...
@@ -791,6 +886,34 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
...
@@ -791,6 +886,34 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
})
})
/**
* @tc.number : SUB_USB_JS_1130
* @tc.name : setInterface
* @tc.desc : 反向测试 设置设备接口 参数类型错误
*/
it
(
'
SUB_USB_JS_1130
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1130 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb case get_device_list is null
'
)
expect
(
false
).
assertTrue
();
return
}
try
{
var
maskCode
=
usb
.
setInterface
(
"
invalid
"
);
console
.
info
(
'
usb case setInterface return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1130 : PASS
'
);
}
})
/**
/**
* @tc.number : SUB_USB_JS_0760
* @tc.number : SUB_USB_JS_0760
* @tc.name : setConfiguration
* @tc.name : setConfiguration
...
@@ -909,5 +1032,32 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
...
@@ -909,5 +1032,32 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
console
.
info
(
'
usb SUB_USB_JS_0790 : PASS
'
);
console
.
info
(
'
usb SUB_USB_JS_0790 : PASS
'
);
})
})
/**
* @tc.number : SUB_USB_JS_1120
* @tc.name : setConfiguration
* @tc.desc : 反向测试 设置设备接口 参数类型错误
*/
it
(
'
SUB_USB_JS_1120
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1120 begin
'
);
if
(
portCurrentMode
==
1
)
{
console
.
info
(
'
usb case get_device port is device
'
)
expect
(
false
).
assertFalse
();
return
}
if
(
gDeviceList
.
length
==
0
)
{
console
.
info
(
'
usb case get_device_list is null
'
)
expect
(
false
).
assertTrue
();
return
}
try
{
var
maskCode
=
usb
.
setConfiguration
(
"
invalid
"
);
console
.
info
(
'
usb case setConfiguration return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1120 : PASS
'
);
}
})
})
})
}
}
usb/usb_standard/src/main/js/test/UsbFunctionsJsunit.test.js
浏览文件 @
4d9bb4fd
...
@@ -100,13 +100,14 @@ describe('UsbFunctionsJsFunctionsTest', function () {
...
@@ -100,13 +100,14 @@ describe('UsbFunctionsJsFunctionsTest', function () {
/**
/**
* @tc.number : SUB_USB_JS_1000
* @tc.number : SUB_USB_JS_1000
* @tc.name : getCurrentFunctions
* @tc.name : getCurrentFunctions
* @tc.desc : 反向测试 获取当前设备模式
* @tc.desc : 反向测试 获取当前设备模式
入参错误(无参接口传参)
*/
*/
it
(
'
SUB_USB_JS_1000
'
,
0
,
function
()
{
it
(
'
SUB_USB_JS_1000
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1000 begin
'
);
console
.
info
(
'
usb SUB_USB_JS_1000 begin
'
);
try
{
try
{
var
maskCode
=
usb
.
getCurrentFunctions
(
"
invalid
"
);
var
maskCode
=
usb
.
getCurrentFunctions
(
"
invalid
"
);
console
.
info
(
'
usb case getCurrentFunctions return:
'
+
maskCode
);
console
.
info
(
'
usb case getCurrentFunctions return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
expect
(
err
.
code
).
assertEqual
(
401
);
...
...
usb/usb_standard/src/main/js/test/UsbFunctionsJsunitEx.test.js
浏览文件 @
4d9bb4fd
...
@@ -20,6 +20,8 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
...
@@ -20,6 +20,8 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
export
default
function
UsbFunctionsJsFunctionsTestEx
()
{
export
default
function
UsbFunctionsJsFunctionsTestEx
()
{
describe
(
'
UsbFunctionsJsFunctionsTestEx
'
,
function
()
{
describe
(
'
UsbFunctionsJsFunctionsTestEx
'
,
function
()
{
var
invalidCode
=
0
;
beforeAll
(
function
()
{
beforeAll
(
function
()
{
console
.
log
(
'
*************Usb Unit UsbFunctionsJsFunctionsTestEx Begin*************
'
);
console
.
log
(
'
*************Usb Unit UsbFunctionsJsFunctionsTestEx Begin*************
'
);
var
Version
=
usb
.
getVersion
()
var
Version
=
usb
.
getVersion
()
...
@@ -155,6 +157,24 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
...
@@ -155,6 +157,24 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
console
.
info
(
'
usb SUB_USB_JS_0990 : PASS
'
);
console
.
info
(
'
usb SUB_USB_JS_0990 : PASS
'
);
})
})
/**
* @tc.number : SUB_USB_JS_1160
* @tc.name : usbFunctionsToString
* @tc.desc : 反向测试 掩码转化成描述字符 参数类型错误
*/
it
(
'
SUB_USB_JS_1160
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1160 begin
'
);
try
{
var
maskCode
=
usb
.
usbFunctionsToString
(
"
invalid
"
);
console
.
info
(
'
usb case usbFunctionsToString return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1160 : PASS
'
);
}
})
/**
/**
* @tc.number : SUB_USB_JS_0860
* @tc.number : SUB_USB_JS_0860
* @tc.name : usbFunctionsFromString
* @tc.name : usbFunctionsFromString
...
@@ -253,5 +273,22 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
...
@@ -253,5 +273,22 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
console
.
info
(
'
usb SUB_USB_JS_0920 : PASS
'
);
console
.
info
(
'
usb SUB_USB_JS_0920 : PASS
'
);
})
})
/**
* @tc.number : SUB_USB_JS_1170
* @tc.name : usbFunctionsFromString
* @tc.desc : 反向测试 描述字符转换成掩码 参数类型错误
*/
it
(
'
SUB_USB_JS_1170
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1170 begin
'
);
try
{
var
maskCode
=
usb
.
usbFunctionsFromString
(
invalidCode
);
console
.
info
(
'
usb case usbFunctionsFromString return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1170 : PASS
'
);
}
})
})
})
}
}
usb/usb_standard/src/main/js/test/UsbPortAndFunctionJsunit.test.js
浏览文件 @
4d9bb4fd
...
@@ -212,6 +212,5 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
...
@@ -212,6 +212,5 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
console
.
info
(
'
usb SUB_USB_JS_0020 host 1 1: PASS
'
);
console
.
info
(
'
usb SUB_USB_JS_0020 host 1 1: PASS
'
);
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
})
})
})
})
}
}
usb/usb_standard/src/main/js/test/UsbPortJsunitEx.test.js
浏览文件 @
4d9bb4fd
...
@@ -63,6 +63,24 @@ describe('UsbPortJsFunctionsTestEx', function () {
...
@@ -63,6 +63,24 @@ describe('UsbPortJsFunctionsTestEx', function () {
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
})
})
/**
* @tc.number : SUB_USB_JS_1210
* @tc.name : getSupportedModes
* @tc.desc : 反向测试 获取指定的端口支持的模式列表的组合掩码 参数类型错误
*/
it
(
'
SUB_USB_JS_1210
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1210 begin
'
);
try
{
var
maskCode
=
usb
.
getSupportedModes
(
"
invalid
"
);
console
.
info
(
'
usb case getSupportedModes return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1210 : PASS
'
);
}
})
/**
/**
* @tc.number : SUB_USB_JS_0030
* @tc.number : SUB_USB_JS_0030
* @tc.name : setPortRoles
* @tc.name : setPortRoles
...
@@ -196,5 +214,58 @@ describe('UsbPortJsFunctionsTestEx', function () {
...
@@ -196,5 +214,58 @@ describe('UsbPortJsFunctionsTestEx', function () {
expect
(
true
).
assertTrue
();
expect
(
true
).
assertTrue
();
})
})
/**
* @tc.number : SUB_USB_JS_1190
* @tc.name : setPortRoles
* @tc.desc : 反向测试 port功能切换 参数个数错误
*/
it
(
'
SUB_USB_JS_1190
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1190 begin
'
);
try
{
var
maskCode
=
usb
.
setPortRoles
(
"
invalid
"
);
console
.
info
(
'
usb case setPortRoles return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1190 : PASS
'
);
}
})
/**
* @tc.number : SUB_USB_JS_1200
* @tc.name : getPorts
* @tc.desc : 反向测试 port功能切换 入参错误(无参接口传参)
*/
it
(
'
SUB_USB_JS_1200
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1200 begin
'
);
try
{
var
maskCode
=
usb
.
getPorts
(
"
invalid
"
);
console
.
info
(
'
usb case getPorts return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1200 : PASS
'
);
}
})
/**
* @tc.number : SUB_USB_JS_1180
* @tc.name : setCurrentFunctions
* @tc.desc : 反向测试 在设备模式下设置当前的USB功能列表 参数类型错误
*/
it
(
'
SUB_USB_JS_1180
'
,
0
,
function
()
{
console
.
info
(
'
usb SUB_USB_JS_1180 begin
'
);
try
{
var
maskCode
=
usb
.
setCurrentFunctions
(
"
invalid
"
);
console
.
info
(
'
usb case setCurrentFunctions return:
'
+
maskCode
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
catch err code:
'
+
err
.
code
+
'
message:
'
+
err
.
message
);
expect
(
err
.
code
).
assertEqual
(
401
);
console
.
info
(
'
usb SUB_USB_JS_1180 : PASS
'
);
}
})
})
})
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录