Bug 1879539 - Add test logs to LibrarySubMenusMultipleSelectionToolbarRobot

fenix/124.1.0
AndiAJ 3 months ago committed by mergify[bot]
parent f9031dd0a2
commit 7dc56f88c0

@ -5,6 +5,7 @@
package org.mozilla.fenix.ui.robots
import android.net.Uri
import android.util.Log
import android.widget.TextView
import androidx.compose.ui.test.onNodeWithTag
import androidx.test.espresso.Espresso.onView
@ -20,6 +21,8 @@ import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.Until
import org.hamcrest.Matchers.allOf
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.Constants
import org.mozilla.fenix.helpers.Constants.TAG
import org.mozilla.fenix.helpers.HomeActivityComposeTestRule
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
@ -34,13 +37,27 @@ import org.mozilla.fenix.tabstray.TabsTrayTestTag
*/
class LibrarySubMenusMultipleSelectionToolbarRobot {
fun verifyMultiSelectionCheckmark() = onView(withId(R.id.checkmark)).check(matches(isDisplayed()))
fun verifyMultiSelectionCheckmark() {
Log.i(TAG, "verifyMultiSelectionCheckmark: Trying to verify that the multi-selection checkmark is displayed")
onView(withId(R.id.checkmark)).check(matches(isDisplayed()))
Log.i(TAG, "verifyMultiSelectionCheckmark: Verified that the multi-selection checkmark is displayed")
}
fun verifyMultiSelectionCheckmark(url: Uri) =
fun verifyMultiSelectionCheckmark(url: Uri) {
Log.i(TAG, "verifyMultiSelectionCheckmark: Trying to verify that the multi-selection checkmark for item with url: $url is displayed")
onView(
allOf(
withId(R.id.checkmark),
withParent(withParent(withChild(allOf(withId(R.id.url), withText(url.toString()))))),
withParent(
withParent(
withChild(
allOf(
withId(R.id.url),
withText(url.toString()),
),
),
),
),
// This is used as part of the `multiSelectionToolbarItemsTest` test. Somehow, in the view hierarchy,
// the match above is finding two checkmark views - one visible, one hidden, which is throwing off
@ -49,14 +66,32 @@ class LibrarySubMenusMultipleSelectionToolbarRobot {
isDisplayed(),
),
).check(matches(isDisplayed()))
Log.i(Constants.TAG, "verifyMultiSelectionCheckmark: Verified that the multi-selection checkmark for item with url: $url is displayed")
}
fun verifyMultiSelectionCounter() = onView(withText("1 selected")).check(matches(isDisplayed()))
fun verifyMultiSelectionCounter() {
Log.i(TAG, "verifyMultiSelectionCounter: Trying to verify that the multi-selection toolbar containing: \"1 selected\" is displayed")
onView(withText("1 selected")).check(matches(isDisplayed()))
Log.i(TAG, "verifyMultiSelectionCounter: Verified that the multi-selection toolbar containing: \"1 selected\" is displayed")
}
fun verifyShareHistoryButton() = shareHistoryButton().check(matches(isDisplayed()))
fun verifyShareHistoryButton() {
Log.i(TAG, "verifyShareHistoryButton: Trying to verify that the multi-selection share history button is displayed")
shareHistoryButton().check(matches(isDisplayed()))
Log.i(TAG, "verifyShareHistoryButton: Verified that the multi-selection share history button is displayed")
}
fun verifyShareBookmarksButton() = shareBookmarksButton().check(matches(isDisplayed()))
fun verifyShareBookmarksButton() {
Log.i(TAG, "verifyShareBookmarksButton: Trying to verify that the multi-selection share bookmarks button is displayed")
shareBookmarksButton().check(matches(isDisplayed()))
Log.i(TAG, "verifyShareBookmarksButton: Verified that the multi-selection share bookmarks button is displayed")
}
fun verifyShareOverlay() = onView(withId(R.id.shareWrapper)).check(matches(isDisplayed()))
fun verifyShareOverlay() {
Log.i(TAG, "verifyShareOverlay: Trying to verify that the share overlay is displayed")
onView(withId(R.id.shareWrapper)).check(matches(isDisplayed()))
Log.i(TAG, "verifyShareOverlay: Verified that the share overlay is displayed")
}
fun verifyShareAppsLayout() {
val sendToDeviceTitle = mDevice.findObject(
@ -67,16 +102,34 @@ class LibrarySubMenusMultipleSelectionToolbarRobot {
sendToDeviceTitle.waitForExists(TestAssetHelper.waitingTime)
}
fun verifyShareTabFavicon() = onView(withId(R.id.share_tab_favicon)).check(matches(isDisplayed()))
fun verifyShareTabFavicon() {
Log.i(TAG, "verifyShareTabFavicon: Trying to verify that the shared tab favicon is displayed")
onView(withId(R.id.share_tab_favicon)).check(matches(isDisplayed()))
Log.i(TAG, "verifyShareTabFavicon: Verified that the shared tab favicon is displayed")
}
fun verifyShareTabTitle() = onView(withId(R.id.share_tab_title)).check(matches(isDisplayed()))
fun verifyShareTabTitle() {
Log.i(TAG, "verifyShareTabTitle: Trying to verify that the shared tab title is displayed")
onView(withId(R.id.share_tab_title)).check(matches(isDisplayed()))
Log.i(TAG, "verifyShareTabTitle: Verified that the shared tab title is displayed")
}
fun verifyShareTabUrl() = onView(withId(R.id.share_tab_url))
fun verifyShareTabUrl() {
Log.i(TAG, "verifyShareTabUrl: Trying to verify that the shared tab url is displayed")
onView(withId(R.id.share_tab_url)).check(matches(isDisplayed()))
Log.i(TAG, "verifyShareTabUrl: Verified that the shared tab url is displayed")
}
fun verifyCloseToolbarButton() = closeToolbarButton().check(matches(isDisplayed()))
fun verifyCloseToolbarButton() {
Log.i(TAG, "verifyCloseToolbarButton: Trying to verify that the navigate up toolbar button is displayed")
closeToolbarButton().check(matches(isDisplayed()))
Log.i(TAG, "verifyCloseToolbarButton: Verified that the navigate up toolbar button is displayed")
}
fun clickShareHistoryButton() {
Log.i(TAG, "clickShareHistoryButton: Trying to click the multi-selection share history button")
shareHistoryButton().click()
Log.i(TAG, "clickShareHistoryButton: Clicked the multi-selection share history button")
mDevice.waitNotNull(
Until.findObject(
@ -87,7 +140,9 @@ class LibrarySubMenusMultipleSelectionToolbarRobot {
}
fun clickShareBookmarksButton() {
Log.i(TAG, "clickShareBookmarksButton: Trying to click the multi-selection share bookmarks button")
shareBookmarksButton().click()
Log.i(TAG, "clickShareBookmarksButton: Clicked the multi-selection share bookmarks button")
mDevice.waitNotNull(
Until.findObject(
@ -98,7 +153,9 @@ class LibrarySubMenusMultipleSelectionToolbarRobot {
}
fun clickMultiSelectionDelete() {
Log.i(TAG, "clickMultiSelectionDelete: Trying to click the multi-selection delete button")
deleteButton().click()
Log.i(TAG, "clickMultiSelectionDelete: Clicked the multi-selection delete button")
}
class Transition {
@ -108,21 +165,28 @@ class LibrarySubMenusMultipleSelectionToolbarRobot {
}
fun closeToolbarReturnToHistory(interact: HistoryRobot.() -> Unit): HistoryRobot.Transition {
Log.i(TAG, "closeToolbarReturnToHistory: Trying to click the navigate up toolbar button")
closeToolbarButton().click()
Log.i(TAG, "closeToolbarReturnToHistory: Clicked the navigate up toolbar button")
HistoryRobot().interact()
return HistoryRobot.Transition()
}
fun closeToolbarReturnToBookmarks(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition {
Log.i(TAG, "closeToolbarReturnToBookmarks: Trying to click the navigate up toolbar button")
closeToolbarButton().click()
Log.i(TAG, "closeToolbarReturnToBookmarks: Clicked the navigate up toolbar button")
BookmarksRobot().interact()
return BookmarksRobot.Transition()
}
fun clickOpenNewTab(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
Log.i(TAG, "clickOpenNewTab: Trying to click the multi-select \"Open in a new tab\" context menu button")
openInNewTabButton().click()
Log.i(TAG, "clickOpenNewTab: Clicked the multi-select \"Open in a new tab\" context menu button")
mDevice.waitNotNull(
Until.findObject(By.res("$packageName:id/tab_layout")),
waitingTime,
@ -133,15 +197,21 @@ class LibrarySubMenusMultipleSelectionToolbarRobot {
}
fun clickOpenNewTab(composeTestRule: HomeActivityComposeTestRule, interact: ComposeTabDrawerRobot.() -> Unit): ComposeTabDrawerRobot.Transition {
Log.i(TAG, "clickOpenNewTab: Trying to click the multi-select \"Open in a new tab\" context menu button")
openInNewTabButton().click()
Log.i(TAG, "clickOpenNewTab: Clicked the multi-select \"Open in a new tab\" context menu button")
Log.i(TAG, "clickOpenNewTab: Trying to verify that the tabs tray exists")
composeTestRule.onNodeWithTag(TabsTrayTestTag.tabsTray).assertExists()
Log.i(TAG, "clickOpenNewTab: Verified that the tabs tray exists")
ComposeTabDrawerRobot(composeTestRule).interact()
return ComposeTabDrawerRobot.Transition(composeTestRule)
}
fun clickOpenPrivateTab(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
Log.i(TAG, "clickOpenPrivateTab: Trying to click the multi-select \"Open in a private tab\" context menu button")
openInPrivateTabButton().click()
Log.i(TAG, "clickOpenPrivateTab: Clicked the multi-select \"Open in a private tab\" context menu button")
mDevice.waitNotNull(
Until.findObject(By.res("$packageName:id/tab_layout")),
waitingTime,
@ -152,7 +222,9 @@ class LibrarySubMenusMultipleSelectionToolbarRobot {
}
fun clickOpenPrivateTab(composeTestRule: HomeActivityComposeTestRule, interact: ComposeTabDrawerRobot.() -> Unit): ComposeTabDrawerRobot.Transition {
Log.i(TAG, "clickOpenPrivateTab: Trying to click the multi-select \"Open in a private tab\" context menu button")
openInPrivateTabButton().click()
Log.i(TAG, "clickOpenPrivateTab: Clicked the multi-select \"Open in a private tab\" context menu button")
ComposeTabDrawerRobot(composeTestRule).interact()
return ComposeTabDrawerRobot.Transition(composeTestRule)

Loading…
Cancel
Save