Remove unused field uploaderUrl from LongPressable

This commit is contained in:
Stypox 2026-02-09 09:30:29 +01:00
parent 03325682a1
commit 3b19d637c9
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
3 changed files with 16 additions and 39 deletions

View File

@ -162,14 +162,18 @@ class LongPressMenuTest {
var dismissedCount = 0
setLongPressMenu(
onDismissRequest = { dismissedCount += 1 },
longPressable = getLongPressable(uploader = "A", uploaderUrl = "https://example.com"),
longPressable = getLongPressable(uploader = "UpLoAdEr"),
longPressActions = listOf(ShowChannelDetails.buildAction { pressedCount += 1 }),
actionArrangement = listOf()
)
// although ShowChannelDetails is not in the actionArrangement set in user settings (and
// thus the action will not appear in the menu), the LongPressMenu "knows" how to open a
// channel because the longPressActions that can be performed contain ShowChannelDetails,
// therefore the channel name is made clickable in the header
composeRule.onNodeWithText(R.string.show_channel_details, substring = true)
.assertDoesNotExist()
composeRule.onNodeWithText("A", substring = true)
composeRule.onNodeWithText("UpLoAdEr", substring = true)
.assertIsDisplayed()
composeRule.onNodeWithTag("ShowChannelDetails")
.performClick()
@ -183,11 +187,13 @@ class LongPressMenuTest {
var dismissedCount = 0
setLongPressMenu(
onDismissRequest = { dismissedCount += 1 },
longPressable = getLongPressable(uploader = null, uploaderUrl = "https://example.com"),
longPressable = getLongPressable(uploader = null),
longPressActions = listOf(ShowChannelDetails.buildAction { pressedCount += 1 }),
actionArrangement = listOf()
)
// if the uploader name is not present, we use "Show channel details" as the text for the
// channel opening link in the header
composeRule.onNodeWithText(R.string.show_channel_details, substring = true)
.assertIsDisplayed()
composeRule.onNodeWithTag("ShowChannelDetails")
@ -198,41 +204,26 @@ class LongPressMenuTest {
@Test
fun testShowChannelDetails3() {
var pressedCount = 0
var dismissedCount = 0
setLongPressMenu(
onDismissRequest = { dismissedCount += 1 },
longPressable = getLongPressable(uploader = null, uploaderUrl = null),
longPressActions = listOf(ShowChannelDetails.buildAction { pressedCount += 1 }),
actionArrangement = listOf()
)
composeRule.onNodeWithText(R.string.show_channel_details, substring = true)
.assertIsDisplayed()
composeRule.onNodeWithTag("ShowChannelDetails")
.performClick()
composeRule.waitUntil { dismissedCount == 1 }
assertEquals(1, pressedCount)
}
@Test
fun testShowChannelDetails4() {
setLongPressMenu(
longPressable = getLongPressable(uploader = "A", uploaderUrl = "https://example.com"),
longPressable = getLongPressable(uploader = "UpLoAdEr"),
longPressActions = listOf(),
actionArrangement = listOf()
)
// the longPressActions that can be performed do not contain ShowChannelDetails, so the
// LongPressMenu cannot "know" how to open channel details
composeRule.onNodeWithTag("ShowChannelDetails")
.assertHasNoClickAction()
}
@Test
fun testShowChannelDetails5() {
fun testShowChannelDetails4() {
setLongPressMenu(
longPressable = getLongPressable(uploader = "A", uploaderUrl = "https://example.com"),
longPressable = getLongPressable(uploader = "UpLoAdEr"),
longPressActions = listOf(ShowChannelDetails.buildAction {}),
actionArrangement = listOf(ShowChannelDetails)
)
// a ShowChannelDetails button is already present among the actions,
// so the channel name isn't clickable in the header
composeRule.onNodeWithTag("ShowChannelDetails")
.assertHasNoClickAction()
}

View File

@ -674,7 +674,6 @@ private class LongPressablePreviews : CollectionPreviewParameterProvider<LongPre
url = "https://www.youtube.com/watch?v=YE7VzlLtp-4",
thumbnailUrl = "https://i.ytimg.com/vi_webp/YE7VzlLtp-4/maxresdefault.webp",
uploader = "Blender",
uploaderUrl = "https://www.youtube.com/@BlenderOfficial",
viewCount = 8765432,
streamType = null,
uploadDate = Either.left("16 years ago"),
@ -685,7 +684,6 @@ private class LongPressablePreviews : CollectionPreviewParameterProvider<LongPre
url = "https://www.youtube.com/watch?v=YE7VzlLtp-4",
thumbnailUrl = null,
uploader = "Blender",
uploaderUrl = "https://www.youtube.com/@BlenderOfficial",
viewCount = 8765432,
streamType = StreamType.VIDEO_STREAM,
uploadDate = Either.left("16 years ago"),
@ -696,7 +694,6 @@ private class LongPressablePreviews : CollectionPreviewParameterProvider<LongPre
url = "https://www.youtube.com/watch?v=YE7VzlLtp-4",
thumbnailUrl = null,
uploader = null,
uploaderUrl = "https://www.youtube.com/@BlenderOfficial",
viewCount = null,
streamType = null,
uploadDate = null,
@ -707,7 +704,6 @@ private class LongPressablePreviews : CollectionPreviewParameterProvider<LongPre
url = "https://www.youtube.com/watch?v=YE7VzlLtp-4",
thumbnailUrl = "https://i.ytimg.com/vi_webp/YE7VzlLtp-4/maxresdefault.webp",
uploader = null,
uploaderUrl = null,
viewCount = null,
streamType = StreamType.AUDIO_STREAM,
uploadDate = null,
@ -718,7 +714,6 @@ private class LongPressablePreviews : CollectionPreviewParameterProvider<LongPre
url = "https://www.youtube.com/watch?v=YE7VzlLtp-4",
thumbnailUrl = "https://i.ytimg.com/vi_webp/YE7VzlLtp-4/maxresdefault.webp",
uploader = null,
uploaderUrl = null,
viewCount = null,
streamType = StreamType.LIVE_STREAM,
uploadDate = null,
@ -729,7 +724,6 @@ private class LongPressablePreviews : CollectionPreviewParameterProvider<LongPre
url = "https://www.youtube.com/watch?v=YE7VzlLtp-4",
thumbnailUrl = null,
uploader = null,
uploaderUrl = null,
viewCount = null,
streamType = StreamType.AUDIO_LIVE_STREAM,
uploadDate = Either.right(OffsetDateTime.now().minusSeconds(12)),

View File

@ -22,7 +22,6 @@ data class LongPressable(
val url: String?,
val thumbnailUrl: String?,
val uploader: String?,
val uploaderUrl: String?,
val viewCount: Long?,
val streamType: StreamType?, // only used to format the view count properly
val uploadDate: Either<String, OffsetDateTime>?,
@ -49,7 +48,6 @@ data class LongPressable(
url = item.url?.takeIf { it.isNotBlank() },
thumbnailUrl = ImageStrategy.choosePreferredImage(item.thumbnails),
uploader = item.uploaderName?.takeIf { it.isNotBlank() },
uploaderUrl = item.uploaderUrl?.takeIf { it.isNotBlank() },
viewCount = item.viewCount.takeIf { it >= 0 },
streamType = item.streamType,
uploadDate = item.uploadDate?.let { Either.right(it.offsetDateTime()) }
@ -63,7 +61,6 @@ data class LongPressable(
url = item.url.takeIf { it.isNotBlank() },
thumbnailUrl = item.thumbnailUrl,
uploader = item.uploader.takeIf { it.isNotBlank() },
uploaderUrl = item.uploaderUrl?.takeIf { it.isNotBlank() },
viewCount = item.viewCount?.takeIf { it >= 0 },
streamType = item.streamType,
uploadDate = item.uploadDate?.let { Either.right(it) }
@ -77,7 +74,6 @@ data class LongPressable(
url = item.url.takeIf { it.isNotBlank() },
thumbnailUrl = ImageStrategy.choosePreferredImage(item.thumbnails),
uploader = item.uploader.takeIf { it.isNotBlank() },
uploaderUrl = item.uploaderUrl?.takeIf { it.isNotBlank() },
viewCount = null,
streamType = item.streamType,
uploadDate = null,
@ -91,7 +87,6 @@ data class LongPressable(
url = null,
thumbnailUrl = item.thumbnailUrl,
uploader = null,
uploaderUrl = null,
viewCount = null,
streamType = null,
uploadDate = null,
@ -104,7 +99,6 @@ data class LongPressable(
url = item.url,
thumbnailUrl = item.thumbnailUrl,
uploader = item.uploader,
uploaderUrl = null,
viewCount = null,
streamType = null,
uploadDate = null,
@ -119,7 +113,6 @@ data class LongPressable(
url = item.url?.takeIf { it.isNotBlank() },
thumbnailUrl = ImageStrategy.choosePreferredImage(item.thumbnails),
uploader = null,
uploaderUrl = item.url?.takeIf { it.isNotBlank() },
viewCount = null,
streamType = null,
uploadDate = null,
@ -132,7 +125,6 @@ data class LongPressable(
url = item.url?.takeIf { it.isNotBlank() },
thumbnailUrl = ImageStrategy.choosePreferredImage(item.thumbnails),
uploader = item.uploaderName?.takeIf { it.isNotBlank() },
uploaderUrl = item.uploaderUrl?.takeIf { it.isNotBlank() },
viewCount = null,
streamType = null,
uploadDate = null,