diff --git a/app/src/androidTest/java/org/schabi/newpipe/ui/components/menu/LongPressMenuTest.kt b/app/src/androidTest/java/org/schabi/newpipe/ui/components/menu/LongPressMenuTest.kt index c3b6d4f7b..b17452232 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/ui/components/menu/LongPressMenuTest.kt +++ b/app/src/androidTest/java/org/schabi/newpipe/ui/components/menu/LongPressMenuTest.kt @@ -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() } diff --git a/app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressMenu.kt b/app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressMenu.kt index 830a8e90b..9d442899a 100644 --- a/app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressMenu.kt +++ b/app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressMenu.kt @@ -674,7 +674,6 @@ private class LongPressablePreviews : CollectionPreviewParameterProvider?, @@ -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,