For #26826 - Add test tags for the recent bookmarks section.

This commit is contained in:
Mugurell 2022-09-06 19:08:00 +03:00 committed by mergify[bot]
parent 0924de7753
commit af8e364381

View File

@ -34,10 +34,14 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTag
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
@ -69,6 +73,7 @@ private val imageModifier = Modifier
* @param onRecentBookmarkClick Invoked when the user clicks on a recent bookmark. * @param onRecentBookmarkClick Invoked when the user clicks on a recent bookmark.
* @param onRecentBookmarkLongClick Invoked when the user long clicks on a recent bookmark. * @param onRecentBookmarkLongClick Invoked when the user long clicks on a recent bookmark.
*/ */
@OptIn(ExperimentalComposeUiApi::class)
@Composable @Composable
fun RecentBookmarks( fun RecentBookmarks(
bookmarks: List<RecentBookmark>, bookmarks: List<RecentBookmark>,
@ -78,6 +83,10 @@ fun RecentBookmarks(
onRecentBookmarkLongClick: () -> Unit = {}, onRecentBookmarkLongClick: () -> Unit = {},
) { ) {
LazyRow( LazyRow(
modifier = Modifier.semantics {
testTagsAsResourceId = true
testTag = "recent.bookmarks"
},
contentPadding = PaddingValues(horizontal = 16.dp), contentPadding = PaddingValues(horizontal = 16.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp),
) { ) {
@ -102,7 +111,10 @@ fun RecentBookmarks(
* @param onRecentBookmarkClick Invoked when the user clicks on the recent bookmark item. * @param onRecentBookmarkClick Invoked when the user clicks on the recent bookmark item.
* @param onRecentBookmarkLongClick Invoked when the user long clicks on the recent bookmark item. * @param onRecentBookmarkLongClick Invoked when the user long clicks on the recent bookmark item.
*/ */
@OptIn(ExperimentalFoundationApi::class) @OptIn(
ExperimentalFoundationApi::class,
ExperimentalComposeUiApi::class,
)
@Composable @Composable
private fun RecentBookmarkItem( private fun RecentBookmarkItem(
bookmark: RecentBookmark, bookmark: RecentBookmark,
@ -139,6 +151,10 @@ private fun RecentBookmarkItem(
Text( Text(
text = bookmark.title ?: bookmark.url ?: "", text = bookmark.title ?: bookmark.url ?: "",
modifier = Modifier.semantics {
testTagsAsResourceId = true
testTag = "recent.bookmark.title"
},
color = FirefoxTheme.colors.textPrimary, color = FirefoxTheme.colors.textPrimary,
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
maxLines = 1, maxLines = 1,
@ -222,6 +238,7 @@ private fun PlaceholderBookmarkImage() {
* @param recentBookmark The [RecentBookmark] for which this menu is shown. * @param recentBookmark The [RecentBookmark] for which this menu is shown.
* @param onDismissRequest Called when the user chooses a menu option or requests to dismiss the menu. * @param onDismissRequest Called when the user chooses a menu option or requests to dismiss the menu.
*/ */
@OptIn(ExperimentalComposeUiApi::class)
@Composable @Composable
private fun RecentBookmarksMenu( private fun RecentBookmarksMenu(
showMenu: Boolean, showMenu: Boolean,
@ -233,7 +250,11 @@ private fun RecentBookmarksMenu(
expanded = showMenu, expanded = showMenu,
onDismissRequest = { onDismissRequest() }, onDismissRequest = { onDismissRequest() },
modifier = Modifier modifier = Modifier
.background(color = FirefoxTheme.colors.layer2), .background(color = FirefoxTheme.colors.layer2)
.semantics {
testTagsAsResourceId = true
testTag = "recent.bookmark.menu"
},
) { ) {
for (item in menuItems) { for (item in menuItems) {
DropdownMenuItem( DropdownMenuItem(