For #26826 - Add test tags for the recent visits section.
This commit is contained in:
parent
5102adc001
commit
0924de7753
|
@ -37,11 +37,15 @@ import androidx.compose.runtime.mutableStateOf
|
|||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
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.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
@ -69,6 +73,7 @@ private const val VISITS_PER_COLUMN = 3
|
|||
* @param onRecentVisitClick Invoked when the user clicks on a recent visit.
|
||||
* @param onRecentVisitLongClick Invoked when the user long clicks on a recent visit.
|
||||
*/
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
@Composable
|
||||
fun RecentlyVisited(
|
||||
recentVisits: List<RecentlyVisitedItem>,
|
||||
|
@ -87,6 +92,10 @@ fun RecentlyVisited(
|
|||
val flingBehavior = EagerFlingBehavior(lazyRowState = listState)
|
||||
|
||||
LazyRow(
|
||||
modifier = Modifier.semantics {
|
||||
testTagsAsResourceId = true
|
||||
testTag = "recent.visits"
|
||||
},
|
||||
state = listState,
|
||||
contentPadding = PaddingValues(16.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(32.dp),
|
||||
|
@ -138,7 +147,10 @@ fun RecentlyVisited(
|
|||
* @param onRecentVisitClick Invoked when the user clicks on a recent visit.
|
||||
* @param onRecentVisitClick Invoked when the user long clicks on a recently visited group.
|
||||
*/
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@OptIn(
|
||||
ExperimentalFoundationApi::class,
|
||||
ExperimentalComposeUiApi::class,
|
||||
)
|
||||
@Suppress("LongParameterList")
|
||||
@Composable
|
||||
private fun RecentlyVisitedHistoryGroup(
|
||||
|
@ -161,7 +173,11 @@ private fun RecentlyVisitedHistoryGroup(
|
|||
isMenuExpanded = true
|
||||
},
|
||||
)
|
||||
.size(268.dp, 56.dp),
|
||||
.size(268.dp, 56.dp)
|
||||
.semantics {
|
||||
testTagsAsResourceId = true
|
||||
testTag = "recent.visits.group"
|
||||
},
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Image(
|
||||
|
@ -179,12 +195,21 @@ private fun RecentlyVisitedHistoryGroup(
|
|||
text = recentVisit.title,
|
||||
modifier = Modifier
|
||||
.padding(top = 7.dp, bottom = 2.dp)
|
||||
.weight(1f),
|
||||
.weight(1f)
|
||||
.semantics {
|
||||
testTagsAsResourceId = true
|
||||
testTag = "recent.visits.group.title"
|
||||
},
|
||||
)
|
||||
|
||||
RecentlyVisitedCaption(
|
||||
count = recentVisit.historyMetadata.size,
|
||||
modifier = Modifier.weight(1f),
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.semantics {
|
||||
testTagsAsResourceId = true
|
||||
testTag = "recent.visits.group.caption"
|
||||
},
|
||||
)
|
||||
|
||||
if (showDividerLine) {
|
||||
|
@ -211,7 +236,10 @@ private fun RecentlyVisitedHistoryGroup(
|
|||
* @param onRecentVisitClick Invoked when the user clicks on a recent visit.
|
||||
* @param onRecentVisitLongClick Invoked when the user long clicks on a recent visit highlight.
|
||||
*/
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@OptIn(
|
||||
ExperimentalFoundationApi::class,
|
||||
ExperimentalComposeUiApi::class,
|
||||
)
|
||||
@Suppress("LongParameterList")
|
||||
@Composable
|
||||
private fun RecentlyVisitedHistoryHighlight(
|
||||
|
@ -234,7 +262,11 @@ private fun RecentlyVisitedHistoryHighlight(
|
|||
isMenuExpanded = true
|
||||
},
|
||||
)
|
||||
.size(268.dp, 56.dp),
|
||||
.size(268.dp, 56.dp)
|
||||
.semantics {
|
||||
testTagsAsResourceId = true
|
||||
testTag = "recent.visits.highlight"
|
||||
},
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Favicon(url = recentVisit.url, size = 24.dp)
|
||||
|
@ -244,7 +276,12 @@ private fun RecentlyVisitedHistoryHighlight(
|
|||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
RecentlyVisitedTitle(
|
||||
text = recentVisit.title.trimmed(),
|
||||
modifier = Modifier.align(Alignment.CenterStart),
|
||||
modifier = Modifier
|
||||
.align(Alignment.CenterStart)
|
||||
.semantics {
|
||||
testTagsAsResourceId = true
|
||||
testTag = "recent.visits.highlight.title"
|
||||
},
|
||||
)
|
||||
|
||||
if (showDividerLine) {
|
||||
|
@ -322,6 +359,7 @@ private fun RecentlyVisitedCaption(
|
|||
* @param recentVisit The [RecentlyVisitedItem] for which this menu is shown.
|
||||
* @param onDismissRequest Called when the user chooses a menu option or requests to dismiss the menu.
|
||||
*/
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
@Composable
|
||||
private fun RecentlyVisitedMenu(
|
||||
showMenu: Boolean,
|
||||
|
@ -337,7 +375,11 @@ private fun RecentlyVisitedMenu(
|
|||
expanded = showMenu,
|
||||
onDismissRequest = { onDismissRequest() },
|
||||
modifier = Modifier
|
||||
.background(color = FirefoxTheme.colors.layer2),
|
||||
.background(color = FirefoxTheme.colors.layer2)
|
||||
.semantics {
|
||||
testTagsAsResourceId = true
|
||||
testTag = "recent.visit.menu"
|
||||
},
|
||||
) {
|
||||
for (item in menuItems) {
|
||||
DropdownMenuItem(
|
||||
|
|
Loading…
Reference in New Issue