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

!2504 add inputMethod

Merge pull request !2504 from 安宁/master
......@@ -15,6 +15,7 @@ import("//build/ohos_var.gni")
group("miscservices") {
testonly = true
deps = [
"InputMethodTest_ets:inputMethod_ets_test",
"PasteBoardTest_js:pasteboard_js_test",
"TimeTest_js:time_js_test",
"TimerTest_js:timer_js_test",
......
# 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("inputMethod_ets_test") {
hap_profile = "./entry/src/main/config.json"
deps = [
":inputMethod_ets_assets",
":inputMethod_ets_resources",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "InputMethodEtsTest"
}
ohos_js_assets("inputMethod_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_resources("inputMethod_ets_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for inputMethod Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "600000",
"package": "com.open.harmony.inputMethodtest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"InputMethodEtsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.open.harmony.inputMethodtest",
"vendor": "open",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 7
}
},
"deviceConfig": {},
"module": {
"package": "com.open.harmony.inputMethodtest",
"name": ".MyApplication",
"mainAbility": "com.open.harmony.inputMethodtest.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"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index",
"pages/input"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
/**
* 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 {
onCreate() {
console.info('Application onCreate')
},
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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets";
import testsuite from "../test/List.test.ets";
import featureAbility from "@ohos.ability.featureAbility";
@Entry
@Component
struct MyComponent {
aboutToAppear() {
console.info("start run testcase!!!!")
featureAbility.getWant()
.then((Want) => {
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
console.info('parameters---->' + JSON.stringify(Want.parameters));
configService.setConfig(Want.parameters);
testsuite();
core.execute();
console.info('Operation successful. Data: ' + JSON.stringify(Want));
})
.catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
}
build() {
Flex({
direction: FlexDirection.Column,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Center
}) {
Text('ACE ETS TEST')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
// @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 TextInputTest {
@State text: string = '';
build() {
Column() {
TextInput({ placeholder: 'input your word' })
.type(InputType.Normal)
.key('TextInput')
.placeholderColor(Color.Blue)
.placeholderFont({ size: 40, weight: FontWeight.Normal, family: "sans-serif", style: FontStyle.Normal })
.enterKeyType(EnterKeyType.Search)
.caretColor(Color.Green)
.height(60)
.fontSize(30)
.fontWeight(FontWeight.Bold)
.fontFamily("cursive")
.fontStyle(FontStyle.Italic)
.fontColor(Color.Red)
.maxLength(20)
.onChange((value: string) => {
this.text = value
})
Text(this.text)
}
}
}
// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets";
import inputMethodEngine from '@ohos.inputMethodEngine';
import Utils from './Utils';
import router from '@system.router';
import events_emitter from '@ohos.events.emitter';
export default function inputMethodEngineJsunit() {
describe('appInfoTest', function () {
var mKeyboardDelegate = null;
var inputMethodEngineObject = inputMethodEngine.getInputMethodEngine();
var textInputClient = null;
var kbController = null;
console.log("************* inputMethodEngine Test start*************");
beforeEach(async function (done) {
let options = {
uri: 'pages/input',
}
try {
router.clear();
let pages = router.getState();
if (!("input" == pages.name)) {
let result = await router.push(options);
await Utils.sleep(1000);
}
} catch (err) {
console.error("push input page error: " + err);
}
done();
});
afterEach(async function () {
console.log("inputMethodEngine afterEach start:" + inputMethodEngineObject);
await Utils.sleep(1000);
});
it('inputMethodEngine_test_000', 0, async function (done) {
inputMethodEngineObject.on('inputStart', (kbController, textInputClient) => {
console.log("inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController));
console.log("inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient));
textInputClient = textInputClient;
kbController = kbController;
});
inputMethodEngineObject.on('keyboardShow', (err) => {
console.log("inputMethodEngine beforeEach keyboardShow:" + err);
});
inputMethodEngineObject.on('keyboardHide', (err) => {
console.log("inputMethodEngine beforeEach keyboardHide:" + err);
});
mKeyboardDelegate = inputMethodEngine.createKeyboardDelegate();
mKeyboardDelegate.on('keyDown', (keyEvent) => {
console.log("inputMethodEngine beforeEach keyDown:" + keyEvent);
expect(keyEvent.keyCode).assertEqual('1');
});
mKeyboardDelegate.on('keyUp', (keyEvent) => {
console.log("inputMethodEngine beforeEach keyUp:" + keyEvent.keyCode);
expect(keyEvent.keyCode).assertEqual('1');
});
mKeyboardDelegate.on('cursorContextChange', (x, y, height) => {
console.log("inputMethodEngine beforeEach cursorContextChange x:" + x);
console.log("inputMethodEngine beforeEach cursorContextChange y:" + y);
console.log("inputMethodEngine beforeEach cursorContextChange height:" + height);
});
mKeyboardDelegate.on('selectionChange', (oldBegin, oldEnd, newBegin, newEnd) => {
console.log("inputMethodEngine beforeEach selectionChange oldBegin:" + oldBegin);
console.log("inputMethodEngine beforeEach selectionChange oldEnd:" + oldEnd);
console.log("inputMethodEngine beforeEach selectionChange newBegin:" + newBegin);
console.log("inputMethodEngine beforeEach selectionChange newEnd:" + newEnd);
});
mKeyboardDelegate.on('textChange', (text) => {
console.log("inputMethodEngine beforeEach textChange:" + text);
});
done();
});
it('inputMethodEngine_test_001', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_UNSPECIFIED;
console.log("inputMethodEngine_test_001 result:" + keyType);
expect(keyType).assertEqual(0);
done();
});
it('inputMethodEngine_test_002', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_GO;
console.log("inputMethodEngine_test_002 result:" + keyType);
expect(keyType).assertEqual(2);
done();
});
it('inputMethodEngine_test_003', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_SEARCH;
console.log("inputMethodEngine_test_003 result:" + keyType);
expect(keyType).assertEqual(3);
done();
});
it('inputMethodEngine_test_004', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_SEND;
console.log("inputMethodEngine_test_004 result:" + keyType);
expect(keyType).assertEqual(4);
done();
});
it('inputMethodEngine_test_005', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_NEXT;
console.log("inputMethodEngine_test_005 result:" + keyType);
expect(keyType).assertEqual(5);
done();
});
it('inputMethodEngine_test_006', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_DONE;
console.log("inputMethodEngine_test_006 result:" + keyType);
expect(keyType).assertEqual(6);
done();
});
it('inputMethodEngine_test_007', 0, async function (done) {
let keyType = inputMethodEngine.ENTER_KEY_TYPE_PREVIOUS;
console.log("inputMethodEngine_test_007 result:" + keyType);
expect(keyType).assertEqual(7);
done();
});
it('inputMethodEngine_test_008', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_NULL;
console.log("inputMethodEngine_test_008 result:" + keyType);
expect(keyType).assertEqual(-1);
done();
});
it('inputMethodEngine_test_009', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_TEXT;
console.log("inputMethodEngine_test_009 result:" + keyType);
expect(keyType).assertEqual(0);
done();
});
it('inputMethodEngine_test_010', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_NUMBER;
console.log("inputMethodEngine_test_010 result:" + keyType);
expect(keyType).assertEqual(2);
done();
});
it('inputMethodEngine_test_011', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_PHONE;
console.log("inputMethodEngine_test_011 result:" + keyType);
expect(keyType).assertEqual(3);
done();
});
it('inputMethodEngine_test_012', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_DATETIME;
console.log("inputMethodEngine_test_012 result:" + keyType);
expect(keyType).assertEqual(4);
done();
});
it('inputMethodEngine_test_013', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_EMAIL;
console.log("inputMethodEngine_test_013 result:" + keyType);
expect(keyType).assertEqual(5);
done();
});
it('inputMethodEngine_test_014', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_URI;
console.log("inputMethodEngine_test_014 result:" + keyType);
expect(keyType).assertEqual(6);
done();
});
it('inputMethodEngine_test_015', 0, async function (done) {
let keyType = inputMethodEngine.PATTERN_PASSWORD;
console.log("inputMethodEngine_test_015 result:" + keyType);
expect(keyType).assertEqual(7);
done();
});
it('inputMethodEngine_test_016', 0, async function (done) {
let keyType = inputMethodEngine.FLAG_SELECTING;
console.log("inputMethodEngine_test_016 result:" + keyType);
expect(keyType).assertEqual(2);
done();
});
it('inputMethodEngine_test_017', 0, async function (done) {
let keyType = inputMethodEngine.FLAG_SINGLE_LINE;
console.log("inputMethodEngine_test_017 result:" + keyType);
expect(keyType).assertEqual(1);
done();
});
it('inputMethodEngine_test_018', 0, async function (done) {
let keyType = inputMethodEngine.DISPLAY_MODE_PART;
console.log("inputMethodEngine_test_018 result:" + keyType);
expect(keyType).assertEqual(0);
done();
});
it('inputMethodEngine_test_019', 0, async function (done) {
let keyType = inputMethodEngine.DISPLAY_MODE_FULL;
console.log("inputMethodEngine_test_019 result:" + keyType);
expect(keyType).assertEqual(1);
done();
});
it('inputMethodEngine_test_020', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_ASCII;
console.log("inputMethodEngine_test_020 result:" + keyType);
expect(keyType).assertEqual(20);
done();
});
it('inputMethodEngine_test_021', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_NONE;
console.log("inputMethodEngine_test_021 result:" + keyType);
expect(keyType).assertEqual(0);
done();
});
it('inputMethodEngine_test_022', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_AUTO_CAP_CHARACTERS;
console.log("inputMethodEngine_test_022 result:" + keyType);
expect(keyType).assertEqual(2);
done();
});
it('inputMethodEngine_test_023', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_AUTO_CAP_SENTENCES;
console.log("inputMethodEngine_test_023 result:" + keyType);
expect(keyType).assertEqual(8);
done();
});
it('inputMethodEngine_test_024', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_AUTO_WORDS;
console.log("inputMethodEngine_test_024 result:" + keyType);
expect(keyType).assertEqual(4);
done();
});
it('inputMethodEngine_test_025', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_MULTI_LINE;
console.log("inputMethodEngine_test_025 result:" + keyType);
expect(keyType).assertEqual(1);
done();
});
it('inputMethodEngine_test_026', 0, async function (done) {
let keyType = inputMethodEngine.OPTION_NO_FULLSCREEN;
console.log("inputMethodEngine_test_026 result:" + keyType);
expect(keyType).assertEqual(10);
done();
});
it('inputMethodEngine_test_027', 0, async function (done) {
let rect = await Utils.getComponentRect('TextInput')
console.info("[inputMethodEngine_test_027] rectInfo is " + JSON.stringify(rect));
let x_value = rect.left + (rect.right - rect.left) / 10
let y_value = rect.top + (rect.bottom - rect.top) / 10
console.info("[inputMethodEngine_test_027] onTouch location is: " + "[x]=== " + x_value + " [y]===" + y_value);
let point: TouchObject = {
id: 1,
x: x_value,
y: y_value,
type: TouchType.Move,
}
console.info('[inputMethodEngine_test_027] testSendTouchEvent ' + sendTouchEvent(point));
await Utils.sleep(1000)
console.info('[inputMethodEngine_test_027] END');
done();
});
it('inputMethodEngine_test_028', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.sendKeyFunction(0, (value) => {
console.log("inputMethodEngine_test_028 textInputClient sendKeyFunction:" + value);
expect(value).assertEqual(true);
});
}
done();
});
it('inputMethodEngine_test_029', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
let promise = textInputClient.sendKeyFunction(0);
promise.then(res => {
console.info("inputMethodEngine_test_029 listInputMethod promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true);
}).catch(err => {
console.info("inputMethodEngine_test_029 listInputMethod promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_030', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.deleteForward(1, (value) => {
console.log("inputMethodEngine_test_030 deleteForward:" + value);
expect(value).assertEqual(true);
});
}
done();
});
it('inputMethodEngine_test_031', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
let promise = textInputClient.deleteForward(1);
promise.then(res => {
console.info("inputMethodEngine_test_031 deleteForward promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true);
}).catch(err => {
console.info("inputMethodEngine_test_031 deleteForward promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_032', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.deleteBackward(1, (value) => {
console.log("inputMethodEngine_test_032 deleteBackward:" + value);
expect(value).assertEqual(true);
});
}
done();
});
it('inputMethodEngine_test_033', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
let promise = textInputClient.deleteBackward(1);
promise.then(res => {
console.info("inputMethodEngine_test_033 deleteBackward promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true);
}).catch(err => {
console.info("inputMethodEngine_test_033 deleteBackward promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_034', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.InsertText('test', (value) => {
console.log("inputMethodEngine_test_034 InsertText:" + value);
expect(value).assertEqual(true);
});
}
done();
});
it('inputMethodEngine_test_035', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
let promise = textInputClient.InsertText('test');
promise.then(res => {
console.info("inputMethodEngine_test_035 InsertText promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true);
}).catch(err => {
console.info("inputMethodEngine_test_035 InsertText promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_036', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.getForward(1, (value) => {
console.log("inputMethodEngine_test_036 getForward:" + value);
expect(value).assertEqual(true);
});
}
done();
});
it('inputMethodEngine_test_037', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
let promise = textInputClient.getForward(1);
promise.then(res => {
console.info("inputMethodEngine_test_037 getForward promise result-----" + JSON.stringify(res));
expect(res).assertEqual(true);
}).catch(err => {
console.info("inputMethodEngine_test_037 getForward promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_038', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
textInputClient.getEditorAttribute(1, (editorAttribute) => {
console.log("inputMethodEngine_test_036 getEditorAttribute:" + value);
expect(editorAttribute.inputPattern).assertEqual(1);
expect(editorAttribute.enterKeyType).assertEqual(1);
});
}
done();
});
it('inputMethodEngine_test_039', 0, async function (done) {
if (textInputClient == null) {
expect(textInputClient == null).assertEqual(true);
} else {
let promise = textInputClient.getEditorAttribute();
promise.then(res => {
console.info("inputMethodEngine_test_037 getEditorAttribute promise result-----" + JSON.stringify(res));
expect(res.inputPattern).assertEqual(1);
expect(res.enterKeyType).assertEqual(1);
}).catch(err => {
console.info("inputMethodEngine_test_037 getEditorAttribute promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
it('inputMethodEngine_test_040', 0, async function (done) {
if (kbController == null) {
expect(kbController == null).assertEqual(true);
} else {
kbController.hideKeyboard(() => {
console.log("inputMethodEngine_test_040 hideKeyboard:" + value);
expect(1 == 1).assertTrue();
});
}
done();
});
it('inputMethodEngine_test_041', 0, async function (done) {
if (kbController == null) {
expect(kbController == null).assertEqual(true);
} else {
let promise = kbController.hideKeyboard();
promise.then(res => {
console.info("inputMethodEngine_test_037 hideKeyboard promise result-----" + JSON.stringify(res));
expect(1 == 1).assertTrue();
}).catch(err => {
console.info("inputMethodEngine_test_037 hideKeyboard promise error----" + JSON.stringify(err));
expect().assertFail();
});
}
done();
});
})
}
// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets";
import inputmeth from '@ohos.inputmethod';
export default function settingUiJsunit() {
describe('appInfoTest', function () {
console.log("************* settings Test start*************");
it('inputmethoh_test_001', 0, async function (done) {
let inputMethodSetting = inputmeth.getInputMethodSetting();
console.log("inputmethoh_test_001 result:" + JSON.stringify(inputMethodSetting));
inputMethodSetting.listInputMethod((arr) => {
console.info("inputmethoh_test_001 listInputMethod result---" + JSON.stringify(arr));
expect(1==1).assertTrue();
});
done();
});
it('inputmethoh_test_002', 0, async function (done) {
let inputMethodSetting = inputmeth.getInputMethodSetting();
console.log("inputmethoh_test_002 result:" + JSON.stringify(inputMethodSetting));
let promise = inputMethodSetting.listInputMethod();
console.info("inputmethoh_test_002 listInputMethod result---" + JSON.stringify(promise));
let obj = promise[0];
console.info("inputmethoh_test_002 listInputMethod obj---" + JSON.stringify(obj));
expect(obj.packageName=='com.example.kikakeyboard').assertTrue();
expect(obj.methodId=='ServiceExtAbility').assertTrue();
done();
});
it('inputmethoh_test_003', 0, async function (done) {
let inputMethodSetting = inputmeth.getInputMethodSetting();
console.log("inputmethoh_test_003 result:" + JSON.stringify(inputMethodSetting));
inputMethodSetting.displayOptionalInputMethod(() => {
console.info("inputmethoh_test_003 displayOptionalInputMethod---");
});
done();
});
it('inputmethoh_test_004', 0, async function (done) {
let inputMethodSetting = inputmeth.getInputMethodSetting();
console.log("inputmethoh_test_004 result:" + JSON.stringify(inputMethodSetting));
let promise = inputMethodSetting.displayOptionalInputMethod();
console.info("inputmethoh_test_004 displayOptionalInputMethod result---" + JSON.stringify(promise));
expect(promise).assertEqual(undefined)
done();
});
it('inputmethoh_test_005', 0, async function (done) {
let inputMethodCtrl = inputmeth.getInputMethodController();
console.log("inputmethoh_test_005 result:" + JSON.stringify(inputMethodCtrl));
inputMethodCtrl.stopInput((res) => {
console.info("inputmethoh_test_005 stopInput result----" + res);
});
done();
});
it('inputmethoh_test_006', 0, async function (done) {
let inputMethodCtrl = inputmeth.getInputMethodController();
console.log("inputmethoh_test_006 result:" + JSON.stringify(inputMethodCtrl));
let promise = inputMethodCtrl.stopInput();
console.info("inputmethoh_test_006 inputMethodCtrl stopInput result---" + JSON.stringify(promise));
expect(promise).assertEqual(true)
done();
});
})
}
/**
* 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 inputmethohJsunit from './InputmethohJsunit.test.ets';
import inputmethodEngineJsunit from './InputmethodEngineJsunit.test.ets';
export default function testsuite() {
inputmethohJsunit();
inputmethodEngineJsunit();
}
\ 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.
*/
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)
}
}
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
},
{
"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.
先完成此消息的编辑!
想要评论请 注册