Skip to content

Commit 2cb0785

Browse files
committed
Build LongPressAction lists using builder pattern
1 parent ae56f08 commit 2cb0785

3 files changed

Lines changed: 290 additions & 306 deletions

File tree

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class LongPressMenuTest {
100100
*/
101101
private fun setLongPressMenu(
102102
longPressable: LongPressable = getLongPressable(),
103-
longPressActions: List<LongPressAction> = LongPressAction.Type.entries.map { it.buildAction { } },
103+
longPressActions: List<LongPressAction> = LongPressAction.Type.entries.map { LongPressAction(it) { } },
104104
onDismissRequest: () -> Unit = {},
105105
isHeaderEnabled: Boolean = true,
106106
actionArrangement: List<LongPressAction.Type> = LongPressAction.Type.entries
@@ -171,7 +171,7 @@ class LongPressMenuTest {
171171
setLongPressMenu(
172172
onDismissRequest = { dismissedCount += 1 },
173173
longPressable = getLongPressable(uploader = "UpLoAdEr"),
174-
longPressActions = listOf(ShowChannelDetails.buildAction { pressedCount += 1 }),
174+
longPressActions = listOf(LongPressAction(ShowChannelDetails) { pressedCount += 1 }),
175175
actionArrangement = listOf()
176176
)
177177

@@ -196,7 +196,7 @@ class LongPressMenuTest {
196196
setLongPressMenu(
197197
onDismissRequest = { dismissedCount += 1 },
198198
longPressable = getLongPressable(uploader = null),
199-
longPressActions = listOf(ShowChannelDetails.buildAction { pressedCount += 1 }),
199+
longPressActions = listOf(LongPressAction(ShowChannelDetails) { pressedCount += 1 }),
200200
actionArrangement = listOf()
201201
)
202202

@@ -227,7 +227,7 @@ class LongPressMenuTest {
227227
fun testShowChannelDetails4() {
228228
setLongPressMenu(
229229
longPressable = getLongPressable(uploader = "UpLoAdEr"),
230-
longPressActions = listOf(ShowChannelDetails.buildAction {}),
230+
longPressActions = listOf(LongPressAction(ShowChannelDetails) {}),
231231
actionArrangement = listOf(ShowChannelDetails)
232232
)
233233
// a ShowChannelDetails button is already present among the actions,
@@ -444,7 +444,7 @@ class LongPressMenuTest {
444444
expectedShownActions: List<LongPressAction.Type>
445445
) {
446446
setLongPressMenu(
447-
longPressActions = availableActions.map { it.buildAction {} },
447+
longPressActions = availableActions.map { LongPressAction(it) {} },
448448
// whether the header is enabled or not shouldn't influence the result, so enable it
449449
// at random (but still deterministically)
450450
isHeaderEnabled = ((expectedShownActions + availableActions).sumOf { it.id } % 2) == 0,
@@ -603,8 +603,8 @@ class LongPressMenuTest {
603603
fun testEnabledDisabledActions() {
604604
setLongPressMenu(
605605
longPressActions = listOf(
606-
ShowDetails.buildAction(enabled = { true }) {},
607-
Enqueue.buildAction(enabled = { false }) {}
606+
LongPressAction(ShowDetails, enabled = { true }) {},
607+
LongPressAction(Enqueue, enabled = { false }) {}
608608
)
609609
)
610610
composeRule.onNodeWithText(ShowDetails.label)
@@ -620,7 +620,7 @@ class LongPressMenuTest {
620620
var dismissedCount = 0
621621
setLongPressMenu(
622622
onDismissRequest = { dismissedCount += 1 },
623-
longPressActions = listOf(PlayWithKodi.buildAction { pressedCount += 1 })
623+
longPressActions = listOf(LongPressAction(PlayWithKodi) { pressedCount += 1 })
624624
)
625625

626626
composeRule.onNodeWithText(PlayWithKodi.label)
@@ -634,7 +634,7 @@ class LongPressMenuTest {
634634
var dismissedCount = 0
635635
setLongPressMenu(
636636
onDismissRequest = { dismissedCount += 1 },
637-
longPressActions = listOf(BackgroundShuffled.buildAction { delay(500) })
637+
longPressActions = listOf(LongPressAction(BackgroundShuffled) { delay(500) })
638638
)
639639

640640
// test that the loading circle appears while the action is being performed; note that there
@@ -659,7 +659,7 @@ class LongPressMenuTest {
659659
setLongPressMenu(
660660
onDismissRequest = { dismissedCount += 1 },
661661
longPressActions = listOf(
662-
BackgroundShuffled.buildAction { throw Throwable("Whatever") }
662+
LongPressAction(BackgroundShuffled) { throw Throwable("Whatever") }
663663
)
664664
)
665665

0 commit comments

Comments
 (0)