提交 96bf4d76 编写于 作者: Z zhangyushuai

add input 自绘控件 004

Signed-off-by: Nzhangyushuai <zhangyushuai1@huawei.com>
上级 733ada9e
......@@ -16,6 +16,7 @@ group("inputmethod") {
testonly = true
deps = [
"InputMethodAuthorityTest:ActsInputMethodAuthorityTest",
"InputMethodDrawnControl:ActsInputMethodDrawnControlTest",
"InputMethodEngine:ActsInputMethodEngineTest",
"InputMethodTest_Stage:ActsImeAbilityTest",
"InputMethodTest_ets:ActsInputMethodEtsTest",
......
{
"app":{
"bundleName":"com.acts.inputmethoddrawncontrol.test",
"vendor":"hw",
"versionCode":1000000,
"versionName":"1.0.0",
"debug":false,
"icon":"$media:icon",
"label":"$string:app_name",
"description":"$string:description_application",
"distributedNotificationEnabled":true,
"keepAlive":true,
"singleUser":true,
"minAPIVersion":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ActsInputMethodDrawnControlTest"
}
]
}
\ 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsInputMethodDrawnControlTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":IMExtAbility_ets_assets",
":IMExtAbility_resources",
]
ets2abc = true
certificate_profile = "signature/ActsInputMethodDrawnControlTest.p7b"
hap_name = "ActsInputMethodDrawnControlTest"
subsystem_name = "inputmethod"
part_name = "imf"
}
ohos_app_scope("IMExtAbility_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("IMExtAbility_ets_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("IMExtAbility_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":IMExtAbility_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "com.acts.inputmethoddrawncontrol.test",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 15000
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602",
"uinput -T -m 300 720 300 360 200",
"uinput -T -m 650 2760 650 1380 200"
]
},
{
"test-file-name": [
"ActsInputMethodDrawnControlTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* Copyright (c) 2023 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 AbilityStage from "@ohos.app.ability.AbilityStage";
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate");
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
/*
* Copyright (c) 2023 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 Ability from '@ohos.app.ability.UIAbility';
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.info("ImExtAbility onCreate");
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.info("ImExtAbility onDestroy");
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.info("ImExtAbility onWindowStageCreate");
globalThis.abilityContext = this.context;
windowStage.setUIContent(this.context, "pages/index/index", null);
console.info("ImExtAbility onWindowStageCreate finish");
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.info("ImExtAbility onWindowStageDestroy");
}
onForeground() {
// Ability has brought to foreground
console.info("ImExtAbility onForeground");
}
onBackground() {
// Ability has back to background
console.info("ImExtAbility onBackground");
}
};
\ No newline at end of file
/*
* Copyright (c) 2023 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 it',
'-s level', '-s testType', '-s size', '-s timeout',
'-s dryRun'
]);
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${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 ");
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility';
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback);
var cmd = 'aa start -d 0 -a com.acts.inputmethoddrawncontrol.test.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName;
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters);
var debug = abilityDelegatorArguments.parameters["-D"];
if (debug === 'true')
{
cmd += ' -D';
}
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 end');
}
};
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../test/List.test'
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
@State inputValue: string = 'inputMethodEngine1inputMethodEngine2inputMethodEngine3inputMethodEngine' +
'inputMethodEngine4inputMethodEngine5inputMethodEngine6inputMethodEngine7inputMethodEngine8inputMethodEn' +
'gine9inputMethodEngine10inputMethodEngine11inputMethodEngine12inputMethodEngine13inputMethodEngine14inputMet' +
'hodEngine15inputMethodEngine16inputMethodEngine17inputMethodEngine18inputMethodEngine19inputMethodEngine20inputMethodEngine21';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.defaultFocus(true)
TextArea({ text: this.inputValue })
.onChange((value: string) => {
this.inputValue = value;
})
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%')
}
aboutToAppear(){
let abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 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 Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 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 inputMethod_attach from './inputMethod_attach.test'
import inputMethod_showTextInput_hideTextInput_detach from './inputMethod_showTextInput_hideTextInput_detach.test'
import inputMethod_updateAttribute from './inputMethod_updateAttribute.test'
import inputMethod_changeSelection from './inputMethod_changeSelection.test'
import inputMethod_updateCursor from './inputMethod_updateCursor.test'
import inputMethod_setCallingWindow from './inputMethod_setCallingWindow.test'
export default function testsuite() {
inputMethod_attach();
inputMethod_showTextInput_hideTextInput_detach();
inputMethod_updateAttribute();
inputMethod_changeSelection();
inputMethod_updateCursor();
inputMethod_setCallingWindow();
}
\ No newline at end of file
//@ts-nocheck
/*
* Copyright (c) 2023 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 inputMethod from '@ohos.inputmethod';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import * as env from './lib/Const';
export default function inputMethodTest() {
describe('inputMethod_attach', function () {
function expectTrue(data) {
try {
expect(data).assertTrue();
}catch (err){
console.info('assertion failure');
}
};
function expectContain(a,b) {
try {
expect(a).assertContain(b);
}catch (err){
console.info('assertion failure');
}
};
function expectFalse() {
try {
expect().assertFail();
}catch (err){
console.info('assertion failure');
}
};
let st = null as any;
const sleep = function (timeout) {
return new Promise(resolve => {
const st = setTimeout(() => {
resolve(null);
}, timeout);
});
};
afterEach(async function(){
clearTimeout(st);
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Async_0100
* @tc.name Call the attach interface in Async mode. Optional input parameter showkeyboard=true
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Async_0100',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Async_0100';
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
let CallBack:any = (error,data)=>{
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().attach(true,ATTRIBUTE,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Async_0200
* @tc.name Call the attach interface in Async mode. Optional input parameter showkeyboard=false
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Async_0200',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Async_0200';
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
let CallBack:any = (error,data)=>{
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().attach(false,ATTRIBUTE,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Async_0300
* @tc.name Call the attach interface in Async mode. Optional input parameter showkeyboard=0
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Async_0300',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Async_0300';
const SHOW_KEYBOARD:any = 0;
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
let CallBack:any = (error,data)=>{
if (error) {
console.info(`${CASE_NAME} execution fail,expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
inputMethod.getController().attach(SHOW_KEYBOARD,ATTRIBUTE,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Async_0400
* @tc.name Call the attach interface in Async mode. Optional input parameter showkeyboard=1
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Async_0400',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Async_0400';
const SHOW_KEYBOARD:any = 1;
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
let CallBack:any = (error,data)=>{
if (error) {
console.info(`${CASE_NAME} execution fail,expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
inputMethod.getController().attach(SHOW_KEYBOARD,ATTRIBUTE,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Async_0500
* @tc.name Call the attach interface in Async mode. Optional input parameter showkeyboard='aa'
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Async_0500',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Async_0500';
const SHOW_KEYBOARD:any = 'aa';
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
let CallBack:any = (error,data)=>{
if (error) {
console.info(`${CASE_NAME} execution fail,expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
inputMethod.getController().attach(SHOW_KEYBOARD,ATTRIBUTE,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Async_0600
* @tc.name Call the attach interface in Async mode. Optional input parameters showkeyboard=true, attribute={}
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Async_0600',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Async_0600';
const ATTRIBUTE:any = {};
let CallBack:any = (error,data)=>{
if (error) {
console.info(`${CASE_NAME} execution fail,expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
inputMethod.getController().attach(true,ATTRIBUTE,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Async_0700
* @tc.name Call the attach interface in Async mode. Optional input parameters showkeyboard=true, attribute='aa'
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Async_0700',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Async_0700';
const ATTRIBUTE:any = 'aa';
let CallBack:any = (error,data)=>{
if (error) {
console.info(`${CASE_NAME} execution fail,expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
inputMethod.getController().attach(true,ATTRIBUTE,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Async_1000
* @tc.name Call the attach interface in Async mode and pass in an invalid input parameter
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Async_1000',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Async_1000';
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
let CallBack:any = (error,data)=>{
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().attach(true,ATTRIBUTE,CallBack,env.INVALID_TYPE_STRING_A);
}catch(error){
console.info(`${CASE_NAME} catch error,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Promise_0100
* @tc.name Call the attach interface in Promise mode. Optional input parameter showkeyboard=true
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Promise_0100',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Promise_0100';
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
try{
let data = await inputMethod.getController().attach(true,ATTRIBUTE);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Promise_0200
* @tc.name Call the attach interface in Promise mode. Optional input parameter showkeyboard=false
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Promise_0200',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Promise_0200';
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
try{
let data = await inputMethod.getController().attach(false,ATTRIBUTE);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Promise_0300
* @tc.name Call the attach interface in Promise mode. Optional input parameter showkeyboard=0
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Promise_0300',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Promise_0300';
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
const SHOW_KEYBOARD:any = 0;
try{
let data = await inputMethod.getController().attach(SHOW_KEYBOARD,ATTRIBUTE);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Promise_0400
* @tc.name Call the attach interface in Promise mode. Optional input parameter showkeyboard=1
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Promise_0400',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Promise_0400';
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
const SHOW_KEYBOARD:any = 1;
try{
let data = await inputMethod.getController().attach(SHOW_KEYBOARD,ATTRIBUTE);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Promise_0500
* @tc.name Call the attach interface in Promise mode. Optional input parameter showkeyboard='aa'
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Promise_0500',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Promise_0500';
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
const SHOW_KEYBOARD:any = 'aa';
try{
let data = await inputMethod.getController().attach(SHOW_KEYBOARD,ATTRIBUTE);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Promise_0600
* @tc.name Call the attach interface in Promise mode. Optional input parameters showkeyboard=true, attribute={}
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Promise_0600',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Promise_0600';
const ATTRIBUTE:any = {};
try{
let data = await inputMethod.getController().attach(true,ATTRIBUTE);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Promise_0700
* @tc.name Call the attach interface in Promise mode. Optional input parameters showkeyboard=true, attribute='aa'
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Promise_0700',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Promise_0700';
const ATTRIBUTE:any = 'aa';
try{
let data = await inputMethod.getController().attach(true,ATTRIBUTE);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_attach_Promise_1000
* @tc.name Call the attach interface in Promise mode and pass in an invalid input parameter
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_attach_Promise_1000',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_attach_Promise_1000';
const ATTRIBUTE:any = {inputAttribute:{textInputType:0,enterKeyType:0}}
try{
let data = await inputMethod.getController().attach(true,ATTRIBUTE,env.INVALID_TYPE_STRING_A);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
})
}
\ No newline at end of file
//@ts-nocheck
/*
* Copyright (c) 2023 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 inputMethod from '@ohos.inputmethod';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import * as env from './lib/Const';
export default function inputMethodTest() {
describe('inputMethod_setCallingWindow', function () {
function expectTrue(data) {
try {
expect(data).assertTrue();
}catch (err){
console.info('assertion failure');
}
};
function expectContain(a,b) {
try {
expect(a).assertContain(b);
}catch (err){
console.info('assertion failure');
}
};
function expectFalse() {
try {
expect().assertFail();
}catch (err){
console.info('assertion failure');
}
};
let st = null as any;
const sleep = function (timeout) {
return new Promise(resolve => {
const st = setTimeout(() => {
resolve(null);
}, timeout);
});
};
beforeEach(
async function (){
try{
let data = await inputMethod.getController().attach(true,{inputAttribute:{textInputType:1,enterKeyType:2}});
console.info(`attach inputMethod success, data: ${JSON.stringify(data)}`);
}catch(error){
console.info(`attach inputMethod fail, error: [${error.code}, ${error.message}]`);
};
}
);
afterEach(
async function (){
try{
await inputMethod.getController().detach();
console.info(`clsoe inputMethod success}`);
}catch(error){
console.info(`clsoe inputMethod fial, error: [${error.code}, ${error.message}]`);
};
clearTimeout(st);
}
);
/**
* @tc.number SUB_Misc_inputMethod_setCallingWindow_Async_0100
* @tc.name When calling the setCallingWindow interface in Async mode, the parameter windowId=5 must be passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_setCallingWindow_Async_0100',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_setCallingWindow_Async_0100';
const WINDOW_ID:any = 5;
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().setCallingWindow(WINDOW_ID,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_setCallingWindow_Async_0200
* @tc.name When calling the setCallingWindow interface in Async mode, the parameter windowId=0 must be passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_setCallingWindow_Async_0200',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_setCallingWindow_Async_0200';
const WINDOW_ID:any = 0;
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`);
expectFalse();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().setCallingWindow(WINDOW_ID,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_setCallingWindow_Async_0300
* @tc.name When calling the setCallingWindow interface in Async mode, the parameter windowId='5' must be
* passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_setCallingWindow_Async_0300',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_setCallingWindow_Async_0300';
const WINDOW_ID:any = '5';
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
inputMethod.getController().setCallingWindow(WINDOW_ID,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_setCallingWindow_Async_0600
* @tc.name The input method keyboard is not bound, and the setCallingWindow interface is called in Async mode
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_setCallingWindow_Async_0600',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_setCallingWindow_Async_0600';
const WINDOW_ID:any = 5;
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
let data = await inputMethod.getController().detach();
console.info(`${CASE_NAME} clsoe inputMethod success, data: ${JSON.stringify(data)}`);
}catch(error){
console.info(`${CASE_NAME} clsoe inputMethod fial, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
try{
inputMethod.getController().setCallingWindow(WINDOW_ID,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_setCallingWindow_Async_0700
* @tc.name Async mode calls the setCallingWindow interface, and an invalid input parameter is passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_setCallingWindow_Async_0700',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_setCallingWindow_Async_0700';
const WINDOW_ID:any = 5;
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().setCallingWindow(WINDOW_ID,CallBack,env.INVALID_TYPE_STRING_A);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_setCallingWindow_Async_0800
* @tc.name Async method calls the setCallingWindow interface. Missing parameter windowId must be passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_setCallingWindow_Async_0800',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_setCallingWindow_Async_0800';
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
inputMethod.getController().setCallingWindow(CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_setCallingWindow_Promise_0100
* @tc.name When calling the setCallingWindow interface in Promise mode, the parameter
* windowId=5 must be passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_setCallingWindow_Promise_0100',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_setCallingWindow_Promise_0100';
const WINDOW_ID:any = 5;
try{
let data = await inputMethod.getController().setCallingWindow(WINDOW_ID);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_setCallingWindow_Promise_0200
* @tc.name When calling the setCallingWindow interface in Promise mode, the parameter windowId=0 must be
* passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_setCallingWindow_Promise_0200',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_setCallingWindow_Promise_0200';
const WINDOW_ID:any = 0;
try{
let data = await inputMethod.getController().setCallingWindow(WINDOW_ID);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_setCallingWindow_Promise_0300
* @tc.name When calling the setCallingWindow interface in Promise mode, the parameter windowId='5' must be
* passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_setCallingWindow_Promise_0300',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_setCallingWindow_Promise_0300';
const WINDOW_ID:any = '5';
try{
let data = await inputMethod.getController().setCallingWindow(WINDOW_ID);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_setCallingWindow_Promise_0600
* @tc.name The input method keyboard is not bound, and the setCallingWindow interface is called in Promise mode
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_setCallingWindow_Promise_0600',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_setCallingWindow_Promise_0600';
const WINDOW_ID:any = 5;
try{
let data = await inputMethod.getController().detach();
console.info(`${CASE_NAME} clsoe inputMethod success, data: ${JSON.stringify(data)}`);
}catch(error){
console.info(`${CASE_NAME} clsoe inputMethod fial, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
try{
let data = await inputMethod.getController().setCallingWindow(WINDOW_ID);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_setCallingWindow_Promise_0700
* @tc.name Call setCallingWindow interface in Promise mode, and pass in an invalid input parameter
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_setCallingWindow_Promise_0700',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_setCallingWindow_Promise_0700';
const WINDOW_ID:any = 5;
try{
let data = await inputMethod.getController().setCallingWindow(WINDOW_ID,env.INVALID_TYPE_STRING_A);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_setCallingWindow_Promise_0800
* @tc.name The setCallingWindow interface is called in Promise mode, and the parameter windowId must be
* passed in if it is missing
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_setCallingWindow_Promise_0800',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_setCallingWindow_Promise_0800';
try{
let data = await inputMethod.getController().setCallingWindow();
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
})
}
\ No newline at end of file
//@ts-nocheck
/*
* Copyright (c) 2023 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 inputMethod from '@ohos.inputmethod';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import * as env from './lib/Const';
export default function inputMethodTest() {
describe('inputMethod_showTextInput_hideTextInput_detach', function () {
function expectTrue(data) {
try {
expect(data).assertTrue();
}catch (err){
console.info('assertion failure');
}
};
function expectContain(a,b) {
try {
expect(a).assertContain(b);
}catch (err){
console.info('assertion failure');
}
};
function expectFalse() {
try {
expect().assertFail();
}catch (err){
console.info('assertion failure');
}
};
let st = null as any;
const sleep = function (timeout) {
return new Promise(resolve => {
const st = setTimeout(() => {
resolve(null);
}, timeout);
});
};
beforeEach(
async function (){
try{
let data = await inputMethod.getController().attach(true,{inputAttribute:{textInputType:1,enterKeyType:2}});
console.info(`attach inputMethod success, data: ${JSON.stringify(data)}`);
}catch(error){
console.info(`attach inputMethod fail, error: [${error.code}, ${error.message}]`);
};
}
);
afterEach(
async function (){
try{
await inputMethod.getController().detach();
console.info(`clsoe inputMethod success}`);
}catch(error){
console.info(`clsoe inputMethod fial, error: [${error.code}, ${error.message}]`);
};
clearTimeout(st);
}
);
/**
* @tc.number SUB_Misc_inputMethod_showTextInput_Async_0100
* @tc.name Async mode calls the showTextInput interface without input parameters
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_showTextInput_Async_0100',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_showTextInput_Async_0100';
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().showTextInput(CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_showTextInput_Async_0400
* @tc.name Do not bind the input method keyboard, and call the showTextInput interface in Async mode
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_showTextInput_Async_0400',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_showTextInput_Async_0400';
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
let data = await inputMethod.getController().detach();
console.info(`${CASE_NAME} clsoe inputMethod success, data: ${JSON.stringify(data)}`);
}catch(error){
console.info(`${CASE_NAME} clsoe inputMethod fial, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
try{
inputMethod.getController().showTextInput(CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_showTextInput_Async_0500
* @tc.name Async method calls the showTextInput interface, and an invalid input parameter is passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_showTextInput_Async_0500',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_showTextInput_Async_0500';
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().showTextInput(CallBack,env.INVALID_TYPE_STRING_A);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_showTextInput_Promise_0100
* @tc.name Promise mode calls the showTextInput interface without input parameters
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_showTextInput_Promise_0100',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_showTextInput_Promise_0100';
try{
let data = await inputMethod.getController().showTextInput();
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_showTextInput_Promise_0400
* @tc.name Do not bind the input method keyboard, and call the showTextInput interface in Promise mode
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_showTextInput_Promise_0400',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_showTextInput_Promise_0400';
try{
let data = await inputMethod.getController().detach();
console.info(`${CASE_NAME} clsoe inputMethod success, data: ${JSON.stringify(data)}`);
}catch(error){
console.info(`${CASE_NAME} clsoe inputMethod fial, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
try{
await inputMethod.getController().showTextInput();
console.info(`${CASE_NAME} execution success`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_showTextInput_Promise_0500
* @tc.name Call the showTextInput interface in Promise mode, and pass in an invalid input parameter
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_showTextInput_Promise_0500',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_showTextInput_Promise_0500';
try{
await inputMethod.getController().showTextInput(env.INVALID_TYPE_STRING_A);
console.info(`${CASE_NAME} execution success`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_hideTextInput_Async_0100
* @tc.name Async mode calls the hideTextInput interface without input parameters
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_hideTextInput_Async_0100',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_hideTextInput_Async_0100';
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().hideTextInput(CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_hideTextInput_Async_0400
* @tc.name The input method keyboard is not bound, and the hideTextInput interface is called in Async mode
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_hideTextInput_Async_0400',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_hideTextInput_Async_0400';
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
let data = await inputMethod.getController().detach();
console.info(`${CASE_NAME} clsoe inputMethod success, data: ${JSON.stringify(data)}`);
}catch(error){
console.info(`${CASE_NAME} clsoe inputMethod fial, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
try{
inputMethod.getController().hideTextInput(CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_hideTextInput_Async_0500
* @tc.name Call the hideTextInput interface in Async mode, and pass in an invalid input parameter
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_hideTextInput_Async_0500',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_hideTextInput_Async_0500';
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().hideTextInput(CallBack,env.INVALID_TYPE_STRING_A);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_hideTextInput_Promise_0100
* @tc.name Promise mode calls the hideTextInput interface without input parameters
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_hideTextInput_Promise_0100',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_hideTextInput_Promise_0100';
try{
await inputMethod.getController().hideTextInput();
}catch(error){
console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED);
done();
return;
};
try{
let data = await inputMethod.getController().hideTextInput();
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_hideTextInput_Promise_0400
* @tc.name The input method keyboard is not bound, and the hideTextInput interface is called in Promise mode
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_hideTextInput_Promise_0400',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_hideTextInput_Promise_0400';
try{
let data = await inputMethod.getController().detach();
console.info(`${CASE_NAME} clsoe inputMethod success, data: ${JSON.stringify(data)}`);
}catch(error){
console.info(`${CASE_NAME} clsoe inputMethod fial, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
try{
await inputMethod.getController().hideTextInput();
console.info(`${CASE_NAME} execution success`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_hideTextInput_Promise_0500
* @tc.name Call the hideTextInput interface in Promise mode, and pass in an invalid input parameter
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_hideTextInput_Promise_0500',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_hideTextInput_Promise_0500';
try{
await inputMethod.getController().hideTextInput(env.INVALID_TYPE_STRING_A);
console.info(`${CASE_NAME} execution success`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_detach_Async_0100
* @tc.name Async mode calls the detach interface without input parameters
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_detach_Async_0100',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_detach_Async_0100';
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().detach(CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_detach_Async_0400
* @tc.name Call the detach interface in Async mode and pass in an invalid input parameter
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_detach_Async_0400',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_detach_Async_0400';
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().detach(CallBack,env.INVALID_TYPE_STRING_A);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_detach_Promise_0100
* @tc.name Promise mode calls the detach interface without input parameters
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_detach_Promise_0100',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_detach_Promise_0100';
try{
let data = await inputMethod.getController().detach();
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_detach_Promise_0400
* @tc.name Call the detach interface in Promise mode, and pass in an invalid input parameter
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_detach_Promise_0400',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_detach_Promise_0400';
try{
await inputMethod.getController().detach(env.INVALID_TYPE_STRING_A);
console.info(`${CASE_NAME} execution success`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
})
}
\ No newline at end of file
//@ts-nocheck
/*
* Copyright (c) 2023 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 inputMethod from '@ohos.inputmethod';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import * as env from './lib/Const';
export default function inputMethodTest() {
describe('inputMethod_updateAttribute', function () {
function expectTrue(data) {
try {
expect(data).assertTrue();
}catch (err){
console.info('assertion failure');
}
};
function expectContain(a,b) {
try {
expect(a).assertContain(b);
}catch (err){
console.info('assertion failure');
}
};
function expectFalse() {
try {
expect().assertFail();
}catch (err){
console.info('assertion failure');
}
};
let st = null as any;
const sleep = function (timeout) {
return new Promise(resolve => {
const st = setTimeout(() => {
resolve(null);
}, timeout);
});
};
beforeEach(
async function (){
try{
let data = await inputMethod.getController().attach(true,{inputAttribute:{textInputType:1,enterKeyType:2}});
console.info(`attach inputMethod success, data: ${JSON.stringify(data)}`);
}catch(error){
console.info(`attach inputMethod fail, error: [${error.code}, ${error.message}]`);
};
}
);
afterEach(
async function (){
try{
await inputMethod.getController().detach();
console.info(`clsoe inputMethod success}`);
}catch(error){
console.info(`clsoe inputMethod fial, error: [${error.code}, ${error.message}]`);
};
clearTimeout(st);
}
);
/**
* @tc.number SUB_Misc_inputMethod_updateAttribute_Async_0100
* @tc.name When calling the updateAttribute interface in Async mode, the parameter attribute=
* {textInputType: 0, enterKeyType: 0} must be passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateAttribute_Async_0100',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateAttribute_Async_0100';
const ATTRIBUTE:any = {textInputType: 0, enterKeyType: 0};
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().updateAttribute(ATTRIBUTE,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateAttribute_Async_0200
* @tc.name When calling the updateAttribute interface in Async mode, the parameter attribute={} must be
* passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateAttribute_Async_0200',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateAttribute_Async_0200';
const ATTRIBUTE:any = {};
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
inputMethod.getController().updateAttribute(ATTRIBUTE,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateAttribute_Async_0300
* @tc.name When calling the updateAttribute interface in Async mode, the parameter attribute='aa' must be
* passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateAttribute_Async_0300',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateAttribute_Async_0300';
const ATTRIBUTE:any = 'aa';
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
inputMethod.getController().updateAttribute(ATTRIBUTE,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateAttribute_Async_0700
* @tc.name Async mode calls the updateAttribute interface and passes in an invalid input parameter
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateAttribute_Async_0700',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateAttribute_Async_0700';
const ATTRIBUTE:any = {textInputType: 0, enterKeyType: 0};
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().updateAttribute(ATTRIBUTE,CallBack,env.INVALID_TYPE_STRING_A);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateAttribute_Async_0800
* @tc.name Async method calls the updateAttribute interface. Missing parameter attribute must be passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateAttribute_Async_0800',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateAttribute_Async_0800';
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
inputMethod.getController().updateAttribute(CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateAttribute_Promise_0100
* @tc.name When calling the updateAttribute interface in Promise mode, the parameter
* attribute={textInputType: 0, enterKeyType: 0} must be passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateAttribute_Promise_0100',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateAttribute_Promise_0100';
const ATTRIBUTE:any = {textInputType: 0, enterKeyType: 0};
try{
let data = await inputMethod.getController().updateAttribute(ATTRIBUTE);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateAttribute_Promise_0200
* @tc.name When calling the updateAttribute interface in Promise mode, the parameter attribute={} must be
* passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateAttribute_Promise_0200',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateAttribute_Promise_0200';
const ATTRIBUTE:any = {};
try{
let data = await inputMethod.getController().updateAttribute(ATTRIBUTE);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateAttribute_Promise_0300
* @tc.name When calling the updateAttribute interface in Promise mode, the parameter attribute='aa' must be
* passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateAttribute_Promise_0300',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateAttribute_Promise_0300';
const ATTRIBUTE:any = 'aa';
try{
let data = await inputMethod.getController().updateAttribute(ATTRIBUTE);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateAttribute_Promise_0700
* @tc.name Call the updateAttribute interface in Promise mode, and pass in an invalid input parameter
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateAttribute_Promise_0700',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateAttribute_Promise_0700';
const ATTRIBUTE:any = {textInputType: 0, enterKeyType: 0};
try{
let data = await inputMethod.getController().updateAttribute(ATTRIBUTE,env.INVALID_TYPE_STRING_A);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateAttribute_Promise_0800
* @tc.name The updateAttribute interface is called in Promise mode. If it is missing,
* the parameter attribute must be passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateAttribute_Promise_0800',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateAttribute_Promise_0800';
try{
let data = await inputMethod.getController().updateAttribute();
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
})
}
\ No newline at end of file
//@ts-nocheck
/*
* Copyright (c) 2023 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 inputMethod from '@ohos.inputmethod';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import * as env from './lib/Const';
export default function inputMethodTest() {
describe('inputMethod_updateCursor', function () {
function expectTrue(data) {
try {
expect(data).assertTrue();
}catch (err){
console.info('assertion failure');
}
};
function expectContain(a,b) {
try {
expect(a).assertContain(b);
}catch (err){
console.info('assertion failure');
}
};
function expectFalse() {
try {
expect().assertFail();
}catch (err){
console.info('assertion failure');
}
};
let st = null as any;
const sleep = function (timeout) {
return new Promise(resolve => {
const st = setTimeout(() => {
resolve(null);
}, timeout);
});
};
beforeEach(
async function (){
try{
let data = await inputMethod.getController().attach(true,{inputAttribute:{textInputType:1,enterKeyType:2}});
console.info(`attach inputMethod success, data: ${JSON.stringify(data)}`);
}catch(error){
console.info(`attach inputMethod fail, error: [${error.code}, ${error.message}]`);
};
}
);
afterEach(
async function (){
try{
await inputMethod.getController().detach();
console.info(`clsoe inputMethod success}`);
}catch(error){
console.info(`clsoe inputMethod fial, error: [${error.code}, ${error.message}]`);
};
clearTimeout(st);
}
);
/**
* @tc.number SUB_Misc_inputMethod_updateCursor_Async_0100
* @tc.name When calling the changeSelection interface in Async mode, the parameter cursorInfo=CursorInfo object
* must be passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateCursor_Async_0100',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateCursor_Async_0100';
const CURSOR_INFO = {left: 2, top: 2, width: 2, height: 2};
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().updateCursor(CURSOR_INFO,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateCursor_Async_0200
* @tc.name When calling the changeSelection interface in Async mode, the parameter cursorInfo={} must be
* passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateCursor_Async_0200',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateCursor_Async_0200';
const CURSOR_INFO:any = {};
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().updateCursor(CURSOR_INFO,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateCursor_Async_0300
* @tc.name When calling the changeSelection interface in Async mode, the parameter cursorInfo='123 'must be
* passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateCursor_Async_0300',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateCursor_Async_0300';
const CURSOR_INFO:any = '123';
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
inputMethod.getController().updateCursor(CURSOR_INFO,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateCursor_Async_0600
* @tc.name The input method keyboard is not bound, and the changeSelection interface is called in Async mode
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateCursor_Async_0600',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateCursor_Async_0600';
const CURSOR_INFO = {left: 2, top: 2, width: 2, height: 2};
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
let data = await inputMethod.getController().detach();
console.info(`${CASE_NAME} clsoe inputMethod success, data: ${JSON.stringify(data)}`);
}catch(error){
console.info(`${CASE_NAME} clsoe inputMethod fial, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
try{
inputMethod.getController().updateCursor(CURSOR_INFO,CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateCursor_Async_0700
* @tc.name Async mode calls the updateCursor interface, and an invalid input parameter is passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateCursor_Async_0700',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateCursor_Async_0700';
const CURSOR_INFO = {left: 2, top: 2, width: 2, height: 2};
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail,error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}
};
try{
inputMethod.getController().updateCursor(CURSOR_INFO,CallBack,env.INVALID_TYPE_STRING_A);
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateCursor_Async_0800
* @tc.name Async mode calls the updateCursor interface. If missing, the parameter cursorInfo must be passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateCursor_Async_0800',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateCursor_Async_0800';
let CallBack:any = (error,data) => {
if (error) {
console.info(`${CASE_NAME} execution fail, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
}else{
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}
};
try{
inputMethod.getController().updateCursor(CallBack);
}catch(error){
console.info(`${CASE_NAME} catch error, expect error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateCursor_Promise_0100
* @tc.name To call the changeSelection interface in Promise mode, the parameter cursorInfo=CursorInfo object
* must be passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateCursor_Promise_0100',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateCursor_Promise_0100';
const CURSOR_INFO = {left: 2, top: 2, width: 2, height: 2};
try{
let data = await inputMethod.getController().updateCursor(CURSOR_INFO);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateCursor_Promise_0200
* @tc.name To call the changeSelection interface in Promise mode, the parameter cursorInfo={} must be passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateCursor_Promise_0200',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateCursor_Promise_0200';
const CURSOR_INFO:any = {};
try{
let data = await inputMethod.getController().updateCursor(CURSOR_INFO);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateCursor_Promise_0300
* @tc.name To call the changeSelection interface in Promise mode, the parameter cursorInfo='123' must be
* passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateCursor_Promise_0300',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateCursor_Promise_0300';
const CURSOR_INFO:any = '123';
try{
let data = await inputMethod.getController().updateCursor(CURSOR_INFO);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateCursor_Promise_0600
* @tc.name The input method keyboard is not bound, and the changeSelection interface is called in Promise mode
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateCursor_Promise_0600',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateCursor_Promise_0600';
const CURSOR_INFO = {left: 2, top: 2, width: 2, height: 2};
try{
let data = await inputMethod.getController().detach();
console.info(`${CASE_NAME} clsoe inputMethod success, data: ${JSON.stringify(data)}`);
}catch(error){
console.info(`${CASE_NAME} clsoe inputMethod fial, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
try{
let data = await inputMethod.getController().updateCursor(CURSOR_INFO);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_METHOD_CLIENT_DETACHED);
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateCursor_Promise_0700
* @tc.name Call the updateCursor interface in Promise mode, and pass in an invalid input parameter
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateCursor_Promise_0700',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateCursor_Promise_0700';
const CURSOR_INFO = {left: 2, top: 2, width: 2, height: 2};
try{
let data = await inputMethod.getController().updateCursor(CURSOR_INFO,env.INVALID_TYPE_STRING_A);
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, error: [${error.code}, ${error.message}]`);
expectFalse();
done();
return;
};
});
/**
* @tc.number SUB_Misc_inputMethod_updateCursor_Promise_0800
* @tc.name The Promise method calls the updateCursor interface. If it is missing,
* the parameter cursorInfo must be passed in
* @tc.desc Function test
*/
it('SUB_Misc_inputMethod_updateCursor_Promise_0800',0, async function (done) {
const CASE_NAME = 'SUB_Misc_inputMethod_updateCursor_Promise_0800';
try{
let data = await inputMethod.getController().updateCursor();
console.info(`${CASE_NAME} execution success, data: ${JSON.stringify(data)}`);
expectFalse();
done();
return;
}catch(error){
console.info(`${CASE_NAME} catch error, except error: [${error.code}, ${error.message}]`);
expectTrue(error.code === env.INVALID_INPUT_PARAMETER);
done();
return;
};
});
})
}
\ No newline at end of file
//ts-nocheck
//public invalid
/*
* Copyright (c) 2023 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 const INVALID_OBJ_NULL:any = {};
export const INVALID_TYPE_NUMBER_123:any = 123;
export const INVALID_TYPE_STRING_123:any = '123';
export const INVALID_STRING_NULL:any = '';
export const INVALID_TYPE_STRING_A:any = 'a';
export const INVALID_NULL:any = null;
export const INVALID_ENUM_N1:any = -1;
export const INVALID_ENUM_2:any = 2;
//----------------------------------------
export const INVALID_INPUT_PARAMETER = 401;
export const INVALID_INPUT_METHOD_CLIENT_DETACHED = 12800009;
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"tablet",
"default",
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.acts.inputmethoddrawncontrol.test.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
}
],
"requestPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.CONNECT_IME_ABILITY"
}
]
}
}
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsInputMethodDrawnControlTest"
},
{
"name": "ime_description",
"value": "input method extension ability."
},
{
"name": "ime_label",
"value": "inputMethod extension ability services."
},
{
"name": "ime_label_1",
"value": "inputMethod extension ability services_1."
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
......@@ -543,7 +543,7 @@ export class KeyboardDelegate {
};
commoneventmanager.publish("inputMethodAbility_test_035", commonEventPublishData, this.publishCallback);
} else {
let value = InputClient.insertText('test');
let value = await InputClient.insertText('test');
console.debug(TAG + '====>inputMethodAbility_test_035 insertText value:' + JSON.stringify(value));
if (value) {
commonEventPublishData = {
......@@ -605,7 +605,7 @@ export class KeyboardDelegate {
};
commoneventmanager.publish("inputMethodAbility_test_037", commonEventPublishData, this.publishCallback);
} else {
let value = InputClient.getForward(1);
let value = await InputClient.getForward(1);
console.debug(TAG + '====>inputMethodAbility_test_037 getForward value' + JSON.stringify(value));
if (value) {
commonEventPublishData = {
......@@ -667,7 +667,7 @@ export class KeyboardDelegate {
};
commoneventmanager.publish("inputMethodAbility_test_039", commonEventPublishData, this.publishCallback);
} else {
let value = InputClient.getEditorAttribute();
let value = await InputClient.getEditorAttribute();
console.debug(TAG + '====>inputMethodAbility_test_039 getEditorAttribute value:' + JSON.stringify(value));
if (value) {
commonEventPublishData = {
......@@ -787,7 +787,7 @@ export class KeyboardDelegate {
};
commoneventmanager.publish("inputMethodAbility_test_043", commonEventPublishData, this.publishCallback);
} else {
let value = InputClient.getBackward(1);
let value = await InputClient.getBackward(1);
console.debug(TAG + '====>inputMethodAbility_test_043 getBackward value:' + JSON.stringify(value));
commonEventPublishData = {
data: "SUCCESS"
......
......@@ -13,8 +13,8 @@
* limitations under the License.
*/
import imeAbilityTest from './imeAbilityTest.test'
import inputMethodStageJSUnit from './inputMethodStageJSUnit';
import inputMethodNormalStageJSUnit from './inputMethodNormalStageJSUnit';
import inputMethodStageJSUnit from './inputMethodStageJSUnit.test';
import inputMethodNormalStageJSUnit from './inputMethodNormalStageJSUnit.test';
export default function testsuite() {
imeAbilityTest(globalThis.abilityContext);
......
......@@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import inputMethodJSUnit from './inputMethodJSUnit';
import inputMethodNormalJSUnit from './inputMethodNormalJSUnit';
import inputMethodJSUnit from './inputMethodJSUnit.test';
import inputMethodNormalJSUnit from './inputMethodNormalJSUnit.test';
export default function testsuite() {
inputMethodJSUnit();
......
......@@ -108,14 +108,6 @@ export class KeyboardController {
console.debug(TAG + '====>Sub_Misc_inputMethod_Panel_resizePromise_0100 event:' + data.event);
that.Sub_Misc_inputMethod_Panel_resizePromise_0100();
break;
case 90:
console.debug(TAG + '====>Sub_Misc_inputMethod_Panel_resizeCallback_0090 event:' + data.event);
that.Sub_Misc_inputMethod_Panel_resizeCallback_0090();
break;
case 100:
console.debug(TAG + '====>Sub_Misc_inputMethod_Panel_resizePromise_0100 event:' + data.event);
that.Sub_Misc_inputMethod_Panel_resizePromise_0100();
break;
case 110:
console.debug(TAG + '====>Sub_Misc_inputMethod_Panel_moveToCallback_0110 event:' + data.event);
that.Sub_Misc_inputMethod_Panel_moveToCallback_0110();
......@@ -306,7 +298,7 @@ export class KeyboardController {
console.info('====>Sub_Misc_inputMethod_Panel_destroyPanelCallback_0030 Succeed in destroying panel.' + JSON.stringify(panel));
}
commoneventmanager.publish("Sub_Misc_inputMethod_Panel_destroyPanelCallback_0030", commonEventPublishData, this.publishCallback);
})
});
}catch(error){
commonEventPublishData = {
data: "FAILED"
......@@ -614,7 +606,7 @@ export class KeyboardController {
console.info('====>Sub_Misc_inputMethod_Panel_showCallback_0130 Succeed in showing the panel: ' + JSON.stringify(data));
}
commoneventmanager.publish("Sub_Misc_inputMethod_Panel_showCallback_0130", commonEventPublishData, this.publishCallback);
})
});
}else{
commonEventPublishData = {
data: "FAILED"
......
......@@ -13,8 +13,8 @@
* limitations under the License.
*/
import screenLockJSUnit from './screenLockTest';
import ScreenLockPromiseTest from './screenLockPromiseTest';
import screenLockJSUnit from './screenLockTest.test';
import ScreenLockPromiseTest from './screenLockPromiseTest.test';
export default function testsuite() {
screenLockJSUnit();
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import wallpaperAuthorityJSUnit from './wallpaperauthorityTest';
import wallpaperAuthorityJSUnit from './wallpaperauthorityTest.test';
export default function testsuite() {
wallpaperAuthorityJSUnit();
......
......@@ -13,8 +13,8 @@
* limitations under the License.
*/
import wallpaperJSUnit from './wallpaperTest';
import wallpaperNoPermissionTest from './wallpapernopermissionTest';
import wallpaperJSUnit from './wallpaperTest.test';
import wallpaperNoPermissionTest from './wallpapernopermissionTest.test';
export default function testsuite() {
wallpaperJSUnit();
......
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import systemTimeJsunit from './systemTimeTest';
import systemTimeJsunit from './systemTimeTest.test';
import systemTimeNoPermissionTest from './timeNoPermission.test'
export default function testsuite() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册