| Index: chrome/android/javatests/src/org/chromium/chrome/browser/media/remote/CastNotificationTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/media/remote/CastNotificationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/media/remote/CastNotificationTest.java
|
| index c4284fe1350230c4cebf367041b5eeadccb91714..416df196d96afffeead8f2a7e1110f714a157087 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/media/remote/CastNotificationTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/media/remote/CastNotificationTest.java
|
| @@ -4,13 +4,13 @@
|
|
|
| package org.chromium.chrome.browser.media.remote;
|
|
|
| -import android.app.PendingIntent.CanceledException;
|
| import android.test.suitebuilder.annotation.LargeTest;
|
| import android.view.View;
|
|
|
| +import org.chromium.base.ThreadUtils;
|
| import org.chromium.base.test.util.Feature;
|
| -import org.chromium.chrome.browser.media.remote.NotificationTransportControl.ListenerService;
|
| import org.chromium.chrome.browser.media.remote.RemoteVideoInfo.PlayerState;
|
| +import org.chromium.chrome.browser.media.ui.MediaNotificationListener;
|
| import org.chromium.chrome.test.util.ActivityUtils;
|
|
|
| import java.util.concurrent.TimeoutException;
|
| @@ -31,21 +31,16 @@ public class CastNotificationTest extends CastTestBase {
|
| castDefaultVideoFromPage(DEFAULT_VIDEO_PAGE);
|
|
|
| // Get the notification
|
| - NotificationTransportControl notificationTransportControl = waitForCastNotification();
|
| - assertNotNull("No notificationTransportControl", notificationTransportControl);
|
| - // We can't actually click the notification's buttons, since they are owned by a different
|
| - // process and hence is not accessible through instrumentation, so send the stop event
|
| - // instead.
|
| - NotificationTransportControl.ListenerService service =
|
| - waitForCastNotificationService(notificationTransportControl);
|
| - assertNotNull("No notification service", service);
|
| -
|
| - try {
|
| - service.getPendingIntent(ListenerService.ACTION_ID_PAUSE).send();
|
| - } catch (CanceledException e) {
|
| - fail();
|
| - }
|
| - assertTrue("Not paused", waitForState(PlayerState.PAUSED));
|
| + final CastNotificationControl notificationControl = waitForCastNotification();
|
| + assertNotNull("No notificationTransportControl", notificationControl);
|
| + // Send pause
|
| + ThreadUtils.runOnUiThread(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + notificationControl.onPause(MediaNotificationListener.ACTION_SOURCE_MEDIA_SESSION);
|
| + }
|
| + });
|
| + assertTrue("Not paused", waitForState(PlayerState.PAUSED, MAX_VIEW_TIME_MS));
|
|
|
| // The new position is sent in a separate message, so we have to wait a bit before
|
| // fetching it.
|
| @@ -54,12 +49,14 @@ public class CastNotificationTest extends CastTestBase {
|
| // Position should not change while paused
|
| Thread.sleep(PAUSE_TEST_TIME_MS);
|
| assertEquals("Pause didn't stop playback", position, getRemotePositionMs());
|
| - try {
|
| - service.getPendingIntent(ListenerService.ACTION_ID_PLAY).send();
|
| - } catch (CanceledException e) {
|
| - fail();
|
| - }
|
| - assertTrue("Not playing", waitForState(PlayerState.PLAYING));
|
| + // Send play
|
| + ThreadUtils.runOnUiThread(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + notificationControl.onPlay(MediaNotificationListener.ACTION_SOURCE_MEDIA_SESSION);
|
| + }
|
| + });
|
| + assertTrue("Not playing", waitForState(PlayerState.PLAYING, MAX_VIEW_TIME_MS));
|
|
|
| // Should now be running again.
|
| Thread.sleep(PAUSE_TEST_TIME_MS);
|
| @@ -75,25 +72,21 @@ public class CastNotificationTest extends CastTestBase {
|
| castDefaultVideoFromPage(DEFAULT_VIDEO_PAGE);
|
|
|
| // Get the notification
|
| - NotificationTransportControl notificationTransportControl = waitForCastNotification();
|
| - assertNotNull("No notificationTransportControl", notificationTransportControl);
|
| - // We can't actually click the notification's buttons, since they are owned by a different
|
| - // process and hence is not accessible through instrumentation, so send the select event
|
| - // instead.
|
| - final NotificationTransportControl.ListenerService service =
|
| - waitForCastNotificationService(notificationTransportControl);
|
| - assertNotNull("No notification service", service);
|
| -
|
| + final CastNotificationControl notificationControl = waitForCastNotification();
|
| + assertNotNull("No notificationTransportControl", notificationControl);
|
| ExpandedControllerActivity fullscreenControls = ActivityUtils.waitForActivityWithTimeout(
|
| getInstrumentation(),
|
| ExpandedControllerActivity.class, new Runnable() {
|
| - @Override
|
| + @Override
|
| public void run() {
|
| - try {
|
| - service.getPendingIntent(ListenerService.ACTION_ID_SELECT).send();
|
| - } catch (CanceledException e) {
|
| - fail();
|
| - }
|
| + // Send play
|
| + ThreadUtils.runOnUiThread(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + notificationControl.onSelect(
|
| + MediaNotificationListener.ACTION_SOURCE_MEDIA_SESSION);
|
| + }
|
| + });
|
| }
|
| }, MAX_VIEW_TIME_MS);
|
| assertNotNull("No expanded controller activity", fullscreenControls);
|
|
|