diff --git a/multimodalinput/BUILD.gn b/multimodalinput/BUILD.gn index f82002374996e059ef6ea71ae8da9be04241579d..8cb3da8a1de0452540514c6e92799820a0e56add 100644 --- a/multimodalinput/BUILD.gn +++ b/multimodalinput/BUILD.gn @@ -16,6 +16,9 @@ import("//build/ohos_var.gni") group("multimodalinput") { testonly = true if (is_standard_system) { - deps = [ "input_js_standard:multimodalinput_js_test" ] + deps = [ + "input_js_standard:multimodalinput_js_test", + "multimodalinput_ets_standard:ActsMultimodalInputEtsTest", + ] } } diff --git a/multimodalinput/multimodalinput_ets_standard/BUILD.gn b/multimodalinput/multimodalinput_ets_standard/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..4de5f9aff0f0ae18a77d1c2bbae15e3a203b459e --- /dev/null +++ b/multimodalinput/multimodalinput_ets_standard/BUILD.gn @@ -0,0 +1,36 @@ +# 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" +} diff --git a/multimodalinput/multimodalinput_ets_standard/Test.json b/multimodalinput/multimodalinput_ets_standard/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..a8c9872210131e99af0555bad0550a6c67442184 --- /dev/null +++ b/multimodalinput/multimodalinput_ets_standard/Test.json @@ -0,0 +1,19 @@ +{ + "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 diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/config.json b/multimodalinput/multimodalinput_ets_standard/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..d2c26caa769322b30c573d3101937c24d098768d --- /dev/null +++ b/multimodalinput/multimodalinput_ets_standard/entry/src/main/config.json @@ -0,0 +1,98 @@ +{ + "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 diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/MainAbility/app.ets b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/MainAbility/app.ets new file mode 100755 index 0000000000000000000000000000000000000000..b917b80ff7cabb5078dd7a9d9bf546c510bd86d7 --- /dev/null +++ b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,33 @@ +// @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 diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/MainAbility/pages/index.ets b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..75987b30d85a509675937a8c615cf760364af546 --- /dev/null +++ b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,36 @@ +// @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 diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/TestAbility/app.ets b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/TestAbility/app.ets new file mode 100755 index 0000000000000000000000000000000000000000..b917b80ff7cabb5078dd7a9d9bf546c510bd86d7 --- /dev/null +++ b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,33 @@ +// @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 diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/TestAbility/pages/index.ets b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..f87ca6e18f4a4dd9c1804b8edabe664029341e78 --- /dev/null +++ b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,50 @@ +// @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 diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100755 index 0000000000000000000000000000000000000000..dfbf1f268a45e4a2f30b8c836f42d76f3a9f5ad3 --- /dev/null +++ b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +// @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 diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/test/List.test.ets b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..815e544c72a17f618b7c70a45ae3847f6eb3bda4 --- /dev/null +++ b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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 diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/test/MultimodalInputEventType.test.ets b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/test/MultimodalInputEventType.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..fc08c8412d1bd699a50d2acf107fb2334f425a29 --- /dev/null +++ b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/test/MultimodalInputEventType.test.ets @@ -0,0 +1,303 @@ +/* + * 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`); + }) + }) +} diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/test/Utils.ets b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/test/Utils.ets new file mode 100755 index 0000000000000000000000000000000000000000..0f4b16d766f1feeb75edd8cc84cd1448d61e569a --- /dev/null +++ b/multimodalinput/multimodalinput_ets_standard/entry/src/main/ets/test/Utils.ets @@ -0,0 +1,118 @@ +// @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) + } +} + + + + diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/base/element/color.json b/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/base/element/color.json new file mode 100755 index 0000000000000000000000000000000000000000..07a14d2b8dcf50dae012854d8310c489dfd7391c --- /dev/null +++ b/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/base/element/color.json @@ -0,0 +1,12 @@ +{ + "color": [ + { + "name": "color_hello", + "value": "#ffff0000" + }, + { + "name": "color_world", + "value": "#ff0000ff" + } + ] +} \ No newline at end of file diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/base/element/float.json b/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/base/element/float.json new file mode 100755 index 0000000000000000000000000000000000000000..26a0491a2b293d8296d4de4d55c8d682527b6c6b --- /dev/null +++ b/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/base/element/float.json @@ -0,0 +1,12 @@ +{ + "float":[ + { + "name":"font_hello", + "value":"28.0fp" + }, + { + "name":"font_world", + "value":"20.0fp" + } + ] +} \ No newline at end of file diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/base/element/string.json b/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..f6488bb9ccc6588f4a68440a5a320c1d2d952a99 --- /dev/null +++ b/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "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 diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/base/media/icon.png b/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/base/media/icon.png differ diff --git a/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/rawfile/test.png b/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/rawfile/test.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/multimodalinput/multimodalinput_ets_standard/entry/src/main/resources/rawfile/test.png differ diff --git a/multimodalinput/multimodalinput_ets_standard/signature/openharmony_sx.p7b b/multimodalinput/multimodalinput_ets_standard/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/multimodalinput/multimodalinput_ets_standard/signature/openharmony_sx.p7b differ