diff --git a/unitest/src/input_method_ability_test.cpp b/unitest/src/input_method_ability_test.cpp index 5416469b5..78c519aa2 100644 --- a/unitest/src/input_method_ability_test.cpp +++ b/unitest/src/input_method_ability_test.cpp @@ -12,18 +12,25 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include + #include -#include -#include #include -#include + +#include +#include #include +#include +#include + #include "global.h" -#include "input_method_agent_stub.h" -#include "input_method_core_stub.h" -#include "input_control_channel_stub.h" +#include "i_input_data_channel.h" #include "input_attribute.h" +#include "input_control_channel_stub.h" +#include "input_data_channel_proxy.h" +#include "input_data_channel_stub.h" +#include "input_method_agent_stub.h" +#include "input_method_core_proxy.h" +#include "input_method_core_stub.h" #include "message_handler.h" using namespace testing::ext; @@ -89,6 +96,41 @@ namespace MiscServices { EXPECT_TRUE(iface != nullptr); } + /** + * @tc.name: testShowKeyboardInputMethodCoreProxy + * @tc.desc: Test InputMethodCoreProxy ShowKeyboard + * @tc.type: FUNC + */ + HWTEST_F(InputMethodAbilityTest, testShowKeyboardInputMethodCoreProxy, TestSize.Level0) + { + sptr coreStub = new InputMethodCoreStub(0); + sptr core = coreStub; + sptr channelStub = new InputDataChannelStub(); + + MessageParcel data; + data.WriteRemoteObject(core->AsObject()); + data.WriteRemoteObject(channelStub->AsObject()); + sptr coreObject = data.ReadRemoteObject(); + sptr channelObject = data.ReadRemoteObject(); + + sptr coreProxy = new InputMethodCoreProxy(coreObject); + sptr channelProxy = new InputDataChannelProxy(channelObject); + auto ret = coreProxy->showKeyboard(channelProxy, true); + EXPECT_TRUE(ret); + } + + /** + * @tc.name: testShowKeyboardInputMethodCoreStub + * @tc.desc: Test InputMethodCoreStub ShowKeyboard + * @tc.type: FUNC + */ + HWTEST_F(InputMethodAbilityTest, testShowKeyboardInputMethodCoreStub, TestSize.Level0) + { + sptr coreStub = new InputMethodCoreStub(0); + auto ret = coreStub->showKeyboard(nullptr, true); + EXPECT_TRUE(!ret); + } + /** * @tc.name: testReadWriteIInputControlChannel * @tc.desc: Checkout IInputControlChannel. diff --git a/unitest/src/input_method_controller_test.cpp b/unitest/src/input_method_controller_test.cpp index ddbc1f1e2..af90f505b 100644 --- a/unitest/src/input_method_controller_test.cpp +++ b/unitest/src/input_method_controller_test.cpp @@ -12,24 +12,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include -#include -#include -#include -#include -#include -#include -#include "global.h" -#include "utils.h" - #include "input_method_controller.h" -#include "i_input_method_system_ability.h" + +#include +#include + +#include +#include +#include +#include +#include + +#include "global.h" #include "i_input_method_agent.h" -#include "input_data_channel_stub.h" +#include "i_input_method_system_ability.h" #include "input_client_stub.h" +#include "input_data_channel_stub.h" +#include "input_method_setting.h" +#include "input_method_system_ability_proxy.h" #include "iservice_registry.h" #include "system_ability_definition.h" -#include "input_method_setting.h" +#include "utils.h" +#include "message_parcel.h" using namespace testing::ext; namespace OHOS { @@ -226,6 +230,10 @@ namespace MiscServices { imc->Attach(textListener, false); sleep(waitForStatusOk); + IMSA_HILOGI("IMC ShowCurrentInput START"); + imc->ShowCurrentInput(); + sleep(waitForStatusOk); + IMSA_HILOGI("IMC ShowTextInput START"); imc->ShowTextInput(); sleep(10); @@ -239,5 +247,40 @@ namespace MiscServices { sleep(waitForStatusOk); IMSA_HILOGI("IMC TEST OVER"); } + + /** + * @tc.name: testIMCShowCurrentInput + * @tc.desc: IMC ShowCurrentInput. + * @tc.type: FUNC + */ + HWTEST_F(InputMethodControllerTest, testIMCShowCurrentInput, TestSize.Level0) + { + IMSA_HILOGI("IMC ShowCurrentInput Test START"); + sptr imc = InputMethodController::GetInstance(); + EXPECT_TRUE(imc != nullptr); + int32_t ret = imc->ShowCurrentInput(); + EXPECT_TRUE(ret == 0); + } + + /** + * @tc.name: testIMSAProxyShowCurrentInput + * @tc.desc: IMSAProxy ShowCurrentInput. + * @tc.type: FUNC + */ + HWTEST_F(InputMethodControllerTest, testIMSAProxyShowCurrentInput, TestSize.Level0) + { + IMSA_HILOGI("IMSAProxy ShowCurrentInput Test START"); + sptr systemAbilityManager = + SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + + auto systemAbility = systemAbilityManager->GetSystemAbility(INPUT_METHOD_SYSTEM_ABILITY_ID, ""); + + sptr imsaProxy = new InputMethodSystemAbilityProxy(systemAbility); + + MessageParcel data; + data.WriteInterfaceToken(imsaProxy->GetDescriptor()); + int32_t ret = imsaProxy->ShowCurrentInput(data); + EXPECT_TRUE(ret == 0); + } } // namespace MiscServices } // namespace OHOS