Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
7eb26d1e
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
7eb26d1e
编写于
4月 10, 2023
作者:
O
openharmony_ci
提交者:
Gitee
4月 10, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8386 【master】【杂散】【输入法框架】新增inputmethod无权限用用例
Merge pull request !8386 from 张育帅/master
上级
b2277c74
74ce8c09
变更
27
显示空白变更内容
内联
并排
Showing
27 changed file
with
1184 addition
and
364 deletion
+1184
-364
inputmethod/BUILD.gn
inputmethod/BUILD.gn
+1
-0
inputmethod/InputMethodAuthorityTest/AppScope/app.json
inputmethod/InputMethodAuthorityTest/AppScope/app.json
+21
-0
inputmethod/InputMethodAuthorityTest/AppScope/resources/base/element/string.json
...AuthorityTest/AppScope/resources/base/element/string.json
+8
-0
inputmethod/InputMethodAuthorityTest/AppScope/resources/base/media/app_icon.png
...dAuthorityTest/AppScope/resources/base/media/app_icon.png
+0
-0
inputmethod/InputMethodAuthorityTest/BUILD.gn
inputmethod/InputMethodAuthorityTest/BUILD.gn
+43
-0
inputmethod/InputMethodAuthorityTest/Test.json
inputmethod/InputMethodAuthorityTest/Test.json
+17
-0
inputmethod/InputMethodAuthorityTest/entry/src/main/ets/Application/AbilityStage.ts
...horityTest/entry/src/main/ets/Application/AbilityStage.ts
+23
-0
inputmethod/InputMethodAuthorityTest/entry/src/main/ets/MainAbility/MainAbility.ts
...thorityTest/entry/src/main/ets/MainAbility/MainAbility.ts
+51
-0
inputmethod/InputMethodAuthorityTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...st/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+78
-0
inputmethod/InputMethodAuthorityTest/entry/src/main/ets/pages/index/index.ets
...hodAuthorityTest/entry/src/main/ets/pages/index/index.ets
+51
-0
inputmethod/InputMethodAuthorityTest/entry/src/main/ets/test/List.test.ets
...MethodAuthorityTest/entry/src/main/ets/test/List.test.ets
+19
-0
inputmethod/InputMethodAuthorityTest/entry/src/main/ets/test/inputmethodauthority.test.ets
...est/entry/src/main/ets/test/inputmethodauthority.test.ets
+373
-0
inputmethod/InputMethodAuthorityTest/entry/src/main/module.json
...ethod/InputMethodAuthorityTest/entry/src/main/module.json
+55
-0
inputmethod/InputMethodAuthorityTest/entry/src/main/resources/base/element/string.json
...ityTest/entry/src/main/resources/base/element/string.json
+36
-0
inputmethod/InputMethodAuthorityTest/entry/src/main/resources/base/media/icon.png
...uthorityTest/entry/src/main/resources/base/media/icon.png
+0
-0
inputmethod/InputMethodAuthorityTest/entry/src/main/resources/base/profile/main_pages.json
...est/entry/src/main/resources/base/profile/main_pages.json
+5
-0
inputmethod/InputMethodAuthorityTest/signature/ActsInputMethodAuthorityTest.p7b
...dAuthorityTest/signature/ActsInputMethodAuthorityTest.p7b
+0
-0
inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/List.test.ets
...putMethodTest_Stage/entry/src/main/ets/test/List.test.ets
+2
-1
inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodNormalStageJSUnit.ets
.../entry/src/main/ets/test/inputMethodNormalStageJSUnit.ets
+206
-0
inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets
..._Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets
+0
-183
inputmethod/InputMethodTest_Stage/entry/src/main/module.json
inputmethod/InputMethodTest_Stage/entry/src/main/module.json
+0
-9
inputmethod/InputMethodTest_Stage/signature/ActInputMethodStageAPITest.p7b
...MethodTest_Stage/signature/ActInputMethodStageAPITest.p7b
+0
-0
inputmethod/InputMethodTest_ets/entry/src/main/config.json
inputmethod/InputMethodTest_ets/entry/src/main/config.json
+1
-6
inputmethod/InputMethodTest_ets/entry/src/main/ets/test/List.test.ets
...InputMethodTest_ets/entry/src/main/ets/test/List.test.ets
+2
-0
inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets
...hodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets
+0
-165
inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodNormalJSUnit.ets
...t_ets/entry/src/main/ets/test/inputMethodNormalJSUnit.ets
+192
-0
inputmethod/InputMethodTest_ets/signature/ActInputMethodEtsAPITest.p7b
...nputMethodTest_ets/signature/ActInputMethodEtsAPITest.p7b
+0
-0
未找到文件。
inputmethod/BUILD.gn
浏览文件 @
7eb26d1e
...
...
@@ -15,6 +15,7 @@ import("//build/ohos_var.gni")
group("inputmethod") {
testonly = true
deps = [
"InputMethodAuthorityTest:ActsInputMethodAuthorityTest",
"InputMethodEngine:ActsInputMethodEngineTest",
"InputMethodTest_Stage:ActsImeAbilityTest",
"InputMethodTest_ets:ActsInputMethodEtsTest",
...
...
inputmethod/InputMethodAuthorityTest/AppScope/app.json
0 → 100644
浏览文件 @
7eb26d1e
{
"app"
:{
"bundleName"
:
"com.acts.inputmethodauthority.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
}
}
}
inputmethod/InputMethodAuthorityTest/AppScope/resources/base/element/string.json
0 → 100644
浏览文件 @
7eb26d1e
{
"string"
:[
{
"name"
:
"app_name"
,
"value"
:
"ohosProject"
}
]
}
\ No newline at end of file
inputmethod/InputMethodAuthorityTest/AppScope/resources/base/media/app_icon.png
0 → 100644
浏览文件 @
7eb26d1e
6.6 KB
inputmethod/InputMethodAuthorityTest/BUILD.gn
0 → 100644
浏览文件 @
7eb26d1e
# 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("ActsInputMethodAuthorityTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":IMExtAbility_ets_assets",
":IMExtAbility_resources",
]
ets2abc = true
certificate_profile = "signature/ActsInputMethodAuthorityTest.p7b"
hap_name = "ActsInputMethodAuthorityTest"
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"
}
inputmethod/InputMethodAuthorityTest/Test.json
0 → 100644
浏览文件 @
7eb26d1e
{
"description"
:
"Configuration for hjunit demo Tests"
,
"driver"
:
{
"type"
:
"OHJSUnitTest"
,
"test-timeout"
:
"180000"
,
"bundle-name"
:
"com.acts.inputmethodauthority.test"
,
"module-name"
:
"entry_test"
,
"shell-timeout"
:
"600000"
},
"kits"
:
[{
"test-file-name"
:
[
"ActsInputMethodAuthorityTest.hap"
],
"type"
:
"AppInstallKit"
,
"cleanup-apps"
:
true
}]
}
inputmethod/InputMethodAuthorityTest/entry/src/main/ets/Application/AbilityStage.ts
0 → 100644
浏览文件 @
7eb26d1e
/*
* 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
AbilityStage
from
"
@ohos.app.ability.AbilityStage
"
;
export
default
class
MyAbilityStage
extends
AbilityStage
{
onCreate
()
{
console
.
log
(
"
MyAbilityStage onCreate
"
);
globalThis
.
stageOnCreateRun
=
1
;
globalThis
.
stageContext
=
this
.
context
;
}
}
inputmethod/InputMethodAuthorityTest/entry/src/main/ets/MainAbility/MainAbility.ts
0 → 100644
浏览文件 @
7eb26d1e
/*
* 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
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
inputmethod/InputMethodAuthorityTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
0 → 100644
浏览文件 @
7eb26d1e
/*
* 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
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.inputmethodauthority.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
inputmethod/InputMethodAuthorityTest/entry/src/main/ets/pages/index/index.ets
0 → 100644
浏览文件 @
7eb26d1e
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../test/List.test'
@Entry
@Component
struct Index {
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.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
inputmethod/InputMethodAuthorityTest/entry/src/main/ets/test/List.test.ets
0 → 100644
浏览文件 @
7eb26d1e
/*
* 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 inputMethodAuthorityJSUnit from './inputmethodauthority.test';
export default function testsuite() {
inputMethodAuthorityJSUnit();
}
\ No newline at end of file
inputmethod/InputMethodAuthorityTest/entry/src/main/ets/test/inputmethodauthority.test.ets
0 → 100644
浏览文件 @
7eb26d1e
/**
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
import inputMethod from '@ohos.inputMethod';
import subtype from '@ohos.InputMethodSubtype';
export default function inputMethodAuthorityJSUnit() {
describe('inputMethodAuthorityJSUnit', function () {
console.info("====>************* inputMethodAuthorityJSUnit settings Test start*************");
/*
* @tc.number inputmethod_test_switchInputMethod_001
* @tc.name Test Indicates the input method which will replace the current one.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethod_test_switchInputMethod_001', 0, async function (done) {
console.info("====>************* inputmethod_test_switchInputMethod_001 Test start*************");
let inputM = inputMethod.getCurrentInputMethod()
console.info("inputmethod_test_switchInputMethod_001 getCurrentInputMethod: " + JSON.stringify(inputM));
let inputMethodProperty = {
packageName: inputM.packageName,
methodId: inputM.methodId,
name: inputM.packageName,
id: inputM.methodId,
extra: {}
}
inputMethod.switchInputMethod(inputMethodProperty).then(data => {
console.info("====>inputmethod_test_switchInputMethod_001 data:" + data)
expect(data == true).assertTrue();
console.info("====>************* inputmethod_test_switchInputMethod_001 Test end*************");
done();
}).catch(err => {
console.info("====>inputmethod_test_switchInputMethod_001 err:" + err)
expect().assertFail();
done();
});
});
/*
* @tc.number inputmethod_test_switchInputMethod_002
* @tc.name Test Indicates the input method which will replace the current one.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethod_test_switchInputMethod_002', 0, async function (done) {
console.info("====>************* inputmethod_test_switchInputMethod_002 Test start*************");
let inputM = inputMethod.getCurrentInputMethod()
console.info("inputmethod_test_switchInputMethod_002 getCurrentInputMethod: " + JSON.stringify(inputM));
let inputMethodProperty = {
packageName: inputM.packageName,
methodId: inputM.methodId,
name: inputM.packageName,
id: inputM.methodId,
extra: {}
}
inputMethod.switchInputMethod(inputMethodProperty, (err, data) => {
try {
if (err) {
console.info("====>inputmethod_test_switchInputMethod_002 error:" + err);
expect().assertFail();
done();
}
console.info("====>inputmethod_test_switchInputMethod_002 data:" + data)
console.info("====>************* inputmethod_test_switchInputMethod_002 Test end*************");
expect(data == true).assertTrue();
done();
} catch (err) {
console.info("====>inputmethod_test_switchInputMethod_002 catch error:" + err);
done();
}
});
});
/*
* @tc.number inputmethod_test_showSoftKeyboard_001
* @tc.name Test Indicates the input method which will show softboard with calback.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethod_test_showSoftKeyboard_001', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.showSoftKeyboard((err) => {
try {
if(err == undefined){
expect().assertFail()
done();
}else{
expect(err.code).assertEqual(12800003)
console.info("====>************* inputmethod_test_showSoftKeyboard_001 Test end*************");
done();
}
} catch (err) {
console.info("====>inputmethod_test_showSoftKeyboard_001 err tests fail" + JSON.stringify(err));
done();
}
});
});
/*
* @tc.number inputmethod_test_showSoftKeyboard_002
* @tc.name Test Indicates the input method which will show softboard with Promise.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethod_test_showSoftKeyboard_002', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.showSoftKeyboard().then(() => {
try {
expect().assertFail()
done();
} catch (err) {
console.info("====>inputmethod_test_showSoftKeyboard_002 err tests fail" + JSON.stringify(err));
done();
}
}).catch((err) => {
console.info('====>inputmethod_test_showSoftKeyboard_002 promise failed : ' + JSON.stringify(err))
console.info('====>inputmethod_test_showSoftKeyboard_002 typeof(err.code): ' + typeof(err.code))
console.info('====>inputmethod_test_showSoftKeyboard_002 typeof(err.code): ' + err.code)
expect(err.code).assertEqual(12800003)
console.info("====>************* inputmethod_test_showSoftKeyboard_002 Test end*************");
done();
})
});
/*
* @tc.number inputmethod_test_hideSoftKeyboard_001
* @tc.name Test Indicates the input method which will hide softboard with calback.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethod_test_hideSoftKeyboard_001', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.hideSoftKeyboard((err) => {
try {
if(err == undefined){
expect().assertFail()
done();
}else{
console.info('====>inputmethod_test_hideSoftKeyboard_001 callbacek failed : ' + JSON.stringify(err))
expect(err.code).assertEqual(12800003)
console.info("====>************* inputmethod_test_hideSoftKeyboard_001 Test end*************");
done();
}
} catch (err) {
console.info('====>inputmethod_test_hideSoftKeyboard_001 callbacek failed : ' + JSON.stringify(err))
done();
}
})
});
/*
* @tc.number inputmethod_test_hideSoftKeyboard_002
* @tc.name Test Indicates the input method which will hide softboard with Promise.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethod_test_hideSoftKeyboard_002', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.hideSoftKeyboard().then(() => {
try {
expect().assertFail()
done();
} catch (err) {
console.info("====>inputmethod_test_hideSoftKeyboard_002 err tests fail" + JSON.stringify(err));
done();
}
}).catch((err) => {
console.info('====>inputmethod_test_hideSoftKeyboard_002 promise failed : ' + JSON.stringify(err))
expect(err.code).assertEqual(12800003);
console.info("====>************* inputmethod_test_hideSoftKeyboard_002 Test end*************");
done();
})
});
/*
* @tc.number inputMethod_test_switchCurrentInputMethodAndSubtype_001
* @tc.name Switch current input method subtype.
* @tc.desc Function test
* @tc.level 2
*/
it('inputMethod_test_switchCurrentInputMethodAndSubtype_001', 0, async function (done) {
console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_001 Test start*************");
let inputM = inputMethod.getCurrentInputMethod()
console.info("inputMethod_test_switchCurrentInputMethodAndSubtype_001 getCurrentInputMethod: " + JSON.stringify(inputM));
let inputMethodProperty = {
packageName:inputM.packageName,
methodId:inputM.methodId,
name:inputM.packageName,
id:inputM.methodId,
label: "",
icon: "",
iconId: 124,
extra:{}
}
let inputMS = inputMethod.getCurrentInputMethodSubtype()
console.info("inputMethod_test_switchCurrentInputMethodAndSubtype_001 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS));
let inputMethodSubProperty : subtype = {
id: inputMS.id,
label: "",
name: inputMS.name,
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
};
inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty, (err,data) => {
try {
if (err) {
console.error('inputMethod_test_switchCurrentInputMethodAndSubtype_001 err: ' + JSON.stringify(err));
expect( err.code === 12800008 ).assertTrue();
done();
}
console.info("====>inputMethod_test_switchCurrentInputMethodAndSubtype_001 data: " + JSON.stringify(data));
expect(data != null).assertTrue();
done();
} catch (error) {
console.error('inputMethod_test_switchCurrentInputMethodAndSubtype_001 catch error: ' + JSON.stringify(error));
done();
}
});
console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_001 Test end*************");
});
/*
* @tc.number inputMethod_test_switchCurrentInputMethodAndSubtype_002
* @tc.name Switch current input method subtype.
* @tc.desc Function test
* @tc.level 2
*/
it('inputMethod_test_switchCurrentInputMethodAndSubtype_002', 0, async function (done) {
console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_002 Test start*************");
let inputM = inputMethod.getCurrentInputMethod()
console.info("inputMethod_test_switchCurrentInputMethodAndSubtype_002 getCurrentInputMethod: " + JSON.stringify(inputM));
let inputMethodProperty = {
packageName:inputM.packageName,
methodId:inputM.methodId,
name:inputM.packageName,
id:inputM.methodId,
label: "",
icon: "",
iconId: 124,
extra:{}
}
let inputMS = inputMethod.getCurrentInputMethodSubtype()
console.info("inputMethod_test_switchCurrentInputMethodAndSubtype_002 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS));
let inputMethodSubProperty : subtype = {
id: inputMS.id,
label: "",
name: inputMS.name,
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
};
try {
inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty).then((data) => {
console.info("====>inputMethod_test_switchCurrentInputMethodAndSubtype_002 data: " + JSON.stringify(data));
expect(data != null).assertTrue();
done();
}).catch(err => {
console.error('inputMethod_test_switchCurrentInputMethodAndSubtype_002 err: ' + JSON.stringify(err));
expect().assertFail();
done();
});
}catch (error) {
console.error('inputMethod_test_switchCurrentInputMethodAndSubtype_002 catch error: ' + JSON.stringify(error));
expect().assertFail();
done();
};
console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_002 Test end*************");
});
/*
* @tc.number inputMethod_test_switchCurrentInputMethodSubtype_001
* @tc.name Switch current input method subtype.
* @tc.desc Function test
* @tc.level 2
*/
it('inputMethod_test_switchCurrentInputMethodSubtype_001', 0, async function (done) {
console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_001 Test start*************");
let inputMS = inputMethod.getCurrentInputMethodSubtype()
console.info("inputMethod_test_switchCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS));
let inputMethodSubProperty : subtype = {
id: inputMS.id,
label: "",
name: inputMS.name,
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
};
inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty, (err,data) => {
try {
if (err) {
console.error('inputMethod_test_switchCurrentInputMethodSubtype_001 err: ' + JSON.stringify(err));
expect().assertFail();
done();
};
console.info("====>inputMethod_test_switchCurrentInputMethodSubtype_001 data: " + JSON.stringify(data));
expect(data != null).assertTrue();
done();
} catch (error) {
console.error('inputMethod_test_switchCurrentInputMethodSubtype_001 catch error: ' + JSON.stringify(error));
done();
}
});
console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_001 Test end*************");
});
/*
* @tc.number inputMethod_test_switchCurrentInputMethodSubtype_002
* @tc.name Switch current input method subtype.
* @tc.desc Function test
* @tc.level 2
*/
it('inputMethod_test_switchCurrentInputMethodSubtype_002', 0, async function (done) {
console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_002 Test start*************");
let inputMS = inputMethod.getCurrentInputMethodSubtype()
console.info("inputMethod_test_switchCurrentInputMethodSubtype_002 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS));
let inputMethodSubProperty : subtype = {
id: inputMS.id,
label: "",
name: inputMS.name,
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
};
try {
inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty).then((data) => {
console.info("====>inputMethod_test_switchCurrentInputMethodSubtype_002 data: " + JSON.stringify(data));
expect(data != null).assertTrue();
done();
}).catch(err => {
console.error('inputMethod_test_switchCurrentInputMethodSubtype_002 err: ' + JSON.stringify(err));
expect().assertFail();
done();
});
}catch (error) {
console.error('inputMethod_test_switchCurrentInputMethodSubtype_002 catch error: ' + JSON.stringify(error));
expect().assertFail();
done();
};
console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_002 Test end*************");
});
});
};
inputmethod/InputMethodAuthorityTest/entry/src/main/module.json
0 → 100644
浏览文件 @
7eb26d1e
{
"module"
:
{
"name"
:
"entry_test"
,
"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"
,
"metadata"
:
[
{
"name"
:
"ArkTSPartialUpdate"
,
"value"
:
"false"
}
],
"abilities"
:
[
{
"name"
:
"com.acts.inputmethodauthority.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"
}
]
}
}
inputmethod/InputMethodAuthorityTest/entry/src/main/resources/base/element/string.json
0 → 100644
浏览文件 @
7eb26d1e
{
"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"
:
"ActsInputMethodAuthorityTest"
},
{
"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"
}
]
}
inputmethod/InputMethodAuthorityTest/entry/src/main/resources/base/media/icon.png
0 → 100644
浏览文件 @
7eb26d1e
6.6 KB
inputmethod/InputMethodAuthorityTest/entry/src/main/resources/base/profile/main_pages.json
0 → 100644
浏览文件 @
7eb26d1e
{
"src"
:
[
"pages/index/index"
]
}
\ No newline at end of file
inputmethod/InputMethodAuthorityTest/signature/ActsInputMethodAuthorityTest.p7b
0 → 100644
浏览文件 @
7eb26d1e
文件已添加
inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/List.test.ets
浏览文件 @
7eb26d1e
...
...
@@ -14,9 +14,10 @@
*/
import imeAbilityTest from './imeAbilityTest.test'
import inputMethodStageJSUnit from './inputMethodStageJSUnit';
import inputMethodNormalStageJSUnit from './inputMethodNormalStageJSUnit';
export default function testsuite() {
imeAbilityTest(globalThis.abilityContext);
inputMethodStageJSUnit();
inputMethodNormalStageJSUnit();
}
\ No newline at end of file
inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodNormalStageJSUnit.ets
0 → 100644
浏览文件 @
7eb26d1e
/**
* 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "@ohos/hypium"
import inputMethod from '@ohos.inputMethod';
import subtype from '@ohos.InputMethodSubtype';
export default function inputMethodNormalStageJSUnit() {
describe('inputMethodNormalStageJSUnit', function () {
console.info("====>************* inputMethodNormalStageJSUnit settings Test start*************");
/*
* @tc.number inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_001
* @tc.name Switch current input method subtype.
* @tc.desc Function test
* @tc.level 2
*/
it('inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_001', 0, async function (done) {
console.info("====>************* inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_001 Test start*************");
let inputM = inputMethod.getCurrentInputMethod()
console.info("inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_001 getCurrentInputMethod: " + JSON.stringify(inputM));
let inputMethodProperty = {
packageName:inputM.packageName,
methodId:inputM.methodId,
name:inputM.packageName,
id:inputM.methodId,
label: "",
icon: "",
iconId: 124,
extra:{}
}
let inputMS = inputMethod.getCurrentInputMethodSubtype()
console.info("inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_001 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS));
let inputMethodSubProperty : subtype = {
id: inputMS.id,
label: "",
name: inputMS.name,
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
};
inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty, (err,data) => {
try{
if(err){
console.info("====>inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_001 permission fail: " + JSON.stringify(err));
expect(err.code).assertEqual(201);
done();
}else{
console.info('====>inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_001 success: ' + data);
expect().assertFail();
done();
}
}catch(err){
console.error("====>inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_001 catch err: " + JSON.stringify(err));
done();
console.info("====>inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_001 end");
}
});
console.info("====>************* inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_001 Test end*************");
});
/*
* @tc.number inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_002
* @tc.name Switch current input method subtype.
* @tc.desc Function test
* @tc.level 2
*/
it('inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_002', 0, async function (done) {
console.info("====>************* inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_002 Test start*************");
let inputM = inputMethod.getCurrentInputMethod()
console.info("inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_002 getCurrentInputMethod: " + JSON.stringify(inputM));
let inputMethodProperty = {
packageName:inputM.packageName,
methodId:inputM.methodId,
name:inputM.packageName,
id:inputM.methodId,
label: "",
icon: "",
iconId: 124,
extra:{}
}
let inputMS = inputMethod.getCurrentInputMethodSubtype()
console.info("inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_002 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS));
let inputMethodSubProperty : subtype = {
id: inputMS.id,
label: "",
name: inputMS.name,
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
};
try{
console.info('====>inputMethodNormalStage_test_switchInputMethod_001 switchCurrentInputMethodAndSubtype permission fail');
await inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty);
expect().assertFail();
done();
}catch(err){
console.error('====>inputMethodNormalStage_test_switchInputMethod_001 switchCurrentInputMethodAndSubtype catch err' + JSON.stringify(err))
expect(err.code).assertEqual(201);
expect(err.message).assertContain("the permissions check fails");
done();
console.info("====>inputMethodNormalStage_test_switchInputMethod_001 end");
}
console.info("====>************* inputMethodNormalStage_test_switchCurrentInputMethodAndSubtype_002 Test end*************");
});
/*
* @tc.number inputMethodNormalStage_test_switchCurrentInputMethodSubtype_001
* @tc.name Switch current input method subtype.
* @tc.desc Function test
* @tc.level 2
*/
it('inputMethodNormalStage_test_switchCurrentInputMethodSubtype_001', 0, async function (done) {
console.info("====>************* inputMethodNormalStage_test_switchCurrentInputMethodSubtype_001 Test start*************");
let inputMS = inputMethod.getCurrentInputMethodSubtype()
console.info("inputMethodNormalStage_test_switchCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS));
let inputMethodSubProperty : subtype = {
id: inputMS.id,
label: "",
name: inputMS.name,
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
};
inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty, (err,data) => {
try{
if(err){
console.info("====>inputMethodNormalStage_test_switchCurrentInputMethodSubtype_001 permission fail: " + JSON.stringify(err));
expect(err.code).assertEqual(201);
done();
}else{
console.info('====>inputMethodNormalStage_test_switchCurrentInputMethodSubtype_001 success: ' + data);
expect().assertFail();
done();
}
}catch(err){
console.error("====>inputMethodNormalStage_test_switchCurrentInputMethodSubtype_001 catch err: " + JSON.stringify(err));
done();
console.info("====>inputMethodNormalStage_test_switchCurrentInputMethodSubtype_001 end");
}
});
console.info("====>************* inputMethodNormalStage_test_switchCurrentInputMethodSubtype_001 Test end*************");
});
/*
* @tc.number inputMethodNormalStage_test_switchCurrentInputMethodSubtype_002
* @tc.name Switch current input method subtype.
* @tc.desc Function test
* @tc.level 2
*/
it('inputMethodNormalStage_test_switchCurrentInputMethodSubtype_002', 0, async function (done) {
console.info("====>************* inputMethodNormalStage_test_switchCurrentInputMethodSubtype_002 Test start*************");
let inputMS = inputMethod.getCurrentInputMethodSubtype()
console.info("inputMethodNormalStage_test_switchCurrentInputMethodSubtype_002 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS));
let inputMethodSubProperty : subtype = {
id: inputMS.id,
label: "",
name: inputMS.name,
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
};
try{
console.info('====>inputMethodNormalStage_test_switchCurrentInputMethodSubtype_002 switchCurrentInputMethodSubtype permission fail');
await inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty);
expect().assertFail();
done();
}catch(err){
console.error('====>inputMethodNormalStage_test_switchCurrentInputMethodSubtype_002 switchCurrentInputMethodSubtype catch err' + JSON.stringify(err))
expect(err.code).assertEqual(201);
expect(err.message).assertContain("the permissions check fails");
done();
console.info("====>inputMethodNormalStage_test_switchCurrentInputMethodSubtype_002 end");
}
console.info("====>************* inputMethodNormalStage_test_switchCurrentInputMethodSubtype_002 Test end*************");
});
});
};
inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets
浏览文件 @
7eb26d1e
...
...
@@ -311,189 +311,6 @@ export default function inputMethodStageJSUnit() {
done();
});
/*
* @tc.number inputMethod_test_switchCurrentInputMethodAndSubtype_001
* @tc.name Switch current input method subtype.
* @tc.desc Function test
* @tc.level 2
*/
it('inputMethod_test_switchCurrentInputMethodAndSubtype_001', 0, async function (done) {
console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_001 Test start*************");
let inputM = inputMethod.getCurrentInputMethod()
console.info("inputMethod_test_switchCurrentInputMethodAndSubtype_001 getCurrentInputMethod: " + JSON.stringify(inputM));
let inputMethodProperty = {
packageName:inputM.packageName,
methodId:inputM.methodId,
name:inputM.packageName,
id:inputM.methodId,
label: "",
icon: "",
iconId: 124,
extra:{}
}
let inputMS = inputMethod.getCurrentInputMethodSubtype()
console.info("inputMethod_test_switchCurrentInputMethodAndSubtype_001 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS));
let inputMethodSubProperty : subtype = {
id: inputMS.id,
label: "",
name: inputMS.name,
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
};
inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty, (err,data) => {
try {
if (err) {
console.error('inputMethod_test_switchCurrentInputMethodAndSubtype_001 err: ' + JSON.stringify(err));
expect( err.code === 12800008 ).assertTrue();
done();
}
console.info("====>inputMethod_test_switchCurrentInputMethodAndSubtype_001 data: " + JSON.stringify(data));
expect(data != null).assertTrue();
done();
} catch (error) {
console.error('inputMethod_test_switchCurrentInputMethodAndSubtype_001 catch error: ' + JSON.stringify(error));
done();
}
});
console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_001 Test end*************");
});
/*
* @tc.number inputMethod_test_switchCurrentInputMethodAndSubtype_002
* @tc.name Switch current input method subtype.
* @tc.desc Function test
* @tc.level 2
*/
it('inputMethod_test_switchCurrentInputMethodAndSubtype_002', 0, async function (done) {
console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_002 Test start*************");
let inputM = inputMethod.getCurrentInputMethod()
console.info("inputMethod_test_switchCurrentInputMethodAndSubtype_002 getCurrentInputMethod: " + JSON.stringify(inputM));
let inputMethodProperty = {
packageName:inputM.packageName,
methodId:inputM.methodId,
name:inputM.packageName,
id:inputM.methodId,
label: "",
icon: "",
iconId: 124,
extra:{}
}
let inputMS = inputMethod.getCurrentInputMethodSubtype()
console.info("inputMethod_test_switchCurrentInputMethodAndSubtype_002 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS));
let inputMethodSubProperty : subtype = {
id: inputMS.id,
label: "",
name: inputMS.name,
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
};
try {
inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty).then((data) => {
console.info("====>inputMethod_test_switchCurrentInputMethodAndSubtype_002 data: " + JSON.stringify(data));
expect(data != null).assertTrue();
done();
}).catch(err => {
console.error('inputMethod_test_switchCurrentInputMethodAndSubtype_002 err: ' + JSON.stringify(err));
expect().assertFail();
done();
});
}catch (error) {
console.error('inputMethod_test_switchCurrentInputMethodAndSubtype_002 catch error: ' + JSON.stringify(error));
expect().assertFail();
done();
};
console.info("====>************* inputMethod_test_switchCurrentInputMethodAndSubtype_002 Test end*************");
});
/*
* @tc.number inputMethod_test_switchCurrentInputMethodSubtype_001
* @tc.name Switch current input method subtype.
* @tc.desc Function test
* @tc.level 2
*/
it('inputMethod_test_switchCurrentInputMethodSubtype_001', 0, async function (done) {
console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_001 Test start*************");
let inputMS = inputMethod.getCurrentInputMethodSubtype()
console.info("inputMethod_test_switchCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS));
let inputMethodSubProperty : subtype = {
id: inputMS.id,
label: "",
name: inputMS.name,
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
};
inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty, (err,data) => {
try {
if (err) {
console.error('inputMethod_test_switchCurrentInputMethodSubtype_001 err: ' + JSON.stringify(err));
expect().assertFail();
done();
};
console.info("====>inputMethod_test_switchCurrentInputMethodSubtype_001 data: " + JSON.stringify(data));
expect(data != null).assertTrue();
done();
} catch (error) {
console.error('inputMethod_test_switchCurrentInputMethodSubtype_001 catch error: ' + JSON.stringify(error));
done();
}
});
console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_001 Test end*************");
});
/*
* @tc.number inputMethod_test_switchCurrentInputMethodSubtype_002
* @tc.name Switch current input method subtype.
* @tc.desc Function test
* @tc.level 2
*/
it('inputMethod_test_switchCurrentInputMethodSubtype_002', 0, async function (done) {
console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_002 Test start*************");
let inputMS = inputMethod.getCurrentInputMethodSubtype()
console.info("inputMethod_test_switchCurrentInputMethodSubtype_002 getCurrentInputMethodSubtype: " + JSON.stringify(inputMS));
let inputMethodSubProperty : subtype = {
id: inputMS.id,
label: "",
name: inputMS.name,
mode: "lower",
locale: "",
language: "",
icon: "",
iconId: 0,
extra: {}
};
try {
inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty).then((data) => {
console.info("====>inputMethod_test_switchCurrentInputMethodSubtype_002 data: " + JSON.stringify(data));
expect(data != null).assertTrue();
done();
}).catch(err => {
console.error('inputMethod_test_switchCurrentInputMethodSubtype_002 err: ' + JSON.stringify(err));
expect().assertFail();
done();
});
}catch (error) {
console.error('inputMethod_test_switchCurrentInputMethodSubtype_002 catch error: ' + JSON.stringify(error));
expect().assertFail();
done();
};
console.info("====>************* inputMethod_test_switchCurrentInputMethodSubtype_002 Test end*************");
});
/*
* @tc.number inputMethod_test_showOptionalInputMethods_001
...
...
inputmethod/InputMethodTest_Stage/entry/src/main/module.json
浏览文件 @
7eb26d1e
...
...
@@ -50,15 +50,6 @@
"description"
:
"$string:ime_description"
,
"type"
:
"inputMethod"
}
],
"requestPermissions"
:
[
{
"name"
:
"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
,
"reason"
:
"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name"
:
"ohos.permission.CONNECT_IME_ABILITY"
}
]
}
}
inputmethod/InputMethodTest_Stage/signature/ActInputMethodStageAPITest.p7b
浏览文件 @
7eb26d1e
无法预览此类型文件
inputmethod/InputMethodTest_ets/entry/src/main/config.json
浏览文件 @
7eb26d1e
...
...
@@ -66,11 +66,6 @@
"launchType"
:
"standard"
}
],
"reqPermissions"
:
[
{
"name"
:
"ohos.permission.CONNECT_IME_ABILITY"
}
],
"js"
:
[
{
"mode"
:
{
...
...
inputmethod/InputMethodTest_ets/entry/src/main/ets/test/List.test.ets
浏览文件 @
7eb26d1e
...
...
@@ -14,8 +14,10 @@
*/
import inputMethodJSUnit from './inputMethodJSUnit';
import inputMethodEngineJSUnit from './inputMethodEngineJSUnit';
import inputMethodNormalJSUnit from './inputMethodNormalJSUnit';
export default function testsuite() {
inputMethodJSUnit();
inputMethodEngineJSUnit();
inputMethodNormalJSUnit();
}
\ No newline at end of file
inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets
浏览文件 @
7eb26d1e
...
...
@@ -122,171 +122,6 @@ export default function inputMethodJSUnit() {
done();
});
/*
* @tc.number inputmethod_test_switchInputMethod_001
* @tc.name Test Indicates the input method which will replace the current one.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethod_test_switchInputMethod_001', 0, async function (done) {
console.info("====>************* inputmethod_test_switchInputMethod_001 Test start*************");
let inputM = inputMethod.getCurrentInputMethod()
console.info("inputmethod_test_switchInputMethod_001 getCurrentInputMethod: " + JSON.stringify(inputM));
let inputMethodProperty = {
packageName: inputM.packageName,
methodId: inputM.methodId,
name: inputM.packageName,
id: inputM.methodId,
extra: {}
}
inputMethod.switchInputMethod(inputMethodProperty).then(data => {
console.info("====>inputmethod_test_switchInputMethod_001 data:" + data)
expect(data == true).assertTrue();
console.info("====>************* inputmethod_test_switchInputMethod_001 Test end*************");
done();
}).catch(err => {
console.info("====>inputmethod_test_switchInputMethod_001 err:" + err)
expect().assertFail();
done();
});
});
/*
* @tc.number inputmethod_test_switchInputMethod_002
* @tc.name Test Indicates the input method which will replace the current one.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethod_test_switchInputMethod_002', 0, async function (done) {
console.info("====>************* inputmethod_test_switchInputMethod_002 Test start*************");
let inputM = inputMethod.getCurrentInputMethod()
console.info("inputmethod_test_switchInputMethod_002 getCurrentInputMethod: " + JSON.stringify(inputM));
let inputMethodProperty = {
packageName: inputM.packageName,
methodId: inputM.methodId,
name: inputM.packageName,
id: inputM.methodId,
extra: {}
}
inputMethod.switchInputMethod(inputMethodProperty, (err, data) => {
try {
if (err) {
console.info("====>inputmethod_test_switchInputMethod_002 error:" + err);
expect().assertFail();
done();
}
console.info("====>inputmethod_test_switchInputMethod_002 data:" + data)
console.info("====>************* inputmethod_test_switchInputMethod_002 Test end*************");
expect(data == true).assertTrue();
done();
} catch (err) {
console.info("====>inputmethod_test_switchInputMethod_002 catch error:" + err);
done();
}
});
});
/*
* @tc.number inputmethod_test_showSoftKeyboard_001
* @tc.name Test Indicates the input method which will show softboard with calback.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethod_test_showSoftKeyboard_001', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.showSoftKeyboard((err) => {
try {
if(err == undefined){
expect().assertFail()
done();
}else{
expect(err.code).assertEqual(12800003)
console.info("====>************* inputmethod_test_showSoftKeyboard_001 Test end*************");
done();
}
} catch (err) {
console.info("====>inputmethod_test_showSoftKeyboard_001 err tests fail" + JSON.stringify(err));
done();
}
});
});
/*
* @tc.number inputmethod_test_showSoftKeyboard_002
* @tc.name Test Indicates the input method which will show softboard with Promise.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethod_test_showSoftKeyboard_002', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.showSoftKeyboard().then(() => {
try {
expect().assertFail()
done();
} catch (err) {
console.info("====>inputmethod_test_showSoftKeyboard_002 err tests fail" + JSON.stringify(err));
done();
}
}).catch((err) => {
console.info('====>inputmethod_test_showSoftKeyboard_002 promise failed : ' + JSON.stringify(err))
console.info('====>inputmethod_test_showSoftKeyboard_002 typeof(err.code): ' + typeof(err.code))
console.info('====>inputmethod_test_showSoftKeyboard_002 typeof(err.code): ' + err.code)
expect(err.code).assertEqual(12800003)
console.info("====>************* inputmethod_test_showSoftKeyboard_002 Test end*************");
done();
})
});
/*
* @tc.number inputmethod_test_hideSoftKeyboard_001
* @tc.name Test Indicates the input method which will hide softboard with calback.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethod_test_hideSoftKeyboard_001', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.hideSoftKeyboard((err) => {
try {
if(err == undefined){
expect().assertFail()
done();
}else{
console.info('====>inputmethod_test_hideSoftKeyboard_001 callbacek failed : ' + JSON.stringify(err))
expect(err.code).assertEqual(12800003)
console.info("====>************* inputmethod_test_hideSoftKeyboard_001 Test end*************");
done();
}
} catch (err) {
console.info('====>inputmethod_test_hideSoftKeyboard_001 callbacek failed : ' + JSON.stringify(err))
done();
}
})
});
/*
* @tc.number inputmethod_test_hideSoftKeyboard_002
* @tc.name Test Indicates the input method which will hide softboard with Promise.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethod_test_hideSoftKeyboard_002', 0, async function (done) {
let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.hideSoftKeyboard().then(() => {
try {
expect().assertFail()
done();
} catch (err) {
console.info("====>inputmethod_test_hideSoftKeyboard_002 err tests fail" + JSON.stringify(err));
done();
}
}).catch((err) => {
console.info('====>inputmethod_test_hideSoftKeyboard_002 promise failed : ' + JSON.stringify(err))
expect(err.code).assertEqual(12800003);
console.info("====>************* inputmethod_test_hideSoftKeyboard_002 Test end*************");
done();
})
});
/*
* @tc.number inputmethod_test_getCurrentInputMethod_001
* @tc.name return The InputMethodProperty object of the current input method.
...
...
inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodNormalJSUnit.ets
0 → 100644
浏览文件 @
7eb26d1e
/**
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
import inputMethod from '@ohos.inputMethod';
export default function inputMethodNormalJSUnit() {
describe('inputMethodNormalJSUnit', function () {
console.info("====>************* inputMethodNormalJSUnit settings Test start*************");
/*
* @tc.number inputmethodNomal_test_switchInputMethod_001
* @tc.name Test Indicates the input method which will replace the current one.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethodNomal_test_switchInputMethod_001', 0, async function (done) {
console.info("====>************* inputmethodNomal_test_switchInputMethod_001 Test start*************");
let inputM = inputMethod.getCurrentInputMethod()
console.info("inputmethodNomal_test_switchInputMethod_001 getCurrentInputMethod: " + JSON.stringify(inputM));
let inputMethodProperty = {
packageName: inputM.packageName,
methodId: inputM.methodId,
name: inputM.packageName,
id: inputM.methodId,
extra: {}
}
try{
console.info('====>inputmethodNomal_test_switchInputMethod_001 switchInputMethod permission fail')
await inputMethod.switchInputMethod(inputMethodProperty);
expect().assertFail();
done();
}catch(err){
console.error('====>inputmethodNomal_test_switchInputMethod_001 switchInputMethod catch err' + JSON.stringify(err))
expect(err.code).assertEqual(201);
expect(err.message).assertContain("the permissions check fails");
done();
console.info("====>inputmethodNomal_test_switchInputMethod_001 end");
}
});
/*
* @tc.number inputmethodNomal_test_switchInputMethod_002
* @tc.name Test Indicates the input method which will replace the current one.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethodNomal_test_switchInputMethod_002', 0, async function (done) {
console.info("====>************* inputmethodNomal_test_switchInputMethod_002 Test start*************");
let inputM = inputMethod.getCurrentInputMethod()
console.info("inputmethodNomal_test_switchInputMethod_002 getCurrentInputMethod: " + JSON.stringify(inputM));
let inputMethodProperty = {
packageName: inputM.packageName,
methodId: inputM.methodId,
name: inputM.packageName,
id: inputM.methodId,
extra: {}
}
inputMethod.switchInputMethod(inputMethodProperty, (err, data) => {
try{
if(err){
console.info("====>inputmethodNomal_test_switchInputMethod_002 switchInputMethod permission fail: " + JSON.stringify(err));
expect(err.code).assertEqual(201);
done();
}else{
console.info('====>inputmethodNomal_test_switchInputMethod_002 success: ' + data);
expect().assertFail();
done();
}
}catch(err){
console.error("====>inputmethodNomal_test_switchInputMethod_002 catch err: " + JSON.stringify(err));
done();
console.info("====>inputmethodNomal_test_switchInputMethod_002 end");
}
});
});
/*
* @tc.number inputmethodNomal_test_showSoftKeyboard_001
* @tc.name Test Indicates the input method which will show softboard with calback.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethodNomal_test_showSoftKeyboard_001', 0, async function (done) {
console.info("====>*************inputmethodNomal_test_showSoftKeyboard_001 start******************");
let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.showSoftKeyboard((err, data) => {
try{
if(err){
console.info("====>inputmethodNomal_test_showSoftKeyboard_001 showSoftKeyboard permission fail: " + JSON.stringify(err));
expect(err.code).assertEqual(201);
done();
}else{
console.info('====>inputmethodNomal_test_showSoftKeyboard_001 success: ' + data);
expect().assertFail();
done();
}
}catch(err){
console.error("====>inputmethodNomal_test_showSoftKeyboard_001 catch err: " + JSON.stringify(err));
done();
console.info("====>inputmethodNomal_test_showSoftKeyboard_001 end");
}
});
});
/*
* @tc.number inputmethodNomal_test_showSoftKeyboard_002
* @tc.name Test Indicates the input method which will show softboard with Promise.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethodNomal_test_showSoftKeyboard_002', 0, async function (done) {
console.info("====>*********inputmethodNomal_test_showSoftKeyboard_002 start************");
let inputMethodCtrl = inputMethod.getInputMethodController();
try{
console.info('====>inputmethodNomal_test_showSoftKeyboard_002 showSoftKeyboard permission fail')
await inputMethodCtrl.showSoftKeyboard();
expect().assertFail();
done();
}catch(err){
console.error('====>inputmethodNomal_test_showSoftKeyboard_002 showSoftKeyboard catch err' + JSON.stringify(err))
expect(err.code).assertEqual(201);
expect(err.message).assertContain("the permissions check fails");
done();
console.info("====>inputmethodNomal_test_showSoftKeyboard_002 end");
}
});
/*
* @tc.number inputmethodNomal_test_hideSoftKeyboard_001
* @tc.name Test Indicates the input method which will hide softboard with calback.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethodNomal_test_hideSoftKeyboard_001', 0, async function (done) {
console.info("====>*********inputmethodNomal_test_hideSoftKeyboard_001 start************");
let inputMethodCtrl = inputMethod.getInputMethodController()
inputMethodCtrl.hideSoftKeyboard((err, data) => {
try{
if(err){
console.info("====>inputmethodNomal_test_hideSoftKeyboard_001 hideSoftKeyboard permission fail: " + JSON.stringify(err));
expect(err.code).assertEqual(201);
done();
}else{
console.info('====>inputmethodNomal_test_hideSoftKeyboard_001 success: ' + data);
expect().assertFail();
done();
}
}catch(err){
console.error("====>inputmethodNomal_test_hideSoftKeyboard_001 catch err: " + JSON.stringify(err));
done();
console.info("====>inputmethodNomal_test_hideSoftKeyboard_001 end");
}
});
});
/*
* @tc.number inputmethodNomal_test_hideSoftKeyboard_002
* @tc.name Test Indicates the input method which will hide softboard with Promise.
* @tc.desc Function test
* @tc.level 2
*/
it('inputmethodNomal_test_hideSoftKeyboard_002', 0, async function (done) {
console.info("====>*********inputmethodNomal_test_hideSoftKeyboard_002 start************");
let inputMethodCtrl = inputMethod.getInputMethodController()
try{
console.info('====>inputmethodNomal_test_hideSoftKeyboard_002 hideSoftKeyboard permission fail')
await inputMethodCtrl.hideSoftKeyboard();
expect().assertFail();
done();
}catch(err){
console.error('====>inputmethodNomal_test_hideSoftKeyboard_002 hideSoftKeyboard catch err' + JSON.stringify(err))
expect(err.code).assertEqual(201);
expect(err.message).assertContain("the permissions check fails");
done();
console.info("====>inputmethodNomal_test_hideSoftKeyboard_002 end");
}
});
});
};
inputmethod/InputMethodTest_ets/signature/ActInputMethodEtsAPITest.p7b
浏览文件 @
7eb26d1e
无法预览此类型文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录