| Index: chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationButtonComputationTest.java
|
| diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationButtonComputationTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationButtonComputationTest.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..58c2ba41a9adf79f87bc45c56bcee85f42325bf8
|
| --- /dev/null
|
| +++ b/chrome/android/junit/src/org/chromium/chrome/browser/media/ui/MediaNotificationButtonComputationTest.java
|
| @@ -0,0 +1,96 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.chrome.browser.media.ui;
|
| +
|
| +import static org.junit.Assert.assertEquals;
|
| +
|
| +import org.junit.Test;
|
| +import org.junit.runner.RunWith;
|
| +import org.robolectric.annotation.Config;
|
| +
|
| +import org.chromium.base.test.util.Feature;
|
| +import org.chromium.blink.mojom.MediaSessionAction;
|
| +import org.chromium.testing.local.LocalRobolectricTestRunner;
|
| +
|
| +import java.util.ArrayList;
|
| +
|
| +/**
|
| + * Robolectric tests for compact view button computation in {@link MediaNotificationManager}.
|
| + */
|
| +@RunWith(LocalRobolectricTestRunner.class)
|
| +@Config
|
| +public class MediaNotificationButtonComputationTest {
|
| + @Test
|
| + @Feature({"MediaNotification"})
|
| + public void testLessThanThreeActionsWillBeAllShownInCompactView() {
|
| + ArrayList<Integer> actions = new ArrayList<>();
|
| + actions.add(MediaSessionAction.NEXT_TRACK);
|
| + actions.add(MediaSessionAction.SEEK_FORWARD);
|
| + actions.add(MediaSessionAction.PLAY);
|
| +
|
| + int[] compactViewActions =
|
| + MediaNotificationManager.computeCompactViewActionIndices(actions);
|
| +
|
| + assertEquals(3, compactViewActions.length);
|
| + assertEquals(0, compactViewActions[0]);
|
| + assertEquals(1, compactViewActions[1]);
|
| + assertEquals(2, compactViewActions[2]);
|
| + }
|
| +
|
| + @Test
|
| + @Feature({"MediaNotification"})
|
| + public void testCompactViewPrefersActionPairs_SwitchTrack() {
|
| + ArrayList<Integer> actions = new ArrayList<>();
|
| + actions.add(MediaSessionAction.PREVIOUS_TRACK);
|
| + actions.add(MediaSessionAction.NEXT_TRACK);
|
| + actions.add(MediaSessionAction.SEEK_FORWARD);
|
| + actions.add(MediaSessionAction.PLAY);
|
| +
|
| + int[] compactViewActions =
|
| + MediaNotificationManager.computeCompactViewActionIndices(actions);
|
| +
|
| + assertEquals(3, compactViewActions.length);
|
| + assertEquals(0, compactViewActions[0]);
|
| + assertEquals(3, compactViewActions[1]);
|
| + assertEquals(1, compactViewActions[2]);
|
| + }
|
| +
|
| + @Test
|
| + @Feature({"MediaNotification"})
|
| + public void testCompactViewPrefersActionPairs_Seek() {
|
| + ArrayList<Integer> actions = new ArrayList<>();
|
| + actions.add(MediaSessionAction.NEXT_TRACK);
|
| + actions.add(MediaSessionAction.SEEK_BACKWARD);
|
| + actions.add(MediaSessionAction.SEEK_FORWARD);
|
| + actions.add(MediaSessionAction.PLAY);
|
| +
|
| + int[] compactViewActions =
|
| + MediaNotificationManager.computeCompactViewActionIndices(actions);
|
| +
|
| + assertEquals(3, compactViewActions.length);
|
| + assertEquals(1, compactViewActions[0]);
|
| + assertEquals(3, compactViewActions[1]);
|
| + assertEquals(2, compactViewActions[2]);
|
| + }
|
| +
|
| + @Test
|
| + @Feature({"MediaNotification"})
|
| + public void testCompactViewPreferSwitchTrackWhenBothPairsExist() {
|
| + ArrayList<Integer> actions = new ArrayList<>();
|
| + actions.add(MediaSessionAction.PREVIOUS_TRACK);
|
| + actions.add(MediaSessionAction.NEXT_TRACK);
|
| + actions.add(MediaSessionAction.SEEK_BACKWARD);
|
| + actions.add(MediaSessionAction.SEEK_FORWARD);
|
| + actions.add(MediaSessionAction.PLAY);
|
| +
|
| + int[] compactViewActions =
|
| + MediaNotificationManager.computeCompactViewActionIndices(actions);
|
| +
|
| + assertEquals(3, compactViewActions.length);
|
| + assertEquals(0, compactViewActions[0]);
|
| + assertEquals(4, compactViewActions[1]);
|
| + assertEquals(1, compactViewActions[2]);
|
| + }
|
| +}
|
|
|