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..608dc5d83b1cb8edf46f6551c0c8abc6c63581ef 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,14 +4,12 @@ |
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.test.util.ActivityUtils; |
+import org.chromium.chrome.browser.media.ui.MediaNotificationListener; |
import java.util.concurrent.TimeoutException; |
@@ -31,21 +29,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,51 +47,17 @@ 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); |
assertTrue("Run didn't restart playback", position < getRemotePositionMs()); |
} |
- |
- /** |
- * Test select (pressing the body) on the notification. |
- */ |
- @Feature({"VideoFling"}) |
- @LargeTest |
- public void testNotificationSelect() throws InterruptedException, TimeoutException { |
- 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); |
- |
- ExpandedControllerActivity fullscreenControls = ActivityUtils.waitForActivityWithTimeout( |
- getInstrumentation(), |
- ExpandedControllerActivity.class, new Runnable() { |
- @Override |
- public void run() { |
- try { |
- service.getPendingIntent(ListenerService.ACTION_ID_SELECT).send(); |
- } catch (CanceledException e) { |
- fail(); |
- } |
- } |
- }, MAX_VIEW_TIME_MS); |
- assertNotNull("No expanded controller activity", fullscreenControls); |
- View rootView = fullscreenControls.findViewById(android.R.id.content); |
- assertNotNull("No root view for fullscreen controls", rootView); |
- assertEquals("Fullscreen controls not shown", View.VISIBLE, rootView.getVisibility()); |
- } |
} |