提交 332c7fce 编写于 作者: J jiyong_sd

modified fa-js

Signed-off-by: Njiyong_sd <jiyong@huawei.com>
Change-Id: I96e463a1d8ebc7ed7d38b996987b1b541c9b8320
上级 136d4c6c
文件模式从 100755 更改为 100644
......@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
......@@ -23,7 +23,9 @@ ohos_js_hap_suite("usb_js_test") {
hap_name = "ActsUsbJSApiTest"
}
ohos_js_assets("usb_js_assets") {
source_dir = "./src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("usb_js_resources") {
sources = [ "./src/main/resources" ]
......
{
"description": "Configuration for usb js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "160000",
"package": "ohos.acts.usb.usb.function",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsUsbJSApiTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"description": "Configuration for usb js api Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "160000",
"shell-timeout": "160000",
"bundle-name": "ohos.acts.usb.usb.function",
"package-name": "ohos.acts.usb.usb.function"
},
"kits": [
{
"test-file-name": [
"ActsUsbJSApiTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
文件模式从 100755 更改为 100644
{
"app": {
"bundleName": "ohos.acts.usb.usb.function",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.usb.usb.function",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.acts.usb.usb.function.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
{
"app": {
"bundleName": "ohos.acts.usb.usb.function",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.usb.usb.function",
"name": ".entry",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ No newline at end of file
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Core, ExpectExtend} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = 5000
configService.setConfig(this)
require('../../test/ListUsb.test')
core.execute()
},
onReady() {
},
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
},
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* host test case */
require('./UsbCoreJsunit.test.js')
require('./UsbCoreJsunitEx.test.js')
require('./UsbDevicePipeJsunit.test.js')
require('./UsbDevicePipeJsunitEx.test.js')
/* device test case */
require('./UsbFunctionsJsunit.test.js')
require('./UsbFunctionsJsunitEx.test.js')
/* device and host test case */
require('./UsbPortJsunit.test.js')
require('./UsbPortJsunitEx.test.js')
// require('./UsbPortAndFunctionJsunit.test.js')
require('./UsbAutoJsunit.test.js')
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
/**
* Check obj is empty.
*
* @param {object} obj
* @return {boolean} true(empty)
*/
isEmpty(obj) {
return (typeof obj == 'undefined' || obj == null ||
JSON.stringify(obj) == '{}' || JSON.stringify(obj) == 'undefined');
},
/**
* Check str is empty.
*
* @param {string} str
* @return {boolean} true(empty)
*/
checkStrIsEmpty(str) {
return str.trim().length == 0;
},
/**
* Check array is empty.
*
* @param {Array}arr
* @return {boolean} true(empty)
*/
isEmptyArr(arr) {
return arr.length == 0;
},
// ArrayBuffer转为字符串,参数为ArrayBuffer对象
ab2str(buf) {
return String.fromCharCode.apply(null, new Uint8Array(buf));
},
// 字符串转为ArrayBuffer对象,参数为字符串
str2ab(str) {
var arr = [];
for (var i = 0, j = str.length; i < j; ++i) {
arr.push(str.charCodeAt(i));
}
var tmpUint8Array = new Uint8Array(arr);
return tmpUint8Array;
},
// 简单阻塞的粗暴实现
sleep(delay) {
for (var t = Date.now(); Date.now() - t <= delay;);
}
}
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
/**
* Check obj is empty.
*
* @param {object} obj
* @return {boolean} true(empty)
*/
isEmpty(obj) {
return (typeof obj == 'undefined' || obj == null ||
JSON.stringify(obj) == '{}' || JSON.stringify(obj) == 'undefined');
},
/**
* Check str is empty.
*
* @param {string} str
* @return {boolean} true(empty)
*/
checkStrIsEmpty(str) {
return str.trim().length == 0;
},
/**
* Check array is empty.
*
* @param {Array}arr
* @return {boolean} true(empty)
*/
isEmptyArr(arr) {
return arr.length == 0;
},
// ArrayBuffer转为字符串,参数为ArrayBuffer对象
ab2str(buf) {
return String.fromCharCode.apply(null, new Uint8Array(buf));
},
// 字符串转为ArrayBuffer对象,参数为字符串
str2ab(str) {
var arr = [];
for (var i = 0, j = str.length; i < j; ++i) {
arr.push(str.charCodeAt(i));
}
var tmpUint8Array = new Uint8Array(arr);
return tmpUint8Array;
},
// 简单阻塞的粗暴实现
sleep(delay) {
for (var t = Date.now(); Date.now() - t <= delay;);
}
}
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const twelve = 12;
/*
* date package tool class
*/
export default class DateAndTimeUtil {
constructor() {
}
/**
*
* Get the current time
*/
now() {
const datetime = new Date();
const hours = datetime.getHours();
const minutes = datetime.getMinutes();
return this.concatTime(hours, minutes);
}
/**
*
* Get the current time
*/
nowWithSeconds() {
const datetime = new Date();
const hours = datetime.getHours();
const minutes = datetime.getMinutes();
const seconds = datetime.getMilliseconds()
console.info('now: ' + hours + ':' + minutes + ':' + seconds)
var now = this.concatTimeWithSeconds(hours, minutes, seconds);
console.info('now concat: ' + now);
return now;
}
/**
* format
* @param value
* @return
*/
fill(value) {
return (value > 9 ? '' : '0') + value;
}
/**
* concat date
* @param year m d
* @return
*/
concatDate(year, month, date) {
return year + this.year + month + this.month + date + this.day;
}
concatTime(hours, minutes) {
return `${this.fill(hours)}:${this.fill(minutes)}`;
}
concatTimeWithSeconds(hours, minutes, milliseconds) {
return `${this.fill(hours)}:${this.fill(minutes)}:${this.fill(milliseconds)}`;
}
/**
* Turn to 24-hour clock
* @param str
* @return
*/
transform24(str) {
const timeFlag = str.substr(0, 2);
if (timeFlag == this.morning) {
const h = str.substr(2).split(':')[0];
if (h == twelve) {
const time = '0' + ':' + str.substr(2).split(':')[1];
return time;
} else {
return h + ':' + str.substr(2).split(':')[1];
}
} else {
const h = str.substr(2).split(':')[0];
const h1 = parseInt(h) + twelve;
if (h != twelve) {
const time = h1 + ':' + str.substr(2).split(':')[1];
return time;
}
}
}
/**
* Turn to 12-hour clock
* @param str
* @return
*/
transform12(str) {
const hours = str.substring(0, str.indexOf(':'));
const minutes = str.split(':')[1];
if (hours < twelve) {
return this.morning.concat(`${hours}:${minutes}`);
}
if (hours == twelve) {
return this.afternoon.concat(`${hours}:${minutes}`);
} else {
const reduceHours = parseInt(hours) - twelve;
return this.afternoon.concat(`${reduceHours}:${minutes}`);
}
}
}
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const twelve = 12;
/*
* date package tool class
*/
export default class DateAndTimeUtil {
constructor() {
}
/**
*
* Get the current time
*/
now() {
const datetime = new Date();
const hours = datetime.getHours();
const minutes = datetime.getMinutes();
return this.concatTime(hours, minutes);
}
/**
*
* Get the current time
*/
nowWithSeconds() {
const datetime = new Date();
const hours = datetime.getHours();
const minutes = datetime.getMinutes();
const seconds = datetime.getMilliseconds()
console.info('now: ' + hours + ':' + minutes + ':' + seconds)
var now = this.concatTimeWithSeconds(hours, minutes, seconds);
console.info('now concat: ' + now);
return now;
}
/**
* format
* @param value
* @return
*/
fill(value) {
return (value > 9 ? '' : '0') + value;
}
/**
* concat date
* @param year m d
* @return
*/
concatDate(year, month, date) {
return year + this.year + month + this.month + date + this.day;
}
concatTime(hours, minutes) {
return `${this.fill(hours)}:${this.fill(minutes)}`;
}
concatTimeWithSeconds(hours, minutes, milliseconds) {
return `${this.fill(hours)}:${this.fill(minutes)}:${this.fill(milliseconds)}`;
}
/**
* Turn to 24-hour clock
* @param str
* @return
*/
transform24(str) {
const timeFlag = str.substr(0, 2);
if (timeFlag == this.morning) {
const h = str.substr(2).split(':')[0];
if (h == twelve) {
const time = '0' + ':' + str.substr(2).split(':')[1];
return time;
} else {
return h + ':' + str.substr(2).split(':')[1];
}
} else {
const h = str.substr(2).split(':')[0];
const h1 = parseInt(h) + twelve;
if (h != twelve) {
const time = h1 + ':' + str.substr(2).split(':')[1];
return time;
}
}
}
/**
* Turn to 12-hour clock
* @param str
* @return
*/
transform12(str) {
const hours = str.substring(0, str.indexOf(':'));
const minutes = str.split(':')[1];
if (hours < twelve) {
return this.morning.concat(`${hours}:${minutes}`);
}
if (hours == twelve) {
return this.afternoon.concat(`${hours}:${minutes}`);
} else {
const reduceHours = parseInt(hours) - twelve;
return this.afternoon.concat(`${reduceHours}:${minutes}`);
}
}
}
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Constants of events that will be registered to system.
*/
const EventConstants = {
/**
* Bitmask used for extracting the USBEndpoint type from it's address
*/
USB_ENDPOINT_XFERTYPE_MASK: 0x03,
/**
* Control USBEndpoint type
*/
USB_ENDPOINT_XFER_CONTROL: 0,
/**
* Isochronous USBEndpoint type
*/
USB_ENDPOINT_XFER_ISOC: 1,
/**
* Bulk USBEndpoint type
*/
USB_ENDPOINT_XFER_BULK: 2,
/**
* Interrupt USBEndpoint type
*/
USB_ENDPOINT_XFER_INT: 3,
/**
* Bitmask used for extracting the USBEndpoint number from it's address
*/
USB_ENDPOINT_NUMBER_MASK: 0x0f,
/**
* Bitmask used for extracting the USBEndpoint direction from it's address
*/
USB_ENDPOINT_DIR_MASK: 0x80,
/**
* Used to signify direction of data for USBEndpoint is OUT, host to device
*/
USB_ENDPOINT_DIR_OUT: 0,
/**
* Used to signify direction of data for USBEndpoint is IN, device to host
*/
USB_ENDPOINT_DIR_IN: 0x80
}
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Constants of events that will be registered to system.
*/
const EventConstants = {
/**
* Bitmask used for extracting the USBEndpoint type from it's address
*/
USB_ENDPOINT_XFERTYPE_MASK: 0x03,
/**
* Control USBEndpoint type
*/
USB_ENDPOINT_XFER_CONTROL: 0,
/**
* Isochronous USBEndpoint type
*/
USB_ENDPOINT_XFER_ISOC: 1,
/**
* Bulk USBEndpoint type
*/
USB_ENDPOINT_XFER_BULK: 2,
/**
* Interrupt USBEndpoint type
*/
USB_ENDPOINT_XFER_INT: 3,
/**
* Bitmask used for extracting the USBEndpoint number from it's address
*/
USB_ENDPOINT_NUMBER_MASK: 0x0f,
/**
* Bitmask used for extracting the USBEndpoint direction from it's address
*/
USB_ENDPOINT_DIR_MASK: 0x80,
/**
* Used to signify direction of data for USBEndpoint is OUT, host to device
*/
USB_ENDPOINT_DIR_OUT: 0,
/**
* Used to signify direction of data for USBEndpoint is IN, device to host
*/
USB_ENDPOINT_DIR_IN: 0x80
}
export default EventConstants;
\ No newline at end of file
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import UsbAutoJsunit from './UsbAutoJsunit.test.js'
import UsbPortAndFunctionsJsFunctionsTest from './UsbPortAndFunctionJsunit.test.js'
import UsbPortJsFunctionsTest from './UsbPortJsunit.test.js'
import UsbPortJsFunctionsTestEx from './UsbPortJsunitEx.test.js'
import UsbFunctionsJsFunctionsTestEx from './UsbFunctionsJsunitEx.test.js'
import UsbFunctionsJsFunctionsTest from './UsbFunctionsJsunit.test.js'
import UsbDevicePipeJsFunctionsTest from './UsbDevicePipeJsunit.test.js'
import UsbDevicePipeJsFunctionsTestEx from './UsbDevicePipeJsunitEx.test.js'
import UsbCoreJsFunctionsTest from './UsbCoreJsunit.test.js'
import UsbCoreJsFunctionsTestEx from './UsbCoreJsunitEx.test.js'
/* host test case */
export default function testsuite() {
UsbAutoJsunit()
UsbCoreJsFunctionsTest()
UsbCoreJsFunctionsTestEx()
UsbDevicePipeJsFunctionsTest()
UsbDevicePipeJsFunctionsTestEx()
UsbFunctionsJsFunctionsTest()
UsbFunctionsJsFunctionsTestEx()
//UsbPortAndFunctionsJsFunctionsTest()
UsbPortJsFunctionsTest()
UsbPortJsFunctionsTestEx()
}
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import usb from '@ohos.usb';
import CheckEmptyUtils from './CheckEmptyUtils.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
/* usb core functions test */
describe('UsbFunctionsJsFunctionsTest', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbFunctionsJsFunctionsTest Begin*************');
var Version = usb.getVersion()
console.info('begin test getversion :' + Version)
// version > 17 host currentMode = 2 device currentMode = 1
var usbPortList = usb.getPorts()
if (usbPortList.length > 0) {
if (usbPortList[0].status.currentMode == 2) {
usb.setPortRoles(usbPortList[0].id, usb.SINK, usb.DEVICE).then(data => {
console.info('usb case setPortRoles return: ' + data);
}).catch(error => {
console.info('usb case setPortRoles error : ' + error);
});
console.log('*************Usb Unit switch to device Begin*************');
}
}
})
beforeEach(function () {
console.info('beforeEach: *************Usb Unit Test Case*************');
})
afterEach(function () {
console.info('afterEach: *************Usb Unit Test Case*************');
})
afterAll(function () {
console.log('*************Usb Unit UsbFunctionsJsFunctionsTest End*************');
})
/**
* @tc.number : SUB_USB_JS_0330
* @tc.name : getCurrentFunctions
* @tc.desc : 获取当前设备模式 掩码与描述字符转换
*/
it('SUB_USB_JS_0330', 0, function () {
console.info('usb SUB_USB_JS_0330 begin');
var maskCode = usb.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
console.info('usb case usbFunctionsToString return str: ' + strMaskCode);
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(maskCode);
console.info('usb SUB_USB_JS_0330 : PASS');
expect(true).assertTrue();
})
/**
* @tc.number : SUB_USB_JS_0340
* @tc.name : usbFunctionString
* @tc.desc : 反向测试 获取当前设备模式 掩码与描述字符转换
*/
it('SUB_USB_JS_0340', 0, function () {
console.info('usb SUB_USB_JS_0340 begin');
var maskCode = usb.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
console.info('usb case usbFunctionsToString return str: ' + strMaskCode);
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode);
var errmaskCode = 0
var strMaskCode = usb.usbFunctionsToString(errmaskCode)
console.info('usb case ' + errmaskCode + ' usbFunctionsToString return str: ' + strMaskCode);
var errStrMaskCode = 'none'
var nMaskCode = usb.usbFunctionsFromString(errStrMaskCode)
expect(nMaskCode).assertEqual(usb.NONE);
console.info('usb case errStrMaskCode ' + errStrMaskCode +
' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0340 : PASS');
})
})
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import usb from '@ohos.usb';
import CheckEmptyUtils from './CheckEmptyUtils.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
/* usb core functions test */
export default function UsbFunctionsJsFunctionsTest() {
describe('UsbFunctionsJsFunctionsTest', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbFunctionsJsFunctionsTest Begin*************');
var Version = usb.getVersion()
console.info('begin test getversion :' + Version)
// version > 17 host currentMode = 2 device currentMode = 1
var usbPortList = usb.getPorts()
if (usbPortList.length > 0) {
if (usbPortList[0].status.currentMode == 2) {
usb.setPortRoles(usbPortList[0].id, usb.SINK, usb.DEVICE).then(data => {
console.info('usb case setPortRoles return: ' + data);
}).catch(error => {
console.info('usb case setPortRoles error : ' + error);
});
console.log('*************Usb Unit switch to device Begin*************');
}
}
})
beforeEach(function () {
console.info('beforeEach: *************Usb Unit Test Case*************');
})
afterEach(function () {
console.info('afterEach: *************Usb Unit Test Case*************');
})
afterAll(function () {
console.log('*************Usb Unit UsbFunctionsJsFunctionsTest End*************');
})
/**
* @tc.number : SUB_USB_JS_0330
* @tc.name : getCurrentFunctions
* @tc.desc : 获取当前设备模式 掩码与描述字符转换
*/
it('SUB_USB_JS_0330', 0, function () {
console.info('usb SUB_USB_JS_0330 begin');
var maskCode = usb.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
console.info('usb case usbFunctionsToString return str: ' + strMaskCode);
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(maskCode);
console.info('usb SUB_USB_JS_0330 : PASS');
expect(true).assertTrue();
})
/**
* @tc.number : SUB_USB_JS_0340
* @tc.name : usbFunctionString
* @tc.desc : 反向测试 获取当前设备模式 掩码与描述字符转换
*/
it('SUB_USB_JS_0340', 0, function () {
console.info('usb SUB_USB_JS_0340 begin');
var maskCode = usb.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
console.info('usb case usbFunctionsToString return str: ' + strMaskCode);
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode);
var errmaskCode = 0
var strMaskCode = usb.usbFunctionsToString(errmaskCode)
console.info('usb case ' + errmaskCode + ' usbFunctionsToString return str: ' + strMaskCode);
var errStrMaskCode = 'none'
var nMaskCode = usb.usbFunctionsFromString(errStrMaskCode)
expect(nMaskCode).assertEqual(usb.NONE);
console.info('usb case errStrMaskCode ' + errStrMaskCode +
' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0340 : PASS');
})
})
}
/*
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import usb from '@ohos.usb';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
/* usb core functions test */
describe('UsbFunctionsJsFunctionsTestEx', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbFunctionsJsFunctionsTestEx Begin*************');
var Version = usb.getVersion()
console.info('begin test getversion :' + Version)
// 17 version host currentMode = 2 device currentMode = 1
var usbPortList = usb.getPorts()
if (usbPortList.length > 0) {
if (usbPortList[0].status.currentMode == 2) {
usb.setPortRoles(usbPortList[0].id, usb.SINK, usb.DEVICE).then(data => {
console.info('usb case setPortRoles return: ' + data);
}).catch(error => {
console.info('usb case setPortRoles error : ' + error);
});
console.log('*************Usb Unit switch to device Begin*************');
}
}
})
beforeEach(function () {
console.info('beforeEach: *************Usb Unit Test Case*************');
})
afterEach(function () {
console.info('afterEach: *************Usb Unit Test Case*************');
})
afterAll(function () {
console.log('*************Usb Unit UsbFunctionsJsFunctionsTest End*************');
})
/**
* @tc.number : SUB_USB_JS_0930
* @tc.name : usbFunctionsToString
* @tc.desc : 正向测试 0 返回 'none'
*/
it('SUB_USB_JS_0930', 0, function () {
console.info('usb SUB_USB_JS_0930 begin');
var maskCode = usb.NONE
console.info('usb case maskCode : ' + usb.NONE);
var strMaskCode = usb.usbFunctionsToString(maskCode)
expect(strMaskCode).assertEqual('none');
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
console.info('usb SUB_USB_JS_0930 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0940
* @tc.name : usbFunctionsToString
* @tc.desc : 正向测试 1 返回 'acm'
*/
it('SUB_USB_JS_0940', 0, function () {
console.info('usb SUB_USB_JS_0940 begin');
var maskCode = usb.ACM
console.info('usb case maskCode : ' + usb.ACM);
var strMaskCode = usb.usbFunctionsToString(maskCode)
expect(strMaskCode).assertEqual('acm');
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
console.info('usb SUB_USB_JS_0940 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0950
* @tc.name : usbFunctionsToString
* @tc.desc : 正向测试 2 返回 'ecm'
*/
it('SUB_USB_JS_0950', 0, function () {
console.info('usb SUB_USB_JS_0950 begin');
var maskCode = usb.ECM
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
expect(strMaskCode).assertEqual('ecm');
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
console.info('usb SUB_USB_JS_0950 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0960
* @tc.name : usbFunctionsToString
* @tc.desc : 正向测试 3 返回 'acm,ecm'
*/
it('SUB_USB_JS_0960', 0, function () {
console.info('usb SUB_USB_JS_0960 begin');
var maskCode = usb.ACM | usb.ECM
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
expect(strMaskCode).assertEqual('acm,ecm');
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
console.info('usb SUB_USB_JS_0960 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0970
* @tc.name : usbFunctionsToString
* @tc.desc : 正向测试 4 返回 'hdc'
*/
it('SUB_USB_JS_0970', 0, function () {
console.info('usb SUB_USB_JS_0970 begin');
var maskCode = usb.HDC
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
expect(strMaskCode).assertEqual('hdc');
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
console.info('usb SUB_USB_JS_0970 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0980
* @tc.name : usbFunctionsToString
* @tc.desc : 正向测试 5 返回 'acm,hdc'
*/
it('SUB_USB_JS_0980', 0, function () {
console.info('usb SUB_USB_JS_0980 begin');
var maskCode = usb.ACM | usb.HDC
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
expect(strMaskCode).assertEqual('hdc,acm');
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
console.info('usb SUB_USB_JS_0980 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0990
* @tc.name : usbFunctionsToString
* @tc.desc : 正向测试 6 返回 'ecm,hdc'
*/
it('SUB_USB_JS_0990', 0, function () {
console.info('usb SUB_USB_JS_0990 begin');
var maskCode = usb.ECM | usb.HDC
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
expect(strMaskCode).assertEqual('hdc,ecm');
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
console.info('usb SUB_USB_JS_0990 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0860
* @tc.name : usbFunctionsFromString
* @tc.desc : 正向测试 'none' 返回 0
*/
it('SUB_USB_JS_0860', 0, function () {
console.info('usb SUB_USB_JS_0860 begin');
var strMaskCode = 'none'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(usb.NONE);
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0860 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0870
* @tc.name : usbFunctionsFromString
* @tc.desc : 正向测试 'acm' 返回 1
*/
it('SUB_USB_JS_0870', 0, function () {
console.info('usb SUB_USB_JS_0870 begin');
var strMaskCode = 'acm'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(usb.ACM);
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0870 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0880
* @tc.name : usbFunctionsFromString
* @tc.desc : 正向测试 'ecm' 返回 2
*/
it('SUB_USB_JS_0880', 0, function () {
console.info('usb SUB_USB_JS_0880 begin');
var strMaskCode = 'ecm'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(usb.ECM);
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0880 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0890
* @tc.name : usbFunctionsFromString
* @tc.desc : 正向测试 'acm,ecm' 返回 3
*/
it('SUB_USB_JS_0890', 0, function () {
console.info('usb SUB_USB_JS_0890 begin');
var strMaskCode = 'acm,ecm'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(usb.ACM | usb.ECM);
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0890 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0900
* @tc.name : usbFunctionsFromString
* @tc.desc : 正向测试 'hdc' 返回 4
*/
it('SUB_USB_JS_0900', 0, function () {
console.info('usb SUB_USB_JS_0900 begin');
var strMaskCode = 'hdc'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(usb.HDC);
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0900 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0910
* @tc.name : usbFunctionsFromString
* @tc.desc : 正向测试 'acm,hdc' 返回 5
*/
it('SUB_USB_JS_0910', 0, function () {
console.info('usb SUB_USB_JS_0910 begin');
var strMaskCode = 'acm,hdc'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(usb.HDC | usb.ACM);
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0910 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0920
* @tc.name : usbFunctionsFromString
* @tc.desc : 正向测试 'ecm,hdc' 返回 6
*/
it('SUB_USB_JS_0920', 0, function () {
console.info('usb SUB_USB_JS_0920 begin');
var strMaskCode = 'ecm,hdc'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(usb.HDC | usb.ECM);
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0920 : PASS');
})
})
/*
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import usb from '@ohos.usb';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
/* usb core functions test */
export default function UsbFunctionsJsFunctionsTestEx() {
describe('UsbFunctionsJsFunctionsTestEx', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbFunctionsJsFunctionsTestEx Begin*************');
var Version = usb.getVersion()
console.info('begin test getversion :' + Version)
// 17 version host currentMode = 2 device currentMode = 1
var usbPortList = usb.getPorts()
if (usbPortList.length > 0) {
if (usbPortList[0].status.currentMode == 2) {
usb.setPortRoles(usbPortList[0].id, usb.SINK, usb.DEVICE).then(data => {
console.info('usb case setPortRoles return: ' + data);
}).catch(error => {
console.info('usb case setPortRoles error : ' + error);
});
console.log('*************Usb Unit switch to device Begin*************');
}
}
})
beforeEach(function () {
console.info('beforeEach: *************Usb Unit Test Case*************');
})
afterEach(function () {
console.info('afterEach: *************Usb Unit Test Case*************');
})
afterAll(function () {
console.log('*************Usb Unit UsbFunctionsJsFunctionsTest End*************');
})
/**
* @tc.number : SUB_USB_JS_0930
* @tc.name : usbFunctionsToString
* @tc.desc : 正向测试 0 返回 'none'
*/
it('SUB_USB_JS_0930', 0, function () {
console.info('usb SUB_USB_JS_0930 begin');
var maskCode = usb.NONE
console.info('usb case maskCode : ' + usb.NONE);
var strMaskCode = usb.usbFunctionsToString(maskCode)
expect(strMaskCode).assertEqual('none');
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
console.info('usb SUB_USB_JS_0930 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0940
* @tc.name : usbFunctionsToString
* @tc.desc : 正向测试 1 返回 'acm'
*/
it('SUB_USB_JS_0940', 0, function () {
console.info('usb SUB_USB_JS_0940 begin');
var maskCode = usb.ACM
console.info('usb case maskCode : ' + usb.ACM);
var strMaskCode = usb.usbFunctionsToString(maskCode)
expect(strMaskCode).assertEqual('acm');
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
console.info('usb SUB_USB_JS_0940 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0950
* @tc.name : usbFunctionsToString
* @tc.desc : 正向测试 2 返回 'ecm'
*/
it('SUB_USB_JS_0950', 0, function () {
console.info('usb SUB_USB_JS_0950 begin');
var maskCode = usb.ECM
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
expect(strMaskCode).assertEqual('ecm');
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
console.info('usb SUB_USB_JS_0950 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0960
* @tc.name : usbFunctionsToString
* @tc.desc : 正向测试 3 返回 'acm,ecm'
*/
it('SUB_USB_JS_0960', 0, function () {
console.info('usb SUB_USB_JS_0960 begin');
var maskCode = usb.ACM | usb.ECM
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
expect(strMaskCode).assertEqual('acm,ecm');
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
console.info('usb SUB_USB_JS_0960 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0970
* @tc.name : usbFunctionsToString
* @tc.desc : 正向测试 4 返回 'hdc'
*/
it('SUB_USB_JS_0970', 0, function () {
console.info('usb SUB_USB_JS_0970 begin');
var maskCode = usb.HDC
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
expect(strMaskCode).assertEqual('hdc');
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
console.info('usb SUB_USB_JS_0970 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0980
* @tc.name : usbFunctionsToString
* @tc.desc : 正向测试 5 返回 'acm,hdc'
*/
it('SUB_USB_JS_0980', 0, function () {
console.info('usb SUB_USB_JS_0980 begin');
var maskCode = usb.ACM | usb.HDC
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
expect(strMaskCode).assertEqual('hdc,acm');
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
console.info('usb SUB_USB_JS_0980 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0990
* @tc.name : usbFunctionsToString
* @tc.desc : 正向测试 6 返回 'ecm,hdc'
*/
it('SUB_USB_JS_0990', 0, function () {
console.info('usb SUB_USB_JS_0990 begin');
var maskCode = usb.ECM | usb.HDC
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
expect(strMaskCode).assertEqual('hdc,ecm');
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
console.info('usb SUB_USB_JS_0990 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0860
* @tc.name : usbFunctionsFromString
* @tc.desc : 正向测试 'none' 返回 0
*/
it('SUB_USB_JS_0860', 0, function () {
console.info('usb SUB_USB_JS_0860 begin');
var strMaskCode = 'none'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(usb.NONE);
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0860 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0870
* @tc.name : usbFunctionsFromString
* @tc.desc : 正向测试 'acm' 返回 1
*/
it('SUB_USB_JS_0870', 0, function () {
console.info('usb SUB_USB_JS_0870 begin');
var strMaskCode = 'acm'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(usb.ACM);
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0870 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0880
* @tc.name : usbFunctionsFromString
* @tc.desc : 正向测试 'ecm' 返回 2
*/
it('SUB_USB_JS_0880', 0, function () {
console.info('usb SUB_USB_JS_0880 begin');
var strMaskCode = 'ecm'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(usb.ECM);
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0880 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0890
* @tc.name : usbFunctionsFromString
* @tc.desc : 正向测试 'acm,ecm' 返回 3
*/
it('SUB_USB_JS_0890', 0, function () {
console.info('usb SUB_USB_JS_0890 begin');
var strMaskCode = 'acm,ecm'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(usb.ACM | usb.ECM);
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0890 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0900
* @tc.name : usbFunctionsFromString
* @tc.desc : 正向测试 'hdc' 返回 4
*/
it('SUB_USB_JS_0900', 0, function () {
console.info('usb SUB_USB_JS_0900 begin');
var strMaskCode = 'hdc'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(usb.HDC);
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0900 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0910
* @tc.name : usbFunctionsFromString
* @tc.desc : 正向测试 'acm,hdc' 返回 5
*/
it('SUB_USB_JS_0910', 0, function () {
console.info('usb SUB_USB_JS_0910 begin');
var strMaskCode = 'acm,hdc'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(usb.HDC | usb.ACM);
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0910 : PASS');
})
/**
* @tc.number : SUB_USB_JS_0920
* @tc.name : usbFunctionsFromString
* @tc.desc : 正向测试 'ecm,hdc' 返回 6
*/
it('SUB_USB_JS_0920', 0, function () {
console.info('usb SUB_USB_JS_0920 begin');
var strMaskCode = 'ecm,hdc'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(usb.HDC | usb.ECM);
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0920 : PASS');
})
})
}
......@@ -15,9 +15,10 @@
import usb from '@ohos.usb';
import CheckEmptyUtils from './CheckEmptyUtils.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
/* usb core functions test */
export default function UsbPortAndFunctionsJsFunctionsTest() {
describe('UsbPortAndFunctionsJsFunctionsTest', function () {
beforeAll(function () {
......@@ -211,3 +212,4 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
})
})
}
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import usb from '@ohos.usb';
import CheckEmptyUtils from './CheckEmptyUtils.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
/* usb core functions test */
describe('UsbPortJsFunctionsTest', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbPortJsFunctionsTest Begin*************');
var Version = usb.getVersion()
console.info('begin test getversion :' + Version)
})
beforeEach(function () {
console.info('beforeEach: *************Usb Unit Test Case*************');
})
afterEach(function () {
console.info('afterEach: *************Usb Unit Test Case*************');
})
afterAll(function () {
console.log('*************Usb Unit UsbPortJsFunctionsTest End*************');
})
/**
* @tc.number : SUB_USB_JS_0410
* @tc.name : getPorts
* @tc.desc : 获取USB端口描述信息列表
*/
it('SUB_USB_JS_0410', 0, function () {
console.info('usb SUB_USB_JS_0410 begin');
var usbPortList = usb.getPorts()
if (usbPortList.length == 0) {
console.info('usb SUB_USB_JS_0410 usbPortList is null');
expect(false).assertTrue();
return
}
expect(usbPortList.length > 0).assertTrue();
console.info('usb SUB_USB_JS_0410 : PASS');
expect(true).assertTrue();
})
/**
* @tc.number : SUB_USB_JS_0220
* @tc.name : getSupportedModes
* @tc.desc : 获取指定的端口支持的模式列表的组合掩码
*/
it('SUB_USB_JS_0220', 0, function () {
console.info('usb SUB_USB_JS_0220 begin');
var usbPortList = usb.getPorts()
if (usbPortList.length == 0) {
console.info('usb SUB_USB_JS_0220 usbPortList is null');
expect(false).assertTrue();
return
}
expect(usbPortList.length > 0).assertTrue();
for (var i = 0; i < usbPortList.length; i++) {
var maskCode = usb.getSupportedModes(usbPortList[i].id)
expect(maskCode).assertEqual(usbPortList[i].supportedModes);
}
console.info('usb SUB_USB_JS_0220 : PASS');
expect(true).assertTrue();
})
})
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import usb from '@ohos.usb';
import CheckEmptyUtils from './CheckEmptyUtils.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
/* usb core functions test */
export default function UsbPortJsFunctionsTest() {
describe('UsbPortJsFunctionsTest', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbPortJsFunctionsTest Begin*************');
var Version = usb.getVersion()
console.info('begin test getversion :' + Version)
})
beforeEach(function () {
console.info('beforeEach: *************Usb Unit Test Case*************');
})
afterEach(function () {
console.info('afterEach: *************Usb Unit Test Case*************');
})
afterAll(function () {
console.log('*************Usb Unit UsbPortJsFunctionsTest End*************');
})
/**
* @tc.number : SUB_USB_JS_0410
* @tc.name : getPorts
* @tc.desc : 获取USB端口描述信息列表
*/
it('SUB_USB_JS_0410', 0, function () {
console.info('usb SUB_USB_JS_0410 begin');
var usbPortList = usb.getPorts()
if (usbPortList.length == 0) {
console.info('usb SUB_USB_JS_0410 usbPortList is null');
expect(false).assertTrue();
return
}
expect(usbPortList.length > 0).assertTrue();
console.info('usb SUB_USB_JS_0410 : PASS');
expect(true).assertTrue();
})
/**
* @tc.number : SUB_USB_JS_0220
* @tc.name : getSupportedModes
* @tc.desc : 获取指定的端口支持的模式列表的组合掩码
*/
it('SUB_USB_JS_0220', 0, function () {
console.info('usb SUB_USB_JS_0220 begin');
var usbPortList = usb.getPorts()
if (usbPortList.length == 0) {
console.info('usb SUB_USB_JS_0220 usbPortList is null');
expect(false).assertTrue();
return
}
expect(usbPortList.length > 0).assertTrue();
for (var i = 0; i < usbPortList.length; i++) {
var maskCode = usb.getSupportedModes(usbPortList[i].id)
expect(maskCode).assertEqual(usbPortList[i].supportedModes);
}
console.info('usb SUB_USB_JS_0220 : PASS');
expect(true).assertTrue();
})
})
}
{
"string": [
{
"name": "app_name",
"value": "UsbJSApiTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
{
"string": [
{
"name": "app_name",
"value": "UsbJSApiTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
文件模式从 100755 更改为 100644
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册