Skip to content

Commit e851a14

Browse files
toniheicopybara-github
authored andcommittedOct 17, 2024
Add slots to CommandButton
These allow to define preferences for where a button should be displayed. PiperOrigin-RevId: 686938126
1 parent 8cb558e commit e851a14

File tree

2 files changed

+304
-7
lines changed

2 files changed

+304
-7
lines changed
 

‎libraries/session/src/main/java/androidx/media3/session/CommandButton.java

+171-7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import androidx.media3.common.util.Util;
3333
import com.google.common.base.Objects;
3434
import com.google.common.collect.ImmutableList;
35+
import com.google.common.primitives.ImmutableIntArray;
3536
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3637
import com.google.errorprone.annotations.CheckReturnValue;
3738
import java.lang.annotation.Documented;
@@ -411,17 +412,68 @@ public final class CommandButton {
411412
*/
412413
@UnstableApi public static final int ICON_FEED = 0xe0e5;
413414

415+
// TODO: b/332877990 - Stabilize these constants and other slot APIs
416+
/**
417+
* A slot at which a button can be displayed in a UI surface. Must be one of the {@code
418+
* CommandButton.SLOT_} constants.
419+
*/
420+
@UnstableApi
421+
@Documented
422+
@Retention(RetentionPolicy.SOURCE)
423+
@Target(TYPE_USE)
424+
@IntDef({
425+
SLOT_CENTRAL,
426+
SLOT_BACK,
427+
SLOT_FORWARD,
428+
SLOT_BACK_SECONDARY,
429+
SLOT_FORWARD_SECONDARY,
430+
SLOT_OVERFLOW
431+
})
432+
public @interface Slot {}
433+
434+
/** A central slot in a playback control UI, most commonly used for play or pause actions. */
435+
@UnstableApi public static final int SLOT_CENTRAL = 1;
436+
437+
/**
438+
* A slot in a playback control UI for backward-directed playback actions, most commonly used for
439+
* previous or rewind actions.
440+
*/
441+
@UnstableApi public static final int SLOT_BACK = 2;
442+
443+
/**
444+
* A slot in a playback control UI for forward-directed playback actions, most commonly used for
445+
* next or fast-forward actions.
446+
*/
447+
@UnstableApi public static final int SLOT_FORWARD = 3;
448+
449+
/**
450+
* A slot in a playback control UI for secondary backward-directed playback actions, most commonly
451+
* used for previous or rewind actions.
452+
*/
453+
@UnstableApi public static final int SLOT_BACK_SECONDARY = 4;
454+
455+
/**
456+
* A slot in a playback control UI for secondary forward-directed playback actions, most commonly
457+
* used for next or fast-forward actions.
458+
*/
459+
@UnstableApi public static final int SLOT_FORWARD_SECONDARY = 5;
460+
461+
/** A slot in a playback control UI for additional actions that don't fit into other slots. */
462+
@UnstableApi public static final int SLOT_OVERFLOW = 6;
463+
414464
/** A builder for {@link CommandButton}. */
415465
public static final class Builder {
416466

467+
private final @Icon int icon;
468+
417469
@Nullable private SessionCommand sessionCommand;
418470
private @Player.Command int playerCommand;
419-
private @Icon int icon;
420471
@DrawableRes private int iconResId;
421472
@Nullable private Uri iconUri;
422473
private CharSequence displayName;
423474
private Bundle extras;
424475
private boolean enabled;
476+
@Nullable private ImmutableIntArray slots;
425477

426478
/**
427479
* [will be deprecated] Use {@link #Builder(int)} instead to define the {@link Icon} for this
@@ -451,7 +503,6 @@ public Builder(@Icon int icon) {
451503
displayName = "";
452504
extras = Bundle.EMPTY;
453505
playerCommand = Player.COMMAND_INVALID;
454-
icon = ICON_UNDEFINED;
455506
enabled = true;
456507
}
457508

@@ -581,13 +632,63 @@ public Builder setExtras(Bundle extras) {
581632
return this;
582633
}
583634

635+
/**
636+
* Sets the allowed {@link Slot} positions for this button.
637+
*
638+
* <p>The button is only allowed in the defined slots. If none of the slots can display the
639+
* button, either because the slots do not exist, are already occupied or the UI surface does
640+
* not allow the specific type of button in these slots, the button will not be displayed at
641+
* all.
642+
*
643+
* <p>When multiple slots are provided, they define a preference order. The button will be
644+
* placed in the first slot in the list that exists, isn't already occupied and that allows this
645+
* type of button.
646+
*
647+
* <p>When not specified, the default value depends on the associated {@link #setPlayerCommand
648+
* player command} and the {@link Icon} set in the constructor:
649+
*
650+
* <ul>
651+
* <li>{@link Player#COMMAND_PLAY_PAUSE} and/or {@link #ICON_PLAY}, {@link #ICON_PAUSE}:
652+
* {@link #SLOT_CENTRAL}
653+
* <li>{@link Player#COMMAND_SEEK_TO_PREVIOUS}, {@link
654+
* Player#COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM}, {@link Player#COMMAND_SEEK_BACK} and/or
655+
* {@link #ICON_PREVIOUS}, {@link #ICON_SKIP_BACK}, {@link #ICON_REWIND}: {@link
656+
* #SLOT_BACK}
657+
* <li>{@link Player#COMMAND_SEEK_TO_NEXT}, {@link Player#COMMAND_SEEK_TO_NEXT_MEDIA_ITEM},
658+
* {@link Player#COMMAND_SEEK_FORWARD} and/or {@link #ICON_NEXT}, {@link
659+
* #ICON_SKIP_FORWARD}, {@link #ICON_FAST_FORWARD}: {@link #SLOT_FORWARD}
660+
* <li>Anything else: {@link #SLOT_OVERFLOW}
661+
* </ul>
662+
*
663+
* @param slots The list of allowed {@link Slot} positions. Must not be empty.
664+
* @return This builder for chaining.
665+
*/
666+
@UnstableApi
667+
@CanIgnoreReturnValue
668+
public Builder setSlots(@Slot int... slots) {
669+
checkArgument(slots.length != 0);
670+
this.slots = ImmutableIntArray.copyOf(slots);
671+
return this;
672+
}
673+
584674
/** Builds a {@link CommandButton}. */
585675
public CommandButton build() {
586676
checkState(
587677
(sessionCommand == null) != (playerCommand == Player.COMMAND_INVALID),
588678
"Exactly one of sessionCommand and playerCommand should be set");
679+
if (slots == null) {
680+
slots = ImmutableIntArray.of(getDefaultSlot(playerCommand, icon));
681+
}
589682
return new CommandButton(
590-
sessionCommand, playerCommand, icon, iconResId, iconUri, displayName, extras, enabled);
683+
sessionCommand,
684+
playerCommand,
685+
icon,
686+
iconResId,
687+
iconUri,
688+
displayName,
689+
extras,
690+
enabled,
691+
slots);
591692
}
592693
}
593694

@@ -630,6 +731,19 @@ public CommandButton build() {
630731
*/
631732
@UnstableApi public final Bundle extras;
632733

734+
/**
735+
* The allowed {@link Slot} positions for this button.
736+
*
737+
* <p>The button is only allowed in the defined slots. If none of the slots can display the
738+
* button, either because the slots do not exist, are already occupied or the UI surface does not
739+
* allow the specific type of button in these slots, the button will not be displayed at all.
740+
*
741+
* <p>When multiple slots are provided, they define a preference order. The button will be placed
742+
* in the first slot in the list that exists, isn't already occupied and that allows this type of
743+
* button.
744+
*/
745+
@UnstableApi public final ImmutableIntArray slots;
746+
633747
/**
634748
* Whether the button is enabled.
635749
*
@@ -647,7 +761,8 @@ private CommandButton(
647761
@Nullable Uri iconUri,
648762
CharSequence displayName,
649763
Bundle extras,
650-
boolean enabled) {
764+
boolean enabled,
765+
ImmutableIntArray slots) {
651766
this.sessionCommand = sessionCommand;
652767
this.playerCommand = playerCommand;
653768
this.icon = icon;
@@ -656,6 +771,7 @@ private CommandButton(
656771
this.displayName = displayName;
657772
this.extras = new Bundle(extras);
658773
this.isEnabled = enabled;
774+
this.slots = slots;
659775
}
660776

661777
/** Returns a copy with the new {@link #isEnabled} flag. */
@@ -675,7 +791,8 @@ private CommandButton(
675791
iconUri,
676792
displayName,
677793
new Bundle(extras),
678-
isEnabled);
794+
isEnabled,
795+
slots);
679796
}
680797

681798
/** Checks the given command button for equality while ignoring {@link #extras}. */
@@ -694,13 +811,14 @@ public boolean equals(@Nullable Object obj) {
694811
&& iconResId == button.iconResId
695812
&& Objects.equal(iconUri, button.iconUri)
696813
&& TextUtils.equals(displayName, button.displayName)
697-
&& isEnabled == button.isEnabled;
814+
&& isEnabled == button.isEnabled
815+
&& slots.equals(button.slots);
698816
}
699817

700818
@Override
701819
public int hashCode() {
702820
return Objects.hashCode(
703-
sessionCommand, playerCommand, icon, iconResId, displayName, isEnabled, iconUri);
821+
sessionCommand, playerCommand, icon, iconResId, displayName, isEnabled, iconUri, slots);
704822
}
705823

706824
/**
@@ -747,6 +865,7 @@ public int hashCode() {
747865
private static final String FIELD_ENABLED = Util.intToStringMaxRadix(5);
748866
private static final String FIELD_ICON_URI = Util.intToStringMaxRadix(6);
749867
private static final String FIELD_ICON = Util.intToStringMaxRadix(7);
868+
private static final String FIELD_SLOTS = Util.intToStringMaxRadix(8);
750869

751870
@UnstableApi
752871
public Bundle toBundle() {
@@ -775,6 +894,9 @@ public Bundle toBundle() {
775894
if (!isEnabled) {
776895
bundle.putBoolean(FIELD_ENABLED, isEnabled);
777896
}
897+
if (slots.length() != 1 || slots.get(0) != SLOT_OVERFLOW) {
898+
bundle.putIntArray(FIELD_SLOTS, slots.toArray());
899+
}
778900
return bundle;
779901
}
780902

@@ -806,6 +928,9 @@ public static CommandButton fromBundle(Bundle bundle, int sessionInterfaceVersio
806928
sessionInterfaceVersion < 3 || bundle.getBoolean(FIELD_ENABLED, /* defaultValue= */ true);
807929
@Nullable Uri iconUri = bundle.getParcelable(FIELD_ICON_URI);
808930
@Icon int icon = bundle.getInt(FIELD_ICON, /* defaultValue= */ ICON_UNDEFINED);
931+
@Nullable
932+
@Slot
933+
int[] slots = bundle.getIntArray(FIELD_SLOTS);
809934
Builder builder = new Builder(icon, iconResId);
810935
if (sessionCommand != null) {
811936
builder.setSessionCommand(sessionCommand);
@@ -820,6 +945,7 @@ public static CommandButton fromBundle(Bundle bundle, int sessionInterfaceVersio
820945
.setDisplayName(displayName)
821946
.setExtras(extras == null ? Bundle.EMPTY : extras)
822947
.setEnabled(enabled)
948+
.setSlots(slots == null ? new int[] {SLOT_OVERFLOW} : slots)
823949
.build();
824950
}
825951

@@ -983,4 +1109,42 @@ public static int getIconResIdForIconConstant(@Icon int icon) {
9831109
return 0;
9841110
}
9851111
}
1112+
1113+
/**
1114+
* Returns the default {@link Slot} for a button.
1115+
*
1116+
* @param playerCommand The {@link Player.Command} associated with this button.
1117+
* @param icon The {@link Icon} of this button.
1118+
* @return The default {@link Slot} for this button.
1119+
*/
1120+
@UnstableApi
1121+
public static @Slot int getDefaultSlot(@Player.Command int playerCommand, @Icon int icon) {
1122+
if (playerCommand == Player.COMMAND_PLAY_PAUSE || icon == ICON_PLAY || icon == ICON_PAUSE) {
1123+
return SLOT_CENTRAL;
1124+
} else if (playerCommand == Player.COMMAND_SEEK_BACK
1125+
|| playerCommand == Player.COMMAND_SEEK_TO_PREVIOUS
1126+
|| playerCommand == Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
1127+
|| icon == ICON_PREVIOUS
1128+
|| icon == ICON_REWIND
1129+
|| icon == ICON_SKIP_BACK
1130+
|| icon == ICON_SKIP_BACK_5
1131+
|| icon == ICON_SKIP_BACK_10
1132+
|| icon == ICON_SKIP_BACK_15
1133+
|| icon == ICON_SKIP_BACK_30) {
1134+
return SLOT_BACK;
1135+
} else if (playerCommand == Player.COMMAND_SEEK_FORWARD
1136+
|| playerCommand == Player.COMMAND_SEEK_TO_NEXT
1137+
|| playerCommand == Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM
1138+
|| icon == ICON_NEXT
1139+
|| icon == ICON_FAST_FORWARD
1140+
|| icon == ICON_SKIP_FORWARD
1141+
|| icon == ICON_SKIP_FORWARD_5
1142+
|| icon == ICON_SKIP_FORWARD_10
1143+
|| icon == ICON_SKIP_FORWARD_15
1144+
|| icon == ICON_SKIP_FORWARD_30) {
1145+
return SLOT_FORWARD;
1146+
} else {
1147+
return SLOT_OVERFLOW;
1148+
}
1149+
}
9861150
}

‎libraries/session/src/test/java/androidx/media3/session/CommandButtonTest.java

+133
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import androidx.media3.common.Player;
2424
import androidx.test.ext.junit.runners.AndroidJUnit4;
2525
import com.google.common.collect.ImmutableList;
26+
import com.google.common.primitives.ImmutableIntArray;
2627
import org.junit.Test;
2728
import org.junit.runner.RunWith;
2829

@@ -172,13 +173,15 @@ public void equals() {
172173
.setIconResId(R.drawable.media3_notification_small_icon)
173174
.setIconUri(Uri.parse("content://test"))
174175
.setPlayerCommand(Player.COMMAND_SEEK_TO_NEXT)
176+
.setSlots(CommandButton.SLOT_FORWARD, CommandButton.SLOT_CENTRAL)
175177
.build())
176178
.isEqualTo(
177179
new CommandButton.Builder(CommandButton.ICON_UNDEFINED)
178180
.setDisplayName("button")
179181
.setIconResId(R.drawable.media3_notification_small_icon)
180182
.setIconUri(Uri.parse("content://test"))
181183
.setPlayerCommand(Player.COMMAND_SEEK_TO_NEXT)
184+
.setSlots(CommandButton.SLOT_FORWARD, CommandButton.SLOT_CENTRAL)
182185
.build());
183186
}
184187

@@ -189,6 +192,7 @@ public void equals_minimalDifference_notEqual() {
189192
.setDisplayName("button")
190193
.setIconResId(R.drawable.media3_notification_small_icon)
191194
.setPlayerCommand(Player.COMMAND_SEEK_TO_NEXT)
195+
.setSlots(CommandButton.SLOT_BACK)
192196
.build();
193197

194198
assertThat(button)
@@ -199,20 +203,23 @@ public void equals_minimalDifference_notEqual() {
199203
.setDisplayName("button2")
200204
.setIconResId(R.drawable.media3_notification_small_icon)
201205
.setPlayerCommand(Player.COMMAND_SEEK_TO_NEXT)
206+
.setSlots(CommandButton.SLOT_BACK)
202207
.build());
203208
assertThat(button)
204209
.isNotEqualTo(
205210
new CommandButton.Builder(CommandButton.ICON_UNDEFINED)
206211
.setPlayerCommand(Player.COMMAND_SEEK_TO_PREVIOUS)
207212
.setDisplayName("button")
208213
.setIconResId(R.drawable.media3_notification_small_icon)
214+
.setSlots(CommandButton.SLOT_BACK)
209215
.build());
210216
assertThat(button)
211217
.isNotEqualTo(
212218
new CommandButton.Builder(CommandButton.ICON_UNDEFINED)
213219
.setIconResId(R.drawable.media3_icon_play)
214220
.setDisplayName("button")
215221
.setPlayerCommand(Player.COMMAND_SEEK_TO_NEXT)
222+
.setSlots(CommandButton.SLOT_BACK)
216223
.build());
217224
assertThat(button)
218225
.isNotEqualTo(
@@ -221,13 +228,15 @@ public void equals_minimalDifference_notEqual() {
221228
.setDisplayName("button")
222229
.setIconResId(R.drawable.media3_notification_small_icon)
223230
.setPlayerCommand(Player.COMMAND_SEEK_TO_NEXT)
231+
.setSlots(CommandButton.SLOT_BACK)
224232
.build());
225233
assertThat(button)
226234
.isNotEqualTo(
227235
new CommandButton.Builder(CommandButton.ICON_UNDEFINED)
228236
.setSessionCommand(new SessionCommand(SessionCommand.COMMAND_CODE_LIBRARY_GET_ITEM))
229237
.setDisplayName("button")
230238
.setIconResId(R.drawable.media3_notification_small_icon)
239+
.setSlots(CommandButton.SLOT_BACK)
231240
.build());
232241
assertThat(button)
233242
.isNotEqualTo(
@@ -236,13 +245,23 @@ public void equals_minimalDifference_notEqual() {
236245
.setIconResId(R.drawable.media3_notification_small_icon)
237246
.setIconUri(Uri.parse("content://test"))
238247
.setPlayerCommand(Player.COMMAND_SEEK_TO_NEXT)
248+
.setSlots(CommandButton.SLOT_BACK)
239249
.build());
240250
assertThat(button)
241251
.isNotEqualTo(
242252
new CommandButton.Builder(CommandButton.ICON_NEXT)
243253
.setDisplayName("button")
244254
.setIconResId(R.drawable.media3_notification_small_icon)
245255
.setPlayerCommand(Player.COMMAND_SEEK_TO_NEXT)
256+
.setSlots(CommandButton.SLOT_BACK)
257+
.build());
258+
assertThat(button)
259+
.isNotEqualTo(
260+
new CommandButton.Builder(CommandButton.ICON_UNDEFINED)
261+
.setDisplayName("button")
262+
.setIconResId(R.drawable.media3_notification_small_icon)
263+
.setPlayerCommand(Player.COMMAND_SEEK_TO_NEXT)
264+
.setSlots(CommandButton.SLOT_FORWARD)
246265
.build());
247266
}
248267

@@ -355,6 +374,118 @@ public void build_withoutSessionOrPlayerCommandSet_throwsIllegalStateException()
355374
assertThrows(IllegalStateException.class, builder::build);
356375
}
357376

377+
@Test
378+
public void build_withoutSlots_assignsDefaultSlots() {
379+
assertThat(
380+
new CommandButton.Builder(CommandButton.ICON_UNDEFINED)
381+
.setPlayerCommand(Player.COMMAND_PLAY_PAUSE)
382+
.build()
383+
.slots)
384+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_CENTRAL));
385+
assertThat(
386+
new CommandButton.Builder(CommandButton.ICON_PLAY)
387+
.setPlayerCommand(Player.COMMAND_PREPARE)
388+
.build()
389+
.slots)
390+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_CENTRAL));
391+
assertThat(
392+
new CommandButton.Builder(CommandButton.ICON_PAUSE)
393+
.setPlayerCommand(Player.COMMAND_STOP)
394+
.build()
395+
.slots)
396+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_CENTRAL));
397+
assertThat(
398+
new CommandButton.Builder(CommandButton.ICON_UNDEFINED)
399+
.setPlayerCommand(Player.COMMAND_SEEK_BACK)
400+
.build()
401+
.slots)
402+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_BACK));
403+
assertThat(
404+
new CommandButton.Builder(CommandButton.ICON_UNDEFINED)
405+
.setPlayerCommand(Player.COMMAND_SEEK_TO_PREVIOUS)
406+
.build()
407+
.slots)
408+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_BACK));
409+
assertThat(
410+
new CommandButton.Builder(CommandButton.ICON_UNDEFINED)
411+
.setPlayerCommand(Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM)
412+
.build()
413+
.slots)
414+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_BACK));
415+
assertThat(
416+
new CommandButton.Builder(CommandButton.ICON_PREVIOUS)
417+
.setPlayerCommand(Player.COMMAND_SEEK_TO_MEDIA_ITEM)
418+
.build()
419+
.slots)
420+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_BACK));
421+
assertThat(
422+
new CommandButton.Builder(CommandButton.ICON_SKIP_BACK)
423+
.setPlayerCommand(Player.COMMAND_SEEK_TO_MEDIA_ITEM)
424+
.build()
425+
.slots)
426+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_BACK));
427+
assertThat(
428+
new CommandButton.Builder(CommandButton.ICON_SKIP_BACK_10)
429+
.setPlayerCommand(Player.COMMAND_SEEK_TO_MEDIA_ITEM)
430+
.build()
431+
.slots)
432+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_BACK));
433+
assertThat(
434+
new CommandButton.Builder(CommandButton.ICON_REWIND)
435+
.setPlayerCommand(Player.COMMAND_SEEK_TO_MEDIA_ITEM)
436+
.build()
437+
.slots)
438+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_BACK));
439+
assertThat(
440+
new CommandButton.Builder(CommandButton.ICON_UNDEFINED)
441+
.setPlayerCommand(Player.COMMAND_SEEK_FORWARD)
442+
.build()
443+
.slots)
444+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_FORWARD));
445+
assertThat(
446+
new CommandButton.Builder(CommandButton.ICON_UNDEFINED)
447+
.setPlayerCommand(Player.COMMAND_SEEK_TO_NEXT)
448+
.build()
449+
.slots)
450+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_FORWARD));
451+
assertThat(
452+
new CommandButton.Builder(CommandButton.ICON_UNDEFINED)
453+
.setPlayerCommand(Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM)
454+
.build()
455+
.slots)
456+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_FORWARD));
457+
assertThat(
458+
new CommandButton.Builder(CommandButton.ICON_NEXT)
459+
.setPlayerCommand(Player.COMMAND_SEEK_TO_MEDIA_ITEM)
460+
.build()
461+
.slots)
462+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_FORWARD));
463+
assertThat(
464+
new CommandButton.Builder(CommandButton.ICON_SKIP_FORWARD)
465+
.setPlayerCommand(Player.COMMAND_SEEK_TO_MEDIA_ITEM)
466+
.build()
467+
.slots)
468+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_FORWARD));
469+
assertThat(
470+
new CommandButton.Builder(CommandButton.ICON_SKIP_FORWARD_10)
471+
.setPlayerCommand(Player.COMMAND_SEEK_TO_MEDIA_ITEM)
472+
.build()
473+
.slots)
474+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_FORWARD));
475+
assertThat(
476+
new CommandButton.Builder(CommandButton.ICON_FAST_FORWARD)
477+
.setPlayerCommand(Player.COMMAND_SEEK_TO_MEDIA_ITEM)
478+
.build()
479+
.slots)
480+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_FORWARD));
481+
assertThat(
482+
new CommandButton.Builder(CommandButton.ICON_SHUFFLE_ON)
483+
.setPlayerCommand(Player.COMMAND_SET_SHUFFLE_MODE)
484+
.build()
485+
.slots)
486+
.isEqualTo(ImmutableIntArray.of(CommandButton.SLOT_OVERFLOW));
487+
}
488+
358489
@Test
359490
public void fromBundle_afterToBundle_returnsEqualInstance() {
360491
Bundle extras = new Bundle();
@@ -367,6 +498,7 @@ public void fromBundle_afterToBundle_returnsEqualInstance() {
367498
.setIconUri(Uri.parse("content://test"))
368499
.setExtras(extras)
369500
.setSessionCommand(new SessionCommand(SessionCommand.COMMAND_CODE_SESSION_SET_RATING))
501+
.setSlots(CommandButton.SLOT_OVERFLOW, CommandButton.SLOT_BACK)
370502
.build();
371503
CommandButton buttonWithPlayerCommand =
372504
new CommandButton.Builder(CommandButton.ICON_CLOSED_CAPTIONS)
@@ -376,6 +508,7 @@ public void fromBundle_afterToBundle_returnsEqualInstance() {
376508
.setIconUri(Uri.parse("content://test"))
377509
.setExtras(extras)
378510
.setPlayerCommand(Player.COMMAND_GET_METADATA)
511+
.setSlots(CommandButton.SLOT_CENTRAL)
379512
.build();
380513
CommandButton buttonWithDefaultValues =
381514
new CommandButton.Builder(CommandButton.ICON_UNDEFINED)

0 commit comments

Comments
 (0)
Please sign in to comment.