diff --git a/inputmethod/InputMethodTest_Stage/BUILD.gn b/inputmethod/InputMethodTest_Stage/BUILD.gn index 22bcaf9aff7356c62d2e4f70e75bb1aa64f6639f..1740ea7d46b8040d7a35c8ed768532705d10daab 100644 --- a/inputmethod/InputMethodTest_Stage/BUILD.gn +++ b/inputmethod/InputMethodTest_Stage/BUILD.gn @@ -21,7 +21,7 @@ ohos_js_hap_suite("ActsImeAbilityTest") { ":IMExtAbility_resources", ] ets2abc = true - certificate_profile = "signature/openharmony_sx.p7b" + certificate_profile = "signature/ActInputMethodStageAPITest.p7b" hap_name = "ActsImeAbilityTest" subsystem_name = "inputmethod" part_name = "imf" diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/ImExtAbility/ImExtAbility.ets b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/ImExtAbility/ImExtAbility.ets index 91c399cdc4eea149d4fbe98619d67eb3358220f5..396025b2193abdc53399662b13abe2c20501d1c2 100644 --- a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/ImExtAbility/ImExtAbility.ets +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/ImExtAbility/ImExtAbility.ets @@ -71,7 +71,6 @@ export default class ImExtAbility extends inputMethodExtensionAbility { }).catch((err) => { console.info('startAbility004 terminateSelf fail: ' + JSON.stringify(err)); }) - } onDestroy() { diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/List.test.ets b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/List.test.ets index f4b5df5861b928b81c17be1480103d8c980c0b02..7e02a072500d00dc853e6d0ee16b1d7c3dd4acee 100644 --- a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/List.test.ets +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/List.test.ets @@ -13,7 +13,10 @@ * limitations under the License. */ import imeAbilityTest from './imeAbilityTest.test' +import inputMethodStageJSUnit from './inputMethodStageJSUnit'; + export default function testsuite() { - imeAbilityTest(globalThis.abilityContext) + imeAbilityTest(globalThis.abilityContext); + inputMethodStageJSUnit(); } \ No newline at end of file diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets new file mode 100644 index 0000000000000000000000000000000000000000..10921dc614d1a308633f68740ab260ce7004e52c --- /dev/null +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/ets/test/inputMethodStageJSUnit.ets @@ -0,0 +1,582 @@ +/** + * 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 inputMethodStageJSUnit() { + describe('inputMethodTest', function () { + console.info("************* settings Test start*************"); + /* + * @tc.number inputMethod_test_getController_001 + * @tc.name get inputMethod controller + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_getController_001', 0, async function (done) { + console.info("-----------------inputMethod_test_getController_001 start---------------------"); + try{ + let inputMethodControl = inputMethod.getController(); + console.info("inputMethod_test_getController_001 result:" + typeof inputMethodControl); + if(typeof inputMethodControl == "object" ){ + console.info("inputMethod_test_getController_001 getController success"); + expect(true).assertTrue(); + }else{ + console.info("inputMethod_test_getController_001 getController failed"); + expect().assertFail(); + }; + }catch(error){ + console.info("inputMethod_test_getController_001 getController error" + JSON.stringify(error)); + expect().assertFail(); + } + + console.info("-----------------inputMethod_test_getController_001 end---------------------"); + done(); + }); + + /* + * @tc.number inputMethod_test_listInputMethodSubtype_001 + * @tc.name List subtype of the specified input method + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_listInputMethodSubtype_001', 0, async function (done) { + console.info("-----------------inputMethod_test_listInputMethodSubtype_001 start---------------------"); + let inputMethodProperty = { + packageName:"com.example.kikakeyboard", + methodId:"ServiceExtAbility", + name:"com.example.kikakeyboard", + id:"ServiceExtAbility", + label: "", + icon: "", + iconId: 124, + extra:{} + } + + try{ + let inputMethodSetting = inputMethod.getSetting(); + console.info("inputMethod_test_listInputMethodSubtype_001 getSetting result:" + inputMethodSetting); + inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err, data) => { + if(err){ + console.info("inputMethod_test_listInputMethodSubtype_001 failed" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info("inputMethod_test_listInputMethodSubtype_001 listInputMethodSubtype: " + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + }); + }catch(error){ + console.info("inputMethod_test_listInputMethodSubtype_001 listInputMethodSubtype catch error" + JSON.stringify(error)); + expect().assertFail(); + done(); + } + console.info("-----------------inputMethod_test_listInputMethodSubtype_001 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_listInputMethodSubtype_002 + * @tc.name List subtype of the specified input method + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_listInputMethodSubtype_002', 0, async function (done) { + console.info("-----------------inputMethod_test_listInputMethodSubtype_002 start---------------------"); + let inputMethodProperty = { + packageName:"com.example.kikakeyboard", + methodId:"ServiceExtAbility", + name:"com.example.kikakeyboard", + id:"ServiceExtAbility", + label: "", + icon: "", + iconId: 124, + extra:{} + } + + try{ + let inputMethodSetting = inputMethod.getSetting(); + console.info("inputMethod_test_listInputMethodSubtype_002 getSetting result:" + inputMethodSetting); + inputMethodSetting.listInputMethodSubtype(inputMethodProperty, (err, data) => { + if(err){ + console.info("inputMethod_test_listInputMethodSubtype_002 failed" + JSON.stringify(err)); + expect().assertFail(); + done() + } + console.info("inputMethod_test_listInputMethodSubtype_002 listInputMethodSubtype:" + JSON.stringify(data)); + if(data.length >= 1){ + let inputMethodSubtype = data[0] + console.info("inputMethod_test_listInputMethodSubtype_002 inputMethodSubtype" + JSON.stringify(inputMethodSubtype)); + expect(inputMethodSubtype.id != null).assertTrue(); + expect(inputMethodSubtype.label != null).assertTrue(); + done(); + }else{ + console.info("inputMethod_test_listInputMethodSubtype_002 listInputMethodSubtype length less 1"); + expect().assertFail(); + done(); + } + }); + }catch(error){ + console.info("inputMethod_test_listInputMethodSubtype_002 listInputMethodSubtype catch error" + JSON.stringify(error)); + expect().assertFail(); + done(); + } + console.info("-----------------inputMethod_test_listInputMethodSubtype_002 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_listInputMethodSubtype_003 + * @tc.name List subtype of the specified input method + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_listInputMethodSubtype_003', 0, async function (done) { + console.info("-----------------inputMethod_test_listInputMethodSubtype_003 start---------------------"); + let inputMethodProperty = { + packageName:"com.example.kikakeyboard", + methodId:"ServiceExtAbility", + name:"com.example.kikakeyboard", + id:"ServiceExtAbility", + label: "", + icon: "", + iconId: 124, + extra:{} + } + + try{ + let inputMethodSetting = inputMethod.getSetting(); + console.info("inputMethod_test_listInputMethodSubtype_003 getSetting result:" + inputMethodSetting); + inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => { + console.info("inputMethod_test_listInputMethodSubtype_003 listInputMethodSubtype: " + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + }).catch(err => { + console.info("inputMethod_test_listInputMethodSubtype_003 failed" + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + }catch(error){ + console.info("inputMethod_test_listInputMethodSubtype_003 listInputMethodSubtype catch error" + JSON.stringify(error)); + expect().assertFail(); + done(); + } + console.info("-----------------inputMethod_test_listInputMethodSubtype_003 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_listInputMethodSubtype_004 + * @tc.name List subtype of the specified input method + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_listInputMethodSubtype_004', 0, async function (done) { + console.info("-----------------inputMethod_test_listInputMethodSubtype_004 start---------------------"); + let inputMethodProperty = { + packageName:"com.example.kikakeyboard", + methodId:"ServiceExtAbility", + name:"com.example.kikakeyboard", + id:"ServiceExtAbility", + label: "", + icon: "", + iconId: 124, + extra:{} + } + + try{ + let inputMethodSetting = inputMethod.getSetting(); + console.info("inputMethod_test_listInputMethodSubtype_004 getSetting result:" + inputMethodSetting); + inputMethodSetting.listInputMethodSubtype(inputMethodProperty).then((data) => { + console.info("inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype:" + JSON.stringify(data)); + if(data.length >= 1){ + let inputMethodSubtype = data[0] + console.info("inputMethod_test_listInputMethodSubtype_004 inputMethodSubtype" + JSON.stringify(inputMethodSubtype)); + expect(inputMethodSubtype.id != null).assertTrue(); + expect(inputMethodSubtype.label != null).assertTrue(); + done(); + }else{ + console.info("inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype length less 1"); + expect().assertFail(); + done(); + } + }).catch(err => { + console.info("inputMethod_test_listInputMethodSubtype_004 failed" + JSON.stringify(err)); + expect().assertFail(); + done() + }); + }catch(error){ + console.info("inputMethod_test_listInputMethodSubtype_004 listInputMethodSubtype catch error" + JSON.stringify(error)); + expect().assertFail(); + done(); + } + console.info("-----------------inputMethod_test_listInputMethodSubtype_004 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_listCurrentInputMethodSubtype_001 + * @tc.name List subtype of the specified input method + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_listCurrentInputMethodSubtype_001', 0, async function (done) { + console.info("-----------------inputMethod_test_listCurrentInputMethodSubtype_001 start---------------------"); + try{ + let inputMethodSetting = inputMethod.getSetting(); + console.info("inputMethod_test_listCurrentInputMethodSubtype_001 getSetting result:" + inputMethodSetting); + inputMethodSetting.listCurrentInputMethodSubtype((err, data) => { + if(err){ + console.info("inputMethod_test_listCurrentInputMethodSubtype_001 failed" + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info("inputMethod_test_listCurrentInputMethodSubtype_001 listCurrentInputMethodSubtype: " + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + }); + }catch(error){ + console.info("inputMethod_test_listCurrentInputMethodSubtype_001 listCurrentInputMethodSubtype catch error" + JSON.stringify(error)); + expect().assertFail(); + done(); + } + console.info("-----------------inputMethod_test_listCurrentInputMethodSubtype_001 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_listInputMethodSubtype_003 + * @tc.name List subtype of current input method + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_listCurrentInputMethodSubtype_002', 0, async function (done) { + console.info("-----------------inputMethod_test_listCurrentInputMethodSubtype_002 start---------------------"); + try{ + let inputMethodSetting = inputMethod.getSetting(); + console.info("inputMethod_test_listCurrentInputMethodSubtype_002 getSetting result:" + inputMethodSetting); + inputMethodSetting.listCurrentInputMethodSubtype().then((data) => { + console.info("inputMethod_test_listCurrentInputMethodSubtype_002 listCurrentInputMethodSubtype: " + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + }).catch(err => { + console.info("inputMethod_test_listCurrentInputMethodSubtype_002 failed" + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + }catch(error){ + console.info("inputMethod_test_listCurrentInputMethodSubtype_002 listCurrentInputMethodSubtype catch error" + JSON.stringify(error)); + expect().assertFail(); + done(); + } + console.info("-----------------inputMethod_test_listCurrentInputMethodSubtype_002 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_getCurrentInputMethodSubtype_001 + * @tc.name Get the current input method subtype + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_getCurrentInputMethodSubtype_001', 0, async function (done) { + console.info("-----------------inputMethod_test_getCurrentInputMethodSubtype_001 start---------------------"); + try{ + let inputMethodSubtype = inputMethod.getCurrentInputMethodSubtype(); + console.info("inputMethod_test_getCurrentInputMethodSubtype_001 result:" + typeof inputMethodSubtype); + if(typeof inputMethodSubtype == "object" ){ + console.info("inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype success"); + expect(true).assertTrue(); + }else{ + console.info("inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype failed"); + expect().assertFail(); + }; + }catch(error){ + console.info("inputMethod_test_getCurrentInputMethodSubtype_001 getCurrentInputMethodSubtype error" + JSON.stringify(error)); + expect().assertFail(); + } + console.info("-----------------inputMethod_test_getCurrentInputMethodSubtype_001 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 inputMethodProperty = { + packageName:"com.example.kikakeyboard", + methodId:"ServiceExtAbility" + } + let inputMethodSubProperty : subtype = { + id: "com.example.kikakeyboard", + label: "ServiceExtAbility", + name: "", + mode: "upper", + locale: "", + language: "", + icon: "", + iconId: 0, + extra: {} + } + try { + inputMethod.switchCurrentInputMethodAndSubtype(inputMethodProperty, inputMethodSubProperty, (err,data) => { + 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)); + expect().assertFail(); + 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 inputMethodProperty = { + packageName:"com.example.kikakeyboard", + methodId:"ServiceExtAbility" + } + let inputMethodSubProperty : subtype = { + id: "com.example.kikakeyboard", + label: "ServiceExtAbility", + 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 inputMethodSubProperty : subtype = { + id: "com.example.kikakeyboard", + label: "ServiceExtAbility", + name: "", + mode: "upper", + locale: "", + language: "", + icon: "", + iconId: 0, + extra: {} + } + try { + inputMethod.switchCurrentInputMethodSubtype(inputMethodSubProperty, (err,data) => { + 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)); + expect().assertFail(); + 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 inputMethodSubProperty : subtype = { + id: "com.example.kikakeyboard", + label: "ServiceExtAbility", + 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*************"); + done(); + }); + + /* + * @tc.number inputMethod_test_showOptionalInputMethods_001 + * @tc.name Show input method setting extension dialog + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_showOptionalInputMethods_001', 0, async function (done) { + console.info("-----------------inputMethod_test_showOptionalInputMethods_001 start---------------------"); + let inputMethodSetting = inputMethod.getSetting(); + try{ + console.info("inputMethod_test_showOptionalInputMethods_001 result:" + inputMethodSetting); + inputMethodSetting.showOptionalInputMethods((err, data) => { + if(err){ + console.info("inputMethod_test_showOptionalInputMethods_001 showOptionalInputMethods faild: " + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info("inputMethod_test_showOptionalInputMethods_001 showOptionalInputMethods success data is : " + data); + expect(true).assertTrue(); + done(); + }); + }catch(error){ + console.info("inputMethod_test_showOptionalInputMethods_001 showOptionalInputMethods catch error: " + JSON.stringify(error)); + expect().assertFail(); + done(); + } + console.info("-----------------inputMethod_test_showOptionalInputMethods_001 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_showOptionalInputMethods_002 + * @tc.name Show input method setting extension dialog + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_showOptionalInputMethods_002', 0, async function (done) { + console.info("-----------------inputMethod_test_showOptionalInputMethods_002 start---------------------"); + let inputMethodSetting = inputMethod.getSetting(); + try { + console.info("inputMethod_test_showOptionalInputMethods_002 result:" + JSON.stringify(inputMethodSetting)); + inputMethodSetting.showOptionalInputMethods().then((data) => { + console.info("inputMethod_test_showOptionalInputMethods_002 showOptionalInputMethods catch error: " + JSON.stringify(data)); + expect(true).assertTrue(); + done(); + }).catch(err => { + console.info("inputMethod_test_showOptionalInputMethods_002 showOptionalInputMethods faild: " + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + } catch (error) { + console.info("inputMethod_test_showOptionalInputMethods_002 showOptionalInputMethods catch error: " + JSON.stringify(error)); + expect().assertFail(); + done(); + } + console.info("-----------------inputMethod_test_showOptionalInputMethods_002 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_stopInputSession_002 + * @tc.name Stop input + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_stopInputSession_002', 0, async function (done) { + console.info("-----------------inputMethod_test_stopInputSession_002 start---------------------"); + try{ + let inputMethodCtrl = inputMethod.getController(); + console.info("inputMethod_test_stopInputSession_002 result:" + typeof inputMethodCtrl); + inputMethodCtrl.stopInputSession().then((data) => { + console.info("inputMethod_test_stopInputSession_002 stopInputSession data: " + data); + expect(data == true).assertTrue(); + done(); + }).catch(err => { + console.info("inputMethod_test_stopInputSession_002 faild: " + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + }catch(error){ + console.info("inputMethod_test_stopInputSession_002 catch error" + JSON.stringify(error)); + expect().assertFail(); + done(); + } + console.info("-----------------inputMethod_test_stopInputSession_002 end---------------------"); + }); + + /* + * @tc.number inputMethod_test_stopInputSession_001 + * @tc.name Stop input + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethod_test_stopInputSession_001', 0, async function (done) { + console.info("-----------------inputMethod_test_stopInputSession_001 start---------------------"); + try{ + let inputMethodCtrl = inputMethod.getController(); + console.info("inputMethod_test_stopInputSession_001 result: " + typeof inputMethodCtrl); + inputMethodCtrl.stopInputSession((err, data) => { + if(err){ + console.info("inputMethod_test_stopInputSession_001 faild: " + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info("inputMethod_test_stopInputSession_001 stopInputSession data: " + data); + expect(data == true).assertTrue(); + done(); + }); + }catch(error){ + console.info("inputMethod_test_stopInputSession_001 catch error" + JSON.stringify(error)); + expect().assertFail(); + done(); + } + console.info("-----------------inputMethod_test_stopInputSession_001 end---------------------"); + }); + + }); +}; diff --git a/inputmethod/InputMethodTest_Stage/entry/src/main/module.json b/inputmethod/InputMethodTest_Stage/entry/src/main/module.json index dca1411321793117777c88609ee1e1167bb1d09e..dca256da79b41f5e9cced68363af95b2d580f0e9 100644 --- a/inputmethod/InputMethodTest_Stage/entry/src/main/module.json +++ b/inputmethod/InputMethodTest_Stage/entry/src/main/module.json @@ -48,7 +48,10 @@ { "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" - } + }, + { + "name": "ohos.permission.CONNECT_IME_ABILITY" + } ] } } diff --git a/inputmethod/InputMethodTest_Stage/signature/openharmony_sx.p7b b/inputmethod/InputMethodTest_Stage/signature/ActInputMethodStageAPITest.p7b similarity index 53% rename from inputmethod/InputMethodTest_Stage/signature/openharmony_sx.p7b rename to inputmethod/InputMethodTest_Stage/signature/ActInputMethodStageAPITest.p7b index cc53179a48f88f20acc379c138a001e9a15838f6..8ed411649d2a229c9a08527453fa131757be31be 100644 Binary files a/inputmethod/InputMethodTest_Stage/signature/openharmony_sx.p7b and b/inputmethod/InputMethodTest_Stage/signature/ActInputMethodStageAPITest.p7b differ diff --git a/inputmethod/InputMethodTest_ets/BUILD.gn b/inputmethod/InputMethodTest_ets/BUILD.gn index d651d0ccb9aeec7e481de7b5d267c36ac72dc53f..4954a98aff9db6d3996937a0b3e4e0517116ac5f 100644 --- a/inputmethod/InputMethodTest_ets/BUILD.gn +++ b/inputmethod/InputMethodTest_ets/BUILD.gn @@ -23,7 +23,7 @@ ohos_js_hap_suite("ActsInputMethodEtsTest") { ets2abc = true subsystem_name = "inputmethod" part_name = "imf" - certificate_profile = "./signature/openharmony_sx.p7b" + certificate_profile = "./signature/ActInputMethodEtsAPITest.p7b" hap_name = "ActsInputMethodEtsTest" } ohos_js_assets("inputMethod_ets_assets") { diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/config.json b/inputmethod/InputMethodTest_ets/entry/src/main/config.json index fd4a0dd38d76277900d626aaaf3af193b5498cdb..bec7b076f63280ea7ea9d8bdce0a9167aac5522f 100644 --- a/inputmethod/InputMethodTest_ets/entry/src/main/config.json +++ b/inputmethod/InputMethodTest_ets/entry/src/main/config.json @@ -18,7 +18,7 @@ "name": ".MyApplication", "mainAbility": "com.acts.inputmethodtest.MainAbility", "deviceType": [ - "default", + "default", "phone" ], "distro": { @@ -65,6 +65,11 @@ "launchType": "standard" } ], + "reqPermissions": [ + { + "name": "ohos.permission.CONNECT_IME_ABILITY" + } + ], "js": [ { "mode": { diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/app.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/app.ets index 24a35d9281861cf6070f89e73b370dd50d5b5979..08e6696db4d03fcac7ea35704d83904700f1fd92 100644 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/app.ets +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/MainAbility/app.ets @@ -13,7 +13,7 @@ * limitations under the License. */ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Hypium } from 'hypium/index' +import { Hypium } from '@ohos/hypium' import testsuite from '../test/List.test' export default { diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/TestAbility/app.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/TestAbility/app.ets index 9511bef9a9463a9b72db92a826b1d58313ddfe78..e6de87af12386aee0473fc24bd16b5a771c2fb22 100644 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/TestAbility/app.ets +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/TestAbility/app.ets @@ -13,7 +13,7 @@ * limitations under the License. */ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Hypium } from 'hypium/index' +import { Hypium } from '@ohos/hypium' import testsuite from '../test/List.test' export default { diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets index 9ff5e35363e7e5e5e663e03077570f68a0e33ef4..bc05859a4fb8c5ef31619597220558eea2e127cd 100644 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodEngineJSUnit.ets @@ -1,4 +1,3 @@ -// @ts-nocheck /** * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; import inputMethodEngine from '@ohos.inputmethodengine'; import Utils from './Utils'; import router from '@system.router'; @@ -55,11 +54,11 @@ export default function inputMethodEngineJSUnit() { console.info("inputMethodEngine beforeEach inputStart:" + JSON.stringify(kbController)); console.info("inputMethodEngine beforeEach inputStart:" + JSON.stringify(textInputClient)); }); - inputMethodEngineObject.off('keyboardShow', (err) => { - console.info("inputMethodEngine beforeEach keyboardShow:" + err); + inputMethodEngineObject.off('keyboardShow', () => { + console.info("inputMethodEngine beforeEach keyboardShow:"); }); - inputMethodEngineObject.off('keyboardHide', (err) => { - console.info("inputMethodEngine beforeEach keyboardHide:" + err); + inputMethodEngineObject.off('keyboardHide', () => { + console.info("inputMethodEngine beforeEach keyboardHide:"); }); KeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); KeyboardDelegate.off('keyDown', (keyEvent) => { @@ -101,11 +100,11 @@ export default function inputMethodEngineJSUnit() { textInputClient = textInputClient; kbController = kbController; }); - inputMethodEngineObject.on('keyboardShow', (err) => { - console.info("inputMethodEngine beforeEach keyboardShow:" + err); + inputMethodEngineObject.on('keyboardShow', () => { + console.info("inputMethodEngine beforeEach keyboardShow:"); }); - inputMethodEngineObject.on('keyboardHide', (err) => { - console.info("inputMethodEngine beforeEach keyboardHide:" + err); + inputMethodEngineObject.on('keyboardHide', () => { + console.info("inputMethodEngine beforeEach keyboardHide:"); }); mKeyboardDelegate = inputMethodEngine.createKeyboardDelegate(); mKeyboardDelegate.on('keyDown', (keyEvent) => { @@ -337,6 +336,8 @@ export default function inputMethodEngineJSUnit() { x: x_value, y: y_value, type: TouchType.Move, + screenX: rect.left + (rect.right - rect.left) / 10, + screenY: rect.left + (rect.right - rect.left) / 10, } console.info('[inputMethodEngine_test_027] testSendTouchEvent ' + sendTouchEvent(point)); await Utils.sleep(1000) @@ -489,7 +490,7 @@ export default function inputMethodEngineJSUnit() { expect(textInputClient == null).assertEqual(true); } else { textInputClient.getEditorAttribute(1, (editorAttribute) => { - console.info("inputMethodEngine_test_038 getEditorAttribute:" + value); + console.info("inputMethodEngine_test_038 getEditorAttribute:" + editorAttribute); expect(editorAttribute.inputPattern).assertEqual(1); expect(editorAttribute.enterKeyType).assertEqual(1); }); @@ -519,7 +520,7 @@ export default function inputMethodEngineJSUnit() { expect(kbController == null).assertEqual(true); } else { kbController.hideKeyboard(() => { - console.info("inputMethodEngine_test_040 hideKeyboard:" + value); + console.info("inputMethodEngine_test_040 hideKeyboard"); expect(1 == 1).assertTrue(); }); } @@ -631,5 +632,85 @@ export default function inputMethodEngineJSUnit() { done(); }) + it('inputMethodEngine_test_049', 0, async function (done) { + if (kbController == null) { + expect(kbController == null).assertEqual(true); + } else { + kbController.hide(() => { + console.info("inputMethodEngine_test_049 hideKeyboard:"); + expect(1 == 1).assertTrue(); + }); + } + done(); + }); + + it('inputMethodEngine_test_050', 0, async function (done) { + if (kbController == null) { + expect(kbController == null).assertEqual(true); + } else { + let promise = kbController.hide(); + promise.then(res => { + console.info("inputMethodEngine_test_050 hideKeyboard promise result-----" + JSON.stringify(res)); + expect(1 == 1).assertTrue(); + }).catch(err => { + console.info("inputMethodEngine_test_050 hideKeyboard promise error----" + JSON.stringify(err)); + expect().assertFail(); + }); + } + done(); + }); + + /* + * @tc.number inputMethodEngine_test_getInputMethodAbility_001 + * @tc.name InputMethodAbility object of the current input method. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethodEngine_test_getInputMethodAbility_001', 0, async function (done) { + console.info("-----------------inputMethodEngine_test_getInputMethodAbility_001 start---------------------"); + try{ + let inputMethodAbility = inputMethodEngine.getInputMethodAbility(); + console.info("inputMethodEngine_test_getInputMethodAbility_001 result:" + typeof inputMethodAbility); + if(typeof inputMethodAbility == "object" ){ + console.info("inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype success"); + expect(true).assertTrue(); + }else{ + console.info("inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype failed"); + expect().assertFail(); + }; + }catch(error){ + console.info("inputMethodEngine_test_getInputMethodAbility_001 getCurrentInputMethodSubtype error" + JSON.stringify(error)); + expect().assertFail(); + } + console.info("-----------------inputMethodEngine_test_getInputMethodAbility_001 end---------------------"); + done(); + }); + + /* + * @tc.number inputMethodEngine_test_getKeyboardDelegate_001 + * @tc.name KeyboardDelegate object of the current input method. + * @tc.desc Function test + * @tc.level 2 + */ + it('inputMethodEngine_test_getKeyboardDelegate_001', 0, async function (done) { + console.info("-----------------inputMethodEngine_test_getKeyboardDelegate_001 start---------------------"); + try{ + let inputMethodAbility = inputMethodEngine.getKeyboardDelegate(); + console.info("inputMethodEngine_test_getKeyboardDelegate_001 result:" + typeof inputMethodAbility); + if(typeof inputMethodAbility == "object" ){ + console.info("inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype success"); + expect(true).assertTrue(); + }else{ + console.info("inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype failed"); + expect().assertFail(); + }; + }catch(error){ + console.info("inputMethodEngine_test_getKeyboardDelegate_001 getCurrentInputMethodSubtype error" + JSON.stringify(error)); + expect().assertFail(); + } + console.info("-----------------inputMethodEngine_test_getKeyboardDelegate_001 end---------------------"); + done(); + }); + }) } diff --git a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets index a1c7caa6caf6e0e6e723bcd3444fc8bf2621e8af..bc0f30e892852ba7dc30ed6d660ad9a11d09b257 100644 --- a/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets +++ b/inputmethod/InputMethodTest_ets/entry/src/main/ets/test/inputMethodJSUnit.ets @@ -1,4 +1,3 @@ -// @ts-nocheck /** * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index'; +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'; import inputMethod from '@ohos.inputmethod'; export default function inputMethodJSUnit() { @@ -161,7 +160,7 @@ export default function inputMethodJSUnit() { */ it('inputmethod_test_showSoftKeyboard_001', 0, async function (done) { let inputMethodCtrl = inputMethod.getInputMethodController() - inputMethodCtrl.showSoftKeyboard((data)=>{ + inputMethodCtrl.showSoftKeyboard((err, data)=>{ if(data == undefined){ console.info("showSoftKeyboard callbace success" ); expect(true).assertTrue(); @@ -201,7 +200,7 @@ export default function inputMethodJSUnit() { */ it('inputmethod_test_hideSoftKeyboard_001', 0, async function (done) { let inputMethodCtrl = inputMethod.getInputMethodController() - inputMethodCtrl.hideSoftKeyboard((data)=>{ + inputMethodCtrl.hideSoftKeyboard((err, data)=>{ if(data == undefined){ console.info("hideSoftKeyboard callbace success" ); expect(true).assertTrue(); @@ -251,45 +250,47 @@ export default function inputMethodJSUnit() { }); /* - * @tc.number inputmethod_test_listInputMethod_001 + * @tc.number inputmethod_test_getInputMethods_001 * @tc.name param enable : * if true, collect enabled input methods. * @tc.desc Function test * @tc.level 2 */ - it('inputmethod_test_listInputMethod_001', 0, async function (done) { + it('inputmethod_test_getInputMethods_001', 0, async function (done) { let inputMethodSetting = inputMethod.getInputMethodSetting(); - console.info("inputmethod_test_listInputMethod_001 result:" + JSON.stringify(inputMethodSetting)); - inputMethodSetting.listInputMethod(true, (err, arr) => { + console.info("inputmethod_test_getInputMethods_001 result:" + JSON.stringify(inputMethodSetting)); + inputMethodSetting.getInputMethods(true, (err, arr) => { if (err) { - console.error("inputmethod_test_listInputMethod_001 failed because: " + JSON.stringify(err)); + console.error("inputmethod_test_getInputMethods_001 failed because: " + JSON.stringify(err)); expect().assertFail(); }; - console.info("inputmethod_test_listInputMethod_001 listInputMethod result---" + JSON.stringify(arr)); + console.info("inputmethod_test_getInputMethods_001 listInputMethod result---" + JSON.stringify(arr)); expect(arr != null).assertTrue(); }); done(); }); /* - * @tc.number inputmethod_test_listInputMethod_002 + * @tc.number inputmethod_test_getInputMethods_002 * @tc.name param enable : * if false, collect disabled input methods. * @tc.desc Function test * @tc.level 2 */ - it('inputmethod_test_listInputMethod_002', 0, async function (done) { + it('inputmethod_test_getInputMethods_002', 0, async function (done) { let inputMethodSetting = inputMethod.getInputMethodSetting(); - console.info("inputmethod_test_listInputMethod_002 result:" + JSON.stringify(inputMethodSetting)); - inputMethodSetting.listInputMethod(false, (err, arr) => { + console.info("inputmethod_test_getInputMethods_002 result:" + JSON.stringify(inputMethodSetting)); + inputMethodSetting.getInputMethods(false, (err, arr) => { if (err) { - console.error("inputmethod_test_listInputMethod_002 failed because: " + JSON.stringify(err)); + console.error("inputmethod_test_getInputMethods_002 failed because: " + JSON.stringify(err)); expect().assertFail(); }; - console.info("inputmethod_test_listInputMethod_002 listInputMethod result---" + JSON.stringify(arr)); + console.info("inputmethod_test_getInputMethods_002 listInputMethod result---" + JSON.stringify(arr)); expect(arr != null).assertTrue(); }); done(); }); - }) -} + + + }); +}; diff --git a/inputmethod/InputMethodTest_ets/signature/openharmony_sx.p7b b/inputmethod/InputMethodTest_ets/signature/ActInputMethodEtsAPITest.p7b similarity index 51% rename from inputmethod/InputMethodTest_ets/signature/openharmony_sx.p7b rename to inputmethod/InputMethodTest_ets/signature/ActInputMethodEtsAPITest.p7b index 66b4457a8a81fb8d3356cf46d67226c850944858..8ed411649d2a229c9a08527453fa131757be31be 100644 Binary files a/inputmethod/InputMethodTest_ets/signature/openharmony_sx.p7b and b/inputmethod/InputMethodTest_ets/signature/ActInputMethodEtsAPITest.p7b differ diff --git a/request/RequestTest_ets/entry/src/main/ets/TestAbility/app.ets b/request/RequestTest_ets/entry/src/main/ets/TestAbility/app.ets index 2e4e48f739b88cd4fbcc15d4e54b244d5af51d90..1471da3b550e5b2caecc292938994e40a1c62f62 100644 --- a/request/RequestTest_ets/entry/src/main/ets/TestAbility/app.ets +++ b/request/RequestTest_ets/entry/src/main/ets/TestAbility/app.ets @@ -14,7 +14,7 @@ * limitations under the License. */ import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Hypium } from 'hypium/index' +import { Hypium } from '@ohos/hypium' import testsuite from '../test/List.test' export default { diff --git a/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets b/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets index 7ac28e4a12aed389ae90aa4467bcb0c8f52c7905..6e24a16fe11a2eac163bbe2c688942d75eefad09 100644 --- a/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets +++ b/request/RequestTest_ets/entry/src/main/ets/test/requestDownload.test.ets @@ -673,5 +673,313 @@ export default function requestDownloadJSUnit() { done(); }); + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DELETE_0001 + * @tc.desc Delete the download task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DELETE_0001', 0, async function (done) { + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_delete_0001 is starting-----------------------"); + try { + request.download(downloadConfig, (data) => { + downloadTask = data; + console.info("SUB_REQUEST_DOWNLOAD_API_DELETE_0001 downloadTask: " + downloadTask); + expect(downloadTask != undefined).assertEqual(true); + downloadTask.delete((err, data) => { + if (err) { + console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Failed to delete the download task.'); + expect().assertFail(); + } + console.info('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 Download task delete success.'); + expect(typeof data == "boolean").assertTrue(); + }); + }) + } catch (error) { + console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0001 delete catch error' + error); + expect().assertFail(); + } + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0001 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_DELETE_0002 + * @tc.desc Delete the download task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_DELETE_0002', 0, async function (done) { + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 is starting-----------------------"); + try { + request.download(downloadConfig, (data) => { + downloadTask = data; + console.info("SUB_REQUEST_DOWNLOAD_API_DELETE_0002 downloadTask: " + downloadTask); + expect(downloadTask != undefined).assertEqual(true); + downloadTask.delete().then(data => { + console.info('SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Download task delete success.'); + expect(data == true).assertTrue(); + }).catch((err) => { + console.info('SUB_REQUEST_DOWNLOAD_API_DELETE_0002 Failed to delete the download task.'); + expect().assertFail(); + }) + }) + } catch (error) { + console.error('SUB_REQUEST_DOWNLOAD_API_DELETE_0002 delete catch error'); + expect().assertFail(); + } + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_DELETE_0002 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 + * @tc.desc Suspend the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001', 0, async function (done) { + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 is starting-----------------------"); + try { + request.download(downloadConfig, (data) => { + downloadTask = data; + console.info("SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 downloadTask: " + downloadTask); + expect(downloadTask != undefined).assertEqual(true); + downloadTask.suspend((err, data) => { + if (err) { + console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Failed to suspend the download task.'); + expect().assertFail(); + } + console.info('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Download task suspend success.'); + expect(data == true).assertTrue(); + }); + }) + } + catch(error) { + console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + error); + expect().assertFail(); + } + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 + * @tc.desc Suspend the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002', 0, async function (done) { + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 is starting-----------------------"); + try { + request.download(downloadConfig, (data) => { + downloadTask = data; + console.info("SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 downloadTask: " + downloadTask); + expect(downloadTask != undefined).assertEqual(true); + downloadTask.suspend().then(data => { + console.info('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 Download task suspend success.'); + expect(data == true).assertTrue(); + }).catch((err) => { + console.info('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 Failed to suspend the download task.'); + expect().assertFail(); + }) + }) + } + catch(error){ + console.error('SUB_REQUEST_DOWNLOAD_API_SUSPEND_0001 suspend catch error' + error); + expect().assertFail(); + } + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_SUSPEND_0002 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 + * @tc.desc Restore the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001', 0, async function (done) { + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 is starting-----------------------"); + try{ + request.download(downloadConfig, (data) => { + downloadTask = data; + console.info("SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 downloadTask: " + downloadTask); + expect(downloadTask != undefined).assertEqual(true); + downloadTask.restore((err, data) => { + if (err) { + console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Failed to restore the download task.'); + expect().assertFail(); + } + console.info('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 Download restore success.'); + expect(data == true).assertTrue(); + }); + }); + }catch(error){ + console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + error); + expect().assertFail(); + } + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 + * @tc.desc Restore the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_RESTORE_0002', 0, async function (done) { + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 is starting-----------------------"); + try{ + request.download(downloadConfig, (data) => { + downloadTask = data; + console.info("SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 downloadTask: " + downloadTask); + expect(downloadTask != undefined).assertEqual(true); + downloadTask.restore().then(data => { + console.info('SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Download task restore.'); + expect(data == true).assertTrue(); + }).catch((err) => { + console.info('SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 Failed to restore the download task.'); + expect().assertFail(); + }); + }); + }catch(error){ + console.error('SUB_REQUEST_DOWNLOAD_API_RESTORE_0001 restore catch error' + error); + expect().assertFail(); + } + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_RESTORE_0002 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 + * @tc.desc Get the download task info + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001', 0, async function (done) { + console.info("---------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 is starting---------------------"); + try{ + request.download(downloadConfig, (data) => { + downloadTask = data; + console.info("SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 downloadTask: " + downloadTask); + expect(downloadTask != undefined).assertEqual(true); + downloadTask.getTaskInfo((err, data) => { + if (err) { + console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Failed to getTaskInfo the download task.'); + expect().assertFail(); + } + console.info('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 Download getTaskInfo success.'); + expect(typeof data == "object").assertTrue(); + }); + }); + }catch(error){ + console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + error); + expect().assertFail(); + } + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 + * @tc.desc Get the download task info + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002', 0, async function (done) { + console.info("-------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 is starting----------------------"); + try{ + request.download(downloadConfig, (data) => { + downloadTask = data; + console.info("SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 downloadTask: " + downloadTask); + expect(downloadTask != undefined).assertEqual(true); + downloadTask.getTaskInfo().then(data => { + console.info('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Download task getTaskInfo success.'); + expect(typeof data == "object").assertTrue(); + }).catch((err) => { + console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 Failed to getTaskInfo the download task.'); + expect().assertFail(); + }); + }); + }catch(error){ + console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0001 getTaskInfo catch error' + error); + expect().assertFail(); + } + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKINFO_0002 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 + * @tc.desc Get mimetype of the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001', 0, async function (done) { + console.info("---------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 is starting---------------------"); + try{ + request.download(downloadConfig, (data) => { + downloadTask = data; + console.info("SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 downloadTask: " + downloadTask); + expect(downloadTask != undefined).assertEqual(true); + downloadTask.getTaskMimeType((err, data) => { + if (err) { + console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 Failed to getTaskMimeType the download task.'); + expect().assertFail(); + } + console.info('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 Download task getTaskMimeType success.'); + expect(typeof data == "string").assertTrue(); + }); + }); + }catch(error){ + console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 getTaskMimeType catch error' + error); + expect().assertFail(); + } + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 + * @tc.desc Get mimetype of the download task + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002', 0, async function (done) { + console.info("-------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 is starting----------------------"); + try{ + request.download(downloadConfig, (data) => { + downloadTask = data; + console.info("SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 downloadTask: " + downloadTask); + expect(downloadTask != undefined).assertEqual(true); + downloadTask.getTaskMimeType().then(data => { + console.info('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 Download getTaskMimeType success.'); + expect(typeof data == "string").assertTrue(); + }).catch((err) => { + console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 Failed to getTaskMimeType the download task.'); + expect().assertFail(); + }); + }); + }catch(error){ + console.error('SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0001 getTaskMimeType catch error' + error); + expect().assertFail(); + } + console.info("-----------------------SUB_REQUEST_DOWNLOAD_API_GETTASKMIMETYPE_0002 end-----------------------"); + done(); + }); + + }) } diff --git a/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets b/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets index 0371cc1af26ffb0496173c2e79a404af3c5f4a90..7ea249536b5f9ff269111b390023d06113d04388 100644 --- a/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets +++ b/request/RequestTest_ets/entry/src/main/ets/test/requestUpload.test.ets @@ -376,5 +376,67 @@ export default function requestUploadJSUnit() { done(); }); + /** + * @tc.number SUB_REQUEST_UPLOAD_API_DELETE_0001 + * @tc.desc Delete the upload task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_UPLOAD_API_DELETE_0001', 0, async function (done) { + console.info("-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 is starting-----------------------"); + try { + request.upload(uploadConfig, (data) => { + uploadTask = data; + console.info("SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask: " + uploadTask); + expect(uploadTask != undefined).assertEqual(true); + uploadTask.delete((err, data) => { + if (err) { + console.error('SUB_REQUEST_UPLOAD_API_DELETE_0001 Failed to delete the uploadTask task.'); + expect().assertFail(); + } + console.info('SUB_REQUEST_UPLOAD_API_DELETE_0001 uploadTask task delete success.'); + expect(typeof data == "boolean").assertTrue(); + }); + }) + } catch (error) { + console.error('SUB_REQUEST_UPLOAD_API_DELETE_0001 delete catch error' + error); + expect().assertFail(); + } + console.info("-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0001 end-----------------------"); + done(); + }); + + /** + * @tc.number SUB_REQUEST_UPLOAD_API_DELETE_0002 + * @tc.desc Delete the upload task. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 2 + */ + it('SUB_REQUEST_UPLOAD_API_DELETE_0002', 0, async function (done) { + console.info("-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 is starting-----------------------"); + try { + request.upload(uploadConfig, (data) => { + uploadTask = data; + console.info("SUB_REQUEST_UPLOAD_API_DELETE_0002 uploadTask: " + uploadTask); + expect(uploadTask != undefined).assertEqual(true); + uploadTask.delete().then(data => { + console.info('SUB_REQUEST_UPLOAD_API_DELETE_0002 uploadTask task delete success.'); + expect(data == true).assertTrue(); + }).catch((err) => { + console.info('SUB_REQUEST_UPLOAD_API_DELETE_0002 Failed to delete the uploadTask task.'); + expect().assertFail(); + }) + }) + } catch (error) { + console.error('SUB_REQUEST_UPLOAD_API_DELETE_0002 delete catch error'); + expect().assertFail(); + } + console.info("-----------------------SUB_REQUEST_UPLOAD_API_DELETE_0002 end-----------------------"); + done(); + }); + + }) } diff --git a/theme/screenlock_ets/entry/src/main/ets/test/screenLockTest.ets b/theme/screenlock_ets/entry/src/main/ets/test/screenLockTest.ets index b964df1a146599c72dd46f326f78633d12acf571..237b392984d1586eb5a37aee4b9c6e70964ce394 100755 --- a/theme/screenlock_ets/entry/src/main/ets/test/screenLockTest.ets +++ b/theme/screenlock_ets/entry/src/main/ets/test/screenLockTest.ets @@ -33,6 +33,59 @@ export default function screenLockJSUnit() { return; } } + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_0012 + * @tc.name Test unlock() to Unlocks the screen. + * @tc.desc Function test + * @tc.level 0 + */ + it('SUB_MISC_THEME_screenLock_API_0012', 0, async function (done) { + console.info('------------------SUB_MISC_THEME_screenLock_API_0012 start----------------------'); + try{ + screenLock.unlock((error, data) => { + if (error) { + console.error(`SUB_MISC_THEME_screenLock_API_0012 failed because: ` + JSON.stringify(error)); + expect().assertFail(); + done(); + } + console.log(`SUB_MISC_THEME_screenLock_API_0012 success.`); + expect(true).assertTrue(); + done(); + }); + }catch(err){ + console.info('SUB_MISC_THEME_screenLock_API_0012 catch err : ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info('------------------SUB_MISC_THEME_screenLock_API_0012 end----------------------'); + }) + + /* + * @tc.number SUB_MISC_THEME_screenLock_API_0013 + * @tc.name Test unlock() to Unlocks the screen. + * @tc.desc Function test + * @tc.level 0 + */ + it('SUB_MISC_THEME_screenLock_API_0013', 0, async function (done) { + console.info('------------------SUB_MISC_THEME_screenLock_API_0013 start----------------------'); + try{ + screenLock.unlock().then((data) => { + console.log(`SUB_MISC_THEME_screenLock_API_0013 success.`); + expect(true).assertTrue(); + done(); + }).catch( err => { + console.error(`SUB_MISC_THEME_screenLock_API_0013 failed because: ` + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + }catch(err){ + console.info('SUB_MISC_THEME_screenLock_API_0013 catch err : ' + JSON.stringify(err)); + expect().assertFail(); + done(); + } + console.info('------------------SUB_MISC_THEME_screenLock_API_0013 end----------------------'); + }); /* * @tc.number SUB_MISC_THEME_screenLock_API_0001 diff --git a/theme/wallpaper_ets/Test.json b/theme/wallpaper_ets/Test.json index cb13254b42de66200083ff49ce7cc2dce29b3b5f..5b084a8ac220ddef4d542e038ed6bd70a53acf7f 100755 --- a/theme/wallpaper_ets/Test.json +++ b/theme/wallpaper_ets/Test.json @@ -18,10 +18,11 @@ { "type": "PushKit", "pre-push": [ - "mount -o rw,remount /" + "mount -o rw,remount /", + "mkdir -p /data/app/el2/100/base/com.acts.theme.wallpapertest/haps" ], "push": [ - "wp.png ->/system/etc/wp.png" + "./resource./wallpaper/wp.png ->/data/app/el2/100/base/com.acts.theme.wallpapertest/haps/wp.png" ] } ] diff --git a/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets b/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets index 073e7a82b18acb44b16d0abb99e4598a4259e3ec..9777b2e2c07caaba61616bd4c6e85024c97c2ff2 100755 --- a/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets +++ b/theme/wallpaper_ets/entry/src/main/ets/test/wallpaperTest.ets @@ -14,12 +14,12 @@ */ import wallpaper from '@ohos.wallpaper'; import image from '@ohos.multimedia.image'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; const WALLPAPER_SYSTEM = 0; const WALLPAPER_LOCKSCREEN = 1; -let imageSourceSystem = '/system/etc/wp.png'; -let imageSourceLockscreen = '/system/etc/wp.png'; +let imageSourceSystem = '/data/storage/el2/base/haps/wp.png'; +let imageSourceLockscreen = '/data/storage/el2/base/haps/wp.png'; export default function wallpaperJSUnit() { describe('WallpaperJsunitTest', function () { @@ -1050,7 +1050,7 @@ export default function wallpaperJSUnit() { */ it('testSetImageCallBack101', 0, async function (done) { console.info('------------------testSetImageCallBack101 start----------------------'); - let wallpaperPath = "/system/etc/wp.png"; + let wallpaperPath = "/data/storage/el2/base/haps/wp.png"; try{ wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { if (error) { @@ -1078,7 +1078,7 @@ export default function wallpaperJSUnit() { */ it('testSetImageCallBack102', 0, async function (done) { console.info('------------------testSetImageCallBack102 start----------------------'); - let wallpaperPath = "/system/etc/wp.png"; + let wallpaperPath = "/data/storage/el2/base/haps/wp.png"; try{ wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN, (error, data) => { if (error) { @@ -1147,7 +1147,7 @@ export default function wallpaperJSUnit() { */ it('testSetImagePromise101', 0, async function (done) { console.info('------------------testSetImagePromise101 start----------------------'); - let wallpaperPath = "/system/etc/wp.png"; + let wallpaperPath = "/data/storage/el2/base/haps/wp.png"; try{ wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { console.log(`testSetImagePromise101 success to setImage.`); @@ -1174,7 +1174,7 @@ export default function wallpaperJSUnit() { */ it('testSetImagePromise102', 0, async function (done) { console.info('------------------testSetImagePromise102 start----------------------'); - let wallpaperPath = "/system/etc/wp.png"; + let wallpaperPath = "/data/storage/el2/base/haps/wp.png"; try{ wallpaper.setImage(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_LOCKSCREEN).then((data) => { console.log(`testSetImagePromise102 success to setImage.`);