Skip to content

Commit 2d24b74

Browse files
committed
Remove unused field uploaderUrl from LongPressable
1 parent f8a508e commit 2d24b74

3 files changed

Lines changed: 16 additions & 39 deletions

File tree

app/src/androidTest/java/org/schabi/newpipe/ui/components/menu/LongPressMenuTest.kt

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,18 @@ class LongPressMenuTest {
162162
var dismissedCount = 0
163163
setLongPressMenu(
164164
onDismissRequest = { dismissedCount += 1 },
165-
longPressable = getLongPressable(uploader = "A", uploaderUrl = "https://example.com"),
165+
longPressable = getLongPressable(uploader = "UpLoAdEr"),
166166
longPressActions = listOf(ShowChannelDetails.buildAction { pressedCount += 1 }),
167167
actionArrangement = listOf()
168168
)
169169

170+
// although ShowChannelDetails is not in the actionArrangement set in user settings (and
171+
// thus the action will not appear in the menu), the LongPressMenu "knows" how to open a
172+
// channel because the longPressActions that can be performed contain ShowChannelDetails,
173+
// therefore the channel name is made clickable in the header
170174
composeRule.onNodeWithText(R.string.show_channel_details, substring = true)
171175
.assertDoesNotExist()
172-
composeRule.onNodeWithText("A", substring = true)
176+
composeRule.onNodeWithText("UpLoAdEr", substring = true)
173177
.assertIsDisplayed()
174178
composeRule.onNodeWithTag("ShowChannelDetails")
175179
.performClick()
@@ -183,11 +187,13 @@ class LongPressMenuTest {
183187
var dismissedCount = 0
184188
setLongPressMenu(
185189
onDismissRequest = { dismissedCount += 1 },
186-
longPressable = getLongPressable(uploader = null, uploaderUrl = "https://example.com"),
190+
longPressable = getLongPressable(uploader = null),
187191
longPressActions = listOf(ShowChannelDetails.buildAction { pressedCount += 1 }),
188192
actionArrangement = listOf()
189193
)
190194

195+
// if the uploader name is not present, we use "Show channel details" as the text for the
196+
// channel opening link in the header
191197
composeRule.onNodeWithText(R.string.show_channel_details, substring = true)
192198
.assertIsDisplayed()
193199
composeRule.onNodeWithTag("ShowChannelDetails")
@@ -198,41 +204,26 @@ class LongPressMenuTest {
198204

199205
@Test
200206
fun testShowChannelDetails3() {
201-
var pressedCount = 0
202-
var dismissedCount = 0
203207
setLongPressMenu(
204-
onDismissRequest = { dismissedCount += 1 },
205-
longPressable = getLongPressable(uploader = null, uploaderUrl = null),
206-
longPressActions = listOf(ShowChannelDetails.buildAction { pressedCount += 1 }),
207-
actionArrangement = listOf()
208-
)
209-
210-
composeRule.onNodeWithText(R.string.show_channel_details, substring = true)
211-
.assertIsDisplayed()
212-
composeRule.onNodeWithTag("ShowChannelDetails")
213-
.performClick()
214-
composeRule.waitUntil { dismissedCount == 1 }
215-
assertEquals(1, pressedCount)
216-
}
217-
218-
@Test
219-
fun testShowChannelDetails4() {
220-
setLongPressMenu(
221-
longPressable = getLongPressable(uploader = "A", uploaderUrl = "https://example.com"),
208+
longPressable = getLongPressable(uploader = "UpLoAdEr"),
222209
longPressActions = listOf(),
223210
actionArrangement = listOf()
224211
)
212+
// the longPressActions that can be performed do not contain ShowChannelDetails, so the
213+
// LongPressMenu cannot "know" how to open channel details
225214
composeRule.onNodeWithTag("ShowChannelDetails")
226215
.assertHasNoClickAction()
227216
}
228217

229218
@Test
230-
fun testShowChannelDetails5() {
219+
fun testShowChannelDetails4() {
231220
setLongPressMenu(
232-
longPressable = getLongPressable(uploader = "A", uploaderUrl = "https://example.com"),
221+
longPressable = getLongPressable(uploader = "UpLoAdEr"),
233222
longPressActions = listOf(ShowChannelDetails.buildAction {}),
234223
actionArrangement = listOf(ShowChannelDetails)
235224
)
225+
// a ShowChannelDetails button is already present among the actions,
226+
// so the channel name isn't clickable in the header
236227
composeRule.onNodeWithTag("ShowChannelDetails")
237228
.assertHasNoClickAction()
238229
}

app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressMenu.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,6 @@ private class LongPressablePreviews : CollectionPreviewParameterProvider<LongPre
674674
url = "https://www.youtube.com/watch?v=YE7VzlLtp-4",
675675
thumbnailUrl = "https://i.ytimg.com/vi_webp/YE7VzlLtp-4/maxresdefault.webp",
676676
uploader = "Blender",
677-
uploaderUrl = "https://www.youtube.com/@BlenderOfficial",
678677
viewCount = 8765432,
679678
streamType = null,
680679
uploadDate = Either.left("16 years ago"),
@@ -685,7 +684,6 @@ private class LongPressablePreviews : CollectionPreviewParameterProvider<LongPre
685684
url = "https://www.youtube.com/watch?v=YE7VzlLtp-4",
686685
thumbnailUrl = null,
687686
uploader = "Blender",
688-
uploaderUrl = "https://www.youtube.com/@BlenderOfficial",
689687
viewCount = 8765432,
690688
streamType = StreamType.VIDEO_STREAM,
691689
uploadDate = Either.left("16 years ago"),
@@ -696,7 +694,6 @@ private class LongPressablePreviews : CollectionPreviewParameterProvider<LongPre
696694
url = "https://www.youtube.com/watch?v=YE7VzlLtp-4",
697695
thumbnailUrl = null,
698696
uploader = null,
699-
uploaderUrl = "https://www.youtube.com/@BlenderOfficial",
700697
viewCount = null,
701698
streamType = null,
702699
uploadDate = null,
@@ -707,7 +704,6 @@ private class LongPressablePreviews : CollectionPreviewParameterProvider<LongPre
707704
url = "https://www.youtube.com/watch?v=YE7VzlLtp-4",
708705
thumbnailUrl = "https://i.ytimg.com/vi_webp/YE7VzlLtp-4/maxresdefault.webp",
709706
uploader = null,
710-
uploaderUrl = null,
711707
viewCount = null,
712708
streamType = StreamType.AUDIO_STREAM,
713709
uploadDate = null,
@@ -718,7 +714,6 @@ private class LongPressablePreviews : CollectionPreviewParameterProvider<LongPre
718714
url = "https://www.youtube.com/watch?v=YE7VzlLtp-4",
719715
thumbnailUrl = "https://i.ytimg.com/vi_webp/YE7VzlLtp-4/maxresdefault.webp",
720716
uploader = null,
721-
uploaderUrl = null,
722717
viewCount = null,
723718
streamType = StreamType.LIVE_STREAM,
724719
uploadDate = null,
@@ -729,7 +724,6 @@ private class LongPressablePreviews : CollectionPreviewParameterProvider<LongPre
729724
url = "https://www.youtube.com/watch?v=YE7VzlLtp-4",
730725
thumbnailUrl = null,
731726
uploader = null,
732-
uploaderUrl = null,
733727
viewCount = null,
734728
streamType = StreamType.AUDIO_LIVE_STREAM,
735729
uploadDate = Either.right(OffsetDateTime.now().minusSeconds(12)),

app/src/main/java/org/schabi/newpipe/ui/components/menu/LongPressable.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ data class LongPressable(
2222
val url: String?,
2323
val thumbnailUrl: String?,
2424
val uploader: String?,
25-
val uploaderUrl: String?,
2625
val viewCount: Long?,
2726
val streamType: StreamType?, // only used to format the view count properly
2827
val uploadDate: Either<String, OffsetDateTime>?,
@@ -49,7 +48,6 @@ data class LongPressable(
4948
url = item.url?.takeIf { it.isNotBlank() },
5049
thumbnailUrl = ImageStrategy.choosePreferredImage(item.thumbnails),
5150
uploader = item.uploaderName?.takeIf { it.isNotBlank() },
52-
uploaderUrl = item.uploaderUrl?.takeIf { it.isNotBlank() },
5351
viewCount = item.viewCount.takeIf { it >= 0 },
5452
streamType = item.streamType,
5553
uploadDate = item.uploadDate?.let { Either.right(it.offsetDateTime()) }
@@ -63,7 +61,6 @@ data class LongPressable(
6361
url = item.url.takeIf { it.isNotBlank() },
6462
thumbnailUrl = item.thumbnailUrl,
6563
uploader = item.uploader.takeIf { it.isNotBlank() },
66-
uploaderUrl = item.uploaderUrl?.takeIf { it.isNotBlank() },
6764
viewCount = item.viewCount?.takeIf { it >= 0 },
6865
streamType = item.streamType,
6966
uploadDate = item.uploadDate?.let { Either.right(it) }
@@ -77,7 +74,6 @@ data class LongPressable(
7774
url = item.url.takeIf { it.isNotBlank() },
7875
thumbnailUrl = ImageStrategy.choosePreferredImage(item.thumbnails),
7976
uploader = item.uploader.takeIf { it.isNotBlank() },
80-
uploaderUrl = item.uploaderUrl?.takeIf { it.isNotBlank() },
8177
viewCount = null,
8278
streamType = item.streamType,
8379
uploadDate = null,
@@ -91,7 +87,6 @@ data class LongPressable(
9187
url = null,
9288
thumbnailUrl = item.thumbnailUrl,
9389
uploader = null,
94-
uploaderUrl = null,
9590
viewCount = null,
9691
streamType = null,
9792
uploadDate = null,
@@ -104,7 +99,6 @@ data class LongPressable(
10499
url = item.url,
105100
thumbnailUrl = item.thumbnailUrl,
106101
uploader = item.uploader,
107-
uploaderUrl = null,
108102
viewCount = null,
109103
streamType = null,
110104
uploadDate = null,
@@ -119,7 +113,6 @@ data class LongPressable(
119113
url = item.url?.takeIf { it.isNotBlank() },
120114
thumbnailUrl = ImageStrategy.choosePreferredImage(item.thumbnails),
121115
uploader = null,
122-
uploaderUrl = item.url?.takeIf { it.isNotBlank() },
123116
viewCount = null,
124117
streamType = null,
125118
uploadDate = null,
@@ -132,7 +125,6 @@ data class LongPressable(
132125
url = item.url?.takeIf { it.isNotBlank() },
133126
thumbnailUrl = ImageStrategy.choosePreferredImage(item.thumbnails),
134127
uploader = item.uploaderName?.takeIf { it.isNotBlank() },
135-
uploaderUrl = item.uploaderUrl?.takeIf { it.isNotBlank() },
136128
viewCount = null,
137129
streamType = null,
138130
uploadDate = null,

0 commit comments

Comments
 (0)