2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00

[fenix] Test for 6593

This commit is contained in:
cesar 2019-11-16 17:30:38 -03:00 committed by Emily Kager
parent e60178b0cf
commit 0fd8d98d12
2 changed files with 33 additions and 2 deletions

View File

@ -98,6 +98,19 @@ class BookmarksTest {
addNewFolderName(bookmarksFolderName) addNewFolderName(bookmarksFolderName)
saveNewFolder() saveNewFolder()
verifyFolderTitle(bookmarksFolderName) verifyFolderTitle(bookmarksFolderName)
verifyKeyboardHidden()
}
}
@Test
fun cancelCreateBookmarkFolderTest() {
homeScreen {
}.openThreeDotMenu {
}.openBookmarks {
clickAddFolderButton()
addNewFolderName(bookmarksFolderName)
navigateUp()
verifyKeyboardHidden()
} }
} }

View File

@ -6,7 +6,9 @@
package org.mozilla.fenix.ui.robots package org.mozilla.fenix.ui.robots
import android.content.Context
import android.net.Uri import android.net.Uri
import android.view.inputmethod.InputMethodManager
import androidx.test.espresso.Espresso.onView import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.typeText import androidx.test.espresso.action.ViewActions.typeText
import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.assertion.ViewAssertions.matches
@ -16,10 +18,14 @@ import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withParent import androidx.test.espresso.matcher.ViewMatchers.withParent
import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import org.hamcrest.Matchers.allOf import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.containsString import org.hamcrest.Matchers.containsString
import org.junit.Assert
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.click import org.mozilla.fenix.helpers.click
import java.io.IOException
/** /**
* Implementation of Robot Pattern for the bookmarks menu. * Implementation of Robot Pattern for the bookmarks menu.
@ -50,6 +56,10 @@ class BookmarksRobot {
fun verifyHomeScreen() = HomeScreenRobot().verifyHomeScreen() fun verifyHomeScreen() = HomeScreenRobot().verifyHomeScreen()
fun verifyKeyboardHidden() = assertKeyboardVisibility(isExpectedToBeVisible = false)
fun verifyKeyboardVisible() = assertKeyboardVisibility(isExpectedToBeVisible = true)
fun clickAddFolderButton() { fun clickAddFolderButton() {
addFolderButton().click() addFolderButton().click()
} }
@ -68,11 +78,11 @@ class BookmarksRobot {
} }
class Transition { class Transition {
fun goBack(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition { fun goBack(interact: BookmarksRobot.() -> Unit): Transition {
goBackButton().click() goBackButton().click()
BookmarksRobot().interact() BookmarksRobot().interact()
return BookmarksRobot.Transition() return Transition()
} }
fun openThreeDotMenu(interact: ThreeDotMenuBookmarksRobot.() -> Unit): ThreeDotMenuBookmarksRobot.Transition { fun openThreeDotMenu(interact: ThreeDotMenuBookmarksRobot.() -> Unit): ThreeDotMenuBookmarksRobot.Transition {
@ -155,3 +165,11 @@ private fun assertBookmarkFolderSelector() =
private fun assertBookmarkURLEditBox() = private fun assertBookmarkURLEditBox() =
onView(withId(R.id.bookmarkUrlEdit)) onView(withId(R.id.bookmarkUrlEdit))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
private fun assertKeyboardVisibility(isExpectedToBeVisible: Boolean) =
Assert.assertEquals(
isExpectedToBeVisible,
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
.executeShellCommand("dumpsys input_method | grep mInputShown")
.contains("mInputShown=true")
)