[fenix] Boomkarks UI tests
Added a comment to the clear all bookmarks methodpull/600/head
parent
1687b09ba0
commit
92ac8a2042
@ -0,0 +1,81 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
@file:Suppress("TooManyFunctions")
|
||||
|
||||
package org.mozilla.fenix.ui.robots
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
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.mozilla.fenix.R
|
||||
import org.mozilla.fenix.helpers.click
|
||||
import org.mozilla.fenix.helpers.isSelected
|
||||
|
||||
/**
|
||||
* Implementation of Robot Pattern for the quick action bar.
|
||||
*/
|
||||
class QuickActionBarRobot {
|
||||
|
||||
fun verifyAddBookmarkButton() = assertAddBookmarkButton()
|
||||
|
||||
fun verifyEditBookmarkButton() = assertEditBookmarkButton()
|
||||
|
||||
fun clickBookmarkButton() {
|
||||
addBookmarkButton().click()
|
||||
}
|
||||
|
||||
fun createBookmark(url: Uri) {
|
||||
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(url) {
|
||||
}.openQuickActionBar {
|
||||
clickBookmarkButton()
|
||||
}
|
||||
}
|
||||
|
||||
class Transition {
|
||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||
|
||||
fun closeQuickActionBar(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
quickActionBarHandle().click()
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun quickActionBar(interact: QuickActionBarRobot.() -> Unit): QuickActionBarRobot.Transition {
|
||||
QuickActionBarRobot().interact()
|
||||
return QuickActionBarRobot.Transition()
|
||||
}
|
||||
|
||||
private fun quickActionBarHandle() = onView(withId(R.id.quick_action_sheet_handle))
|
||||
|
||||
private fun addBookmarkButton() =
|
||||
onView(allOf(withId(R.id.quick_action_bookmark), isSelected(false)))
|
||||
|
||||
private fun editBookmarkButton() =
|
||||
onView(allOf(withId(R.id.quick_action_bookmark), isSelected(true)))
|
||||
|
||||
private fun snackBarText() = onView(withId(R.id.snackbar_text))
|
||||
|
||||
private fun assertAddBookmarkButton() = addBookmarkButton()
|
||||
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||
.check(matches(withText("Bookmark")))
|
||||
|
||||
private fun assertBookmarkSavedSnackBarText() =
|
||||
snackBarText().check(matches(withText("Bookmark saved!")))
|
||||
|
||||
private fun assertEditBookmarkButton() = editBookmarkButton().check(matches(withEffectiveVisibility(
|
||||
ViewMatchers.Visibility.VISIBLE)))
|
||||
.check(matches(withText("Edit Bookmark")))
|
@ -0,0 +1,65 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
@file:Suppress("TooManyFunctions")
|
||||
|
||||
package org.mozilla.fenix.ui.robots
|
||||
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import org.mozilla.fenix.helpers.click
|
||||
|
||||
/**
|
||||
* Implementation of Robot Pattern for the Bookmarks three dot menu.
|
||||
*/
|
||||
class ThreeDotMenuBookmarks {
|
||||
|
||||
class Transition {
|
||||
|
||||
fun clickEdit(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition {
|
||||
editButton().click()
|
||||
|
||||
BookmarksRobot().interact()
|
||||
return BookmarksRobot.Transition()
|
||||
}
|
||||
|
||||
fun clickCopy(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition {
|
||||
copyButton().click()
|
||||
|
||||
BookmarksRobot().interact()
|
||||
return BookmarksRobot.Transition()
|
||||
}
|
||||
|
||||
fun clickOpenInNewTab(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
openInNewTabButton().click()
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
}
|
||||
|
||||
fun clickOpenInPrivateTab(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
||||
openInPrivateTabButton().click()
|
||||
|
||||
BrowserRobot().interact()
|
||||
return BrowserRobot.Transition()
|
||||
}
|
||||
|
||||
fun clickDelete(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition {
|
||||
deleteButton().click()
|
||||
|
||||
BookmarksRobot().interact()
|
||||
return BookmarksRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun editButton() = onView(withText("Edit"))
|
||||
|
||||
private fun copyButton() = onView(withText("Copy"))
|
||||
|
||||
private fun openInNewTabButton() = onView(withText("Open in new tab"))
|
||||
|
||||
private fun openInPrivateTabButton() = onView(withText("Open in private tab"))
|
||||
|
||||
private fun deleteButton() = onView(withText("Delete"))
|
Loading…
Reference in New Issue