From c7efd8a6f6eb4f52b7da39e7515f3371958da940 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Fri, 8 Jul 2022 12:05:44 +0100 Subject: [PATCH] always attempting to close the keyboard to help avoid can't inject events error --- .../androidTest/java/im/vector/app/ui/robot/ElementRobot.kt | 4 ++-- .../java/im/vector/app/ui/robot/MessageMenuRobot.kt | 2 ++ .../java/im/vector/app/ui/robot/RoomDetailRobot.kt | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt index 35027843d6..3b54a8607b 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt @@ -17,6 +17,7 @@ package im.vector.app.ui.robot import android.view.View +import androidx.test.espresso.Espresso.closeSoftKeyboard import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.pressBack import androidx.test.espresso.action.ViewActions @@ -91,8 +92,7 @@ class ElementRobot { waitUntilActivityVisible { waitUntilViewVisible(withId(R.id.userListSearch)) } - // close keyboard - pressBack() + closeSoftKeyboard() block(NewDirectMessageRobot()) pressBack() waitUntilViewVisible(withId(R.id.bottomNavigationView)) diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/MessageMenuRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/MessageMenuRobot.kt index 53ad2af7e6..01a9ec02dc 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/robot/MessageMenuRobot.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/MessageMenuRobot.kt @@ -16,6 +16,7 @@ package im.vector.app.ui.robot +import androidx.test.espresso.Espresso.closeSoftKeyboard import androidx.test.espresso.Espresso.pressBack import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withText @@ -59,6 +60,7 @@ class MessageMenuRobot( clickOn(R.string.message_add_reaction) // Wait for emoji to load, it's async now waitUntilActivityVisible { + closeSoftKeyboard() waitUntilViewVisible(withId(R.id.emojiRecyclerView)) waitUntilViewVisible(withText("😀")) } diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/RoomDetailRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/RoomDetailRobot.kt index 91409582d9..a123484087 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/robot/RoomDetailRobot.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/RoomDetailRobot.kt @@ -17,6 +17,7 @@ package im.vector.app.ui.robot import androidx.recyclerview.widget.RecyclerView +import androidx.test.espresso.Espresso.closeSoftKeyboard import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.pressBack import androidx.test.espresso.action.ViewActions @@ -44,6 +45,7 @@ class RoomDetailRobot { fun postMessage(content: String) { writeTo(R.id.composerEditText, content) + closeSoftKeyboard() waitUntilViewVisible(withId(R.id.sendButton)) clickOn(R.id.sendButton) waitUntilViewVisible(withText(content)) @@ -68,6 +70,7 @@ class RoomDetailRobot { } val threadMessage = "Hello universe - long message to avoid espresso tapping edited!" writeTo(R.id.composerEditText, threadMessage) + closeSoftKeyboard() waitUntilViewVisible(withId(R.id.sendButton)) clickOn(R.id.sendButton) } @@ -105,6 +108,7 @@ class RoomDetailRobot { // TODO Cancel action val edit = "Hello universe - long message to avoid espresso tapping edited!" writeTo(R.id.composerEditText, edit) + closeSoftKeyboard() // Wait a bit for the keyboard layout to update waitUntilViewVisible(withId(R.id.sendButton)) clickOn(R.id.sendButton)