未验证 提交 e3b22ee5 编写于 作者: O openharmony_ci 提交者: Gitee

!4358 modified FS-JS PART9

Merge pull request !4358 from jiyong/local-20220716-0010
文件模式从 100755 更改为 100644
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # 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") import("//test/xts/tools/build/suite.gni")
...@@ -23,7 +23,9 @@ ohos_js_hap_suite("usb_js_test") { ...@@ -23,7 +23,9 @@ ohos_js_hap_suite("usb_js_test") {
hap_name = "ActsUsbJSApiTest" hap_name = "ActsUsbJSApiTest"
} }
ohos_js_assets("usb_js_assets") { 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") { ohos_resources("usb_js_resources") {
sources = [ "./src/main/resources" ] sources = [ "./src/main/resources" ]
......
{ {
"description": "Configuration for usb js api Tests", "description": "Configuration for usb js api Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "160000", "test-timeout": "160000",
"package": "ohos.acts.usb.usb.function", "shell-timeout": "160000",
"shell-timeout": "60000" "bundle-name": "ohos.acts.usb.usb.function",
}, "package-name": "ohos.acts.usb.usb.function"
"kits": [ },
{ "kits": [
"test-file-name": [ {
"ActsUsbJSApiTest.hap" "test-file-name": [
], "ActsUsbJSApiTest.hap"
"type": "AppInstallKit", ],
"cleanup-apps": true "type": "AppInstallKit",
} "cleanup-apps": true
] }
} ]
}
\ No newline at end of file
文件模式从 100755 更改为 100644
{ {
"app": { "app": {
"bundleName": "ohos.acts.usb.usb.function", "bundleName": "ohos.acts.usb.usb.function",
"vendor": "example", "vendor": "example",
"version": { "version": {
"code": 1, "code": 1,
"name": "1.0" "name": "1.0"
}, },
"apiVersion": { "apiVersion": {
"compatible": 4, "compatible": 4,
"target": 5 "target": 5
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "ohos.acts.usb.usb.function", "package": "ohos.acts.usb.usb.function",
"name": ".MyApplication", "name": ".entry",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
"distro": { "distro": {
"deliveryWithInstall": true, "deliveryWithInstall": true,
"moduleName": "entry", "moduleName": "entry",
"moduleType": "entry" "moduleType": "entry"
}, },
"abilities": [ "abilities": [
{ {
"visible": true, "skills": [
"skills": [ {
{ "entities": [
"entities": [ "entity.system.home"
"entity.system.home" ],
], "actions": [
"actions": [ "action.system.home"
"action.system.home" ]
] }
} ],
], "orientation": "unspecified",
"name": "ohos.acts.usb.usb.function.MainAbility", "formsEnabled": false,
"icon": "$media:icon", "name": ".MainAbility",
"description": "$string:mainability_description", "srcLanguage": "js",
"label": "$string:app_name", "srcPath": "MainAbility",
"type": "page", "icon": "$media:icon",
"launchType": "standard" "description": "$string:MainAbility_desc",
} "label": "$string:MainAbility_label",
], "type": "page",
"js": [ "visible": true,
{ "launchType": "standard"
"pages": [ },
"pages/index/index" {
], "orientation": "unspecified",
"name": "default", "formsEnabled": false,
"window": { "name": ".TestAbility",
"designWidth": 720, "srcLanguage": "js",
"autoDesignWidth": false "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. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
const injectRef = Object.getPrototypeOf(global) || global
import {Core, ExpectExtend} from 'deccjsunit/index' injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
const injectRef = Object.getPrototypeOf(global) || global export default {
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') data: {
title: ""
export default { },
data: { onInit() {
title: "" this.title = this.$t('strings.world');
}, },
onInit() { onShow() {
this.title = this.$t('strings.world'); console.info('onShow finish')
}, },
onShow() { onReady() {
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) 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. * Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
export default {
/* host test case */ data: {
require('./UsbCoreJsunit.test.js') title: ""
require('./UsbCoreJsunitEx.test.js') },
require('./UsbDevicePipeJsunit.test.js') onInit() {
require('./UsbDevicePipeJsunitEx.test.js') this.title = this.$t('strings.world');
}
/* 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.
*/
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. * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
export default { export default {
/** /**
* Check obj is empty. * Check obj is empty.
* *
* @param {object} obj * @param {object} obj
* @return {boolean} true(empty) * @return {boolean} true(empty)
*/ */
isEmpty(obj) { isEmpty(obj) {
return (typeof obj == 'undefined' || obj == null || return (typeof obj == 'undefined' || obj == null ||
JSON.stringify(obj) == '{}' || JSON.stringify(obj) == 'undefined'); JSON.stringify(obj) == '{}' || JSON.stringify(obj) == 'undefined');
}, },
/** /**
* Check str is empty. * Check str is empty.
* *
* @param {string} str * @param {string} str
* @return {boolean} true(empty) * @return {boolean} true(empty)
*/ */
checkStrIsEmpty(str) { checkStrIsEmpty(str) {
return str.trim().length == 0; return str.trim().length == 0;
}, },
/** /**
* Check array is empty. * Check array is empty.
* *
* @param {Array}arr * @param {Array}arr
* @return {boolean} true(empty) * @return {boolean} true(empty)
*/ */
isEmptyArr(arr) { isEmptyArr(arr) {
return arr.length == 0; return arr.length == 0;
}, },
// ArrayBuffer转为字符串,参数为ArrayBuffer对象 // ArrayBuffer转为字符串,参数为ArrayBuffer对象
ab2str(buf) { ab2str(buf) {
return String.fromCharCode.apply(null, new Uint8Array(buf)); return String.fromCharCode.apply(null, new Uint8Array(buf));
}, },
// 字符串转为ArrayBuffer对象,参数为字符串 // 字符串转为ArrayBuffer对象,参数为字符串
str2ab(str) { str2ab(str) {
var arr = []; var arr = [];
for (var i = 0, j = str.length; i < j; ++i) { for (var i = 0, j = str.length; i < j; ++i) {
arr.push(str.charCodeAt(i)); arr.push(str.charCodeAt(i));
} }
var tmpUint8Array = new Uint8Array(arr); var tmpUint8Array = new Uint8Array(arr);
return tmpUint8Array; return tmpUint8Array;
}, },
// 简单阻塞的粗暴实现 // 简单阻塞的粗暴实现
sleep(delay) { sleep(delay) {
for (var t = Date.now(); Date.now() - t <= delay;); for (var t = Date.now(); Date.now() - t <= delay;);
} }
} }
/* /*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
const twelve = 12; const twelve = 12;
/* /*
* date package tool class * date package tool class
*/ */
export default class DateAndTimeUtil { export default class DateAndTimeUtil {
constructor() { constructor() {
} }
/** /**
* *
* Get the current time * Get the current time
*/ */
now() { now() {
const datetime = new Date(); const datetime = new Date();
const hours = datetime.getHours(); const hours = datetime.getHours();
const minutes = datetime.getMinutes(); const minutes = datetime.getMinutes();
return this.concatTime(hours, minutes); return this.concatTime(hours, minutes);
} }
/** /**
* *
* Get the current time * Get the current time
*/ */
nowWithSeconds() { nowWithSeconds() {
const datetime = new Date(); const datetime = new Date();
const hours = datetime.getHours(); const hours = datetime.getHours();
const minutes = datetime.getMinutes(); const minutes = datetime.getMinutes();
const seconds = datetime.getMilliseconds() const seconds = datetime.getMilliseconds()
console.info('now: ' + hours + ':' + minutes + ':' + seconds) console.info('now: ' + hours + ':' + minutes + ':' + seconds)
var now = this.concatTimeWithSeconds(hours, minutes, seconds); var now = this.concatTimeWithSeconds(hours, minutes, seconds);
console.info('now concat: ' + now); console.info('now concat: ' + now);
return now; return now;
} }
/** /**
* format * format
* @param value * @param value
* @return * @return
*/ */
fill(value) { fill(value) {
return (value > 9 ? '' : '0') + value; return (value > 9 ? '' : '0') + value;
} }
/** /**
* concat date * concat date
* @param year m d * @param year m d
* @return * @return
*/ */
concatDate(year, month, date) { concatDate(year, month, date) {
return year + this.year + month + this.month + date + this.day; return year + this.year + month + this.month + date + this.day;
} }
concatTime(hours, minutes) { concatTime(hours, minutes) {
return `${this.fill(hours)}:${this.fill(minutes)}`; return `${this.fill(hours)}:${this.fill(minutes)}`;
} }
concatTimeWithSeconds(hours, minutes, milliseconds) { concatTimeWithSeconds(hours, minutes, milliseconds) {
return `${this.fill(hours)}:${this.fill(minutes)}:${this.fill(milliseconds)}`; return `${this.fill(hours)}:${this.fill(minutes)}:${this.fill(milliseconds)}`;
} }
/** /**
* Turn to 24-hour clock * Turn to 24-hour clock
* @param str * @param str
* @return * @return
*/ */
transform24(str) { transform24(str) {
const timeFlag = str.substr(0, 2); const timeFlag = str.substr(0, 2);
if (timeFlag == this.morning) { if (timeFlag == this.morning) {
const h = str.substr(2).split(':')[0]; const h = str.substr(2).split(':')[0];
if (h == twelve) { if (h == twelve) {
const time = '0' + ':' + str.substr(2).split(':')[1]; const time = '0' + ':' + str.substr(2).split(':')[1];
return time; return time;
} else { } else {
return h + ':' + str.substr(2).split(':')[1]; return h + ':' + str.substr(2).split(':')[1];
} }
} else { } else {
const h = str.substr(2).split(':')[0]; const h = str.substr(2).split(':')[0];
const h1 = parseInt(h) + twelve; const h1 = parseInt(h) + twelve;
if (h != twelve) { if (h != twelve) {
const time = h1 + ':' + str.substr(2).split(':')[1]; const time = h1 + ':' + str.substr(2).split(':')[1];
return time; return time;
} }
} }
} }
/** /**
* Turn to 12-hour clock * Turn to 12-hour clock
* @param str * @param str
* @return * @return
*/ */
transform12(str) { transform12(str) {
const hours = str.substring(0, str.indexOf(':')); const hours = str.substring(0, str.indexOf(':'));
const minutes = str.split(':')[1]; const minutes = str.split(':')[1];
if (hours < twelve) { if (hours < twelve) {
return this.morning.concat(`${hours}:${minutes}`); return this.morning.concat(`${hours}:${minutes}`);
} }
if (hours == twelve) { if (hours == twelve) {
return this.afternoon.concat(`${hours}:${minutes}`); return this.afternoon.concat(`${hours}:${minutes}`);
} else { } else {
const reduceHours = parseInt(hours) - twelve; const reduceHours = parseInt(hours) - twelve;
return this.afternoon.concat(`${reduceHours}:${minutes}`); return this.afternoon.concat(`${reduceHours}:${minutes}`);
} }
} }
} }
/* /*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* /*
* Constants of events that will be registered to system. * Constants of events that will be registered to system.
*/ */
const EventConstants = { const EventConstants = {
/** /**
* Bitmask used for extracting the USBEndpoint type from it's address * Bitmask used for extracting the USBEndpoint type from it's address
*/ */
USB_ENDPOINT_XFERTYPE_MASK: 0x03, USB_ENDPOINT_XFERTYPE_MASK: 0x03,
/** /**
* Control USBEndpoint type * Control USBEndpoint type
*/ */
USB_ENDPOINT_XFER_CONTROL: 0, USB_ENDPOINT_XFER_CONTROL: 0,
/** /**
* Isochronous USBEndpoint type * Isochronous USBEndpoint type
*/ */
USB_ENDPOINT_XFER_ISOC: 1, USB_ENDPOINT_XFER_ISOC: 1,
/** /**
* Bulk USBEndpoint type * Bulk USBEndpoint type
*/ */
USB_ENDPOINT_XFER_BULK: 2, USB_ENDPOINT_XFER_BULK: 2,
/** /**
* Interrupt USBEndpoint type * Interrupt USBEndpoint type
*/ */
USB_ENDPOINT_XFER_INT: 3, USB_ENDPOINT_XFER_INT: 3,
/** /**
* Bitmask used for extracting the USBEndpoint number from it's address * Bitmask used for extracting the USBEndpoint number from it's address
*/ */
USB_ENDPOINT_NUMBER_MASK: 0x0f, USB_ENDPOINT_NUMBER_MASK: 0x0f,
/** /**
* Bitmask used for extracting the USBEndpoint direction from it's address * Bitmask used for extracting the USBEndpoint direction from it's address
*/ */
USB_ENDPOINT_DIR_MASK: 0x80, USB_ENDPOINT_DIR_MASK: 0x80,
/** /**
* Used to signify direction of data for USBEndpoint is OUT, host to device * Used to signify direction of data for USBEndpoint is OUT, host to device
*/ */
USB_ENDPOINT_DIR_OUT: 0, USB_ENDPOINT_DIR_OUT: 0,
/** /**
* Used to signify direction of data for USBEndpoint is IN, device to host * Used to signify direction of data for USBEndpoint is IN, device to host
*/ */
USB_ENDPOINT_DIR_IN: 0x80 USB_ENDPOINT_DIR_IN: 0x80
} }
export default EventConstants; 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. * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import usb from '@ohos.usb'; import usb from '@ohos.usb';
import CheckEmptyUtils from './CheckEmptyUtils.js'; 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 */ /* usb core functions test */
describe('UsbFunctionsJsFunctionsTest', function () { export default function UsbFunctionsJsFunctionsTest() {
describe('UsbFunctionsJsFunctionsTest', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbFunctionsJsFunctionsTest Begin*************'); beforeAll(function () {
var Version = usb.getVersion() console.log('*************Usb Unit UsbFunctionsJsFunctionsTest Begin*************');
console.info('begin test getversion :' + Version) var Version = usb.getVersion()
// version > 17 host currentMode = 2 device currentMode = 1 console.info('begin test getversion :' + Version)
var usbPortList = usb.getPorts() // version > 17 host currentMode = 2 device currentMode = 1
if (usbPortList.length > 0) { var usbPortList = usb.getPorts()
if (usbPortList[0].status.currentMode == 2) { if (usbPortList.length > 0) {
usb.setPortRoles(usbPortList[0].id, usb.SINK, usb.DEVICE).then(data => { if (usbPortList[0].status.currentMode == 2) {
console.info('usb case setPortRoles return: ' + data); usb.setPortRoles(usbPortList[0].id, usb.SINK, usb.DEVICE).then(data => {
}).catch(error => { console.info('usb case setPortRoles return: ' + data);
console.info('usb case setPortRoles error : ' + error); }).catch(error => {
}); console.info('usb case setPortRoles error : ' + error);
console.log('*************Usb Unit switch to device Begin*************'); });
} console.log('*************Usb Unit switch to device Begin*************');
} }
}) }
beforeEach(function () { })
console.info('beforeEach: *************Usb Unit Test Case*************'); beforeEach(function () {
}) console.info('beforeEach: *************Usb Unit Test Case*************');
afterEach(function () { })
console.info('afterEach: *************Usb Unit Test Case*************'); afterEach(function () {
}) console.info('afterEach: *************Usb Unit Test Case*************');
afterAll(function () { })
console.log('*************Usb Unit UsbFunctionsJsFunctionsTest End*************'); afterAll(function () {
}) console.log('*************Usb Unit UsbFunctionsJsFunctionsTest End*************');
})
/**
* @tc.number : SUB_USB_JS_0330 /**
* @tc.name : getCurrentFunctions * @tc.number : SUB_USB_JS_0330
* @tc.desc : 获取当前设备模式 掩码与描述字符转换 * @tc.name : getCurrentFunctions
*/ * @tc.desc : 获取当前设备模式 掩码与描述字符转换
it('SUB_USB_JS_0330', 0, function () { */
console.info('usb SUB_USB_JS_0330 begin'); it('SUB_USB_JS_0330', 0, function () {
var maskCode = usb.getCurrentFunctions(); console.info('usb SUB_USB_JS_0330 begin');
console.info('usb case getCurrentFunctions return: ' + maskCode); 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 strMaskCode = usb.usbFunctionsToString(maskCode)
var nMaskCode = usb.usbFunctionsFromString(strMaskCode) console.info('usb case usbFunctionsToString return str: ' + strMaskCode);
console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode); var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
expect(nMaskCode).assertEqual(maskCode); console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0330 : PASS'); expect(nMaskCode).assertEqual(maskCode);
expect(true).assertTrue(); console.info('usb SUB_USB_JS_0330 : PASS');
}) expect(true).assertTrue();
})
/**
* @tc.number : SUB_USB_JS_0340 /**
* @tc.name : usbFunctionString * @tc.number : SUB_USB_JS_0340
* @tc.desc : 反向测试 获取当前设备模式 掩码与描述字符转换 * @tc.name : usbFunctionString
*/ * @tc.desc : 反向测试 获取当前设备模式 掩码与描述字符转换
it('SUB_USB_JS_0340', 0, function () { */
console.info('usb SUB_USB_JS_0340 begin'); it('SUB_USB_JS_0340', 0, function () {
var maskCode = usb.getCurrentFunctions(); console.info('usb SUB_USB_JS_0340 begin');
console.info('usb case getCurrentFunctions return: ' + maskCode); 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 strMaskCode = usb.usbFunctionsToString(maskCode)
var nMaskCode = usb.usbFunctionsFromString(strMaskCode) console.info('usb case usbFunctionsToString return str: ' + strMaskCode);
console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode); var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode);
var errmaskCode = 0
var strMaskCode = usb.usbFunctionsToString(errmaskCode) var errmaskCode = 0
var strMaskCode = usb.usbFunctionsToString(errmaskCode)
console.info('usb case ' + errmaskCode + ' usbFunctionsToString return str: ' + strMaskCode);
console.info('usb case ' + errmaskCode + ' usbFunctionsToString return str: ' + strMaskCode);
var errStrMaskCode = 'none'
var nMaskCode = usb.usbFunctionsFromString(errStrMaskCode) var errStrMaskCode = 'none'
expect(nMaskCode).assertEqual(usb.NONE); var nMaskCode = usb.usbFunctionsFromString(errStrMaskCode)
console.info('usb case errStrMaskCode ' + errStrMaskCode + expect(nMaskCode).assertEqual(usb.NONE);
' usbFunctionsFromString return int: ' + nMaskCode); console.info('usb case errStrMaskCode ' + errStrMaskCode +
' usbFunctionsFromString return int: ' + nMaskCode);
console.info('usb SUB_USB_JS_0340 : PASS');
}) console.info('usb SUB_USB_JS_0340 : PASS');
})
})
})
}
/* /*
* Copyright (C) 2021-2022 Huawei Device Co., Ltd. * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License'); * Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS, * distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import usb from '@ohos.usb'; import usb from '@ohos.usb';
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 */ /* usb core functions test */
describe('UsbFunctionsJsFunctionsTestEx', function () { export default function UsbFunctionsJsFunctionsTestEx() {
describe('UsbFunctionsJsFunctionsTestEx', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbFunctionsJsFunctionsTestEx Begin*************'); beforeAll(function () {
var Version = usb.getVersion() console.log('*************Usb Unit UsbFunctionsJsFunctionsTestEx Begin*************');
console.info('begin test getversion :' + Version) var Version = usb.getVersion()
// 17 version host currentMode = 2 device currentMode = 1 console.info('begin test getversion :' + Version)
var usbPortList = usb.getPorts() // 17 version host currentMode = 2 device currentMode = 1
if (usbPortList.length > 0) { var usbPortList = usb.getPorts()
if (usbPortList[0].status.currentMode == 2) { if (usbPortList.length > 0) {
usb.setPortRoles(usbPortList[0].id, usb.SINK, usb.DEVICE).then(data => { if (usbPortList[0].status.currentMode == 2) {
console.info('usb case setPortRoles return: ' + data); usb.setPortRoles(usbPortList[0].id, usb.SINK, usb.DEVICE).then(data => {
}).catch(error => { console.info('usb case setPortRoles return: ' + data);
console.info('usb case setPortRoles error : ' + error); }).catch(error => {
}); console.info('usb case setPortRoles error : ' + error);
});
console.log('*************Usb Unit switch to device Begin*************');
} console.log('*************Usb Unit switch to device Begin*************');
} }
}) }
beforeEach(function () { })
console.info('beforeEach: *************Usb Unit Test Case*************'); beforeEach(function () {
}) console.info('beforeEach: *************Usb Unit Test Case*************');
})
afterEach(function () {
console.info('afterEach: *************Usb Unit Test Case*************'); afterEach(function () {
}) console.info('afterEach: *************Usb Unit Test Case*************');
})
afterAll(function () {
console.log('*************Usb Unit UsbFunctionsJsFunctionsTest End*************'); afterAll(function () {
}) console.log('*************Usb Unit UsbFunctionsJsFunctionsTest End*************');
})
/**
* @tc.number : SUB_USB_JS_0930 /**
* @tc.name : usbFunctionsToString * @tc.number : SUB_USB_JS_0930
* @tc.desc : 正向测试 0 返回 'none' * @tc.name : usbFunctionsToString
*/ * @tc.desc : 正向测试 0 返回 'none'
it('SUB_USB_JS_0930', 0, function () { */
console.info('usb SUB_USB_JS_0930 begin'); it('SUB_USB_JS_0930', 0, function () {
var maskCode = usb.NONE console.info('usb SUB_USB_JS_0930 begin');
console.info('usb case maskCode : ' + usb.NONE); var maskCode = usb.NONE
var strMaskCode = usb.usbFunctionsToString(maskCode) console.info('usb case maskCode : ' + usb.NONE);
expect(strMaskCode).assertEqual('none'); var strMaskCode = usb.usbFunctionsToString(maskCode)
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); expect(strMaskCode).assertEqual('none');
console.info('usb SUB_USB_JS_0930 : PASS'); 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.number : SUB_USB_JS_0940
* @tc.desc : 正向测试 1 返回 'acm' * @tc.name : usbFunctionsToString
*/ * @tc.desc : 正向测试 1 返回 'acm'
it('SUB_USB_JS_0940', 0, function () { */
console.info('usb SUB_USB_JS_0940 begin'); it('SUB_USB_JS_0940', 0, function () {
var maskCode = usb.ACM console.info('usb SUB_USB_JS_0940 begin');
console.info('usb case maskCode : ' + usb.ACM); var maskCode = usb.ACM
var strMaskCode = usb.usbFunctionsToString(maskCode) console.info('usb case maskCode : ' + usb.ACM);
expect(strMaskCode).assertEqual('acm'); var strMaskCode = usb.usbFunctionsToString(maskCode)
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); expect(strMaskCode).assertEqual('acm');
console.info('usb SUB_USB_JS_0940 : PASS'); 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.number : SUB_USB_JS_0950
* @tc.desc : 正向测试 2 返回 'ecm' * @tc.name : usbFunctionsToString
*/ * @tc.desc : 正向测试 2 返回 'ecm'
it('SUB_USB_JS_0950', 0, function () { */
console.info('usb SUB_USB_JS_0950 begin'); it('SUB_USB_JS_0950', 0, function () {
var maskCode = usb.ECM console.info('usb SUB_USB_JS_0950 begin');
console.info('usb case maskCode : ' + maskCode); var maskCode = usb.ECM
var strMaskCode = usb.usbFunctionsToString(maskCode) console.info('usb case maskCode : ' + maskCode);
expect(strMaskCode).assertEqual('ecm'); var strMaskCode = usb.usbFunctionsToString(maskCode)
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); expect(strMaskCode).assertEqual('ecm');
console.info('usb SUB_USB_JS_0950 : PASS'); 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.number : SUB_USB_JS_0960
* @tc.desc : 正向测试 3 返回 'acm,ecm' * @tc.name : usbFunctionsToString
*/ * @tc.desc : 正向测试 3 返回 'acm,ecm'
it('SUB_USB_JS_0960', 0, function () { */
console.info('usb SUB_USB_JS_0960 begin'); it('SUB_USB_JS_0960', 0, function () {
var maskCode = usb.ACM | usb.ECM console.info('usb SUB_USB_JS_0960 begin');
console.info('usb case maskCode : ' + maskCode); var maskCode = usb.ACM | usb.ECM
var strMaskCode = usb.usbFunctionsToString(maskCode) console.info('usb case maskCode : ' + maskCode);
expect(strMaskCode).assertEqual('acm,ecm'); var strMaskCode = usb.usbFunctionsToString(maskCode)
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); expect(strMaskCode).assertEqual('acm,ecm');
console.info('usb SUB_USB_JS_0960 : PASS'); 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.number : SUB_USB_JS_0970
* @tc.desc : 正向测试 4 返回 'hdc' * @tc.name : usbFunctionsToString
*/ * @tc.desc : 正向测试 4 返回 'hdc'
it('SUB_USB_JS_0970', 0, function () { */
console.info('usb SUB_USB_JS_0970 begin'); it('SUB_USB_JS_0970', 0, function () {
var maskCode = usb.HDC console.info('usb SUB_USB_JS_0970 begin');
console.info('usb case maskCode : ' + maskCode); var maskCode = usb.HDC
var strMaskCode = usb.usbFunctionsToString(maskCode) console.info('usb case maskCode : ' + maskCode);
expect(strMaskCode).assertEqual('hdc'); var strMaskCode = usb.usbFunctionsToString(maskCode)
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); expect(strMaskCode).assertEqual('hdc');
console.info('usb SUB_USB_JS_0970 : PASS'); 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.number : SUB_USB_JS_0980
* @tc.desc : 正向测试 5 返回 'acm,hdc' * @tc.name : usbFunctionsToString
*/ * @tc.desc : 正向测试 5 返回 'acm,hdc'
it('SUB_USB_JS_0980', 0, function () { */
console.info('usb SUB_USB_JS_0980 begin'); it('SUB_USB_JS_0980', 0, function () {
var maskCode = usb.ACM | usb.HDC console.info('usb SUB_USB_JS_0980 begin');
console.info('usb case maskCode : ' + maskCode); var maskCode = usb.ACM | usb.HDC
var strMaskCode = usb.usbFunctionsToString(maskCode) console.info('usb case maskCode : ' + maskCode);
expect(strMaskCode).assertEqual('hdc,acm'); var strMaskCode = usb.usbFunctionsToString(maskCode)
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); expect(strMaskCode).assertEqual('hdc,acm');
console.info('usb SUB_USB_JS_0980 : PASS'); 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.number : SUB_USB_JS_0990
* @tc.desc : 正向测试 6 返回 'ecm,hdc' * @tc.name : usbFunctionsToString
*/ * @tc.desc : 正向测试 6 返回 'ecm,hdc'
it('SUB_USB_JS_0990', 0, function () { */
console.info('usb SUB_USB_JS_0990 begin'); it('SUB_USB_JS_0990', 0, function () {
var maskCode = usb.ECM | usb.HDC console.info('usb SUB_USB_JS_0990 begin');
console.info('usb case maskCode : ' + maskCode); var maskCode = usb.ECM | usb.HDC
var strMaskCode = usb.usbFunctionsToString(maskCode) console.info('usb case maskCode : ' + maskCode);
expect(strMaskCode).assertEqual('hdc,ecm'); var strMaskCode = usb.usbFunctionsToString(maskCode)
console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); expect(strMaskCode).assertEqual('hdc,ecm');
console.info('usb SUB_USB_JS_0990 : PASS'); 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.number : SUB_USB_JS_0860
* @tc.desc : 正向测试 'none' 返回 0 * @tc.name : usbFunctionsFromString
*/ * @tc.desc : 正向测试 'none' 返回 0
it('SUB_USB_JS_0860', 0, function () { */
console.info('usb SUB_USB_JS_0860 begin'); it('SUB_USB_JS_0860', 0, function () {
var strMaskCode = 'none' console.info('usb SUB_USB_JS_0860 begin');
var nMaskCode = usb.usbFunctionsFromString(strMaskCode) var strMaskCode = 'none'
expect(nMaskCode).assertEqual(usb.NONE); var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); expect(nMaskCode).assertEqual(usb.NONE);
console.info('usb SUB_USB_JS_0860 : PASS'); 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.number : SUB_USB_JS_0870
* @tc.desc : 正向测试 'acm' 返回 1 * @tc.name : usbFunctionsFromString
*/ * @tc.desc : 正向测试 'acm' 返回 1
it('SUB_USB_JS_0870', 0, function () { */
console.info('usb SUB_USB_JS_0870 begin'); it('SUB_USB_JS_0870', 0, function () {
var strMaskCode = 'acm' console.info('usb SUB_USB_JS_0870 begin');
var nMaskCode = usb.usbFunctionsFromString(strMaskCode) var strMaskCode = 'acm'
expect(nMaskCode).assertEqual(usb.ACM); var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); expect(nMaskCode).assertEqual(usb.ACM);
console.info('usb SUB_USB_JS_0870 : PASS'); 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.number : SUB_USB_JS_0880
* @tc.desc : 正向测试 'ecm' 返回 2 * @tc.name : usbFunctionsFromString
*/ * @tc.desc : 正向测试 'ecm' 返回 2
it('SUB_USB_JS_0880', 0, function () { */
console.info('usb SUB_USB_JS_0880 begin'); it('SUB_USB_JS_0880', 0, function () {
var strMaskCode = 'ecm' console.info('usb SUB_USB_JS_0880 begin');
var nMaskCode = usb.usbFunctionsFromString(strMaskCode) var strMaskCode = 'ecm'
expect(nMaskCode).assertEqual(usb.ECM); var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); expect(nMaskCode).assertEqual(usb.ECM);
console.info('usb SUB_USB_JS_0880 : PASS'); 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.number : SUB_USB_JS_0890
* @tc.desc : 正向测试 'acm,ecm' 返回 3 * @tc.name : usbFunctionsFromString
*/ * @tc.desc : 正向测试 'acm,ecm' 返回 3
it('SUB_USB_JS_0890', 0, function () { */
console.info('usb SUB_USB_JS_0890 begin'); it('SUB_USB_JS_0890', 0, function () {
var strMaskCode = 'acm,ecm' console.info('usb SUB_USB_JS_0890 begin');
var nMaskCode = usb.usbFunctionsFromString(strMaskCode) var strMaskCode = 'acm,ecm'
expect(nMaskCode).assertEqual(usb.ACM | usb.ECM); var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); expect(nMaskCode).assertEqual(usb.ACM | usb.ECM);
console.info('usb SUB_USB_JS_0890 : PASS'); 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.number : SUB_USB_JS_0900
* @tc.desc : 正向测试 'hdc' 返回 4 * @tc.name : usbFunctionsFromString
*/ * @tc.desc : 正向测试 'hdc' 返回 4
it('SUB_USB_JS_0900', 0, function () { */
console.info('usb SUB_USB_JS_0900 begin'); it('SUB_USB_JS_0900', 0, function () {
var strMaskCode = 'hdc' console.info('usb SUB_USB_JS_0900 begin');
var nMaskCode = usb.usbFunctionsFromString(strMaskCode) var strMaskCode = 'hdc'
expect(nMaskCode).assertEqual(usb.HDC); var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); expect(nMaskCode).assertEqual(usb.HDC);
console.info('usb SUB_USB_JS_0900 : PASS'); 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.number : SUB_USB_JS_0910
* @tc.desc : 正向测试 'acm,hdc' 返回 5 * @tc.name : usbFunctionsFromString
*/ * @tc.desc : 正向测试 'acm,hdc' 返回 5
it('SUB_USB_JS_0910', 0, function () { */
console.info('usb SUB_USB_JS_0910 begin'); it('SUB_USB_JS_0910', 0, function () {
var strMaskCode = 'acm,hdc' console.info('usb SUB_USB_JS_0910 begin');
var nMaskCode = usb.usbFunctionsFromString(strMaskCode) var strMaskCode = 'acm,hdc'
expect(nMaskCode).assertEqual(usb.HDC | usb.ACM); var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); expect(nMaskCode).assertEqual(usb.HDC | usb.ACM);
console.info('usb SUB_USB_JS_0910 : PASS'); 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.number : SUB_USB_JS_0920
* @tc.desc : 正向测试 'ecm,hdc' 返回 6 * @tc.name : usbFunctionsFromString
*/ * @tc.desc : 正向测试 'ecm,hdc' 返回 6
it('SUB_USB_JS_0920', 0, function () { */
console.info('usb SUB_USB_JS_0920 begin'); it('SUB_USB_JS_0920', 0, function () {
var strMaskCode = 'ecm,hdc' console.info('usb SUB_USB_JS_0920 begin');
var nMaskCode = usb.usbFunctionsFromString(strMaskCode) var strMaskCode = 'ecm,hdc'
expect(nMaskCode).assertEqual(usb.HDC | usb.ECM); var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); expect(nMaskCode).assertEqual(usb.HDC | usb.ECM);
console.info('usb SUB_USB_JS_0920 : PASS'); console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
}) console.info('usb SUB_USB_JS_0920 : PASS');
})
})
})
}
...@@ -15,9 +15,10 @@ ...@@ -15,9 +15,10 @@
import usb from '@ohos.usb'; import usb from '@ohos.usb';
import CheckEmptyUtils from './CheckEmptyUtils.js'; 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 */ /* usb core functions test */
export default function UsbPortAndFunctionsJsFunctionsTest() {
describe('UsbPortAndFunctionsJsFunctionsTest', function () { describe('UsbPortAndFunctionsJsFunctionsTest', function () {
beforeAll(function () { beforeAll(function () {
...@@ -211,3 +212,4 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () { ...@@ -211,3 +212,4 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
}) })
}) })
}
/* /*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import usb from '@ohos.usb'; import usb from '@ohos.usb';
import CheckEmptyUtils from './CheckEmptyUtils.js'; 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 */ /* usb core functions test */
describe('UsbPortJsFunctionsTest', function () { export default function UsbPortJsFunctionsTest() {
describe('UsbPortJsFunctionsTest', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbPortJsFunctionsTest Begin*************'); beforeAll(function () {
var Version = usb.getVersion() console.log('*************Usb Unit UsbPortJsFunctionsTest Begin*************');
console.info('begin test getversion :' + Version) var Version = usb.getVersion()
}) console.info('begin test getversion :' + Version)
beforeEach(function () { })
console.info('beforeEach: *************Usb Unit Test Case*************'); beforeEach(function () {
}) console.info('beforeEach: *************Usb Unit Test Case*************');
afterEach(function () { })
console.info('afterEach: *************Usb Unit Test Case*************'); afterEach(function () {
}) console.info('afterEach: *************Usb Unit Test Case*************');
afterAll(function () { })
console.log('*************Usb Unit UsbPortJsFunctionsTest End*************'); afterAll(function () {
}) console.log('*************Usb Unit UsbPortJsFunctionsTest End*************');
})
/**
* @tc.number : SUB_USB_JS_0410 /**
* @tc.name : getPorts * @tc.number : SUB_USB_JS_0410
* @tc.desc : 获取USB端口描述信息列表 * @tc.name : getPorts
*/ * @tc.desc : 获取USB端口描述信息列表
it('SUB_USB_JS_0410', 0, function () { */
console.info('usb SUB_USB_JS_0410 begin'); it('SUB_USB_JS_0410', 0, function () {
var usbPortList = usb.getPorts() console.info('usb SUB_USB_JS_0410 begin');
if (usbPortList.length == 0) { var usbPortList = usb.getPorts()
console.info('usb SUB_USB_JS_0410 usbPortList is null'); if (usbPortList.length == 0) {
expect(false).assertTrue(); console.info('usb SUB_USB_JS_0410 usbPortList is null');
return expect(false).assertTrue();
} return
expect(usbPortList.length > 0).assertTrue(); }
console.info('usb SUB_USB_JS_0410 : PASS'); expect(usbPortList.length > 0).assertTrue();
expect(true).assertTrue(); console.info('usb SUB_USB_JS_0410 : PASS');
}) expect(true).assertTrue();
})
/**
* @tc.number : SUB_USB_JS_0220 /**
* @tc.name : getSupportedModes * @tc.number : SUB_USB_JS_0220
* @tc.desc : 获取指定的端口支持的模式列表的组合掩码 * @tc.name : getSupportedModes
*/ * @tc.desc : 获取指定的端口支持的模式列表的组合掩码
it('SUB_USB_JS_0220', 0, function () { */
console.info('usb SUB_USB_JS_0220 begin'); it('SUB_USB_JS_0220', 0, function () {
var usbPortList = usb.getPorts() console.info('usb SUB_USB_JS_0220 begin');
if (usbPortList.length == 0) { var usbPortList = usb.getPorts()
console.info('usb SUB_USB_JS_0220 usbPortList is null'); if (usbPortList.length == 0) {
expect(false).assertTrue(); console.info('usb SUB_USB_JS_0220 usbPortList is null');
return expect(false).assertTrue();
} return
}
expect(usbPortList.length > 0).assertTrue();
for (var i = 0; i < usbPortList.length; i++) { expect(usbPortList.length > 0).assertTrue();
var maskCode = usb.getSupportedModes(usbPortList[i].id) for (var i = 0; i < usbPortList.length; i++) {
expect(maskCode).assertEqual(usbPortList[i].supportedModes); var maskCode = usb.getSupportedModes(usbPortList[i].id)
} expect(maskCode).assertEqual(usbPortList[i].supportedModes);
}
console.info('usb SUB_USB_JS_0220 : PASS');
expect(true).assertTrue(); console.info('usb SUB_USB_JS_0220 : PASS');
}) expect(true).assertTrue();
})
})
})
}
{ {
"string": [ "string": [
{ {
"name": "app_name", "name": "app_name",
"value": "UsbJSApiTest" "value": "UsbJSApiTest"
}, },
{ {
"name": "mainability_description", "name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability" "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.
先完成此消息的编辑!
想要评论请 注册