提交 e94e24e6 编写于 作者: L logic42

fixed 0e8f8f2b from https://gitee.com/logic42/xts_acts/pulls/4634

add input ets testcase
Signed-off-by: Nlogic42 <wanglong108@huawei.com>
上级 d4026a9b
...@@ -16,6 +16,9 @@ import("//build/ohos_var.gni") ...@@ -16,6 +16,9 @@ import("//build/ohos_var.gni")
group("multimodalinput") { group("multimodalinput") {
testonly = true testonly = true
if (is_standard_system) { if (is_standard_system) {
deps = [ "input_js_standard:multimodalinput_js_test" ] deps = [
"input_js_standard:multimodalinput_js_test",
"multimodalinput_ets_standard:ActsMultimodalInputEtsTest",
]
} }
} }
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsMultimodalInputEtsTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":multimodalinput_ets_assets",
":multimodalinput_ets_resources",
":multimodalinput_ets_test_assets",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsMultimodalInputEtsTest"
}
ohos_js_assets("multimodalinput_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_js_assets("multimodalinput_ets_test_assets") {
source_dir = "./entry/src/main/ets/TestAbility"
}
ohos_resources("multimodalinput_ets_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for MultimodalInput EventType Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "ohos.acts.multimodalinput.input",
"package-name": "ohos.acts.multimodalinput.input",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsMultimodalInputEtsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.multimodalinput.input",
"vendor": "open",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 8
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.multimodalinput.input",
"name": ".MyApplication",
"mainAbility": "ohos.acts.multimodalinput.input.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"formsEnabled": false,
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"orientation": "unspecified",
"visible": true,
"srcPath": "TestAbility",
"name": ".TestAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"formsEnabled": false,
"label": "$string:TestAbility_label",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
// @ts-nocheck
/**
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('Application onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
// @ts-nocheck
/*
* 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.
*/
@Entry
@Component
struct MyComponent {
aboutToAppear() {
}
build() {
Flex({
direction: FlexDirection.Column,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Center
}) {
Text('ACE CURVES ETS TEST')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
// @ts-nocheck
/**
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('Application onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
// @ts-nocheck
/**
* 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 router from '@system.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
// @ts-nocheck
/**
* 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 TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
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'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log('onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
console.info('addAbilityMonitorCallback : ' + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
}
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext')
var context = abilityDelegator.getAppContext()
console.info('getAppContext : ' + JSON.stringify(context))
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ 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 MultimodalInputEventTypeTest from './MultimodalInputEventType.test';
export default function testsuite() {
MultimodalInputEventTypeTest()
}
\ No newline at end of file
/*
* 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 inputkeyCode from '@ohos.multimodalInput.keyCode'
import keyEvent from '@ohos.multimodalInput.keyEvent'
import mouseEvent from '@ohos.multimodalInput.mouseEvent'
import touchEvent from '@ohos.multimodalInput.touchEvent'
import { Key, KeyEvent } from '@ohos.multimodalInput.keyEvent'
import { AxisValue, MouseEvent } from '@ohos.multimodalInput.mouseEvent'
import { Touch, TouchEvent } from '@ohos.multimodalInput.touchEvent'
import {
describe,
beforeAll,
beforeEach,
afterEach,
afterAll,
it,
expect
} from 'hypium/index'
export default function MultimodalInputEventTypeTest() {
describe('MultimodalInput_test', function () {
it('MultimodalInput_test::KeyEventTypeTest_0010', 0, function () {
console.info(`MultimodalInput_test::KeyEventTypeTest_0010 enter`);
expect(keyEvent.Action.CANCEL == 0).assertTrue();
expect(keyEvent.Action.DOWN == 1).assertTrue();
expect(keyEvent.Action.UP == 2).assertTrue();
console.info(`MultimodalInput_test::KeyEventTypeTest_0010 exit`);
})
it('MultimodalInput_test::KeyEventTypeTest_0020', 0, function () {
console.info(`MultimodalInput_test::KeyEventTypeTest_0020 enter`);
let testKey: Key = { code: inputkeyCode.KeyCode.KEYCODE_FN, pressedTime: 10, deviceId: 1 };
expect(testKey.code == inputkeyCode.KeyCode.KEYCODE_FN).assertTrue();
expect(testKey.pressedTime == 10).assertTrue();
expect(testKey.deviceId == 1).assertTrue();
console.info(`MultimodalInput_test::KeyEventTypeTest_0020 exit`);
})
it('MultimodalInput_test::KeyEventTypeTest_0030', 0, function () {
console.info(`MultimodalInput_test::KeyEventTypeTest_0030 enter`);
let testKey: Key = { code: inputkeyCode.KeyCode.KEYCODE_FN, pressedTime: 10, deviceId: 1 };
let testKeyEvent: KeyEvent = {
id: 1, deviceId: 1, actionTime: 1, screenId: 1, windowId: 1,
action: keyEvent.Action.DOWN, key: testKey, unicodeChar: 1, keys: [testKey],
ctrlKey: true, altKey: true, shiftKey: true, infooKey: true, fnKey: true, capsLock: true, numLock: true,
scrollLock: true
};
expect(testKeyEvent.action == keyEvent.Action.DOWN).assertTrue();
expect(testKeyEvent.key.code == testKey.code).assertTrue();
expect(testKeyEvent.unicodeChar == 1).assertTrue();
expect(testKeyEvent.keys[0].code == testKey.code).assertTrue();
expect(testKeyEvent.ctrlKey).assertTrue();
expect(testKeyEvent.altKey).assertTrue();
expect(testKeyEvent.shiftKey).assertTrue();
expect(testKeyEvent.infooKey).assertTrue();
expect(testKeyEvent.fnKey).assertTrue();
expect(testKeyEvent.capsLock).assertTrue();
expect(testKeyEvent.numLock).assertTrue();
expect(testKeyEvent.scrollLock).assertTrue();
console.info(`MultimodalInput_test::KeyEventTypeTest_0030 exit`);
})
it('MultimodalInput_test::MouseEventTypeTest_0010', 0, function () {
console.info(`MultimodalInput_test::MouseEventTypeTest_0010 enter`);
expect(mouseEvent.Action.CANCEL == 0).assertTrue();
expect(mouseEvent.Action.MOVE == 1).assertTrue();
expect(mouseEvent.Action.BUTTON_DOWN == 2).assertTrue();
expect(mouseEvent.Action.BUTTON_UP == 3).assertTrue();
expect(mouseEvent.Action.AXIS_BEGIN == 4).assertTrue();
expect(mouseEvent.Action.AXIS_UPDATE == 5).assertTrue();
expect(mouseEvent.Action.AXIS_END == 6).assertTrue();
console.info(`MultimodalInput_test::MouseEventTypeTest_0010 exit`);
})
it('MultimodalInput_test::MouseEventTypeTest_0020', 0, function () {
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 enter` + mouseEvent.Button.LEFT + mouseEvent.Button.MIDDLE + mouseEvent.Button.RIGHT + mouseEvent.Button.SIDE +mouseEvent.Button.EXTRA +mouseEvent.Button.BACK + mouseEvent.Button.TASK );
expect(mouseEvent.Button.LEFT == 0).assertTrue();
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 exit`);
})
it('MultimodalInput_test::MouseEventTypeTest_00201', 0, function () {
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 enter` + mouseEvent.Button.LEFT + mouseEvent.Button.MIDDLE + mouseEvent.Button.RIGHT + mouseEvent.Button.SIDE +mouseEvent.Button.EXTRA +mouseEvent.Button.BACK + mouseEvent.Button.TASK );
expect(mouseEvent.Button.MIDDLE == 1).assertTrue();
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 exit`);
})
it('MultimodalInput_test::MouseEventTypeTest_00202', 0, function () {
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 enter` + mouseEvent.Button.LEFT + mouseEvent.Button.MIDDLE + mouseEvent.Button.RIGHT + mouseEvent.Button.SIDE +mouseEvent.Button.EXTRA +mouseEvent.Button.BACK + mouseEvent.Button.TASK );
expect(mouseEvent.Button.RIGHT == 2).assertTrue();
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 exit`);
})
it('MultimodalInput_test::MouseEventTypeTest_00203', 0, function () {
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 enter` + mouseEvent.Button.LEFT + mouseEvent.Button.MIDDLE + mouseEvent.Button.RIGHT + mouseEvent.Button.SIDE +mouseEvent.Button.EXTRA +mouseEvent.Button.BACK + mouseEvent.Button.TASK );
expect(mouseEvent.Button.SIDE == 3).assertTrue();
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 exit`);
})
it('MultimodalInput_test::MouseEventTypeTest_00204', 0, function () {
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 enter` + mouseEvent.Button.LEFT + mouseEvent.Button.MIDDLE + mouseEvent.Button.RIGHT + mouseEvent.Button.SIDE +mouseEvent.Button.EXTRA +mouseEvent.Button.BACK + mouseEvent.Button.TASK );
expect(mouseEvent.Button.EXTRA == 4).assertTrue();
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 exit`);
})
it('MultimodalInput_test::MouseEventTypeTest_00205', 0, function () {
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 enter` + mouseEvent.Button.LEFT + mouseEvent.Button.MIDDLE + mouseEvent.Button.RIGHT + mouseEvent.Button.SIDE +mouseEvent.Button.EXTRA +mouseEvent.Button.BACK + mouseEvent.Button.TASK );
expect(mouseEvent.Button.FORWARD == 5).assertTrue();
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 exit`);
})
it('MultimodalInput_test::MouseEventTypeTest_00206', 0, function () {
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 enter` + mouseEvent.Button.LEFT + mouseEvent.Button.MIDDLE + mouseEvent.Button.RIGHT + mouseEvent.Button.SIDE +mouseEvent.Button.EXTRA +mouseEvent.Button.BACK + mouseEvent.Button.TASK );
expect(mouseEvent.Button.BACK == 6).assertTrue();
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 exit`);
})
it('MultimodalInput_test::MouseEventTypeTest_00207', 0, function () {
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 enter` + mouseEvent.Button.LEFT + mouseEvent.Button.MIDDLE + mouseEvent.Button.RIGHT + mouseEvent.Button.SIDE +mouseEvent.Button.EXTRA +mouseEvent.Button.BACK + mouseEvent.Button.TASK );
expect(mouseEvent.Button.TASK == 7).assertTrue();
console.info(`MultimodalInput_test::MouseEventTypeTest_0020 exit`);
})
it('MultimodalInput_test::MouseEventTypeTest_0030', 0, function () {
console.info(`MultimodalInput_test::MouseEventTypeTest_0030 enter`);
expect(mouseEvent.Axis.SCROLL_VERTICAL == 0).assertTrue();
expect(mouseEvent.Axis.SCROLL_HORIZONTAL == 1).assertTrue();
expect(mouseEvent.Axis.PINCH == 2).assertTrue();
console.info(`MultimodalInput_test::MouseEventTypeTest_0030 exit`);
})
it('MultimodalInput_test::MouseEventTypeTest_0040', 0, function () {
console.info(`MultimodalInput_test::MouseEventTypeTest_0040 enter`);
let testAxisValue: AxisValue = { axis: mouseEvent.Axis.SCROLL_VERTICAL, value: 1 };
expect(testAxisValue.axis == mouseEvent.Axis.SCROLL_VERTICAL).assertTrue();
expect(testAxisValue.value == 1).assertTrue();
console.info(`MultimodalInput_test::MouseEventTypeTest_0040 exit`);
})
it('MultimodalInput_test::MouseEventTypeTest_0050', 0, function () {
console.info(`MultimodalInput_test::MouseEventTypeTest_0050 enter`);
let testAxisValue: AxisValue = { axis: mouseEvent.Axis.SCROLL_VERTICAL, value: 1 };
let testMouseEvent: MouseEvent = {
id: 1, deviceId: 1, actionTime: 1, screenId: 1, windowId: 1,
action: mouseEvent.Action.CANCEL, screenX: 1, screenY: 1, windowX: 1,
windowY: 1, rawDeltaX: 1, rawDeltaY: 1, button: mouseEvent.Button.LEFT,
pressedButtons: [mouseEvent.Button.LEFT], axes: [testAxisValue],
pressedKeys: [inputkeyCode.KeyCode.KEYCODE_FN], ctrlKey: true, altKey: true, shiftKey: true,
infooKey: true, fnKey: true, capsLock: true, numLock: true, scrollLock: true
};
expect(testMouseEvent.action == mouseEvent.Action.CANCEL).assertTrue();
expect(testMouseEvent.screenX == 1).assertTrue();
expect(testMouseEvent.screenY == 1).assertTrue();
expect(testMouseEvent.windowX == 1).assertTrue();
expect(testMouseEvent.windowY == 1).assertTrue();
expect(testMouseEvent.rawDeltaX == 1).assertTrue();
expect(testMouseEvent.rawDeltaY == 1).assertTrue();
expect(testMouseEvent.button == mouseEvent.Button.LEFT).assertTrue();
expect(testMouseEvent.pressedButtons[0] == mouseEvent.Button.LEFT).assertTrue();
expect(testMouseEvent.axes[0].axis == mouseEvent.Axis.SCROLL_VERTICAL).assertTrue();
expect(testMouseEvent.pressedKeys[0] == inputkeyCode.KeyCode.KEYCODE_FN).assertTrue();
expect(testMouseEvent.ctrlKey).assertTrue();
expect(testMouseEvent.altKey).assertTrue();
expect(testMouseEvent.shiftKey).assertTrue();
expect(testMouseEvent.infooKey).assertTrue();
expect(testMouseEvent.fnKey).assertTrue();
expect(testMouseEvent.capsLock).assertTrue();
expect(testMouseEvent.numLock).assertTrue();
expect(testMouseEvent.scrollLock).assertTrue();
console.info(`MultimodalInput_test::MouseEventTypeTest_0050 exit`);
})
it('MultimodalInput_test::TouchEventTypeTest_0010', 0, function () {
console.info(`MultimodalInput_test::TouchEventTypeTest_0010 enter`);
expect(touchEvent.Action.CANCEL == 0).assertTrue();
expect(touchEvent.Action.DOWN == 1).assertTrue();
expect(touchEvent.Action.MOVE == 2).assertTrue();
expect(touchEvent.Action.UP == 3).assertTrue();
console.info(`MultimodalInput_test::TouchEventTypeTest_0010 exit`);
})
it('MultimodalInput_test::TouchEventTypeTest_0020', 0, function () {
console.info(`MultimodalInput_test::TouchEventTypeTest_0020 enter`);
expect(touchEvent.ToolType.FINGER == 0).assertTrue();
expect(touchEvent.ToolType.PEN == 1).assertTrue();
expect(touchEvent.ToolType.RUBBER == 2).assertTrue();
expect(touchEvent.ToolType.BRUSH == 3).assertTrue();
expect(touchEvent.ToolType.PENCIL == 4).assertTrue();
expect(touchEvent.ToolType.AIRBRUSH == 5).assertTrue();
expect(touchEvent.ToolType.MOUSE == 6).assertTrue();
expect(touchEvent.ToolType.LENS == 7).assertTrue();
console.info(`MultimodalInput_test::TouchEventTypeTest_0020 exit`);
})
it('MultimodalInput_test::TouchEventTypeTest_0030', 0, function () {
console.info(`MultimodalInput_test::TouchEventTypeTest_0030 enter`);
expect(touchEvent.SourceType.TOUCH_SCREEN == 0).assertTrue();
expect(touchEvent.SourceType.PEN == 1).assertTrue();
expect(touchEvent.SourceType.TOUCH_PAD == 2).assertTrue();
console.info(`MultimodalInput_test::TouchEventTypeTest_0030 exit`);
})
it('MultimodalInput_test::TouchEventTypeTest_0040', 0, function () {
console.info(`MultimodalInput_test::TouchEventTypeTest_0040 enter`);
let testTouch: Touch = {
id: 1, pressedTime: 1, screenX: 1, screenY: 1, windowX: 1, windowY: 1, pressure: 1,
width: 1, height: 1, tiltX: 1, tiltY: 1, toolX: 1, toolY: 1, toolWidth: 1, toolHeight: 1, rawX: 1,
rawY: 1, toolType: touchEvent.ToolType.FINGER
};
expect(testTouch.id == 1).assertTrue();
expect(testTouch.pressedTime == 1).assertTrue();
expect(testTouch.screenX == 1).assertTrue();
expect(testTouch.screenY == 1).assertTrue();
expect(testTouch.windowX == 1).assertTrue();
expect(testTouch.windowY == 1).assertTrue();
expect(testTouch.pressure == 1).assertTrue();
expect(testTouch.width == 1).assertTrue();
expect(testTouch.height == 1).assertTrue();
expect(testTouch.tiltX == 1).assertTrue();
expect(testTouch.tiltY == 1).assertTrue();
expect(testTouch.toolX == 1).assertTrue();
expect(testTouch.toolY == 1).assertTrue();
expect(testTouch.toolWidth == 1).assertTrue();
expect(testTouch.toolHeight == 1).assertTrue();
expect(testTouch.rawX == 1).assertTrue();
expect(testTouch.rawY == 1).assertTrue();
expect(testTouch.toolType == touchEvent.ToolType.FINGER).assertTrue();
console.info(`MultimodalInput_test::TouchEventTypeTest_0040 exit`);
})
it('MultimodalInput_test::TouchEventTypeTest_0050', 0, function () {
console.info(`MultimodalInput_test::TouchEventTypeTest_0050 enter`);
let testTouch: Touch = {
id: 1, pressedTime: 1, screenX: 1, screenY: 1, windowX: 1, windowY: 1, pressure: 1,
width: 1, height: 1, tiltX: 1, tiltY: 1, toolX: 1, toolY: 1, toolWidth: 1, toolHeight: 1, rawX: 1,
rawY: 1, toolType: touchEvent.ToolType.FINGER
};
let testTouchEvent: TouchEvent = {
id: 1, deviceId: 1, actionTime: 1, screenId: 1, windowId: 1,
action: touchEvent.Action.CANCEL, touch: testTouch, touches: [testTouch],
sourceType: touchEvent.SourceType.TOUCH_SCREEN
};
expect(testTouchEvent.action == touchEvent.Action.CANCEL).assertTrue();
expect(testTouchEvent.touch.id == 1).assertTrue();
expect(testTouchEvent.touches[0].id == 1).assertTrue();
expect(testTouchEvent.sourceType == touchEvent.SourceType.TOUCH_SCREEN).assertTrue();
console.info(`MultimodalInput_test::TouchEventTypeTest_0050 exit`);
})
})
}
// @ts-nocheck
/**
* 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.
*/
export default class Utils {
static rect_left;
static rect_top;
static rect_right;
static rect_bottom;
static rect_value;
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
static getComponentRect(key) {
let strJson = getInspectorByKey(key);
let obj = JSON.parse(strJson);
console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj));
let rectInfo = JSON.parse('[' + obj.$rect + ']')
console.info("[getInspectorByKey] rectInfo is: " + rectInfo);
this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1]
return this.rect_value = {
"left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom
}
}
static async swipe(downX, downY, upX, upY, steps) {
console.info('start to swipe')
this.drags(downX, downY, upX, upY, steps, false)
}
static async drag(downX, downY, upX, upY, steps) {
console.info('start to drag')
this.drags(downX, downY, upX, upY, steps, true)
}
static async drags(downX, downY, upX, upY, steps, drag) {
var xStep;
var yStep;
var swipeSteps;
var ret;
xStep = 0;
yStep = 0;
ret = false;
swipeSteps = steps;
if (swipeSteps == 0) {
swipeSteps = 1;
}
xStep = (upX - downX) / swipeSteps;
yStep = (upY - downY) / swipeSteps;
console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep)
var downPonit: TouchObject = {
id: 1,
x: downX,
y: downY,
type: TouchType.Down,
}
console.info('down touch started: ' + JSON.stringify(downPonit))
sendTouchEvent(downPonit);
console.info('start to move')
if (drag) {
await this.sleep(500)
}
for (var i = 1;i <= swipeSteps; i++) {
var movePoint: TouchObject = {
id: 1,
x: downX + (xStep * i),
y: downY + (yStep * i),
type: TouchType.Move
}
console.info('move touch started: ' + JSON.stringify(movePoint))
ret = sendTouchEvent(movePoint)
if (ret == false) {
break;
}
await this.sleep(5)
}
console.info('start to up')
if (drag) {
await this.sleep(100)
}
var upPoint: TouchObject = {
id: 1,
x: upX,
y: upY,
type: TouchType.Up,
}
console.info('up touch started: ' + JSON.stringify(upPoint))
sendTouchEvent(upPoint)
await this.sleep(500)
}
}
{
"color": [
{
"name": "color_hello",
"value": "#ffff0000"
},
{
"name": "color_world",
"value": "#ff0000ff"
}
]
}
\ No newline at end of file
{
"float":[
{
"name":"font_hello",
"value":"28.0fp"
},
{
"name":"font_world",
"value":"20.0fp"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
},
{
"name":"string_hello",
"value":"Hello"
},
{
"name":"string_world",
"value":"World"
},
{
"name":"message_arrive",
"value":"We will arrive at %s."
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册